本文整理汇总了Java中com.intellij.openapi.ui.Messages.showYesNoCancelDialog方法的典型用法代码示例。如果您正苦于以下问题:Java Messages.showYesNoCancelDialog方法的具体用法?Java Messages.showYesNoCancelDialog怎么用?Java Messages.showYesNoCancelDialog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.ui.Messages
的用法示例。
在下文中一共展示了Messages.showYesNoCancelDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: moveDirectoriesLibrariesSafe
import com.intellij.openapi.ui.Messages; //导入方法依赖的package包/类
private static void moveDirectoriesLibrariesSafe(Project project,
PsiElement targetContainer,
MoveCallback callback,
PsiDirectory[] directories,
String prompt) {
final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(directories[0]);
LOG.assertTrue(aPackage != null);
final PsiDirectory[] projectDirectories = aPackage.getDirectories(GlobalSearchScope.projectScope(project));
if (projectDirectories.length > 1) {
int ret = Messages
.showYesNoCancelDialog(project, prompt + " or all directories in project?", RefactoringBundle.message("warning.title"),
RefactoringBundle.message("move.current.directory"),
RefactoringBundle.message("move.directories"),
CommonBundle.getCancelButtonText(), Messages.getWarningIcon());
if (ret == Messages.YES) {
moveAsDirectory(project, targetContainer, callback, directories);
}
else if (ret == Messages.NO) {
moveAsDirectory(project, targetContainer, callback, projectDirectories);
}
}
else if (Messages.showOkCancelDialog(project, prompt + "?", RefactoringBundle.message("warning.title"),
Messages.getWarningIcon()) == Messages.OK) {
moveAsDirectory(project, targetContainer, callback, directories);
}
}
示例2: processFoundCodeSmells
import com.intellij.openapi.ui.Messages; //导入方法依赖的package包/类
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;
}
}
示例3: suggestCreatingFileInstead
import com.intellij.openapi.ui.Messages; //导入方法依赖的package包/类
@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;
}
示例4: checkAddLibraryDependency
import com.intellij.openapi.ui.Messages; //导入方法依赖的package包/类
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;
}
示例5: addRoot
import com.intellij.openapi.ui.Messages; //导入方法依赖的package包/类
boolean addRoot(final TypeMigrationUsageInfo usageInfo, final PsiType type, final PsiElement place, boolean alreadyProcessed) {
if (myShowWarning && myMigrationRoots.size() > 10 && !ApplicationManager.getApplication().isUnitTestMode()) {
myShowWarning = false;
try {
final Runnable checkTimeToStopRunnable = new Runnable() {
public void run() {
if (Messages.showYesNoCancelDialog("Found more than 10 roots to migrate. Do you want to preview?", "Type Migration",
Messages.getWarningIcon()) == Messages.YES) {
myException = new MigrateException();
}
}
};
SwingUtilities.invokeLater(checkTimeToStopRunnable);
}
catch (Exception e) {
//do nothing
}
}
if (myException != null) throw myException;
rememberRootTrace(usageInfo, type, place, alreadyProcessed);
if (!alreadyProcessed && !getTypeEvaluator().setType(usageInfo, type)) {
alreadyProcessed = true;
}
if (!alreadyProcessed) myMigrationRoots.addFirst(Pair.create(usageInfo, type));
return alreadyProcessed;
}
示例6: validate
import com.intellij.openapi.ui.Messages; //导入方法依赖的package包/类
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;
}
示例7: validate
import com.intellij.openapi.ui.Messages; //导入方法依赖的package包/类
@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;
}
示例8: getSuperMethod
import com.intellij.openapi.ui.Messages; //导入方法依赖的package包/类
@Nullable
protected static PyFunction getSuperMethod(@Nullable PyFunction function) {
if (function == null) {
return null;
}
final PyClass containingClass = function.getContainingClass();
if (containingClass == null) {
return function;
}
final PyFunction deepestSuperMethod = PySuperMethodsSearch.findDeepestSuperMethod(function);
if (!deepestSuperMethod.equals(function)) {
final PyClass baseClass = deepestSuperMethod.getContainingClass();
final PyBuiltinCache cache = PyBuiltinCache.getInstance(baseClass);
final String baseClassName = baseClass == null ? "" : baseClass.getName();
if (cache.isBuiltin(baseClass)) {
return function;
}
final String message = PyBundle.message("refactoring.change.signature.find.usages.of.base.class",
function.getName(),
containingClass.getName(),
baseClassName);
final int choice;
if (ApplicationManager.getApplication().isUnitTestMode()) {
choice = Messages.YES;
}
else {
choice = Messages.showYesNoCancelDialog(function.getProject(), message, REFACTORING_NAME, Messages.getQuestionIcon());
}
switch (choice) {
case Messages.YES:
return deepestSuperMethod;
case Messages.NO:
return function;
default:
return null;
}
}
return function;
}
示例9: getState
import com.intellij.openapi.ui.Messages; //导入方法依赖的package包/类
@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;
}
示例10: closeQuery
import com.intellij.openapi.ui.Messages; //导入方法依赖的package包/类
/**
* @return true if content can be closed
*/
private boolean closeQuery() {
if (myContent == null) {
return true;
}
final AntBuildMessageView messageView = myContent.getUserData(KEY);
if (messageView == null || messageView.isStoppedOrTerminateRequested()) {
return true;
}
if (myCloseAllowed) {
return true;
}
final int result = Messages.showYesNoCancelDialog(
AntBundle.message("ant.process.is.active.terminate.confirmation.text"),
AntBundle.message("close.ant.build.messages.dialog.title"), Messages.getQuestionIcon()
);
if (result == 0) { // yes
messageView.stopProcess();
myCloseAllowed = true;
return true;
}
if (result == 1) { // no
// close content and leave the process running
myCloseAllowed = true;
return true;
}
return false;
}
示例11: checkAddModuleDependency
import com.intellij.openapi.ui.Messages; //导入方法依赖的package包/类
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;
}
示例12: showDialog
import com.intellij.openapi.ui.Messages; //导入方法依赖的package包/类
/**
* 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");
}
示例13: invoke
import com.intellij.openapi.ui.Messages; //导入方法依赖的package包/类
public void invoke(@NotNull final Project project, @NotNull final PsiElement[] elements, final DataContext dataContext) {
if (elements.length != 1 || !(elements[0] instanceof PsiMethod)) return;
final PsiMethod method = (PsiMethod)elements[0];
String message = null;
if (!method.getManager().isInProject(method)) {
message = "Move method is not supported for non-project methods";
} else if (method.isConstructor()) {
message = RefactoringBundle.message("move.method.is.not.supported.for.constructors");
} else if (method.getLanguage()!= JavaLanguage.INSTANCE) {
message = RefactoringBundle.message("move.method.is.not.supported.for.0", method.getLanguage().getDisplayName());
}
else {
final PsiClass containingClass = method.getContainingClass();
if (containingClass != null && PsiUtil.typeParametersIterator(containingClass).hasNext() && TypeParametersSearcher.hasTypeParameters(method)) {
message = RefactoringBundle.message("move.method.is.not.supported.for.generic.classes");
}
else if (method.findSuperMethods().length > 0 ||
OverridingMethodsSearch.search(method, true).toArray(PsiMethod.EMPTY_ARRAY).length > 0) {
message = RefactoringBundle.message("move.method.is.not.supported.when.method.is.part.of.inheritance.hierarchy");
}
else {
final Set<PsiClass> classes = MoveInstanceMembersUtil.getThisClassesToMembers(method).keySet();
for (PsiClass aClass : classes) {
if (aClass instanceof JspClass) {
message = RefactoringBundle.message("synthetic.jsp.class.is.referenced.in.the.method");
Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.MOVE_INSTANCE_METHOD);
break;
}
}
}
}
if (message != null) {
showErrorHint(project, dataContext, message);
return;
}
final List<PsiVariable> suitableVariables = new ArrayList<PsiVariable>();
message = collectSuitableVariables(method, suitableVariables);
if (message != null) {
final String unableToMakeStaticMessage = MakeStaticHandler.validateTarget(method);
if (unableToMakeStaticMessage != null) {
showErrorHint(project, dataContext, message);
}
else {
final String suggestToMakeStaticMessage = "Would you like to make method \'" + method.getName() + "\' static and then move?";
if (Messages
.showYesNoCancelDialog(project, message + ". " + suggestToMakeStaticMessage,
REFACTORING_NAME, Messages.getErrorIcon()) == Messages.YES) {
MakeStaticHandler.invoke(method);
}
}
return;
}
new MoveInstanceMethodDialog(
method,
suitableVariables.toArray(new PsiVariable[suitableVariables.size()])).show();
}
示例14: addMouseShortcut
import com.intellij.openapi.ui.Messages; //导入方法依赖的package包/类
private void addMouseShortcut(Shortcut shortcut, ShortcutRestrictions restrictions) {
String actionId = myActionsTree.getSelectedActionId();
if (actionId == null) {
return;
}
Keymap keymap = createKeymapCopyIfNeeded();
MouseShortcut mouseShortcut = shortcut instanceof MouseShortcut ? (MouseShortcut)shortcut : null;
Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(this));
MouseShortcutDialog dialog = new MouseShortcutDialog(
this,
mouseShortcut,
keymap,
actionId,
ActionsTreeUtil.createMainGroup(project, keymap, myQuickLists, null, true, null),
restrictions
);
if (!dialog.showAndGet()) {
return;
}
mouseShortcut = dialog.getMouseShortcut();
if (mouseShortcut == null) {
return;
}
String[] actionIds = keymap.getActionIds(mouseShortcut);
if (actionIds.length > 1 || (actionIds.length == 1 && !actionId.equals(actionIds[0]))) {
int result = Messages.showYesNoCancelDialog(
this,
KeyMapBundle.message("conflict.shortcut.dialog.message"),
KeyMapBundle.message("conflict.shortcut.dialog.title"),
KeyMapBundle.message("conflict.shortcut.dialog.remove.button"),
KeyMapBundle.message("conflict.shortcut.dialog.leave.button"),
KeyMapBundle.message("conflict.shortcut.dialog.cancel.button"),
Messages.getWarningIcon());
if (result == Messages.YES) {
for (String id : actionIds) {
keymap.removeShortcut(id, mouseShortcut);
}
}
else if (result != Messages.NO) {
return;
}
}
// if shortcut is already registered to this action, just select it in the list
Shortcut[] shortcuts = keymap.getShortcuts(actionId);
for (Shortcut shortcut1 : shortcuts) {
if (shortcut1.equals(mouseShortcut)) {
return;
}
}
keymap.addShortcut(actionId, mouseShortcut);
if (StringUtil.startsWithChar(actionId, '$')) {
keymap.addShortcut(KeyMapBundle.message("editor.shortcut", actionId.substring(1)), mouseShortcut);
}
repaintLists();
currentKeymapChanged();
}
示例15: exportTextToFile
import com.intellij.openapi.ui.Messages; //导入方法依赖的package包/类
public static void exportTextToFile(Project project, String fileName, String textToExport) {
String prepend = "";
File file = new File(fileName);
if (file.exists()) {
int result = Messages.showYesNoCancelDialog(
project,
IdeBundle.message("error.text.file.already.exists", fileName),
IdeBundle.message("title.warning"),
IdeBundle.message("action.overwrite"),
IdeBundle.message("action.append"),
CommonBundle.getCancelButtonText(),
Messages.getWarningIcon()
);
if (result != Messages.NO && result != Messages.YES) {
return;
}
if (result == Messages.NO) {
char[] buf = new char[(int)file.length()];
try {
FileReader reader = new FileReader(fileName);
try {
reader.read(buf, 0, (int)file.length());
prepend = new String(buf) + SystemProperties.getLineSeparator();
}
finally {
reader.close();
}
}
catch (IOException ignored) {
}
}
}
try {
FileWriter writer = new FileWriter(fileName);
try {
writer.write(prepend + textToExport);
}
finally {
writer.close();
}
}
catch (IOException e) {
Messages.showMessageDialog(
project,
IdeBundle.message("error.writing.to.file", fileName),
CommonBundle.getErrorTitle(),
Messages.getErrorIcon()
);
}
}