List of usage examples for com.intellij.openapi.ui Messages showWarningDialog
public static void showWarningDialog(@NotNull Component component, String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title)
From source file:com.intellij.debugger.actions.JavaValueModifier.java
License:Apache License
@Override public void setValue(@NotNull String expression, @NotNull XModificationCallback callback) { final NodeDescriptorImpl descriptor = myJavaValue.getDescriptor(); if (!(descriptor instanceof ValueDescriptorImpl)) { return;//from w ww .j av a 2 s. co m } if (!((ValueDescriptorImpl) descriptor).canSetValue()) { return; } //final DebuggerTree tree = getTree(event.getDataContext()); //final DebuggerContextImpl debuggerContext = getDebuggerContext(event.getDataContext()); final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(myJavaValue.getProject()) .getContext(); //tree.saveState(node); if (descriptor instanceof FieldDescriptorImpl) { FieldDescriptorImpl fieldDescriptor = (FieldDescriptorImpl) descriptor; final Field field = fieldDescriptor.getField(); if (!field.isStatic()) { final ObjectReference object = fieldDescriptor.getObject(); if (object != null) { set(expression, callback, debuggerContext, new SetValueRunnable() { public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException { object.setValue(field, preprocessValue(evaluationContext, newValue, field.type())); update(debuggerContext); } public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException { return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, field.declaringType().classLoader()); } }); } } else { // field is static ReferenceType refType = field.declaringType(); if (refType instanceof ClassType) { final ClassType classType = (ClassType) refType; set(expression, callback, debuggerContext, new SetValueRunnable() { public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException { classType.setValue(field, preprocessValue(evaluationContext, newValue, field.type())); update(debuggerContext); } public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException { return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, field.declaringType().classLoader()); } }); } } } else if (descriptor instanceof LocalVariableDescriptorImpl) { LocalVariableDescriptorImpl localDescriptor = (LocalVariableDescriptorImpl) descriptor; final LocalVariableProxyImpl local = localDescriptor.getLocalVariable(); if (local != null) { set(expression, callback, debuggerContext, new SetValueRunnable() { public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException { debuggerContext.getFrameProxy().setValue(local, preprocessValue(evaluationContext, newValue, local.getType())); update(debuggerContext); } public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException { return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, evaluationContext.getClassLoader()); } }); } } else if (descriptor instanceof ArrayElementDescriptorImpl) { final ArrayElementDescriptorImpl elementDescriptor = (ArrayElementDescriptorImpl) descriptor; final ArrayReference array = elementDescriptor.getArray(); if (array != null) { if (VirtualMachineProxyImpl.isCollected(array)) { // will only be the case if debugger does not use ObjectReference.disableCollection() because of Patches // .IBM_JDK_DISABLE_COLLECTION_BUG Messages.showWarningDialog(myJavaValue.getProject(), DebuggerBundle.message("evaluation.error.array.collected") + "\n" + DebuggerBundle.message("warning.recalculate"), DebuggerBundle.message("title.set.value")); //node.getParent().calcValue(); return; } final ArrayType arrType = (ArrayType) array.referenceType(); set(expression, callback, debuggerContext, new SetValueRunnable() { public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException { array.setValue(elementDescriptor.getIndex(), preprocessValue(evaluationContext, newValue, arrType.componentType())); update(debuggerContext); } public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException { return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, arrType.classLoader()); } }); } } else if (descriptor instanceof EvaluationDescriptor) { final EvaluationDescriptor evaluationDescriptor = (EvaluationDescriptor) descriptor; if (evaluationDescriptor.canSetValue()) { set(expression, callback, debuggerContext, new SetValueRunnable() { public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException { final Modifier modifier = evaluationDescriptor.getModifier(); modifier.setValue(preprocessValue(evaluationContext, newValue, modifier.getExpectedType())); update(debuggerContext); } public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException { return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, evaluationContext.getClassLoader()); } }); } } }
From source file:com.intellij.debugger.actions.SetValueAction.java
License:Apache License
public void actionPerformed(final AnActionEvent event) { final DebuggerTreeNodeImpl node = getSelectedNode(event.getDataContext()); if (node == null) { return;// ww w . j av a 2s .c o m } final NodeDescriptorImpl descriptor = node.getDescriptor(); if (!(descriptor instanceof ValueDescriptorImpl)) { return; } if (!((ValueDescriptorImpl) descriptor).canSetValue()) { return; } final DebuggerTree tree = getTree(event.getDataContext()); final DebuggerContextImpl debuggerContext = getDebuggerContext(event.getDataContext()); tree.saveState(node); if (descriptor instanceof FieldDescriptorImpl) { FieldDescriptorImpl fieldDescriptor = (FieldDescriptorImpl) descriptor; final Field field = fieldDescriptor.getField(); if (!field.isStatic()) { final ObjectReference object = fieldDescriptor.getObject(); if (object != null) { askAndSet(node, debuggerContext, new SetValueRunnable() { public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException { object.setValue(field, preprocessValue(evaluationContext, newValue, field.type())); update(debuggerContext); } public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException { return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, field.declaringType().classLoader()); } }); } } else { // field is static ReferenceType refType = field.declaringType(); if (refType instanceof ClassType) { final ClassType classType = (ClassType) refType; askAndSet(node, debuggerContext, new SetValueRunnable() { public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException { classType.setValue(field, preprocessValue(evaluationContext, newValue, field.type())); update(debuggerContext); } public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException { return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, field.declaringType().classLoader()); } }); } } } else if (descriptor instanceof LocalVariableDescriptorImpl) { LocalVariableDescriptorImpl localDescriptor = (LocalVariableDescriptorImpl) descriptor; final LocalVariableProxyImpl local = localDescriptor.getLocalVariable(); if (local != null) { askAndSet(node, debuggerContext, new SetValueRunnable() { public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException { debuggerContext.getFrameProxy().setValue(local, preprocessValue(evaluationContext, newValue, local.getType())); update(debuggerContext); } public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException { return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, evaluationContext.getClassLoader()); } }); } } else if (descriptor instanceof ArrayElementDescriptorImpl) { final ArrayElementDescriptorImpl elementDescriptor = (ArrayElementDescriptorImpl) descriptor; final ArrayReference array = elementDescriptor.getArray(); if (array != null) { if (VirtualMachineProxyImpl.isCollected(array)) { // will only be the case if debugger does not use ObjectReference.disableCollection() because of Patches.IBM_JDK_DISABLE_COLLECTION_BUG Messages.showWarningDialog(tree, DebuggerBundle.message("evaluation.error.array.collected") + "\n" + DebuggerBundle.message("warning.recalculate"), DebuggerBundle.message("title.set.value")); node.getParent().calcValue(); return; } final ArrayType arrType = (ArrayType) array.referenceType(); askAndSet(node, debuggerContext, new SetValueRunnable() { public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException { array.setValue(elementDescriptor.getIndex(), preprocessValue(evaluationContext, newValue, arrType.componentType())); update(debuggerContext); } public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException { return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, arrType.classLoader()); } }); } } else if (descriptor instanceof EvaluationDescriptor) { final EvaluationDescriptor evaluationDescriptor = (EvaluationDescriptor) descriptor; if (evaluationDescriptor.canSetValue()) { askAndSet(node, debuggerContext, new SetValueRunnable() { public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException { final Modifier modifier = evaluationDescriptor.getModifier(); modifier.setValue(preprocessValue(evaluationContext, newValue, modifier.getExpectedType())); update(debuggerContext); } public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException { return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, evaluationContext.getClassLoader()); } }); } } }
From source file:com.intellij.lang.ant.config.actions.AddAntBuildFile.java
License:Apache License
public void actionPerformed(AnActionEvent e) { Project project = e.getProject();// w w w . java2 s. c o m VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE); AntConfiguration antConfiguration = AntConfiguration.getInstance(project); try { antConfiguration.addBuildFile(file); ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.ANT_BUILD).activate(null); } catch (AntNoFileException ex) { String message = ex.getMessage(); if (message == null || message.length() == 0) { message = AntBundle.message("cannot.add.build.files.from.excluded.directories.error.message", ex.getFile().getPresentableUrl()); } Messages.showWarningDialog(project, message, AntBundle.message("cannot.add.build.file.dialog.title")); } }
From source file:com.intellij.lang.ant.config.explorer.AntExplorer.java
License:Apache License
private void addBuildFile(final VirtualFile[] files) { if (files.length == 0) { return;/*from ww w .j av a 2s . c o m*/ } ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { final AntConfiguration antConfiguration = myConfig; if (antConfiguration == null) { return; } final List<VirtualFile> ignoredFiles = new ArrayList<VirtualFile>(); for (VirtualFile file : files) { try { antConfiguration.addBuildFile(file); } catch (AntNoFileException e) { ignoredFiles.add(e.getFile()); } } if (ignoredFiles.size() != 0) { String messageText; final StringBuilder message = StringBuilderSpinAllocator.alloc(); try { String separator = ""; for (final VirtualFile virtualFile : ignoredFiles) { message.append(separator); message.append(virtualFile.getPresentableUrl()); separator = "\n"; } messageText = message.toString(); } finally { StringBuilderSpinAllocator.dispose(message); } Messages.showWarningDialog(myProject, messageText, AntBundle.message("cannot.add.ant.files.dialog.title")); } } }); }
From source file:com.intellij.refactoring.changeSignature.ChangeSignatureDialogBase.java
License:Apache License
@Override protected void doAction() { if (myParametersTable != null) { TableUtil.stopEditing(myParametersTable); }/*from w w w .j a va2 s. c om*/ String message = validateAndCommitData(); if (message != null) { if (message != EXIT_SILENTLY) { CommonRefactoringUtil.showErrorMessage(getTitle(), message, getHelpId(), myProject); } return; } if (myMethodsToPropagateParameters != null && !mayPropagateParameters()) { Messages.showWarningDialog(myProject, RefactoringBundle.message("changeSignature.parameters.wont.propagate"), ChangeSignatureHandler.REFACTORING_NAME); myMethodsToPropagateParameters = null; } invokeRefactoring(createRefactoringProcessor()); }
From source file:com.intellij.refactoring.changeSignature.JavaChangeSignatureDialog.java
License:Apache License
@Override protected void invokeRefactoring(final BaseRefactoringProcessor processor) { if (myMethodsToPropagateExceptions != null && !mayPropagateExceptions()) { Messages.showWarningDialog(myProject, RefactoringBundle.message("changeSignature.exceptions.wont.propagate"), REFACTORING_NAME); myMethodsToPropagateExceptions = null; }//w ww. j a v a 2 s . c o m super.invokeRefactoring(processor); }
From source file:com.intellij.tasks.actions.vcs.VcsOpenTaskPanel.java
License:Apache License
private void updateFields(boolean initial) { if (!initial && myBranchFrom.getItemCount() == 0 && myCreateBranch.isSelected()) { Messages.showWarningDialog(myPanel, "Can't create branch if no commit exists.\nCreate a commit first.", "Cannot Create Branch"); myCreateBranch.setSelected(false); }/* w w w . jav a2 s .c om*/ myBranchName.setEnabled(myCreateBranch.isSelected()); myFromLabel.setEnabled(myCreateBranch.isSelected()); myBranchFrom.setEnabled(myCreateBranch.isSelected()); myUseBranchCombo.setEnabled(myUseBranch.isSelected()); myChangelistName.setEnabled(myCreateChangelist.isSelected()); }
From source file:com.maddyhome.idea.copyright.ui.CopyrightProfilesPanel.java
License:Apache License
@Nullable protected ArrayList<AnAction> createActions(boolean fromPopup) { ArrayList<AnAction> result = new ArrayList<AnAction>(); result.add(new AnAction("Add", "Add", IconUtil.getAddIcon()) { {//w w w.j a v a2 s .co m registerCustomShortcutSet(CommonShortcuts.INSERT, myTree); } public void actionPerformed(AnActionEvent event) { final String name = askForProfileName("Create Copyright Profile", ""); if (name == null) return; final CopyrightProfile copyrightProfile = new CopyrightProfile(name); addProfileNode(copyrightProfile); } }); result.add(new MyDeleteAction(forAll(Conditions.alwaysTrue()))); result.add(new AnAction("Copy", "Copy", AllIcons.Actions.Copy) { { registerCustomShortcutSet( new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, KeyEvent.CTRL_MASK)), myTree); } public void actionPerformed(AnActionEvent event) { final String profileName = askForProfileName("Copy Copyright Profile", ""); if (profileName == null) return; final CopyrightProfile clone = new CopyrightProfile(); clone.copyFrom((CopyrightProfile) getSelectedObject()); clone.setName(profileName); addProfileNode(clone); } public void update(AnActionEvent event) { super.update(event); event.getPresentation().setEnabled(getSelectedObject() != null); } }); result.add(new AnAction("Import", "Import", AllIcons.ToolbarDecorator.Import) { public void actionPerformed(AnActionEvent event) { final OpenProjectFileChooserDescriptor descriptor = new OpenProjectFileChooserDescriptor(true) { @Override public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { return super.isFileVisible(file, showHiddenFiles) || canContainCopyright(file); } @Override public boolean isFileSelectable(VirtualFile file) { return super.isFileSelectable(file) || canContainCopyright(file); } private boolean canContainCopyright(VirtualFile file) { return !file.isDirectory() && file.getFileType() == InternalStdFileTypes.XML; } }; descriptor.setTitle("Choose file containing copyright notice"); final VirtualFile file = FileChooser.chooseFile(descriptor, myProject, null); if (file == null) return; final List<CopyrightProfile> copyrightProfiles = ExternalOptionHelper .loadOptions(VfsUtil.virtualToIoFile(file)); if (copyrightProfiles == null) return; if (!copyrightProfiles.isEmpty()) { if (copyrightProfiles.size() == 1) { importProfile(copyrightProfiles.get(0)); } else { JBPopupFactory.getInstance() .createListPopup(new BaseListPopupStep<CopyrightProfile>("Choose profile to import", copyrightProfiles) { @Override public PopupStep onChosen(final CopyrightProfile selectedValue, boolean finalChoice) { return doFinalStep(new Runnable() { public void run() { importProfile(selectedValue); } }); } @NotNull @Override public String getTextFor(CopyrightProfile value) { return value.getName(); } }).showUnderneathOf(myNorthPanel); } } else { Messages.showWarningDialog(myProject, "The selected file does not contain any copyright settings.", "Import Failure"); } } private void importProfile(CopyrightProfile copyrightProfile) { final String profileName = askForProfileName("Import copyright profile", copyrightProfile.getName()); if (profileName == null) return; copyrightProfile.setName(profileName); addProfileNode(copyrightProfile); Messages.showInfoMessage(myProject, "The copyright settings have been successfully imported.", "Import Complete"); } }); return result; }
From source file:com.microsoft.alm.plugin.idea.common.utils.IdeaHelper.java
License:Open Source License
/** * Verifies if Git exe is configured, show notification and warning message if not * * @param project Idea project/*from www .j a v a 2 s .c om*/ * @return true if Git exe is configured, false if Git exe is not correctly configured */ public static boolean isGitExeConfigured(@NotNull final Project project) { final GitExecutableValidator validator = GitVcs.getInstance(project).getExecutableValidator(); if (!validator.checkExecutableAndNotifyIfNeeded()) { //Git.exe is not configured, show warning message in addition to notification from Git plugin Messages.showWarningDialog(project, TfPluginBundle.message(TfPluginBundle.KEY_GIT_NOT_CONFIGURED), TfPluginBundle.message(TfPluginBundle.KEY_TF_GIT)); return false; } return true; }
From source file:com.microsoft.alm.plugin.idea.common.utils.IdeaHelper.java
License:Open Source License
/** * Verifies if TF is configured, show notification and warning message if not * * @param project Idea project/*from w w w . j a v a 2s .co m*/ * @return true if TF is configured, false if TF is not correctly configured */ public static boolean isTFConfigured(@NotNull final Project project) { final String tfLocation = TfTool.getLocation(); if (StringUtils.isEmpty(tfLocation)) { //TF is not configured, show warning message Messages.showWarningDialog(project, TfPluginBundle.message(TfPluginBundle.KEY_TFVC_NOT_CONFIGURED), TfPluginBundle.message(TfPluginBundle.KEY_TFVC)); return false; } return true; }