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:com.intellij.lang.properties.refactoring.ResourceBundleKeyRenameHandler.java

License:Apache License

@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
    ResourceBundleEditor bundleEditor = ResourceBundleUtil.getEditor(dataContext);
    if (bundleEditor == null) {
        return;/*from w w w . j  av  a 2 s. c  o  m*/
    }

    String propertyName = bundleEditor.getState(FileEditorStateLevel.NAVIGATION).getPropertyName();
    if (propertyName == null) {
        return;
    }

    ResourceBundle bundle = ResourceBundleUtil.getResourceBundleFromDataContext(dataContext);
    if (bundle == null) {
        return;
    }
    Messages.showInputDialog(project,
            PropertiesBundle.message("rename.bundle.enter.new.resource.bundle.key.name.prompt.text"),
            PropertiesBundle.message("rename.resource.bundle.key.dialog.title"), Messages.getQuestionIcon(),
            propertyName, new ResourceBundleKeyRenameValidator(project, bundleEditor, bundle, propertyName));
}

From source file:com.intellij.lang.properties.refactoring.ResourceBundleRenameHandler.java

License:Apache License

public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
    ResourceBundle resourceBundle = ResourceBundleUtil.getResourceBundleFromDataContext(dataContext);

    assert resourceBundle != null;
    Messages.showInputDialog(project,
            PropertiesBundle.message("rename.bundle.enter.new.resource.bundle.base.name.prompt.text"),
            PropertiesBundle.message("rename.resource.bundle.dialog.title"), Messages.getQuestionIcon(),
            resourceBundle.getBaseName(), new MyInputValidator(project, resourceBundle));
}

From source file:com.intellij.lang.properties.ResourceBundleRenameHandler.java

License:Apache License

public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
    ResourceBundle resourceBundle = getResourceBundleFromDataContext(dataContext);

    assert resourceBundle != null;
    Messages.showInputDialog(project,
            PropertiesBundle.message("rename.bundle.enter.new.resource.bundle.base.name.prompt.text"),
            PropertiesBundle.message("rename.resource.bundle.dialog.title"), Messages.getQuestionIcon(),
            resourceBundle.getBaseName(), new MyInputValidator(project, resourceBundle));
}

From source file:com.intellij.packaging.impl.elements.DirectoryElementType.java

License:Apache License

@Override
public CompositePackagingElement<?> createComposite(CompositePackagingElement<?> parent, String baseName,
        @NotNull ArtifactEditorContext context) {
    final String initialValue = PackagingElementFactoryImpl.suggestFileName(parent,
            baseName != null ? baseName : "folder", "");
    String path = Messages.showInputDialog(context.getProject(), "Enter directory name: ", "New Directory",
            null, initialValue, new FilePathValidator());
    if (path == null) {
        return null;
    }/*  w  w w . j a  va  2  s  .  co m*/
    path = FileUtil.toSystemIndependentName(path);
    final String parentPath = PathUtil.getParentPath(path);
    final String fileName = PathUtil.getFileName(path);
    final PackagingElement<?> element = new DirectoryPackagingElement(fileName);
    return (CompositePackagingElement<?>) PackagingElementFactoryImpl.getInstance()
            .createParentDirectories(parentPath, element);

}

From source file:com.intellij.packaging.impl.elements.JarArchiveElementType.java

License:Apache License

@Override
public CompositePackagingElement<?> createComposite(CompositePackagingElement<?> parent,
        @Nullable String baseName, @NotNull ArtifactEditorContext context) {
    final String initialValue = PackagingElementFactoryImpl.suggestFileName(parent,
            baseName != null ? baseName : "archive", ".jar");
    String path = Messages.showInputDialog(context.getProject(), "Enter archive name: ", "New Archive", null,
            initialValue, new FilePathValidator());
    if (path == null) {
        return null;
    }/*from  w  w w.jav  a 2 s  . co m*/
    path = FileUtil.toSystemIndependentName(path);
    final String parentPath = PathUtil.getParentPath(path);
    final String fileName = PathUtil.getFileName(path);
    final PackagingElement<?> element = new JarArchivePackagingElement(fileName);
    return (CompositePackagingElement<?>) PackagingElementFactory.getInstance()
            .createParentDirectories(parentPath, element);
}

From source file:com.intellij.packaging.impl.elements.ZipArchiveElementType.java

License:Apache License

@Override
public CompositePackagingElement<?> createComposite(CompositePackagingElement<?> parent,
        @Nullable String baseName, @NotNull ArtifactEditorContext context) {
    final String initialValue = PackagingElementFactoryImpl.suggestFileName(parent,
            baseName != null ? baseName : "archive", ".zip");
    String path = Messages.showInputDialog(context.getProject(), "Enter archive name: ", "New Archive", null,
            initialValue, new FilePathValidator());
    if (path == null) {
        return null;
    }/*  w  w w  .ja v  a  2s.  c o m*/
    path = FileUtil.toSystemIndependentName(path);
    final String parentPath = PathUtil.getParentPath(path);
    final String fileName = PathUtil.getFileName(path);
    final PackagingElement<?> element = new ZipArchivePackagingElement(fileName);
    return (CompositePackagingElement<?>) PackagingElementFactory.getInstance()
            .createParentDirectories(parentPath, element);
}

From source file:com.intellij.platform.renameProject.RenameProjectHandler.java

License:Apache License

@Override
public void invoke(@NotNull Project project, @NotNull PsiElement[] elements, DataContext dataContext) {
    LOG.assertTrue(project instanceof ProjectEx);

    final Module module = LangDataKeys.MODULE_CONTEXT.getData(dataContext);
    LOG.assertTrue(module != null);/*from ww  w  .  j a  va2s  . co  m*/
    Messages.showInputDialog(project, RefactoringBundle.message("enter.new.project.name"),
            RefactoringBundle.message("rename.project"), Messages.getQuestionIcon(), project.getName(),
            new MyInputValidator((ProjectEx) project, module));
}

From source file:com.intellij.tasks.actions.context.SaveContextAction.java

License:Apache License

public static void saveContext(Project project) {

    String initial = null;/* w  w w.j  a  v  a  2 s  .  co m*/
    Editor textEditor = FileEditorManager.getInstance(project).getSelectedTextEditor();
    if (textEditor != null) {
        PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(textEditor.getDocument());
        if (file != null) {
            initial = file.getName();
        }
    }
    String comment = Messages.showInputDialog(project, "Enter comment (optional):", "Save Context", null,
            initial, null);
    if (comment != null) {
        WorkingContextManager.getInstance(project).saveContext(null,
                StringUtil.isEmpty(comment) ? null : comment);
    }
}

From source file:com.intellij.tasks.actions.CreateChangelistAction.java

License:Apache License

@Override
public void actionPerformed(AnActionEvent e) {
    TaskManagerImpl manager = (TaskManagerImpl) getTaskManager(e);
    assert manager != null;
    LocalTask activeTask = manager.getActiveTask();
    String name = Messages.showInputDialog(getProject(e), "Changelist name:", "Create Changelist", null,
            manager.getChangelistName(activeTask), null);
    if (name != null) {
        manager.createChangeList(activeTask, name);
    }//from  w  ww.java  2s .c  om
}

From source file:com.intellij.uiDesigner.actions.GroupButtonsAction.java

License:Apache License

public static void groupButtons(final GuiEditor editor, final List<RadComponent> selectedComponents) {
    if (!editor.ensureEditable())
        return;/*from w  w w  .j ava  2s .  c o  m*/
    String groupName = Messages.showInputDialog(editor.getProject(),
            UIDesignerBundle.message("group.buttons.name.prompt"),
            UIDesignerBundle.message("group.buttons.title"), Messages.getQuestionIcon(),
            editor.getRootContainer().suggestGroupName(), new IdentifierValidator(editor.getProject()));
    if (groupName == null)
        return;
    RadRootContainer rootContainer = editor.getRootContainer();
    RadButtonGroup group = rootContainer.createGroup(groupName);
    for (RadComponent component : selectedComponents) {
        rootContainer.setGroupForComponent(component, group);
    }
    editor.refreshAndSave(true);
}