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.ibm.domino.osgi.debug.actions.CreateNotesJavaApiProject.java
License:Open Source License
/** * The action has been activated. The argument of the * method represents the 'real' action sitting * in the workbench UI./* w w w . j ava 2 s .c o m*/ * @see IWorkbenchWindowActionDelegate#run */ public void run(IAction action) { if (exists(getBinDirectoryFromPreferenceStore())) { doCreateNotesJavaApiProject(); return; } int status = 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) { @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() { /* * (non-Javadoc) * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetSelected(SelectionEvent e) { doLinkActivated(); } /* * Open the appropriate preference page */ private void doLinkActivated() { String id = "com.ibm.domino.osgi.debug.preferences.DominoOSGiDebugPreferencePage"; PreferencesUtil.createPreferenceDialogOn(window.getShell(), id, new String[] { id }, null) .open(); updateButtons(); } public void widgetDefaultSelected(SelectionEvent e) { doLinkActivated(); } }); return link; } private void updateButtons() { getButton(0).setEnabled(exists(getBinDirectoryFromPreferenceStore())); } protected Control createContents(Composite parent) { Control ctrl = super.createContents(parent); updateButtons(); return ctrl; }; }.open(); if (status == MessageDialog.OK) { doCreateNotesJavaApiProject(); } }
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; }/*from w w w.j a v a2 s . c om*/ } 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.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 www . ja v a 2s . com 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.tooling.panels.applicationlayout.ApplicationLayoutBasicsPanel.java
License:Open Source License
private boolean showConfigWarning() { String msg = "If you change the configuration, all attribute values associated with the current configuration will be lost. Do you want to continue?"; // $NLX-ApplicationLayoutBasicsPanel.Youareabouttochangetheconfigurati-1$ MessageDialog dlg = new MessageDialog(getShell(), "Domino Designer", // $NLX-ApplicationLayoutDropDialog.Dominodesigner-1$ null, // image msg, MessageDialog.WARNING, new String[] { "Continue", "Cancel" }, // $NLX-ApplicationLayoutBasicsPanel.Continue-1$ $NLX-ApplicationLayoutBasicsPanel.Cancel-2$ 1);/*w w w.jav a 2s .com*/ int code = dlg.open(); // "Continue" was returning 256.. but then started returning 0 at some point...did SWT version change (it was pending)? boolean bShouldContinue = (code == MessageDialog.OK); //Only continue if 'OK' (Continue) is pressed - otherwise bail out return bShouldContinue; }
From source file:com.ibm.xsp.extlib.designer.tooling.utils.WizardUtils.java
License:Open Source License
public static boolean displayContinueDialog(Shell shell, String title, String msg) { MessageDialog dialog = new MessageDialog(shell, title, null, msg, MessageDialog.WARNING, new String[] { "Continue", "Cancel" }, 0); // $NLX-WizardUtils.Continue-1$ $NLX-WizardUtils.Cancel-2$ return (dialog.open() == 0); }
From source file:com.iw.plugins.spindle.ui.properties.ProjectPropertyPage.java
License:Mozilla Public License
private void doOk(IProgressMonitor monitor) throws CoreException { // store the values as properties IResource resource = (IResource) getElement(); // resource.setPersistentProperty( // new QualifiedName("", PROJECT_TYPE_PROPERTY), // new Integer(TapestryProject.APPLICATION_PROJECT_TYPE).toString()); resource.setPersistentProperty(new QualifiedName("", CONTEXT_ROOT_PROPERTY), fWebContextRoot.getText()); resource.setPersistentProperty(new QualifiedName("", VALIDATE_WEBXML_PROPERTY), Boolean.toString(fValidateWebXML.getSelection())); final IProject workspaceProject = (IProject) (this.getElement().getAdapter(IProject.class)); IWorkspaceRunnable runnable = new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { if (fIsTapestryProjectCheck.getSelection()) { String projectName = workspaceProject.getProject().getName(); String temp = fWebContextRoot.getText(); createFolderIfRequired(projectName + temp); fNewProjectMetadata.setWebContext(temp); fNewProjectMetadata.setValidateWebXML(fValidateWebXML.getSelection()); fNewProjectMetadata.saveProperties(monitor); IJavaProject jproject = getJavaProject(); TapestryProject prj = getTapestryProject(); if (prj == null) { TapestryProject.addTapestryNature(jproject, true); } else { prj.clearMetadata(); }/*from w w w .j a v a2s . c o m*/ try { if (jproject .findType(TapestryCore.getString("TapestryComponentSpec.specInterface")) == null) { MessageDialog dialog = new MessageDialog(getShell(), "Tapestry jars missing", null, "Add the Tapestry jars to the classpath?", MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0); // OK is the default int result = dialog.open(); if (result == 0) { List entries = Arrays.asList(jproject.getRawClasspath()); ArrayList useEntries = new ArrayList(entries); useEntries.add(JavaCore.newContainerEntry(new Path(TapestryCore.CORE_CONTAINER))); jproject.setRawClasspath( (IClasspathEntry[]) useEntries.toArray(new IClasspathEntry[entries.size()]), monitor); } } } catch (JavaModelException e) { UIPlugin.log(e); } } else { TapestryProject.removeTapestryNature(getJavaProject()); } if (fIsTapestryProjectCheck.getSelection()) { IProject project = getJavaProject().getProject(); project.build(IncrementalProjectBuilder.FULL_BUILD, monitor); } } }; UIPlugin.getWorkspace().run(runnable, monitor); }
From source file:com.javapathfinder.vjp.config.editors.ModePropertyEditorComposite.java
License:Open Source License
private Composite createFileInfoUI(Composite parent) { Group group = new Group(parent, SWT.NULL); group.setText("Configuration file location:"); group.setLayout(new FormLayout()); Button button = new Button(group, SWT.NULL); button.setText("Move/Rename"); FormData buttonData = new FormData(); buttonData.right = new FormAttachment(100, -5); button.setLayoutData(buttonData);//from w w w. ja v a 2 s . c o m button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { IPath path = getNewPath(); if (path == null) return; int matches = path.matchingFirstSegments(ResourcesPlugin.getWorkspace().getRoot().getLocation()); path = path.removeFirstSegments(matches).makeAbsolute(); try { properties.getIFile().move(path, true, null); properties.getIFile().refreshLocal(IFile.DEPTH_INFINITE, null); refreshDialog(properties.getIFile()); } catch (CoreException e1) { VJP.logError("Could not move property file.", e1); } } private void refreshDialog(IFile file) { ((LaunchDialog) (getShell().getData())).updateTree(); } private IPath getNewPath() { ModePropertyFileDialog dialog = new ModePropertyFileDialog(getShell(), properties); IFile file = dialog.getFile(); IProject project = dialog.getFileProject(); if (project == null) { new MessageDialog(getShell(), "Invalid Mode Property Location", null, "Mode Property Files must be kept within a project", MessageDialog.ERROR, new String[] { "OK" }, 0).open(); return null; } if (file.equals(properties.getIFile())) return null; return file.getLocation(); } }); Text configPathField = new Text(group, SWT.SINGLE | SWT.LEFT); configPathField.setText(properties.getIFile().getProjectRelativePath().toOSString()); configPathField.setEditable(false); FormData textData = new FormData(); textData.left = new FormAttachment(0, 10); textData.right = new FormAttachment(button, -5); Point buttonsize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT); Point textsize = configPathField.computeSize(SWT.DEFAULT, SWT.DEFAULT); int diff = Math.abs(buttonsize.y - textsize.y); diff /= 2; textData.top = new FormAttachment(0, diff); configPathField.setLayoutData(textData); return group; }
From source file:com.javapathfinder.vjp.config.editors.userdefined.UserDefinedPropertiesTab.java
License:Open Source License
private Composite createButtons(Composite parent, int style) { Composite main = new Composite(parent, style); main.setLayout(new FillLayout(SWT.VERTICAL)); add = new Button(main, SWT.PUSH); add.setText("Add Property"); add.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { AddPropertyDialog addDialog = new AddPropertyDialog(getShell()); Property property = addDialog.open(); if (property == null) return; if (properties.isDefaultProperty(property.getName())) { new MessageDialog(getParent().getShell(), "Property is already defined.", null, "The property '" + property.getName() + "' is" + " already defined in the default properties." + " Please change its value there.", MessageDialog.WARNING, new String[] { "OK" }, 0).open(); return; }/* w w w. j a v a 2 s . c om*/ properties.setProperty(property); viewer.repackColumns(); viewer.refresh(); } }); remove = new Button(main, SWT.PUSH); remove.setText("Remove Property"); remove.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { for (TableItem item : viewer.getTable().getSelection()) { Property p = ((Property) item.getData()); properties.removeProperty(p); } viewer.refresh(); } }); return main; }
From source file:com.javapathfinder.vjp.config.LaunchDialog.java
License:Open Source License
private boolean shouldVerify() { if (VerifyJob.isRunning()) { new MessageDialog(getShell(), "Program being verified.", null, "Only one program can be verified at a time.", MessageDialog.ERROR, new String[] { "OK" }, 0) .open();/*from www . j a v a2 s. c o m*/ return false; } if (!editor.isDirty()) return true; MessageDialog dialog = new MessageDialog(getShell(), "Save Changes?", null, "Before the program can be verified changes made to the configuration must first be saved.", MessageDialog.ERROR, new String[] { "&Save New Properties and Verify", "&Revert to Old Properties and Verify", "&Cancel" }, 2); int option = dialog.open(); if (option == 0) editor.saveProperties(); else if (option == 1) editor.revertProperties(); else return false; return true; }
From source file:com.javapathfinder.vjp.config.LaunchDialog.java
License:Open Source License
private void handleNewFile() { ModePropertyFileDialog dialog = new ModePropertyFileDialog(getShell()); IFile file = dialog.getFile();//from ww w .ja va2s .c om if (file == null) return; IProject project = dialog.getFileProject(); if (project == null) { new MessageDialog(getShell(), "Invalid Mode Property File location", null, "Mode Property Files can only be stored within a project.", MessageDialog.ERROR, new String[] { "OK" }, 0).open(); return; } if (file.exists()) { new MessageDialog(getShell(), "File already exists.", null, "This file location chosen already exists.", MessageDialog.ERROR, new String[] { "OK" }, 0).open(); return; } try { file.getLocation().toFile().getParentFile().mkdirs(); file.getLocation().toFile().createNewFile(); file.refreshLocal(IResource.DEPTH_INFINITE, null); } catch (Exception e) { VJP.logError("File could not be created or refreshed", e); } updateTree(); }