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

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

Introduction

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

Prototype

@Nullable
    public static String showInputDialog(@NotNull Component parent, String message,
            @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon,
            @Nullable String initialValue, @Nullable InputValidator validator) 

Source Link

Usage

From source file:be.cegeka.intellij.plugin.configurablefilename.CreateFileWithConfigurableNameAction.java

License:Open Source License

@NotNull
@Override/*from  w  w  w  .  j a v  a  2 s  . com*/
protected PsiElement[] invokeDialog(Project project, PsiDirectory directory) {
    MyInputValidator validator = new MyValidator(project, directory);
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        try {
            return validator.create("test");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    } else {
        Messages.showInputDialog(project, IdeBundle.message("prompt.enter.new.file.name"),
                MessageBundle.message("title.new.file", type), null, null, validator);
        return validator.getCreatedElements();
    }
}

From source file:com.android.tools.idea.gradle.refactoring.GradleRenameModuleHandler.java

License:Apache License

@Override
public void invoke(@NotNull final Project project, @NotNull PsiElement[] elements,
        @NotNull DataContext dataContext) {
    Module module = getGradleModule(dataContext);
    assert module != null;
    Messages.showInputDialog(project, IdeBundle.message("prompt.enter.new.module.name"),
            IdeBundle.message("title.rename.module"), Messages.getQuestionIcon(), module.getName(),
            new MyInputValidator(module));
}

From source file:com.android.tools.idea.rendering.multi.RenderPreview.java

License:Apache License

/**
 * Handles clicks within the preview (x and y are positions relative within the
 * preview/*  w ww .  j av a  2  s  . c  o m*/
 *
 * @param x the x coordinate within the preview where the click occurred
 * @param y the y coordinate within the preview where the click occurred
 * @return true if this preview handled (and therefore consumed) the click
 */
public boolean click(int x, int y) {
    if (y >= myTitleHeight && y < myTitleHeight + HEADER_HEIGHT) {
        int left = 0;
        left += AllIcons.Actions.CloseNewHovered.getIconWidth();
        if (x <= left) {
            // Delete
            myManager.deletePreview(this);
            return true;
        }
        if (ZOOM_SUPPORT) {
            left += AndroidIcons.ZoomIn.getIconWidth();
            if (x <= left) {
                // Zoom in
                myScale *= (1 / 0.5);
                if (Math.abs(myScale - 1.0) < 0.0001) {
                    myScale = 1.0;
                }

                myManager.scheduleRender(this, 0);
                myManager.layout(true);
                myManager.redraw();
                return true;
            }
            left += AndroidIcons.ZoomOut.getIconWidth();
            if (x <= left) {
                // Zoom out
                myScale *= (0.5 / 1);
                if (Math.abs(myScale - 1.0) < 0.0001) {
                    myScale = 1.0;
                }
                myManager.scheduleRender(this, 0);

                myManager.layout(true);
                myManager.redraw();
                return true;
            }
        }
        left += AllIcons.Actions.Edit.getIconWidth();
        if (x <= left) {
            // Edit. For now, just rename
            Project project = myConfiguration.getConfigurationManager().getProject();
            String newName = Messages.showInputDialog(project, "Name:", "Rename Preview", null,
                    myConfiguration.getDisplayName(), null);
            if (newName != null) {
                myConfiguration.setDisplayName(newName);
                myManager.redraw();
            }

            return true;
        }

        // Clicked anywhere else on header
        // Perhaps open Edit dialog here?
    }

    myManager.switchTo(this);
    return true;
}

From source file:com.ansorgit.plugins.bash.actions.NewBashActionBase.java

License:Apache License

@NotNull
protected final PsiElement[] invokeDialog(final Project project, final PsiDirectory directory) {
    log.debug("invokeDialog");
    final MyInputValidator validator = new MyInputValidator(project, directory);
    Messages.showInputDialog(project, getDialogPrompt(), getDialogTitle(), Messages.getQuestionIcon(), "",
            validator);//from   www.  j  av  a 2s.c om

    final PsiElement[] elements = validator.getCreatedElements();
    log.debug("Result: " + elements);
    return elements;
}

From source file:com.bitbakery.plugin.arc.actions.NewArcFileAction.java

License:Artistic License

@NotNull
protected final PsiElement[] invokeDialog(final Project project, final PsiDirectory directory) {
    MyInputValidator validator = new MyInputValidator(project, directory);
    Messages.showInputDialog(project, getDialogPrompt(), getDialogTitle(), Messages.getQuestionIcon(), "",
            validator);/*from   w  w w  . ja  va 2  s .c  o  m*/

    return validator.getCreatedElements();
}

From source file:com.denimgroup.threadfix.plugins.intellij.dialog.ConfigDialog.java

License:Mozilla Public License

private static String getUrl(AnActionEvent e, String text, String url) {
    Project project = e.getData(PlatformDataKeys.PROJECT);
    return Messages.showInputDialog(project, text, Constants.URL_CONFIG_TITLE, Messages.getInformationIcon(),
            url, UrlValidator.INSTANCE);
}

From source file:com.denimgroup.threadfix.plugins.intellij.dialog.ConfigDialog.java

License:Mozilla Public License

private static String getApiKey(AnActionEvent e, String message, String key) {
    Project project = e.getData(PlatformDataKeys.PROJECT);
    return Messages.showInputDialog(project, message, Constants.API_KEY_TITLE, Messages.getInformationIcon(),
            key, null);//from  w w  w .j  av a  2  s . c om
}

From source file:com.elega9t.intellij.plugin.jbehave.actions.CreateNewStoryAction.java

License:Open Source License

@NotNull
@Override//from  w ww  .j  a  v  a  2 s  . c o  m
protected PsiElement[] invokeDialog(Project project, PsiDirectory directory) {
    MyInputValidator validator = new MyInputValidator(project, directory);
    Messages.showInputDialog(project, "File name:", "jBehave Feature File", Messages.getQuestionIcon(), "",
            validator);
    return validator.getCreatedElements();
}

From source file:com.github.kumaraman21.intellijbehave.creator.CreateStoryAction.java

License:Apache License

@NotNull
@Override/* w  ww  .  j  a  v  a2  s. co  m*/
protected PsiElement[] invokeDialog(Project project, PsiDirectory directory) {
    CreateElementActionBase.MyInputValidator validator = new CreateElementActionBase.MyInputValidator(project,
            directory);
    Messages.showInputDialog(project, "Enter a new file name:", "New Story File", Messages.getQuestionIcon(),
            "", validator);
    return validator.getCreatedElements();
}

From source file:com.intellij.android.designer.model.layout.actions.AssignWeightAction.java

License:Apache License

@Override
public void actionPerformed(AnActionEvent e) {
    final List<? extends RadViewComponent> targets = mySelectedChildren;
    if (targets.isEmpty()) {
        return;//from  ww  w . j  a v  a2 s .co m
    }
    String currentWeight = targets.get(0).getTag().getAttributeValue(ATTR_LAYOUT_WEIGHT, ANDROID_URI);
    if (currentWeight == null || currentWeight.isEmpty()) {
        currentWeight = "0.0";
    }

    String title = getTemplatePresentation().getDescription();
    InputValidator validator = null; // TODO: Number validation!
    final String weight = Messages.showInputDialog(myDesigner, "Enter Weight Value:", title, null,
            currentWeight, validator);
    if (weight != null) {

        myDesigner.getToolProvider().execute(new ThrowableRunnable<Exception>() {
            @Override
            public void run() throws Exception {
                ApplicationManager.getApplication().runWriteAction(new Runnable() {
                    @Override
                    public void run() {
                        if (weight.isEmpty()) {
                            // Remove attributes
                            ClearWeightsAction.clearWeights(myLayout, targets);
                        } else {
                            for (RadViewComponent target : targets) {
                                target.getTag().setAttribute(ATTR_LAYOUT_WEIGHT, ANDROID_URI, weight);
                            }
                        }
                    }
                });
            }
        }, getTemplatePresentation().getDescription(), true);
    }
}