List of usage examples for org.eclipse.jface.dialogs MessageDialog QUESTION_WITH_CANCEL
int QUESTION_WITH_CANCEL
To view the source code for org.eclipse.jface.dialogs MessageDialog QUESTION_WITH_CANCEL.
Click Source Link
From source file:com.persistent.winazureroles.WARComponents.java
License:Open Source License
/** * Listener method for remove button which * deletes the selected component.//from www . j av a 2 s . c o m */ protected void removeBtnListener() { int selIndex = tblViewer.getTable().getSelectionIndex(); IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = workspace.getRoot(); WindowsAzureRoleComponent component = listComponents.get(selIndex); if (selIndex > -1) { try { /* First condition: Checks component is part of a JDK, * server configuration * Second condition: For not showing error message * "Disable Server JDK Configuration" * while removing server application * when server or JDK is already disabled. */ if (component.getIsPreconfigured() && (!(component.getType().equals(Messages.typeSrvApp) && windowsAzureRole.getServerName() == null))) { PluginUtil.displayErrorDialog(getShell(), Messages.jdkDsblErrTtl, Messages.jdkDsblErrMsg); } else { boolean choice = MessageDialog.openQuestion(getShell(), Messages.cmpntRmvTtl, Messages.cmpntRmvMsg); if (choice) { String cmpntPath = String.format("%s%s%s%s%s", root.getProject(waProjManager.getProjectName()).getLocation(), File.separator, windowsAzureRole.getName(), Messages.approot, component.getDeployName()); File file = new File(cmpntPath); // Check import source is equal to approot if (component.getImportPath().isEmpty() && file.exists()) { MessageDialog dialog = new MessageDialog(getShell(), Messages.cmpntSrcRmvTtl, null, Messages.cmpntSrcRmvMsg, MessageDialog.QUESTION_WITH_CANCEL, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); switch (dialog.open()) { case 0: //yes component.delete(); tblViewer.refresh(); fileToDel.add(file); break; case 1: //no component.delete(); tblViewer.refresh(); break; case 2: //cancel break; default: break; } } else { component.delete(); tblViewer.refresh(); fileToDel.add(file); } } } if (tblComponents.getItemCount() == 0) { // table is empty i.e. number of rows = 0 btnRemove.setEnabled(false); btnEdit.setEnabled(false); } } catch (WindowsAzureInvalidProjectOperationException e) { PluginUtil.displayErrorDialogAndLog(getShell(), Messages.cmpntSetErrTtl, Messages.cmpntRmvErrMsg, e); } } updateMoveButtons(); }
From source file:com.simplifide.core.ui.wizard.other.NewFilePage.java
License:Open Source License
/** * Creates a new file resource in the selected container and with the * selected name. Creates any missing resource containers along the path; * does nothing if the container resources already exist. * <p>// ww w .jav a 2 s .c o m * In normal usage, this method is invoked after the user has pressed Finish * on the wizard; the enablement of the Finish button implies that all * controls on on this page currently contain valid values. * </p> * <p> * Note that this page caches the new file once it has been successfully * created; subsequent invocations of this method will answer the same file * resource without attempting to create it again. * </p> * <p> * This method should be called within a workspace modify operation since it * creates resources. * </p> * * @return the created file resource, or <code>null</code> if the file was * not created */ public IFile createNewFile() { if (newFile != null) { return newFile; } // create the new file and cache it if successful final IPath containerPath = resourceGroup.getContainerFullPath(); IPath newFilePath = containerPath.append(resourceGroup.getResource()); final IFile newFileHandle = createFileHandle(newFilePath); final InputStream initialContents = getInitialContents(); createLinkTarget(); if (linkTargetPath != null) { // Not compatible with 3.5 URI resolvedPath = linkTargetPath;//newFileHandle.getPathVariableManager().resolveURI(linkTargetPath); try { if (resolvedPath.getScheme() != null && resolvedPath.getSchemeSpecificPart() != null) { IFileStore store = EFS.getStore(resolvedPath); if (!store.fetchInfo().exists()) { MessageDialog dlg = new MessageDialog(getContainer().getShell(), LINK_TITLE, null, NLS.bind(LINK_NOTSURE, linkTargetPath), MessageDialog.QUESTION_WITH_CANCEL, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); int result = dlg.open(); if (result == Window.OK) { store.getParent().mkdir(0, new NullProgressMonitor()); OutputStream stream = store.openOutputStream(0, new NullProgressMonitor()); stream.close(); } if (result == 2) return null; } } } catch (CoreException e) { MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(), IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle, NLS.bind(IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage, e.getMessage()), SWT.SHEET); return null; } catch (IOException e) { MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(), IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle, NLS.bind(IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage, e.getMessage()), SWT.SHEET); return null; } } IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { CreateFileOperation op = new CreateFileOperation(newFileHandle, linkTargetPath, initialContents, IDEWorkbenchMessages.WizardNewFileCreationPage_title); try { // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=219901 // directly execute the operation so that the undo state is // not preserved. Making this undoable resulted in too many // accidental file deletions. op.execute(monitor, WorkspaceUndoUtil.getUIInfoAdapter(getShell())); } catch (final ExecutionException e) { getContainer().getShell().getDisplay().syncExec(new Runnable() { public void run() { if (e.getCause() instanceof CoreException) { ErrorDialog.openError(getContainer().getShell(), // Was // Utilities.getFocusShell() IDEWorkbenchMessages.WizardNewFileCreationPage_errorTitle, null, // no special // message ((CoreException) e.getCause()).getStatus()); } else { IDEWorkbenchPlugin.log(getClass(), "createNewFile()", e.getCause()); //$NON-NLS-1$ MessageDialog.openError(getContainer().getShell(), IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle, NLS.bind( IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage, e.getCause().getMessage())); } } }); } } }; try { getContainer().run(true, true, op); } catch (InterruptedException e) { return null; } catch (InvocationTargetException e) { // Execution Exceptions are handled above but we may still get // unexpected runtime errors. IDEWorkbenchPlugin.log(getClass(), "createNewFile()", e.getTargetException()); //$NON-NLS-1$ MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(), IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle, NLS.bind(IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage, e.getTargetException().getMessage()), SWT.SHEET); return null; } newFile = newFileHandle; return newFile; }
From source file:com.technophobia.substeps.editor.preferences.page.SubstepsPropertyPage.java
License:Open Source License
private ConfirmationStatus getConfirmationStatus(final IPath previousPath, final IPath newPath, final SubstepsFolderChangedListener folderChangeListener) { final MessageDialog messageDialog = new MessageDialog(getShell(), "Confirm", null, folderChangeListener.confirmationMessage(previousPath, newPath), MessageDialog.QUESTION_WITH_CANCEL, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0);/*from www .j a va2s . c om*/ final int status = messageDialog.open(); return ConfirmationStatus.values()[status]; }
From source file:com.testify.ecfeed.ui.wizards.NewEcFileWizard.java
License:Open Source License
public boolean performFinish() { IFile file = fPage.createNewFile();/* w ww .j av a2s .co m*/ try { if (file.getContents().read() != -1) { MessageDialog dialog = new MessageDialog(getShell(), Messages.WIZARD_FILE_EXISTS_TITLE, Display.getDefault().getSystemImage(SWT.ICON_QUESTION), Messages.WIZARD_FILE_EXISTS_MESSAGE, MessageDialog.QUESTION_WITH_CANCEL, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, IDialogConstants.OK_ID); if (dialog.open() != IDialogConstants.OK_ID) { return false; } } final IPath newFileFullPath = fPage.getContainerFullPath().append(fPage.getFileName()); String modelName = newFileFullPath.removeFileExtension().lastSegment(); RootNode model = new RootNode(modelName != null ? modelName : Constants.DEFAULT_NEW_ECT_MODEL_NAME); ByteArrayOutputStream ostream = new ByteArrayOutputStream(); new EctSerializer(ostream).serialize(model); ByteArrayInputStream istream = new ByteArrayInputStream(ostream.toByteArray()); file.setContents(istream, true, true, null); //open new file in an ect editor IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); page.openEditor(new FileEditorInput(file), Constants.ECT_EDITOR_ID); } catch (Exception e) { e.printStackTrace(); } return true; }
From source file:cu.uci.abos.core.util.MessageDialogUtil.java
License:Open Source License
private static String[] getButtonLabels(int kind) { String[] dialogButtonLabels;//from w w w . ja va2s .co m switch (kind) { case MessageDialog.ERROR: case MessageDialog.INFORMATION: case MessageDialog.WARNING: { dialogButtonLabels = new String[] { AbosMessages.get().BUTTON_CLOSE }; break; } case MessageDialog.CONFIRM: { dialogButtonLabels = new String[] { AbosMessages.get().BUTTON_ACCEPT, AbosMessages.get().BUTTON_CANCEL }; break; } case MessageDialog.QUESTION: { dialogButtonLabels = new String[] { AbosMessages.get().BUTTON_ACCEPT, AbosMessages.get().BUTTON_CANCEL }; break; } case MessageDialog.QUESTION_WITH_CANCEL: { dialogButtonLabels = new String[] { AbosMessages.get().BUTTON_ACCEPT, AbosMessages.get().BUTTON_CANCEL, AbosMessages.get().BUTTON_CLOSE }; break; } default: { throw new IllegalArgumentException("Illegal value for kind in MessageDialog.open()"); } } return dialogButtonLabels; }
From source file:eu.scasefp7.eclipse.servicecomposition.toolbar.FillToolbar.java
/** * <h1>fillToolBar</h1>Add buttons to the toolbar. *///from ww w .ja v a 2 s. c om public static void fillToolBar(ServiceCompositionView view) { ZoomContributionViewItem toolbarZoomContributionViewItem = new ZoomContributionViewItem(view); IActionBars bars = view.getViewSite().getActionBars(); final Shell shell = view.getSite().getWorkbenchWindow().getShell(); final Display disp = shell.getDisplay(); bars.getMenuManager().add(toolbarZoomContributionViewItem); runWorkflowAction = new Action("Run workflow") { public void run() { try { // clean outputs // cleanOutputs(); RunWorkflow run = new RunWorkflow(view, view.getTreeViewer(), view.getColumnb(), view.getAuthParamsComposite(), view.getRequestHeaderComposite()); run.runWorkflow(); } catch (Exception e) { Activator.log("Error while running the workflow", e); e.printStackTrace(); } } }; runWorkflowAction.setImageDescriptor(getImageDescriptor("icons/run.png")); newWorkflowAction = new Action("Create a new workflow") { public void run() { try { if (view.getSavedWorkflow()) { // clean outputs Utils.cleanOutputs(view.getOutputsComposite(), view.getJungGraph()); CreateWorkflow.createNewWorkflow(view); } else { if (view.jungGraphHasOperations()) { MessageDialog dialog = new MessageDialog(shell, "Workflow is not saved", null, "This workflow is not saved. Would you like to save it before creating a new one?", MessageDialog.QUESTION_WITH_CANCEL, new String[] { "Yes", "No", "Cancel" }, 0); int result = dialog.open(); System.out.println(result); if (result == 0) { IStatus status = checkGraph(view.getJungGraph(), disp); if (status.getMessage().equalsIgnoreCase("OK")) { if (view.getWorkflowFilePath().isEmpty()) { SaveOpen.saveWorkflow(true, view.getWorkflowFilePath(), view); } else { SaveOpen.saveWorkflow(false, view.getWorkflowFilePath(), view); } } // clean outputs Utils.cleanOutputs(view.getOutputsComposite(), view.getJungGraph()); view.clearMatchedInputs(); CreateWorkflow.createNewWorkflow(view); } else if (result == 1) { // clean outputs Utils.cleanOutputs(view.getOutputsComposite(), view.getJungGraph()); view.clearMatchedInputs(); CreateWorkflow.createNewWorkflow(view); } } else { CreateWorkflow.createNewWorkflow(view); } } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; newWorkflowAction.setImageDescriptor(getImageDescriptor("icons/New File.png")); displayCostAction = new Action("Display total cost, trial period, licenses") { public void run() { try { // clean outputs DisplayCost.displayCost(view); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; displayCostAction.setImageDescriptor(getImageDescriptor("icons/copyrights.png")); generateCodeAction = new Action("Generate RESTful java project of the workflow.") { public void run() { try { IStatus status = checkGraph(view.getJungGraph(), disp); if (status.getMessage().equalsIgnoreCase("OK")) { newProject = new GenerateUpload(view); newProject.generate(); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; generateCodeAction.setImageDescriptor(getImageDescriptor("icons/java.png")); saveWorkflowAction = new Action("Save the workflow.") { public void run() { try { IStatus status = checkGraph(view.getJungGraph(), disp); if (status.getMessage().equalsIgnoreCase("OK")) { if (view.getWorkflowFilePath().isEmpty()) { SaveOpen.saveWorkflow(true, view.getWorkflowFilePath(), view); } else { SaveOpen.saveWorkflow(false, view.getWorkflowFilePath(), view); } } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; saveWorkflowAction.setImageDescriptor(getImageDescriptor("icons/save.png")); openWorkflowAction = new Action("Open a workflow file.") { public void run() { try { if (view.getSavedWorkflow()) { view.clearMatchedInputs(); SaveOpen.openWorkflow(view); } else { if (view.jungGraphHasOperations()) { MessageDialog dialog = new MessageDialog(shell, "Workflow is not saved", null, "This workflow is not saved. Would you like to save it before creating a new one?", MessageDialog.QUESTION_WITH_CANCEL, new String[] { "Yes", "No", "Cancel" }, 0); int result = dialog.open(); System.out.println(result); if (result == 0) { IStatus status = checkGraph(view.getJungGraph(), disp); if (status.getMessage().equalsIgnoreCase("OK")) { if (view.getWorkflowFilePath().isEmpty()) { SaveOpen.saveWorkflow(true, view.getWorkflowFilePath(), view); } else { SaveOpen.saveWorkflow(false, view.getWorkflowFilePath(), view); } } view.clearMatchedInputs(); SaveOpen.openWorkflow(view); } else if (result == 1) { view.clearMatchedInputs(); SaveOpen.openWorkflow(view); } } else { SaveOpen.openWorkflow(view); } } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; openWorkflowAction.setImageDescriptor(getImageDescriptor("icons/open.png")); reloadWorkflowAction = new Action("Reload storyboard file.") { public void run() { try { ReloadStoryboard.reloadStoryboard(disp, shell, view, view.getStoryboardFile()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; reloadWorkflowAction.setImageDescriptor(getImageDescriptor("icons/reload_storyboard.png")); Action uploadOnServerAction = new Action("Upload RESTful web service on server.") { public void run() { try { newProject.install(); } catch (Exception e) { e.printStackTrace(); } } }; uploadOnServerAction.setImageDescriptor(getImageDescriptor("icons/database.png")); IToolBarManager mgr = view.getViewSite().getActionBars().getToolBarManager(); mgr.add(newWorkflowAction); mgr.add(openWorkflowAction); mgr.add(saveWorkflowAction); mgr.add(runWorkflowAction); mgr.add(generateCodeAction); mgr.add(uploadOnServerAction); mgr.add(displayCostAction); mgr.add(reloadWorkflowAction); }
From source file:fr.gouv.mindef.safran.database.ui.actions.AbstractScaffoldHandler.java
License:Open Source License
public Object execute(ExecutionEvent event) throws ExecutionException { ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection(); shell = HandlerUtil.getActiveShell(event); if (selection instanceof StructuredSelection) { StructuredSelection structuredSelection = (StructuredSelection) selection; if (structuredSelection.size() == 2) { ScaffoldInfo existingScaffoldInfo = getExistingScaffoldModel(structuredSelection); if (existingScaffoldInfo != null) { MessageDialog dlg = new MessageDialog(shell, "Existing scaffold model found", null, "A scaffold model already exists for these objects in file " + existingScaffoldInfo.eResource().getURI().toPlatformString(true) + "\n\nWhat do you want to do ?", MessageDialog.QUESTION_WITH_CANCEL, new String[] { "Use existing scaffold", "Create a new scaffold", "Cancel" }, 0); int btn = dlg.open(); if (btn == CANCEL) { return null; } else if (btn == CREATE_NEW_SCAFFOLD) { executeScaffoldingWizard(structuredSelection); } else if (btn == USE_EXISTING_SCAFFOLD) { executeFromScaffoldModel(existingScaffoldInfo); }// ww w . j av a2s. co m } else { executeScaffoldingWizard(structuredSelection); } } else if (structuredSelection.size() == 1) { executeFromScaffoldModel(structuredSelection); } } return null; }
From source file:gr.aueb.dmst.istlab.unixtools.views.preferences.PreferencesTableView.java
public String handleImportButton() { String filename = null;/* w ww.jav a 2s. c o m*/ // ask the user if he/she wants to overwrite the existing table MessageDialog messageDialog = new MessageDialog(getShell(), "Import commands", null, PropertiesLoader.CUSTOM_COMMAND_PAGE_IMPORT_MESSAGE, MessageDialog.QUESTION_WITH_CANCEL, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); if (messageDialog.open() == MessageDialog.OK) { // User has selected to open a single file FileDialog fileDialog = new FileDialog(getShell(), SWT.OPEN); filename = fileDialog.open(); } return filename; }
From source file:net.sf.smbt.ui.dmx.editors.DMXMultiPageEditor.java
License:LGPL
/** * The <code>MultiPageEditorExample</code> implementation of this method * checks that the input is an instance of <code>IFileEditorInput</code>. *//*from w w w .ja va 2s . co m*/ public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException { if (!(editorInput instanceof IFileEditorInput)) throw new PartInitException("Invalid Input: Must be IFileEditorInput"); super.init(site, editorInput); setSite(site); DMXProject proj = DMXUtils.INSTANCE.load(editorInput); dmxProject = (proj.getLibrary() == null && proj.getUniverses().isEmpty()) ? DMXUtils.INSTANCE.initDMXProject() : proj; if (dmxProject.getLastAddress() != null) { if (dmxPipe == null) { MessageDialog dlg = new MessageDialog(Display.getDefault().getActiveShell(), "DMX connection question", Activator.imageDescriptorFromPlugin("net.sf.smbt.ui", "icons/new/control_wheel.png") .createImage(), "Reconnect to last known DMX connection ?\n\n" + dmxProject.getLastAddress().toString(), MessageDialog.QUESTION_WITH_CANCEL, new String[] { "Yes", "No", "Cancel" }, 0); if (dlg.open() == 0) { CmdPipe pipe = XCPAddressUtils.INSTANCE.getCmdPipe(dmxProject.getLastAddress(), true); if (pipe == null) { dmxProject.setLastAddress(null); label.setText("Not connected !"); label.setForeground(ColorConstants.orange); } else { dmxPipe = pipe; } } } } initAdapterFactory(); setInput(editorInput); }
From source file:org.apache.sling.ide.eclipse.ui.actions.JcrNewNodeHandler.java
License:Apache License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { ISelection sel = HandlerUtil.getCurrentSelection(event); JcrNode node = SelectionUtils.getFirst(sel, JcrNode.class); if (node == null) { return null; }/* w ww . j av a2 s.c o m*/ Shell shell = HandlerUtil.getActiveShell(event); if (!node.canCreateChild()) { MessageDialog.openInformation(shell, "Cannot create node", "Node is not covered by the workspace filter as defined in filter.xml"); return null; } Repository repository = ServerUtil.getDefaultRepository(node.getProject()); NodeTypeRegistry ntManager = (repository == null) ? null : repository.getNodeTypeRegistry(); if (ntManager == null) { if (!doNotAskAgain) { MessageDialog dialog = new MessageDialog(null, "Unable to validate node type", null, "Unable to validate node types since project " + node.getProject().getName() + " is not associated with a server or the server is not started.", MessageDialog.QUESTION_WITH_CANCEL, new String[] { "Cancel", "Continue (do not ask again)", "Continue" }, 1) { @Override protected void configureShell(Shell shell) { super.configureShell(shell); setShellStyle(getShellStyle() | SWT.SHEET); } }; int choice = dialog.open(); if (choice <= 0) { return null; } if (choice == 1) { doNotAskAgain = true; } } } final NodeType nodeType = node.getNodeType(); if (nodeType != null && nodeType.getName() != null && nodeType.getName().equals("nt:file")) { MessageDialog.openInformation(shell, "Cannot create node", "Node of type nt:file cannot have children"); return null; } try { final NewNodeDialog nnd = new NewNodeDialog(shell, node, ntManager); if (nnd.open() == IStatus.OK) { node.createChild(nnd.getValue(), nnd.getChosenNodeType()); return null; } } catch (RepositoryException e1) { Activator.getDefault().getPluginLogger().warn("Could not open NewNodeDialog due to " + e1, e1); } return null; }