com.intellij.openapi.ui.MessageType Java Examples
The following examples show how to use
com.intellij.openapi.ui.MessageType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PopupUtil.java From consulo with Apache License 2.0 | 6 votes |
public static void showBalloonForComponent(@Nonnull Component component, @Nonnull final String message, final MessageType type, final boolean atTop, @Nullable final Disposable disposable) { final JBPopupFactory popupFactory = JBPopupFactory.getInstance(); if (popupFactory == null) return; BalloonBuilder balloonBuilder = popupFactory.createHtmlTextBalloonBuilder(message, type, null); balloonBuilder.setDisposable(disposable == null ? ApplicationManager.getApplication() : disposable); Balloon balloon = balloonBuilder.createBalloon(); Dimension size = component.getSize(); Balloon.Position position; int x; int y; if (size == null) { x = y = 0; position = Balloon.Position.above; } else { x = Math.min(10, size.width / 2); y = size.height; position = Balloon.Position.below; } balloon.show(new RelativePoint(component, new Point(x, y)), position); }
Example #2
Source File: ExternalSystemUiUtil.java From consulo with Apache License 2.0 | 6 votes |
/** * Asks to show balloon that contains information related to the given component. * * @param component component for which we want to show information * @param messageType balloon message type * @param message message to show */ public static void showBalloon(@Nonnull JComponent component, @Nonnull MessageType messageType, @Nonnull String message) { final BalloonBuilder builder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, messageType, null) .setDisposable(ApplicationManager.getApplication()) .setFadeoutTime(BALLOON_FADEOUT_TIME); Balloon balloon = builder.createBalloon(); Dimension size = component.getSize(); Balloon.Position position; int x; int y; if (size == null) { x = y = 0; position = Balloon.Position.above; } else { x = Math.min(10, size.width / 2); y = size.height; position = Balloon.Position.below; } balloon.show(new RelativePoint(component, new Point(x, y)), position); }
Example #3
Source File: QueryToXMLConverter.java From dbunit-extractor with MIT License | 6 votes |
@Nullable private DbDataSource getDataSource(final Editor editor, final List<DbDataSource> dataSources, final String selectedDataSourceName) { DbDataSource dataSource = null; if (StringUtil.isNotEmpty(selectedDataSourceName)) { for (final DbDataSource source : dataSources) { if (source.getName().equals(selectedDataSourceName)) { dataSource = source; break; } } } if (dataSource == null || StringUtil.isEmpty(selectedDataSourceName)) { dataSource = dataSources.get(0); showPopup(editor, MessageType.INFO, "Using first found datasource: " + dataSource.getName() + ". Please change default one in options."); } return dataSource; }
Example #4
Source File: UiUtils.java From Crucible4IDEA with MIT License | 6 votes |
public static void showBalloon(@NotNull final Project project, @NotNull final String message, @NotNull final MessageType messageType) { final JFrame frame = WindowManager.getInstance().getFrame(project.isDefault() ? null : project); if (frame == null) return; final JComponent component = frame.getRootPane(); if (component == null) return; final Rectangle rect = component.getVisibleRect(); final Point p = new Point(rect.x + rect.width - 10, rect.y + 10); final RelativePoint point = new RelativePoint(component, p); final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance(). createHtmlTextBalloonBuilder(message, messageType.getDefaultIcon(), messageType.getPopupBackground(), null); balloonBuilder.setShowCallout(false).setCloseButtonEnabled(true) .createBalloon().show(point, Balloon.Position.atLeft); }
Example #5
Source File: JsonDialog.java From GsonFormat with Apache License 2.0 | 6 votes |
private void onOK() { this.setAlwaysOnTop(false); String jsonSTR = editTP.getText().trim(); if (TextUtils.isEmpty(jsonSTR)) { return; } String generateClassName = generateClassTF.getText().replaceAll(" ", "").replaceAll(".java$", ""); if (TextUtils.isEmpty(generateClassName) || generateClassName.endsWith(".")) { Toast.make(project, generateClassP, MessageType.ERROR, "the path is not allowed"); return; } PsiClass generateClass = null; if (!currentClass.equals(generateClassName)) { generateClass = PsiClassUtil.exist(file, generateClassTF.getText()); } else { generateClass = cls; } new ConvertBridge(this, jsonSTR, file, project, generateClass, cls, generateClassName).run(); }
Example #6
Source File: DiffUtil.java From consulo with Apache License 2.0 | 6 votes |
public static void showSuccessPopup(@Nonnull String message, @Nonnull RelativePoint point, @Nonnull Disposable disposable, @Nullable Runnable hyperlinkHandler) { HyperlinkListener listener = null; if (hyperlinkHandler != null) { listener = new HyperlinkAdapter() { @Override protected void hyperlinkActivated(HyperlinkEvent e) { hyperlinkHandler.run(); } }; } Color bgColor = MessageType.INFO.getPopupBackground(); Balloon balloon = JBPopupFactory.getInstance() .createHtmlTextBalloonBuilder(message, null, bgColor, listener) .setAnimationCycle(200) .createBalloon(); balloon.show(point, Balloon.Position.below); Disposer.register(disposable, balloon); }
Example #7
Source File: TestsUIUtil.java From consulo with Apache License 2.0 | 6 votes |
public static void notifyByBalloon(@Nonnull final Project project, final AbstractTestProxy root, final TestConsoleProperties properties, TestResultPresentation testResultPresentation) { if (project.isDisposed()) return; if (properties == null) return; TestStatusListener.notifySuiteFinished(root, properties.getProject()); final String testRunDebugId = properties.isDebug() ? ToolWindowId.DEBUG : ToolWindowId.RUN; final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project); final String title = testResultPresentation.getTitle(); final String text = testResultPresentation.getText(); final String balloonText = testResultPresentation.getBalloonText(); final MessageType type = testResultPresentation.getType(); if (!Comparing.strEqual(toolWindowManager.getActiveToolWindowId(), testRunDebugId)) { toolWindowManager.notifyByBalloon(testRunDebugId, type, balloonText, null, null); } NOTIFICATION_GROUP.createNotification(balloonText, type).notify(project); SystemNotifications.getInstance().notify("TestRunner", title, text); }
Example #8
Source File: RoboVmPlugin.java From robovm-idea with GNU General Public License v2.0 | 6 votes |
public static void logBalloon(final Project project, final MessageType messageType, final String message) { UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { if (project != null) { // this may throw an exception, see #88. It appears to be a timing // issue try { ToolWindowManager.getInstance(project).notifyByBalloon(ROBOVM_TOOLWINDOW_ID, MessageType.ERROR, message); } catch (Throwable t) { logError(project, message, t); } } } }); }
Example #9
Source File: VcsBalloonProblemNotifier.java From consulo with Apache License 2.0 | 6 votes |
private static void show(final Project project, final String message, final MessageType type, final boolean showOverChangesView, @Nullable final NamedRunnable[] notificationListener) { final Application application = ApplicationManager.getApplication(); if (application.isHeadlessEnvironment()) return; final Runnable showErrorAction = new Runnable() { public void run() { new VcsBalloonProblemNotifier(project, message, type, showOverChangesView, notificationListener).run(); } }; if (application.isDispatchThread()) { showErrorAction.run(); } else { application.invokeLater(showErrorAction); } }
Example #10
Source File: JsonDialog.java From GsonFormat with Apache License 2.0 | 6 votes |
@Override public void showError(ConvertBridge.Error err) { switch (err) { case DATA_ERROR: errorLB.setText("data err !!"); if (Config.getInstant().isToastError()) { Toast.make(project, errorLB, MessageType.ERROR, "click to see details"); } break; case PARSE_ERROR: errorLB.setText("parse err !!"); if (Config.getInstant().isToastError()) { Toast.make(project, errorLB, MessageType.ERROR, "click to see details"); } break; case PATH_ERROR: Toast.make(project, generateClassP, MessageType.ERROR, "the path is not allowed"); break; } }
Example #11
Source File: MoveChangesToAnotherListAction.java From consulo with Apache License 2.0 | 6 votes |
public void actionPerformed(@Nonnull AnActionEvent e) { Project project = e.getRequiredData(CommonDataKeys.PROJECT); List<Change> changesList = ContainerUtil.newArrayList(); Change[] changes = e.getData(VcsDataKeys.CHANGES); if (changes != null) { ContainerUtil.addAll(changesList, changes); } List<VirtualFile> unversionedFiles = ContainerUtil.newArrayList(); final List<VirtualFile> changedFiles = ContainerUtil.newArrayList(); VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY); if (files != null) { changesList.addAll(getChangesForSelectedFiles(project, files, unversionedFiles, changedFiles)); } if (changesList.isEmpty() && unversionedFiles.isEmpty()) { VcsBalloonProblemNotifier.showOverChangesView(project, "Nothing is selected that can be moved", MessageType.INFO); return; } if (!askAndMove(project, changesList, unversionedFiles)) return; if (!changedFiles.isEmpty()) { selectAndShowFile(project, changedFiles.get(0)); } }
Example #12
Source File: QueryPanel.java From nosql4idea with Apache License 2.0 | 6 votes |
void notifyOnErrorForOperator(JComponent component, Exception ex) { String message; if (ex instanceof JSONParseException) { message = StringUtils.removeStart(ex.getMessage(), "\n"); } else { message = String.format("%s: %s", ex.getClass().getSimpleName(), ex.getMessage()); } NonOpaquePanel nonOpaquePanel = new NonOpaquePanel(); JTextPane textPane = Messages.configureMessagePaneUi(new JTextPane(), message); textPane.setFont(COURIER_FONT); textPane.setBackground(MessageType.ERROR.getPopupBackground()); nonOpaquePanel.add(textPane, BorderLayout.CENTER); nonOpaquePanel.add(new JLabel(MessageType.ERROR.getDefaultIcon()), BorderLayout.WEST); JBPopupFactory.getInstance().createBalloonBuilder(nonOpaquePanel) .setFillColor(MessageType.ERROR.getPopupBackground()) .createBalloon() .show(new RelativePoint(component, new Point(0, 0)), Balloon.Position.above); }
Example #13
Source File: CommittedChangesCache.java From consulo with Apache License 2.0 | 6 votes |
public void commitMessageChanged(final AbstractVcs vcs, final RepositoryLocation location, final long number, final String newMessage) { myTaskQueue.run(new Runnable() { @Override public void run() { final ChangesCacheFile file = myCachesHolder.haveCache(location); if (file != null) { try { if (file.isEmpty()) return; file.editChangelist(number, newMessage); loadIncomingChanges(true); fireChangesLoaded(location, Collections.<CommittedChangeList>emptyList()); } catch (IOException e) { VcsBalloonProblemNotifier.showOverChangesView(myProject, "Didn't update Repository changes with new message due to error: " + e.getMessage(), MessageType.ERROR); } } } }); }
Example #14
Source File: TreeWillListener.java From leetcode-editor with Apache License 2.0 | 6 votes |
@Override public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { TreePath selPath = event.getPath(); DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath.getLastPathComponent(); Question question = (Question) node.getUserObject(); if (!isOneOpen(node)) { return; } else if ("lock".equals(question.getStatus())) { MessageUtils.showMsg(toolWindow.getContentManager().getComponent(), MessageType.INFO, "info", "no permissions"); throw new ExpandVetoException(event); } ProgressManager.getInstance().run(new Task.Backgroundable(project,"leetcode.editor.tree",false) { @Override public void run(@NotNull ProgressIndicator progressIndicator) { loadData(question,node,selPath,tree,toolWindow); } }); throw new ExpandVetoException(event); }
Example #15
Source File: DataWriter.java From GsonFormat with Apache License 2.0 | 6 votes |
public void execute(ClassEntity targetClass) { this.targetClass = targetClass; ProgressManager.getInstance().run(new Task.Backgroundable(project, "GsonFormat") { @Override public void run(@NotNull ProgressIndicator progressIndicator) { progressIndicator.setIndeterminate(true); long currentTimeMillis = System.currentTimeMillis(); execute(); progressIndicator.setIndeterminate(false); progressIndicator.setFraction(1.0); StringBuffer sb = new StringBuffer(); sb.append("GsonFormat [" + (System.currentTimeMillis() - currentTimeMillis) + " ms]\n"); // sb.append("generate class : ( "+generateClassList.size()+" )\n"); // for (String item: generateClassList) { // sb.append(" at "+item+"\n"); // } // sb.append(" \n"); // NotificationCenter.info(sb.toString()); Toast.make(project, MessageType.INFO, sb.toString()); } }); }
Example #16
Source File: ConfigurationErrorsComponent.java From consulo with Apache License 2.0 | 5 votes |
@Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { final ConfigurationError error = (ConfigurationError)value; myList = list; myFixGroup.setVisible(error.canBeFixed()); myText.setText(error.getDescription()); setBackground(error.isIgnored() ? MessageType.WARNING.getPopupBackground() : MessageType.ERROR.getPopupBackground()); return this; }
Example #17
Source File: GeneralCodeStylePanel.java From consulo with Apache License 2.0 | 5 votes |
private static void showError(final JTextField field, final String message) { BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, MessageType.ERROR, null); balloonBuilder.setFadeoutTime(1500); final Balloon balloon = balloonBuilder.createBalloon(); final Rectangle rect = field.getBounds(); final Point p = new Point(0, rect.height); final RelativePoint point = new RelativePoint(field, p); balloon.show(point, Balloon.Position.below); Disposer.register(ProjectManager.getInstance().getDefaultProject(), balloon); }
Example #18
Source File: PopupUtil.java From consulo with Apache License 2.0 | 5 votes |
public static void showBalloonForActiveComponent(@Nonnull final String message, final MessageType type) { Runnable runnable = new Runnable() { public void run() { Window[] windows = Window.getWindows(); Window targetWindow = null; for (Window each : windows) { if (each.isActive()) { targetWindow = each; break; } } if (targetWindow == null) { targetWindow = JOptionPane.getRootFrame(); } if (targetWindow == null) { final IdeFrame frame = IdeFocusManager.findInstance().getLastFocusedFrame(); if (frame == null) { final Project[] projects = ProjectManager.getInstance().getOpenProjects(); final Project project = projects == null || projects.length == 0 ? ProjectManager.getInstance().getDefaultProject() : projects[0]; final JFrame jFrame = WindowManager.getInstance().getFrame(project); if (jFrame != null) { showBalloonForComponent(jFrame, message, type, true, project); } else { LOG.info("Can not get component to show message: " + message); } return; } showBalloonForComponent(frame.getComponent(), message, type, true, frame.getProject()); } else { showBalloonForComponent(targetWindow, message, type, true, null); } } }; UIUtil.invokeLaterIfNeeded(runnable); }
Example #19
Source File: VcsLogUiImpl.java From consulo with Apache License 2.0 | 5 votes |
private void commitNotFound(@Nonnull String commitHash) { if (myMainFrame.getFilterUi().getFilters().isEmpty()) { showMessage(MessageType.WARNING, "Commit " + commitHash + " not found"); } else { showMessage(MessageType.WARNING, "Commit " + commitHash + " doesn't exist or doesn't match the active filters"); } }
Example #20
Source File: ExportTestResultsAction.java From consulo with Apache License 2.0 | 5 votes |
private void showBalloon(final Project project, final MessageType type, final String text, @Nullable final HyperlinkListener listener) { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { if (project.isDisposed()) return; if (ToolWindowManager.getInstance(project).getToolWindow(myToolWindowId) != null) { ToolWindowManager.getInstance(project).notifyByBalloon(myToolWindowId, type, text, null, listener); } } }); }
Example #21
Source File: Mock.java From consulo with Apache License 2.0 | 5 votes |
@Override public void notifyByBalloon(@Nonnull final String toolWindowId, @Nonnull final MessageType type, @Nonnull final String text, @Nullable final Image icon, @Nullable final HyperlinkListener listener) { }
Example #22
Source File: ToolWindowManager.java From consulo with Apache License 2.0 | 5 votes |
@Deprecated public void notifyByBalloon(@Nonnull final String toolWindowId, @Nonnull final MessageType type, @Nonnull final String htmlBody, @Nullable final Image icon, @Nullable javax.swing.event.HyperlinkListener listener) { throw new AbstractMethodError("AWT & Swing dependency"); }
Example #23
Source File: SearchForUsagesRunnable.java From consulo with Apache License 2.0 | 5 votes |
private static void notifyByFindBalloon(@javax.annotation.Nullable final HyperlinkListener listener, @Nonnull final MessageType info, @Nonnull FindUsagesProcessPresentation processPresentation, @Nonnull final Project project, @Nonnull final List<String> lines) { com.intellij.usageView.UsageViewManager.getInstance(project); // in case tool window not registered final Collection<VirtualFile> largeFiles = processPresentation.getLargeFiles(); List<String> resultLines = new ArrayList<>(lines); HyperlinkListener resultListener = listener; if (!largeFiles.isEmpty()) { String shortMessage = "(<a href='" + LARGE_FILES_HREF_TARGET + "'>" + UsageViewBundle.message("large.files.were.ignored", largeFiles.size()) + "</a>)"; resultLines.add(shortMessage); resultListener = addHrefHandling(resultListener, LARGE_FILES_HREF_TARGET, () -> { String detailedMessage = detailedLargeFilesMessage(largeFiles); List<String> strings = new ArrayList<>(lines); strings.add(detailedMessage); //noinspection SSBasedInspection ToolWindowManager.getInstance(project).notifyByBalloon(ToolWindowId.FIND, info, wrapInHtml(strings), AllIcons.Actions.Find, listener); }); } Runnable searchIncludingProjectFileUsages = processPresentation.searchIncludingProjectFileUsages(); if (searchIncludingProjectFileUsages != null) { resultLines .add("Occurrences in project configuration files are skipped. " + "<a href='" + SHOW_PROJECT_FILE_OCCURRENCES_HREF_TARGET + "'>Include them</a>"); resultListener = addHrefHandling(resultListener, SHOW_PROJECT_FILE_OCCURRENCES_HREF_TARGET, searchIncludingProjectFileUsages); } //noinspection SSBasedInspection ToolWindowManager.getInstance(project).notifyByBalloon(ToolWindowId.FIND, info, wrapInHtml(resultLines), AllIcons.Actions.Find, resultListener); }
Example #24
Source File: TestWindowManager.java From consulo with Apache License 2.0 | 5 votes |
@Override public BalloonHandler notifyProgressByBalloon(@Nonnull MessageType type, @Nonnull String htmlBody, @Nullable Icon icon, @Nullable HyperlinkListener listener) { return new BalloonHandler() { public void hide() { } }; }
Example #25
Source File: TestsUIUtil.java From consulo with Apache License 2.0 | 5 votes |
public TestResultPresentation getPresentation(int failedCount, int passedCount, int notStartedCount, int ignoredCount) { if (myRoot == null) { myBalloonText = myTitle = myStarted ? "Tests were interrupted" : ExecutionBundle.message("test.not.started.progress.text"); myText = ""; myType = MessageType.WARNING; } else { if (failedCount > 0) { myTitle = ExecutionBundle.message("junit.runing.info.tests.failed.label"); myText = passedCount + " passed, " + failedCount + " failed" + (notStartedCount > 0 ? ", " + notStartedCount + " not started" : ""); myType = MessageType.ERROR; } else if (notStartedCount > 0) { myTitle = ignoredCount > 0 ? "Tests Ignored" : ExecutionBundle.message("junit.running.info.failed.to.start.error.message"); myText = passedCount + " passed, " + notStartedCount + (ignoredCount > 0 ? " ignored" : " not started"); myType = ignoredCount == 0 ? MessageType.WARNING : MessageType.ERROR; } else { myTitle = ExecutionBundle.message("junit.runing.info.tests.passed.label"); myText = passedCount + " passed"; myType = MessageType.INFO; } if (myComment != null) { myText += " " + myComment; } myBalloonText = myTitle + ": " + myText; } return this; }
Example #26
Source File: CrucibleManager.java From Crucible4IDEA with MIT License | 5 votes |
public void completeReview(String reviewId) { try { final CrucibleSession session = getSession(); if (session != null) { session.completeReview(reviewId); } } catch (CrucibleApiException e) { LOG.warn(e.getMessage()); UiUtils.showBalloon(myProject, CrucibleBundle.message("crucible.connection.error.message.$0", e.getMessage()), MessageType.ERROR); } }
Example #27
Source File: CrucibleManager.java From Crucible4IDEA with MIT License | 5 votes |
@Nullable public Comment postComment(@NotNull final Comment comment, boolean isGeneral, String reviewId) { try { final CrucibleSession session = getSession(); if (session != null) { return session.postComment(comment, isGeneral, reviewId); } } catch (CrucibleApiException e) { LOG.warn(e.getMessage()); UiUtils.showBalloon(myProject, CrucibleBundle.message("crucible.connection.error.message.$0", e.getMessage()), MessageType.ERROR); } return null; }
Example #28
Source File: RunPhpMetricsAction.java From PhpMetrics-jetbrains with MIT License | 5 votes |
private void inform(AnActionEvent e, String text, MessageType messageType) { StatusBar statusBar = WindowManager.getInstance() .getStatusBar(PlatformDataKeys.PROJECT.getData(e.getDataContext())); JBPopupFactory.getInstance() .createHtmlTextBalloonBuilder(text, messageType, null) .setFadeoutTime(7500) .createBalloon() .show(RelativePoint.getCenterOf(statusBar.getComponent()), Balloon.Position.atRight); }
Example #29
Source File: SettingsForm.java From PhpMetrics-jetbrains with MIT License | 5 votes |
private void inform(JComponent target, String text, MessageType messageType) { JBPopupFactory.getInstance() .createHtmlTextBalloonBuilder(text, messageType, null) .setFadeoutTime(2000) .createBalloon() .show(RelativePoint.getNorthEastOf(target), Balloon.Position.atRight); }
Example #30
Source File: LombokProjectValidatorActivity.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void enableAnnotations(Project project) { getCompilerConfiguration(project).getDefaultProcessorProfile().setEnabled(true); StatusBar statusBar = WindowManager.getInstance().getStatusBar(project); JBPopupFactory.getInstance() .createHtmlTextBalloonBuilder( "Java annotation processing has been enabled", MessageType.INFO, null ) .setFadeoutTime(3000) .createBalloon() .show(RelativePoint.getNorthEastOf(statusBar.getComponent()), Balloon.Position.atRight); }