Example usage for com.intellij.openapi.ui DialogBuilder DialogBuilder

List of usage examples for com.intellij.openapi.ui DialogBuilder DialogBuilder

Introduction

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

Prototype

public DialogBuilder(@Nullable Component parent) 

Source Link

Usage

From source file:com.android.tools.idea.apk.viewer.ApkEditor.java

License:Apache License

@Override
public void selectApkAndCompare() {
    FileChooserDescriptor desc = new FileChooserDescriptor(true, false, false, false, false, false);
    desc.withFileFilter(file -> ApkFileSystem.EXTENSIONS.contains(file.getExtension()));
    VirtualFile file = FileChooser.chooseFile(desc, myProject, null);
    if (file == null) {
        // user canceled
        return;//from w w  w . j  a  va 2s. co m
    }
    VirtualFile newApk = ApkFileSystem.getInstance().getRootByLocal(file);
    assert newApk != null;

    DialogBuilder builder = new DialogBuilder(myProject);
    builder.setTitle(myRoot.getName() + " vs " + newApk.getName());
    ApkDiffParser parser = new ApkDiffParser(myRoot, newApk);
    ApkDiffPanel panel = new ApkDiffPanel(parser);
    builder.setCenterPanel(panel.getContainer());
    builder.setPreferredFocusComponent(panel.getPreferredFocusedComponent());
    builder.show();
}

From source file:com.android.tools.idea.uibuilder.property.NlIdPropertyItem.java

License:Apache License

private DialogBuilder createDialogBuilder(@NotNull Project project) {
    return myDialogSupplier != null ? myDialogSupplier.get() : new DialogBuilder(project);
}

From source file:com.github.intelliguard.ui.FormDialogWrapper.java

License:Apache License

@Nullable
public static JarOptionsForm showJarOptionsForm(@NotNull GuardFacet guardFacet) {
    DialogBuilder builder = new DialogBuilder(guardFacet.getModule().getProject());
    JarOptionsForm jarOptionsForm = new JarOptionsForm(guardFacet);
    builder.setCenterPanel(jarOptionsForm.getContentPane());
    builder.setTitle("Obfuscate Jar");
    builder.addOkAction().setText("Build");
    builder.addCancelAction().setText("Cancel");

    int res = builder.show();

    return res == 0 ? jarOptionsForm : null;
}

From source file:com.github.intelliguard.ui.FormDialogWrapper.java

License:Apache License

@Nullable
public static ExportOptionsForm showExportOptionsForm(@NotNull GuardFacet guardFacet) {
    DialogBuilder builder = new DialogBuilder(guardFacet.getModule().getProject());
    ExportOptionsForm exportOptionsForm = new ExportOptionsForm(guardFacet);
    builder.setCenterPanel(exportOptionsForm.getContentPane());
    builder.setTitle("Export Configuration");
    builder.addOkAction().setText("Export");
    builder.addCancelAction().setText("Cancel");

    int res = builder.show();

    return res == 0 ? exportOptionsForm : null;
}

From source file:com.intellij.execution.util.ExecutionErrorDialog.java

License:Apache License

public static void show(final ExecutionException e, final String title, final Project project) {
    if (e instanceof RunCanceledByUserException) {
        return;/*www . j a  v a 2s.  com*/
    }

    if (ApplicationManager.getApplication().isUnitTestMode()) {
        throw new RuntimeException(e.getLocalizedMessage());
    }
    final String message = e.getMessage();
    if (message == null || message.length() < 100) {
        Messages.showErrorDialog(project, message == null ? "exception was thrown" : message, title);
        return;
    }
    final DialogBuilder builder = new DialogBuilder(project);
    builder.setTitle(title);
    final JTextArea textArea = new JTextArea();
    textArea.setEditable(false);
    textArea.setForeground(UIUtil.getLabelForeground());
    textArea.setBackground(UIUtil.getLabelBackground());
    textArea.setFont(UIUtil.getLabelFont());
    textArea.setText(message);
    textArea.setWrapStyleWord(false);
    textArea.setLineWrap(true);
    final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(textArea);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    final JPanel panel = new JPanel(new BorderLayout(10, 0));
    panel.setPreferredSize(new Dimension(500, 200));
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.add(new JLabel(Messages.getErrorIcon()), BorderLayout.WEST);
    builder.setCenterPanel(panel);
    builder.setButtonsAlignment(SwingConstants.CENTER);
    builder.addOkAction();
    builder.show();
}

From source file:com.intellij.history.integration.ui.views.HistoryDialog.java

License:Apache License

private boolean showAsDialog(CreatePatchConfigurationPanel p) {
    final DialogBuilder b = new DialogBuilder(myProject);
    JComponent createPatchPanel = p.getPanel();
    b.setPreferredFocusComponent(IdeFocusTraversalPolicy.getPreferredFocusedComponent(createPatchPanel));
    b.setTitle(message("create.patch.dialog.title"));
    b.setCenterPanel(createPatchPanel);//from   www . j a v a 2  s .c om
    p.installOkEnabledListener(new Consumer<Boolean>() {
        public void consume(final Boolean aBoolean) {
            b.setOkActionEnabled(aBoolean);
        }
    });
    return b.show() == DialogWrapper.OK_EXIT_CODE;
}

From source file:com.intellij.lang.ant.config.impl.configuration.BuildFilePropertiesPanel.java

License:Apache License

private boolean showDialog() {
    DialogBuilder builder = new DialogBuilder(myBuildFile.getProject());
    builder.setCenterPanel(myForm.myWholePanel);
    builder.setDimensionServiceKey(DIMENSION_SERVICE_KEY);
    builder.setPreferredFocusComponent(myForm.getPreferedFocusComponent());
    builder.setTitle(AntBundle.message("build.file.properties.dialog.title"));
    builder.removeAllActions();/*from   w w w .  java 2  s  .  com*/
    builder.addOkAction();
    builder.addCancelAction();
    builder.setHelpId("reference.dialogs.buildfileproperties");

    boolean isOk = builder.show() == DialogWrapper.OK_EXIT_CODE;
    if (isOk) {
        apply();
    }
    beforeClose();
    return isOk;
}

From source file:com.intellij.packaging.impl.run.AbstractArtifactsBeforeRunTaskProvider.java

License:Apache License

@Override
public boolean configureTask(RunConfiguration runConfiguration, T task) {
    final Artifact[] artifacts = ArtifactManager.getInstance(myProject).getArtifacts();
    Set<ArtifactPointer> pointers = new THashSet<ArtifactPointer>();
    for (Artifact artifact : artifacts) {
        pointers.add(ArtifactPointerUtil.getPointerManager(myProject).create(artifact));
    }/*from   w  w w . j  ava  2s  . c  o  m*/
    pointers.addAll(task.getArtifactPointers());
    ArtifactChooser chooser = new ArtifactChooser(new ArrayList<ArtifactPointer>(pointers));
    chooser.markElements(task.getArtifactPointers());
    chooser.setPreferredSize(new Dimension(400, 300));

    DialogBuilder builder = new DialogBuilder(myProject);
    builder.setTitle(CompilerBundle.message("build.artifacts.before.run.selector.title"));
    builder.setDimensionServiceKey("#BuildArtifactsBeforeRunChooser");
    builder.addOkAction();
    builder.addCancelAction();
    builder.setCenterPanel(chooser);
    builder.setPreferredFocusComponent(chooser);
    if (builder.show() == DialogWrapper.OK_EXIT_CODE) {
        task.setArtifactPointers(chooser.getMarkedElements());
        return true;
    }
    return false;
}

From source file:com.intellij.uiDesigner.designSurface.GuiEditor.java

License:Apache License

public void showFormSource() {
    EditorFactory editorFactory = EditorFactory.getInstance();

    Editor editor = editorFactory.createViewer(myDocument, myProject);

    try {/*  ww  w .  j a v a2 s .com*/
        ((EditorEx) editor).setHighlighter(new LexerEditorHighlighter(new XmlFileHighlighter(),
                EditorColorsManager.getInstance().getGlobalScheme()));

        JComponent component = editor.getComponent();
        component.setPreferredSize(new Dimension(640, 480));

        DialogBuilder dialog = new DialogBuilder(myProject);

        dialog.title("Form - " + myFile.getPresentableName()).dimensionKey("GuiDesigner.FormSource.Dialog");
        dialog.centerPanel(component).setPreferredFocusComponent(editor.getContentComponent());
        dialog.addOkAction();

        dialog.show();
    } finally {
        editorFactory.releaseEditor(editor);
    }
}

From source file:com.intellij.util.xml.ui.TextControl.java

License:Apache License

@Override
protected TextPanel createMainComponent(TextPanel boundedComponent, final Project project) {
    if (boundedComponent == null) {
        boundedComponent = new TextPanel();
    }//from  w  ww .  j a  v  a2 s .  c o  m
    boundedComponent.removeAll();
    final Function<String, Document> factory = new Function<String, Document>() {
        @Override
        public Document fun(final String s) {
            return PsiDocumentManager.getInstance(project).getDocument(PsiFileFactory.getInstance(project)
                    .createFileFromText("a.txt", PlainTextLanguage.INSTANCE, "", true, false));
        }
    };
    final TextPanel boundedComponent1 = boundedComponent;
    final EditorTextField editorTextField = new EditorTextField(factory.fun(""), project,
            PlainTextFileType.INSTANCE) {
        @Override
        protected EditorEx createEditor() {
            final EditorEx editor = super.createEditor();
            return boundedComponent1 instanceof MultiLineTextPanel
                    ? makeBigEditor(editor, ((MultiLineTextPanel) boundedComponent1).getRowCount())
                    : editor;
        }
    };
    editorTextField.setOneLineMode(false);

    if (boundedComponent instanceof BigTextPanel) {
        final ReferenceEditorWithBrowseButton editor = new ReferenceEditorWithBrowseButton(null,
                editorTextField, factory);
        boundedComponent.add(editor);
        editor.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                EditorTextField textArea = new EditorTextField(editorTextField.getDocument(), project,
                        PlainTextFileType.INSTANCE) {
                    @Override
                    protected EditorEx createEditor() {
                        final EditorEx editor = super.createEditor();
                        editor.setEmbeddedIntoDialogWrapper(true);
                        return makeBigEditor(editor, 5);
                    }
                };
                textArea.setOneLineMode(false);

                DialogBuilder builder = new DialogBuilder(project);
                builder.setDimensionServiceKey("TextControl");
                builder.setCenterPanel(textArea);
                builder.setPreferredFocusComponent(textArea);
                builder.setTitle(UIBundle.message("big.text.control.window.title"));
                builder.addCloseButton();
                builder.show();
            }
        });
        return boundedComponent;
    }

    boundedComponent.add(editorTextField);
    return boundedComponent;
}