List of usage examples for com.intellij.openapi.ui Messages showMessageDialog
public static void showMessageDialog(@NotNull Component parent, String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon)
From source file:de.mobilej.plugin.adc.ToolWindowFactory.java
License:Apache License
@NotNull private JPanel createPanel(@NotNull Project project) { // Create Panel and Content JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; devices = new ComboBox(new String[] { resourceBundle.getString("device.none") }); c.gridx = 0;/*from w ww .j av a 2 s .c om*/ c.gridy = 0; panel.add(new JLabel("Device"), c); c.gridx = 1; c.gridy = 0; panel.add(devices, c); showLayoutBounds = new JBCheckBox(resourceBundle.getString("show.layout.bounds")); c.gridx = 0; c.gridy = 1; c.gridwidth = 2; panel.add(showLayoutBounds, c); showLayoutBounds.addActionListener(e -> { final String what = showLayoutBounds.isSelected() ? "true" : "\"\""; final String cmd = "setprop debug.layout " + what; ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true); userAction = true; executeShellCommand(cmd, true); userAction = false; }, resourceBundle.getString("setting.values.title"), false, null); }); localeChooser = new ComboBox(LOCALES); c.gridx = 0; c.gridy = 2; c.gridwidth = 2; panel.add(localeChooser, c); localeChooser.addActionListener(e -> { final LocaleData ld = (LocaleData) localeChooser.getSelectedItem(); if (ld == null) { return; } ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true); userAction = true; executeShellCommand( "am start -a SETMYLOCALE --es language " + ld.language + " --es country " + ld.county, false); userAction = false; }, resourceBundle.getString("setting.values.title"), false, null); }); goToActivityButton = new JButton(resourceBundle.getString("button.goto_activity")); c.gridx = 0; c.gridy = 3; c.gridwidth = 2; panel.add(goToActivityButton, c); goToActivityButton .addActionListener(e -> ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true); userAction = true; final String result = executeShellCommand("dumpsys activity top", false); userAction = false; if (result == null) { return; } ApplicationManager.getApplication().invokeLater(() -> { String activity = result.substring(result.indexOf("ACTIVITY ") + 9); activity = activity.substring(0, activity.indexOf(" ")); String pkg = activity.substring(0, activity.indexOf("/")); String clz = activity.substring(activity.indexOf("/") + 1); if (clz.startsWith(".")) { clz = pkg + clz; } GlobalSearchScope scope = GlobalSearchScope.allScope(project); PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(clz, scope); if (psiClass != null) { FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); //Open the file containing the class VirtualFile vf = psiClass.getContainingFile().getVirtualFile(); //Jump there new OpenFileDescriptor(project, vf, 1, 0).navigateInEditor(project, false); } else { Messages.showMessageDialog(project, clz, resourceBundle.getString("error.class_not_found"), Messages.getWarningIcon()); return; } }); }, resourceBundle.getString("setting.values.title"), false, null)); inputOnDeviceButton = new JButton(resourceBundle.getString("button.input_on_device")); c.gridx = 0; c.gridy = 4; c.gridwidth = 2; panel.add(inputOnDeviceButton, c); inputOnDeviceButton.addActionListener(e -> { final String text2send = Messages.showMultilineInputDialog(project, resourceBundle.getString("send_text.message"), resourceBundle.getString("send_text.title"), storage.getLastSentText(), Messages.getQuestionIcon(), null); if (text2send != null) { storage.setLastSentText(text2send); ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true); userAction = true; doInputOnDevice(text2send); userAction = false; }, resourceBundle.getString("processing.title"), false, null); } }); clearDataButton = new JButton(resourceBundle.getString("button.clear_data")); c.gridx = 0; c.gridy = 5; c.gridwidth = 2; panel.add(clearDataButton, c); clearDataButton.addActionListener(actionEvent -> { ArrayList<String> appIds = new ArrayList<String>(); List<AndroidFacet> androidFacets = ProjectFacetManager.getInstance(project).getFacets(AndroidFacet.ID); if (androidFacets != null) { for (AndroidFacet facet : androidFacets) { if (!facet.isLibraryProject()) { AndroidModel androidModel = facet.getAndroidModel(); if (androidModel != null) { String appId = androidModel.getApplicationId(); appIds.add(appId); } } } } ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true); userAction = true; for (String appId : appIds) { executeShellCommand("pm clear " + appId, false); } userAction = false; }, resourceBundle.getString("processing.title"), false, null); }); JPanel framePanel = new JPanel(new BorderLayout()); framePanel.add(panel, BorderLayout.NORTH); return framePanel; }
From source file:de.mprengemann.intellij.plugin.androidicons.actions.AndroidIconsAction.java
License:Apache License
@Override public void actionPerformed(@NotNull AnActionEvent event) { Project project = getEventProject(event); VirtualFile assetRoot = SettingsHelper.getAssetPath(IconPack.ANDROID_ICONS); if (assetRoot == null) { Messages.showMessageDialog(project, "You have to select the Android Icons asset folder in the settings!", "Error", Messages.getErrorIcon()); if (project == null) { project = ProjectManager.getInstance().getDefaultProject(); }//from w w w. j a v a2s . c o m ShowSettingsUtil.getInstance().showSettingsDialog(project, "Android Drawable Importer"); } else { Module module = event.getData(DataKeys.MODULE); AndroidIconsImporter dialog = new AndroidIconsImporter(project, module); dialog.show(); } }
From source file:de.mprengemann.intellij.plugin.androidicons.actions.MaterialIconsAction.java
License:Apache License
@Override public void actionPerformed(@NotNull AnActionEvent event) { Project project = getEventProject(event); VirtualFile assetRoot = SettingsHelper.getAssetPath(IconPack.MATERIAL_ICONS); if (assetRoot == null) { Messages.showMessageDialog(project, "You have to select the Material Icons root folder in the settings!", "Error", Messages.getErrorIcon()); if (project == null) { project = ProjectManager.getInstance().getDefaultProject(); }//from ww w .j a v a 2 s. c o m ShowSettingsUtil.getInstance().showSettingsDialog(project, "Android Drawable Importer"); } else { Module module = event.getData(DataKeys.MODULE); MaterialIconsImporter dialog = new MaterialIconsImporter(project, module); dialog.show(); } }
From source file:generate.tostring.GenerateToStringUtils.java
License:Apache License
/** * Handles any exception during the executing on this plugin. * * @param project PSI project//from w w w . j a va2 s . co m * @param e the caused exception. * @throws RuntimeException is thrown for severe exceptions */ public static void handleExeption(Project project, Exception e) throws RuntimeException { e.printStackTrace(); // must print stacktrace to see caused in IDEA log / console log.error(e); if (e instanceof GenerateCodeException) { // code generation error - display velocity errror in error dialog so user can identify problem quicker Messages.showMessageDialog(project, "Velocity error generating code - see IDEA log for more details (stacktrace should be in idea.log):\n" + e.getMessage(), "Warning", Messages.getWarningIcon()); } else if (e instanceof PluginException) { // plugin related error - could be recoverable. Messages.showMessageDialog(project, "A PluginException was thrown while performing the action - see IDEA log for details (stacktrace should be in idea.log):\n" + e.getMessage(), "Warning", Messages.getWarningIcon()); } else if (e instanceof RuntimeException) { // unknown error (such as NPE) - not recoverable Messages.showMessageDialog(project, "An unrecoverable exception was thrown while performing the action - see IDEA log for details (stacktrace should be in idea.log):\n" + e.getMessage(), "Error", Messages.getErrorIcon()); throw (RuntimeException) e; // throw to make IDEA alert user } else { // unknown error (such as NPE) - not recoverable Messages.showMessageDialog(project, "An unrecoverable exception was thrown while performing the action - see IDEA log for details (stacktrace should be in idea.log):\n" + e.getMessage(), "Error", Messages.getErrorIcon()); throw new RuntimeException(e); // rethrow as runtime to make IDEA alert user } }
From source file:intellijeval.Util.java
License:Apache License
public static void showErrorDialog(Project project, String message, String title) { Messages.showMessageDialog(project, message, title, Messages.getErrorIcon()); }
From source file:io.ballerina.plugins.idea.webview.diagram.preview.BallerinaDiagramEditor.java
License:Open Source License
@NotNull private HtmlPanelProvider retrievePanelProvider(@NotNull DiagramApplicationSettings settings) { final HtmlPanelProvider.ProviderInfo providerInfo = settings.getDiagramPreviewSettings() .getHtmlPanelProviderInfo(); HtmlPanelProvider provider = HtmlPanelProvider.createFromInfo(providerInfo); if (provider.isAvailable() != HtmlPanelProvider.AvailabilityInfo.AVAILABLE) { settings.setDiagramPreviewSettings( new DiagramPreviewSettings(settings.getDiagramPreviewSettings().getSplitEditorLayout(), DiagramPreviewSettings.DEFAULT.getHtmlPanelProviderInfo(), settings.getDiagramPreviewSettings().isUseGrayscaleRendering(), settings.getDiagramPreviewSettings().isAutoScrollPreview())); Messages.showMessageDialog(myHtmlPanelWrapper, "Tried to use preview panel provider (" + providerInfo.getName() + "), but it is unavailable. Reverting to default.", CommonBundle.getErrorTitle(), Messages.getErrorIcon()); provider = HtmlPanelProvider.getProviders()[0]; }/*from www .j av a 2 s. co m*/ myLastPanelProviderInfo = settings.getDiagramPreviewSettings().getHtmlPanelProviderInfo(); return provider; }
From source file:myPlugin.src.TextBoxes.java
License:Apache License
public void actionPerformed(AnActionEvent event) { Project project = event.getData(PlatformDataKeys.PROJECT); String txt = Messages.showInputDialog(project, "Android Class Name", "Android Class Name", Messages.getQuestionIcon()); String recommendation = ""; rulesForClass = parser.getRuleForClass(rules, txt); int i = 1;/* w ww .j a va 2 s . com*/ for (Rule rule : rulesForClass) { recommendation += i + ") " + rule.right_hand_side + "\t Confidece: " + rule.confidence + "\n\n"; i++; } Messages.showMessageDialog(project, recommendation, "Recommended Intent Actions", Messages.getInformationIcon()); }
From source file:net.groboclown.idea.p4ic.extension.P4Vcs.java
License:Apache License
@Override protected void start() throws VcsException { if (!CompatFactoryLoader.isSupported()) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override// www . j a v a2 s.c om public void run() { Messages.showMessageDialog(myProject, P4Bundle.message("ide.not.supported.message", ApplicationInfo.getInstance().getApiVersion(), P4Bundle.getString("p4ic.name"), P4Bundle.getString("p4ic.bug.url")), P4Bundle.message("ide.not.supported.title"), Messages.getErrorIcon()); } }); throw new VcsException(P4Bundle.message("ide.not.supported.title")); } }
From source file:net.groboclown.idea.p4ic.ui.checkin.P4SubmitPanel.java
License:Apache License
public P4SubmitPanel(final SubmitContext context) { this.context = context; // UI setup code - compiler will inject the initialization from the // form.// w ww . ja va 2 s.com $$$setupUI$$$(); // Set the visibility of the expanded panel first. myExpandedPanel.setVisible(false); myJobTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); myJobTable.setRowSelectionAllowed(true); myJobTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(final ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { // Something in this call is disabling // the currently selected item in the table. updateStatus(); } } }); myAddJobButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { String jobId = getJobIdFieldText(); if (jobId != null) { jobId = jobId.trim(); if (jobId.length() > 0) { if (context.addJobId(jobId) != null) { // job was added successfully myJobIdField.setText(""); jobTableModel.fireTableDataChanged(); } else { Messages.showMessageDialog(context.getProject(), P4Bundle.message("submit.job.error.notfound.message", jobId), P4Bundle.getString("submit.job.error.notfound.title"), Messages.getErrorIcon()); } } } } }); myRemoveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { int rowId = myJobTable.getSelectedRow(); if (rowId >= 0 && rowId < context.getJobs().size()) { context.removeJob(context.getJobs().get(rowId)); jobTableModel.fireTableDataChanged(); } } }); myBrowseButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { // TODO replace with real action Messages.showMessageDialog(context.getProject(), "Browsing for jobs is not yet implemented", "Not implemented", Messages.getErrorIcon()); } }); myJobIdField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(final DocumentEvent e) { updateStatus(); } @Override public void removeUpdate(final DocumentEvent e) { updateStatus(); } @Override public void changedUpdate(final DocumentEvent e) { updateStatus(); } }); myJobStatus.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { final Object selected = myJobStatus.getSelectedItem(); if (selected != null) { context.setSubmitStatus(selected.toString()); } } }); myAssociateJobExpander.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(final MouseEvent e) { expandState = !expandState; updateStatus(); } }); myAssociateJobExpander.setIcon(Actions.Right); myJobsDisabledLabel.setVisible(false); }
From source file:net.groboclown.idea.p4ic.ui.config.P4ConfigPanel.java
License:Apache License
private void checkConnection() { runBackgroundAwtAction(myCheckConnectionSpinner, new BackgroundAwtAction<Collection<Builder>>() { @Override/*from ww w . j ava 2 s . co m*/ public Collection<Builder> runBackgroundProcess() { final ConfigSet sources = getValidConfigs(); final List<Builder> problems = new ArrayList<Builder>(); problems.addAll(sources.invalid); for (Entry<ProjectConfigSource, Exception> entry : ConnectionUIConfiguration .findConnectionProblems(sources.valid, ServerConnectionManager.getInstance()).entrySet()) { final VcsException err; //noinspection ThrowableResultOfMethodCallIgnored if (entry.getValue() instanceof VcsException) { err = (VcsException) entry.getValue(); } else { err = new P4FileException(entry.getValue()); } problems.add(entry.getKey().causedError(err)); } return problems; } @Override public void runAwtProcess(final Collection<Builder> problems) { if (problems != null && problems.isEmpty()) { Messages.showMessageDialog(myProject, P4Bundle.message("configuration.dialog.valid-connection.message"), P4Bundle.message("configuration.dialog.valid-connection.title"), Messages.getInformationIcon()); } else if (problems != null) { reportConfigProblems(problems); } } }); }