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

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

Introduction

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

Prototype

@Nullable
    public static String showEditableChooseDialog(String message,
            @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon, String[] values,
            String initialValue, @Nullable InputValidator validator) 

Source Link

Usage

From source file:auto.fix.ConstantsExtractorFix.java

License:Apache License

public void applyDefaultFix(Project project, String command, boolean useSuggestedName) {
    IntroduceAndPropagateConstantHandler introduceConstantHandler = new IntroduceAndPropagateConstantHandler(
            project, constantExpression);
    if (useSuggestedName) {
        introduceConstantHandler.setPropagateSettings(command,
                IntroduceAndPropagateConstantHandler.extractDefaultFieldName(constantExpression), false);
    } else {/* w  w w  . ja  v  a  2 s  .c o m*/
        //TODO: there's some utility that let's you highlight the actual text in the file and rename right in the editor - figure out how to use that 
        String suggestedName = IntroduceAndPropagateConstantHandler.extractDefaultFieldName(constantExpression);
        String constantName = Messages.showEditableChooseDialog("Set constant name",
                "Rename Suggested Constant Name", null, new String[] {}, suggestedName, new InputValidator() {
                    public boolean checkInput(String inputString) {
                        return true;
                    }

                    public boolean canClose(String inputString) {
                        return true;
                    }
                });
        introduceConstantHandler.setPropagateSettings(command,
                constantName != null ? constantName : suggestedName, false);
    }
}

From source file:com.intellij.uiDesigner.inspections.AssignMnemonicFix.java

License:Apache License

public void run() {
    IProperty textProperty = FormInspectionUtil.findProperty(myComponent, SwingProperties.TEXT);
    StringDescriptor descriptor = (StringDescriptor) textProperty.getPropertyValue(myComponent);
    String value = StringDescriptorManager.getInstance(myComponent.getModule()).resolve(myComponent,
            descriptor);/*w ww . ja v  a2  s . c om*/
    String[] variants = fillMnemonicVariants(SupportCode.parseText(value).myText);
    String result = Messages.showEditableChooseDialog(
            UIDesignerBundle.message("inspection.missing.mnemonics.quickfix.prompt"),
            UIDesignerBundle.message("inspection.missing.mnemonics.quickfix.title"), Messages.getQuestionIcon(),
            variants, variants[0], null);
    if (result != null) {
        if (!myEditor.ensureEditable()) {
            return;
        }
        FormInspectionUtil.updateStringPropertyValue(myEditor, myComponent, (IntroStringProperty) textProperty,
                descriptor, result);
    }
}

From source file:com.magnet.plugin.r2m.ui.chooser.ExampleChooserHelper.java

License:Open Source License

public static String showExamplesDialog() {

    EXAMPLES_DIALOG_UP = true;/*from  w  w w .j  av a2  s . c o m*/
    try {
        List<String> examples = getManifest().getExamplesList();
        String response = Messages.showEditableChooseDialog(R2MMessages.getMessage("CHOOSE_EXAMPLE_LABEL"),
                R2MMessages.getMessage("CHOOSE_EXAMPLE_TITLE"), Messages.getQuestionIcon(),
                examples.toArray(new String[examples.size()]),
                R2MMessages.getMessage("CHOOSE_EXAMPLE_DEFAULT_VALUE"), null);
        return response == null ? null : response.split(ExamplesManifest.DESCRIPTION_SEPARATOR_KEY)[0];
    } finally {
        EXAMPLES_DIALOG_UP = false;
    }
}

From source file:com.magnet.plugin.ui.chooser.ExampleChooserHelper.java

License:Open Source License

public static String showExamplesDialog() {

    EXAMPLES_DIALOG_UP = true;/* w ww  . j  a  v  a  2  s .  c  o m*/
    try {
        List<String> examples = getManifest().getExamplesList();
        String response = Messages.showEditableChooseDialog(
                Rest2MobileMessages.getMessage(Rest2MobileMessages.CHOOSE_EXAMPLE_LABEL),
                Rest2MobileMessages.getMessage(Rest2MobileMessages.CHOOSE_EXAMPLE_TITLE),
                Messages.getQuestionIcon(), examples.toArray(new String[examples.size()]),
                Rest2MobileMessages.getMessage(Rest2MobileMessages.CHOOSE_EXAMPLE_DEFAULT_VALUE), null);
        return response == null ? null : response.split(ExamplesManifest.DESCRIPTION_SEPARATOR_KEY)[0];
    } finally {
        EXAMPLES_DIALOG_UP = false;
    }
}

From source file:git4idea.actions.GitCheckout.java

License:Apache License

@Override
protected void perform(@NotNull Project project, GitVcs vcs, @NotNull List<VcsException> exceptions,
        @NotNull VirtualFile[] affectedFiles) throws VcsException {
    saveAll();/*  ww w.  ja va2  s  . com*/

    final VirtualFile[] roots = ProjectLevelVcsManager.getInstance(project).getRootsUnderVcs(vcs);
    List<GitBranch> branches;

    for (VirtualFile root : roots) {
        GitCommand command = new GitCommand(project, vcs.getSettings(), root);
        branches = command.branchList();

        String[] branchesList = new String[branches.size()];
        String selectedBranch = null;
        int i = 0;
        for (GitBranch b : branches) {
            branchesList[i++] = b.getName();
            if (selectedBranch == null || b.isActive())
                selectedBranch = b.getName();
        }

        String branchName = Messages.showEditableChooseDialog("Select branch to checkout", "Checkout Branch",
                Messages.getQuestionIcon(), branchesList, selectedBranch, new GitBranchNameValidator());

        if (branchName == null)
            return;
        selectedBranch = null;
        for (GitBranch b : branches) {
            if (branchName.equals(b.getName())) {
                selectedBranch = branchName;
            }
        }

        String[] args = new String[1];
        if (selectedBranch != null) {
            args[0] = selectedBranch;
        } else {
            args[0] = branchName;
        }

        GitCommandRunnable cmdr = new GitCommandRunnable(project, vcs.getSettings(), root);
        cmdr.setCommand(GitCommand.CHECKOUT_CMD);
        cmdr.setArgs(args);

        ProgressManager manager = ProgressManager.getInstance();
        //TODO: make this async so the git command output can be seen in the version control window as it happens...
        manager.runProcessWithProgressSynchronously(cmdr, "Checkout " + args[0], false, project);

        VcsException ex = cmdr.getException();
        if (ex != null)
            Messages.showErrorDialog(project, ex.getMessage(), "Error occurred during 'git checkout'");
    }
}

From source file:org.codinjutsu.tools.nosql.redis.view.action.SetSeparatorAction.java

License:Apache License

@Override
public void actionPerformed(AnActionEvent event) {
    String[] strings = ArrayUtil.toStringArray(myPredefinedSeparators);
    String current = redisPanel.getGroupSeparator();
    String separator = Messages.showEditableChooseDialog("Redis Keys Separator", "Select Separator",
            Messages.getQuestionIcon(), strings, current, null);
    if (separator == null) {
        return;//from  w w  w.ja  v  a  2  s.  com
    }

    if (StringUtils.equals(redisPanel.getGroupSeparator(), separator)) {
        return;
    }

    redisPanel.setGroupSeparator(separator);

    myPredefinedSeparators.add(separator);
    update(event);
}