Search in sources :

Example 26 with DialogBuilder

use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.

the class ShowUpdateInfoDialogAction method getUserText.

@NotNull
private static Pair<String, VirtualFile> getUserText(@NotNull Project project, @NotNull String title) {
    JTextArea textArea = new JTextArea(10, 50);
    UIUtil.addUndoRedoActions(textArea);
    textArea.setWrapStyleWord(true);
    textArea.setLineWrap(true);
    JPanel panel = new JPanel(new BorderLayout(0, 10));
    panel.add(ScrollPaneFactory.createScrollPane(textArea), BorderLayout.CENTER);
    Disposable disposable = Disposer.newDisposable();
    FileTextField fileField = FileChooserFactory.getInstance().createFileTextField(BrowseFilesListener.SINGLE_FILE_DESCRIPTOR, disposable);
    TextFieldWithBrowseButton fileCompo = new TextFieldWithBrowseButton(fileField.getField());
    FileChooserDescriptor fileDescriptor = FileChooserDescriptorFactory.createSingleLocalFileDescriptor();
    fileCompo.addBrowseFolderListener("Patch File", "Patch file", project, fileDescriptor);
    panel.add(LabeledComponent.create(fileCompo, "Patch file:"), BorderLayout.SOUTH);
    DialogBuilder builder = new DialogBuilder(project);
    builder.addDisposable(disposable);
    builder.setCenterPanel(panel);
    builder.setPreferredFocusComponent(textArea);
    builder.setTitle(title);
    builder.addOkAction();
    builder.addCancelAction();
    return builder.showAndGet() ? Pair.create(textArea.getText(), fileField.getSelectedFile()) : Pair.empty();
}
Also used : Disposable(com.intellij.openapi.Disposable) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) FileTextField(com.intellij.openapi.fileChooser.FileTextField) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) NotNull(org.jetbrains.annotations.NotNull)

Example 27 with DialogBuilder

use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.

the class GuiEditor method showFormSource.

public void showFormSource() {
    EditorFactory editorFactory = EditorFactory.getInstance();
    Editor editor = editorFactory.createViewer(myDocument, myProject);
    try {
        ((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);
    }
}
Also used : EditorFactory(com.intellij.openapi.editor.EditorFactory) EditorEx(com.intellij.openapi.editor.ex.EditorEx) LexerEditorHighlighter(com.intellij.openapi.editor.ex.util.LexerEditorHighlighter) XmlFileHighlighter(com.intellij.ide.highlighter.XmlFileHighlighter) UIFormEditor(com.intellij.uiDesigner.editor.UIFormEditor) Editor(com.intellij.openapi.editor.Editor) DialogBuilder(com.intellij.openapi.ui.DialogBuilder)

Example 28 with DialogBuilder

use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.

the class MemoryDiskConflictResolver method askReloadFromDisk.

boolean askReloadFromDisk(VirtualFile file, Document document) {
    String message = UIBundle.message("file.cache.conflict.message.text", file.getPresentableUrl());
    final DialogBuilder builder = new DialogBuilder();
    builder.setCenterPanel(new JLabel(message, Messages.getQuestionIcon(), SwingConstants.CENTER));
    builder.addOkAction().setText(UIBundle.message("file.cache.conflict.load.fs.changes.button"));
    builder.addCancelAction().setText(UIBundle.message("file.cache.conflict.keep.memory.changes.button"));
    builder.addAction(new AbstractAction(UIBundle.message("file.cache.conflict.show.difference.button")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            final ProjectEx project = (ProjectEx) ProjectLocator.getInstance().guessProjectForFile(file);
            FileType fileType = file.getFileType();
            String fsContent = LoadTextUtil.loadText(file).toString();
            DocumentContent content1 = DiffContentFactory.getInstance().create(project, fsContent, fileType);
            DocumentContent content2 = DiffContentFactory.getInstance().create(project, document, file);
            String title = UIBundle.message("file.cache.conflict.for.file.dialog.title", file.getPresentableUrl());
            String title1 = UIBundle.message("file.cache.conflict.diff.content.file.system.content");
            String title2 = UIBundle.message("file.cache.conflict.diff.content.memory.content");
            DiffRequest request = new SimpleDiffRequest(title, content1, content2, title1, title2);
            request.putUserData(DiffUserDataKeys.GO_TO_SOURCE_DISABLE, true);
            DialogBuilder diffBuilder = new DialogBuilder(project);
            DiffRequestPanel diffPanel = DiffManager.getInstance().createRequestPanel(project, diffBuilder, diffBuilder.getWindow());
            diffPanel.setRequest(request);
            diffBuilder.setCenterPanel(diffPanel.getComponent());
            diffBuilder.setDimensionServiceKey("FileDocumentManager.FileCacheConflict");
            diffBuilder.addOkAction().setText(UIBundle.message("file.cache.conflict.save.changes.button"));
            diffBuilder.addCancelAction();
            diffBuilder.setTitle(title);
            if (diffBuilder.show() == DialogWrapper.OK_EXIT_CODE) {
                builder.getDialogWrapper().close(DialogWrapper.CANCEL_EXIT_CODE);
            }
        }
    });
    builder.setTitle(UIBundle.message("file.cache.conflict.dialog.title"));
    builder.setButtonsAlignment(SwingConstants.CENTER);
    builder.setHelpId("reference.dialogs.fileCacheConflict");
    return builder.show() == 0;
}
Also used : ProjectEx(com.intellij.openapi.project.ex.ProjectEx) SimpleDiffRequest(com.intellij.diff.requests.SimpleDiffRequest) DiffRequestPanel(com.intellij.diff.DiffRequestPanel) FileType(com.intellij.openapi.fileTypes.FileType) ActionEvent(java.awt.event.ActionEvent) DocumentContent(com.intellij.diff.contents.DocumentContent) DiffRequest(com.intellij.diff.requests.DiffRequest) SimpleDiffRequest(com.intellij.diff.requests.SimpleDiffRequest) DialogBuilder(com.intellij.openapi.ui.DialogBuilder)

Example 29 with DialogBuilder

use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.

the class LocalChangesWouldBeOverwrittenHelper method showErrorDialog.

private static void showErrorDialog(@NotNull Project project, @NotNull String operationName, @NotNull List<Change> changes, @NotNull Collection<String> absolutePaths) {
    String title = "Local Changes Prevent from " + StringUtil.capitalize(operationName);
    String description = getErrorDialogDescription();
    if (changes.isEmpty()) {
        GitUtil.showPathsInDialog(project, absolutePaths, title, description);
    } else {
        DialogBuilder builder = new DialogBuilder(project);
        builder.setNorthPanel(new MultiLineLabel(description));
        builder.setCenterPanel(new ChangesBrowserWithRollback(project, changes));
        builder.addOkAction();
        builder.setTitle(title);
        builder.show();
    }
}
Also used : ChangesBrowserWithRollback(git4idea.ui.ChangesBrowserWithRollback) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) MultiLineLabel(com.intellij.openapi.ui.ex.MultiLineLabel)

Example 30 with DialogBuilder

use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.

the class CCChangeCourseInfo method createChangeInfoDialog.

private static DialogBuilder createChangeInfoDialog(Project project, @NotNull CCNewProjectPanel panel) {
    DialogBuilder builder = new DialogBuilder(project);
    builder.setTitle(ACTION_TEXT);
    JPanel changeInfoPanel = panel.getMainPanel();
    changeInfoPanel.setPreferredSize(new Dimension(450, 300));
    changeInfoPanel.setMinimumSize(new Dimension(450, 300));
    builder.setCenterPanel(changeInfoPanel);
    return builder;
}
Also used : DialogBuilder(com.intellij.openapi.ui.DialogBuilder)

Aggregations

DialogBuilder (com.intellij.openapi.ui.DialogBuilder)33 ActionEvent (java.awt.event.ActionEvent)7 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)4 Project (com.intellij.openapi.project.Project)4 Module (com.intellij.openapi.module.Module)3 GradleBuildFile (com.android.tools.idea.gradle.parser.GradleBuildFile)2 Disposable (com.intellij.openapi.Disposable)2 AnAction (com.intellij.openapi.actionSystem.AnAction)2 CustomShortcutSet (com.intellij.openapi.actionSystem.CustomShortcutSet)2 EditorEx (com.intellij.openapi.editor.ex.EditorEx)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 FrameWrapper (com.intellij.openapi.ui.FrameWrapper)2 MultiLineLabel (com.intellij.openapi.ui.ex.MultiLineLabel)2 Pair (com.intellij.openapi.util.Pair)2 PsiFile (com.intellij.psi.PsiFile)2 JBTextField (com.intellij.ui.components.JBTextField)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 ApkDiffPanel (com.android.tools.idea.apk.viewer.diff.ApkDiffPanel)1 ApkDiffParser (com.android.tools.idea.apk.viewer.diff.ApkDiffParser)1