List of usage examples for com.intellij.openapi.ui Messages showInfoMessage
public static void showInfoMessage(@Nullable Project project, @Nls String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title)
From source file:com.intellij.ide.actions.OpenFileAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent e) { @Nullable/*from ww w .j a v a2s . c o m*/ final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext()); final boolean showFiles = project != null; final FileChooserDescriptor descriptor = new OpenProjectFileChooserDescriptor(true) { @Override public boolean isFileSelectable(VirtualFile file) { if (super.isFileSelectable(file)) { return true; } if (file.isDirectory()) { return false; } return showFiles && !FileElement.isArchive(file); } @Override public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { if (!file.isDirectory() && isFileSelectable(file)) { if (!showHiddenFiles && FileElement.isFileHidden(file)) return false; return true; } return super.isFileVisible(file, showHiddenFiles); } @Override public boolean isChooseMultiple() { return showFiles; } }; descriptor.setTitle(showFiles ? "Open File or Project" : "Open Project"); VirtualFile userHomeDir = null; if (SystemInfo.isUnix) { userHomeDir = VfsUtil.getUserHomeDir(); } descriptor.putUserData(PathChooserDialog.PREFER_LAST_OVER_EXPLICIT, Boolean.TRUE); FileChooser.chooseFiles(descriptor, project, userHomeDir, new Consumer<List<VirtualFile>>() { @Override public void consume(final List<VirtualFile> files) { for (VirtualFile file : files) { if (!descriptor.isFileSelectable(file)) { // on Mac, it could be selected anyway Messages.showInfoMessage(project, file.getPresentableUrl() + " contains no " + ApplicationNamesInfo.getInstance().getFullProductName() + " project", "Cannot Open Project"); return; } } doOpenFile(project, files); } }); }
From source file:com.intellij.ide.plugins.InstalledPluginsManagerMain.java
License:Apache License
public InstalledPluginsManagerMain(PluginManagerUISettings uiSettings) { super(uiSettings); init();/*from w w w . j a va2s . c o m*/ myActionsPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); final JButton button = new JButton("Browse repositories..."); button.setMnemonic('b'); button.addActionListener(new BrowseRepoListener(null)); myActionsPanel.add(button); final JButton installPluginFromFileSystem = new JButton("Install plugin from disk..."); installPluginFromFileSystem.setMnemonic('d'); installPluginFromFileSystem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, false, true, true, false, false) { @Override public boolean isFileSelectable(VirtualFile file) { return file.getFileType() instanceof ArchiveFileType; } }; descriptor.setTitle("Choose Plugin File"); descriptor.setDescription("JAR and ZIP archives are accepted"); FileChooser.chooseFile(descriptor, null, myActionsPanel, null, new Consumer<VirtualFile>() { @Override public void consume(@NotNull VirtualFile virtualFile) { final File file = VfsUtilCore.virtualToIoFile(virtualFile); try { final IdeaPluginDescriptorImpl pluginDescriptor = PluginDownloader .loadDescriptionFromJar(file); if (pluginDescriptor == null) { Messages.showErrorDialog( "Fail to load plugin descriptor from file " + file.getName(), CommonBundle.getErrorTitle()); return; } if (PluginManagerCore.isIncompatible(pluginDescriptor)) { Messages.showErrorDialog( "Plugin " + pluginDescriptor.getName() + " is incompatible with current installation", CommonBundle.getErrorTitle()); return; } final IdeaPluginDescriptor alreadyInstalledPlugin = PluginManager .getPlugin(pluginDescriptor.getPluginId()); if (alreadyInstalledPlugin != null) { final File oldFile = alreadyInstalledPlugin.getPath(); if (oldFile != null) { StartupActionScriptManager.addActionCommand( new StartupActionScriptManager.DeleteCommand(oldFile)); } } if (((InstalledPluginsTableModel) pluginsModel) .appendOrUpdateDescriptor(pluginDescriptor)) { PluginDownloader.install(file, file.getName(), false); select(pluginDescriptor); checkInstalledPluginDependencies(pluginDescriptor); setRequireShutdown(true); } else { Messages.showInfoMessage(myActionsPanel, "Plugin " + pluginDescriptor.getName() + " was already installed", CommonBundle.getWarningTitle()); } } catch (IOException ex) { Messages.showErrorDialog(ex.getMessage(), CommonBundle.getErrorTitle()); } } }); } }); myActionsPanel.add(installPluginFromFileSystem); final StatusText emptyText = pluginTable.getEmptyText(); emptyText.setText("Nothing to show."); emptyText.appendText(" Click "); emptyText.appendText("Browse", SimpleTextAttributes.LINK_ATTRIBUTES, new BrowseRepoListener(null)); emptyText.appendText(" to search for non-bundled plugins."); }
From source file:com.intellij.ide.startupWizard.StartupWizardAction.java
License:Apache License
public void actionPerformed(final AnActionEvent e) { Project project = e.getData(CommonDataKeys.PROJECT); final StartupWizard startupWizard = new StartupWizard(project, ApplicationInfoImpl.getShadowInstance().getPluginChooserPages()); final String title = ApplicationNamesInfo.getInstance().getFullProductName() + " Plugin Configuration Wizard"; startupWizard.setTitle(title);/*from w ww . j av a 2 s .c om*/ startupWizard.show(); if (startupWizard.getExitCode() == DialogWrapper.OK_EXIT_CODE) { Messages.showInfoMessage(project, "To apply the changes, please restart " + ApplicationNamesInfo.getInstance().getFullProductName(), title); } }
From source file:com.intellij.lang.ant.config.execution.RunCanceledException.java
License:Apache License
public void showMessage(Project project, String title) { Messages.showInfoMessage(project, getMessage(), title); }
From source file:com.intellij.lang.ant.config.explorer.SaveMetaTargetDialog.java
License:Apache License
protected void doOKAction() { final ExecuteCompositeTargetEvent eventObject = createEventObject(); if (myAntConfiguration.getTargetForEvent(eventObject) == null) { myAntConfiguration.setTargetForEvent(myBuildFile, eventObject.getMetaTargetName(), eventObject); super.doOKAction(); } else {/*from ww w . jav a 2 s . c om*/ Messages.showInfoMessage(getContentPane(), AntBundle.message("save.meta.data.such.sequence.of.targets.already.exists.error.message"), getTitle()); } }
From source file:com.intellij.plugins.haxe.runner.debugger.HaxeDebugRunner.java
License:Apache License
private static void showInfoMessage(final Project project, final String message, final String title) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override//from w ww . j a v a2 s.c o m public void run() { Messages.showInfoMessage(project, message, title); } }); }
From source file:com.intellij.refactoring.migration.MigrationProcessor.java
License:Apache License
protected boolean preprocessUsages(Ref<UsageInfo[]> refUsages) { if (refUsages.get().length == 0) { Messages.showInfoMessage(myProject, RefactoringBundle.message("migration.no.usages.found.in.the.project"), REFACTORING_NAME); return false; }//from www . ja v a 2 s . c o m setPreviewUsages(true); return true; }
From source file:com.intellij.refactoring.turnRefsToSuper.TurnRefsToSuperProcessor.java
License:Apache License
protected boolean preprocessUsages(@NotNull Ref<UsageInfo[]> refUsages) { if (!ApplicationManager.getApplication().isUnitTestMode() && refUsages.get().length == 0) { String message = RefactoringBundle.message("no.usages.can.be.replaced", myClass.getQualifiedName(), mySuper.getQualifiedName()); Messages.showInfoMessage(myProject, message, TurnRefsToSuperHandler.REFACTORING_NAME); return false; }//from www . j av a 2 s . c o m return super.preprocessUsages(refUsages); }
From source file:com.intellij.refactoring.util.duplicates.MethodDuplicatesHandler.java
License:Apache License
public static void invokeOnScope(final Project project, final Set<PsiMember> members, final AnalysisScope scope, boolean silent) { final Map<PsiMember, List<Match>> duplicates = new HashMap<PsiMember, List<Match>>(); final int fileCount = scope.getFileCount(); final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); if (progressIndicator != null) { progressIndicator.setIndeterminate(false); }// w w w.ja v a 2 s. c o m final Map<PsiMember, Set<Module>> memberWithModulesMap = new HashMap<PsiMember, Set<Module>>(); for (PsiMember member : members) { final Module module = ModuleUtil.findModuleForPsiElement(member); if (module != null) { final HashSet<Module> dependencies = new HashSet<Module>(); ApplicationManager.getApplication().runReadAction(new Runnable() { public void run() { ModuleUtil.collectModulesDependsOn(module, dependencies); } }); memberWithModulesMap.put(member, dependencies); } } scope.accept(new PsiRecursiveElementVisitor() { private int myFileCount = 0; @Override public void visitFile(final PsiFile file) { if (progressIndicator != null) { if (progressIndicator.isCanceled()) return; progressIndicator.setFraction(((double) myFileCount++) / fileCount); final VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile != null) { progressIndicator.setText2(ProjectUtil.calcRelativeToProjectPath(virtualFile, project)); } } final Module targetModule = ModuleUtil.findModuleForPsiElement(file); if (targetModule == null) return; for (Map.Entry<PsiMember, Set<Module>> entry : memberWithModulesMap.entrySet()) { final Set<Module> dependencies = entry.getValue(); if (dependencies == null || !dependencies.contains(targetModule)) continue; final PsiMember method = entry.getKey(); final List<Match> matchList = hasDuplicates(file, method); for (Iterator<Match> iterator = matchList.iterator(); iterator.hasNext();) { Match match = iterator.next(); final PsiElement matchStart = match.getMatchStart(); final PsiElement matchEnd = match.getMatchEnd(); for (PsiMember psiMember : members) { if (PsiTreeUtil.isAncestor(psiMember, matchStart, false) || PsiTreeUtil.isAncestor(psiMember, matchEnd, false)) { iterator.remove(); break; } } } if (!matchList.isEmpty()) { List<Match> matches = duplicates.get(method); if (matches == null) { matches = new ArrayList<Match>(); duplicates.put(method, matches); } matches.addAll(matchList); } } } }); replaceDuplicate(project, duplicates, members); if (!silent) { final Runnable nothingFoundRunnable = new Runnable() { @Override public void run() { if (duplicates.isEmpty()) { final String message = RefactoringBundle.message( "idea.has.not.found.any.code.that.can.be.replaced.with.method.call", ApplicationNamesInfo.getInstance().getProductName()); Messages.showInfoMessage(project, message, REFACTORING_NAME); } } }; if (ApplicationManager.getApplication().isUnitTestMode()) { nothingFoundRunnable.run(); } else { ApplicationManager.getApplication().invokeLater(nothingFoundRunnable, ModalityState.NON_MODAL); } } }
From source file:com.intellij.tasks.actions.SwitchTaskAction.java
License:Apache License
public static void removeTask(final @Nonnull Project project, LocalTask task, TaskManager manager) { if (task.isDefault()) { Messages.showInfoMessage(project, "Default task cannot be removed", "Cannot Remove"); } else {/*from w w w.j ava2 s . c o m*/ List<ChangeListInfo> infos = task.getChangeLists(); List<LocalChangeList> lists = ContainerUtil.mapNotNull(infos, new NullableFunction<ChangeListInfo, LocalChangeList>() { public LocalChangeList fun(ChangeListInfo changeListInfo) { LocalChangeList changeList = ChangeListManager.getInstance(project) .getChangeList(changeListInfo.id); return changeList != null && !changeList.isDefault() ? changeList : null; } }); boolean removeIt = true; l: for (LocalChangeList list : lists) { if (!list.getChanges().isEmpty()) { int result = Messages.showYesNoCancelDialog(project, "Changelist associated with '" + task.getSummary() + "' is not empty.\n" + "Do you want to remove it and move the changes to the active changelist?", "Changelist Not Empty", Messages.getWarningIcon()); switch (result) { case 0: break l; case 1: removeIt = false; break; default: return; } } } if (removeIt) { for (LocalChangeList list : lists) { ChangeListManager.getInstance(project).removeChangeList(list); } } manager.removeTask(task); } }