Example usage for com.intellij.openapi.ui DialogWrapper OK_EXIT_CODE

List of usage examples for com.intellij.openapi.ui DialogWrapper OK_EXIT_CODE

Introduction

In this page you can find the example usage for com.intellij.openapi.ui DialogWrapper OK_EXIT_CODE.

Prototype

int OK_EXIT_CODE

To view the source code for com.intellij.openapi.ui DialogWrapper OK_EXIT_CODE.

Click Source Link

Document

The default exit code for "OK" action.

Usage

From source file:org.dubik.tasks.ui.actions.ExportToTextFileAction.java

License:Apache License

public void actionPerformed(AnActionEvent e) {
    ExportToFileForm form = new ExportToFileForm(getProject(e));
    TaskTreeModel model = getTreeController(e).getTreeModel();

    OutputStream os = new ByteArrayOutputStream();
    writeTasks(model, os);//from  ww  w .  j  av a 2  s.c  o  m

    form.show();
    if (form.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
        if (!form.isExportToClipboard()) {
            File file = form.getFile();
            if (file.exists()) {
                if (JOptionPane.showConfirmDialog(null, TasksBundle.message("export.overwrite"),
                        TasksBundle.message("export.overwrite.title"),
                        JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                    writeTasks(file, os.toString());
                }
            } else {
                writeTasks(file, os.toString());
            }
        } else {
            new TextTransfer().setClipboardContent(os.toString());
        }
    }
}

From source file:org.dubik.tasks.ui.actions.NewChangeListAction.java

License:Apache License

public void actionPerformed(AnActionEvent e) {
    TaskController controller = getController(e);
    List<ITask> selectedTasks = controller.getSelectedTasks();

    String changelist = generateChangelistTitle(selectedTasks);

    NewChangelistForm newChangelistDlg = new NewChangelistForm(getProject(e));
    newChangelistDlg.setName(changelist);
    newChangelistDlg.show();/*from  www  . j  a va 2 s .  c o  m*/

    if (newChangelistDlg.getExitCode() == DialogWrapper.OK_EXIT_CODE
            && newChangelistDlg.getName().length() > 0) {
        ChangeListManager changeListManager = ChangeListManager.getInstance(getProject(e));
        LocalChangeList list = changeListManager.addChangeList(newChangelistDlg.getName(),
                newChangelistDlg.getDescription());

        if (newChangelistDlg.isNewChangelistActive()) {
            changeListManager.setDefaultChangeList(list);
        }
    }
}

From source file:org.dylanfoundry.deft.library.LibraryAttachHandler.java

License:Apache License

@Nullable
public static NewLibraryConfiguration chooseLibrary(final @NotNull Project project,
        JComponent parentComponent) {
    LibraryAttachDialog dialog = new LibraryAttachDialog(project);
    dialog.setTitle("Attach Library");
    dialog.show();/* www.  j  a va2  s  . c  o m*/
    if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
        return null;
    }

    NewLibraryConfiguration configuration = attachLibrary(project, dialog.getRegistryEntries());
    if (configuration == null) {
        Messages.showErrorDialog(parentComponent, "No libraries attached", CommonBundle.getErrorTitle());
    }
    return configuration;
}

From source file:org.intellij.erlang.rebar.importWizard.RebarProjectImportBuilder.java

License:Apache License

@SuppressWarnings("DialogTitleCapitalization")
@Override/*from  ww  w .j a v a 2 s  .c o m*/
public boolean validate(Project current, Project dest) {
    if (!findIdeaModuleFiles(mySelectedOtpApps)) {
        return true;
    }
    final int resultCode = Messages.showYesNoCancelDialog(
            ApplicationInfoEx.getInstanceEx().getFullApplicationName() + " module files found:\n\n"
                    + StringUtil.join(mySelectedOtpApps, new Function<ImportedOtpApp, String>() {
                        public String fun(ImportedOtpApp importedOtpApp) {
                            final VirtualFile ideaModuleFile = importedOtpApp.getIdeaModuleFile();
                            return ideaModuleFile != null ? "    " + ideaModuleFile.getPath() + "\n" : "";
                        }
                    }, "") + "\nWould you like to reuse them?",
            "Module files found", Messages.getQuestionIcon());
    if (resultCode == DialogWrapper.OK_EXIT_CODE) {
        return true;
    } else if (resultCode == DialogWrapper.CANCEL_EXIT_CODE) {
        try {
            deleteIdeaModuleFiles(mySelectedOtpApps);
            return true;
        } catch (IOException e) {
            LOG.error(e);
            return false;
        }
    } else {
        return false;
    }
}

From source file:org.intellij.plugins.intelliLang.inject.AbstractLanguageInjectionSupport.java

License:Apache License

@Nullable
protected static BaseInjection showDefaultInjectionUI(final Project project, BaseInjection injection) {
    final BaseInjectionPanel panel = new BaseInjectionPanel(injection, project);
    panel.reset();/*from  w ww  .j  av a2 s. co m*/
    final DialogBuilder builder = new DialogBuilder(project);
    LanguageInjectionSupport support = InjectorUtils.findInjectionSupport(injection.getSupportId());
    if (support != null && support instanceof AbstractLanguageInjectionSupport) {
        builder.setHelpId(((AbstractLanguageInjectionSupport) support).getHelpId());
    }
    builder.addOkAction();
    builder.addCancelAction();
    builder.setDimensionServiceKey("#org.intellij.plugins.intelliLang.inject.config.ui.BaseInjectionDialog");
    builder.setCenterPanel(panel.getComponent());
    builder.setTitle(EditInjectionSettingsAction.EDIT_INJECTION_TITLE);
    builder.setOkOperation(new Runnable() {
        public void run() {
            try {
                panel.apply();
                builder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE);
            } catch (Exception e) {
                final Throwable cause = e.getCause();
                final String message = e.getMessage() + (cause != null ? "\n  " + cause.getMessage() : "");
                Messages.showErrorDialog(project, message, "Unable to Save");
            }
        }
    });
    if (builder.show() == DialogWrapper.OK_EXIT_CODE) {
        return injection;
    }
    return null;
}

From source file:org.intellij.plugins.intelliLang.inject.java.JavaLanguageInjectionSupport.java

License:Apache License

private static BaseInjection showInjectionUI(final Project project,
        final MethodParameterInjection methodParameterInjection) {
    final AbstractInjectionPanel panel = new MethodParameterPanel(methodParameterInjection, project);
    panel.reset();/*ww  w  .j  a  v  a  2 s.  c o m*/
    final DialogBuilder builder = new DialogBuilder(project);
    builder.setHelpId("reference.settings.injection.language.injection.settings.java.parameter");
    builder.addOkAction();
    builder.addCancelAction();
    builder.setCenterPanel(panel.getComponent());
    builder.setTitle(EditInjectionSettingsAction.EDIT_INJECTION_TITLE);
    builder.setOkOperation(new Runnable() {
        public void run() {
            panel.apply();
            builder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE);
        }
    });
    if (builder.show() == DialogWrapper.OK_EXIT_CODE) {
        return new BaseInjection(methodParameterInjection.getSupportId()).copyFrom(methodParameterInjection);
    }
    return null;
}

From source file:org.intellij.plugins.intelliLang.inject.xml.XmlLanguageInjectionSupport.java

License:Apache License

@Nullable
private static BaseInjection showInjectionUI(final Project project, final BaseInjection xmlInjection) {
    final DialogBuilder builder = new DialogBuilder(project);
    final AbstractInjectionPanel panel;
    if (xmlInjection instanceof XmlTagInjection) {
        panel = new XmlTagPanel((XmlTagInjection) xmlInjection, project);
        builder.setHelpId("reference.settings.injection.language.injection.settings.xml.tag");
    } else if (xmlInjection instanceof XmlAttributeInjection) {
        panel = new XmlAttributePanel((XmlAttributeInjection) xmlInjection, project);
        builder.setHelpId("reference.settings.injection.language.injection.settings.xml.attribute");
    } else//from   w  ww . j av a2 s.  co m
        throw new AssertionError();
    panel.reset();
    builder.addOkAction();
    builder.addCancelAction();
    builder.setCenterPanel(panel.getComponent());
    builder.setTitle(EditInjectionSettingsAction.EDIT_INJECTION_TITLE);
    builder.setOkOperation(new Runnable() {
        public void run() {
            panel.apply();
            builder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE);
        }
    });
    if (builder.show() == DialogWrapper.OK_EXIT_CODE) {
        return new AbstractTagInjection().copyFrom(xmlInjection);
    }
    return null;
}

From source file:org.jetbrains.android.actions.NewAndroidComponentAction.java

License:Apache License

@Override
public void actionPerformed(AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();

    final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
    if (view == null) {
        return;/*from  w  w w .  j  av  a 2 s .  c  om*/
    }

    final Module module = LangDataKeys.MODULE.getData(dataContext);

    if (module == null)
        return;

    final PsiDirectory dir = view.getOrChooseDirectory();
    if (dir == null)
        return;

    NewAndroidComponentDialog dialog = new NewAndroidComponentDialog(module, dir);
    dialog.show();
    if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
        return;
    }
    final PsiElement[] createdElements = dialog.getCreatedElements();

    for (PsiElement createdElement : createdElements) {
        view.selectElement(createdElement);
    }
}

From source file:org.jetbrains.android.refactoring.UnusedResourcesDialog.java

License:Apache License

@Override
protected void doAction() {
    myProcessor.setIncludeIds(myCbIncludeIds.isSelected());
    myProcessor.setPreviewUsages(isPreviewUsages());
    close(DialogWrapper.OK_EXIT_CODE);
    myProcessor.run();/*  w ww .  j ava 2  s  .  com*/
}

From source file:org.jetbrains.android.run.AndroidRunningState.java

License:Apache License

@Override
public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner)
        throws ExecutionException {
    myProcessHandler = new DefaultDebugProcessHandler();
    AndroidProcessText.attach(myProcessHandler);
    ConsoleView console;//from w w w .ja  v a2s.  co  m
    if (isDebugMode()) {
        Project project = myFacet.getModule().getProject();
        final TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
        console = builder.getConsole();
        if (console != null) {
            console.attachToProcess(myProcessHandler);
        }
    } else {
        console = myConfiguration.attachConsole(this, executor);
    }
    myConsole = console;

    if (myTargetChooser instanceof ManualTargetChooser) {

        final ExtendedDeviceChooserDialog chooser = new ExtendedDeviceChooserDialog(myFacet,
                mySupportMultipleDevices);
        chooser.show();
        if (chooser.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
            return null;
        }

        if (chooser.isToLaunchEmulator()) {
            final String selectedAvd = chooser.getSelectedAvd();
            if (selectedAvd == null) {
                return null;
            }
            myTargetChooser = new EmulatorTargetChooser(selectedAvd);
            myAvdName = selectedAvd;
        } else {
            final IDevice[] selectedDevices = chooser.getSelectedDevices();
            if (selectedDevices.length == 0) {
                return null;
            }
            myTargetDevices = selectedDevices;
        }
    }

    ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
        @Override
        public void run() {
            start(true);
        }
    });
    return new DefaultExecutionResult(console, myProcessHandler);
}