当前位置: 首页>>代码示例>>Java>>正文


Java Messages.CANCEL属性代码示例

本文整理汇总了Java中com.intellij.openapi.ui.Messages.CANCEL属性的典型用法代码示例。如果您正苦于以下问题:Java Messages.CANCEL属性的具体用法?Java Messages.CANCEL怎么用?Java Messages.CANCEL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.intellij.openapi.ui.Messages的用法示例。


在下文中一共展示了Messages.CANCEL属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showYesNoCancelDialog

@Override
public int showYesNoCancelDialog(@NotNull String title,
                                 String message,
                                 @NotNull String defaultButton,
                                 String alternateButton,
                                 String otherButton,
                                 @Nullable Window window,
                                 @Nullable DialogWrapper.DoNotAskOption doNotAskOption) {
  if (window == null) {
    window = getForemostWindow(null);
  }
  SheetMessage sheetMessage = new SheetMessage(window, title, message, UIUtil.getQuestionIcon(),
                                               new String [] {defaultButton, otherButton, alternateButton},
                                               doNotAskOption, defaultButton, alternateButton);

  String resultString = sheetMessage.getResult();
  int result = resultString.equals(defaultButton) ? Messages.YES : resultString.equals(alternateButton) ? Messages.NO : Messages.CANCEL;
  if (doNotAskOption != null) {
      doNotAskOption.setToBeShown(sheetMessage.toBeShown(), result);
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:JBMacMessages.java

示例2: processFoundCodeSmells

private ReturnResult processFoundCodeSmells(final List<CodeSmellInfo> codeSmells, @Nullable CommitExecutor executor) {
  int errorCount = collectErrors(codeSmells);
  int warningCount = codeSmells.size() - errorCount;
  String commitButtonText = executor != null ? executor.getActionText() : myCheckinPanel.getCommitActionName();
  if (commitButtonText.endsWith("...")) {
    commitButtonText = commitButtonText.substring(0, commitButtonText.length()-3);
  }

  final int answer = Messages.showYesNoCancelDialog(myProject,
    VcsBundle.message("before.commit.files.contain.code.smells.edit.them.confirm.text", errorCount, warningCount),
    VcsBundle.message("code.smells.error.messages.tab.name"), VcsBundle.message("code.smells.review.button"),
    commitButtonText, CommonBundle.getCancelButtonText(), UIUtil.getWarningIcon());
  if (answer == Messages.YES) {
    CodeSmellDetector.getInstance(myProject).showCodeSmellErrors(codeSmells);
    return ReturnResult.CLOSE_WINDOW;
  }
  else if (answer == Messages.CANCEL) {
    return ReturnResult.CANCEL;
  }
  else {
    return ReturnResult.COMMIT;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:CodeAnalysisBeforeCheckinHandler.java

示例3: suggestCreatingFileInstead

@Nullable
private Boolean suggestCreatingFileInstead(String subDirName) {
  Boolean createFile = false;
  if (StringUtil.countChars(subDirName, '.') == 1 && Registry.is("ide.suggest.file.when.creating.filename.like.directory")) {
    FileType fileType = findFileTypeBoundToName(subDirName);
    if (fileType != null) {
      String message = "The name you entered looks like a file name. Do you want to create a file named " + subDirName + " instead?";
      int ec = Messages.showYesNoCancelDialog(myProject, message,
                                              "File Name Detected",
                                              "&Yes, create file",
                                              "&No, create " + (myIsDirectory ? "directory" : "packages"),
                                              CommonBundle.getCancelButtonText(),
                                              fileType.getIcon());
      if (ec == Messages.CANCEL) {
        createFile = null;
      }
      if (ec == Messages.YES) {
        createFile = true;
      }
    }
  }
  return createFile;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:CreateDirectoryOrPackageHandler.java

示例4: checkAddLibraryDependency

private boolean checkAddLibraryDependency(final ComponentItem item, final LibraryOrderEntry libraryOrderEntry) {
  int rc = Messages.showYesNoCancelDialog(
    myEditor,
    UIDesignerBundle.message("add.library.dependency.prompt", item.getClassName(), libraryOrderEntry.getPresentableName(),
                             myEditor.getModule().getName()),
    UIDesignerBundle.message("add.library.dependency.title"),
    Messages.getQuestionIcon());
  if (rc == Messages.CANCEL) return false;
  if (rc == Messages.YES) {
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      public void run() {
        final ModifiableRootModel model = ModuleRootManager.getInstance(myEditor.getModule()).getModifiableModel();
        if (libraryOrderEntry.isModuleLevel()) {
          copyModuleLevelLibrary(libraryOrderEntry.getLibrary(), model);
        }
        else {
          model.addLibraryEntry(libraryOrderEntry.getLibrary());
        }
        model.commit();
      }
    });
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:InsertComponentProcessor.java

示例5: doOKAction

@Override
protected void doOKAction() {
  if (!createPropertiesFileIfNotExists()) return;
  Collection<PropertiesFile> propertiesFiles = getAllPropertiesFiles();
  for (PropertiesFile propertiesFile : propertiesFiles) {
    IProperty existingProperty = propertiesFile.findPropertyByKey(getKey());
    final String propValue = myValue.getText();
    if (existingProperty != null && !Comparing.strEqual(existingProperty.getValue(), propValue)) {
      final String messageText = CodeInsightBundle.message("i18nize.dialog.error.property.already.defined.message", getKey(), propertiesFile.getName());
      final int code = Messages.showOkCancelDialog(myProject,
                                                   messageText,
                                                   CodeInsightBundle.message("i18nize.dialog.error.property.already.defined.title"),
                                                   null);
      if (code == Messages.CANCEL) {
        return;
      }
    }
  }

  super.doOKAction();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:I18nizeQuickFixDialog.java

示例6: doOKAction

protected void doOKAction() {
  RecentsManager.getInstance(myProject).registerRecentEntry(RECENTS_KEY, myTargetPackageField.getText());
  RecentsManager.getInstance(myProject).registerRecentEntry(RECENT_SUPERS_KEY, mySuperClassField.getText());

  String errorMessage;
  try {
    myTargetDirectory = selectTargetDirectory();
    if (myTargetDirectory == null) return;
    errorMessage = RefactoringMessageUtil.checkCanCreateClass(myTargetDirectory, getClassName());
  }
  catch (IncorrectOperationException e) {
    errorMessage = e.getMessage();
  }

  if (errorMessage != null) {
    final int result = Messages
      .showOkCancelDialog(myProject, errorMessage + ". Update existing class?", CommonBundle.getErrorTitle(), Messages.getErrorIcon());
    if (result == Messages.CANCEL) {
      super.close(CANCEL_EXIT_CODE);
      return;
    }
  }

  saveDefaultLibraryName();
  saveShowInheritedMembersStatus();
  super.doOKAction();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:CreateTestDialog.java

示例7: validate

public boolean validate() throws ConfigurationException {
  if (!super.validate()) {
    return false;
  }

  if (CREATE_SOURCE_PANEL.equals(myCurrentMode) && myRbCreateSource.isSelected()) {
    final String sourceDirectoryPath = getSourceDirectoryPath();
    final String relativePath = myTfSourceDirectoryName.getText().trim();
    if (relativePath.length() == 0) {
      String text = IdeBundle.message("prompt.relative.path.to.sources.empty", FileUtil.toSystemDependentName(sourceDirectoryPath));
      final int answer = Messages.showYesNoCancelDialog(myTfSourceDirectoryName, text, IdeBundle.message("title.mark.source.directory"),
                                             IdeBundle.message("action.mark"), IdeBundle.message("action.do.not.mark"),
                                               CommonBundle.getCancelButtonText(), Messages.getQuestionIcon());
      if (answer == Messages.CANCEL) {
        return false; // cancel
      }
      if (answer == Messages.NO) { // don't mark
        myRbNoSource.doClick();
      }
    }
    if (sourceDirectoryPath != null) {
      final File rootDir = new File(getContentRootPath());
      final File srcDir = new File(sourceDirectoryPath);
      if (!FileUtil.isAncestor(rootDir, srcDir, false)) {
        Messages.showErrorDialog(myTfSourceDirectoryName,
                                 IdeBundle.message("error.source.directory.should.be.under.module.content.root.directory"),
                                 CommonBundle.getErrorTitle());
        return false;
      }
      try {
        VfsUtil.createDirectories(srcDir.getPath());
      }
      catch (IOException e) {
        throw new ConfigurationException(e.getMessage());
      }
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:SourcePathsStep.java

示例8: validate

@Override
public boolean validate() throws ConfigurationException {
  final boolean validated = super.validate();
  if (!validated) {
    return false;
  }

  final List<ModuleDescriptor> modules = myModulesLayoutPanel.getChosenEntries();
  final Map<String, ModuleDescriptor> errors = new LinkedHashMap<String, ModuleDescriptor>();
  for (ModuleDescriptor module : modules) {
    try {
      final String moduleFilePath = module.computeModuleFilePath();
      if (new File(moduleFilePath).exists()) {
        errors.put(IdeBundle.message("warning.message.the.module.file.0.already.exist.and.will.be.overwritten", moduleFilePath), module);
      }
    }
    catch (InvalidDataException e) {
      errors.put(e.getMessage(), module);
    }
  }
  if (!errors.isEmpty()) {
    final int answer = Messages.showYesNoCancelDialog(getComponent(),
                                                      IdeBundle.message("warning.text.0.do.you.want.to.overwrite.these.files",
                                                                        StringUtil.join(errors.keySet(), "\n"), errors.size()),
                                                      IdeBundle.message("title.file.already.exists"), "Overwrite", "Reuse", "Cancel", Messages.getQuestionIcon());
    if (answer == Messages.CANCEL) {
      return false;
    }

    if (answer != Messages.YES) {
      for (ModuleDescriptor moduleDescriptor : errors.values()) {
        moduleDescriptor.reuseExisting(true);
      }
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:ModulesDetectionStep.java

示例9: getState

@Override
public AndroidRunningState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
  final AndroidRunningState state = super.getState(executor, env);

  if (state == null) {
    return null;
  }

  final AndroidFacet facet = state.getFacet();
  final AndroidFacetConfiguration configuration = facet.getConfiguration();

  if (!facet.isGradleProject() && !configuration.getState().PACK_TEST_CODE) {
    final Module module = facet.getModule();
    final int count = getTestSourceRootCount(module);
    
    if (count > 0) {
      final String message = "Code and resources under test source " + (count > 1 ? "roots" : "root") +
                             " aren't included into debug APK.\nWould you like to include them and recompile " +
                             module.getName() + " module?" + "\n(You may change this option in Android facet settings later)";
      final int result =
        Messages.showYesNoCancelDialog(getProject(), message, "Test code not included into APK", Messages.getQuestionIcon());
      
      if (result == Messages.YES) {
        configuration.getState().PACK_TEST_CODE = true;
      }
      else if (result == Messages.CANCEL) {
        return null;
      }
    }
  }
  return state;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:AndroidTestRunConfiguration.java

示例10: checkAddModuleDependency

private boolean checkAddModuleDependency(final ComponentItem item, final ModuleSourceOrderEntry moduleSourceOrderEntry) {
  final Module ownerModule = moduleSourceOrderEntry.getOwnerModule();
  int rc = Messages.showYesNoCancelDialog(
    myEditor,
    UIDesignerBundle.message("add.module.dependency.prompt", item.getClassName(), ownerModule.getName(), myEditor.getModule().getName()),
    UIDesignerBundle.message("add.module.dependency.title"),
    Messages.getQuestionIcon());
  if (rc == Messages.CANCEL) return false;
  if (rc == Messages.YES) {
    ModuleRootModificationUtil.addDependency(myEditor.getModule(), ownerModule);
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:InsertComponentProcessor.java

示例11: showDialog

/**
 * Shows this dialog.
 * <p/>
 * The user now has the choices to either:
 * <ul>
 *    <li/>Replace existing method
 *    <li/>Create a duplicate method
 *    <li/>Cancel
 * </ul>
 *
 * @param targetMethodName   the name of the target method (toString)
 * @return the chosen conflict resolution policy (never null)
 */
public static ConflictResolutionPolicy showDialog(String targetMethodName) {
    int exit = Messages.showYesNoCancelDialog("Replace existing " + targetMethodName + " method", "Method Already Exists", Messages.getQuestionIcon());
    if (exit == Messages.CANCEL) {
        return CancelPolicy.getInstance();
    }
    if (exit == Messages.YES) {
        return ReplacePolicy.getInstance();
    }
    if (exit == Messages.NO) {
        return DuplicatePolicy.getInstance();
    }

    throw new IllegalArgumentException("exit code [" + exit + "] from YesNoCancelDialog not supported");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:MethodExistsDialog.java

示例12: evaluateFinallyBlocks

static boolean evaluateFinallyBlocks(Project project,
                              String title,
                              JavaStackFrame stackFrame,
                              XDebuggerEvaluator.XEvaluationCallback callback) {
  if (!DebuggerSettings.EVALUATE_FINALLY_NEVER.equals(DebuggerSettings.getInstance().EVALUATE_FINALLY_ON_POP_FRAME)) {
    List<PsiStatement> statements = getFinallyStatements(stackFrame.getDescriptor().getSourcePosition());
    if (!statements.isEmpty()) {
      StringBuilder sb = new StringBuilder();
      for (PsiStatement statement : statements) {
        sb.append("\n").append(statement.getText());
      }
      if (DebuggerSettings.EVALUATE_FINALLY_ALWAYS.equals(DebuggerSettings.getInstance().EVALUATE_FINALLY_ON_POP_FRAME)) {
        evaluateAndAct(project, stackFrame, sb, callback);
        return true;
      }
      else {
        int res = MessageDialogBuilder
          .yesNoCancel(title,
                       DebuggerBundle.message("warning.finally.block.detected") + sb)
          .project(project)
          .icon(Messages.getWarningIcon())
          .yesText(DebuggerBundle.message("button.execute.finally"))
          .noText(DebuggerBundle.message("button.drop.anyway"))
          .cancelText(CommonBundle.message("button.cancel"))
          .doNotAsk(
            new DialogWrapper.DoNotAskOption() {
              @Override
              public boolean isToBeShown() {
                return !DebuggerSettings.EVALUATE_FINALLY_ALWAYS.equals(DebuggerSettings.getInstance().EVALUATE_FINALLY_ON_POP_FRAME) &&
                       !DebuggerSettings.EVALUATE_FINALLY_NEVER.equals(DebuggerSettings.getInstance().EVALUATE_FINALLY_ON_POP_FRAME);
              }

              @Override
              public void setToBeShown(boolean value, int exitCode) {
                if (!value) {
                  DebuggerSettings.getInstance().EVALUATE_FINALLY_ON_POP_FRAME =
                    exitCode == Messages.YES ? DebuggerSettings.EVALUATE_FINALLY_ALWAYS : DebuggerSettings.EVALUATE_FINALLY_NEVER;
                }
                else {
                  DebuggerSettings.getInstance().EVALUATE_FINALLY_ON_POP_FRAME = DebuggerSettings.EVALUATE_FINALLY_ASK;
                }
              }

              @Override
              public boolean canBeHidden() {
                return true;
              }

              @Override
              public boolean shouldSaveOptionsOnCancel() {
                return false;
              }

              @NotNull
              @Override
              public String getDoNotShowMessage() {
                return CommonBundle.message("dialog.options.do.not.show");
              }
            })
          .show();

        switch (res) {
          case Messages.CANCEL:
            return true;
          case Messages.NO:
            break;
          case Messages.YES: // evaluate finally
            evaluateAndAct(project, stackFrame, sb, callback);
            return true;
        }
      }
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:75,代码来源:PopFrameAction.java

示例13: buildTemplateAndStart

protected boolean buildTemplateAndStart(final Collection<PsiReference> refs,
                                        final Collection<Pair<PsiElement, TextRange>> stringUsages,
                                        final PsiElement scope,
                                        final PsiFile containingFile) {
  final PsiElement context = InjectedLanguageManager.getInstance(containingFile.getProject()).getInjectionHost(containingFile);
  myScope = context != null ? context.getContainingFile() : scope;
  final TemplateBuilderImpl builder = new TemplateBuilderImpl(myScope);

  PsiElement nameIdentifier = getNameIdentifier();
  int offset = InjectedLanguageUtil.getTopLevelEditor(myEditor).getCaretModel().getOffset();
  PsiElement selectedElement = getSelectedInEditorElement(nameIdentifier, refs, stringUsages, offset);

  boolean subrefOnPrimaryElement = false;
  boolean hasReferenceOnNameIdentifier = false;
  for (PsiReference ref : refs) {
    if (isReferenceAtCaret(selectedElement, ref)) {
      builder.replaceElement(ref.getElement(), getRangeToRename(ref), PRIMARY_VARIABLE_NAME, createLookupExpression(selectedElement), true);
      subrefOnPrimaryElement = true;
      continue;
    }
    addVariable(ref, selectedElement, builder, offset);
    hasReferenceOnNameIdentifier |= isReferenceAtCaret(nameIdentifier, ref);
  }
  if (nameIdentifier != null) {
    hasReferenceOnNameIdentifier |= selectedElement.getTextRange().contains(nameIdentifier.getTextRange());
    if (!subrefOnPrimaryElement || !hasReferenceOnNameIdentifier){
      addVariable(nameIdentifier, selectedElement, builder);
    }
  }
  for (Pair<PsiElement, TextRange> usage : stringUsages) {
    addVariable(usage.first, usage.second, selectedElement, builder);
  }
  addAdditionalVariables(builder);
  try {
    myMarkAction = startRename();
  }
  catch (final StartMarkAction.AlreadyStartedException e) {
    final Document oldDocument = e.getDocument();
    if (oldDocument != myEditor.getDocument()) {
      final int exitCode = Messages.showYesNoCancelDialog(myProject, e.getMessage(), getCommandName(),
                                                          "Navigate to Started", "Cancel Started", "Cancel", Messages.getErrorIcon());
      if (exitCode == Messages.CANCEL) return true;
      navigateToAlreadyStarted(oldDocument, exitCode);
      return true;
    }
    else {

      if (!ourRenamersStack.isEmpty() && ourRenamersStack.peek() == this) {
        ourRenamersStack.pop();
        if (!ourRenamersStack.empty()) {
          myOldName = ourRenamersStack.peek().myOldName;
        }
      }

      revertState();
      final TemplateState templateState = TemplateManagerImpl.getTemplateState(InjectedLanguageUtil.getTopLevelEditor(myEditor));
      if (templateState != null) {
        templateState.gotoEnd(true);
      }
    }
    return false;
  }

  beforeTemplateStart();

  new WriteCommandAction(myProject, getCommandName()) {
    @Override
    protected void run(@NotNull Result result) throws Throwable {
      startTemplate(builder);
    }
  }.execute();

  if (myBalloon == null) {
    showBalloon();
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:77,代码来源:InplaceRefactoring.java


注:本文中的com.intellij.openapi.ui.Messages.CANCEL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。