Example usage for com.intellij.openapi.ui Messages getErrorIcon

List of usage examples for com.intellij.openapi.ui Messages getErrorIcon

Introduction

In this page you can find the example usage for com.intellij.openapi.ui Messages getErrorIcon.

Prototype

@NotNull
    public static Icon getErrorIcon() 

Source Link

Usage

From source file:org.jetbrains.plugins.groovy.doc.GenerateGroovyDocDialog.java

License:Apache License

private void showError(final String message) {
    Messages.showMessageDialog(myProject, message, CommonBundle.getErrorTitle(), Messages.getErrorIcon());
}

From source file:org.jetbrains.plugins.groovy.mvc.MvcFramework.java

License:Apache License

public void createApplicationIfNeeded(@NotNull final Module module) {
    if (findAppRoot(module) == null && module.getUserData(CREATE_APP_STRUCTURE) == Boolean.TRUE) {
        while (ModuleUtilCore.getSdk(module, JavaModuleExtensionImpl.class) == null) {
            if (Messages.showYesNoDialog(module.getProject(), "Cannot generate " + getDisplayName()
                    + " project structure because JDK is not specified for module \"" + module.getName()
                    + "\".\n" + getDisplayName()
                    + " project will not be created if you don't specify JDK.\nDo you want to specify JDK?",
                    "Error", Messages.getErrorIcon()) == 1) {
                return;
            }/*from   w ww. j av  a 2 s .  c o  m*/
            ProjectSettingsService.getInstance(module.getProject())
                    .showModuleConfigurationDialog(module.getName(), ClasspathEditor.NAME);
        }
        module.putUserData(CREATE_APP_STRUCTURE, null);
        final GeneralCommandLine commandLine = getCreationCommandLine(module);
        if (commandLine == null)
            return;

        MvcConsole.executeProcess(module, commandLine, new Runnable() {
            public void run() {
                VirtualFile root = findAppRoot(module);
                if (root == null)
                    return;

                PsiDirectory psiDir = PsiManager.getInstance(module.getProject()).findDirectory(root);
                IdeView ide = LangDataKeys.IDE_VIEW.getData(DataManager.getInstance().getDataContext());
                if (ide != null)
                    ide.selectElement(psiDir);

                //also here comes fileCreated(application.properties) which manages roots and run configuration
            }
        }, true);
    }

}

From source file:org.jetbrains.plugins.groovy.refactoring.convertToJava.ConvertToJavaProcessor.java

License:Apache License

@Override
protected void performRefactoring(UsageInfo[] usages) {
    final GeneratorClassNameProvider classNameProvider = new GeneratorClassNameProvider();

    ExpressionContext context = new ExpressionContext(myProject, myFiles);
    final ClassGenerator classGenerator = new ClassGenerator(classNameProvider,
            new ClassItemGeneratorImpl(context));

    for (GroovyFile file : myFiles) {
        final PsiClass[] classes = file.getClasses();
        StringBuilder builder = new StringBuilder();
        boolean first = true;
        for (PsiClass aClass : classes) {
            classGenerator.writeTypeDefinition(builder, aClass, true, first);
            first = false;// www  . j av a2 s .  co m
            builder.append('\n');
        }

        final Document document = PsiDocumentManager.getInstance(myProject).getDocument(file);
        LOG.assertTrue(document != null);
        document.setText(builder.toString());
        PsiDocumentManager.getInstance(myProject).commitDocument(document);
        String fileName = getNewFileName(file);
        PsiElement newFile;
        try {
            newFile = file.setName(fileName);
        } catch (final IncorrectOperationException e) {
            ApplicationManager.getApplication().invokeLater(new Runnable() {
                @Override
                public void run() {
                    Messages.showMessageDialog(myProject, e.getMessage(),
                            RefactoringBundle.message("error.title"), Messages.getErrorIcon());
                }
            });
            return;
        }

        doPostProcessing(newFile);
    }
}

From source file:org.jetbrains.plugins.groovy.refactoring.introduce.constant.GrIntroduceConstantDialog.java

License:Apache License

@Override
protected void doOKAction() {
    final String targetClassName = getTargetClassName();

    if (myDefaultTargetClass == null || !targetClassName.isEmpty()
            && !Comparing.strEqual(targetClassName, myDefaultTargetClass.getQualifiedName())) {
        final Module module = ModuleUtilCore.findModuleForPsiElement(myContext.getPlace());
        JavaPsiFacade facade = JavaPsiFacade.getInstance(myContext.getProject());
        PsiClass newClass = facade.findClass(targetClassName,
                GlobalSearchScope.projectScope(myContext.getProject()));

        if (newClass == null && Messages.showOkCancelDialog(myContext.getProject(),
                GroovyRefactoringBundle.message("class.does.not.exist.in.the.module"),
                IntroduceConstantHandler.REFACTORING_NAME, Messages.getErrorIcon()) != OK_EXIT_CODE) {
            return;
        }/*from www .  j a v a 2  s. c o m*/
        myTargetClassInfo = new TargetClassInfo(targetClassName,
                myContext.getPlace().getContainingFile().getContainingDirectory(), module,
                myContext.getProject());
    } else {
        myTargetClassInfo = new TargetClassInfo(myDefaultTargetClass);
    }

    JavaRefactoringSettings.getInstance().INTRODUCE_CONSTANT_VISIBILITY = getVisibilityModifier();

    RecentsManager.getInstance(myContext.getProject()).registerRecentEntry(RECENTS_KEY, targetClassName);

    super.doOKAction();
}

From source file:org.mustbe.consulo.csharp.ide.codeInsight.actions.CreateUnresolvedElementFix.java

License:Apache License

@Nullable
protected static Editor openEditor(@NotNull PsiElement anchor, int offset) {
    PsiFile containingFile = anchor.getContainingFile();
    if (containingFile == null) {
        return null;
    }//from w w  w. ja  va  2 s .  c om
    VirtualFile virtualFile = containingFile.getVirtualFile();
    if (virtualFile == null) {
        return null;
    }

    Project project = containingFile.getProject();
    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 null;
    }

    OpenFileDescriptor descriptor = new OpenFileDescriptor(project, virtualFile);
    Editor editor = FileEditorManager.getInstance(project).openTextEditor(descriptor, true);
    if (editor != null) {
        editor.getCaretModel().moveToOffset(offset);
        editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
        return editor;
    }
    return null;
}

From source file:org.sonarlint.intellij.actions.UpdateAction.java

License:Open Source License

@Override
public void actionPerformed(final AnActionEvent e) {
    final Project p = e.getProject();
    final SonarLintStatus status = SonarLintStatus.get(p);
    final SonarLintConsole console = SonarLintConsole.getSonarQubeConsole(p);

    if (!status.tryRun()) {
        String msg = "Unable to update SonarLint as an analysis is on-going";
        console.error(msg);//from w w w . j a  va 2 s  .co  m
        showMessage(p, msg, Messages.getErrorIcon());
        return;
    }

    ProgressManager.getInstance().run(new Task.Backgroundable(e.getProject(), "Update SonarLint") {
        @Override
        public void run(@NotNull ProgressIndicator progressIndicator) {
            doUpdate(p, status, console);
        }
    });
}

From source file:org.sonarlint.intellij.actions.UpdateAction.java

License:Open Source License

void doUpdate(final Project p, final SonarLintStatus status, final SonarLintConsole console) {
    SonarQubeRunnerFacade runner = p.getComponent(SonarQubeRunnerFacade.class);

    try {/*from  w  w w .j  a  va2s.  c o m*/
        runner.tryUpdate();
    } catch (final Exception ex) {
        console.error("Unable to perform update", ex);
        showMessage(p, "Unable to update SonarLint: " + ex.getMessage(), Messages.getErrorIcon());
        return;
    } finally {
        status.stopRun();
    }

    String version = runner.getVersion();
    if (version == null) {
        showMessage(p, "Unable to update SonarLint. Please check logs in SonarLint console.",
                Messages.getErrorIcon());
    } else {
        showMessage(p, "SonarLint is up to date and running", Messages.getInformationIcon());
    }
}

From source file:org.trzcinka.intellitrac.gateway.TracGatewayLocator.java

License:Apache License

public static void handleConnectionProblem() {
    if (SwingUtilities.isEventDispatchThread()) {
        Messages.showMessageDialog(bundle.getString("configuration.connection.dialogs.connection_failed"),
                bundle.getString("dialogs.error"), Messages.getErrorIcon());
    }/*w  w  w.  j av a 2 s  . c o  m*/
}

From source file:org.trzcinka.intellitrac.view.configuration.ConfigurationForm.java

License:Apache License

public ConfigurationForm() {
    testConnectionButton.addActionListener(new ActionListener() {
        /**//from   w  w w  .  j  av a  2  s  .  c  om
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            Container parent = ((Component) e.getSource()).getParent();
            Cursor oldCursor = parent.getCursor();
            parent.setCursor(MouseCursors.WAIT_CURSOR);
            ResourceBundle bundle = BundleLocator.getBundle();
            TracGateway gateway = TracGatewayLocator.retrieveTracGateway();
            try {
                ConnectionSettings settings = new ConnectionSettings();
                settings.setLogin(login.getText());
                settings.setPassword(password.getText());
                settings.setTracUrl(tracUrl.getText());
                gateway.testConnection(settings);
                Messages.showMessageDialog(
                        bundle.getString("configuration.connection.dialogs.connection_success"),
                        bundle.getString("dialogs.success"), Messages.getInformationIcon());
            } catch (ConnectionFailedException exception) {
                Messages.showMessageDialog(
                        bundle.getString("configuration.connection.dialogs.connection_failed"),
                        bundle.getString("dialogs.error"), Messages.getErrorIcon());
            } catch (MalformedURLException e1) {
                Messages.showMessageDialog(bundle.getString("configuration.connection.dialogs.malformed_url"),
                        bundle.getString("dialogs.error"), Messages.getErrorIcon());
            } finally {
                parent.setCursor(oldCursor);
            }
        }
    });
    ticketTemplatesList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            ListSelectionModel model = (ListSelectionModel) e.getSource();
            if (model.isSelectionEmpty()) {
                ticketTemplateNameTextField.setEnabled(false);
                ticketTemplateContentEditorPane.setEnabled(false);
                ticketTemplateNameTextField.setText(null);
                ticketTemplateContentEditorPane.setText(null);
                removeButton.setEnabled(false);
            } else {
                Template selected = (Template) ticketTemplatesList.getSelectedValue();
                ticketTemplateNameTextField.setEnabled(true);
                ticketTemplateContentEditorPane.setEnabled(true);
                ticketTemplateNameTextField.setText(selected.getName());
                ticketTemplateContentEditorPane.setText(selected.getContent());
                removeButton.setEnabled(true);
            }

        }
    });
    ticketTemplateNameTextField.getDocument().addDocumentListener(new DocumentAdapter() {
        protected void textChanged(DocumentEvent e) {
            Template selected = (Template) ticketTemplatesList.getSelectedValue();
            if (selected != null) {
                selected.setName(ticketTemplateNameTextField.getText());
            }
        }
    });
    ticketTemplateContentEditorPane.getDocument().addDocumentListener(new DocumentAdapter() {
        protected void textChanged(DocumentEvent e) {
            Template selected = (Template) ticketTemplatesList.getSelectedValue();
            if (selected != null) {
                selected.setContent(ticketTemplateContentEditorPane.getText());
            }
        }
    });
    newButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Template template = new Template();
            template.setName(
                    BundleLocator.getBundle().getString("configuration.ticket_templates.new_template_name"));
            ticketTemplatesListModel.add(template);
        }
    });
    removeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ticketTemplatesListModel.remove(ticketTemplatesList.getSelectedIndex());
        }
    });

    rootComponent.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (defaultValuesPanel == rootComponent.getSelectedComponent()) {
                ConnectionSettings connectionSettings = new ConnectionSettings();
                connectionSettings.setLogin(login.getText());
                connectionSettings.setPassword(password.getText());
                connectionSettings.setTracUrl(tracUrl.getText());
                try {
                    gateway.setConfiguration(connectionSettings);
                    fillComboBox(componentComboBoxModel, gateway.retrieveComponents(),
                            componentComboBox.getSelectedItem(), false);
                    fillComboBox(priorityComboBoxModel, gateway.retrievePriorities(),
                            priorityComboBox.getSelectedItem(), false);
                    fillComboBox(typeComboBoxModel, gateway.retrieveTypes(), typeComboBox.getSelectedItem(),
                            false);
                    fillComboBox(milestoneComboBoxModel, gateway.retrieveMilestones(),
                            milestoneComboBox.getSelectedItem(), false);
                    fillComboBox(versionComboBoxModel, gateway.retrieveVersions(),
                            versionComboBox.getSelectedItem(), false);
                } catch (Exception e1) {
                    if (logger.isDebugEnabled()) {
                        logger.debug(e1);
                    }
                }
            }
        }
    });
}

From source file:org.trzcinka.intellitrac.view.toolwindow.tickets.report_editor.ReportEditorForm.java

License:Apache License

public ReportEditorForm() {
    ticketsModel.getCurrentReportModel().addListener(this);
    okButton.addActionListener(new ActionListener() {
        /**/*www . ja  v a2  s.  com*/
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            Report report = new Report();
            getData(report);

            try {
                TracGatewayLocator.retrieveTracGateway().retrieveTickets(report.getProperQuery());
            } catch (TracError er) {
                Messages.showMessageDialog(MessageFormat.format(
                        bundle.getString("tool_window.tickets.report_editor.validation.custom.query"),
                        er.getMessage()), bundle.getString("dialogs.error"), Messages.getErrorIcon());
                return;
            } catch (ConnectionFailedException e1) {
                TracGatewayLocator.handleConnectionProblem();
                return;
            }

            ticketsModel.getReportsListModel().saveReport(report);
            reportsListRedirect();
        }
    });
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            reportsListRedirect();
        }
    });
}