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:liveplugin.toolwindow.addplugin.git.GitCloneDialog.java
License:Apache License
private void test() { myTestURL = getCurrentUrlText();/* w w w .j av a 2 s. c o m*/ boolean testResult = test(myTestURL); if (testResult) { Messages.showInfoMessage(myTestButton, DvcsBundle.message("clone.test.success.message", myTestURL), DvcsBundle.getString("clone.test.connection.title")); myTestResult = Boolean.TRUE; } else { myTestResult = Boolean.FALSE; } updateButtons(); }
From source file:net.andydvorak.intellij.lessc.ui.configurable.LessCompileAction.java
License:Apache License
public void actionPerformed(AnActionEvent _e) { final AnActionEventWrapper e = new AnActionEventWrapper(_e); final Collection<VirtualFile> files = e.getLessFiles(); final LessManager lessManager = LessManager.getInstance(e.getProject()); int numMissing = 0; for (VirtualFile file : files) { final VirtualFileEvent virtualFileEvent = new VirtualFileEvent(this, file, file.getName(), file.getParent());/*from ww w . ja v a 2 s .com*/ final LessProfile lessProfile = lessManager.getLessProfile(virtualFileEvent); if (lessProfile != null && lessProfile.hasCssDirectories()) { lessManager.handleChangeEvent(virtualFileEvent); } else { numMissing++; } } if (numMissing > 0) { final String title, message; if (numMissing == 1) { title = UIBundle.message("action.missing.css.dir.single.title"); message = UIBundle.message("action.missing.css.dir.single.message"); } else { title = UIBundle.message("action.missing.css.dir.multiple.title"); message = UIBundle.message("action.missing.css.dir.multiple.message", numMissing, files.size()); } Messages.showInfoMessage(e.getProject(), UIBundle.message("action.missing.css.dir.add.message", message), title); } }
From source file:org.coding.git.util.CodingNetNotifications.java
License:Apache License
public static void showInfoDialog(@Nullable Project project, @NotNull String title, @NotNull String message) { LOG.info(title + "; " + message); Messages.showInfoMessage(project, message, title); }
From source file:org.coding.git.util.CodingNetNotifications.java
License:Apache License
public static void showInfoDialog(@NotNull Component component, @NotNull String title, @NotNull String message) { LOG.info(title + "; " + message); Messages.showInfoMessage(component, message, title); }
From source file:org.codinjutsu.tools.nosql.commons.view.ServerConfigurationPanel.java
License:Apache License
private void initListeners() { testConnectionButton.addActionListener(new ActionListener() { @Override/* w w w. ja va 2s. c o m*/ public void actionPerformed(ActionEvent actionEvent) { final Ref<Exception> excRef = new Ref<>(); final ProgressManager progressManager = ProgressManager.getInstance(); progressManager.runProcessWithProgressSynchronously(new Runnable() { @Override public void run() { ServerConfiguration configuration = createServerConfigurationForTesting(); final ProgressIndicator progressIndicator = progressManager.getProgressIndicator(); if (progressIndicator != null) { progressIndicator.setText("Connecting to " + configuration.getServerUrl()); } try { databaseClient.connect(configuration); } catch (Exception ex) { excRef.set(ex); } } }, "Testing connection for " + databaseVendor.name, true, ServerConfigurationPanel.this.project); if (!excRef.isNull()) { Messages.showErrorDialog(rootPanel, excRef.get().getMessage(), "Connection test failed"); } else { Messages.showInfoMessage(rootPanel, "Connection test successful for " + databaseVendor.name, "Connection test successful"); } } }); }
From source file:org.community.intellij.plugins.communitycase.actions.RebaseActionBase.java
License:Apache License
/** * {@inheritDoc}/*from ww w . j a v a2 s . c o m*/ */ protected void perform(@NotNull final Project project, @NotNull final List<VirtualFile> Roots, @NotNull final VirtualFile defaultRoot, final Set<VirtualFile> affectedRoots, final List<VcsException> exceptions) throws VcsException { LineHandler h = createHandler(project, Roots, defaultRoot); if (h == null) { return; } final VirtualFile root = h.workingDirectoryFile(); RebaseEditorService service = RebaseEditorService.getInstance(); InteractiveRebaseEditorHandler editor = new InteractiveRebaseEditorHandler(service, project, root, h); RebaseLineListener resultListener = new RebaseLineListener(); h.addLineListener(resultListener); configureEditor(editor); affectedRoots.add(root); try { service.configureHandler(h, editor.getHandlerNo()); HandlerUtil.doSynchronously(h, Bundle.getString("rebasing.title"), h.printableCommandLine()); } finally { editor.close(); final RebaseLineListener.Result result = resultListener.getResult(); String messageId; boolean isError = true; switch (result.status) { case CONFLICT: messageId = "rebase.result.conflict"; break; case ERROR: messageId = "rebase.result.error"; break; case CANCELLED: isError = false; messageId = "rebase.result.cancelled"; // we do not need to show a message if editing was cancelled. exceptions.clear(); break; case EDIT: isError = false; messageId = "rebase.result.amend"; break; case FINISHED: default: messageId = null; } if (messageId != null) { String message = Bundle.message(messageId, result.current, result.total); String title = Bundle.message(messageId + ".title"); if (isError) { Messages.showErrorDialog(project, message, title); } else { Messages.showInfoMessage(project, message, title); } } } }
From source file:org.community.intellij.plugins.communitycase.checkout.CloneDialog.java
License:Apache License
/** * Init components/*from w ww . j av a 2s .com*/ */ private void initListeners() { FileChooserDescriptor fcd = new FileChooserDescriptor(false, true, false, false, false, false); fcd.setShowFileSystemRoots(true); fcd.setTitle(Bundle.getString("clone.destination.directory.title")); fcd.setDescription(Bundle.getString("clone.destination.directory.description")); fcd.setHideIgnored(false); myParentDirectory.addActionListener(new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>( fcd.getTitle(), fcd.getDescription(), myParentDirectory, myProject, fcd, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) { @Override protected VirtualFile getInitialFile() { // suggest project base directory only if nothing is typed in the component. String text = getComponentText(); if (text.length() == 0) { VirtualFile file = myProject.getBaseDir(); if (file != null) { return file; } } return super.getInitialFile(); } }); final DocumentListener updateOkButtonListener = new DocumentListener() { // update Ok button state depending on the current state of the fields public void insertUpdate(final DocumentEvent e) { updateOkButton(); } public void removeUpdate(final DocumentEvent e) { updateOkButton(); } public void changedUpdate(final DocumentEvent e) { updateOkButton(); } }; myParentDirectory.getChildComponent().getDocument().addDocumentListener(updateOkButtonListener); myDirectoryName.getDocument().addDocumentListener(updateOkButtonListener); myOriginName.getDocument().addDocumentListener(updateOkButtonListener); myRepositoryURL.getDocument().addDocumentListener(new DocumentListener() { // enable test button only if something is entered in repository URL public void insertUpdate(final DocumentEvent e) { changed(); } public void removeUpdate(final DocumentEvent e) { changed(); } public void changedUpdate(final DocumentEvent e) { changed(); } private void changed() { final String url = myRepositoryURL.getText(); myTestButton.setEnabled(url.length() != 0); if (myDefaultDirectoryName.equals(myDirectoryName.getText()) || myDirectoryName.getText().length() == 0) { // modify field if it was unmodified or blank myDefaultDirectoryName = defaultDirectoryName(url); myDirectoryName.setText(myDefaultDirectoryName); } updateOkButton(); } }); myTestButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { myTestURL = myRepositoryURL.getText(); String output = HandlerUtil.doSynchronously(checkRepository(myProject, myTestURL), Bundle.message("clone.testing", myTestURL), "connection test"); if (output != null) { Messages.showInfoMessage(myTestButton, Bundle.message("clone.test.success.message", myTestURL), Bundle.getString("clone.test.success")); myTestResult = Boolean.TRUE; } else { myTestResult = Boolean.FALSE; } updateOkButton(); } }); setOKActionEnabled(false); }
From source file:org.community.intellij.plugins.communitycase.vfs.RootTracker.java
License:Apache License
/** * Fix mapped roots/*from w w w. j a va 2s . c o m*/ * * @return true if roots now in the correct state */ boolean fixRoots() { final List<VcsDirectoryMapping> vcsDirectoryMappings = new ArrayList<VcsDirectoryMapping>( myVcsManager.getDirectoryMappings()); final HashSet<String> mapped = new HashSet<String>(); final HashSet<String> removed = new HashSet<String>(); final HashSet<String> added = new HashSet<String>(); final VirtualFile baseDir = myProject.getBaseDir(); ApplicationManager.getApplication().runReadAction(new Runnable() { public void run() { for (Iterator<VcsDirectoryMapping> i = vcsDirectoryMappings.iterator(); i.hasNext();) { VcsDirectoryMapping m = i.next(); String vcsName = myVcs.getName(); if (!vcsName.equals(m.getVcs())) { continue; } String path = m.getDirectory(); if (path.length() == 0 && baseDir != null) { path = baseDir.getPath(); } VirtualFile file = lookupFile(path); if (file != null && !mapped.add(file.getPath())) { // eliminate duplicates i.remove(); continue; } final VirtualFile actual = Util.rootOrNull(file); if (file == null || actual == null) { removed.add(path); } else if (actual != file) { removed.add(path); added.add(actual.getPath()); } } for (String m : mapped) { VirtualFile file = lookupFile(m); if (file == null) { continue; } addSubroots(file, added, mapped); if (removed.contains(m)) { continue; } VirtualFile root = Util.rootOrNull(file); assert root != null; for (String o : mapped) { // the mapped collection is not modified here, so order is being kept if (o.equals(m) || removed.contains(o)) { continue; } if (o.startsWith(m)) { VirtualFile otherFile = lookupFile(m); assert otherFile != null; VirtualFile otherRoot = Util.rootOrNull(otherFile); assert otherRoot != null; if (otherRoot == root) { removed.add(o); } else if (otherFile != otherRoot) { added.add(otherRoot.getPath()); removed.add(o); } } } } } }); if (added.isEmpty() && removed.isEmpty()) { Messages.showInfoMessage(myProject, Bundle.message("fix.roots.valid.message"), Bundle.message("fix.roots.valid.title")); return true; } FixRootsDialog d = new FixRootsDialog(myProject, mapped, added, removed); d.show(); if (!d.isOK()) { return false; } for (Iterator<VcsDirectoryMapping> i = vcsDirectoryMappings.iterator(); i.hasNext();) { VcsDirectoryMapping m = i.next(); String path = m.getDirectory(); if (removed.contains(path) || (path.length() == 0 && baseDir != null && removed.contains(baseDir.getPath()))) { i.remove(); } } for (String a : added) { vcsDirectoryMappings.add(new VcsDirectoryMapping(a, myVcs.getName())); } myVcsManager.setDirectoryMappings(vcsDirectoryMappings); myVcsManager.updateActiveVcss(); return true; }
From source file:org.intellij.plugins.intelliLang.InjectionsSettingsUI.java
License:Apache License
private void doImportAction(final DataContext dataContext) { final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, true, false, true, false) { @Override//w w w . j a va 2 s .c om public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { return super.isFileVisible(file, showHiddenFiles) && (file.isDirectory() || "xml".equals(file.getExtension()) || file.getFileType() instanceof ArchiveFileType); } @Override public boolean isFileSelectable(VirtualFile file) { return "xml".equalsIgnoreCase(file.getExtension()); } }; descriptor .setDescription("Please select the configuration file (usually named IntelliLang.xml) to import."); descriptor.setTitle("Import Configuration"); descriptor.putUserData(LangDataKeys.MODULE_CONTEXT, LangDataKeys.MODULE.getData(dataContext)); final SplitterProportionsData splitterData = new SplitterProportionsDataImpl(); splitterData.externalizeFromDimensionService("IntelliLang.ImportSettingsKey.SplitterProportions"); final VirtualFile file = FileChooser.chooseFile(descriptor, myProject, null); if (file == null) { return; } try { final Configuration cfg = Configuration.load(file.getInputStream()); if (cfg == null) { Messages.showWarningDialog(myProject, "The selected file does not contain any importable configuration.", "Nothing to Import"); return; } final CfgInfo info = getDefaultCfgInfo(); final Map<String, Set<InjInfo>> currentMap = ContainerUtil.classify(info.injectionInfos.iterator(), new Convertor<InjInfo, String>() { @Override public String convert(final InjInfo o) { return o.injection.getSupportId(); } }); final List<BaseInjection> originalInjections = new ArrayList<BaseInjection>(); final List<BaseInjection> newInjections = new ArrayList<BaseInjection>(); //// remove duplicates //for (String supportId : InjectorUtils.getActiveInjectionSupportIds()) { // final Set<BaseInjection> currentInjections = currentMap.get(supportId); // if (currentInjections == null) continue; // for (BaseInjection injection : currentInjections) { // Configuration.importInjections(newInjections, Collections.singleton(injection), originalInjections, newInjections); // } //} //myInjections.clear(); //myInjections.addAll(newInjections); for (String supportId : InjectorUtils.getActiveInjectionSupportIds()) { ArrayList<InjInfo> list = new ArrayList<InjInfo>( ObjectUtils.notNull(currentMap.get(supportId), Collections.<InjInfo>emptyList())); final List<BaseInjection> currentInjections = getInjectionList(list); final List<BaseInjection> importingInjections = cfg.getInjections(supportId); if (currentInjections == null) { newInjections.addAll(importingInjections); } else { Configuration.importInjections(currentInjections, importingInjections, originalInjections, newInjections); } } info.replace(originalInjections, newInjections); myInjectionsTable.getListTableModel().setItems(getInjInfoList(myInfos)); final int n = newInjections.size(); if (n > 1) { Messages.showInfoMessage(myProject, n + " entries have been successfully imported", "Import Successful"); } else if (n == 1) { Messages.showInfoMessage(myProject, "One entry has been successfully imported", "Import Successful"); } else { Messages.showInfoMessage(myProject, "No new entries have been imported", "Import"); } } catch (Exception ex) { Configuration.LOG.error(ex); final String msg = ex.getLocalizedMessage(); Messages.showErrorDialog(myProject, msg != null && msg.length() > 0 ? msg : ex.toString(), "Import Failed"); } }
From source file:org.intellij.plugins.xpathView.XPathEvalAction.java
License:Apache License
private boolean evaluateExpression(EvalExpressionDialog.Context context, XmlElement contextNode, Editor editor, Config cfg) {//w w w . jav a 2 s . co m final Project project = editor.getProject(); try { final XPathSupport support = XPathSupport.getInstance(); final XPath xpath = support.createXPath((XmlFile) contextNode.getContainingFile(), context.input.expression, context.input.namespaces); xpath.setVariableContext(new CachedVariableContext(context.input.variables, xpath, contextNode)); // evaluate the expression on the whole document final Object result = xpath.evaluate(contextNode); LOG.debug("result = " + result); LOG.assertTrue(result != null, "null result?"); if (result instanceof List<?>) { final List<?> list = (List<?>) result; if (!list.isEmpty()) { if (cfg.HIGHLIGHT_RESULTS) { highlightResult(contextNode, editor, list); } if (cfg.SHOW_USAGE_VIEW) { showUsageView(editor, xpath, contextNode, list); } if (!cfg.SHOW_USAGE_VIEW && !cfg.HIGHLIGHT_RESULTS) { final String s = StringUtil.pluralize("match", list.size()); Messages.showInfoMessage(project, "Expression produced " + list.size() + " " + s, "XPath Result"); } } else { return Messages.showOkCancelDialog(project, "Sorry, your expression did not return any result", "XPath Result", "OK", "Edit Expression", Messages.getInformationIcon()) == 1; } } else if (result instanceof String) { Messages.showMessageDialog("'" + result.toString() + "'", "XPath result (String)", Messages.getInformationIcon()); } else if (result instanceof Number) { Messages.showMessageDialog(result.toString(), "XPath result (Number)", Messages.getInformationIcon()); } else if (result instanceof Boolean) { Messages.showMessageDialog(result.toString(), "XPath result (Boolean)", Messages.getInformationIcon()); } else { LOG.error("Unknown XPath result: " + result); } } catch (XPathSyntaxException e) { LOG.debug(e); // TODO: Better layout of the error message with non-fixed size fonts return Messages.showOkCancelDialog(project, e.getMultilineMessage(), "XPath syntax error", "Edit Expression", "Cancel", Messages.getErrorIcon()) == 0; } catch (SAXPathException e) { LOG.debug(e); Messages.showMessageDialog(project, e.getMessage(), "XPath error", Messages.getErrorIcon()); } return false; }