List of usage examples for org.eclipse.jface.dialogs MessageDialog openQuestion
public static boolean openQuestion(Shell parent, String title, String message)
From source file:com.htmlhifive.tools.wizard.ui.property.LibraryImportPropertyPage.java
License:Apache License
/** * Nature??./*from w w w . j ava2 s.c o m*/ * * @param project * @param natureId NatureID * @return ??????. */ private boolean addNature(IProject project, String natureId) { // JSNature?. if (MessageDialog.openQuestion(getShell(), Messages.SE0119.format(), Messages.SE0120.format(getTitle()))) { // ?. final ResultStatus logger = new ResultStatus(); try { // . final IRunnableWithProgress downloadRunnable = getAddNatureRunnnable(logger, project, natureId); ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); dialog.run(false, false, downloadRunnable); // ?????. return true; } catch (InvocationTargetException e) { final Throwable ex = e.getTargetException(); H5LogUtils.putLog(ex, Messages.SE0025); } catch (InterruptedException e) { logger.setInterrupted(true); // We were cancelled... //removeProject(logger); } finally { // // ?. // logger.showDialog(Messages.PI0138); if (logger.isSuccess()) { return true; } // ??(??). container.refreshTreeLibrary(false, true); // SE0103=INFO,????? logger.log(Messages.SE0103); } } return false; }
From source file:com.ibm.domino.osgi.debug.actions.CreateNotesJavaApiProject.java
License:Open Source License
private void doCreateNotesJavaApiProject() { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); final IProject project = root.getProject(JAVA_API_PROJECT_NAME); if (project.exists()) { boolean bContinue = MessageDialog.openQuestion(window.getShell(), "Debug plug-in for Domino OSGi", MessageFormat.format("Project {0} already exists. Would you like to update it?", JAVA_API_PROJECT_NAME)); if (!bContinue) { return; }/*www. jav a 2 s .co m*/ } String binDirectory = Activator.getDefault().getPreferenceStore() .getString(PreferenceConstants.PREF_DOMINO_BIN_DIR); if (binDirectory == null || binDirectory.length() == 0) { int ret = new MessageDialog(window.getShell(), "Question", null, "Domino Bin directory not set, please click on the link to set it", MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0) { /* * (non-Javadoc) * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite) */ @Override protected Control createCustomArea(Composite parent) { Link link = new Link(parent, SWT.NONE); link.setFont(parent.getFont()); link.setText("<A>Domino Debug Plugin Preferences....</A>"); link.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { doLinkActivated(); } private void doLinkActivated() { String id = "com.ibm.domino.osgi.debug.preferences.DominoOSGiDebugPreferencePage"; PreferencesUtil .createPreferenceDialogOn(window.getShell(), id, new String[] { id }, null) .open(); } public void widgetDefaultSelected(SelectionEvent e) { doLinkActivated(); } }); return link; } }.open(); if (ret == 1) { return; } } binDirectory = Activator.getDefault().getPreferenceStore() .getString(PreferenceConstants.PREF_DOMINO_BIN_DIR); if (binDirectory == null || binDirectory.length() == 0) { MessageDialog.openError(window.getShell(), "Error", "Domino Bin directory not set"); return; } try { final String sBinDir = binDirectory; new ProgressMonitorDialog(window.getShell()).run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { if (!project.exists()) { project.create(monitor); } project.open(monitor); IProjectDescription description = project.getDescription(); String[] natures = description.getNatureIds(); String[] newNatures = new String[natures.length + 2]; System.arraycopy(natures, 0, newNatures, 0, natures.length); newNatures[natures.length] = JavaCore.NATURE_ID; newNatures[natures.length + 1] = "org.eclipse.pde.PluginNature"; description.setNatureIds(newNatures); project.setDescription(description, monitor); //Copy the resources under res copyOneLevel(project, monitor, "res", ""); //Copy notes.jar File notesJar = new File(sBinDir + "/jvm/lib/ext/Notes.jar"); if (!notesJar.exists() || !notesJar.isFile()) { MessageDialog.openError(window.getShell(), "Error", MessageFormat.format("{0} does not exist", notesJar.getAbsolutePath())); return; } copyFile(notesJar, project.getFile("Notes.jar"), monitor); } catch (Throwable t) { throw new InvocationTargetException(t); } } }); } catch (Throwable t) { MessageDialog.openError(window.getShell(), "error", t.getMessage()); t.printStackTrace(); } }
From source file:com.ibm.domino.osgi.debug.launch.AbstractDominoOSGILaunchConfiguration.java
License:Open Source License
/** * @param osgiConfig/* ww w. java2 s . c o m*/ * @return * @throws IOException */ private File getPDELaunchIni(DominoOSGIConfig osgiConfig) throws IOException { File notesDataDir = new File(osgiConfig.getDominoDataPath()); if (!notesDataDir.exists()) { throw new IOException( MessageFormat.format("Data directory does not exist {0}", osgiConfig.getDominoDataPath())); } final File dominoWorkspaceDir = new File(notesDataDir, getWorkspaceRelativePath()); if (!dominoWorkspaceDir.exists() || !dominoWorkspaceDir.isDirectory()) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); boolean bCreate = MessageDialog.openQuestion(shell, "Question", MessageFormat.format( "The directory \"{0}\" does not exist.\nThis may be because the OSGi configuration has never been run previously.\nWould you like to create it?", dominoWorkspaceDir.getAbsolutePath())); if (bCreate) { dominoWorkspaceDir.mkdirs(); } } }); } if (!dominoWorkspaceDir.exists() || !dominoWorkspaceDir.isDirectory()) { throw new AbortException(); } return new File(dominoWorkspaceDir, "pde.launch.ini"); }
From source file:com.ibm.research.tagging.core.ui.tags.TagViewListener.java
License:Open Source License
public void deleteTag(TagView view) { IStructuredSelection tagSelection = (IStructuredSelection) view.getTagTableViewer().getSelection(); boolean doIt = true; if (!MessageDialog.openQuestion(view.getSite().getShell(), "Tag View", "Are you sure you want to delete the selected tag(s)?")) doIt = false;/*w ww. ja v a2s . c om*/ if (doIt) { for (Object o : tagSelection.toArray()) { ITag tag = (ITag) o; TagCorePlugin.getDefault().getTagCore().getTagModel().removeTag(tag); } } }
From source file:com.ibm.research.tagging.core.ui.tags.TagViewListener.java
License:Open Source License
public void deleteUnusedTags(TagView view) { if (MessageDialog.openQuestion(view.getSite().getShell(), "Delete unused tags", "Are you sure you want to delete all un-used tags?")) { ITagModel collection = TagCorePlugin.getDefault().getTagCore().getTagModel(); for (ITag tag : collection.getTags()) if (tag.getWaypointCount() == 0) collection.removeTag(tag); }/*from w w w. ja v a 2 s .c o m*/ }
From source file:com.ibm.research.tagging.core.ui.waypoints.WaypointViewListener.java
License:Open Source License
public void deleteWaypoint(WaypointView view) { IStructuredSelection waypointSelection = (IStructuredSelection) view.getWaypointTableViewer() .getSelection();// www. j a v a2 s . c o m boolean doIt = true; if (!MessageDialog.openQuestion(view.getSite().getShell(), "Waypoint View", "Are you sure you want to delete the selected waypoints?")) doIt = false; if (doIt) { for (Object o : waypointSelection.toArray()) { IWaypoint waypoint = (IWaypoint) o; TagCorePlugin.getDefault().getTagCore().getWaypointModel().removeWaypoint(waypoint); } } }
From source file:com.ibm.research.tours.actions.RunTourActionDelegate.java
License:Open Source License
public void run(IAction action) { Object[] selection = fSelection.toArray(); for (Object selected : selection) { if (selected instanceof IFile) { IFile file = (IFile) selected; try { ITour tour = XMLTourFactory.createTour(file); boolean open = true; if (tour != null && tour.getElementCount() == 0) { if (!MessageDialog.openQuestion(fTargetPart.getSite().getShell(), "Run Tour", "This tour contains no runnable elements, open anyway?")) open = false;/*from w ww .j av a 2s .com*/ } if (open) { ToursPlugin.getDefault().getTourRuntime().run(tour); } } catch (CoreException e) { MessageBox box = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); box.setText("Error opening tour"); box.setMessage(e.getMessage()); box.open(); e.printStackTrace(); } } } }
From source file:com.ibm.xsp.extlib.designer.bluemix.action.DeployAction.java
License:Open Source License
public static void deployWithQuestion() { if (ToolbarAction.project != null) { ManifestMultiPageEditor editor = BluemixUtil.getManifestEditor(ToolbarAction.project); if (editor != null) { if (editor.isDirty()) { MessageDialog dg = new MessageDialog(null, _DEPLOY_TXT, null, "Do you want to save the Manifest before deployment?", // $NLX-DeployAction.DoyouwanttosavetheManifest-1$ MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0);//from w ww . j a v a2s. c o m switch (dg.open()) { case 0: //yes editor.doSave(null); break; case 1: //no break; case 2: //cancel return; } } } // Check for a valid configuration BluemixConfig config = ConfigManager.getInstance().getConfig(ToolbarAction.project); if (config.isValid(true)) { // Check the Server configuration if (BluemixUtil.isServerConfigured()) { // All good - Deploy !!! DeployJob job = new DeployJob(config, ToolbarAction.project); job.start(); } else { // Server configuration problem BluemixUtil.displayConfigureServerDialog(); } } else { if (config.isValid(false)) { // Something is wrong with the Manifest if (ManifestUtil.doesManifestExist(config)) { // Corrupt String msg = "The Manifest for this application is invalid. Cannot deploy."; // $NLX-DeployAction.TheManifestforthisapplicationisin-1$ MessageDialog.openError(null, _DEPLOY_TXT, msg); } else { // Missing String msg = "The Manifest for this application is missing. Do you want to open the Configuration Wizard?"; // $NLX-DeployAction.TheManifestforthisapplicationismi-1$ if (MessageDialog.openQuestion(null, _DEPLOY_TXT, msg)) { ConfigBluemixWizard.launch(); } } } else { // App has not been configured or the bluemix.properties file is missing or corrupt String msg = "This application is not configured for deployment. Do you want to open the Configuration Wizard?"; // $NLX-DeployAction.Thisapplicationisnotconfiguredfor-1$ if (MessageDialog.openQuestion(null, _DEPLOY_TXT, msg)) { ConfigBluemixWizard.launch(); } } } } else { MessageDialog.openError(null, _DEPLOY_TXT, "No application has been selected or the selected application is not open."); // $NLX-DeployAction.Noapplicationhasbeenselectedorthe-1$ } }
From source file:com.ibm.xsp.extlib.designer.bluemix.job.ImportJob.java
License:Open Source License
@Override protected IStatus run(final IProgressMonitor monitor) { monitor.beginTask("Importing starter code", IProgressMonitor.UNKNOWN); // $NLX-ImportJob.ImportingStarterCode-1$ try {/*from w ww .ja va2 s . c om*/ // Get the NSF name from the zip file final String nsfName = BluemixZipUtil.getNsfFromZipFile(new File(_zipFileName)); if (StringUtil.isEmpty(nsfName)) { throw new Exception("There is no NSF in the starter code zip file"); // $NLX-ImportJob.ThereisnoNSFintheStarterCodeZIPFi-1$ } // Construct the target NSF name - c:\notes\data\xxx.nsf final String targetNsfName = BluemixUtil.getNotesDataDir() + File.separator + nsfName; // Check if the target NSF is open in Designer DominoDesignerProject ddp = BluemixUtil.getDesignerProjectFromWorkspace(nsfName); if (ddp != null) { // Delete the project and NSF final DeleteResourceAction delAction = new DeleteResourceAction(true, new File(targetNsfName).exists()); delAction.selectionChanged(new StructuredSelection(ddp)); Display.getDefault().syncExec(new Runnable() { public void run() { delAction.run(); } }); if (monitor.isCanceled()) return Status.CANCEL_STATUS; // Wait on the delete jobs to complete before continuing IJobManager jobManager = Job.getJobManager(); jobManager.join(IDEWorkbenchMessages.DeleteResourceAction_checkJobName, new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN)); jobManager.join(IDEWorkbenchMessages.DeleteResourceAction_jobName, new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN)); if (monitor.isCanceled()) return Status.CANCEL_STATUS; // Is everything clean (Project and NSF should be gone) ??? // User may have cancelled or there was an error if ((BluemixUtil.getDesignerProjectFromWorkspace(nsfName) != null) || (new File(targetNsfName).exists())) { // Just finish - can't do anything else return Status.CANCEL_STATUS; } } // If the target NSF still exists at this point then it wasn't // open in Designer - Delete it now if (new File(targetNsfName).exists()) { // Ask the user for confirmation final boolean[] continueJob = new boolean[1]; PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { String msg = StringUtil.format( "\"{0}\" will be overwritten, do you want to continue with this import?", targetNsfName); // $NLX-ImportJob.0willbeoverwrittendoyouwanttocont-1$ continueJob[0] = MessageDialog.openQuestion(null, "Importing Starter Code", msg); // $NLX-ImportJob.ImportingStarterCode.1-1$ } }); if (!continueJob[0]) { // User has cancelled return Status.CANCEL_STATUS; } _threadException = null; NotesPlatform.getInstance().syncExec(new Runnable() { public void run() { Database db = null; try { // Delete the existing NSF monitor.subTask("Deleting database..."); // $NLX-ImportJob.Deletingdatabase-1$ Session sess = NotesPlatform.getInstance().getSession(); db = sess.getDatabase(null, nsfName); db.remove(); } catch (Throwable e) { // Record the Exception _threadException = e; } finally { if (db != null) { try { db.recycle(); } catch (NotesException e) { if (BluemixLogger.BLUEMIX_LOGGER.isErrorEnabled()) { BluemixLogger.BLUEMIX_LOGGER.errorp(this, "run", e, "Failed to recycle db"); // $NON-NLS-1$ $NLE-ImportJob.Failedtorecycledb-2$ } } } } } }); if (_threadException != null) { throw new Exception("Could not delete database", _threadException); // $NLX-ImportJob.Couldnotdeletedatabase-1$ } } if (monitor.isCanceled()) return Status.CANCEL_STATUS; monitor.subTask("Unzipping the starter code zip file..."); // $NLX-ImportJob.UnzippingtheStarterCodeZIPfile-1$ BluemixZipUtil.unzipFile(_zipFileName, _config.directory); if (monitor.isCanceled()) return Status.CANCEL_STATUS; // Copy the DB to the data directory monitor.subTask("Copying NSF to data directory"); // $NLX-ImportJob.CopyingNSFtodatadirectory-1$ // Make a copy or use the actual NSF ? if (StringUtil.equalsIgnoreCase(_importCopyMethod, "copy") || StringUtil.equalsIgnoreCase(_importCopyMethod, "replica")) { // $NON-NLS-1$ $NON-NLS-2$ // We need a thread for this _threadException = null; NotesPlatform.getInstance().syncExec(new Runnable() { public void run() { Database db = null; try { Session sess = NotesPlatform.getInstance().getSession(); db = sess.getDatabase(null, BluemixUtil.getNsfFromDirectory(_config.directory).getPath()); if (StringUtil.equalsIgnoreCase(_importCopyMethod, "copy")) { // $NON-NLS-1$ BluemixUtil.createLocalDatabaseCopy(db, nsfName); } else { BluemixUtil.createLocalDatabaseReplica(db, nsfName); } } catch (Throwable e) { // Record the Exception _threadException = e; } finally { if (db != null) { try { db.remove(); db.recycle(); } catch (NotesException e) { if (BluemixLogger.BLUEMIX_LOGGER.isErrorEnabled()) { BluemixLogger.BLUEMIX_LOGGER.errorp(this, "run", e, "Failed to remove/recycle db"); // $NON-NLS-1$ $NLE-ImportJob.Failedtorecycledb.1-2$ } } } } } }); if (_threadException != null) { throw new Exception("Could not copy database", _threadException); // $NLX-ImportJob.Couldnotcopydatabase-1$ } } else { // Use the actual database from the ZIP file // It will have the same replicaID BluemixUtil.copyFile(BluemixUtil.getNsfFromDirectory(_config.directory), new File(targetNsfName)); } if (monitor.isCanceled()) return Status.CANCEL_STATUS; // Open the newly copied NSF in Designer _threadException = null; Display.getDefault().syncExec(new Runnable() { public void run() { try { if (DominoResourcesPlugin.canEditDbWithError("Local", nsfName)) { // $NON-NLS-1$ final NsfDbInfo info = DominoResourcesPlugin.addToNotesWorkspace("Local", nsfName); // $NON-NLS-1$ if (info != null) { DominoResourcesPlugin.createDominoDesignerProject(info, new JobChangeAdapter() { public void done(IJobChangeEvent event) { super.done(event); // Create the link to the deployment directory DominoDesignerProject ddp = BluemixUtil .getDesignerProjectFromWorkspace(info.getFullPath()); if (ddp != null) { ConfigManager.getInstance().setConfig(ddp, _config, false, null); } } }); } else { throw new Exception("addToNotesWorkspace returned null"); // $NLX-ImportJob.addToNotesWorkspacereturnednull-1$ } } else { throw new Exception("canEditDbWithError returned false"); // $NLX-ImportJob.canEditDbWithErrorreturnedfalse-1$ } } catch (Throwable e) { // Record the Exception _threadException = e; } } }); // Did the NSF open successfully? if (_threadException != null) { // No throw exception throw new Exception("Error opening starter code project", _threadException); // $NLX-ImportJob.ErroropeningStarterCodeproject-1$ } } catch (Throwable e) { StatusAdapter status = new StatusAdapter( new Status(IStatus.ERROR, BluemixPlugin.PLUGIN_ID, 0, BluemixUtil.getErrorText(e), null)); status.setProperty(IStatusAdapterConstants.TITLE_PROPERTY, e.getMessage()); StatusManager.getManager().handle(status, StatusManager.BLOCK); if (BluemixLogger.BLUEMIX_LOGGER.isErrorEnabled()) { BluemixLogger.BLUEMIX_LOGGER.errorp(this, "run", BluemixUtil.getRootCause(e), "Error importing starter code"); // $NON-NLS-1$ $NLE-ImportJob.ErrorimportingStarterCode-2$ } } return Status.OK_STATUS; }
From source file:com.ibm.xsp.extlib.designer.bluemix.manifest.editor.ManifestHybridEditorPage.java
License:Open Source License
private void createOptionsArea(Composite parent) { Section section = XSPEditorUtil.createSection(_toolkit, parent, "Configuration Options", 1, 1); // $NLX-ManifestHybridEditorPage.ConfigurationOptions-1$ Composite container = XSPEditorUtil.createSectionChild(section, 1); Composite btnContainer = new Composite(container, SWT.NONE); GridLayout gl = SWTLayoutUtils.createLayoutNoMarginDefaultSpacing(2); gl.horizontalSpacing = 5;//ww w .j ava2s .com btnContainer.setLayout(gl); btnContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); btnContainer.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); Button btn = new Button(btnContainer, SWT.PUSH); btn.setText("Load hybrid profile..."); // $NLX-ManifestHybridEditorPage.Loadhybridprofile-1$ btn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { HybridProfileDialog dialog = new HybridProfileDialog(getShell()); if (dialog.open() == Dialog.OK) { loadProfile(dialog.getSelectedProfile()); _mpe.refreshPage(ManifestHybridEditorPage.this); } } }); btn = new Button(btnContainer, SWT.PUSH); btn.setText("Delete this configuration"); // $NLX-ManifestHybridEditorPage.Deletethisconfiguration-1$ btn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { String msg = "Are you sure you want to remove this hybrid configuration from the manifest?"; // $NLX-ManifestHybridEditorPage.Areyousureyouwanttoremovethishyri-1$ if (MessageDialog.openQuestion(null, BluemixUtil.productizeString("%BM_PRODUCT% Manifest"), msg)) { // $NLX-ManifestHybridEditorPage.BM_PRODUCTManifest-1$ loadProfile(null); _mpe.refreshPage(ManifestHybridEditorPage.this); } } }); section.setClient(container); }