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:com.intellij.ui.ColorPicker.java

License:Apache License

@Nullable
public static Color showDialog(Component parent, String caption, Color preselectedColor, boolean enableOpacity,
        ColorPickerListener[] listeners, boolean opacityInPercent) {
    final ColorPickerDialog dialog = new ColorPickerDialog(parent, caption, preselectedColor, enableOpacity,
            listeners, opacityInPercent);
    dialog.show();//from   www . j  a  v  a  2s. c o m
    if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
        return dialog.getColor();
    }

    return null;
}

From source file:com.intellij.uiDesigner.propertyInspector.editors.ColorEditor.java

License:Apache License

public ColorEditor(String propertyName) {
    myPropertyName = propertyName;//  ww w .  ja  v a  2  s.  c  om
    myTextField.getTextField().setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
    myTextField.getTextField().setEditable(false);
    myTextField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            MyColorChooserDialog dialog = new MyColorChooserDialog(myProject);
            dialog.setSelectedValue(myValue);
            dialog.show();
            if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
                myValue = dialog.getSelectedValue();
                updateTextField();
            }
        }
    });
}

From source file:com.intellij.uiDesigner.propertyInspector.editors.FontEditor.java

License:Apache License

private void showFontEditorDialog() {
    FontEditorDialog dlg = new FontEditorDialog(myProject, myPropertyName);
    dlg.setValue(myValue);/*from  www  . j av  a2s .  co m*/
    dlg.show();
    if (dlg.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
        myValue = dlg.getValue();
        myTextField.setText(IntroFontProperty.descriptorToString(myValue));
        fireValueCommitted(true, false);
    }
}

From source file:com.intellij.uiDesigner.propertyInspector.editors.ListModelEditor.java

License:Apache License

private void openListEditorDialog(String[] value) {
    ListEditorDialog dlg = new ListEditorDialog(myLastComponent.getProject(), myPropertyName);
    dlg.setValue(value);//from  w  w w. j  a v a  2  s .  c  om
    dlg.show();
    if (dlg.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
        myLastValue = dlg.getValue();
        myTextField.setText(listValueToString(myLastValue));
        fireValueCommitted(true, false);
    }
}

From source file:com.intellij.uiDesigner.snapShooter.CreateSnapShotAction.java

License:Apache License

private static void runSnapShooterSession(final SnapShotClient client, final Project project,
        final PsiDirectory dir, final IdeView view) {
    try {//  w  ww . java2  s  .  c  o m
        client.suspendSwing();
    } catch (IOException e1) {
        Messages.showMessageDialog(project, UIDesignerBundle.message("snapshot.connection.error"),
                UIDesignerBundle.message("snapshot.title"), Messages.getInformationIcon());
        return;
    }

    final MyDialog dlg = new MyDialog(project, client, dir);
    dlg.show();
    if (dlg.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
        final int id = dlg.getSelectedComponentId();
        final Ref<Object> result = new Ref<Object>();
        ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
            public void run() {
                try {
                    result.set(client.createSnapshot(id));
                } catch (Exception ex) {
                    result.set(ex);
                }
            }
        }, UIDesignerBundle.message("progress.creating.snapshot"), false, project);

        String snapshot = null;
        if (result.get() instanceof String) {
            snapshot = (String) result.get();
        } else {
            Exception ex = (Exception) result.get();
            Messages.showMessageDialog(project,
                    UIDesignerBundle.message("snapshot.create.error", ex.getMessage()),
                    UIDesignerBundle.message("snapshot.title"), Messages.getErrorIcon());
        }

        if (snapshot != null) {
            final String snapshot1 = snapshot;
            ApplicationManager.getApplication().runWriteAction(new Runnable() {
                public void run() {
                    CommandProcessor.getInstance().executeCommand(project, new Runnable() {
                        public void run() {
                            try {
                                PsiFile formFile = PsiFileFactory.getInstance(dir.getProject())
                                        .createFileFromText(
                                                dlg.getFormName() + GuiFormFileType.DOT_DEFAULT_EXTENSION,
                                                snapshot1);
                                formFile = (PsiFile) dir.add(formFile);
                                formFile.getVirtualFile().setCharset(CharsetToolkit.UTF8_CHARSET);
                                formFile.getViewProvider().getDocument().setText(snapshot1);
                                view.selectElement(formFile);
                            } catch (IncorrectOperationException ex) {
                                Messages.showMessageDialog(project,
                                        UIDesignerBundle.message("snapshot.save.error", ex.getMessage()),
                                        UIDesignerBundle.message("snapshot.title"), Messages.getErrorIcon());
                            }
                        }
                    }, "", null);
                }
            });
        }
    }

    try {
        client.resumeSwing();
    } catch (IOException ex) {
        Messages.showErrorDialog(project, UIDesignerBundle.message("snapshot.connection.broken"),
                UIDesignerBundle.message("snapshot.title"));
    }

    client.dispose();
}

From source file:com.intellij.util.net.HttpConfigurable.java

License:Apache License

public PasswordAuthentication getGenericPromptedAuthentication(final String prefix, final String host,
        final String prompt, final int port, final boolean remember) {
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        return myTestGenericAuthRunnable.get();
    }/*  www. j a  va2s  . c o m*/

    final Ref<PasswordAuthentication> value = Ref.create();
    runAboveAll(new Runnable() {
        @Override
        public void run() {
            if (isGenericPasswordCanceled(host, port)) {
                return;
            }

            PasswordAuthentication password = getGenericPassword(host, port);
            if (password != null) {
                value.set(password);
                return;
            }

            AuthenticationDialog dialog = new AuthenticationDialog(PopupUtil.getActiveComponent(),
                    prefix + host, "Please enter credentials for: " + prompt, "", "", remember);
            dialog.show();
            if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
                AuthenticationPanel panel = dialog.getPanel();
                PasswordAuthentication passwordAuthentication = new PasswordAuthentication(panel.getLogin(),
                        panel.getPassword());
                putGenericPassword(host, port, passwordAuthentication, remember && panel.isRememberPassword());
                value.set(passwordAuthentication);
            } else {
                setGenericPasswordCanceled(host, port);
            }
        }
    });
    return value.get();
}

From source file:com.intellij.util.net.HttpConfigurable.java

License:Apache License

public PasswordAuthentication getPromptedAuthentication(final String host, final String prompt) {
    if (AUTHENTICATION_CANCELLED) {
        return null;
    }/*w w  w .j  a v  a 2 s  . co  m*/
    final String password = getPlainProxyPassword();
    if (PROXY_AUTHENTICATION && !StringUtil.isEmptyOrSpaces(PROXY_LOGIN)
            && !StringUtil.isEmptyOrSpaces(password)) {
        return new PasswordAuthentication(PROXY_LOGIN, password.toCharArray());
    }

    // do not try to show any dialogs if application is exiting
    if (ApplicationManager.getApplication() == null || ApplicationManager.getApplication().isDisposeInProgress()
            || ApplicationManager.getApplication().isDisposed())
        return null;

    if (ApplicationManager.getApplication().isUnitTestMode()) {
        return myTestGenericAuthRunnable.get();
    }
    final PasswordAuthentication[] value = new PasswordAuthentication[1];
    runAboveAll(new Runnable() {
        @Override
        public void run() {
            if (AUTHENTICATION_CANCELLED) {
                return;
            }

            // password might have changed, and the check below is for that
            String password = getPlainProxyPassword();
            if (PROXY_AUTHENTICATION && !StringUtil.isEmptyOrSpaces(PROXY_LOGIN)
                    && !StringUtil.isEmptyOrSpaces(password)) {
                value[0] = new PasswordAuthentication(PROXY_LOGIN, password.toCharArray());
                return;
            }
            AuthenticationDialog dialog = new AuthenticationDialog(PopupUtil.getActiveComponent(),
                    "Proxy authentication: " + host, "Please enter credentials for: " + prompt, PROXY_LOGIN, "",
                    KEEP_PROXY_PASSWORD);
            dialog.show();
            if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
                PROXY_AUTHENTICATION = true;
                AuthenticationPanel panel = dialog.getPanel();
                KEEP_PROXY_PASSWORD = panel.isRememberPassword();
                PROXY_LOGIN = StringUtil.nullize(panel.getLogin());
                setPlainProxyPassword(String.valueOf(panel.getPassword()));
                value[0] = new PasswordAuthentication(panel.getLogin(), panel.getPassword());
            } else {
                AUTHENTICATION_CANCELLED = true;
            }
        }
    });
    return value[0];
}

From source file:com.intellij.xml.refactoring.XmlTagRenameDialog.java

License:Apache License

@Override
protected void doAction() {
    LOG.assertTrue(myElement.isValid());

    CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
        @Override/*  w  w  w  .j  ava2 s.co m*/
        public void run() {
            ApplicationManager.getApplication().runWriteAction(new Runnable() {
                @Override
                public void run() {
                    try {
                        myTag.setName(getNewName());
                    } catch (IncorrectOperationException e) {
                        LOG.error(e);
                    }
                }
            });
        }
    }, RefactoringBundle.message("rename.title"), null);

    close(DialogWrapper.OK_EXIT_CODE);
}

From source file:com.jetbrains.lang.dart.ide.refactoring.DartInlineHandler.java

License:Apache License

@Override
protected void doAction() {
    if (!isInlineThisOnly()) {
        refactoring.setInlineAll(true);/*from   ww w .java 2 s .  c  o  m*/
        refactoring.setDeleteSource(true);
    }
    close(DialogWrapper.OK_EXIT_CODE);
}

From source file:com.jetbrains.lang.dart.ide.refactoring.DartRenameHandler.java

License:Apache License

@Override
protected void doAction() {
    // Validate final status.
    {/*ww  w.j a va2  s.  co  m*/
        final RefactoringStatus finalStatus = myRefactoring.checkFinalConditions();
        if (finalStatus.hasError()) {
            Messages.showErrorDialog(myProject, finalStatus.getMessage(), "Error");
            return;
        }
    }
    // Apply the change.
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {
            final SourceChange change = myRefactoring.getChange();
            assert change != null;
            final Set<String> excludedIds = myRefactoring.getPotentialEdits();
            AssistUtils.applySourceChange(myProject, change, excludedIds);
            close(DialogWrapper.OK_EXIT_CODE);
        }
    });
}