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

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

Introduction

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

Prototype

public static void showInfoMessage(@Nullable Project project, @Nls String message,
        @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title) 

Source Link

Document

Shows dialog with given message and title, information icon #getInformationIcon() and OK button

Usage

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

License:Apache License

public void actionPerformed(final AnActionEvent e) {
    final Project project;
    final VirtualFile formFile;
    GuiEditor editor = FormEditingUtil.getActiveEditor(e.getDataContext());
    assert editor != null;
    project = editor.getProject();/*from  w  w  w .j  a v  a2s  . com*/
    formFile = editor.getFile();

    try {
        final WizardData wizardData = new WizardData(project, formFile);

        final Module module = ModuleUtil.findModuleForFile(formFile, wizardData.myProject);
        LOG.assertTrue(module != null);

        final LwRootContainer[] rootContainer = new LwRootContainer[1];
        Generator.exposeForm(wizardData.myProject, formFile, rootContainer);
        final String classToBind = rootContainer[0].getClassToBind();
        if (classToBind == null) {
            Messages.showInfoMessage(project, UIDesignerBundle.message("info.form.not.bound"),
                    UIDesignerBundle.message("title.data.binding.wizard"));
            return;
        }

        final PsiClass boundClass = FormEditingUtil.findClassToBind(module, classToBind);
        if (boundClass == null) {
            Messages.showErrorDialog(project,
                    UIDesignerBundle.message("error.bound.to.not.found.class", classToBind),
                    UIDesignerBundle.message("title.data.binding.wizard"));
            return;
        }

        Generator.prepareWizardData(wizardData, boundClass);

        if (!hasBinding(rootContainer[0])) {
            Messages.showInfoMessage(project, UIDesignerBundle.message("info.no.bound.components"),
                    UIDesignerBundle.message("title.data.binding.wizard"));
            return;
        }

        if (!wizardData.myBindToNewBean) {
            final String[] variants = new String[] { UIDesignerBundle.message("action.alter.data.binding"),
                    UIDesignerBundle.message("action.bind.to.another.bean"),
                    CommonBundle.getCancelButtonText() };
            final int result = Messages.showYesNoCancelDialog(project,
                    MessageFormat.format(UIDesignerBundle.message("info.data.binding.regenerate"),
                            wizardData.myBeanClass.getQualifiedName()),
                    UIDesignerBundle.message("title.data.binding"), variants[0], variants[1], variants[2],
                    Messages.getQuestionIcon());
            if (result == 0) {
                // do nothing here
            } else if (result == 1) {
                wizardData.myBindToNewBean = true;
            } else {
                return;
            }
        }

        final DataBindingWizard wizard = new DataBindingWizard(project, formFile, wizardData);
        wizard.show();
    } catch (Generator.MyException exc) {
        Messages.showErrorDialog(project, exc.getMessage(), CommonBundle.getErrorTitle());
    }
}

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

License:Apache License

public void actionPerformed(AnActionEvent e) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    ComponentItem selectedItem = e.getData(ComponentItem.DATA_KEY);
    GroupItem groupItem = e.getData(GroupItem.DATA_KEY);
    if (project == null || selectedItem == null || groupItem == null)
        return;/*from w ww .j a v  a2  s  .c  o  m*/

    if (!selectedItem.isRemovable()) {
        Messages.showInfoMessage(project, UIDesignerBundle.message("error.cannot.remove.default.palette"),
                CommonBundle.getErrorTitle());
        return;
    }

    int rc = Messages.showYesNoDialog(project,
            UIDesignerBundle.message("delete.component.prompt", selectedItem.getClassShortName()),
            UIDesignerBundle.message("delete.component.title"), Messages.getQuestionIcon());
    if (rc != 0)
        return;

    final Palette palette = Palette.getInstance(project);
    palette.removeItem(groupItem, selectedItem);
    palette.fireGroupsChanged();
}

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

License:Apache License

public void actionPerformed(AnActionEvent e) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    GroupItem groupToBeRemoved = e.getData(GroupItem.DATA_KEY);
    if (groupToBeRemoved == null || project == null)
        return;//  w  ww.  ja  v  a  2 s  .c o m

    if (!Palette.isRemovable(groupToBeRemoved)) {
        Messages.showInfoMessage(project, UIDesignerBundle.message("error.cannot.remove.default.group"),
                CommonBundle.getErrorTitle());
        return;
    }

    Palette palette = Palette.getInstance(project);
    ArrayList<GroupItem> groups = new ArrayList<GroupItem>(palette.getGroups());
    groups.remove(groupToBeRemoved);
    palette.setGroups(groups);
}

From source file:com.jetbrains.lang.dart.ide.actions.DartSortMembersAction.java

License:Apache License

protected void runOverFiles(@NotNull final Project project, @NotNull final List<VirtualFile> dartFiles) {
    if (dartFiles.isEmpty()) {
        Messages.showInfoMessage(project, DartBundle.message("dart.sort.members.files.no.dart.files"),
                DartBundle.message("dart.sort.members.action.name"));
        return;//from  ww w .j  a v  a2 s .c o m
    }

    if (Messages.showOkCancelDialog(project,
            DartBundle.message("dart.sort.members.files.dialog.question", dartFiles.size()),
            DartBundle.message("dart.sort.members.action.name"), null) != Messages.OK) {
        return;
    }

    final Map<VirtualFile, SourceFileEdit> fileToFileEditMap = Maps.newHashMap();

    final Runnable runnable = () -> {
        double fraction = 0.0;
        for (final VirtualFile virtualFile : dartFiles) {
            fraction += 1.0;
            final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
            if (indicator != null) {
                indicator.checkCanceled();
                indicator.setFraction(fraction / dartFiles.size());
                indicator.setText2(FileUtil.toSystemDependentName(virtualFile.getPath()));
            }

            final String path = virtualFile.getPath();
            final SourceFileEdit fileEdit = DartAnalysisServerService.getInstance(project)
                    .edit_sortMembers(path);
            if (fileEdit != null) {
                fileToFileEditMap.put(virtualFile, fileEdit);
            }
        }
    };

    DartAnalysisServerService.getInstance(project).updateFilesContent();

    final boolean ok = ApplicationManagerEx.getApplicationEx().runProcessWithProgressSynchronously(runnable,
            DartBundle.message("dart.sort.members.action.name"), true, project);

    if (ok) {
        final Runnable onSuccessRunnable = () -> {
            CommandProcessor.getInstance().markCurrentCommandAsGlobal(project);

            for (Map.Entry<VirtualFile, SourceFileEdit> entry : fileToFileEditMap.entrySet()) {
                final VirtualFile file = entry.getKey();
                final Document document = FileDocumentManager.getInstance().getDocument(file);
                final SourceFileEdit fileEdit = entry.getValue();
                if (document != null) {
                    AssistUtils.applySourceEdits(project, file, document, fileEdit.getEdits(),
                            Collections.emptySet());
                }
            }
        };

        ApplicationManager.getApplication()
                .runWriteAction(() -> CommandProcessor.getInstance().executeCommand(project, onSuccessRunnable,
                        DartBundle.message("dart.sort.members.action.name"), null));
    }
}

From source file:com.maddyhome.idea.copyright.ui.CopyrightProfilesPanel.java

License:Apache License

@Nullable
protected ArrayList<AnAction> createActions(boolean fromPopup) {
    ArrayList<AnAction> result = new ArrayList<AnAction>();
    result.add(new AnAction("Add", "Add", IconUtil.getAddIcon()) {
        {/*from  w w  w . j  av  a  2 s.co m*/
            registerCustomShortcutSet(CommonShortcuts.INSERT, myTree);
        }

        public void actionPerformed(AnActionEvent event) {
            final String name = askForProfileName("Create Copyright Profile", "");
            if (name == null)
                return;
            final CopyrightProfile copyrightProfile = new CopyrightProfile(name);
            addProfileNode(copyrightProfile);
        }
    });
    result.add(new MyDeleteAction(forAll(Conditions.alwaysTrue())));
    result.add(new AnAction("Copy", "Copy", AllIcons.Actions.Copy) {
        {
            registerCustomShortcutSet(
                    new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, KeyEvent.CTRL_MASK)), myTree);
        }

        public void actionPerformed(AnActionEvent event) {
            final String profileName = askForProfileName("Copy Copyright Profile", "");
            if (profileName == null)
                return;
            final CopyrightProfile clone = new CopyrightProfile();
            clone.copyFrom((CopyrightProfile) getSelectedObject());
            clone.setName(profileName);
            addProfileNode(clone);
        }

        public void update(AnActionEvent event) {
            super.update(event);
            event.getPresentation().setEnabled(getSelectedObject() != null);
        }
    });
    result.add(new AnAction("Import", "Import", AllIcons.ToolbarDecorator.Import) {
        public void actionPerformed(AnActionEvent event) {
            final OpenProjectFileChooserDescriptor descriptor = new OpenProjectFileChooserDescriptor(true) {
                @Override
                public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
                    return super.isFileVisible(file, showHiddenFiles) || canContainCopyright(file);
                }

                @Override
                public boolean isFileSelectable(VirtualFile file) {
                    return super.isFileSelectable(file) || canContainCopyright(file);
                }

                private boolean canContainCopyright(VirtualFile file) {
                    return !file.isDirectory() && file.getFileType() == InternalStdFileTypes.XML;
                }
            };
            descriptor.setTitle("Choose file containing copyright notice");
            final VirtualFile file = FileChooser.chooseFile(descriptor, myProject, null);
            if (file == null)
                return;

            final List<CopyrightProfile> copyrightProfiles = ExternalOptionHelper
                    .loadOptions(VfsUtil.virtualToIoFile(file));
            if (copyrightProfiles == null)
                return;
            if (!copyrightProfiles.isEmpty()) {
                if (copyrightProfiles.size() == 1) {
                    importProfile(copyrightProfiles.get(0));
                } else {
                    JBPopupFactory.getInstance()
                            .createListPopup(new BaseListPopupStep<CopyrightProfile>("Choose profile to import",
                                    copyrightProfiles) {
                                @Override
                                public PopupStep onChosen(final CopyrightProfile selectedValue,
                                        boolean finalChoice) {
                                    return doFinalStep(new Runnable() {
                                        public void run() {
                                            importProfile(selectedValue);
                                        }
                                    });
                                }

                                @NotNull
                                @Override
                                public String getTextFor(CopyrightProfile value) {
                                    return value.getName();
                                }
                            }).showUnderneathOf(myNorthPanel);
                }
            } else {
                Messages.showWarningDialog(myProject,
                        "The selected file does not contain any copyright settings.", "Import Failure");
            }
        }

        private void importProfile(CopyrightProfile copyrightProfile) {
            final String profileName = askForProfileName("Import copyright profile",
                    copyrightProfile.getName());
            if (profileName == null)
                return;
            copyrightProfile.setName(profileName);
            addProfileNode(copyrightProfile);
            Messages.showInfoMessage(myProject, "The copyright settings have been successfully imported.",
                    "Import Complete");
        }
    });
    return result;
}

From source file:com.magnet.plugin.actions.CheckUpdatesAction.java

License:Open Source License

private static void showUpdatesAvailableDialog(Project project, String installedVersion, Properties info) {
    String newVersion = info.getProperty(Rest2MobileConstants.LATEST_VERSION_KEY);
    String url = info.getProperty(Rest2MobileConstants.DOWNLOAD_URL_KEY);
    String description = info.getProperty(Rest2MobileConstants.DESCRIPTION_KEY);
    String comments = info.getProperty(Rest2MobileConstants.COMMENTS_KEY);
    Messages.showInfoMessage(project,
            Rest2MobileMessages.getMessage(Rest2MobileMessages.UPDATES_AVAILABLE, installedVersion, newVersion,
                    url, description, comments),
            Rest2MobileMessages.getMessage(Rest2MobileMessages.UPDATES_WINDOW_TITLE));
}

From source file:com.magnet.plugin.actions.CheckUpdatesAction.java

License:Open Source License

private static void showNoUpdateDialog(Project project, String installedVersion, Properties info) {
    String newVersion = info.getProperty(Rest2MobileConstants.LATEST_VERSION_KEY);
    Messages.showInfoMessage(project, Rest2MobileMessages.getMessage(Rest2MobileMessages.NO_UPDATES_AVAILABLE,
            installedVersion, newVersion),
            Rest2MobileMessages.getMessage(Rest2MobileMessages.UPDATES_WINDOW_TITLE));
}

From source file:com.magnet.plugin.r2m.actions.CheckUpdatesAction.java

License:Open Source License

private static void showUpdatesAvailableDialog(Project project, String installedVersion, Properties info) {
    String newVersion = info.getProperty(R2MConstants.LATEST_VERSION_KEY);
    String url = info.getProperty(R2MConstants.DOWNLOAD_URL_KEY);
    String description = info.getProperty(R2MConstants.DESCRIPTION_KEY);
    String comments = info.getProperty(R2MConstants.COMMENTS_KEY);
    Messages.showInfoMessage(project, R2MMessages.getMessage("UPDATES_AVAILABLE", installedVersion, newVersion,
            url, description, comments), R2MMessages.getMessage("UPDATES_WINDOW_TITLE"));
}

From source file:com.magnet.plugin.r2m.actions.CheckUpdatesAction.java

License:Open Source License

private static void showNoUpdateDialog(Project project, String installedVersion, Properties info) {
    String newVersion = info.getProperty(R2MConstants.LATEST_VERSION_KEY);
    Messages.showInfoMessage(project,
            R2MMessages.getMessage("NO_UPDATES_AVAILABLE", installedVersion, newVersion),
            R2MMessages.getMessage("UPDATES_WINDOW_TITLE"));
}

From source file:com.microsoft.alm.plugin.idea.tfvc.actions.BranchAction.java

License:Open Source License

protected void execute(final @NotNull SingleItemActionContext actionContext) {
    logger.info("executing...");
    try {//from ww w.  j a  v a2s  .c  o  m
        final ServerContext serverContext = actionContext.getServerContext();
        final Project project = actionContext.getProject();
        final String sourceServerPath = actionContext.getItem().getServerItem();
        final boolean isFolder = actionContext.getItem().isFolder();
        final String workingFolder = isFolder ? actionContext.getItem().getLocalItem()
                : Path.getDirectoryName(actionContext.getItem().getLocalItem());
        logger.info("Working folder: " + workingFolder);
        logger.info("Opening branch dialog for " + sourceServerPath);
        CreateBranchDialog d = new CreateBranchDialog(project, serverContext, sourceServerPath, isFolder);
        if (!d.showAndGet()) {
            return;
        }

        // For now we are just branching from the Latest
        //VersionSpecBase version = d.getVersionSpec();
        //if (version == null) {
        //    Messages.showErrorDialog(project, "Incorrect version specified", "Create Branch");
        //    return;
        //}

        // Get the current workspace
        final Workspace workspace = CommandUtils.getWorkspace(serverContext, actionContext.getProject());
        if (workspace == null) {
            throw new RuntimeException(
                    TfPluginBundle.message(TfPluginBundle.KEY_ERRORS_UNABLE_TO_DETERMINE_WORKSPACE));
        }

        final String targetServerPath = d.getTargetPath();
        logger.info("TargetServerPath from dialog: " + targetServerPath);
        String targetLocalPath = StringUtils.EMPTY;
        if (d.isCreateWorkingCopies()) {
            logger.info("User selected to sync the new branched copies");
            // See if the target path is already mapped
            targetLocalPath = CommandUtils.tryGetLocalPath(serverContext, targetServerPath,
                    workspace.getName());
            logger.info("targetLocalPath: " + targetLocalPath);
            if (StringUtils.isEmpty(targetLocalPath)) {
                logger.info(
                        "Opening the FileChooser dialog for the user to select where the unmapped branch should be mapped to.");
                final FileChooserDescriptor descriptor = FileChooserDescriptorFactory
                        .createSingleFolderDescriptor();
                descriptor.setTitle(
                        TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_TFVC_BRANCH_FILE_CHOOSE_TITLE));
                descriptor.setShowFileSystemRoots(true);
                final String message = TfPluginBundle.message(
                        TfPluginBundle.KEY_ACTIONS_TFVC_BRANCH_FILE_CHOOSE_DESCRIPTION, targetServerPath,
                        workspace.getName());
                descriptor.setDescription(message);

                final VirtualFile selectedFile = FileChooser.chooseFile(descriptor, project, null);
                if (selectedFile == null) {
                    logger.info("User canceled");
                    return;
                }

                targetLocalPath = TfsFileUtil.getFilePath(selectedFile).getPath();
                logger.info("Adding workspace mapping: " + targetServerPath + " -> " + targetLocalPath);
                CommandUtils.addWorkspaceMapping(serverContext, workspace.getName(), targetServerPath,
                        targetLocalPath);
            }
        }

        //            final ResultWithFailures<GetOperation> createBranchResult = workspace.getServer().getVCS()
        //                    .createBranch(workspace.getName(), workspace.getOwnerName(), sourceServerPath, version, targetServerPath, project,
        //                            TFSBundle.message("creating.branch"));
        //            if (!createBranchResult.getFailures().isEmpty()) {
        //                StringBuilder s = new StringBuilder("Failed to create branch:\n");
        //                for (Failure failure : createBranchResult.getFailures()) {
        //                    s.append(failure.getMessage()).append("\n");
        //                }
        //                Messages.showErrorDialog(project, s.toString(), "Create Branch");
        //                return;
        //            }

        // Create the branch
        logger.info("Creating branch... isFolder: " + isFolder);
        final String comment = TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_TFVC_BRANCH_COMMENT,
                sourceServerPath);
        CommandUtils.createBranch(serverContext, workingFolder, true, comment, null, sourceServerPath,
                targetServerPath);

        if (d.isCreateWorkingCopies()) {
            logger.info("Get the latest for the branched folder...");
            final String localPath = targetLocalPath;
            final List<VcsException> errors = new ArrayList<VcsException>();
            ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
                public void run() {
                    logger.info("Syncing: " + localPath);
                    final SyncResults syncResults = CommandUtils.syncWorkspace(serverContext, localPath);
                    if (syncResults.getExceptions().size() > 0) {
                        for (final SyncException se : syncResults.getExceptions()) {
                            errors.add(TFSVcs.convertToVcsException(se));
                        }
                    }
                }
            }, TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_TFVC_BRANCH_SYNC_PROGRESS), false, project);

            if (!errors.isEmpty()) {
                logger.info("Errors found");
                AbstractVcsHelper.getInstance(project).showErrors(errors,
                        TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_TFVC_BRANCH_MESSAGE_TITLE));
            }
        }

        targetLocalPath = CommandUtils.tryGetLocalPath(serverContext, targetServerPath, workspace.getName());
        logger.info("targetLocalPath: " + targetLocalPath);
        if (StringUtils.isNotEmpty(targetLocalPath)) {
            logger.info("Marking the target path dirty in the editor.");
            TfsFileUtil.markDirtyRecursively(project, new LocalFilePath(targetLocalPath, isFolder));
        }

        final String message = TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_TFVC_BRANCH_MESSAGE_SUCCESS,
                sourceServerPath, targetServerPath);
        Messages.showInfoMessage(project, message,
                TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_TFVC_BRANCH_MESSAGE_TITLE));
    } catch (final Throwable t) {
        logger.warn("Branching failed", t);
        final String message = TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_TFVC_BRANCH_MESSAGE_FAILURE,
                t.getMessage());
        Messages.showErrorDialog(actionContext.getProject(), message,
                TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_TFVC_BRANCH_MESSAGE_TITLE));
    }
}