Java Code Examples for com.intellij.openapi.ui.DialogBuilder#setTitle()

The following examples show how to use com.intellij.openapi.ui.DialogBuilder#setTitle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractArtifactsBeforeRunTaskProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Nonnull
@Override
public AsyncResult<Void> configureTask(RunConfiguration runConfiguration, T task) {
  final Artifact[] artifacts = ArtifactManager.getInstance(myProject).getArtifacts();
  Set<ArtifactPointer> pointers = new THashSet<>();
  for (Artifact artifact : artifacts) {
    pointers.add(ArtifactPointerManager.getInstance(myProject).create(artifact));
  }
  pointers.addAll(task.getArtifactPointers());
  ArtifactChooser chooser = new ArtifactChooser(new ArrayList<>(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);

  AsyncResult<Void> result = builder.showAsync();
  result.doWhenDone(() -> task.setArtifactPointers(chooser.getMarkedElements()));
  return result;
}
 
Example 2
Source File: PackagesNotificationPanel.java    From vue-for-idea with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void doShowError(String title, String description, DialogBuilder builder) {
    builder.setTitle(title);
    final JTextArea textArea = new JTextArea();
    textArea.setEditable(false);
    textArea.setText(description);
    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(600, 400));
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.add(new JBLabel("Details:", Messages.getErrorIcon(), SwingConstants.LEFT), BorderLayout.NORTH);
    builder.setCenterPanel(panel);
    builder.setButtonsAlignment(SwingConstants.CENTER);
    builder.addOkAction();
    builder.show();
}
 
Example 3
Source File: MergeTool.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void showDialog(MergeRequestImpl data) {
  DialogBuilder builder = new DialogBuilder(data.getProject());
  builder.setDimensionServiceKey(data.getGroupKey());
  builder.setTitle(data.getWindowTitle());
  Disposable parent = Disposable.newDisposable();
  builder.addDisposable(parent);
  MergePanel2 mergePanel = createMergeComponent(data, builder, parent);
  builder.setCenterPanel(mergePanel.getComponent());
  builder.setPreferredFocusComponent(mergePanel.getPreferredFocusedComponent());
  builder.setHelpId(data.getHelpId());
  int result = builder.show();
  MergeRequestImpl lastData = mergePanel.getMergeRequest();
  if (lastData != null) {
    lastData.setResult(result);
  }
}
 
Example 4
Source File: DateFilterPopupComponent.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  final DateFilterComponent dateComponent = new DateFilterComponent(false, DateFormatUtil.getDateFormat().getDelegate());
  VcsLogDateFilter currentFilter = myFilterModel.getFilter();
  if (currentFilter != null) {
    if (currentFilter.getBefore() != null) {
      dateComponent.setBefore(currentFilter.getBefore().getTime());
    }
    if (currentFilter.getAfter() != null) {
      dateComponent.setAfter(currentFilter.getAfter().getTime());
    }
  }

  DialogBuilder db = new DialogBuilder(DateFilterPopupComponent.this);
  db.addOkAction();
  db.setCenterPanel(dateComponent.getPanel());
  db.setPreferredFocusComponent(dateComponent.getPanel());
  db.setTitle("Select Period");
  if (DialogWrapper.OK_EXIT_CODE == db.show()) {
    long after = dateComponent.getAfter();
    long before = dateComponent.getBefore();
    VcsLogDateFilter filter = new VcsLogDateFilterImpl(after > 0 ? new Date(after) : null, before > 0 ? new Date(before) : null);
    myFilterModel.setFilter(filter);
  }
}
 
Example 5
Source File: ExecutionErrorDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void show(final ExecutionException e, final String title, final Project project) {
  if (e instanceof RunCanceledByUserException) {
    return;
  }

  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();
}
 
Example 6
Source File: RenderingOptionsForm.java    From markdown-doclet with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    DialogBuilder dialogBuilder = new DialogBuilder((Component)e.getSource());
    dialogBuilder.setTitle("Markdown Javadoc Rendering Options");
    dialogBuilder.addOkAction();
    dialogBuilder.addCancelAction();
    RenderingOptionsForm form = new RenderingOptionsForm(options.renderingOptions);
    dialogBuilder.setCenterPanel(form.getComponent());
    int exitCode = dialogBuilder.show();
    if (exitCode == DialogWrapper.OK_EXIT_CODE) {
        options.renderingOptions = form.get();
    }
}
 
Example 7
Source File: EnvironmentVariablesTextFieldWithBrowseButton.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void showParentEnvironmentDialog(@Nonnull Component parent) {
  EnvVariablesTable table = new EnvVariablesTable();
  table.setValues(convertToVariables(new TreeMap<>(new GeneralCommandLine().getParentEnvironment()), true));
  table.getActionsPanel().setVisible(false);
  DialogBuilder builder = new DialogBuilder(parent);
  builder.setTitle(ExecutionBundle.message("environment.variables.system.dialog.title"));
  builder.centerPanel(table.getComponent());
  builder.addCloseButton();
  builder.show();
}
 
Example 8
Source File: VcsDiffUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
public static void showChangesDialog(@Nonnull Project project, @Nonnull String title, @Nonnull List<Change> changes) {
  DialogBuilder dialogBuilder = new DialogBuilder(project);

  dialogBuilder.setTitle(title);
  dialogBuilder.setActionDescriptors(new DialogBuilder.CloseDialogAction());
  final ChangesBrowser changesBrowser =
          new ChangesBrowser(project, null, changes, null, false, true, null, ChangesBrowser.MyUseCase.COMMITTED_CHANGES, null);
  changesBrowser.setChangesToDisplay(changes);
  dialogBuilder.setCenterPanel(changesBrowser);
  dialogBuilder.setPreferredFocusComponent(changesBrowser.getPreferredFocusedComponent());
  dialogBuilder.showNotModal();
}
 
Example 9
Source File: BaseDiffFromHistoryHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected void showChangesDialog(@Nonnull String title, @Nonnull List<Change> changes) {
  DialogBuilder dialogBuilder = new DialogBuilder(myProject);

  dialogBuilder.setTitle(title);
  dialogBuilder.setActionDescriptors(new DialogBuilder.ActionDescriptor[]{new DialogBuilder.CloseDialogAction()});
  final ChangesBrowser changesBrowser =
          new ChangesBrowser(myProject, null, changes, null, false, true, null, ChangesBrowser.MyUseCase.COMMITTED_CHANGES, null);
  changesBrowser.setChangesToDisplay(changes);
  dialogBuilder.setCenterPanel(changesBrowser);
  dialogBuilder.setPreferredFocusComponent(changesBrowser.getPreferredFocusedComponent());
  dialogBuilder.showNotModal();
}
 
Example 10
Source File: Panel.java    From GitCommitMessage with Apache License 2.0 5 votes vote down vote up
public DialogWrapper createTemplateDialog(Project project) {
    Template template = new Template(project);

    DialogBuilder builder = new DialogBuilder(project);
    builder.setTitle("Git / Hg Mercurial Commit Message Template.");
    builder.setCenterPanel(template.getMainPanel());
    builder.removeAllActions();
    builder.addOkAction();
    builder.addCancelAction();
    boolean isOk = builder.show() == DialogWrapper.OK_EXIT_CODE;
    if (isOk) {
        TemplateFileHandler.storeFile(project, template.getTemplateContent());
    }
    return builder.getDialogWrapper();
}
 
Example 11
Source File: ExtractConceptInfoCollector.java    From Intellij-Plugin with Apache License 2.0 5 votes vote down vote up
private void showDialog(String steps, ExtractConceptDialog form) {
    final DialogBuilder builder = new DialogBuilder(editor.getProject());
    form.setData(steps, getConceptFileNames(), builder);
    builder.setCenterPanel(form.getRootPane());
    builder.setTitle("Extract Concept");
    builder.removeAllActions();
    builder.show();
}
 
Example 12
Source File: CodeDialogBuilder.java    From android-codegenerator-plugin-intellij with Apache License 2.0 5 votes vote down vote up
public CodeDialogBuilder(Project project, String title, String producedCode) {
    dialogBuilder = new DialogBuilder(project);
    dialogBuilder.setTitle(title);

    JPanel centerPanel = new JPanel(new BorderLayout());

    codeArea = prepareCodeArea(producedCode);
    centerPanel.add(new JBScrollPane(codeArea), BorderLayout.CENTER);
    dialogBuilder.setCenterPanel(centerPanel);

    topPanel = new JPanel(new GridLayout(0, 2));
    centerPanel.add(topPanel, BorderLayout.PAGE_START);

    dialogBuilder.removeAllActions();
}
 
Example 13
Source File: UsingReportAction.java    From freeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent event) {
    final Project project = event.getProject();
    Module[] modules = ModuleManager.getInstance(project).getModules();
    List<Pair<Module, PsiFile>> selectModulesList = new ArrayList<Pair<Module, PsiFile>>();
    for (Module module : modules) {
        GradleBuildFile file = GradleBuildFile.get(module);
        if (file != null && !GradleUtil.isLibrary(file)) {
            selectModulesList.add(Pair.create(module, file.getPsiFile()));
        }
    }

    if (selectModulesList.size() > 1) {
        final DialogBuilder builder = new DialogBuilder();
        builder.setTitle("Freeline Reporter");
        builder.resizable(false);
        builder.setCenterPanel(new JLabel("There are multiple application modules, Please select the exact one.",
                Messages.getInformationIcon(), SwingConstants.CENTER));
        builder.addOkAction().setText("Cancel");
        for (final Pair<Module, PsiFile> pair : selectModulesList) {
            builder.addAction(new AbstractAction(":" + pair.first.getName()) {
                @Override
                public void actionPerformed(ActionEvent e) {
                    builder.getDialogWrapper().close(DialogWrapper.CANCEL_EXIT_CODE);
                    report(project, pair.getSecond());
                }
            });
        }
        if (builder.show() > -1) {
            //return false;
        }
    } else if (selectModulesList.size() == 1) {
        report(project, selectModulesList.get(0).getSecond());
    }
}
 
Example 14
Source File: DialogUtil.java    From freeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 创建普通对话框
 * @param message
 * @param okText
 * @param cancelText
 * @return
 */
public static boolean createDialog(String message, String okText, String cancelText) {
    DialogBuilder builder = new DialogBuilder();
    builder.setTitle("Dialog Message");
    builder.resizable(false);
    builder.setCenterPanel(new JLabel(message, Messages.getInformationIcon(), SwingConstants.CENTER));
    builder.addOkAction().setText(okText);
    builder.addCancelAction().setText(cancelText);
    builder.setButtonsAlignment(SwingConstants.CENTER);
    return  builder.show() == 0;
}
 
Example 15
Source File: CodeMakerAction.java    From CodeMaker with Apache License 2.0 5 votes vote down vote up
private void showSource(Project project, String language, String className, String content) {
    final Editor editor = Editors.createSourceEditor(project, language, content, true);
    try {
        final DialogBuilder builder = new DialogBuilder(project);
        builder.addCloseButton().setText("Close");
        builder.setCenterPanel(editor.getComponent());
        builder.setTitle(className);
        builder.show();
    } finally {
        Editors.release(editor);
    }
}
 
Example 16
Source File: TemplateEditPane.java    From CodeMaker with Apache License 2.0 5 votes vote down vote up
private void testTemplate() {
    CodeTemplate template = new CodeTemplate(getTemplateName(), getClassName(), getTemplate(),
            getClassNumber(), getFileEncoding(), getTemplateLanguage(), getTargetLanguage());

    final List<ClassEntry> classEntries = inputClassIndices()
            .map(i ->
                 getSelectedTestInput().createInput("SomeClass" + i)
            )
            .collect(Collectors.toList());

    Object result;
    try {
        result = templateEngine.evaluate(template, classEntries, classEntries.get(0));
    } catch (Throwable e) {
        result = e;
    }

    final DialogBuilder builder = new DialogBuilder(this.templateEdit);
    builder.addCloseButton().setText("Close");

    if(result instanceof GeneratedSource) {
        builder.setTitle(((GeneratedSource) result).getClassName());
        builder.setCenterPanel(
                Editors.createSourceEditor(null, getTargetLanguage(), ((GeneratedSource) result).getContent(), true).getComponent());
    } else {
        Throwable error = (Throwable) result;
        builder.setTitle("Failed!");
        builder.setCenterPanel(
              Editors.createSourceEditor(null, "txt",
                      error.getMessage() + "\n\n" + ExceptionUtil.getThrowableText(error), true)
                      .getComponent());
    }
    builder.show();
}
 
Example 17
Source File: MemoryDiskConflictResolver.java    From consulo with Apache License 2.0 4 votes vote down vote up
boolean askReloadFromDisk(VirtualFile file, Document document) {
  if (myConflictAppeared != null) {
    Throwable trace = myConflictAppeared;
    myConflictAppeared = null;
    throw new IllegalStateException("Unexpected memory-disk conflict in tests for " + file.getPath() + ", please use FileDocumentManager#reloadFromDisk or avoid VFS refresh", trace);
  }

  String message = UIBundle.message("file.cache.conflict.message.text", file.getPresentableUrl());

  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) {
      Project project = ProjectLocator.getInstance().guessProjectForFile(file);
      String fsContent = LoadTextUtil.loadText(file).toString();
      DocumentContent content1 = DiffContentFactory.getInstance().create(project, fsContent, file.getFileType());
      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;
}
 
Example 18
Source File: FileTypeConfigurable.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void editPattern(@Nullable final String item) {
  final FileType type = myRecognizedFileType.getSelectedFileType();
  if (type == null) return;

  final String title = item == null
                       ? FileTypesBundle.message("filetype.edit.add.pattern.title")
                       : FileTypesBundle.message("filetype.edit.edit.pattern.title");

  final Language oldLanguage = item == null ? null : myTempTemplateDataLanguages.findAssociatedFileType(item);
  final FileTypePatternDialog dialog = new FileTypePatternDialog(item, type, oldLanguage);
  final DialogBuilder builder = new DialogBuilder(myPatterns);
  builder.setPreferredFocusComponent(dialog.getPatternField());
  builder.setCenterPanel(dialog.getMainPanel());
  builder.setTitle(title);
  builder.showModal(true);
  if (builder.getDialogWrapper().isOK()) {
    final String pattern = dialog.getPatternField().getText();
    if (StringUtil.isEmpty(pattern)) return;

    final FileNameMatcher matcher = FileTypeManager.parseFromString(pattern);
    FileType registeredFileType = findExistingFileType(matcher);
    if (registeredFileType != null && registeredFileType != type) {
      if (registeredFileType.isReadOnly()) {
        Messages.showMessageDialog(myPatterns.myPatternsList, FileTypesBundle
                .message("filetype.edit.add.pattern.exists.error", registeredFileType.getDescription()), title,
                                   Messages.getErrorIcon());
        return;
      }
      else {
        if (Messages.OK ==
            Messages.showOkCancelDialog(myPatterns.myPatternsList, FileTypesBundle
                    .message("filetype.edit.add.pattern.exists.message", registeredFileType.getDescription()),
                                        FileTypesBundle.message("filetype.edit.add.pattern.exists.title"),
                                        FileTypesBundle.message("filetype.edit.add.pattern.reassign.button"),
                                        CommonBundle.getCancelButtonText(), Messages.getQuestionIcon())) {
          myTempPatternsTable.removeAssociation(matcher, registeredFileType);
          if(oldLanguage != null) {
            myTempTemplateDataLanguages.removeAssociation(matcher, oldLanguage);
          }
          myReassigned.put(matcher, registeredFileType);
        }
        else {
          return;
        }
      }
    }

    if (item != null) {
      final FileNameMatcher oldMatcher = FileTypeManager.parseFromString(item);
      myTempPatternsTable.removeAssociation(oldMatcher, type);
      if(oldLanguage != null) {
        myTempTemplateDataLanguages.removeAssociation(oldMatcher, oldLanguage);
      }
    }
    myTempPatternsTable.addAssociation(matcher, type);
    myTempTemplateDataLanguages.addAssociation(matcher, dialog.getTemplateDataLanguage());

    updateExtensionList();
    final int index = myPatterns.getListModel().indexOf(matcher.getPresentableString());
    if (index >= 0) {
      ScrollingUtil.selectItem(myPatterns.myPatternsList, index);
    }
    IdeFocusManager.getGlobalInstance().doForceFocusWhenFocusSettlesDown(myPatterns.myPatternsList);
  }
}
 
Example 19
Source File: FreelineUtil.java    From freeline with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * 检查是否需要载入Freeline
 *
 * @param project
 * @return
 */
public static boolean checkInstall(@NotNull final Project project) {
    final FreelineStatus status = getFreelineStatus(project);
    if (GradleUtil.isSyncInProgress(project)) {
        NotificationUtils.errorMsgDialog("Waiting for sync project to complete");
        return false;
    }
    if (status.hasInitFreeline()) {
        return true;
    }
    if (status.getGradleBuildFiles().size() < 1) {
        NotificationUtils.errorMsgDialog("It's not an Android Gradle project Currently?");
        return false;
    }
    if (status.isExistClasspath() && status.isExistPlugin() && !status.isExistFreelineCore()) {
        NotificationUtils.errorNotification("Execute task initFreeline and download freeline dependencies...");
        initFreeline(project);
        return false;
    }
    if (DialogUtil.createDialog("Detected that you did not installFreeline Freeline, Whether installFreeline Automatically?",
            "Install Freeline Automatically", "Cancel")) {
        Module[] modules = ModuleManager.getInstance(project).getModules();
        List<Pair<Module, PsiFile>> selectModulesList = new ArrayList<Pair<Module, PsiFile>>();
        for (Module module : modules) {
            GradleBuildFile file = GradleBuildFile.get(module);
            if (file != null && !GradleUtil.isLibrary(file)) {
                selectModulesList.add(Pair.create(module, file.getPsiFile()));
            }
        }
        // 多个app模块的情况
        if (selectModulesList.size() > 1) {
            final DialogBuilder builder = new DialogBuilder();
            builder.setTitle("Install Freeline");
            builder.resizable(false);
            builder.setCenterPanel(new JLabel("There are multiple application modules, Please select the module to be installed Freeline.",
                    Messages.getInformationIcon(), SwingConstants.CENTER));
            builder.addOkAction().setText("Cancel");
            for (final Pair<Module, PsiFile> pair : selectModulesList) {
                builder.addAction(new AbstractAction(":" + pair.first.getName()) {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        builder.getDialogWrapper().close(DialogWrapper.CANCEL_EXIT_CODE);
                        installFreeline(project, status, pair.getSecond());
                    }
                });
            }
            if (builder.show() > -1) {
                return false;
            }
        } else if (selectModulesList.size() == 1) {
            installFreeline(project, status, selectModulesList.get(0).getSecond());
        } else {
            NotificationUtils.errorMsgDialog("Can not found Application Module! Please Sync Project.");
            return false;
        }
    }
    return false;
}