Java 类com.intellij.openapi.ui.DialogBuilder 实例源码

项目:AndroidSourceViewer    文件:CleanAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
    cacheFile = new File(Constant.CACHE_PATH);
    if (!cacheFile.exists()) {
        cacheFile.mkdirs();
    }
    long size = FileUtils.sizeOfDirectory(cacheFile);
    DialogBuilder builder = new DialogBuilder();
    builder.setTitle(Constant.TITLE);
    builder.resizable(false);
    builder.setCenterPanel(new JLabel(String.format("Currently occupy storage %.2fM, "
            + "Clean Cache immediately?", size/1024.0/1024.0),
            Messages.getInformationIcon(), SwingConstants.CENTER));
    builder.addOkAction().setText("Clean Now");
    builder.addCancelAction().setText("Cancel");
    builder.setButtonsAlignment(SwingConstants.RIGHT);
    if (builder.show() == 0) {
        clean();
    }
}
项目:educational-plugin    文件:EduBrowseCoursesAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  EduCoursesPanel panel = new EduCoursesPanel();
  DialogBuilder dialogBuilder = new DialogBuilder().title("Select Course").centerPanel(panel);
  dialogBuilder.addOkAction().setText("Join");
  panel.addCourseValidationListener(new EduCoursesPanel.CourseValidationListener() {
    @Override
    public void validationStatusChanged(boolean canStartCourse) {
      dialogBuilder.setOkActionEnabled(canStartCourse);
    }
  });
  dialogBuilder.setOkOperation(() -> {
    dialogBuilder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE);
    Course course = panel.getSelectedCourse();
    String location = panel.getLocationString();
    EduCreateNewProjectDialog.createProject(EduPluginConfigurator.INSTANCE.forLanguage(course.getLanguageById()).getEduCourseProjectGenerator(), course, location);
  });
  dialogBuilder.show();
}
项目:educational-plugin    文件:CCChangeCourseInfo.java   
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  Project project = e.getProject();
  if (project == null) {
    return;
  }
  Course course = StudyTaskManager.getInstance(project).getCourse();
  if (course == null) {
    return;
  }

  CCNewProjectPanel panel =
    new CCNewProjectPanel(course.getName(), Course.getAuthorsString(course.getAuthors()), course.getDescription());
  setupLanguageLevels(course, panel);
  DialogBuilder builder = createChangeInfoDialog(project, panel);
  if (builder.showAndGet()) {
    course.setAuthorsAsString(panel.getAuthors());
    course.setName(panel.getName());
    course.setDescription(panel.getDescription());
    setVersion(course, panel);
    ProjectView.getInstance(project).refresh();
    ProjectInspectionProfileManager.getInstance(project).fireProfileChanged();
  }
}
项目:stylint-plugin    文件:PackagesNotificationPanel.java   
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();
}
项目:intellij-ce-playground    文件:BuildArtifactsBeforeRunTaskProvider.java   
public boolean configureTask(RunConfiguration runConfiguration, BuildArtifactsBeforeRunTask task) {
  final Artifact[] artifacts = ArtifactManager.getInstance(myProject).getArtifacts();
  Set<ArtifactPointer> pointers = new THashSet<ArtifactPointer>();
  for (Artifact artifact : artifacts) {
    pointers.add(ArtifactPointerManager.getInstance(myProject).createPointer(artifact));
  }
  pointers.addAll(task.getArtifactPointers());
  ArtifactChooser chooser = new ArtifactChooser(new ArrayList<ArtifactPointer>(pointers));
  chooser.markElements(task.getArtifactPointers());
  chooser.setPreferredSize(JBUI.size(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;
}
项目:intellij-ce-playground    文件:DateFilterPopupComponent.java   
@Override
public void actionPerformed(@NotNull 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);
  }
}
项目:intellij-ce-playground    文件:MergeTool.java   
private static void showDialog(MergeRequestImpl data) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("MergeTool - dialog");
  }
  DialogBuilder builder = new DialogBuilder(data.getProject());
  builder.setDimensionServiceKey(data.getGroupKey());
  builder.setTitle(data.getWindowTitle());
  Disposable parent = Disposer.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);
  }
}
项目:intellij-ce-playground    文件:MergeRequestImpl.java   
private static void configureAction(DialogBuilder builder,
                                    DialogBuilder.CustomizableAction customizableAction,
                                    ActionButtonPresentation presentation) {
  customizableAction.setText(presentation.getName());

  String actionName = presentation.getName();
  final int index = actionName.indexOf('&');
  final char mnemonic;
  if (index >= 0 && index < actionName.length() - 1) {
    mnemonic = actionName.charAt(index + 1);
    actionName = actionName.substring(0, index) + actionName.substring(index + 1);
  }
  else {
    mnemonic = 0;
  }
  final Action action = ((DialogBuilder.ActionDescriptor)customizableAction).getAction(builder.getDialogWrapper());
  action.putValue(Action.NAME, actionName);
  if (mnemonic > 0) {
    action.putValue(Action.MNEMONIC_KEY, Integer.valueOf(mnemonic));
  }
}
项目:intellij-ce-playground    文件:BuildFilePropertiesPanel.java   
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();
  builder.addOkAction();
  builder.addCancelAction();
  builder.setHelpId("reference.dialogs.buildfileproperties");

  boolean isOk = builder.show() == DialogWrapper.OK_EXIT_CODE;
  if (isOk) {
    apply();
  }
  beforeClose();
  return isOk;
}
项目:intellij-ce-playground    文件:GuiEditor.java   
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);
  }
}
项目:intellij-ce-playground    文件:LocalChangesWouldBeOverwrittenHelper.java   
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();
  }
}
项目:intellij-ce-playground    文件:JavaLanguageInjectionSupport.java   
private static BaseInjection showInjectionUI(final Project project, final MethodParameterInjection methodParameterInjection) {
  final AbstractInjectionPanel panel = new MethodParameterPanel(methodParameterInjection, project);
  panel.reset();
  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;
}
项目:vue-for-idea    文件:PackagesNotificationPanel.java   
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();
}
项目:android-codegenerator-plugin-intellij    文件:CodeDialogBuilder.java   
public CodeDialogBuilder(Project project, String title, String producedCode) {
    dialogBuilder = new DialogBuilder(project);
    dialogBuilder.setTitle(title);

    JPanel centerPanel = new JPanel(new BorderLayout());
    codeArea = prepareCodeArea(producedCode);
    codeArea.setLineWrap(true);
    JBScrollPane codeScroll = new JBScrollPane(codeArea);

    centerPanel.add(codeScroll, BorderLayout.CENTER);
    dialogBuilder.setCenterPanel(centerPanel);

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

    dialogBuilder.removeAllActions();
}
项目:intellij-ocaml    文件:OCamlToolWindowSettingsAction.java   
public void showSettingsDialog() {
    final OCamlToolWindowSettingsForm settingsForm = new OCamlToolWindowSettingsForm(myProject);
    settingsForm.setSelectedSdk(OCamlSettings.getInstance().getTopLevelSdk());
    settingsForm.setCmdParams(OCamlSettings.getInstance().getTopLevelCmdOptions());
    settingsForm.setWorkingDirectory(OCamlSettings.getInstance().getTopLevelCmdWorkingDir());

    final DialogBuilder dialogBuilder = new DialogBuilder(myProject);
    dialogBuilder.setCenterPanel(settingsForm.getRootPanel());
    dialogBuilder.addOkAction().setText("Ok");
    dialogBuilder.addCancelAction().setText("Cancel");
    dialogBuilder.setPreferedFocusComponent(settingsForm.getSdkComboBox());
    dialogBuilder.setTitle("OCaml Top Level Console Settings");
    dialogBuilder.setOkOperation(new Runnable() {
        public void run() {
            OCamlSettings.getInstance().setTopLevelSdk(settingsForm.getSelectedSdk());
            OCamlSettings.getInstance().setTopLevelCmdOptions(settingsForm.getCmdParams());
            OCamlSettings.getInstance().setTopLevelCmdWorkingDir(settingsForm.getWorkingDirectory());
            dialogBuilder.getWindow().setVisible(false);
            if (myAction != null) {
                myAction.run();
            }
        }
    });
    dialogBuilder.show();
}
项目:fossil4idea    文件:OpenAction.java   
public void showDialog(final Project project, final Runnable callback) {
  final DialogBuilder builder = new DialogBuilder(project);
  builder.setCenterPanel(createPanel(project, new Consumer<Boolean>() {
    @Override
    public void consume(Boolean aBoolean) {
      builder.setOkActionEnabled(aBoolean);
    }
  }));
  builder.addOkAction();
  builder.addCancelAction();
  builder.setDimensionServiceKey(getClass().getName());
  builder.setTitle("Open Fossil Repository");
  builder.setOkOperation(new Runnable() {
    @Override
    public void run() {
      builder.getWindow().setVisible(false);
      callback.run();
    }
  });
  builder.setPreferredFocusComponent(myRepoField);
  builder.show();
}
项目:fossil4idea    文件:CloneAndOpenAction.java   
public void showDialog(final Project project, final Runnable callback) {
  final DialogBuilder builder = new DialogBuilder(project);
  builder.setCenterPanel(createPanel(project, new Consumer<Boolean>() {
    @Override
    public void consume(Boolean aBoolean) {
      builder.setOkActionEnabled(aBoolean);
    }
  }));
  builder.addOkAction();
  builder.addCancelAction();
  builder.setDimensionServiceKey(getClass().getName());
  builder.setTitle("Clone and Open Fossil Repository");
  builder.setOkOperation(new Runnable() {
    @Override
    public void run() {
      builder.getWindow().setVisible(false);
      callback.run();
    }
  });
  builder.setPreferredFocusComponent(myUrlField);
  builder.show();
}
项目:fossil4idea    文件:CloneAction.java   
public void showDialog(final Project project, final Runnable callback) {
  final DialogBuilder builder = new DialogBuilder(project);
  builder.setCenterPanel(createPanel(project, new Consumer<Boolean>() {
    @Override
    public void consume(Boolean aBoolean) {
      builder.setOkActionEnabled(aBoolean);
    }
  }));
  builder.addOkAction();
  builder.addCancelAction();
  builder.setDimensionServiceKey(getClass().getName());
  builder.setTitle("Clone Fossil Repository");
  builder.setOkOperation(new Runnable() {
    @Override
    public void run() {
      builder.getWindow().setVisible(false);
      callback.run();
    }
  });
  builder.setPreferredFocusComponent(myUrlField);
  builder.show();
}
项目:ui5-intellij-plugin    文件:UI5ApiSearchDialog.java   
/**
 * Show the search dialog
 * @param searchTerm
 */
public void show(@Nullable final String searchTerm) {

    final JTextField searchTextField = new JTextField(searchTerm);

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(new JLabel(UI5Bundle.getString("api.searchterm")), BorderLayout.WEST);
    panel.add(searchTextField, BorderLayout.CENTER);

    final DialogBuilder dialogBuilder = new DialogBuilder(project);
    dialogBuilder.setTitle(UI5Bundle.getString("api.search"));
    dialogBuilder.setCenterPanel(panel);
    dialogBuilder.addAction(getSearchAction(dialogBuilder, searchTextField.getText()));
    dialogBuilder.addCancelAction();
    dialogBuilder.showModal(true);
}
项目:tools-idea    文件:BuildArtifactsBeforeRunTaskProvider.java   
public boolean configureTask(RunConfiguration runConfiguration, BuildArtifactsBeforeRunTask task) {
  final Artifact[] artifacts = ArtifactManager.getInstance(myProject).getArtifacts();
  Set<ArtifactPointer> pointers = new THashSet<ArtifactPointer>();
  for (Artifact artifact : artifacts) {
    pointers.add(ArtifactPointerManager.getInstance(myProject).createPointer(artifact));
  }
  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;
}
项目:tools-idea    文件:MergeTool.java   
private static void showDialog(MergeRequestImpl data) {
  DialogBuilder builder = new DialogBuilder(data.getProject());
  builder.setDimensionServiceKey(data.getGroupKey());
  builder.setTitle(data.getWindowTitle());
  Disposable parent = Disposer.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);
  }
}
项目:tools-idea    文件:MergeRequestImpl.java   
private static void configureAction(DialogBuilder builder,
                                    DialogBuilder.CustomizableAction customizableAction,
                                    ActionButtonPresentation presentation) {
  customizableAction.setText(presentation.getName());

  String actionName = presentation.getName();
  final int index = actionName.indexOf('&');
  final char mnemonic;
  if (index >= 0 && index < actionName.length() - 1) {
    mnemonic = actionName.charAt(index + 1);
    actionName = actionName.substring(0, index) + actionName.substring(index + 1);
  }
  else {
    mnemonic = 0;
  }
  final Action action = ((DialogBuilder.ActionDescriptor)customizableAction).getAction(builder.getDialogWrapper());
  action.putValue(Action.NAME, actionName);
  if (mnemonic > 0) {
    action.putValue(Action.MNEMONIC_KEY, Integer.valueOf(mnemonic));
  }
}
项目:tools-idea    文件:BuildFilePropertiesPanel.java   
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();
  builder.addOkAction();
  builder.addCancelAction();
  builder.setHelpId("reference.dialogs.buildfileproperties");

  boolean isOk = builder.show() == DialogWrapper.OK_EXIT_CODE;
  if (isOk) {
    apply();
  }
  beforeClose();
  return isOk;
}
项目:tools-idea    文件:GitDiffFromHistoryHandler.java   
private void showDirDiffDialog(@NotNull FilePath path, @Nullable String hash1, @Nullable String hash2, @NotNull List<Change> diff) {
  DialogBuilder dialogBuilder = new DialogBuilder(myProject);
  String title;
  if (hash2 != null) {
    if (hash1 != null) {
      title = String.format("Difference between %s and %s in %s", GitUtil.getShortHash(hash1), GitUtil.getShortHash(hash2), path.getName());
    }
    else {
      title = String.format("Initial commit %s in %s", GitUtil.getShortHash(hash2), path.getName());
    }
  }
  else {
    LOG.assertTrue(hash1 != null, "hash1 and hash2 can't both be null. Path: " + path);
    title = String.format("Difference between %s and local version in %s", GitUtil.getShortHash(hash1), path.getName());
  }
  dialogBuilder.setTitle(title);
  dialogBuilder.setActionDescriptors(new DialogBuilder.ActionDescriptor[] { new DialogBuilder.CloseDialogAction()});
  final ChangesBrowser changesBrowser = new ChangesBrowser(myProject, null, diff, null, false, true,
                                                           null, ChangesBrowser.MyUseCase.COMMITTED_CHANGES, null);
  changesBrowser.setChangesToDisplay(diff);
  dialogBuilder.setCenterPanel(changesBrowser);
  dialogBuilder.showNotModal();
}
项目:tools-idea    文件:HgDiffFromHistoryHandler.java   
private void showDirDiffDialog(@NotNull FilePath path, @Nullable String hash1, @Nullable String hash2, @NotNull List<Change> diff) {
  DialogBuilder dialogBuilder = new DialogBuilder(myProject);
  String title;
  if (hash2 != null) {
    if (hash1 != null) {
      title = String.format("Difference between %s and %s in %s", hash1, hash2, path.getName());
    }
    else {
      title = String.format("Initial commit %s in %s", hash2, path.getName());
    }
  }
  else {
    LOG.assertTrue(hash1 != null, "hash1 and hash2 can't both be null. Path: " + path);
    title = String.format("Difference between %s and local version in %s", hash1, path.getName());
  }
  dialogBuilder.setTitle(title);
  dialogBuilder.setActionDescriptors(new DialogBuilder.ActionDescriptor[]{new DialogBuilder.CloseDialogAction()});
  final ChangesBrowser changesBrowser = new ChangesBrowser(myProject, null, diff, null, false, true,
                                                           null, ChangesBrowser.MyUseCase.COMMITTED_CHANGES, null);
  changesBrowser.setChangesToDisplay(diff);
  dialogBuilder.setCenterPanel(changesBrowser);
  dialogBuilder.showNotModal();
}
项目:tools-idea    文件:JavaLanguageInjectionSupport.java   
private static BaseInjection showInjectionUI(final Project project, final MethodParameterInjection methodParameterInjection) {
  final AbstractInjectionPanel panel = new MethodParameterPanel(methodParameterInjection, project);
  panel.reset();
  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;
}
项目:consulo-apache-ant    文件:BuildFilePropertiesPanel.java   
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();
    builder.addOkAction();
    builder.addCancelAction();
    builder.setHelpId("reference.dialogs.buildfileproperties");

    boolean isOk = builder.show() == DialogWrapper.OK_EXIT_CODE;
    if(isOk)
    {
        apply();
    }
    beforeClose();
    return isOk;
}
项目:consulo    文件:DateFilterPopupComponent.java   
@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);
  }
}
项目:consulo    文件:MergeTool.java   
private static void showDialog(MergeRequestImpl data) {
  DialogBuilder builder = new DialogBuilder(data.getProject());
  builder.setDimensionServiceKey(data.getGroupKey());
  builder.setTitle(data.getWindowTitle());
  Disposable parent = Disposer.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);
  }
}
项目:consulo    文件:MergeRequestImpl.java   
private static void configureAction(DialogBuilder builder,
                                    DialogBuilder.CustomizableAction customizableAction,
                                    ActionButtonPresentation presentation) {
  customizableAction.setText(presentation.getName());

  String actionName = presentation.getName();
  final int index = actionName.indexOf('&');
  final char mnemonic;
  if (index >= 0 && index < actionName.length() - 1) {
    mnemonic = actionName.charAt(index + 1);
    actionName = actionName.substring(0, index) + actionName.substring(index + 1);
  }
  else {
    mnemonic = 0;
  }
  final Action action = ((DialogBuilder.ActionDescriptor)customizableAction).getAction(builder.getDialogWrapper());
  action.putValue(Action.NAME, actionName);
  if (mnemonic > 0) {
    action.putValue(Action.MNEMONIC_KEY, Integer.valueOf(mnemonic));
  }
}
项目:consulo    文件:AbstractArtifactsBeforeRunTaskProvider.java   
@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));
  }
  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;
}
项目:consulo-java    文件:JavaLanguageInjectionSupport.java   
private static BaseInjection showInjectionUI(final Project project, final MethodParameterInjection methodParameterInjection) {
  final AbstractInjectionPanel panel = new MethodParameterPanel(methodParameterInjection, project);
  panel.reset();
  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;
}
项目:JNomad-Plugin    文件:JNomadPluginRegistration.java   
@Override
public void initComponent() {
    ActionManager am = ActionManager.getInstance();
    AnAction action = new AnAction("JNomad Configuration") {
        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            Project project = Objects.requireNonNull(anActionEvent.getData(PlatformDataKeys.PROJECT));
            JNomadConfigurationPanel configPanel = new JNomadConfigurationPanel();
            DialogBuilder builder = new DialogBuilder(project);
            builder.setTitle("JNomad Configuration");
            builder.setCenterPanel(configPanel);
            builder.setOkActionEnabled(true);
            if (configPanel.getPluginConfiguration().getEnvironmentList().isEmpty()) {
                builder.setPreferredFocusComponent(configPanel.getEnvironmentNameTextField());
            } else {
                builder.setPreferredFocusComponent(configPanel.getDatabaseHostTextField());
            }

            if (DialogWrapper.OK_EXIT_CODE == builder.show()) {
                JNomadPluginConfiguration pluginConfiguration = configPanel.getPluginConfiguration();
                pluginConfiguration.setSlowQueryThreshold(configPanel.getSlowQueryThreshold());
                pluginConfiguration.setRecommendIndexThreshold(configPanel.getRecommendIndexThreshold());

                PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(project);
                propertiesComponent.setValue("jnomad.plugin.configuration", new Gson().toJson(pluginConfiguration));
                JNomadInspection.resetJNomadSetup();
            }
        }
    };
    am.registerAction("JNomadPluginAction", action);

    //add to analyze menu
    DefaultActionGroup windowM = (DefaultActionGroup) am.getAction("AnalyzeMenu");
    windowM.addSeparator();
    windowM.add(action);
}
项目:GitCommitMessage    文件:Panel.java   
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();
}
项目:educational-plugin    文件:CCChangeCourseInfo.java   
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;
}
项目:RoboPOJOGenerator    文件:GeneratorViewBinder.java   
public void bindView(DialogBuilder builder, GuiFormEventListener eventListener) {
    final GeneratorVew generatorVew = new GeneratorVew();
    final GenerateActionListener actionListener = new GenerateActionListener(generatorVew, eventListener);
    generatorVew.getGenerateButton().addActionListener(actionListener);
    generatorVew.getKotlinCheckBox().addItemListener(new KotlinCheckBoxStateListener(generatorVew));

    bindGroupViews(generatorVew.getTypeButtonGroup(), generatorVew);

    builder.setCenterPanel(generatorVew.getRootView());
    builder.setTitle("RoboPOJOGenerator");
    builder.removeAllActions();
    builder.show();
}
项目:RoboPOJOGenerator    文件:GeneratePOJOActionController.java   
private void proceed(AnActionEvent event) throws RoboPluginException {
    final ProjectModel projectModel = environmentDelegate.obtainProjectModel(event);
    final DialogBuilder dialogBuilder = new DialogBuilder();
    final Window window = dialogBuilder.getWindow();

    generatorViewBinder.bindView(dialogBuilder, new GuiFormEventListener() {
        @Override
        public void onJsonDataObtained(GenerationModel generationModel) {
            window.dispose();
            generationDelegate.runGenerationTask(generationModel, projectModel);
        }
    });
}
项目:fastdex    文件:DialogUtil.java   
/**
 * 创建普通对话框
 * @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;
}
项目:intellij-ce-playground    文件:ExecutionErrorDialog.java   
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(JBUI.size(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();
}
项目:intellij-ce-playground    文件:FileDocumentManagerImpl.java   
@Override
public boolean process(final VirtualFile file, final 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(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;
}