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:com.intellij.uiDesigner.palette.Palette.java

License:Apache License

/**
 * Adds specified <code>item</code> to the palette.
 * @param item item to be added// www  .j  a  va  2  s  . c  o m
 * @exception java.lang.IllegalArgumentException  if an item for the same class
 * is already exists in the palette
 */
public void addItem(@NotNull final GroupItem group, @NotNull final ComponentItem item) {
    // class -> item
    final String componentClassName = item.getClassName();
    if (getItem(componentClassName) != null) {
        Messages.showMessageDialog(UIDesignerBundle.message("error.item.already.added", componentClassName),
                ApplicationNamesInfo.getInstance().getFullProductName(), Messages.getErrorIcon());
        return;
    }
    myClassName2Item.put(componentClassName, item);

    // group -> items
    group.addItem(item);

    // Process special predefined item for JPanel
    if ("javax.swing.JPanel".equals(item.getClassName())) {
        myPanelItem = item;
    }
}

From source file:com.intellij.uiDesigner.propertyInspector.PropertyInspectorTable.java

License:Apache License

private static void showInvalidInput(final Exception exc) {
    final Throwable cause = exc.getCause();
    String message;/*w  w w. j  a v a2 s  .c om*/
    if (cause != null) {
        message = cause.getMessage();
    } else {
        message = exc.getMessage();
    }
    if (message == null || message.length() == 0) {
        message = UIDesignerBundle.message("error.no.message");
    }
    Messages.showMessageDialog(UIDesignerBundle.message("error.setting.value", message),
            UIDesignerBundle.message("title.invalid.input"), Messages.getErrorIcon());
}

From source file:com.intellij.uiDesigner.propertyInspector.PropertyInspectorTable.java

License:Apache License

private static boolean setPropValue(final Property property, final RadComponent c, final Object newValue) {
    try {//from w  w w.ja v  a  2 s . c o m
        //noinspection unchecked
        property.setValue(c, newValue);
    } catch (Throwable e) {
        LOG.debug(e);
        if (e instanceof InvocationTargetException) { // special handling of warapped exceptions
            e = ((InvocationTargetException) e).getTargetException();
        }
        Messages.showMessageDialog(e.getMessage(), UIDesignerBundle.message("title.invalid.input"),
                Messages.getErrorIcon());
        return false;
    }
    return true;
}

From source file:com.intellij.uiDesigner.snapShooter.CreateSnapShotAction.java

License:Apache License

public void actionPerformed(AnActionEvent e) {
    final Project project = e.getData(CommonDataKeys.PROJECT);
    final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
    if (project == null || view == null) {
        return;//from w w  w .  j  av a 2 s  . c om
    }

    final PsiDirectory dir = view.getOrChooseDirectory();
    if (dir == null)
        return;

    final SnapShotClient client = new SnapShotClient();
    List<RunnerAndConfigurationSettings> appConfigurations = new ArrayList<RunnerAndConfigurationSettings>();
    RunnerAndConfigurationSettings snapshotConfiguration = null;
    boolean connected = false;

    ApplicationConfigurationType cfgType = ApplicationConfigurationType.getInstance();
    List<RunnerAndConfigurationSettings> racsi = RunManager.getInstance(project)
            .getConfigurationSettingsList(cfgType);

    for (RunnerAndConfigurationSettings config : racsi) {
        if (config.getConfiguration() instanceof ApplicationConfiguration) {
            ApplicationConfiguration appConfig = (ApplicationConfiguration) config.getConfiguration();
            appConfigurations.add(config);
            if (appConfig.ENABLE_SWING_INSPECTOR) {
                SnapShooterConfigurationSettings settings = SnapShooterConfigurationSettings.get(appConfig);
                snapshotConfiguration = config;
                if (settings.getLastPort() > 0) {
                    try {
                        client.connect(settings.getLastPort());
                        connected = true;
                    } catch (IOException ex) {
                        connected = false;
                    }
                }
            }
            if (connected)
                break;
        }
    }

    if (snapshotConfiguration == null) {
        snapshotConfiguration = promptForSnapshotConfiguration(project, appConfigurations);
        if (snapshotConfiguration == null)
            return;
    }

    if (!connected) {
        int rc = Messages.showYesNoDialog(project, UIDesignerBundle.message("snapshot.run.prompt"),
                UIDesignerBundle.message("snapshot.title"), Messages.getQuestionIcon());
        if (rc == 1)
            return;
        final ApplicationConfiguration appConfig = (ApplicationConfiguration) snapshotConfiguration
                .getConfiguration();
        final SnapShooterConfigurationSettings settings = SnapShooterConfigurationSettings.get(appConfig);
        settings.setNotifyRunnable(new Runnable() {
            public void run() {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        Messages.showMessageDialog(project, UIDesignerBundle.message("snapshot.prepare.notice"),
                                UIDesignerBundle.message("snapshot.title"), Messages.getInformationIcon());
                        try {
                            client.connect(settings.getLastPort());
                        } catch (IOException ex) {
                            Messages.showMessageDialog(project,
                                    UIDesignerBundle.message("snapshot.connection.error"),
                                    UIDesignerBundle.message("snapshot.title"), Messages.getErrorIcon());
                            return;
                        }
                        runSnapShooterSession(client, project, dir, view);
                    }
                });
            }
        });

        try {
            final ProgramRunner runner = RunnerRegistry.getInstance().getRunner(DefaultRunExecutor.EXECUTOR_ID,
                    appConfig);
            LOG.assertTrue(runner != null, "Runner MUST not be null!");
            Executor executor = DefaultRunExecutor.getRunExecutorInstance();
            runner.execute(new ExecutionEnvironment(executor, runner, snapshotConfiguration, project));
        } catch (ExecutionException ex) {
            Messages.showMessageDialog(project, UIDesignerBundle.message("snapshot.run.error", ex.getMessage()),
                    UIDesignerBundle.message("snapshot.title"), Messages.getErrorIcon());
        }
    } else {
        runSnapShooterSession(client, project, dir, view);
    }
}

From source file:com.intellij.uiDesigner.snapShooter.CreateSnapShotAction.java

License:Apache License

private static void runSnapShooterSession(final SnapShotClient client, final Project project,
        final PsiDirectory dir, final IdeView view) {
    try {/*w w  w.ja  va  2  s . c om*/
        client.suspendSwing();
    } catch (IOException e1) {
        Messages.showMessageDialog(project, UIDesignerBundle.message("snapshot.connection.error"),
                UIDesignerBundle.message("snapshot.title"), Messages.getInformationIcon());
        return;
    }

    final MyDialog dlg = new MyDialog(project, client, dir);
    dlg.show();
    if (dlg.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
        final int id = dlg.getSelectedComponentId();
        final Ref<Object> result = new Ref<Object>();
        ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
            public void run() {
                try {
                    result.set(client.createSnapshot(id));
                } catch (Exception ex) {
                    result.set(ex);
                }
            }
        }, UIDesignerBundle.message("progress.creating.snapshot"), false, project);

        String snapshot = null;
        if (result.get() instanceof String) {
            snapshot = (String) result.get();
        } else {
            Exception ex = (Exception) result.get();
            Messages.showMessageDialog(project,
                    UIDesignerBundle.message("snapshot.create.error", ex.getMessage()),
                    UIDesignerBundle.message("snapshot.title"), Messages.getErrorIcon());
        }

        if (snapshot != null) {
            final String snapshot1 = snapshot;
            ApplicationManager.getApplication().runWriteAction(new Runnable() {
                public void run() {
                    CommandProcessor.getInstance().executeCommand(project, new Runnable() {
                        public void run() {
                            try {
                                PsiFile formFile = PsiFileFactory.getInstance(dir.getProject())
                                        .createFileFromText(
                                                dlg.getFormName() + GuiFormFileType.DOT_DEFAULT_EXTENSION,
                                                snapshot1);
                                formFile = (PsiFile) dir.add(formFile);
                                formFile.getVirtualFile().setCharset(CharsetToolkit.UTF8_CHARSET);
                                formFile.getViewProvider().getDocument().setText(snapshot1);
                                view.selectElement(formFile);
                            } catch (IncorrectOperationException ex) {
                                Messages.showMessageDialog(project,
                                        UIDesignerBundle.message("snapshot.save.error", ex.getMessage()),
                                        UIDesignerBundle.message("snapshot.title"), Messages.getErrorIcon());
                            }
                        }
                    }, "", null);
                }
            });
        }
    }

    try {
        client.resumeSwing();
    } catch (IOException ex) {
        Messages.showErrorDialog(project, UIDesignerBundle.message("snapshot.connection.broken"),
                UIDesignerBundle.message("snapshot.title"));
    }

    client.dispose();
}

From source file:com.intellij.uiDesigner.snapShooter.SnapShotTreeModel.java

License:Apache License

private static void reportDisconnection(final SnapShotClient client) {
    Messages.showMessageDialog("Disconnected from remote application", "Create Form Snapshot",
            Messages.getErrorIcon());
    client.setDisconnected();/*from  w  w  w. j  a va 2 s .  com*/
}

From source file:com.intellij.vcs.starteam.actions.UpdateStatusAction.java

License:Apache License

protected void perform(final Project project, StarteamVcs activeVcs, VirtualFile file) {
    try {/*  ww w  .j a va  2 s. c  o  m*/
        activeVcs.refresh();
        activeVcs.updateStatus(file);
    } catch (VcsException ex) {
        Messages.showMessageDialog(project, ex.getMessage(),
                StarteamBundle.message("message.title.action.error"), Messages.getErrorIcon());
    } catch (IOException ex) {
        Messages.showMessageDialog(project, ex.getMessage(),
                StarteamBundle.message("message.title.action.error"), Messages.getErrorIcon());
    }
}

From source file:com.mbeddr.pluginmanager.com.intellij.ide.plugins.PluginManagerMain.java

License:Apache License

/**
 * Start a new thread which downloads new list of plugins from the site in
 * the background and updates a list of plugins in the table.
 */// w w w  . j av  a 2s  .co  m
protected void loadPluginsFromHostInBackground() {
    setDownloadStatus(true);

    ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
        @Override
        public void run() {
            final List<IdeaPluginDescriptor> list = ContainerUtil.newArrayList();
            final Map<String, String> errors = ContainerUtil.newLinkedHashMap();
            ProgressIndicator indicator = new EmptyProgressIndicator();

            List<String> hosts = RepositoryHelper.getPluginHosts();
            Set<PluginId> unique = ContainerUtil.newHashSet();
            for (String host : hosts) {
                try {
                    if (host == null || acceptHost(host)) {
                        List<IdeaPluginDescriptor> plugins = RepositoryHelper.loadPlugins(host, indicator);
                        for (IdeaPluginDescriptor plugin : plugins) {
                            if (unique.add(plugin.getPluginId())) {
                                list.add(plugin);
                            }
                        }
                    }
                } catch (FileNotFoundException e) {
                    LOG.info(host, e);
                } catch (IOException e) {
                    LOG.info(host, e);
                    if (host != ApplicationInfoEx.getInstanceEx().getBuiltinPluginsUrl()) {
                        errors.put(host, String.format("'%s' for '%s'", e.getMessage(), host));
                    }
                }
            }

            UIUtil.invokeLaterIfNeeded(new Runnable() {
                @Override
                public void run() {
                    setDownloadStatus(false);

                    if (!list.isEmpty()) {
                        InstalledPluginsState state = InstalledPluginsState.getInstance();
                        for (IdeaPluginDescriptor descriptor : list) {
                            state.onDescriptorDownload(descriptor);
                        }

                        modifyPluginsList(list);
                        propagateUpdates(list);
                    }

                    if (!errors.isEmpty()) {
                        String message = IdeBundle.message("error.list.of.plugins.was.not.loaded",
                                StringUtil.join(errors.keySet(), ", "),
                                StringUtil.join(errors.values(), ",\n"));
                        String title = IdeBundle.message("title.plugins");
                        String ok = CommonBundle.message("button.retry"),
                                cancel = CommonBundle.getCancelButtonText();
                        if (Messages.showOkCancelDialog(message, title, ok, cancel,
                                Messages.getErrorIcon()) == Messages.OK) {
                            loadPluginsFromHostInBackground();
                        }
                    }
                }
            });
        }
    });
}

From source file:com.mediaworx.intellij.opencmsplugin.actions.importmodule.OpenCmsImportAction.java

License:Open Source License

/**
 * Triggers the import of modules depending on the menu entry the user chose. Which modules are to
 * be imported is determined by calling the abstract method
 * {@link #getModuleFileList(AnActionEvent)} that's implemented by subclasses.
 * For the moduel import the IDEConnectorClient is used that is provided as a separate library.
 * @param event the action event, provided by IntelliJ
 *//*from  ww w.  j av a2 s . com*/
@Override
public void actionPerformed(AnActionEvent event) {
    LOG.info("actionPerformed - event: " + event);
    super.actionPerformed(event);

    if (config.isPluginConnectorServiceEnabled() && StringUtils.isNotBlank(config.getConnectorServiceUrl())) {
        final List<File> moduleFiles = getModuleFileList(event);

        final OpenCmsToolWindowConsole console = plugin.getConsole();

        final List<ModuleImportInfo> moduleImportInfos = new ArrayList<>();
        for (File moduleFile : moduleFiles) {
            OpenCmsModule ocmsModule = plugin.getOpenCmsModules().getModuleForFile(moduleFile);
            if (ocmsModule == null || !ocmsModule.isFileModuleRoot(moduleFile)) {
                continue;
            }
            String moduleZipPath = ocmsModule.findNewestModuleZipPath();
            if (StringUtils.isNotBlank(moduleZipPath)) {
                ModuleImportInfo importInfo = new ModuleImportInfo();
                importInfo.setModuleZipPath(moduleZipPath);
                importInfo.setImportSiteRoot(ocmsModule.getExportImportSiteRoot());
                moduleImportInfos.add(importInfo);
            } else {
                console.error("No module zip for module " + ocmsModule.getModuleName()
                        + " found in target folder " + config.getModuleZipTargetFolderPath());
            }
        }
        if (moduleImportInfos.size() > 0) {

            plugin.showConsole();
            clearConsole();

            Runnable runnable = new Runnable() {
                @Override
                public void run() {
                    try {
                        connectorClient.login(config.getUsername(), config.getPassword());
                        connectorClient.importModules(moduleImportInfos, new ConsolePrinter(console));
                        connectorClient.logout();
                    } catch (Exception e) {
                        UIUtil.invokeLaterIfNeeded(new Runnable() {
                            @Override
                            public void run() {
                                Messages.showDialog(
                                        "This function is only available if the IDE Connector module 1.5 is installed and configured in OpenCms and if OpenCms is running. Consult the Plugin Wiki for mor information.",
                                        "Error", new String[] { "Ok" }, 0, Messages.getErrorIcon());
                            }
                        });
                    }
                }
            };
            Thread thread = new Thread(runnable);
            thread.start();
        }
    } else {
        Messages.showDialog(
                "This function is only available if the IDE Connector Service URL is provided and the Connector Service is activated (IDE connector module 1.5 required).",
                "Error - Please Check Your OpenCms Plugin Configuration.", new String[] { "Ok" }, 0,
                Messages.getErrorIcon());
    }
}

From source file:com.mediaworx.intellij.opencmsplugin.listeners.OpenCmsModuleFileChangeListener.java

License:Open Source License

/**
 * Handler method that is called after the file change has been executed by IntelliJ, handles file deletes, moves
 * and renames: Is used to present a dialog asking the user if the file change should be reflected in the OpenCms
 * VFS as well./*from  w  w w  .  j  a  v  a2 s  .  c o m*/
 * @param vFileEvents   List of file events, provided by IntelliJ
 */
public void after(@NotNull List<? extends VFileEvent> vFileEvents) {

    if (config == null || !config.isOpenCmsPluginEnabled()) {
        return;
    }

    ToolWindow toolWindow = plugin.getToolWindow();
    if (toolWindow == null) {
        return;
    }

    console = plugin.getConsole();

    try {
        for (VFileEvent event : vFileEvents) {
            handleFileEvent(event);
        }
        if (getNumAffected() > 0) {
            boolean wasExecuted = handleAffectedFiles();

            // Publish the affected VFS resources (if publish is enabled)
            if (wasExecuted && config.isPluginConnectorEnabled()
                    && config.getAutoPublishMode() != AutoPublishMode.OFF) {
                publishAffectedVfsResources();
            }
        }
    } catch (CmsConnectionException e) {
        Messages.showDialog("Error syncing file deletion/move/rename to OpenCms:\n" + e.getMessage(), "Error",
                new String[] { "Ok" }, 0, Messages.getErrorIcon());
    } finally {
        vfsFilesToBeDeleted.clear();
        vfsFilesToBeMoved.clear();
        vfsFilesToBeRenamed.clear();
        deletedFileModuleLookup.clear();
        refreshFiles.clear();
    }
}