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) 

Source Link

Usage

From source file:co.uk.mikedamay.MikeActionClass.java

License:Apache License

public void actionPerformed(AnActionEvent event) {
    Project project = event.getData(PlatformDataKeys.PROJECT);
    String txt = Messages.showInputDialog(project, "What is your name?", "Input your name",
            Messages.getQuestionIcon());
    Messages.showMessageDialog(project, "Hello, " + txt + "!\n I am glad to see you.", "Information",
            Messages.getInformationIcon());
}

From source file:com.aspiro.git.actions.GitTag.java

License:Apache License

public void perform(@NotNull Project project, GitVcs vcs, @NotNull List<VcsException> exceptions,
        @NotNull VirtualFile[] affectedFiles) throws VcsException {
    saveAll();// w  w  w. j a va 2s . c  o m

    if (!ProjectLevelVcsManager.getInstance(project).checkAllFilesAreUnder(vcs, affectedFiles))
        return;

    final String tagName = Messages.showInputDialog(project, "Specify tag name", "Tag",
            Messages.getQuestionIcon());
    if (tagName == null)
        return;

    //todo: support multiple roots?
    GitCommand command = new GitCommand(project, vcs.getSettings(),
            GitUtil.getVcsRoot(project, affectedFiles[0]));

    final String output = command.tag(tagName);
    if (output.trim().length() != 0) {
        Messages.showInfoMessage(project, output, "Result");
    }
}

From source file:com.hp.alm.ali.idea.action.BlockItemAction.java

License:Apache License

@Override
public void setSelected(AnActionEvent event, boolean selected) {
    Project project = getEventProject(event);
    if (project != null) {
        Entity entity = EntityAction.getEntity(event);
        boolean isBlocked = isBlockedEntity(entity);
        Entity backlogItem = new Entity("release-backlog-item",
                Integer.valueOf(entity.getPropertyValue("release-backlog-item.id")));
        if (!selected && isBlocked) {
            backlogItem.setProperty("blocked", null);
        } else if (selected && !isBlocked) {
            String reason = Messages.showInputDialog(project, "Provide the reason why the item is blocked",
                    "Blocking Reason", null);
            if (reason != null) {
                backlogItem.setProperty("blocked", reason);
            } else {
                return;
            }/*from   w  ww .  j  a  v a  2s .co m*/
        } else {
            return;
        }
        EntityService entityService = project.getComponent(EntityService.class);
        entityService.updateEntity(backlogItem, Collections.singleton("blocked"), false);
    }
}

From source file:com.intellij.application.options.emmet.CssEditPrefixesListPanel.java

License:Apache License

public JPanel createMainComponent() {
    final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myPrefixesTableView);
    decorator.disableUpDownActions();/*  ww w .ja v  a2  s  . c  o  m*/
    final JPanel panel = decorator.createPanel();
    decorator.setAddAction(new AnActionButtonRunnable() {
        @Override
        public void run(AnActionButton button) {
            TableUtil.stopEditing(myPrefixesTableView);
            String propertyName = Messages.showInputDialog(myPrefixesTableView, "Property name:",
                    "New Css Property", null);
            if (propertyName != null && !propertyName.isEmpty()) {
                List<CssPrefixInfo> items = myPrefixesModel.getItems();
                for (CssPrefixInfo state : items) {
                    if (propertyName.equals(state.getPropertyName())) {
                        myPrefixesTableView.clearSelection();
                        myPrefixesTableView.addSelection(state);
                        scrollToSelection();
                        return;
                    }
                }
                CssPrefixInfo newPrefixInfo = new CssPrefixInfo(propertyName);
                myPrefixesModel.addRow(newPrefixInfo);
                myPrefixesTableView.clearSelection();
                myPrefixesTableView.addSelection(newPrefixInfo);
                scrollToSelection();
            }
            myPrefixesTableView.requestFocus();
        }

        private void scrollToSelection() {
            int selectedRow = myPrefixesTableView.getSelectedRow();
            if (selectedRow >= 0) {
                myPrefixesTableView.scrollRectToVisible(myPrefixesTableView.getCellRect(selectedRow, 0, true));
            }
        }
    }).setRemoveAction(new AnActionButtonRunnable() {
        @Override
        public void run(AnActionButton button) {
            TableUtil.stopEditing(myPrefixesTableView);
            CssPrefixInfo selectedObject = myPrefixesTableView.getSelectedObject();
            int selectedRow = myPrefixesTableView.getSelectedRow();
            int index = myPrefixesModel.indexOf(selectedObject);
            if (0 <= index && index < myPrefixesModel.getRowCount()) {
                myPrefixesModel.removeRow(index);
                if (selectedRow < myPrefixesTableView.getRowCount()) {
                    myPrefixesTableView.setRowSelectionInterval(selectedRow, selectedRow);
                } else {
                    if (selectedRow > 0) {
                        myPrefixesTableView.setRowSelectionInterval(selectedRow - 1, selectedRow - 1);
                    }
                }
            }
            myPrefixesTableView.getParent().repaint();
            myPrefixesTableView.requestFocus();
        }
    });
    return panel;
}

From source file:com.intellij.debugger.ui.InstanceFilterEditor.java

License:Apache License

protected void addClassFilter() {
    String idString = Messages.showInputDialog(myProject,
            DebuggerBundle.message("add.instance.filter.dialog.prompt"),
            DebuggerBundle.message("add.instance.filter.dialog.title"), Messages.getQuestionIcon());
    if (idString != null) {
        ClassFilter filter = createFilter(idString);
        if (filter != null) {
            myTableModel.addRow(filter);
            int row = myTableModel.getRowCount() - 1;
            myTable.getSelectionModel().setSelectionInterval(row, row);
            myTable.scrollRectToVisible(myTable.getCellRect(row, 0, true));

        }/*from  ww w . j  a  va2  s .co  m*/
        myTable.requestFocus();
    }
}

From source file:com.intellij.ide.actionMacro.ActionMacroManager.java

License:Apache License

public void stopRecording(@Nullable Project project) {
    LOG.assertTrue(myIsRecording);/*from w  w  w  .  ja  v a  2  s .com*/

    if (myWidget != null) {
        myWidget.delete();
        myWidget = null;
    }

    myIsRecording = false;
    myLastActionInputEvent.clear();
    String macroName;
    do {
        macroName = Messages.showInputDialog(project, IdeBundle.message("prompt.enter.macro.name"),
                IdeBundle.message("title.enter.macro.name"), Messages.getQuestionIcon());
        if (macroName == null) {
            myRecordingMacro = null;
            return;
        }

        if (macroName.isEmpty())
            macroName = null;
    } while (macroName != null && !checkCanCreateMacro(macroName));

    myLastMacro = myRecordingMacro;
    addRecordedMacroWithName(macroName);
    registerActions();
}

From source file:com.intellij.profile.codeInspection.ui.SingleInspectionProfilePanel.java

License:Apache License

@Nullable
public static ModifiableModel createNewProfile(final int initValue, ModifiableModel selectedProfile,
        JPanel parent, String profileName, Set<String> existingProfileNames, @NotNull Project project) {
    profileName = Messages.showInputDialog(parent, profileName, "Create New Inspection Profile",
            Messages.getQuestionIcon());
    if (profileName == null)
        return null;
    final ProfileManager profileManager = selectedProfile.getProfileManager();
    if (existingProfileNames.contains(profileName)) {
        Messages.showErrorDialog(/*from   w  ww. j  a v  a  2  s  .  c  o m*/
                InspectionsBundle.message("inspection.unable.to.create.profile.message", profileName),
                InspectionsBundle.message("inspection.unable.to.create.profile.dialog.title"));
        return null;
    }
    InspectionProfileImpl inspectionProfile = new InspectionProfileImpl(profileName,
            InspectionToolRegistrar.getInstance(), profileManager);
    if (initValue == -1) {
        inspectionProfile.initInspectionTools(project);
        ModifiableModel profileModifiableModel = inspectionProfile.getModifiableModel();
        final InspectionToolWrapper[] profileEntries = profileModifiableModel.getInspectionTools(null);
        for (InspectionToolWrapper toolWrapper : profileEntries) {
            profileModifiableModel.disableTool(toolWrapper.getShortName(), null, project);
        }
        profileModifiableModel.setProjectLevel(false);
        profileModifiableModel.setModified(true);
        return profileModifiableModel;
    } else if (initValue == 0) {
        inspectionProfile.copyFrom(selectedProfile);
        inspectionProfile.setName(profileName);
        inspectionProfile.initInspectionTools(project);
        inspectionProfile.setModified(true);
        return inspectionProfile;
    }
    return null;
}

From source file:com.intellij.tools.ScanSourceCommentsAction.java

License:Apache License

@Override
public void actionPerformed(AnActionEvent e) {

    final Project p = CommonDataKeys.PROJECT.getData(e.getDataContext());
    final String file = Messages.showInputDialog(p, "Enter path to the file comments will be extracted to",
            "Comments File Path", Messages.getQuestionIcon());

    try {//from  ww  w . j  a  v a 2s. c o  m
        final PrintStream stream = new PrintStream(file);
        stream.println("Comments in " + p.getName());

        ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
            @Override
            public void run() {
                final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
                ProjectRootManager.getInstance(p).getFileIndex().iterateContent(new ContentIterator() {
                    @Override
                    public boolean processFile(VirtualFile fileOrDir) {
                        if (fileOrDir.isDirectory()) {
                            indicator.setText("Extracting comments");
                            indicator.setText2(fileOrDir.getPresentableUrl());
                        }
                        scanCommentsInFile(p, fileOrDir);
                        return true;
                    }
                });

                indicator.setText2("");
                int count = 1;
                for (CommentDescriptor descriptor : myComments.values()) {
                    stream.println(
                            "#" + count + " ---------------------------------------------------------------");
                    descriptor.print(stream);
                    stream.println();
                    count++;
                }

            }
        }, "Generating Comments", true, p);

        stream.close();

    } catch (Throwable e1) {
        LOG.error(e1);
        Messages.showErrorDialog(p, "Error writing? " + e1.getMessage(), "Problem writing");
    }
}

From source file:com.intellij.uiDesigner.palette.AddGroupAction.java

License:Apache License

public void actionPerformed(AnActionEvent e) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    if (project == null)
        return;//  w w w .  j av  a  2 s.  co  m
    // Ask group name
    final String groupName = Messages.showInputDialog(project,
            UIDesignerBundle.message("message.enter.group.name"), UIDesignerBundle.message("title.add.group"),
            Messages.getQuestionIcon());
    if (groupName == null) {
        return;
    }

    Palette palette = Palette.getInstance(project);
    // Check that name of the group is unique
    final ArrayList<GroupItem> groups = palette.getGroups();
    for (int i = groups.size() - 1; i >= 0; i--) {
        if (groupName.equals(groups.get(i).getName())) {
            Messages.showErrorDialog(project, UIDesignerBundle.message("error.group.name.unique"),
                    CommonBundle.getErrorTitle());
            return;
        }
    }

    final GroupItem groupToBeAdded = new GroupItem(groupName);
    ArrayList<GroupItem> newGroups = new ArrayList<GroupItem>(groups);
    newGroups.add(groupToBeAdded);
    palette.setGroups(newGroups);
}

From source file:com.ritesh.idea.plugin.ui.toolswindow.reviewpanel.ReviewsPanel.java

License:Apache License

private JComponent createDiffPanelToolbar() {
    DefaultActionGroup actionGroup = new DefaultActionGroup("ReviewBoardDiffActionsGroup", false);
    actionGroup.add(new AnAction("Refresh", "Refresh", AllIcons.Actions.Refresh) {
        @Override/*  www .java 2s .  c o m*/
        public void actionPerformed(AnActionEvent anActionEvent) {
            controller.loadSelectedReview();
        }
    });
    actionGroup.addAction(
            new AnAction("Publish Review", "Publish comments and changes to server", AllIcons.Actions.Export) {
                @Override
                public void actionPerformed(AnActionEvent anActionEvent) {
                    if (controller.commentsAvailableForPublish()) {
                        final String reviewComment = Messages.showInputDialog(project, "Review Comment",
                                "Review Comment", null);
                        if (reviewComment != null) {
                            controller.publishReview(reviewComment);
                        }
                    }
                }

                @Override
                public void update(AnActionEvent e) {
                    e.getPresentation().setEnabled(controller.commentsAvailableForPublish());
                }
            });
    actionGroup.add(new Separator());
    actionGroup.addAll(changesTree.getTreeActions());
    return ActionManager.getInstance().createActionToolbar("ReviewBoardDiffActionGroup", actionGroup, true)
            .getComponent();
}