List of usage examples for com.intellij.openapi.ui MessageType WARNING
MessageType WARNING
To view the source code for com.intellij.openapi.ui MessageType WARNING.
Click Source Link
From source file:com.android.tools.idea.npw.importing.ModuleListModel.java
License:Apache License
@Nullable public MessageType getStatusSeverity(ModuleToImport module) { ModuleValidationState state = getModuleState(module); switch (state) { case OK://from w w w .ja v a 2s . c om case NULL: return null; case NOT_FOUND: case DUPLICATE_MODULE_NAME: case INVALID_NAME: return MessageType.ERROR; case ALREADY_EXISTS: return getSelectedModules().contains(module) ? MessageType.ERROR : MessageType.WARNING; case REQUIRED: return MessageType.INFO; } throw new IllegalArgumentException(state.name()); }
From source file:com.android.tools.idea.npw.ModulesListModelTest.java
License:Apache License
public void testModuleExistsSeverity() { ModuleToImport existing = new ModuleToImport(EXISTING_MODULE, myModule2.location, NO_DEPS); setModules(existing, myModule1);/*w w w. jav a 2 s. c o m*/ assertEquals(MessageType.WARNING, myModel.getStatusSeverity(existing)); myModel.setSelected(existing, true); assertEquals(MessageType.ERROR, myModel.getStatusSeverity(existing)); }
From source file:com.intellij.codeInsight.completion.CompletionProgressIndicator.java
License:Apache License
void duringCompletion(CompletionInitializationContext initContext) { if (isAutopopupCompletion()) { if (shouldPreselectFirstSuggestion(myParameters)) { if (!CodeInsightSettings.getInstance().SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS) { myLookup.setFocusDegree(LookupImpl.FocusDegree.SEMI_FOCUSED); if (FeatureUsageTracker.getInstance().isToBeAdvertisedInLookup( CodeCompletionFeatures.EDITING_COMPLETION_FINISH_BY_CONTROL_DOT, getProject())) { String dotShortcut = CompletionContributor .getActionShortcut(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM_DOT); if (StringUtil.isNotEmpty(dotShortcut)) { addAdvertisement("Press " + dotShortcut + " to choose the selected (or first) suggestion and insert a dot afterwards", null);//from w w w .j a va 2 s. c om } } } else { myLookup.setFocusDegree(LookupImpl.FocusDegree.FOCUSED); } } if (!myEditor.isOneLineMode() && FeatureUsageTracker.getInstance().isToBeAdvertisedInLookup( CodeCompletionFeatures.EDITING_COMPLETION_CONTROL_ARROWS, getProject())) { String downShortcut = CompletionContributor.getActionShortcut(IdeActions.ACTION_LOOKUP_DOWN); String upShortcut = CompletionContributor.getActionShortcut(IdeActions.ACTION_LOOKUP_UP); if (StringUtil.isNotEmpty(downShortcut) && StringUtil.isNotEmpty(upShortcut)) { addAdvertisement( downShortcut + " and " + upShortcut + " will move caret down and up in the editor", null); } } } else if (DumbService.isDumb(getProject())) { addAdvertisement("The results might be incomplete while indexing is in progress", MessageType.WARNING.getPopupBackground()); } ProgressManager.checkCanceled(); if (!initContext.getOffsetMap().wasModified(CompletionInitializationContext.IDENTIFIER_END_OFFSET)) { try { final int selectionEndOffset = initContext.getSelectionEndOffset(); final PsiReference reference = TargetElementUtil.findReference(myEditor, selectionEndOffset); if (reference != null) { initContext.setReplacementOffset(findReplacementOffset(selectionEndOffset, reference)); } } catch (IndexNotReadyException ignored) { } } for (CompletionContributor contributor : CompletionContributor .forLanguage(initContext.getPositionLanguage())) { ProgressManager.checkCanceled(); if (DumbService.getInstance(initContext.getProject()).isDumb() && !DumbService.isDumbAware(contributor)) { continue; } contributor.duringCompletion(initContext); } }
From source file:com.intellij.compiler.impl.CompileDriver.java
License:Apache License
/** * @noinspection SSBasedInspection//from w ww .j a va2s .c o m */ private long notifyCompilationCompleted(final CompileContextImpl compileContext, final CompileStatusNotification callback, final ExitStatus _status, final boolean refreshOutputRoots) { final long duration = System.currentTimeMillis() - compileContext.getStartCompilationStamp(); if (refreshOutputRoots) { // refresh on output roots is required in order for the order enumerator to see all roots via VFS final Set<File> outputs = new HashSet<File>(); final Module[] affectedModules = compileContext.getCompileScope().getAffectedModules(); for (final String path : CompilerPathsImpl.getOutputPaths(affectedModules)) { outputs.add(new File(path)); } final LocalFileSystem lfs = LocalFileSystem.getInstance(); if (!outputs.isEmpty()) { final ProgressIndicator indicator = compileContext.getProgressIndicator(); indicator.setText("Synchronizing output directories..."); lfs.refreshIoFiles(outputs, _status == ExitStatus.CANCELLED, false, null); indicator.setText(""); } final Set<File> genSourceRoots = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY); for (AdditionalOutputDirectoriesProvider additionalOutputDirectoriesProvider : AdditionalOutputDirectoriesProvider.EP_NAME .getExtensions()) { for (Module module : affectedModules) { for (String path : additionalOutputDirectoriesProvider.getOutputDirectories(myProject, module)) { genSourceRoots.add(new File(path)); } } } if (!genSourceRoots.isEmpty()) { // refresh generates source roots asynchronously; needed for error highlighting update lfs.refreshIoFiles(genSourceRoots, true, true, null); } } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { int errorCount = 0; int warningCount = 0; try { errorCount = compileContext.getMessageCount(CompilerMessageCategory.ERROR); warningCount = compileContext.getMessageCount(CompilerMessageCategory.WARNING); if (!myProject.isDisposed()) { final String statusMessage = createStatusMessage(_status, warningCount, errorCount, duration); final MessageType messageType = errorCount > 0 ? MessageType.ERROR : warningCount > 0 ? MessageType.WARNING : MessageType.INFO; if (duration > ONE_MINUTE_MS) { ToolWindowManager.getInstance(myProject).notifyByBalloon( ProblemsView.PROBLEMS_TOOLWINDOW_ID, messageType, statusMessage); } CompilerManager.NOTIFICATION_GROUP.createNotification(statusMessage, messageType) .notify(myProject); if (_status != ExitStatus.UP_TO_DATE && compileContext.getMessageCount(null) > 0) { compileContext.addMessage(CompilerMessageCategory.INFORMATION, statusMessage, null, -1, -1); } } } finally { if (callback != null) { callback.finished(_status == ExitStatus.CANCELLED, errorCount, warningCount, compileContext); } } } }); return duration; }
From source file:com.intellij.debugger.ui.breakpoints.BreakpointManager.java
License:Apache License
private static boolean checkAndNotifyPossiblySlowBreakpoint(XBreakpoint breakpoint) { if (breakpoint.isEnabled() && (breakpoint.getType() instanceof JavaMethodBreakpointType || breakpoint.getType() instanceof JavaWildcardMethodBreakpointType)) { XDebugSessionImpl.NOTIFICATION_GROUP .createNotification("Method breakpoints may dramatically slow down debugging", MessageType.WARNING) .notify(((XBreakpointBase) breakpoint).getProject()); return true; }//w w w. j av a 2 s. c om return false; }
From source file:com.intellij.dvcs.push.ui.RepositoryWithBranchPanel.java
License:Apache License
public RepositoryWithBranchPanel(@NotNull final Project project, @NotNull String repoName, @NotNull String sourceName, @NotNull PushTargetPanel<T> destPushTargetPanelComponent) { super();/* w w w. j av a 2 s . c o m*/ setLayout(new BorderLayout()); myRepositoryCheckbox = new JBCheckBox(); myRepositoryCheckbox.setFocusable(false); myRepositoryCheckbox.setOpaque(false); myRepositoryCheckbox.setBorder(null); myRepositoryCheckbox.addActionListener(new ActionListener() { @Override public void actionPerformed(@NotNull ActionEvent e) { fireOnSelectionChange(myRepositoryCheckbox.isSelected()); } }); myRepositoryLabel = new JLabel(repoName); myLocalBranch = new JBLabel(sourceName); myArrowLabel = new JLabel(" " + UIUtil.rightArrow() + " "); myDestPushTargetPanelComponent = destPushTargetPanelComponent; myTextRenderer = new ColoredTreeCellRenderer() { public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { } }; myTextRenderer.setOpaque(false); layoutComponents(); setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { ValidationInfo error = myDestPushTargetPanelComponent.verify(); if (error != null) { //noinspection ConstantConditions PopupUtil.showBalloonForComponent(error.component, error.message, MessageType.WARNING, false, project); } return error == null; } }); JCheckBox emptyBorderCheckBox = new JCheckBox(); emptyBorderCheckBox.setBorder(null); Dimension size = emptyBorderCheckBox.getPreferredSize(); myCheckBoxWidth = size.width; myCheckBoxHeight = size.height; myLoadingIcon = LoadingIcon.create(myCheckBoxWidth, size.height); myCheckBoxLoadingIconGapH = myCheckBoxWidth - myLoadingIcon.getIconWidth(); myCheckBoxLoadingIconGapV = size.height - myLoadingIcon.getIconHeight(); }
From source file:com.intellij.execution.junit.TestPackage.java
License:Apache License
@Override protected void notifyByBalloon(JUnitRunningModel model, boolean started, final JUnitConsoleProperties consoleProperties) { if (myFoundTests) { super.notifyByBalloon(model, started, consoleProperties); } else {/*from ww w . j a v a2s .co m*/ final String packageName = myConfiguration.getPackage(); if (packageName == null) return; final Project project = myConfiguration.getProject(); final PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(packageName); if (aPackage == null) return; final Module module = myConfiguration.getConfigurationModule().getModule(); if (module == null) return; final Set<Module> modulesWithPackage = new HashSet<Module>(); final PsiDirectory[] directories = aPackage.getDirectories(); for (PsiDirectory directory : directories) { final Module currentModule = ModuleUtil.findModuleForFile(directory.getVirtualFile(), project); if (module != currentModule && currentModule != null) { modulesWithPackage.add(currentModule); } } if (!modulesWithPackage.isEmpty()) { final String testRunDebugId = consoleProperties.isDebug() ? ToolWindowId.DEBUG : ToolWindowId.RUN; final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project); final Function<Module, String> moduleNameRef = new Function<Module, String>() { @Override public String fun(Module module) { final String moduleName = module.getName(); return "<a href=\"" + moduleName + "\">" + moduleName + "</a>"; } }; String message = "Tests were not found in module \"" + module.getName() + "\".\n" + "Use "; if (modulesWithPackage.size() == 1) { message += "module \"" + moduleNameRef.fun(modulesWithPackage.iterator().next()) + "\" "; } else { message += "one of\n" + StringUtil.join(modulesWithPackage, moduleNameRef, "\n") + "\n"; } message += "instead"; toolWindowManager.notifyByBalloon(testRunDebugId, MessageType.WARNING, message, null, new ResetConfigurationModuleAdapter(project, consoleProperties, toolWindowManager, testRunDebugId)); } } }
From source file:com.intellij.execution.testframework.ResetConfigurationModuleAdapter.java
License:Apache License
public static <T extends ModuleBasedConfiguration<JavaRunConfigurationModule> & CommonJavaRunConfigurationParameters> boolean tryWithAnotherModule( T configuration, boolean isDebug) { final String packageName = configuration.getPackage(); if (packageName == null) return false; final Project project = configuration.getProject(); final PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(packageName); if (aPackage == null) return false; final Module module = configuration.getConfigurationModule().getModule(); if (module == null) return false; final Set<Module> modulesWithPackage = new HashSet<Module>(); final PsiDirectory[] directories = aPackage.getDirectories(); for (PsiDirectory directory : directories) { final Module currentModule = ModuleUtilCore.findModuleForFile(directory.getVirtualFile(), project); if (module != currentModule && currentModule != null) { modulesWithPackage.add(currentModule); }//ww w .ja v a2 s . c o m } if (!modulesWithPackage.isEmpty()) { final String testRunDebugId = isDebug ? ToolWindowId.DEBUG : ToolWindowId.RUN; final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project); final Function<Module, String> moduleNameRef = module1 -> { final String moduleName = module1.getName(); return "<a href=\"" + moduleName + "\">" + moduleName + "</a>"; }; String message = "Tests were not found in module \"" + module.getName() + "\".\n" + "Use "; if (modulesWithPackage.size() == 1) { message += "module \"" + moduleNameRef.fun(modulesWithPackage.iterator().next()) + "\" "; } else { message += "one of\n" + StringUtil.join(modulesWithPackage, moduleNameRef, "\n") + "\n"; } message += "instead"; toolWindowManager.notifyByBalloon(testRunDebugId, MessageType.WARNING, message, null, new ResetConfigurationModuleAdapter(configuration, project, isDebug, toolWindowManager, testRunDebugId)); return true; } return false; }
From source file:com.intellij.execution.testframework.sm.runner.ui.SMTRunnerNotificationsHandler.java
License:Apache License
public void onTestingFinished(@NotNull SMTestProxy.SMRootTestProxy testsRoot) { final String msg; final MessageType type; final TestStateInfo.Magnitude magnitude = testsRoot.getMagnitudeInfo(); //noinspection EnumSwitchStatementWhichMissesCases switch (magnitude) { case SKIPPED_INDEX: case IGNORED_INDEX: msg = testsRoot.hasErrors()/*from w ww. j ava2s. c o m*/ ? SMTestsRunnerBundle.message("sm.test.runner.notifications.tests.skipped.with.errors") : SMTestsRunnerBundle.message("sm.test.runner.notifications.tests.skipped"); type = MessageType.WARNING; break; case NOT_RUN_INDEX: msg = testsRoot.hasErrors() ? SMTestsRunnerBundle.message("sm.test.runner.notifications.tests.not.run.with.errors") : SMTestsRunnerBundle.message("sm.test.runner.notifications.tests.not.run"); type = MessageType.WARNING; break; case FAILED_INDEX: case ERROR_INDEX: msg = testsRoot.hasErrors() ? SMTestsRunnerBundle.message("sm.test.runner.notifications.tests.failed.with.errors") : SMTestsRunnerBundle.message("sm.test.runner.notifications.tests.failed"); type = MessageType.ERROR; break; case COMPLETE_INDEX: if (testsRoot.getChildren().size() == 0 && !testsRoot.isLeaf()) { msg = testsRoot.hasErrors() ? SMTestsRunnerBundle.message( "sm.test.runner.ui.tests.tree.presentation.labels.no.tests.were.found.with.errors") : testsRoot.isTestsReporterAttached() ? SMTestsRunnerBundle.message( "sm.test.runner.ui.tests.tree.presentation.labels.no.tests.were.found") : SMTestsRunnerBundle.message( "sm.test.runner.ui.tests.tree.presentation.labels.test.reporter.not.attached"); type = MessageType.ERROR; break; } else if (testsRoot.isEmptySuite()) { msg = SMTestsRunnerBundle .message("sm.test.runner.ui.tests.tree.presentation.labels.empty.test.suite"); type = MessageType.WARNING; break; } // else same as: PASSED_INDEX case PASSED_INDEX: msg = testsRoot.hasErrors() ? SMTestsRunnerBundle.message("sm.test.runner.notifications.tests.passed.with.errors") : SMTestsRunnerBundle.message("sm.test.runner.notifications.tests.passed"); type = MessageType.INFO; break; default: msg = null; type = null; } if (msg != null) { notify(msg, type, testsRoot); } }
From source file:com.intellij.find.actions.ShowUsagesAction.java
License:Apache License
@NotNull private JComponent createHintComponent(@NotNull String text, @NotNull final FindUsagesHandler handler, @NotNull final RelativePoint popupPosition, final Editor editor, @NotNull final Runnable cancelAction, final int maxUsages, @NotNull final FindUsagesOptions options, boolean isWarning) { JComponent label = HintUtil// ww w . jav a 2 s . c om .createInformationLabel(suggestSecondInvocation(options, handler, text + " ")); if (isWarning) { label.setBackground(MessageType.WARNING.getPopupBackground()); } InplaceButton button = createSettingsButton(handler, popupPosition, editor, maxUsages, cancelAction); JPanel panel = new JPanel(new BorderLayout()) { @Override public void addNotify() { mySearchEverywhereRunnable = new Runnable() { @Override public void run() { searchEverywhere(options, handler, editor, popupPosition, maxUsages); } }; super.addNotify(); } @Override public void removeNotify() { mySearchEverywhereRunnable = null; super.removeNotify(); } }; button.setBackground(label.getBackground()); panel.setBackground(label.getBackground()); label.setOpaque(false); label.setBorder(null); panel.setBorder(HintUtil.createHintBorder()); panel.add(label, BorderLayout.CENTER); panel.add(button, BorderLayout.EAST); return panel; }