Example usage for com.intellij.openapi.ui DialogWrapper CANCEL_EXIT_CODE

List of usage examples for com.intellij.openapi.ui DialogWrapper CANCEL_EXIT_CODE

Introduction

In this page you can find the example usage for com.intellij.openapi.ui DialogWrapper CANCEL_EXIT_CODE.

Prototype

int CANCEL_EXIT_CODE

To view the source code for com.intellij.openapi.ui DialogWrapper CANCEL_EXIT_CODE.

Click Source Link

Document

The default exit code for "Cancel" action.

Usage

From source file:net.andydvorak.intellij.lessc.ui.configurable.VfsLocationChangeDialog.java

License:Apache License

public synchronized boolean shouldMoveCssFile(final VirtualFileEvent virtualFileEvent) {
    DialogWrapper.DoNotAskOption option = new DialogWrapper.DoNotAskOption() {
        @Override/*from   w w w  .  j a va2  s . c om*/
        public boolean isToBeShown() {
            return myLessProjectState.isPromptOnMove();
        }

        @Override
        public void setToBeShown(boolean value, int exitCode) {
            myLessProjectState.setPromptOnMove(value);
        }

        @Override
        public boolean canBeHidden() {
            return true;
        }

        @Override
        public boolean shouldSaveOptionsOnCancel() {
            return true;
        }

        @Override
        public String getDoNotShowMessage() {
            return UIBundle.message("do.not.ask.me.again");
        }
    };

    if (option.isToBeShown()) {
        if (System.currentTimeMillis() - lastPrompt > promptIntervalMillis) {
            result = Messages.showYesNoDialog(
                    UIBundle.message("vfs.move.message", virtualFileEvent.getFileName()),
                    UIBundle.message("vfs.move.title"), // Title
                    UIBundle.message("vfs.move.yes"), // "Yes" button text
                    UIBundle.message("vfs.move.no"), // "No" button text
                    Messages.getQuestionIcon(), option);
        }
    } else {
        result = myLessProjectState.isMoveCssFiles() ? DialogWrapper.OK_EXIT_CODE
                : DialogWrapper.CANCEL_EXIT_CODE;
    }

    lastPrompt = System.currentTimeMillis();

    final boolean shouldMove = result == DialogWrapper.OK_EXIT_CODE;

    myLessProjectState.setMoveCssFiles(shouldMove);

    return shouldMove;
}

From source file:net.andydvorak.intellij.lessc.ui.configurable.VfsLocationChangeDialog.java

License:Apache License

public synchronized boolean shouldCopyCssFile(final VirtualFileEvent virtualFileEvent) {
    DialogWrapper.DoNotAskOption option = new DialogWrapper.DoNotAskOption() {
        @Override//from   w  w  w  .ja va  2  s . co  m
        public boolean isToBeShown() {
            return myLessProjectState.isPromptOnCopy();
        }

        @Override
        public void setToBeShown(boolean value, int exitCode) {
            myLessProjectState.setPromptOnCopy(value);
        }

        @Override
        public boolean canBeHidden() {
            return true;
        }

        @Override
        public boolean shouldSaveOptionsOnCancel() {
            return true;
        }

        @Override
        public String getDoNotShowMessage() {
            return UIBundle.message("do.not.ask.me.again");
        }
    };

    if (option.isToBeShown()) {
        if (System.currentTimeMillis() - lastPrompt > promptIntervalMillis) {
            result = Messages.showYesNoDialog(
                    UIBundle.message("vfs.copy.message", virtualFileEvent.getFileName()),
                    UIBundle.message("vfs.copy.title"), // Title
                    UIBundle.message("vfs.copy.yes"), // "Yes" button text
                    UIBundle.message("vfs.copy.no"), // "No" button text
                    Messages.getQuestionIcon(), option);
        }
    } else {
        result = myLessProjectState.isCopyCssFiles() ? DialogWrapper.OK_EXIT_CODE
                : DialogWrapper.CANCEL_EXIT_CODE;
    }

    lastPrompt = System.currentTimeMillis();

    final boolean shouldCopy = result == DialogWrapper.OK_EXIT_CODE;

    myLessProjectState.setCopyCssFiles(shouldCopy);

    return shouldCopy;
}

From source file:net.andydvorak.intellij.lessc.ui.configurable.VfsLocationChangeDialog.java

License:Apache License

public synchronized boolean shouldDeleteCssFile(final VirtualFileEvent virtualFileEvent) {
    DialogWrapper.DoNotAskOption option = new DialogWrapper.DoNotAskOption() {
        @Override//from   ww w  .j a va 2  s. co m
        public boolean isToBeShown() {
            return myLessProjectState.isPromptOnDelete();
        }

        @Override
        public void setToBeShown(boolean value, int exitCode) {
            myLessProjectState.setPromptOnDelete(value);
        }

        @Override
        public boolean canBeHidden() {
            return true;
        }

        @Override
        public boolean shouldSaveOptionsOnCancel() {
            return true;
        }

        @Override
        public String getDoNotShowMessage() {
            return UIBundle.message("do.not.ask.me.again");
        }
    };

    if (option.isToBeShown()) {
        if (System.currentTimeMillis() - lastPrompt > promptIntervalMillis) {
            result = Messages.showYesNoDialog(
                    UIBundle.message("vfs.delete.message", virtualFileEvent.getFileName()),
                    UIBundle.message("vfs.delete.title"), // Title
                    UIBundle.message("vfs.delete.yes"), // "Yes" button text
                    UIBundle.message("vfs.delete.no"), // "No" button text
                    Messages.getQuestionIcon(), option);
        }
    } else {
        result = myLessProjectState.isDeleteCssFiles() ? DialogWrapper.OK_EXIT_CODE
                : DialogWrapper.CANCEL_EXIT_CODE;
    }

    lastPrompt = System.currentTimeMillis();

    final boolean shouldDelete = result == DialogWrapper.OK_EXIT_CODE;

    myLessProjectState.setDeleteCssFiles(shouldDelete);

    return shouldDelete;
}

From source file:net.stevechaloner.intellijad.environment.EnvironmentValidator.java

License:Apache License

/**
 * Shows the error dialog, allowing the user to cancel the decompilation or open the config.
 *
 * @param config the configuration//from w ww.  ja  va2s . c  om
 * @param envContext the environment context
 * @param consoleContext the console's logging context
 * @param message the error message
 * @return the result of the dialog-based operation
 */
private static ValidationResult showErrorDialog(@NotNull Config config, @NotNull EnvironmentContext envContext,
        @NotNull ConsoleContext consoleContext, @NotNull String message) {
    DialogBuilder builder = new DialogBuilder(envContext.getProject());
    builder.setTitle(IntelliJadResourceBundle.message("plugin.IntelliJad.name"));
    builder.addOkAction().setText(IntelliJadResourceBundle.message("option.open-config"));
    builder.addCancelAction().setText(IntelliJadResourceBundle.message("option.cancel-decompilation"));
    JLabel label = new JLabel(message);
    label.setUI(new MultiLineLabelUI());
    builder.setCenterPanel(label);
    builder.setOkActionEnabled(true);

    ValidationResult result;
    switch (builder.show()) {
    case DialogWrapper.OK_EXIT_CODE:
        // this will cause recursive correction unless cancel is selected
        Project project = envContext.getProject();
        ConfigAccessor configAccessor = config.isUseProjectSpecificSettings()
                ? new ProjectConfigComponent(project)
                : new ApplicationConfigComponent();
        // design point - if this dialog is cancelled, should we assume the decompilation is cancelled?
        ShowSettingsUtil.getInstance().editConfigurable(project, configAccessor);
        config.copyFrom(configAccessor.getConfig());
        result = validateEnvironment(config, envContext, consoleContext);
        break;
    case DialogWrapper.CANCEL_EXIT_CODE:
    default:
        result = new ValidationResult(false, true);
        break;
    }

    return result;
}

From source file:org.cordovastudio.editors.designer.propertyTable.properties.IdProperty.java

License:Apache License

@Override
public void setValue(@NotNull final RadViewComponent component, final Object value) throws Exception {
    final String newId = value != null ? value.toString() : "";

    IdManager idManager = IdManager.get(component);
    final String oldId = component.getId();

    if (ourRefactoringChoice != REFACTOR_NO && oldId != null && !oldId.isEmpty() && !newId.isEmpty()
            && !oldId.equals(newId) && component.getTag().isValid()) {
        // Offer rename refactoring?
        XmlTag tag = component.getTag();
        XmlAttribute attribute = tag.getAttribute(ATTR_ID, CORDOVASTUDIO_URI);
        if (attribute != null) {
            Module module = RadModelBuilder.getModule(component);
            if (module != null) {
                XmlAttributeValue valueElement = attribute.getValueElement();
                if (valueElement != null && valueElement.isValid()) {
                    final Project project = module.getProject();
                    // Exact replace only, no comment/text occurrence changes since it is non-interactive
                    RenameProcessor processor = new RenameProcessor(project, valueElement, newId,
                            false /*comments*/, false /*text*/);
                    processor.setPreviewUsages(false);
                    // Do a quick usage search to see if we need to ask about renaming
                    UsageInfo[] usages = processor.findUsages();
                    if (usages.length > 0) {
                        int choice = ourRefactoringChoice;
                        if (choice == REFACTOR_ASK) {
                            DialogBuilder builder = new DialogBuilder(project);
                            builder.setTitle("Update Usages?");
                            JPanel panel = new JPanel(new BorderLayout()); // UGH!
                            JLabel label = new JLabel("<html>" + "Update usages as well?<br>"
                                    + "This will update all XML references and Java R field references.<br>"
                                    + "<br>" + "</html>");
                            panel.add(label, BorderLayout.CENTER);
                            JBCheckBox checkBox = new JBCheckBox("Don't ask again during this session");
                            panel.add(checkBox, BorderLayout.SOUTH);
                            builder.setCenterPanel(panel);
                            builder.setDimensionServiceKey("idPropertyDimension");
                            builder.removeAllActions();

                            DialogBuilder.CustomizableAction yesAction = builder.addOkAction();
                            yesAction.setText(Messages.YES_BUTTON);

                            builder.addActionDescriptor(new DialogBuilder.ActionDescriptor() {
                                @Override
                                public Action getAction(final DialogWrapper dialogWrapper) {
                                    return new AbstractAction(Messages.NO_BUTTON) {
                                        @Override
                                        public void actionPerformed(ActionEvent actionEvent) {
                                            dialogWrapper.close(DialogWrapper.NEXT_USER_EXIT_CODE);
                                        }
                                    };/*from   ww  w  .  ja  va  2s .co  m*/
                                }
                            });
                            builder.addCancelAction();
                            int exitCode = builder.show();

                            choice = exitCode == DialogWrapper.OK_EXIT_CODE ? REFACTOR_YES
                                    : exitCode == DialogWrapper.NEXT_USER_EXIT_CODE ? REFACTOR_NO
                                            : ourRefactoringChoice;

                            if (!checkBox.isSelected()) {
                                ourRefactoringChoice = REFACTOR_ASK;
                            } else {
                                ourRefactoringChoice = choice;
                            }

                            if (exitCode == DialogWrapper.CANCEL_EXIT_CODE) {
                                return;
                            }
                        }

                        if (choice == REFACTOR_YES) {
                            processor.run();
                            // Fall through to also set the value in the layout editor property; otherwise we'll be out of sync
                        }
                    }
                }
            }
        }
    }

    if (idManager != null) {
        idManager.removeComponent(component, false);
    }

    //noinspection ConstantConditions
    super.setValue(component, value);

    if (idManager != null) {
        idManager.addComponent(component);
    }
}

From source file:org.intellij.erlang.rebar.importWizard.RebarProjectImportBuilder.java

License:Apache License

@SuppressWarnings("DialogTitleCapitalization")
@Override/*from  w w  w . j ava2  s .  c  om*/
public boolean validate(Project current, Project dest) {
    if (!findIdeaModuleFiles(mySelectedOtpApps)) {
        return true;
    }
    final int resultCode = Messages.showYesNoCancelDialog(
            ApplicationInfoEx.getInstanceEx().getFullApplicationName() + " module files found:\n\n"
                    + StringUtil.join(mySelectedOtpApps, new Function<ImportedOtpApp, String>() {
                        public String fun(ImportedOtpApp importedOtpApp) {
                            final VirtualFile ideaModuleFile = importedOtpApp.getIdeaModuleFile();
                            return ideaModuleFile != null ? "    " + ideaModuleFile.getPath() + "\n" : "";
                        }
                    }, "") + "\nWould you like to reuse them?",
            "Module files found", Messages.getQuestionIcon());
    if (resultCode == DialogWrapper.OK_EXIT_CODE) {
        return true;
    } else if (resultCode == DialogWrapper.CANCEL_EXIT_CODE) {
        try {
            deleteIdeaModuleFiles(mySelectedOtpApps);
            return true;
        } catch (IOException e) {
            LOG.error(e);
            return false;
        }
    } else {
        return false;
    }
}

From source file:org.jetbrains.plugins.groovy.refactoring.rename.RenamePropertyUtil.java

License:Apache License

/**
 * @param m rename is invoked on member/*from   w w w  . j a v a  2  s  . c  om*/
 * @return true, if rename property
 */
public static Pair<List<? extends PsiElement>, String> askToRenameProperty(PsiMember m) {
    if (m instanceof GrAccessorMethod) {
        return member(((GrAccessorMethod) m).getProperty());
    }
    final String name;
    if (m instanceof GrMethod) {
        name = GroovyPropertyUtils.getPropertyNameByAccessorName(m.getName());
        if (name == null)
            return member(m);
    } else if (m instanceof GrField) {
        name = m.getName();
        if (!((GrField) m).isProperty())
            return member(m);
    } else {
        return member(m);
    }

    final PsiClass containingClass = m.getContainingClass();
    if (containingClass == null)
        return member(m);
    final boolean isStatic = m.hasModifierProperty(PsiModifier.STATIC);

    List<PsiElement> property = new ArrayList<PsiElement>();
    assert name != null;
    ContainerUtil.addAll(property, GroovyPropertyUtils.getAllGetters(containingClass, name, isStatic, false));
    ContainerUtil.addAll(property, GroovyPropertyUtils.getAllSetters(containingClass, name, isStatic, false));

    for (Iterator<PsiElement> iterator = property.iterator(); iterator.hasNext();) {
        if (iterator.next() instanceof GrAccessorMethod)
            iterator.remove();
    }

    final PsiField field = containingClass.findFieldByName(name, false);
    if (field != null) {
        property.add(field);
    }
    if (property.size() == 1)
        return member(m);

    if (ApplicationManager.getApplication().isUnitTestMode()) {
        return property(property, name);
    }

    AskDialog dialog = new AskDialog(m);
    dialog.show();
    if (dialog.getExitCode() == DialogWrapper.CANCEL_EXIT_CODE)
        return cancel();
    if (dialog.renameProperty())
        return property(property, name);
    return member(m);
}

From source file:org.moe.designer.propertyTable.IdProperty.java

License:Apache License

@Override
public void setValue(@NotNull final RadViewComponent component, final Object value) throws Exception {
    final String newId = value != null ? value.toString() : "";

    final String oldId = component.getId();

    if (ourRefactoringChoice != REFACTOR_NO && oldId != null && !oldId.isEmpty() && !newId.isEmpty()
            && !oldId.equals(newId) && component.getTag().isValid()) {
        // Offer rename refactoring?
        XmlTag tag = component.getTag();
        XmlAttribute attribute = tag.getAttribute(SdkConstants.ATTR_ID, SdkConstants.ANDROID_URI);
        if (attribute != null) {
            Module module = RadModelBuilder.getModule(component);
            if (module != null) {
                XmlAttributeValue valueElement = attribute.getValueElement();
                if (valueElement != null && valueElement.isValid()) {
                    final Project project = module.getProject();
                    // Exact replace only, no comment/text occurrence changes since it is non-interactive
                    RenameProcessor processor = new RenameProcessor(project, valueElement, newId,
                            false /*comments*/, false /*text*/);
                    processor.setPreviewUsages(false);
                    // Do a quick usage search to see if we need to ask about renaming
                    UsageInfo[] usages = processor.findUsages();
                    if (usages.length > 0) {
                        int choice = ourRefactoringChoice;
                        if (choice == REFACTOR_ASK) {
                            DialogBuilder builder = new DialogBuilder(project);
                            builder.setTitle("Update Usages?");
                            JPanel panel = new JPanel(new BorderLayout()); // UGH!
                            JLabel label = new JLabel("<html>" + "Update usages as well?<br>"
                                    + "This will update all XML references and Java R field references.<br>"
                                    + "<br>" + "</html>");
                            panel.add(label, BorderLayout.CENTER);
                            JBCheckBox checkBox = new JBCheckBox("Don't ask again during this session");
                            panel.add(checkBox, BorderLayout.SOUTH);
                            builder.setCenterPanel(panel);
                            builder.setDimensionServiceKey("idPropertyDimension");
                            builder.removeAllActions();

                            DialogBuilder.CustomizableAction yesAction = builder.addOkAction();
                            yesAction.setText(Messages.YES_BUTTON);

                            builder.addActionDescriptor(new DialogBuilder.ActionDescriptor() {
                                @Override
                                public Action getAction(final DialogWrapper dialogWrapper) {
                                    return new AbstractAction(Messages.NO_BUTTON) {
                                        @Override
                                        public void actionPerformed(ActionEvent actionEvent) {
                                            dialogWrapper.close(DialogWrapper.NEXT_USER_EXIT_CODE);
                                        }
                                    };/*from   w w  w . j av a 2s  .c  o  m*/
                                }
                            });
                            builder.addCancelAction();
                            int exitCode = builder.show();

                            choice = exitCode == DialogWrapper.OK_EXIT_CODE ? REFACTOR_YES
                                    : exitCode == DialogWrapper.NEXT_USER_EXIT_CODE ? REFACTOR_NO
                                            : ourRefactoringChoice;

                            if (!checkBox.isSelected()) {
                                ourRefactoringChoice = REFACTOR_ASK;
                            } else {
                                ourRefactoringChoice = choice;
                            }

                            if (exitCode == DialogWrapper.CANCEL_EXIT_CODE) {
                                return;
                            }
                        }

                        if (choice == REFACTOR_YES) {
                            processor.run();
                            // Fall through to also set the value in the layout editor property; otherwise we'll be out of sync
                        }
                    }
                }
            }
        }
    }

    //noinspection ConstantConditions
    super.setValue(component, value);
}

From source file:org.onehippo.intellij.groovy.actions.ScheduleFileAction.java

License:Apache License

@Override
public void actionPerformed(AnActionEvent event) {
    final Project project = event.getData(CommonDataKeys.PROJECT);
    if (project == null) {
        return;/*from  w w w .  j  a  v  a 2  s . c  o m*/
    }
    final GroovySessionComponent sessionComponent = project.getComponent(GroovySessionComponent.class);

    final FileEditorManager editorManager = FileEditorManager.getInstance(project);
    final Editor selectedTextEditor = editorManager.getSelectedTextEditor();

    if (selectedTextEditor == null) {
        Util.showError(project, "No document selected");
        return;
    }
    final Document document = selectedTextEditor.getDocument();
    final VirtualFile currentFile = FileDocumentManager.getInstance().getFile(document);
    if (currentFile == null) {
        Util.showError(project, "No document selected");
        return;
    }
    // check if groovy file
    final FileType fileType = currentFile.getFileType();
    if (fileType != GroovyFileType.GROOVY_FILE_TYPE) {
        final int result = Messages.showOkCancelDialog(
                "File" + currentFile.getName() + " doesn't seems to be a groovy file",
                CommonBundle.getWarningTitle(), Messages.getWarningIcon());
        if (result != 0) {
            return;
        }
    }
    FileDialogData existingData = new FileDialogData();
    final SessionState state = sessionComponent.getState();
    if (state != null) {
        final Map<String, FileDialogData> items = state.getItems();
        final FileDialogData dialogData = items.get(currentFile.getCanonicalPath());
        if (dialogData != null) {
            existingData = dialogData;
        }
    }

    final String content = selectedTextEditor.getDocument().getText();
    final ScheduleDialog dialog = new ScheduleDialog(project, existingData);
    existingData.setContent(content);
    dialog.setTitle("Groovy Script Settings");
    dialog.show();
    switch (dialog.getExitCode()) {
    case DialogWrapper.OK_EXIT_CODE:
        processFile(dialog.getData(), sessionComponent, project);

        break;
    case DialogWrapper.CANCEL_EXIT_CODE:
        Util.showMessage(project, "File not saved");
        break;
    }

}

From source file:org.twodividedbyzero.idea.findbugs.actions.ExportBugCollection.java

License:Open Source License

@Override
void actionPerformedImpl(@NotNull final AnActionEvent e, @NotNull final Project project,
        @Nullable final Module module, @NotNull final FindBugsPlugin plugin,
        @NotNull final ToolWindow toolWindow, @NotNull final FindBugsState state,
        @NotNull final FindBugsPreferences preferences) {

    final BugCollection bugCollection = IdeaUtilImpl.getPluginComponent(project).getBugCollection();
    if (bugCollection == null) {
        FindBugsPluginImpl.showToolWindowNotifier(project, "No bug collection", MessageType.WARNING);
        return;/* w  w  w .j  a va2 s . c  o  m*/
    }

    String exportDir = preferences.getProperty(FindBugsPreferences.EXPORT_BASE_DIR,
            FindBugsPluginConstants.DEFAULT_EXPORT_DIR);
    boolean exportXml = preferences.getBooleanProperty(FindBugsPreferences.EXPORT_AS_XML, true);
    boolean exportHtml = preferences.getBooleanProperty(FindBugsPreferences.EXPORT_AS_HTML, true);
    boolean exportBoth = exportXml && preferences.getBooleanProperty(FindBugsPreferences.EXPORT_AS_HTML, true);

    if (exportDir.isEmpty() || !exportXml && !exportBoth && !exportHtml) {

        //Ask the user for a export directory
        final DialogBuilder dialogBuilder = new DialogBuilder(project);
        dialogBuilder.addOkAction();
        dialogBuilder.addCancelAction();
        dialogBuilder.setTitle("Select directory to save the exported file");
        final ExportFileDialog exportDialog = new ExportFileDialog(exportDir, dialogBuilder);
        dialogBuilder.showModal(true);
        if (dialogBuilder.getDialogWrapper().getExitCode() == DialogWrapper.CANCEL_EXIT_CODE) {
            return;
        }
        final String path = exportDialog.getText();
        if (path == null || path.trim().isEmpty()) {
            return;
        }

        exportXml = exportDialog.isXml() != exportXml ? exportDialog.isXml() : exportXml;
        exportHtml = exportDialog.isXml() == exportHtml ? !exportDialog.isXml() : exportHtml;
        exportBoth = exportDialog.isBoth() != exportBoth ? exportDialog.isBoth() : exportBoth;
        exportDir = path.trim();
    }
    //Create a unique file name by using time stamp
    final Date currentDate = new Date();
    final String timestamp = PATTERN.matcher(new SimpleDateFormat().format(currentDate)).replaceAll("_");
    final String fileName = File.separatorChar + FINDBUGS_RESULT_PREFIX + timestamp;

    final boolean finalExportXml = exportXml;
    final boolean finalExportHtml = exportHtml;
    final boolean finalExportBoth = exportBoth;
    final String finalExportDir = exportDir + File.separatorChar + project.getName();

    //Create a task to export the bug collection to html
    final Task exportTask = new BackgroundableTask(project, "Exporting Findbugs Result", false) {
        private ProgressIndicator _indicator;

        @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({ "REC_CATCH_EXCEPTION" })
        @SuppressWarnings({ "IOResourceOpenedButNotSafelyClosed" })
        @Override
        public void run(@NotNull final ProgressIndicator indicator) {
            indicator.setText2(finalExportDir + File.separatorChar + fileName);
            setProgressIndicator(indicator);
            Writer writer = null;
            try {
                createDirIfAbsent(project, finalExportDir);
                String exportDir = finalExportDir;
                final boolean createSubDir = preferences
                        .getBooleanProperty(FindBugsPreferences.EXPORT_CREATE_ARCHIVE_DIR, true);
                if (createSubDir) {
                    exportDir = finalExportDir + File.separatorChar
                            + new SimpleDateFormat("yyyy_MM_dd", Locale.ENGLISH).format(currentDate);
                    createDirIfAbsent(project, exportDir);
                }

                bugCollection.setWithMessages(true);
                final String exportDirAndFilenameWithoutSuffix = exportDir + fileName;
                if (finalExportXml && !finalExportBoth) {
                    exportXml(bugCollection, exportDirAndFilenameWithoutSuffix + FINDBUGS_RESULT_RAW_SUFFIX);
                } else if (finalExportBoth) {
                    exportXml(bugCollection, exportDirAndFilenameWithoutSuffix + FINDBUGS_RESULT_RAW_SUFFIX);
                    writer = exportHtml(bugCollection,
                            exportDirAndFilenameWithoutSuffix + FINDBUGS_RESULT_HTML_SUFFIX);
                } else if (finalExportHtml) {
                    writer = exportHtml(bugCollection,
                            exportDirAndFilenameWithoutSuffix + FINDBUGS_RESULT_HTML_SUFFIX);
                }
                bugCollection.setWithMessages(false);

                showToolWindowNotifier(project, "Exported bug collection to " + exportDir + '.',
                        MessageType.INFO);
                if ((!finalExportXml || finalExportBoth)
                        && preferences.getBooleanProperty(FindBugsPreferences.EXPORT_OPEN_BROWSER, true)) {
                    BrowserUtil.browse(new File(exportDirAndFilenameWithoutSuffix + FINDBUGS_RESULT_HTML_SUFFIX)
                            .getAbsolutePath());
                }

            } catch (final IOException e1) {
                final String message = "Export failed";
                showToolWindowNotifier(project, message, MessageType.ERROR);
                LOGGER.error(message, e1);
            } catch (final TransformerConfigurationException e1) {
                final String message = "Transform to html failed due to configuration problems.";
                showToolWindowNotifier(project, message, MessageType.ERROR);
                LOGGER.error(message, e1);
            } catch (final TransformerException e1) {
                final String message = "Transformation to exportXml failed.";
                showToolWindowNotifier(project, message, MessageType.ERROR);
                LOGGER.error(message, e1);
            } catch (final Exception e) {
                showToolWindowNotifier(project, e.getMessage(), MessageType.ERROR);
                LOGGER.error(e.getMessage(), e);
            } finally {
                IoUtil.safeClose(writer);
                Thread.currentThread().interrupt();
            }
        }

        @Override
        public void setProgressIndicator(@NotNull final ProgressIndicator indicator) {
            _indicator = indicator;
        }

        @Override
        public ProgressIndicator getProgressIndicator() {
            return _indicator;
        }
    };

    final File file = new File(exportDir + fileName);
    if (file.getParentFile() == null) {
        showToolWindowNotifier(project,
                "Exporting bug collection failed. not a directory. " + exportDir + fileName + '.',
                MessageType.ERROR);
    } else {
        exportTask.queue();
    }
}