List of usage examples for com.intellij.openapi.ui Messages showChooseDialog
@Deprecated public static int showChooseDialog(Project project, String message, @Nls(capitalization = Nls.Capitalization.Title) String title, Icon icon, String[] values, String initialValue)
From source file:com.intellij.profile.codeInspection.ui.actions.AddScopeAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent e) { final List<Descriptor> descriptors = new ArrayList<Descriptor>(); final InspectionConfigTreeNode[] selectedNodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null);//from w w w.j a v a 2s .c o m LOG.assertTrue(selectedNodes != null); final List<InspectionConfigTreeNode> nodes = new ArrayList<InspectionConfigTreeNode>( Arrays.asList(selectedNodes)); for (InspectionConfigTreeNode node : selectedNodes) { collect(descriptors, nodes, node); } final Project project = getProject(e); final List<String> availableScopes = getAvailableScopes(project, descriptors); final int idx = Messages.showChooseDialog(myTree, "Scope:", "Choose Scope", ArrayUtil.toStringArray(availableScopes), availableScopes.get(0), Messages.getQuestionIcon()); if (idx == -1) return; final NamedScope chosenScope = NamedScopesHolder.getScope(project, availableScopes.get(idx)); for (InspectionConfigTreeNode node : nodes) { final Descriptor descriptor = node.getDescriptor(); if (node.getScopeName() != null || descriptor == null) continue; final InspectionToolWrapper toolWrapper = descriptor.getToolWrapper(); //copy InspectionProfileImpl selectedProfile = getSelectedProfile(); HighlightDisplayLevel level = selectedProfile.getErrorLevel(descriptor.getKey(), chosenScope, project); boolean enabled = selectedProfile.isToolEnabled(descriptor.getKey()); final ScopeToolState scopeToolState = selectedProfile.addScope(toolWrapper, chosenScope, level, enabled, project); final Descriptor addedDescriptor = new Descriptor(scopeToolState, selectedProfile, project); if (node.getChildCount() == 0) { node.add(new InspectionConfigTreeNode(descriptor, selectedProfile.getToolDefaultState(descriptor.getKey().toString(), project), true, true, false)); } node.insert(new InspectionConfigTreeNode(addedDescriptor, scopeToolState, false, false), 0); node.setInspectionNode(false); node.dropCache(); ((DefaultTreeModel) myTree.getModel()).reload(node); myTree.expandPath(new TreePath(node.getPath())); } myTree.revalidate(); }
From source file:com.intellij.uiDesigner.snapShooter.CreateSnapShotAction.java
License:Apache License
@Nullable private static RunnerAndConfigurationSettings promptForSnapshotConfiguration(final Project project, final List<RunnerAndConfigurationSettings> configurations) { if (configurations.isEmpty()) { Messages.showMessageDialog(project, UIDesignerBundle.message("snapshot.no.configuration.error"), UIDesignerBundle.message("snapshot.title"), Messages.getInformationIcon()); return null; }// w w w. j a v a 2 s .c o m for (int i = configurations.size() - 1; i >= 0; i--) { final JreVersionDetector detector = new JreVersionDetector(); final ApplicationConfiguration configuration = (ApplicationConfiguration) configurations.get(i) .getConfiguration(); if (!detector.isJre50Configured(configuration) && !detector.isModuleJre50Configured(configuration)) { configurations.remove(i); } } if (configurations.isEmpty()) { Messages.showMessageDialog(project, UIDesignerBundle.message("snapshot.no.compatible.configuration.error"), UIDesignerBundle.message("snapshot.title"), Messages.getInformationIcon()); return null; } final RunnerAndConfigurationSettings snapshotConfiguration; if (configurations.size() == 1) { final int rc = Messages.showYesNoDialog(project, UIDesignerBundle.message("snapshot.confirm.configuration.prompt", configurations.get(0).getConfiguration().getName()), UIDesignerBundle.message("snapshot.title"), Messages.getQuestionIcon()); if (rc == 1) { return null; } snapshotConfiguration = configurations.get(0); } else { String[] names = new String[configurations.size()]; for (int i = 0; i < configurations.size(); i++) { names[i] = configurations.get(i).getConfiguration().getName(); } int rc = Messages.showChooseDialog(project, UIDesignerBundle.message("snapshot.choose.configuration.prompt"), UIDesignerBundle.message("snapshot.title"), Messages.getQuestionIcon(), names, names[0]); if (rc < 0) return null; snapshotConfiguration = configurations.get(rc); } ((ApplicationConfiguration) snapshotConfiguration.getConfiguration()).ENABLE_SWING_INSPECTOR = true; return snapshotConfiguration; }
From source file:com.intellij.vcs.starteam.StarteamChangeProvider.java
private void processFailedConnection(final String msg) { if (!warnShown) { Runnable action = new Runnable() { public void run() { String title = StarteamBundle.message("message.title.configuration.error"); String reconnectText = StarteamBundle.message("text.reconnect"); String cancelText = StarteamBundle.message("text.cancel"); int result = Messages.showChooseDialog(project, msg, title, Messages.getQuestionIcon(), new String[] { reconnectText, cancelText }, reconnectText); if (result == 0) { try { host.doShutdown(); host.doStart();//w w w . j av a2s . co m warnShown = false; } catch (VcsException e) { Messages.showErrorDialog(msg, StarteamBundle.message("message.title.configuration.error")); } } } }; ApplicationManager.getApplication().invokeLater(action); warnShown = true; } }