List of usage examples for org.eclipse.jface.dialogs MessageDialog MessageDialog
public MessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, int dialogImageType, int defaultIndex, String... dialogButtonLabels)
From source file:com.google.gapid.widgets.TextViewer.java
License:Apache License
public static void showViewTextPopup(Shell shell, Widgets widgets, String title, ListenableFuture<String> text) { new MessageDialog(shell, Messages.VIEW_DETAILS, null, title, MessageDialog.INFORMATION, 0, IDialogConstants.OK_LABEL) { protected LoadablePanel<Text> loadable; @Override//from ww w .j a v a 2 s. c o m protected boolean isResizable() { return true; } @Override protected Control createCustomArea(Composite parent) { loadable = new LoadablePanel<Text>(parent, widgets, panel -> new Text(panel, SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL)); loadable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); loadable.startLoading(); Rpc.listen(text, new UiErrorCallback<String, String, String>(parent, LOG) { @Override protected ResultOrError<String, String> onRpcThread(Rpc.Result<String> result) { try { return success(result.get()); } catch (RpcException e) { return error(e.getMessage()); } catch (ExecutionException e) { return error(e.getCause().toString()); } } @Override protected void onUiThreadSuccess(String result) { loadable.getContents().setText(result); loadable.stopLoading(); } @Override protected void onUiThreadError(String error) { loadable.showMessage(MessageType.Error, error); } }); return loadable; } @Override protected Point getInitialSize() { Point size = super.getInitialSize(); size.y = Math.max(size.y, INITIAL_MIN_HEIGHT); return size; } }.open(); }
From source file:com.google.gdt.eclipse.appsmarketplace.ui.ListOnMarketplaceDialog.java
License:Open Source License
@Override protected void okPressed() { if (listingInProgress == false) { listingInProgress = true;/* w ww . j a va 2 s. c om*/ if (listingType == ListingType.UPDATE) { String message = new String("This will overwrite you existing application listing \"" + DataStorage.getAppListings().get(listingCombo.getSelectionIndex()).name + "\" on Google Apps Marketplace.\n\nDo you want to continue ?"); final MessageDialog messageDialog = new MessageDialog(Display.getDefault().getActiveShell(), "Update Application Listing on Google Apps Marketplace", null, message, MessageDialog.QUESTION, new String[] { "OK", "Cancel" }, 1); if (messageDialog.open() != Window.OK) { super.okPressed(); return; } } deploymentStatus = deployAppsMarketplaceListing(); String messageTitle = new String(); String messageText = new String(); if (deploymentStatus) { try { AppsMarketplaceProjectProperties.setAppListingAlreadyListed(project, true); String consumerKey = DataStorage.getListedAppListing().consumerKey; String consumerSecret = DataStorage.getListedAppListing().consumerSecret; AppsMarketplaceProjectProperties.setAppListingConsumerKey(project, consumerKey); AppsMarketplaceProjectProperties.setAppListingConsumerSecret(project, consumerSecret); } catch (BackingStoreException e) { // Consume exception AppsMarketplacePluginLog.logError(e); } messageTitle = "Successfully created private listing on Google Apps Marketplace"; messageText = "Successfully listed application \'" + appNameText.getText() + "\'" + " on Google Apps Marketplace." + " Click <a href=\"#\">here</a> to view details."; } else { messageTitle = "Failed to created listing on Google Apps Marketplace"; messageText = "Failed to list application \'" + appNameText.getText() + "\'" + " on Google Apps Marketplace." + " Click <a href=\"#\">here</a> to manually create listing."; } this.setMessage(""); this.setTitle(messageTitle); disposeDialogArea(); Composite container = (Composite) this.getDialogArea(); createDescribeLinkArea(container, 1); describeLink.setText(messageText); container.layout(true); getButton(IDialogConstants.CANCEL_ID).setVisible(false); deployButton.setText(FINISH_TEXT); describeLink.addSelectionListener(new DescribeListener()); getShell().redraw(); } else { if (deploymentStatus) { try { String consumerKey = AppsMarketplaceProjectProperties.getAppListingConsumerKey(project); String consumerSecret = AppsMarketplaceProjectProperties.getAppListingConsumerSecret(project); // Set the consumerKey and consumerSecret in web.xml. // Operation may fail. appsMarketplaceProject.setOAuthParams(consumerKey, consumerSecret, true); } catch (CoreException e) { // Consume exception AppsMarketplacePluginLog.logError(e); } } super.okPressed(); } }
From source file:com.google.gdt.eclipse.core.browser.BrowserMenuPopulator.java
License:Open Source License
/** * Find a browser to open url/*from w w w. j ava2s . com*/ */ private void findBrowser() { MessageDialog md = new MessageDialog(SWTUtilities.getShell(), "No browsers found", null, null, MessageDialog.ERROR, new String[] { "Ok" }, 0) { @Override protected Control createMessageArea(Composite parent) { super.createMessageArea(parent); Link link = new Link(parent, SWT.NONE); link.setText("There are no browsers defined, please add one (Right-click on URL -> " + "Open with -> Add a Browser, or <a href=\"#\">Window -> Preferences -> General -> Web Browser</a>)."); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn( Display.getCurrent().getActiveShell(), "org.eclipse.ui.browser.preferencePage", new String[] { "org.eclipse.ui.browser.preferencePage" }, null); if (dialog != null) { dialog.open(); } } }); return parent; } }; md.open(); }
From source file:com.google.gdt.eclipse.core.ui.BackgroundInitiatedYesNoDialog.java
License:Open Source License
private static boolean displayDialogAndGetAnswer(int type, String title, final String message, int defaultPosition) { Shell activeShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); MessageDialog dialog = new MessageDialog(activeShell, title, null, message, type, LABELS, defaultPosition); int selection = dialog.open(); return selection == YesOrNo.YES.ordinal(); }
From source file:com.google.gdt.eclipse.gph.egit.wizard.ImportProjectsWizardPage.java
License:Open Source License
/** * The <code>WizardDataTransfer</code> implementation of this * <code>IOverwriteQuery</code> method asks the user whether the existing * resource at the given path should be overwritten. * /*from w ww . j av a 2 s . co m*/ * @param pathString * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>, * <code>"ALL"</code>, or <code>"CANCEL"</code> */ @Override public String queryOverwrite(String pathString) { Path path = new Path(pathString); String messageString; // Break the message up if there is a file name and a directory // and there are at least 2 segments. if (path.getFileExtension() == null || path.segmentCount() < 2) { messageString = NLS.bind("''{0}'' already exists. Would you like to overwrite it?", pathString); } else { messageString = NLS.bind("Overwrite ''{0}'' in folder ''{1}''?", path.lastSegment(), path.removeLastSegments(1).toOSString()); } final MessageDialog dialog = new MessageDialog(getContainer().getShell(), "Question", null, messageString, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }, 0) { @Override protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL }; // run in syncExec because callback is from an operation, // which is probably not running in the UI thread. getControl().getDisplay().syncExec(new Runnable() { @Override public void run() { dialog.open(); } }); return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()]; }
From source file:com.google.gdt.eclipse.login.GoogleLogin.java
License:Open Source License
private static void showNoBrowsersMessageDialog() { MessageDialog noBrowsersMd = new MessageDialog(Display.getDefault().getActiveShell(), "No browsers found", null, null, MessageDialog.ERROR, new String[] { "Ok" }, 0) { @Override//from w w w. j av a 2s . co m protected Control createMessageArea(Composite parent) { super.createMessageArea(parent); Link link = new Link(parent, SWT.WRAP); link.setText("An embedded browser could not be created for signing in." + "\nAn external browser is needed to sign in, however, none are defined in Eclipse." + "\nPlease add a browser in <a href=\"#\">Window -> Preferences -> General -> Web Browser</a> and sign in again."); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn( Display.getDefault().getActiveShell(), "org.eclipse.ui.browser.preferencePage", new String[] { "org.eclipse.ui.browser.preferencePage" }, null); if (dialog != null) { dialog.open(); } } }); return parent; } }; noBrowsersMd.open(); }
From source file:com.google.gdt.eclipse.suite.preferences.ui.ErrorsWarningsPage.java
License:Open Source License
@Override public boolean performOk() { updateWorkingCopyFromCombos();/*from w ww.j ava 2s . c o m*/ if (!GdtProblemSeverities.getInstance().equals(problemSeveritiesWorkingCopy)) { MessageDialog dialog = new MessageDialog(getShell(), "Errors/Warnings Settings Changed", null, "The Google Error/Warning settings have changed. A full rebuild " + "of all GWT/App Engine projects is required for changes to " + "take effect. Do the full build now?", MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); // Cancel // is // default int result = dialog.open(); if (result == 2) { // Cancel return false; } else { updateWorkspaceSeveritySettingsFromWorkingCopy(); if (result == 0) { // Yes BuilderUtilities.scheduleRebuildAll(GWTNature.NATURE_ID); } } } return true; }
From source file:com.google.gwt.eclipse.core.preferences.ui.GwtPreferencePage.java
License:Open Source License
@Override protected Control createContents(Composite parent) { noDefaultAndApplyButton();//from w w w.j av a 2 s .co m sdkSet = GWTPreferences.getSdks(); return new SdkTable<GWTRuntime>(parent, SWT.NONE, sdkSet, null, this) { @Override protected IStatus doAddSdk() { AddSdkDialog<GWTRuntime> addGaeSdkDialog = new AddGwtSdkDialog(getShell(), sdkSet, GWTPlugin.PLUGIN_ID, "Add Google Web Toolkit SDK", GWTRuntime.getFactory()); if (addGaeSdkDialog.open() == Window.OK) { GWTRuntime newSdk = addGaeSdkDialog.getSdk(); if (newSdk != null) { sdkSet.add(newSdk); } return Status.OK_STATUS; } return Status.CANCEL_STATUS; } @Override protected IStatus doDownloadSdk() { MessageDialog dialog = new MessageDialog(GWTPlugin.getActiveWorkbenchShell(), "Google Eclipse Plugin", null, "Would you like to open the Google Web Toolkit download page in your " + "web browser?\n\nFrom there, you can " + "download the latest GWT SDK and extract it to the" + " location of your choice. Add it to Eclipse" + " with the \"Add...\" button.", MessageDialog.QUESTION, new String[] { "Open Browser", IDialogConstants.CANCEL_LABEL }, 0); if (dialog.open() == Window.OK) { if (BrowserUtilities.launchBrowserAndHandleExceptions(GWTPlugin.SDK_DOWNLOAD_URL) == null) { return Status.CANCEL_STATUS; } } else { return Status.CANCEL_STATUS; } return Status.OK_STATUS; } }; }
From source file:com.google.gwt.eclipse.core.properties.ui.GWTProjectPropertyPage.java
License:Open Source License
/** * Removes all GWT SDK jars and replaces it with a single container entry, adds GWT nature and * optionally the web app nature.//from w ww .j a v a2 s .co m * * @throws BackingStoreException * @throws FileNotFoundException * @throws FileNotFoundException */ private void addGWT() throws CoreException, BackingStoreException, FileNotFoundException { IProject project = getProject(); IJavaProject javaProject = JavaCore.create(project); /* * Set the appropriate web app project properties if this is a J2EE project. * * There can be a collision between different property pages manipulating the same web app * properties, but the collision actually works itself out. * * Both the GWT and GAE property pages make a call to this method. So, there are no * conflicting/differing settings of the web app project properties in this case. * * In the event that the GAE/GWT natures are enabled and the Web App property page does not have * the "This Project Has a War Directory" setting selected, and that setting is enabled, then * the settings on the Web App project page will take precedence (over those settings that are * set by this method call). * * The gory details as to why have to do with the order of application of the properties for * each page (App Engine, Web App, then GWT), and the fact that this method will not make any * changes to Web App properties if the project is already a Web App. */ WebAppProjectProperties.maybeSetWebAppPropertiesForDynamicWebProject(project); if (sdkSelectionBlock.hasSdkChanged() && !GWTProjectsRuntime.isGWTRuntimeProject(javaProject)) { SdkSelection<GWTRuntime> sdkSelection = sdkSelectionBlock.getSdkSelection(); boolean isDefault = false; GWTRuntime newSdk = null; if (sdkSelection != null) { newSdk = sdkSelection.getSelectedSdk(); isDefault = sdkSelection.isDefault(); } GWTRuntime oldSdk = sdkSelectionBlock.getInitialSdk(); UpdateType updateType = GWTUpdateProjectSdkCommand.computeUpdateType(oldSdk, newSdk, isDefault); GWTUpdateProjectSdkCommand updateProjectSdkCommand = new GWTUpdateProjectSdkCommand(javaProject, oldSdk, newSdk, updateType, null); /* * Update the project classpath which will trigger the <WAR>/WEB-INF/lib jars to be updated. */ updateProjectSdkCommand.execute(); } GWTNature.addNatureToProject(project); // Need to rebuild to get GWT errors to appear BuilderUtilities.scheduleRebuild(project); // only prompt to reopen editors if the transition from disabled -> enabled if (!initialUseGWT && useGWT) { // Get the list of Java editors opened on files in this project IEditorReference[] openEditors = getOpenJavaEditors(project); if (openEditors.length > 0) { MessageDialog dlg = new MessageDialog(GWTPlugin.getActiveWorkbenchShell(), GWTPlugin.getName(), null, "GWT editing functionality, such as syntax-colored JSNI blocks, " + "will only be enabled after you re-open your Java editors.\n\nDo " + "you want to re-open your editors now?", MessageDialog.QUESTION, new String[] { "Re-open Java editors", "No" }, 0); if (dlg.open() == IDialogConstants.OK_ID) { reopenWithGWTJavaEditor(openEditors); } } } }
From source file:com.google.gwt.eclipse.core.properties.ui.GWTProjectPropertyPage.java
License:Open Source License
public void addGWT(IProject project, GWTRuntime runtime) throws BackingStoreException, FileNotFoundException, CoreException { IJavaProject javaProject = JavaCore.create(project); // TODO this causes some issue with dialog popup and war output folder selection WebAppProjectProperties.maybeSetWebAppPropertiesForDynamicWebProject(project); // if (sdkSelectionBlock.hasSdkChanged() && // !GWTProjectsRuntime.isGWTRuntimeProject(javaProject)) { boolean isDefault = false; GWTRuntime newSdk = runtime;/*from w ww. j a v a 2s .c om*/ GWTRuntime oldSdk = runtime; UpdateType updateType = GWTUpdateProjectSdkCommand.computeUpdateType(oldSdk, newSdk, isDefault); GWTUpdateProjectSdkCommand updateProjectSdkCommand = new GWTUpdateProjectSdkCommand(javaProject, oldSdk, newSdk, updateType, null); /* * Update the project classpath which will trigger the <WAR>/WEB-INF/lib jars to be updated. */ updateProjectSdkCommand.execute(); // } GWTNature.addNatureToProject(project); // Need to rebuild to get GWT errors to appear BuilderUtilities.scheduleRebuild(project); // only prompt to reopen editors if the transition from disabled -> enabled if (!initialUseGWT && useGWT) { // Get the list of Java editors opened on files in this project IEditorReference[] openEditors = getOpenJavaEditors(project); if (openEditors.length > 0) { MessageDialog dlg = new MessageDialog(GWTPlugin.getActiveWorkbenchShell(), GWTPlugin.getName(), null, "GWT editing functionality, such as syntax-colored JSNI blocks, " + "will only be enabled after you re-open your Java editors.\n\nDo " + "you want to re-open your editors now?", MessageDialog.QUESTION, new String[] { "Re-open Java editors", "No" }, 0); if (dlg.open() == IDialogConstants.OK_ID) { reopenWithGWTJavaEditor(openEditors); } } } }