List of usage examples for com.intellij.openapi.ui Messages showErrorDialog
public static void showErrorDialog(@Nullable Component component, String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title)
From source file:org.jetbrains.android.newProject.AndroidSdkComboBoxWithBrowseButton.java
License:Apache License
public AndroidSdkComboBoxWithBrowseButton() { final JComboBox sdkCombobox = getComboBox(); sdkCombobox.setRenderer(new ListCellRendererWrapper() { @Override/*from w w w . ja v a 2 s .com*/ public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) { if (value instanceof Sdk) { final Sdk sdk = (Sdk) value; setText(sdk.getName()); setIcon(((SdkType) sdk.getSdkType()).getIcon()); } else { setText("<html><font color='red'>[none]</font></html>"); } } }); addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ProjectJdksEditor editor = new ProjectJdksEditor(null, ProjectManager.getInstance().getDefaultProject(), AndroidSdkComboBoxWithBrowseButton.this); editor.show(); if (editor.isOK()) { final Sdk selectedJdk = editor.getSelectedJdk(); rebuildSdksListAndSelectSdk(selectedJdk); if (selectedJdk == null || !(selectedJdk.getSdkType().equals(AndroidSdkType.getInstance()))) { Messages.showErrorDialog(AndroidSdkComboBoxWithBrowseButton.this, AndroidBundle.message("select.platform.error"), CommonBundle.getErrorTitle()); } } } }); getButton().setToolTipText(AndroidBundle.message("android.add.sdk.tooltip")); }
From source file:org.jetbrains.android.run.AndroidRunConfigurationBase.java
License:Apache License
@Override public AndroidRunningState getState(@NotNull final Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException { final Module module = getConfigurationModule().getModule(); if (module == null) { throw new ExecutionException("Module is not found"); }// w ww.j a v a 2 s . c o m final AndroidFacet facet = AndroidFacet.getInstance(module); if (facet == null) { throw new ExecutionException(AndroidBundle.message("no.facet.error", module.getName())); } Project project = env.getProject(); AndroidFacetConfiguration configuration = facet.getConfiguration(); AndroidPlatform platform = configuration.getAndroidPlatform(); if (platform == null) { Messages.showErrorDialog(project, AndroidBundle.message("specify.platform.error"), CommonBundle.getErrorTitle()); ModulesConfigurator.showDialog(project, module.getName(), ClasspathEditor.NAME); return null; } boolean debug = DefaultDebugExecutor.EXECUTOR_ID.equals(executor.getId()); boolean nonDebuggableOnDevice = false; if (debug) { final Manifest manifest = facet.getManifest(); final Application application = manifest != null ? manifest.getApplication() : null; nonDebuggableOnDevice = application != null && Boolean.FALSE.toString().equals(application.getDebuggable().getStringValue()); if (!AndroidSdkUtils.activateDdmsIfNecessary(facet.getModule().getProject(), new Computable<AndroidDebugBridge>() { @Nullable @Override public AndroidDebugBridge compute() { return facet.getDebugBridge(); } })) { return null; } } if (platform.getSdkData().getDebugBridge(getProject()) == null) return null; TargetChooser targetChooser = null; switch (getTargetSelectionMode()) { case SHOW_DIALOG: targetChooser = new ManualTargetChooser(); break; case EMULATOR: targetChooser = new EmulatorTargetChooser(PREFERRED_AVD.length() > 0 ? PREFERRED_AVD : null); break; case USB_DEVICE: targetChooser = new UsbDeviceTargetChooser(); break; default: assert false : "Unknown target selection mode " + TARGET_SELECTION_MODE; break; } AndroidApplicationLauncher applicationLauncher = getApplicationLauncher(facet); if (applicationLauncher != null) { final boolean supportMultipleDevices = supportMultipleDevices() && executor.getId().equals(DefaultRunExecutor.EXECUTOR_ID); return new AndroidRunningState(env, facet, targetChooser, computeCommandLine(), applicationLauncher, supportMultipleDevices, CLEAR_LOGCAT, this, nonDebuggableOnDevice); } return null; }
From source file:org.jetbrains.android.run.AndroidRunningState.java
License:Apache License
private void chooseAvd() { IAndroidTarget buildTarget = myFacet.getConfiguration().getAndroidTarget(); assert buildTarget != null; AvdInfo[] avds = myFacet.getValidCompatibleAvds(); if (avds.length > 0) { myAvdName = avds[0].getName();/*from www . j a v a 2 s .co m*/ } else { final Project project = myFacet.getModule().getProject(); AvdManager manager = null; try { manager = myFacet.getAvdManager(new AvdManagerLog() { @Override public void error(Throwable t, String errorFormat, Object... args) { super.error(t, errorFormat, args); if (errorFormat != null) { final String msg = String.format(errorFormat, args); message(msg, STDERR); } } }); } catch (AvdsNotSupportedException e) { // can't be LOG.error(e); } catch (final AndroidLocation.AndroidLocationException e) { LOG.info(e); runInDispatchedThread(new Runnable() { @Override public void run() { Messages.showErrorDialog(project, e.getMessage(), CommonBundle.getErrorTitle()); } }, false); return; } final AvdManager finalManager = manager; runInDispatchedThread(new Runnable() { @Override public void run() { CreateAvdDialog dialog = new CreateAvdDialog(project, myFacet, finalManager, true, true); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { AvdInfo createdAvd = dialog.getCreatedAvd(); if (createdAvd != null) { myAvdName = createdAvd.getName(); } } } }, true); } }
From source file:org.jetbrains.android.util.AndroidUtils.java
License:Apache License
public static void reportError(@NotNull Project project, @NotNull String message, @NotNull String title) { if (ApplicationManager.getApplication().isUnitTestMode()) { throw new IncorrectOperationException(message); } else {//from w w w . j a v a 2 s . c o m Messages.showErrorDialog(project, message, title); } }
From source file:org.jetbrains.idea.devkit.actions.ShowSerializedXmlAction.java
License:Apache License
private static void generateAndShowXml(final Module module, final String className) { final List<URL> urls = new ArrayList<URL>(); final List<String> list = OrderEnumerator.orderEntries(module).recursively().runtimeOnly().getPathsList() .getPathList();//from ww w .j a v a2s . c om for (String path : list) { try { urls.add(new File(FileUtil.toSystemIndependentName(path)).toURI().toURL()); } catch (MalformedURLException e1) { LOG.info(e1); } } final Project project = module.getProject(); UrlClassLoader loader = UrlClassLoader.build().urls(urls).parent(XmlSerializer.class.getClassLoader()) .get(); final Class<?> aClass; try { aClass = Class.forName(className, true, loader); } catch (ClassNotFoundException e) { Messages.showErrorDialog(project, "Cannot find class '" + className + "'", CommonBundle.getErrorTitle()); LOG.info(e); return; } final Object o; try { o = new SampleObjectGenerator().createValue(aClass, FList.<Type>emptyList()); } catch (Exception e) { Messages.showErrorDialog(project, "Cannot generate class '" + className + "': " + e.getMessage(), CommonBundle.getErrorTitle()); LOG.info(e); return; } final Element element = XmlSerializer.serialize(o); final String text = JDOMUtil.writeElement(element, "\n"); Messages.showIdeaMessageDialog(project, text, "Serialized XML for '" + className + "'", new String[] { CommonBundle.getOkButtonText() }, 0, Messages.getInformationIcon(), null); }
From source file:org.jetbrains.idea.devkit.dom.generator.DomGenPanel.java
License:Apache License
public boolean validate() { if (!new File(mySchemaLocation.getText()).exists()) { Messages.showErrorDialog(myProject, "Schema location doesn't exist", "Error"); IdeFocusManager.getInstance(myProject).requestFocus(mySchemaLocation, true); return false; }//w ww . ja va2 s. c om if (!new File(myOutputDir.getText()).exists()) { Messages.showErrorDialog(myProject, "Output dir doesn't exist", "Error"); IdeFocusManager.getInstance(myProject).requestFocus(myOutputDir, true); return false; } return true; }
From source file:org.jetbrains.idea.maven.execution.MavenResumeAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent e) { Project project = myEnvironment.getProject(); try {//from w ww . j a va2 s. com MavenRunConfiguration runConfiguration = ((MavenRunConfiguration) myEnvironment.getRunProfile()) .clone(); List<String> goals = runConfiguration.getRunnerParameters().getGoals(); if (goals.size() > 2 && "-rf".equals(goals.get(goals.size() - 2))) { // This runConfiguration was created by other MavenResumeAction. goals.set(goals.size() - 1, myResumeModuleId); } else { goals.add("-rf"); goals.add(myResumeModuleId); } myRunner.execute(new ExecutionEnvironmentBuilder(myEnvironment).contentToReuse(null).build()); } catch (RunCanceledByUserException ignore) { } catch (ExecutionException e1) { Messages.showErrorDialog(project, e1.getMessage(), ExecutionBundle.message("restart.error.message.title")); } }
From source file:org.jetbrains.idea.maven.utils.library.RepositoryAttachHandler.java
License:Apache License
@Nullable public static NewLibraryConfiguration chooseLibraryAndDownload(final @Nonnull Project project, final @Nullable String initialFilter, JComponent parentComponent) { final RepositoryAttachDialog dialog = new RepositoryAttachDialog(project, false, initialFilter); dialog.setTitle("Download Library From Maven Repository"); dialog.show();// w w w.ja va 2 s .com if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) { return null; } final String copyTo = dialog.getDirectoryPath(); final String coord = dialog.getCoordinateText(); final boolean attachJavaDoc = dialog.getAttachJavaDoc(); final boolean attachSources = dialog.getAttachSources(); final SmartList<MavenExtraArtifactType> extraTypes = new SmartList<MavenExtraArtifactType>(); if (attachSources) extraTypes.add(MavenExtraArtifactType.SOURCES); if (attachJavaDoc) extraTypes.add(MavenExtraArtifactType.DOCS); final Ref<NewLibraryConfiguration> result = Ref.create(null); resolveLibrary(project, coord, extraTypes, dialog.getRepositories(), new Processor<List<MavenArtifact>>() { public boolean process(final List<MavenArtifact> artifacts) { if (!artifacts.isEmpty()) { AccessToken accessToken = WriteAction.start(); try { final List<OrderRoot> roots = createRoots(artifacts, copyTo); result.set(new NewLibraryConfiguration(coord, RepositoryLibraryType.getInstance(), new RepositoryLibraryProperties(coord)) { @Override public void addRoots(@Nonnull LibraryEditor editor) { editor.addRoots(roots); } }); } finally { accessToken.finish(); } final StringBuilder sb = new StringBuilder(); final String title = "The following files were downloaded:"; sb.append("<ol>"); for (MavenArtifact each : artifacts) { sb.append("<li>"); sb.append(each.getFile().getName()); final String scope = each.getScope(); if (scope != null) { sb.append(" ("); sb.append(scope); sb.append(")"); } sb.append("</li>"); } sb.append("</ol>"); Notifications.Bus.notify( new Notification("Repository", title, sb.toString(), NotificationType.INFORMATION), project); } return true; } }); NewLibraryConfiguration configuration = result.get(); if (configuration == null) { Messages.showErrorDialog(parentComponent, "No files were downloaded for " + coord, CommonBundle.getErrorTitle()); } return configuration; }
From source file:org.jetbrains.idea.svn.actions.RelocateAction.java
License:Apache License
protected void perform(final Project project, final SvnVcs activeVcs, final VirtualFile file, DataContext context) throws VcsException { SVNInfo info = activeVcs.getInfo(file); assert info != null; RelocateDialog dlg = new RelocateDialog(project, info.getURL()); dlg.show();/*from ww w .ja v a 2 s. co m*/ if (!dlg.isOK()) return; final String beforeURL = dlg.getBeforeURL(); final String afterURL = dlg.getAfterURL(); if (beforeURL.equals(afterURL)) return; ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { public void run() { final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); if (indicator != null) { indicator.setIndeterminate(true); } try { File path = new File(file.getPath()); activeVcs.getFactory(path).createRelocateClient().relocate(path, beforeURL, afterURL); VcsDirtyScopeManager.getInstance(project).markEverythingDirty(); } catch (final VcsException e) { WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() { public void run() { Messages.showErrorDialog(project, "Error relocating working copy: " + e.getMessage(), "Relocate Working Copy"); } }, null, project); } } }, "Relocating Working Copy", false, project); }
From source file:org.jetbrains.idea.svn.actions.SelectBranchPopup.java
License:Apache License
public static void showForBranchRoot(Project project, VirtualFile vcsRoot, BranchSelectedCallback callback, final String title, final Component component) { final SvnBranchConfigurationNew configuration; try {/*from w w w .ja v a 2 s . com*/ configuration = SvnBranchConfigurationManager.getInstance(project).get(vcsRoot); } catch (VcsException e1) { Messages.showErrorDialog(project, SvnBundle.message("getting.branch.configuration.error", e1.getMessage()), title); return; } final List<String> items = new ArrayList<String>(); if (!StringUtil.isEmptyOrSpaces(configuration.getTrunkUrl())) { items.add(getTrunkString(configuration)); } for (String url : configuration.getBranchUrls()) { items.add(url); } items.add(CONFIGURE_MESSAGE); BranchBasesPopupStep step = new BranchBasesPopupStep(project, vcsRoot, configuration, callback, items, title, component); final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step); step.showPopupAt(listPopup); }