List of usage examples for com.intellij.openapi.ui Messages getErrorIcon
@NotNull public static Icon getErrorIcon()
From source file:com.intellij.execution.ProgramRunnerUtil.java
License:Apache License
public static void executeConfiguration(@NotNull ExecutionEnvironment environment, boolean showSettings, boolean assignNewId) { if (ExecutorRegistry.getInstance().isStarting(environment)) { return;/*from ww w . j ava 2s. c om*/ } RunnerAndConfigurationSettings runnerAndConfigurationSettings = environment .getRunnerAndConfigurationSettings(); if (runnerAndConfigurationSettings != null) { if (!ExecutionTargetManager.canRun(environment)) { ExecutionUtil.handleExecutionError(environment, new ExecutionException( StringUtil.escapeXml("Cannot run '" + environment.getRunProfile().getName() + "' on '" + environment.getExecutionTarget().getDisplayName() + "'"))); return; } if (!RunManagerImpl.canRunConfiguration(environment) || (showSettings && runnerAndConfigurationSettings.isEditBeforeRun())) { if (!RunDialog.editConfiguration(environment, "Edit configuration")) { return; } while (!RunManagerImpl.canRunConfiguration(environment)) { if (Messages.YES == Messages.showYesNoDialog(environment.getProject(), "Configuration is still incorrect. Do you want to edit it again?", "Change Configuration Settings", "Edit", "Continue Anyway", Messages.getErrorIcon())) { if (!RunDialog.editConfiguration(environment, "Edit configuration")) { return; } } else { break; } } } ConfigurationType configurationType = runnerAndConfigurationSettings.getType(); if (configurationType != null) { UsageTrigger.trigger("execute." + ConvertUsagesUtil.ensureProperKey(configurationType.getId()) + "." + environment.getExecutor().getId()); } } try { if (assignNewId) { environment.assignNewExecutionId(); } environment.getRunner().execute(environment); } catch (ExecutionException e) { String name = runnerAndConfigurationSettings != null ? runnerAndConfigurationSettings.getName() : null; if (name == null) { name = environment.getRunProfile().getName(); } if (name == null && environment.getContentToReuse() != null) { name = environment.getContentToReuse().getDisplayName(); } if (name == null) { name = "<Unknown>"; } ExecutionUtil.handleExecutionError(environment.getProject(), environment.getExecutor().getToolWindowId(), name, e); } }
From source file:com.intellij.execution.util.ExecutionErrorDialog.java
License:Apache License
public static void show(final ExecutionException e, final String title, final Project project) { if (e instanceof RunCanceledByUserException) { return;/*from w w w.j a v a 2s . c o m*/ } if (ApplicationManager.getApplication().isUnitTestMode()) { throw new RuntimeException(e.getLocalizedMessage()); } final String message = e.getMessage(); if (message == null || message.length() < 100) { Messages.showErrorDialog(project, message == null ? "exception was thrown" : message, title); return; } final DialogBuilder builder = new DialogBuilder(project); builder.setTitle(title); final JTextArea textArea = new JTextArea(); textArea.setEditable(false); textArea.setForeground(UIUtil.getLabelForeground()); textArea.setBackground(UIUtil.getLabelBackground()); textArea.setFont(UIUtil.getLabelFont()); textArea.setText(message); textArea.setWrapStyleWord(false); textArea.setLineWrap(true); final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(textArea); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); final JPanel panel = new JPanel(new BorderLayout(10, 0)); panel.setPreferredSize(new Dimension(500, 200)); panel.add(scrollPane, BorderLayout.CENTER); panel.add(new JLabel(Messages.getErrorIcon()), BorderLayout.WEST); builder.setCenterPanel(panel); builder.setButtonsAlignment(SwingConstants.CENTER); builder.addOkAction(); builder.show(); }
From source file:com.intellij.find.actions.FindUsagesAction.java
License:Apache License
static void chooseAmbiguousTargetAndPerform(@NotNull final Project project, final Editor editor, @NotNull PsiElementProcessor<PsiElement> processor) { if (editor == null) { Messages.showMessageDialog(project, FindBundle.message("find.no.usages.at.cursor.error"), CommonBundle.getErrorTitle(), Messages.getErrorIcon()); } else {/*from w ww . ja v a2 s . c o m*/ int offset = editor.getCaretModel().getOffset(); boolean chosen = GotoDeclarationAction.chooseAmbiguousTarget(editor, offset, processor, FindBundle.message("find.usages.ambiguous.title"), null); if (!chosen) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { if (editor.isDisposed() || !editor.getComponent().isShowing()) return; HintManager.getInstance().showErrorHint(editor, FindBundle.message("find.no.usages.at.cursor.error")); } }, project.getDisposed()); } } }
From source file:com.intellij.find.actions.FindUsagesInFileAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent e) { DataContext dataContext = e.getDataContext(); final Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project == null) return;/*from w w w . ja v a 2s. c om*/ PsiDocumentManager.getInstance(project).commitAllDocuments(); Editor editor = PlatformDataKeys.EDITOR.getData(dataContext); UsageTarget[] usageTargets = UsageView.USAGE_TARGETS_KEY.getData(dataContext); if (usageTargets != null) { FileEditor fileEditor = PlatformDataKeys.FILE_EDITOR.getData(dataContext); if (fileEditor != null) { usageTargets[0].findUsagesInEditor(fileEditor); } } else if (editor == null) { Messages.showMessageDialog(project, FindBundle.message("find.no.usages.at.cursor.error"), CommonBundle.getErrorTitle(), Messages.getErrorIcon()); } else { HintManager.getInstance().showErrorHint(editor, FindBundle.message("find.no.usages.at.cursor.error")); } }
From source file:com.intellij.find.impl.FindDialog.java
License:Apache License
private void doOKAction(boolean findAll) { FindModel validateModel = (FindModel) myModel.clone(); applyTo(validateModel, findAll);/* w ww.ja v a2 s.co m*/ ValidationInfo validationInfo = getValidationInfo(validateModel); if (validationInfo == null) { myModel.copyFrom(validateModel); updateFindSettings(); super.doOKAction(); myOkHandler.consume(myModel); } else { String message = validationInfo.message; Messages.showMessageDialog(myProject, message, CommonBundle.getErrorTitle(), Messages.getErrorIcon()); } }
From source file:com.intellij.ide.actions.CreateDirectoryOrPackageHandler.java
License:Apache License
private void showErrorDialog(String message) { String title = CommonBundle.getErrorTitle(); Icon icon = Messages.getErrorIcon(); if (myDialogParent != null) { Messages.showMessageDialog(myDialogParent, message, title, icon); } else {/*from ww w . java 2s. c o m*/ Messages.showMessageDialog(myProject, message, title, icon); } }
From source file:com.intellij.ide.actions.ElementCreator.java
License:Apache License
public PsiElement[] tryCreate(@NotNull final String inputString) { if (inputString.length() == 0) { Messages.showMessageDialog(myProject, IdeBundle.message("error.name.should.be.specified"), CommonBundle.getErrorTitle(), Messages.getErrorIcon()); return PsiElement.EMPTY_ARRAY; }/*w w w .java 2s. com*/ final Exception[] exception = new Exception[1]; final SmartPsiElementPointer[][] myCreatedElements = { null }; final String commandName = getActionName(inputString); new WriteCommandAction(myProject, commandName) { @Override protected void run(Result result) throws Throwable { LocalHistoryAction action = LocalHistoryAction.NULL; try { action = LocalHistory.getInstance().startAction(commandName); PsiElement[] psiElements = create(inputString); myCreatedElements[0] = new SmartPsiElementPointer[psiElements.length]; SmartPointerManager manager = SmartPointerManager.getInstance(myProject); for (int i = 0; i < myCreatedElements[0].length; i++) { myCreatedElements[0][i] = manager.createSmartPsiElementPointer(psiElements[i]); } } catch (Exception ex) { exception[0] = ex; } finally { action.finish(); } } @Override protected UndoConfirmationPolicy getUndoConfirmationPolicy() { return UndoConfirmationPolicy.REQUEST_CONFIRMATION; } }.execute(); if (exception[0] != null) { LOG.info(exception[0]); String errorMessage = CreateElementActionBase.filterMessage(exception[0].getMessage()); if (errorMessage == null || errorMessage.length() == 0) { errorMessage = exception[0].toString(); } Messages.showMessageDialog(myProject, errorMessage, myErrorTitle, Messages.getErrorIcon()); return PsiElement.EMPTY_ARRAY; } List<PsiElement> result = new SmartList<PsiElement>(); for (final SmartPsiElementPointer pointer : myCreatedElements[0]) { ContainerUtil.addIfNotNull(pointer.getElement(), result); } return PsiUtilBase.toPsiElementArray(result); }
From source file:com.intellij.ide.actions.ExternalJavaDocAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent e) { DataContext dataContext = e.getDataContext(); Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project == null) { return;//www . j ava 2 s .com } Editor editor = CommonDataKeys.EDITOR.getData(dataContext); PsiElement element = getElement(dataContext, editor); if (element == null) { Messages.showMessageDialog(project, IdeBundle.message("message.please.select.element.for.javadoc"), IdeBundle.message("title.no.element.selected"), Messages.getErrorIcon()); return; } PsiFile context = CommonDataKeys.PSI_FILE.getData(dataContext); PsiElement originalElement = getOriginalElement(context, editor); DocumentationManager.storeOriginalElement(project, originalElement, element); final DocumentationProvider provider = DocumentationManager.getProviderFromElement(element); if (provider instanceof ExternalDocumentationHandler && ((ExternalDocumentationHandler) provider).handleExternal(element, originalElement)) { return; } final List<String> urls = provider.getUrlFor(element, originalElement); if (urls != null && !urls.isEmpty()) { showExternalJavadoc(urls, PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext)); } else if (provider instanceof ExternalDocumentationProvider) { final ExternalDocumentationProvider externalDocumentationProvider = (ExternalDocumentationProvider) provider; if (externalDocumentationProvider.canPromptToConfigureDocumentation(element)) { externalDocumentationProvider.promptToConfigureDocumentation(element); } } }
From source file:com.intellij.ide.actions.OpenFileAction.java
License:Apache License
public static void openFile(final VirtualFile virtualFile, final Project project) { FileEditorProviderManager editorProviderManager = FileEditorProviderManager.getInstance(); if (editorProviderManager.getProviders(project, virtualFile).length == 0) { Messages.showMessageDialog(project, IdeBundle.message("error.files.of.this.type.cannot.be.opened", ApplicationNamesInfo.getInstance().getProductName()), IdeBundle.message("title.cannot.open.file"), Messages.getErrorIcon()); return;/*from w w w.java2 s .co m*/ } OpenFileDescriptor descriptor = new OpenFileDescriptor(project, virtualFile); FileEditorManager.getInstance(project).openTextEditor(descriptor, true); }
From source file:com.intellij.ide.actions.ToggleReadOnlyAttributeAction.java
License:Apache License
public void actionPerformed(final AnActionEvent e) { ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { // Save all documents. We won't be able to save changes to the files that became read-only afterwards. FileDocumentManager.getInstance().saveAllDocuments(); try { VirtualFile[] files = getFiles(e.getDataContext()); for (VirtualFile file : files) { ReadOnlyAttributeUtil.setReadOnlyAttribute(file, file.isWritable()); }//from w ww.j a v a 2s . co m } catch (IOException exc) { Project project = CommonDataKeys.PROJECT.getData(e.getDataContext()); Messages.showMessageDialog(project, exc.getMessage(), CommonBundle.getErrorTitle(), Messages.getErrorIcon()); } } }); }