List of usage examples for org.eclipse.jface.dialogs MessageDialog openError
public static void openError(Shell parent, String title, String message)
From source file:com.appcelerator.titanium.desktop.ui.wizard.PackageHandler.java
License:Apache License
public Object execute(ExecutionEvent event) throws ExecutionException { ITitaniumUser user = TitaniumCorePlugin.getDefault().getUserManager().getSignedInUser(); if (user == null) { // Force the login! // TODO Make it easy for user to sign in from here! MessageDialog.openError(UIUtils.getActiveShell(), Messages.PackageHandler_LoginTitle, Messages.PackageHandler_LoginMessage); return null; }/*w ww . j av a2 s. c o m*/ DistributeDesktopWizard wizard = new DistributeDesktopWizard(); WizardDialog dialog = new WizardDialog(UIUtils.getActiveShell(), wizard); dialog.setPageSize(400, 300); IResource selectedResource = UIUtils .getSelectedResource((IEvaluationContext) event.getApplicationContext()); if (selectedResource != null) { wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(selectedResource)); } dialog.open(); return null; }
From source file:com.appcelerator.titanium.desktop.ui.wizard.Packager.java
License:Apache License
/** * Show the webpage that lists the last releases generated by Desktop packaging for a given project. * // w ww .j a v a 2 s .c om * @param project */ public void showPackages(final IProject project) { final List<Release> releases = Release.load(project); UIUtils.getDisplay().asyncExec(new Runnable() { // For now let's just pop open a dialog with the releases public void run() { try { InputStream in = FileLocator.openStream(DesktopPlugin.getDefault().getBundle(), Path.fromPortableString("template.html"), false); //$NON-NLS-1$ String html = IOUtil.read(in); StringBuilder builder = new StringBuilder(); String appPage = StringUtil.EMPTY; String pubDate = StringUtil.EMPTY; if (releases != null) { for (Release release : releases) { String label = release.getLabel(); String url = release.getURL(); String platform = release.getPlatform(); builder.append("<div class=\"row even\">\n"); //$NON-NLS-1$ builder.append( "<div class=\"platform\"><img height=\"20\" width=\"20\" src=\"http://studio-titanium.s3.amazonaws.com/") //$NON-NLS-1$ .append(platform).append("_small.png\"/></div>\n"); //$NON-NLS-1$ builder.append("<div class=\"label\">").append(label).append("</div>\n"); //$NON-NLS-1$ //$NON-NLS-2$ builder.append("<div class=\"link\"><a href=\"").append(url).append("\">").append(url) //$NON-NLS-1$ //$NON-NLS-2$ .append("</a></div>\n</div>\n"); //$NON-NLS-1$ appPage = release.getAppPage(); pubDate = release.getPubDate(); } } // We need to inject the releases into the list html = html.replaceAll(Pattern.quote("${RELEASES}"), builder.toString()); //$NON-NLS-1$ html = html.replaceAll(Pattern.quote("${APP_PAGE}"), appPage); //$NON-NLS-1$ html = html.replaceAll(Pattern.quote("${PUB_DATE}"), pubDate); //$NON-NLS-1$ // if tehre are no releases, show the no links div in the webpage html = html.replaceAll(Pattern.quote("${DISPLAY_LINKS}"), //$NON-NLS-1$ (releases == null || releases.isEmpty()) ? "none" : "block"); //$NON-NLS-1$ //$NON-NLS-2$ html = html.replaceAll(Pattern.quote("${DISPLAY_NO_LINKS}"), //$NON-NLS-1$ (releases == null || releases.isEmpty()) ? "block" : "none"); //$NON-NLS-1$ //$NON-NLS-2$ File tmpFile = File.createTempFile("releases", ".html"); //$NON-NLS-1$ //$NON-NLS-2$ FileWriter writer = new FileWriter(tmpFile); writer.write(html); writer.close(); try { PlatformUI.getWorkbench().getBrowserSupport() .createBrowser(IWorkbenchBrowserSupport.AS_EDITOR, null, Messages.Packager_LastPackagedDist_Title, Messages.Packager_LastPackagedDist_ToolTip) .openURL(new URL(tmpFile.toURI().toURL().toString())); } catch (Exception e) { IdeLog.logError(DesktopPlugin.getDefault(), "Unable to open last packaged distribution", e); //$NON-NLS-1$ } } catch (Exception e) { MessageDialog.openError(new Shell(), Messages.Packager_LinksWebpageOpenError, e.getMessage()); } } }); }
From source file:com.appnativa.studio.ConsoleManager.java
License:Open Source License
public void println(String msg, int msgKind) { if (msg == null) { return;/* w w w . jav a2 s . c o m*/ } /* * if console-view in Java-perspective is not active, then show it and * then display the message in the console attached to it */ if (!displayConsoleView()) { /*If an exception occurs while displaying in the console, then just diplay atleast the same in a message-box */ MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error", msg); return; } /* display message on console */ getNewMessageConsoleStream(msgKind).println(msg); }
From source file:com.appnativa.studio.ConsoleManager.java
License:Open Source License
public void print(String msg, int msgKind) { if (msg == null) { return;/*ww w .ja v a2 s. c om*/ } /* * if console-view in Java-perspective is not active, then show it and * then display the message in the console attached to it */ if (!displayConsoleView()) { /*If an exception occurs while displaying in the console, then just diplay atleast the same in a message-box */ MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error", msg); return; } /* display message on console */ getNewMessageConsoleStream(msgKind).print(msg); }
From source file:com.appnativa.studio.editors.MultiPageEditor.java
License:Open Source License
public void hideDesignAfterError(final boolean showMessage) { if (designSage != null) { final iPlatformAppContext app = designSage.getAppContext(); designSage = null;// w ww.j av a2 s . c o m try { app.exit(); } catch (Exception e) { } Display.getDefault().asyncExec(new Runnable() { @Override public void run() { if (designComposite != null) { designComposite.dispose(); designComposite = null; } setActivePage(0); if (showMessage) { String title = Studio.getResourceAsString("Studio.title"); String msg = Studio.getResourceAsString("Studio.text.design_error"); MessageDialog.openError(Display.getDefault().getActiveShell(), title, msg); } } }); } }
From source file:com.appnativa.studio.Studio.java
License:Open Source License
public static void showError(final Throwable e, final boolean switchToSource) { ErrorInformation ei = new ErrorInformation(e); final String s = ei.toAlertPanelString(); Runnable r = new Runnable() { @Override/*ww w . ja va 2s .c om*/ public void run() { MessageDialog.openError(Display.getDefault().getActiveShell(), getResourceAsString("Studio.title"), s); if (switchToSource) { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IEditorPart ep = page == null ? null : page.getActiveEditor(); if (ep instanceof MultiPageEditor) { ((MultiPageEditor) ep).hideDesignAfterError(false); } } } }; e.printStackTrace(); runInSWTThread(r); }
From source file:com.appnativa.studio.wizards.NewLayout.java
License:Open Source License
/** * This method is called when 'Finish' button is pressed in * the wizard. We will create an operation and run it * using wizard as execution context./*from w w w .j av a 2 s .co m*/ */ public boolean performFinish() { final String containerName = page.getContainerName(); final String fileName = page.getFileName(); String id = page.getWidgetType(); if (id != null) { Object o = Studio.getAttribute(id); if (o != null) { contents = o.toString(); } } if (contents == null) { contents = ""; } IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { try { doFinish(containerName, fileName, monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } finally { monitor.done(); } } }; try { getContainer().run(true, false, op); } catch (InterruptedException e) { return false; } catch (InvocationTargetException e) { e.printStackTrace(); Throwable realException = e.getTargetException(); MessageDialog.openError(getShell(), "Error", realException.getMessage()); return false; } return true; }
From source file:com.appnativa.studio.wizards.NewProject.java
License:Open Source License
@Override public boolean performFinish() { try {// w w w . j a v a2 s. c o m if ((applicationPage == null) || !applicationPage.isPageComplete()) { return true; } String name = applicationPage.getApplicationName(); if ((name == null) || (name.trim().length() == 0)) { name = "MyApplication"; } String title = applicationPage.getApplicationTitle(); if ((title == null) || (title.trim().length() == 0)) { title = "My Application"; } UIColor fg = applicationPage.getAppForegroundColor(); UIColor bg = applicationPage.getAppBackgroundColor(); UIColor lc = applicationPage.getLineColor(); UIColor dfg = applicationPage.getAppDisabledForegroundColor(); String sdkPath = MainPreferencePage.getAppNativaSDKDirectory(); Application app = ProjectGenerator.createApplicationObject(sdkPath, applicationPage.getPackageName(), fg, bg, lc, dfg); if (applicationPage.isAutoAjustFont()) { app.autoAdjustFontSize.setValue(true); } String rename = applicationPage.getPackageName(); int n = rename.lastIndexOf('.'); if (n != -1) { rename = rename.substring(n + 1); } final MainWindow[] windows = new MainWindow[3]; MainWindow w; app.name.setValue(name); if (applicationPage.isSupportMultipleScreens()) { String s = mainWindowPage.smallSupport.getScreenPointSize().trim(); n = SNumber.intValue(s); if (n > 0) { app.managedScreenSizes.spot_setAttribute("smallScreenPointSize", s); } w = mainWindowPage.getMainWindow(mainWindowPage.smallSupport, rename, title); windows[0] = w; if (applicationPage.isSupportMediumSizeScreens()) { app.managedScreenSizes.setValue(Application.CManagedScreenSizes.small_medium_large); s = mainWindowPage.mediumSupport.getScreenPointSize().trim(); n = SNumber.intValue(s); if (n > 0) { app.managedScreenSizes.spot_setAttribute("mediumScreenPointSize", s); } w = mainWindowPage.getMainWindow(mainWindowPage.mediumSupport, rename, title); w.title.setValue(title); windows[1] = w; } else { app.managedScreenSizes.setValue(Application.CManagedScreenSizes.small_large); } w = mainWindowPage.getMainWindow(mainWindowPage.screenSupport, rename, title); windows[2] = w; if (applicationPage.isAutoFallback()) { app.managedScreenSizes.spot_setAttribute("autoFallback", "true"); } } else { w = mainWindowPage.getMainWindow(mainWindowPage.screenSupport, rename, title); app.setMainWindow(w); } if (applicationPage.wantsDesktopSupport()) { app.desktopIconDensity.setValue(mainWindowPage.screenSupport.getDesktopIconDensity()); String s = w.icon.getValue(); s += ",resource:" + rename + "_icon24"; s += ",resource:" + rename + "_icon32"; s += ",resource:" + rename + "_icon48"; w.icon.setValue(s); } String projectName = applicationPage.getProjectName(); URI location = applicationPage.useDefaults() ? null : applicationPage.getLocationURI(); String packageName = applicationPage.getPackageName(); final String android = applicationPage.wantsAndroidSupport() ? linksPage.getAdroidProjectName(projectName) : null; final String swing = applicationPage.wantsDesktopSupport() ? linksPage.getSwingProjectName(projectName) : null; final String ios = applicationPage.wantsIOSSupport() ? linksPage.getIOSProjectPath(projectName) : null; final ProjectGenerator pg = new ProjectGenerator(projectName, packageName, location, app, windows); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { try { pg.generate(getShell(), monitor, swing, android, ios); } catch (Exception e) { throw new InvocationTargetException(e); } finally { monitor.done(); } } }; try { getContainer().run(true, false, op); } catch (InterruptedException e) { return false; } catch (InvocationTargetException e) { e.printStackTrace(); Throwable realException = e.getTargetException(); MessageDialog.openError(getShell(), "Error", ApplicationException.getMessageEx(realException)); return false; } } catch (Exception e) { Utilities.errorDialogWithStackTrace(Studio.getResourceAsString("Studio.text.newProjectError"), e); } return true; }
From source file:com.aptana.deploy.engineyard.ui.wizard.EngineYardLoginWizardPage.java
License:Open Source License
public boolean validateLogin() { // Try to verify credentials with Engine Yard and write them to a file EngineYardAPI api = new EngineYardAPI(); if (!api.writeCredentials(userId.getText(), password.getText())) { MessageDialog.openError(getShell(), Messages.EngineYardLoginWizardPage_ErrorTitle, Messages.EngineYardLoginWizardPage_InvalidCredentails_Message); return false; }//from ww w.jav a2s . c o m return true; }
From source file:com.aptana.deploy.engineyard.ui.wizard.EngineYardSignupPage.java
License:Open Source License
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NULL); composite.setLayout(new GridLayout()); composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL)); setControl(composite);//w ww . j a v a 2s .c o m initializeDialogUnits(parent); // Actual contents Label label = new Label(composite, SWT.NONE); label.setText(Messages.EngineYardSignupPage_EnterCredentialsLabel); Composite credentials = new Composite(composite, SWT.NONE); credentials.setLayout(new GridLayout(2, false)); Label userIdLabel = new Label(credentials, SWT.NONE); userIdLabel.setText(Messages.EngineYardSignupPage_EmailAddressLabel); userId = new Text(credentials, SWT.SINGLE | SWT.BORDER); userId.setMessage(Messages.EngineYardSignupPage_EmailAddressExample); if (startingUserId != null && startingUserId.trim().length() > 0) { userId.setText(startingUserId); } GridData gd = new GridData(300, SWT.DEFAULT); userId.setLayoutData(gd); Label note = new Label(composite, SWT.WRAP); Font dialogFont = JFaceResources.getDialogFont(); FontData[] data = SWTUtils.italicizedFont(JFaceResources.getDialogFont()); final Font italic = new Font(dialogFont.getDevice(), data); note.setFont(italic); note.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (!italic.isDisposed()) { italic.dispose(); } } }); gd = new GridData(400, SWT.DEFAULT); note.setLayoutData(gd); note.setText(Messages.EngineYardSignupPage_SignupNote); // Add signup button Button signup = new Button(composite, SWT.PUSH); signup.setText(Messages.EngineYardSignupPage_SignupButtonLabel); signup.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { //check if email address is valid if (!isEmailValid(userId.getText())) { MessageDialog.openError(getShell(), "Error", //$NON-NLS-1$ Messages.EngineYardSignupPage_InvalidEmail_Message); return; } // basically just perform finish! if (getWizard().performFinish()) { ((WizardDialog) getContainer()).close(); } } }); Dialog.applyDialogFont(composite); }