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

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

Introduction

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

Prototype

@NotNull
    public static Icon getQuestionIcon() 

Source Link

Usage

From source file:com.microsoftopentechnologies.intellij.ui.RolesPanel.java

License:Apache License

private ActionListener createBtnRemoveListener() {
    return new ActionListener() {
        @Override/*from w  w  w.j  ava 2  s .  c o m*/
        public void actionPerformed(ActionEvent e) {
            try {
                int selIndex = tblRoles.getSelectedRow();
                if (selIndex > -1) {
                    int choice = Messages.showYesNoDialog(myModule.getProject(), message("rolsDelMsg"),
                            message("rolsDelTitle"), Messages.getQuestionIcon());
                    if (choice == Messages.YES) {
                        /*
                        * If the role selected for deletion is the last role,
                        * then do not delete it and give error message.
                        */
                        if (listRoles.size() == 1) {
                            PluginUtil.displayErrorDialog(message("rolsDelTitle"), message("lastRolDelMsg"));
                        } else {
                            WindowsAzureRole windowsAzureRole = listRoles.get(selIndex);
                            windowsAzureRole.delete();
                            waProjManager.save();
                            ((RolesTableModel) tblRoles.getModel()).fireTableDataChanged();
                        }
                    }
                }
            } catch (WindowsAzureInvalidProjectOperationException ex) {
                PluginUtil.displayErrorDialogAndLog(message("rolsErr"),
                        message("adRolErrMsgBox1") + message("adRolErrMsgBox2"), ex);
            }
        }
    };
}

From source file:com.microsoftopentechnologies.intellij.ui.WARemoteAccessPanel.java

License:Apache License

public boolean doOKAction() {
    try {//  w  w w. ja v  a2s .co m
        loadProject();
        if (remoteChkBtn.isSelected()) {
            waProjManager.setRemoteAccessAllRoles(true);
            String userName = txtUserName.getText();
            String pwd = txtPassword.getText();
            String cnfPwd = txtConfirmPwd.getText();
            String newPath = txtPath.getText();
            Date expDate = txtExpiryDate.getDate();
            String tempPath = newPath;
            boolean isPathChanged = false;
            waProjManager.setRemoteAccessUsername(userName);
            if (!newPath.equals(waProjManager.getRemoteAccessCertificatePath()) && !newPath.isEmpty()) {
                isPathChanged = true;
                /*
                 * check If certificate file path has changed,
                 * If yes then prompt user
                 * for changing the password as well,
                 * if that is not changed.
                 * Because we have to encrypt the new password
                 * and then we will generate certificate
                 * based on that.
                 * Case 1 :- If user has changed the path
                 * and password is old then it
                 * will prompt for new password or re-enter the password.
                 * If user changes the password
                 * then it will generate certificate based
                 * on that new password.
                 * Case 2 :- If user set the blank password
                 * even after displaying that
                 * password change prompt, in that case
                 * we will display warning messages
                 * to user that whether he want to continue
                 * with empty password, If yes
                 * then we will consider that blank password
                 * else use will have to enter
                 * new password.
                 */
                if (pwd.equals(waProjManager.getRemoteAccessEncryptedPassword()) && !pwd.isEmpty()) {
                    txtPassword.setText("");
                    txtConfirmPwd.setText("");
                    PluginUtil.displayErrorDialog(message("remAccErTxtTitle"), message("remAccPwdMstChng"));
                    return false;
                }
            }
            if (pwd.isEmpty()) {
                int choice = Messages.showOkCancelDialog(message("remAccErTxtTitle"), message("remAccWarnPwd"),
                        Messages.getQuestionIcon());
                if (!(choice == Messages.OK)) {
                    return false;
                }
            }
            if (expDate == null) {
                PluginUtil.displayErrorDialog(message("remAccErTxtTitle"), message("remAccExpDateNull"));
                return false;
            } else {
                boolean status = validateExpDate(expDate);
                if (!status) {
                    return false;
                }
            }
            if (newPath.equalsIgnoreCase("")) {
                PluginUtil.displayErrorDialog(message("remAccErTxtTitle"), message("remAccPathNull"));
                return false;
            }
            /*
             * Check for displaying the relative path
             * in case when user select the certificate file path
             * as workspace or of current project.
             * We will be showing relative path in that case on UI.
             */
            if (tempPath.startsWith(BASE_PATH)) {
                tempPath = tempPath.substring(tempPath.indexOf("}") + 1, tempPath.length());
                tempPath = String.format("%s%s", PluginUtil.getModulePath(myModule), tempPath);
            }
            File file = new File(tempPath);
            //if path is not correct.display error message for that.
            if (file.exists() && tempPath.endsWith(".cer")) {
                waProjManager.setRemoteAccessCertificatePath(newPath);
            } else {
                PluginUtil.displayErrorDialog(message("remAccErTxtTitle"), message("remAccInvldPath"));
                return false;
            }
            try {
                if (isPathChanged) {
                    String thumbprint = CerPfxUtil.getThumbPrint(tempPath);
                    if (waProjManager.isRemoteAccessTryingToUseSSLCert(thumbprint)) {
                        PluginUtil.displayErrorDialog(message("remAccSyntaxErr"), message("usedBySSL"));
                        return false;
                    } else {
                        waProjManager.setRemoteAccessCertificateFingerprint(thumbprint);
                    }
                }
            } catch (Exception e) {
                PluginUtil.displayErrorDialogAndLog(message("remAccSyntaxErr"), message("remAccErTmbPrint"), e);
                return false;
            }
            if (cnfPwd.equals(pwd)) {
                try {
                    /*
                     * Encrypting the password
                     * if it is not dummy & blank from xml
                     * and isPwdChanged is true that means
                     * user has changes the password.
                     */
                    String modifiedPwd = message("remAccDummyPwd");
                    if (!pwd.equals(modifiedPwd) && !pwd.isEmpty() && isPwdChanged) {
                        String encryptedPwd = EncUtilHelper.encryptPassword(pwd, tempPath,
                                AzurePlugin.encFolder);
                        waProjManager.setRemoteAccessEncryptedPassword(encryptedPwd);
                    } else {
                        waProjManager.setRemoteAccessEncryptedPassword(pwd);
                    }
                } catch (Exception e) {
                    PluginUtil.displayErrorDialogAndLog(message("remAccSyntaxErr"), message("remAccErPwd"), e);
                    return false;
                }
            } else {
                PluginUtil.displayErrorDialog(message("remAccErTxtTitle"), message("remAccPwdNotMatch"));
                return false;
            }
        } else {
            waProjManager.setRemoteAccessAllRoles(false);
        }
        waProjManager.save();
    } catch (WindowsAzureInvalidProjectOperationException e) {
        PluginUtil.displayErrorDialogAndLog(message("remAccSyntaxErr"),
                message("proPageErrMsgBox1") + message("proPageErrMsgBox2"), e);
    } catch (ParseException e) {
        PluginUtil.displayErrorDialogAndLog(message("remAccErrTitle"), message("remAccErDateParse"), e);
        return false;
    }
    //        WAEclipseHelper.refreshWorkspace(Messages.remAccWarning, Messages.remAccWarnMsg);
    isFrmEncLink = false;
    return true;
}

From source file:com.perl5.lang.mason2.idea.configuration.MasonSettingsConfigurable.java

License:Apache License

protected void createAutobaseNamesComponent(FormBuilder builder) {
    autobaseModel = new CollectionListModel<String>();
    autobaseList = new JBList(autobaseModel);
    builder.addLabeledComponent(new JLabel(
            "Autobase names (autobase_names option. Order is important, later components may be inherited from early):"),
            ToolbarDecorator.createDecorator(autobaseList).setAddAction(new AnActionButtonRunnable() {
                @Override//from w w  w  .j  av  a2 s  .c om
                public void run(AnActionButton anActionButton) {
                    String fileName = Messages.showInputDialog(myProject, "Type new Autobase filename:",
                            "New Autobase Filename", Messages.getQuestionIcon(), "", null);
                    if (StringUtil.isNotEmpty(fileName) && !autobaseModel.getItems().contains(fileName)) {
                        autobaseModel.add(fileName);
                    }
                }
            }).setPreferredSize(JBUI.size(0, PerlConfigurationUtil.WIDGET_HEIGHT)).createPanel());
}

From source file:com.perl5.lang.perl.extensions.generation.PerlCodeGeneratorImpl.java

License:Apache License

protected List<String> askFieldsNames(Project project, String promptText, String promptTitle) {
    Set<String> result = new THashSet<String>();
    String name = Messages.showInputDialog(project, promptText, promptTitle, Messages.getQuestionIcon(), "",
            null);//from   ww w. j ava2 s. c om

    if (!StringUtil.isEmpty(name)) {

        for (String nameChunk : name.split("[ ,]+")) {
            if (!nameChunk.isEmpty() && PerlLexer.IDENTIFIER_PATTERN.matcher(nameChunk).matches()) {
                result.add(nameChunk);
            }
        }
    }
    return new ArrayList<String>(result);
}

From source file:com.perl5.lang.perl.idea.configuration.settings.PerlSettingsConfigurable.java

License:Apache License

@Nullable
@Override//  w w w.j a va 2  s  .co m
public JComponent createComponent() {
    FormBuilder builder = FormBuilder.createFormBuilder();
    builder.getPanel().setLayout(new VerticalFlowLayout());

    if (!PlatformUtils.isIntelliJ()) {
        createMicroIdeComponents(builder);
    }

    simpleMainCheckbox = new JCheckBox(
            "Use simple main:: subs resolution (many scripts with same named subs in main:: namespace)");
    builder.addComponent(simpleMainCheckbox);

    autoInjectionCheckbox = new JCheckBox("Automatically inject other languages in here-docs by marker text");
    builder.addComponent(autoInjectionCheckbox);

    allowInjectionWithInterpolation = new JCheckBox(
            "Allow injections in QQ here-docs with interpolated entities");
    builder.addComponent(allowInjectionWithInterpolation);

    perlTryCatchCheckBox = new JCheckBox("Enable TryCatch syntax extension");
    builder.addComponent(perlTryCatchCheckBox);

    perlAnnotatorCheckBox = new JCheckBox("Enable perl -cw annotations [NYI]");
    //      builder.addComponent(perlAnnotatorCheckBox);

    perlCriticCheckBox = new JCheckBox("Enable Perl::Critic annotations (should be installed)");
    builder.addComponent(perlCriticCheckBox);

    perlCriticPathInputField = new TextFieldWithBrowseButton();
    perlCriticPathInputField.setEditable(false);
    FileChooserDescriptor perlCriticDescriptor = new FileChooserDescriptor(true, false, false, false, false,
            false) {
        @Override
        public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
            if (!super.isFileVisible(file, showHiddenFiles))
                return false;

            return file.isDirectory()
                    || StringUtil.equals(file.getName(), PerlCriticAnnotator.PERL_CRITIC_NAME);
        }
    };

    perlCriticPathInputField.addBrowseFolderListener("Select file", "Choose a Perl::Critic executable", null, // project
            perlCriticDescriptor);
    builder.addLabeledComponent(new JLabel("Path to PerlCritic executable:"), perlCriticPathInputField);
    perlCriticArgsInputField = new RawCommandLineEditor();
    builder.addComponent(copyDialogCaption(
            LabeledComponent.create(perlCriticArgsInputField, "Perl::Critic command line arguments:"),
            "Perl::Critic command line arguments:"));

    perlTidyPathInputField = new TextFieldWithBrowseButton();
    perlTidyPathInputField.setEditable(false);
    FileChooserDescriptor perlTidyDescriptor = new FileChooserDescriptor(true, false, false, false, false,
            false) {
        @Override
        public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
            if (!super.isFileVisible(file, showHiddenFiles))
                return false;

            return file.isDirectory()
                    || StringUtil.equals(file.getName(), PerlFormatWithPerlTidyAction.PERL_TIDY_NAME);
        }
    };

    perlTidyPathInputField.addBrowseFolderListener("Select file", "Choose a Perl::Tidy executable", null, // project
            perlTidyDescriptor);
    builder.addLabeledComponent(new JLabel("Path to PerlTidy executable:"), perlTidyPathInputField);
    perlTidyArgsInputField = new RawCommandLineEditor();
    builder.addComponent(copyDialogCaption(
            LabeledComponent.create(perlTidyArgsInputField,
                    "Perl::Tidy command line arguments (-se -se arguments will be added automatically):"),
            "Perl::Tidy command line arguments:"));

    regeneratePanel = new JPanel(new BorderLayout());
    regenerateButton = new JButton("Re-generate XSubs declarations");
    regenerateButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            PerlXSubsState.getInstance(myProject).reparseXSubs();
        }
    });
    regeneratePanel.add(regenerateButton, BorderLayout.WEST);
    builder.addComponent(regeneratePanel);

    deparseArgumentsTextField = new JTextField();
    builder.addLabeledComponent("Comma-separated B::Deparse options for deparse action",
            deparseArgumentsTextField);

    selfNamesModel = new CollectionListModel<String>();
    selfNamesList = new JBList(selfNamesModel);
    builder.addLabeledComponent(
            new JLabel("Scalar names considered as an object self-reference (without a $):"),
            ToolbarDecorator.createDecorator(selfNamesList).setAddAction(new AnActionButtonRunnable() {
                @Override
                public void run(AnActionButton anActionButton) {
                    String variableName = Messages.showInputDialog(myProject, "Type variable name:",
                            "New Self-Reference Variable Name", Messages.getQuestionIcon(), "", null);
                    if (StringUtil.isNotEmpty(variableName)) {
                        while (variableName.startsWith("$")) {
                            variableName = variableName.substring(1);
                        }

                        if (StringUtil.isNotEmpty(variableName)
                                && !selfNamesModel.getItems().contains(variableName)) {
                            selfNamesModel.add(variableName);
                        }
                    }
                }
            }).createPanel());

    return builder.getPanel();
}

From source file:com.perl5.lang.perl.idea.configuration.settings.sdk.Perl5ProjectConfigurable.java

License:Apache License

@Nullable
@Override/*w w  w  . j  av a2  s. c om*/
public JComponent createComponent() {
    FormBuilder builder = FormBuilder.createFormBuilder();
    builder.getPanel().setLayout(new VerticalFlowLayout());

    builder.addComponent(myPerl5SdkConfigurable.createComponent());

    FormBuilder versionBuilder = FormBuilder.createFormBuilder();
    ComboBoxModel<PerlVersion> versionModel = new CollectionComboBoxModel<>(PerlVersion.ALL_VERSIONS);
    myTargetPerlVersionComboBox = new ComboBox<>(versionModel);
    myTargetPerlVersionComboBox.setRenderer(new ColoredListCellRenderer<PerlVersion>() {
        @Override
        protected void customizeCellRenderer(@NotNull JList<? extends PerlVersion> list, PerlVersion value,
                int index, boolean selected, boolean hasFocus) {
            append(value.getStrictDottedVersion());
            String versionDescription = PerlVersion.PERL_VERSION_DESCRIPTIONS.get(value);
            if (StringUtil.isNotEmpty(versionDescription)) {
                append(" (" + versionDescription + ")");
            }
        }
    });
    versionBuilder.addLabeledComponent(PerlBundle.message("perl.config.language.level"),
            myTargetPerlVersionComboBox);
    builder.addComponent(versionBuilder.getPanel());

    myLibsModel = new CollectionListModel<>();
    myLibsList = new JBList<>(myLibsModel);
    myLibsList.setVisibleRowCount(ourRowsCount);
    myLibsList.setCellRenderer(new ColoredListCellRenderer<VirtualFile>() {
        @Override
        protected void customizeCellRenderer(@NotNull JList<? extends VirtualFile> list, VirtualFile value,
                int index, boolean selected, boolean hasFocus) {
            setIcon(PerlIcons.PERL_LANGUAGE_ICON);
            append(FileUtil.toSystemDependentName(value.getPath()));
        }
    });
    builder.addLabeledComponent(PerlBundle.message("perl.settings.external.libs"), ToolbarDecorator
            .createDecorator(myLibsList).setAddAction(this::doAddExternalLibrary).createPanel());

    simpleMainCheckbox = new JCheckBox(PerlBundle.message("perl.config.simple.main"));
    builder.addComponent(simpleMainCheckbox);

    autoInjectionCheckbox = new JCheckBox(PerlBundle.message("perl.config.heredoc.injections"));
    builder.addComponent(autoInjectionCheckbox);

    allowInjectionWithInterpolation = new JCheckBox(PerlBundle.message("perl.config.heredoc.injections.qq"));
    builder.addComponent(allowInjectionWithInterpolation);

    allowRegexpInjections = new JCheckBox(PerlBundle.message("perl.config.regex.injections"));
    builder.addComponent(allowRegexpInjections);
    allowRegexpInjections.setEnabled(false);
    allowRegexpInjections.setVisible(false);

    perlAnnotatorCheckBox = new JCheckBox(PerlBundle.message("perl.config.annotations.cw"));
    //      builder.addComponent(perlAnnotatorCheckBox);

    perlCriticCheckBox = new JCheckBox(PerlBundle.message("perl.config.annotations.critic"));
    builder.addComponent(perlCriticCheckBox);

    enablePerlSwitchCheckbox = new JCheckBox(PerlBundle.message("perl.config.enable.switch"));
    builder.addComponent(enablePerlSwitchCheckbox);

    perlCriticPathInputField = new TextFieldWithBrowseButton();
    perlCriticPathInputField.setEditable(false);
    FileChooserDescriptor perlCriticDescriptor = new FileChooserDescriptor(true, false, false, false, false,
            false) {
        @Override
        public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
            return super.isFileVisible(file, showHiddenFiles) && (file.isDirectory() || StringUtil
                    .equals(file.getNameWithoutExtension(), PerlCriticAnnotator.PERL_CRITIC_LINUX_NAME));
        }
    };

    //noinspection DialogTitleCapitalization
    perlCriticPathInputField.addBrowseFolderListener(PerlBundle.message("perl.config.select.file.title"),
            PerlBundle.message("perl.config.select.critic"), null, // project
            perlCriticDescriptor);
    builder.addLabeledComponent(new JLabel(PerlBundle.message("perl.config.path.critic")),
            perlCriticPathInputField);
    perlCriticArgsInputField = new RawCommandLineEditor();
    builder.addComponent(copyDialogCaption(
            LabeledComponent.create(perlCriticArgsInputField,
                    PerlBundle.message("perl.config.critic.cmd.arguments")),
            PerlBundle.message("perl.config.critic.cmd.arguments")));

    perlTidyPathInputField = new TextFieldWithBrowseButton();
    perlTidyPathInputField.setEditable(false);
    FileChooserDescriptor perlTidyDescriptor = new FileChooserDescriptor(true, false, false, false, false,
            false) {
        @Override
        public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
            return super.isFileVisible(file, showHiddenFiles) && (file.isDirectory() || StringUtil
                    .equals(file.getNameWithoutExtension(), PerlFormatWithPerlTidyAction.PERL_TIDY_LINUX_NAME));
        }
    };

    //noinspection DialogTitleCapitalization
    perlTidyPathInputField.addBrowseFolderListener(PerlBundle.message("perl.config.select.file.title"),
            PerlBundle.message("perl.config.select.tidy"), null, // project
            perlTidyDescriptor);
    builder.addLabeledComponent(new JLabel(PerlBundle.message("perl.config.path.tidy")),
            perlTidyPathInputField);
    perlTidyArgsInputField = new RawCommandLineEditor();
    builder.addComponent(copyDialogCaption(
            LabeledComponent.create(perlTidyArgsInputField,
                    PerlBundle.message("perl.config.tidy.options.label")),
            PerlBundle.message("perl.config.tidy.options.label.short")));

    JPanel regeneratePanel = new JPanel(new BorderLayout());
    JButton regenerateButton = new JButton(PerlBundle.message("perl.config.generate.xsubs"));
    regenerateButton.addActionListener(e -> PerlXSubsState.getInstance(myProject).reparseXSubs());
    regeneratePanel.add(regenerateButton, BorderLayout.WEST);
    builder.addComponent(regeneratePanel);

    deparseArgumentsTextField = new JTextField();
    builder.addLabeledComponent(PerlBundle.message("perl.config.deparse.options.label"),
            deparseArgumentsTextField);

    selfNamesModel = new CollectionListModel<>();
    JBList selfNamesList = new JBList<>(selfNamesModel);
    selfNamesList.setVisibleRowCount(ourRowsCount);
    builder.addLabeledComponent(new JLabel(PerlBundle.message("perl.config.self.names.label")),
            ToolbarDecorator.createDecorator(selfNamesList).setAddAction(anActionButton -> {
                String variableName = Messages.showInputDialog(myProject,
                        PerlBundle.message("perl.config.self.add.text"),
                        PerlBundle.message("perl.config.self.add.title"), Messages.getQuestionIcon(), "", null);
                if (StringUtil.isNotEmpty(variableName)) {
                    while (variableName.startsWith("$")) {
                        variableName = variableName.substring(1);
                    }

                    if (StringUtil.isNotEmpty(variableName)
                            && !selfNamesModel.getItems().contains(variableName)) {
                        selfNamesModel.add(variableName);
                    }
                }
            }).createPanel());

    JBScrollPane scrollPane = new JBScrollPane(builder.getPanel(),
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBorder(new JBEmptyBorder(JBUI.emptyInsets()));
    return scrollPane;
}

From source file:com.perl5.lang.perl.idea.generation.handlers.GeneratePerlGetterSetterActionHandlerBase.java

License:Apache License

@Override
protected void generateAtOffset(int targetOffset, Project project, Editor editor, PsiFile file) {
    String name = Messages.showInputDialog(project, getPromtText(), getPromtTitle(), Messages.getQuestionIcon(),
            "", null);

    if (!StringUtil.isEmpty(name)) {
        Document document = editor.getDocument();

        for (String nameChunk : name.split("[ ,]+")) {
            if (!nameChunk.isEmpty() && PerlLexer.IDENTIFIER_PATTERN.matcher(nameChunk).matches()) {
                doGenerate(document, nameChunk, targetOffset);
            }//from www  .j a  v  a2  s.  c o  m
        }

        PsiDocumentManager.getInstance(project).commitDocument(document);
    }

}

From source file:com.perl5.lang.perl.idea.intentions.StringToHeredocConverter.java

License:Apache License

@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element)
        throws IncorrectOperationException {
    String markerText = Messages.showInputDialog(project, "What here-doc marker should we use?",
            "Input a Heredoc Marker", Messages.getQuestionIcon(), HEREDOC_MARKER, null);
    if (markerText != null)
        if (markerText.isEmpty())
            Messages.showErrorDialog(project, "Empty heredoc markers are not supported", "Marker Error");
        else // converting
        {/*from   w  ww  .ja v a2 s . co m*/
            HEREDOC_MARKER = markerText;
            PsiElement parentElement = element.getParent();
            char quoteSymbol = '"';
            if (parentElement instanceof PsiPerlStringSq)
                quoteSymbol = '\'';
            else if (parentElement instanceof PsiPerlStringXq)
                quoteSymbol = '`';

            List<PsiElement> heredocElements = PerlElementFactory.createHereDocElements(project, quoteSymbol,
                    markerText, element.getText());

            PsiFile currentFile = element.getContainingFile();

            PsiElement newLineItem = null;
            int newLineIndex = currentFile.getText().indexOf("\n", element.getTextOffset());
            if (newLineIndex > 1)
                newLineItem = currentFile.findElementAt(newLineIndex);

            if (newLineItem == null) // last statement without newline
            {
                currentFile.addAfter(heredocElements.get(3), currentFile.getLastChild());
                currentFile.addAfter(heredocElements.get(1), currentFile.getLastChild());
                currentFile.addAfter(heredocElements.get(2), currentFile.getLastChild());
                currentFile.addAfter(heredocElements.get(3), currentFile.getLastChild());
            } else {
                PsiElement container = newLineItem.getParent();
                container.addAfter(heredocElements.get(3), container.addAfter(heredocElements.get(2),
                        container.addAfter(heredocElements.get(1), newLineItem)));
            }
            parentElement.replace(heredocElements.get(0));
        }
}

From source file:com.perl5.lang.perl.idea.intentions.StringToHeredocConverterIntention.java

License:Apache License

@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element)
        throws IncorrectOperationException {
    String markerText = Messages.showInputDialog(project, "What here-doc marker should we use?",
            "Input a Heredoc Marker", Messages.getQuestionIcon(), HEREDOC_MARKER, null);
    if (markerText != null) {
        if (markerText.isEmpty()) {
            Messages.showErrorDialog(project, "Empty heredoc markers are not supported", "Marker Error");
        } else // converting
        {// w  ww  .  j  a va2  s.  co m
            HEREDOC_MARKER = markerText;
            super.invoke(project, editor, element);
        }
    }
}

From source file:com.perl5.lang.perl.idea.intentions.StringToHeredocIntention.java

License:Apache License

@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element)
        throws IncorrectOperationException {
    ApplicationManager.getApplication().invokeLater(() -> {
        String markerText = Messages.showInputDialog(project,
                PerlBundle.message("perl.intention.heredoc.dialog.prompt"),
                PerlBundle.message("perl.intention.heredoc.dialog.title"), Messages.getQuestionIcon(),
                HEREDOC_MARKER, null);/*from   w w  w.  j  av a 2s.  c  o m*/
        if (markerText != null) {
            if (markerText.isEmpty()) {
                Messages.showErrorDialog(project, PerlBundle.message("perl.intention.heredoc.error.message"),
                        PerlBundle.message("perl.intention.heredoc.error.title"));
            } else // converting
            {
                HEREDOC_MARKER = markerText;
                WriteCommandAction.runWriteCommandAction(project, () -> super.invoke(project, editor, element));
            }
        }
    });
}