List of usage examples for org.eclipse.jface.dialogs IDialogConstants YES_LABEL
String YES_LABEL
To view the source code for org.eclipse.jface.dialogs IDialogConstants YES_LABEL.
Click Source Link
From source file:org.eclipse.papyrus.modelexplorer.actions.GenericTransformAction.java
License:Open Source License
/** * Transform the element and update referencing diagrams. * //from w ww.j a va 2s . c o m * @see org.eclipse.jface.action.Action#run() */ @Override public void run() { GenericTransformer transformer = new GenericTransformer(element); MultiStatus messages = transformer.isTransformationPossible(targetEClass); if (messages != null && messages.getChildren().length == 0) { String message = String.format(WARNING_MESSAGE, this.element.eClass().getName(), targetEClass.getName()); InformationDialog dialog = new InformationDialog(Display.getDefault().getActiveShell(), WARNING_TITLE, message, Activator.getDefault().getPreferenceStore(), INavigatorPreferenceConstants.PREF_NAVIGATOR_TRANSFORM_INTO_SHOW_POPUP, SWT.YES | SWT.NO, MessageDialog.INFORMATION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }); int result = dialog.open(); if (result == SWT.YES || result == Window.OK) { transformer.transform(targetEClass); } } else { ErrorDialog errorDialog = new ErrorDialog(Display.getDefault().getActiveShell(), ERROR_TITLE, ERROR_MESSAGE, messages, IStatus.WARNING); errorDialog.open(); } }
From source file:org.eclipse.pde.emfforms.editor.EmfFormEditor.java
License:Open Source License
/** * @param monitor/*from w w w . ja v a 2 s . co m*/ */ protected void internalDoValidate(IProgressMonitor monitor) { VALIDATE_ON_SAVE validateOnSave = getEditorConfig().getValidateOnSave(); // result of the Validation Diagnostic diagnostic = Diagnostic.OK_INSTANCE; // if the validation is asked by the user if (validateOnSave != VALIDATE_ON_SAVE.NO_VALIDATION) diagnostic = _validator.validate(getCurrentEObject()); if (diagnostic.getSeverity() != Diagnostic.OK) { switch (validateOnSave) { case VALIDATE_AND_WARN: int dialogResult = new DiagnosticDialog(getSite().getShell(), Messages.EmfFormEditor_DiaDialog_InvalidModel_Title, null, diagnostic, Diagnostic.ERROR | Diagnostic.WARNING) { @Override protected Control createMessageArea(Composite composite) { message = Messages.EmfFormEditor_ValidationWarn_Msg; return super.createMessageArea(composite); } @Override protected void createButtonsForButtonBar(Composite parent) { // create OK and Details buttons createButton(parent, IDialogConstants.OK_ID, IDialogConstants.YES_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.NO_LABEL, true); createDetailsButton(parent); } }.open(); if (dialogResult != Window.OK) { if (monitor != null) monitor.setCanceled(true); throw new OperationCanceledException(); } break; case VALIDATE_AND_ABORT: new DiagnosticDialog(getSite().getShell(), Messages.EmfFormEditor_DiaDialog_InvalidModel_Title, null, diagnostic, Diagnostic.ERROR | Diagnostic.WARNING) { @Override protected Control createMessageArea(Composite composite) { message = Messages.EmfFormEditor_ValidationError_Msg; return super.createMessageArea(composite); } }.open(); monitor.setCanceled(true); throw new OperationCanceledException(); default: // fall through } } }
From source file:org.eclipse.pde.internal.ui.editor.plugin.OverviewPage.java
License:Open Source License
private void activateExtensionPages(String activePageId) { MessageDialog mdiag = new MessageDialog(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.OverviewPage_extensionPageMessageTitle, null, PDEUIMessages.OverviewPage_extensionPageMessageBody, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); if (mdiag.open() != Window.OK) return;/*from w w w .j a va 2s. c om*/ try { ManifestEditor manifestEditor = (ManifestEditor) getEditor(); manifestEditor.addExtensionTabs(); manifestEditor.setShowExtensions(true); manifestEditor.setActivePage(activePageId); } catch (PartInitException e) { } catch (BackingStoreException e) { } }
From source file:org.eclipse.pde.internal.ui.editor.product.IntroSection.java
License:Open Source License
private void handleNewIntro() { boolean needNewProduct = false; if (!productDefined()) { needNewProduct = true;/*from w ww. j av a 2 s .com*/ MessageDialog mdiag = new MessageDialog(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.IntroSection_undefinedProductId, null, PDEUIMessages.IntroSection_undefinedProductIdMessage, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); if (mdiag.open() != Window.OK) return; } ProductIntroWizard wizard = new ProductIntroWizard(getProduct(), needNewProduct); WizardDialog dialog = new WizardDialog(PDEPlugin.getActiveWorkbenchShell(), wizard); dialog.create(); if (dialog.open() == Window.OK) { String id = wizard.getIntroId(); fIntroCombo.add(id, 0); fIntroCombo.setText(id); getIntroInfo().setId(id); addDependenciesAndPlugins(); } }
From source file:org.eclipse.pde.internal.ui.launcher.LauncherUtilsStatusHandler.java
License:Open Source License
/** * Creates a message dialog using a syncExec in case we are launching in the background. * Dialog will be a question dialog with Yes, No and Cancel buttons. * @param message Message to use in the dialog * @return int representing the button clicked (-1 or 2 for cancel, 0 for yes, 1 for no). *///from w w w . ja v a 2 s . co m private static Integer generateDialog(final String message) { final int[] result = new int[1]; getDisplay().syncExec(new Runnable() { public void run() { String title = PDEUIMessages.LauncherUtils_title; MessageDialog dialog = new MessageDialog(getActiveShell(), title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); result[0] = dialog.open(); } }); return new Integer(result[0]); }
From source file:org.eclipse.php.internal.ui.compare.ContentMergeViewer.java
License:Open Source License
/** * This method is called from the <code>Viewer</code> method * <code>inputChanged</code> to save any unsaved changes of the old input. * <p>// w w w. j a v a 2 s.c o m * The <code>ContentMergeViewer</code> implementation of this method calls * <code>saveContent(...)</code>. If confirmation has been turned on with * <code>setConfirmSave(true)</code>, a confirmation alert is posted before * saving. * </p> * Clients can override this method and are free to decide whether they want * to call the inherited method. * * @param newInput * the new input of this viewer, or <code>null</code> if there is * no new input * @param oldInput * the old input element, or <code>null</code> if there was * previously no input * @return <code>true</code> if saving was successful, or if the user didn't * want to save (by pressing 'NO' in the confirmation dialog). * @since 2.0 */ protected boolean doSave(Object newInput, Object oldInput) { // before setting the new input we have to save the old if (isLeftDirty() || isRightDirty()) { if (Utilities.RUNNING_TESTS) { if (Utilities.TESTING_FLUSH_ON_COMPARE_INPUT_CHANGE) { flushContent(oldInput, null); } } else if (fConfirmSave) { // post alert Shell shell = fComposite.getShell(); MessageDialog dialog = new MessageDialog(shell, Utilities.getString(getResourceBundle(), "saveDialog.title"), //$NON-NLS-1$ null, // accept the default window icon Utilities.getString(getResourceBundle(), "saveDialog.message"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, }, 0); // default // button // index switch (dialog.open()) { // open returns index of pressed button case 0: flushContent(oldInput, null); break; case 1: setLeftDirty(false); setRightDirty(false); break; case 2: throw new ViewerSwitchingCancelled(); } } else flushContent(oldInput, null); return true; } return false; }
From source file:org.eclipse.php.internal.ui.dialogs.saveFiles.SaveAsDialog.java
License:Open Source License
protected void okPressed() { IPath path = resourceGroup.getContainerFullPath().append(resourceGroup.getResource()); // If the user does not supply a file extension and if the save // as dialog was provided a default file name append the extension // of the default filename to the new name if (path.getFileExtension() == null) { if (originalFile != null && originalFile.getFileExtension() != null) { path = path.addFileExtension(originalFile.getFileExtension()); } else if (originalName != null) { int pos = originalName.lastIndexOf('.'); if (++pos > 0 && pos < originalName.length()) { path = path.addFileExtension(originalName.substring(pos)); }/*from w w w . j a v a2s .co m*/ } } // If the path already exists then confirm overwrite. IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); if (file.exists()) { String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; String question = PHPUIMessages.SaveAsDialog_6 + file.getFullPath().toString() + PHPUIMessages.SaveAsDialog_7; MessageDialog d = new MessageDialog(getShell(), PHPUIMessages.SaveAsDialog_saveFileMessage, null, question, MessageDialog.QUESTION, buttons, 0); int overwrite = d.open(); switch (overwrite) { case 0: // Yes break; case 1: // No return; case 2: // Cancel default: cancelPressed(); return; } } // Store path and close. result = path; close(); }
From source file:org.eclipse.php.internal.ui.editor.PHPStructuredTextViewer.java
License:Open Source License
/** * This method overrides WST since sometimes we get a subset of the document * and NOT the whole document, although the case is FORMAT_DOCUMENT. In all * other cases we call the parent method. *///from w w w . j a v a 2s. com @Override public void doOperation(int operation) { Point selection = getTextWidget().getSelection(); int cursorPosition = selection.x; // save the last cursor position and the top visible line. int selectionLength = selection.y - selection.x; int topLine = getTextWidget().getTopIndex(); switch (operation) { case FORMAT_DOCUMENT: try { setRedraw(false); // begin recording beginRecording(FORMAT_DOCUMENT_TEXT, FORMAT_DOCUMENT_TEXT, cursorPosition, selectionLength); // format the whole document ! IRegion region; if (selectionLength != 0) { region = new Region(cursorPosition, selectionLength); } else { region = new Region(0, getDocument().getLength()); } if (fContentFormatter instanceof IContentFormatterExtension) { IContentFormatterExtension extension = (IContentFormatterExtension) fContentFormatter; IFormattingContext context = new FormattingContext(); context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.TRUE); context.setProperty(FormattingContextProperties.CONTEXT_REGION, region); extension.format(getDocument(), context); } else { fContentFormatter.format(getDocument(), region); } } finally { // end recording selection = getTextWidget().getSelection(); selectionLength = selection.y - selection.x; endRecording(cursorPosition, selectionLength); // return the cursor to its original position after the // formatter change its position. getTextWidget().setSelection(cursorPosition); getTextWidget().setTopIndex(topLine); setRedraw(true); } return; case CONTENTASSIST_PROPOSALS: // Handle javascript content assist when there is no support // (instead of printing the stack trace) if (fViewerConfiguration != null) { IProject project = null; boolean isJavaScriptRegion = false; boolean hasJavaScriptNature = true; try { // Resolve the partition type IStructuredDocument sDoc = (IStructuredDocument) getDocument(); // get the "real" offset - adjusted according to the // projection int selectionOffset = getSelectedRange().x; IStructuredDocumentRegion sdRegion = sDoc.getRegionAtCharacterOffset(selectionOffset); if (sdRegion == null) { super.doOperation(operation); return; } ITextRegion textRegion = sdRegion.getRegionAtCharacterOffset(selectionOffset); if (textRegion instanceof ForeignRegion) { ForeignRegion foreignRegion = (ForeignRegion) textRegion; isJavaScriptRegion = "script" //$NON-NLS-1$ .equalsIgnoreCase(foreignRegion.getSurroundingTag()); } // Check if the containing project has JS nature or not if (fTextEditor instanceof PHPStructuredEditor) { PHPStructuredEditor phpEditor = (PHPStructuredEditor) fTextEditor; IModelElement modelElement = phpEditor.getModelElement(); if (modelElement != null) { IScriptProject scriptProject = modelElement.getScriptProject(); project = scriptProject.getProject(); if (project != null && project.isAccessible() && project.getNature(JavaScriptCore.NATURE_ID) == null) { hasJavaScriptNature = false; } } } // open dialog if required if (isJavaScriptRegion && !hasJavaScriptNature) { Shell activeWorkbenchShell = PHPUiPlugin.getActiveWorkbenchShell(); // Pop a question dialog - if the user selects 'Yes' JS // Support is added, otherwise no change int addJavaScriptSupport = OptionalMessageDialog.open("PROMPT_ADD_JAVASCRIPT_SUPPORT", //$NON-NLS-1$ activeWorkbenchShell, PHPUIMessages.PHPStructuredTextViewer_0, null, PHPUIMessages.PHPStructuredTextViewer_1, OptionalMessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); //$NON-NLS-1$ // run the JSDT action for adding the JS nature if (addJavaScriptSupport == 0 && project != null) { SetupProjectsWizzard wiz = new SetupProjectsWizzard(); wiz.setActivePart(null, this.getTextEditor()); wiz.selectionChanged(null, new StructuredSelection(project)); wiz.run(null); } return; } } catch (CoreException e) { Logger.logException(e); } } // notifing the processors that the next request for completion is // an explicit request if (fViewerConfiguration != null) { PHPStructuredTextViewerConfiguration structuredTextViewerConfiguration = (PHPStructuredTextViewerConfiguration) fViewerConfiguration; IContentAssistProcessor[] all = structuredTextViewerConfiguration.getContentAssistProcessors(this, PHPPartitionTypes.PHP_DEFAULT); for (IContentAssistProcessor element : all) { if (element instanceof PHPCompletionProcessor) { ((PHPCompletionProcessor) element).setExplicit(true); } } } super.doOperation(operation); return; case SHOW_OUTLINE: if (fOutlinePresenter != null) { fOutlinePresenter.showInformation(); } return; case SHOW_HIERARCHY: if (fHierarchyPresenter != null) { fHierarchyPresenter.showInformation(); } return; case DELETE: StyledText textWidget = getTextWidget(); if (textWidget == null) return; ITextSelection textSelection = null; if (redraws()) { try { textSelection = (ITextSelection) getSelection(); int length = textSelection.getLength(); if (!textWidget.getBlockSelection() && (length == 0 || length == textWidget.getSelectionRange().y)) getTextWidget().invokeAction(ST.DELETE_NEXT); else deleteSelection(textSelection, textWidget); if (fFireSelectionChanged) { Point range = textWidget.getSelectionRange(); fireSelectionChanged(range.x, range.y); } } catch (BadLocationException x) { // ignore } } return; } super.doOperation(operation); }
From source file:org.eclipse.php.internal.ui.preferences.includepath.VariableBlock.java
License:Open Source License
public boolean performOk() { ArrayList removedVariables = new ArrayList(); ArrayList changedVariables = new ArrayList(); // removedVariables.addAll(Arrays.asList(PHPProjectOptions.getIncludePathVariableNames())); // remove all unchanged List changedElements = fVariablesList.getElements(); List unchangedElements = fVariablesList.getElements(); for (int i = changedElements.size() - 1; i >= 0; i--) { IPVariableElement curr = (IPVariableElement) changedElements.get(i); if (curr.isReserved()) { changedElements.remove(curr); } else {/*from www .j a v a 2 s . c o m*/ IPath path = curr.getPath(); IPath prevPath = null; // PHPProjectOptions.getIncludePathVariable(curr.getName()); if (prevPath != null && prevPath.equals(path)) { changedElements.remove(curr); } else { changedVariables.add(curr.getName()); unchangedElements.remove(curr); } } removedVariables.remove(curr.getName()); } int steps = changedElements.size() + removedVariables.size(); if (steps > 0) { boolean needsBuild = false; if (fAskToBuild && doesChangeRequireFullBuild(removedVariables, changedVariables)) { String title = PHPUIMessages.VariableBlock_needsbuild_title; String message = PHPUIMessages.VariableBlock_needsbuild_message; MessageDialog buildDialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); int res = buildDialog.open(); if (res != 0 && res != 1) { return false; } needsBuild = (res == 0); } final VariableBlockRunnable runnable = new VariableBlockRunnable(removedVariables, changedElements, unchangedElements, needsBuild); Job buildJob = new Job(PHPUIMessages.VariableBlock_job_description) { protected IStatus run(IProgressMonitor monitor) { try { runnable.setVariables(monitor); } catch (CoreException e) { return e.getStatus(); } catch (OperationCanceledException e) { return Status.CANCEL_STATUS; } finally { monitor.done(); } return Status.OK_STATUS; } }; buildJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule()); buildJob.setUser(true); buildJob.schedule(); return true; } // ProgressMonitorDialog dialog= new ProgressMonitorDialog(getShell()); // try { // dialog.run(true, true, runnable); // } catch (InvocationTargetException e) { // ExceptionHandler.handle(e, getShell(), PHPUIMessages.getString("VariableBlock.operation_errror.title"), PHPUIMessages.getString("VariableBlock.operation_errror.message")); // return false; // } catch (InterruptedException e) { // return false; // } // } return true; }
From source file:org.eclipse.php.internal.ui.preferences.OptionsConfigurationBlock.java
License:Open Source License
protected boolean processChanges(IWorkbenchPreferenceContainer container) { IScopeContext currContext = fLookupOrder[0]; List<Key> changedOptions = new ArrayList<Key>(); boolean needsBuild = getChanges(currContext, changedOptions); if (changedOptions.isEmpty()) { hasChanges = false;/*from w w w .jav a2 s.c o m*/ return true; } else { hasChanges = true; } if (!this.checkChanges(currContext)) { // check failed return false; } boolean doBuild = false; if (needsBuild) { String[] strings = getFullBuildDialogStrings(fProject == null); if (strings != null) { MessageDialog dialog = new MessageDialog(getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); int res = dialog.open(); if (res == 0) { doBuild = true; } else if (res != 1) { return false; // cancel pressed } } } if (doBuild) { prepareForBuild(); } if (container != null) { // no need to apply the changes to the original store: will be done // by the page container if (doBuild) { // post build container.registerUpdateJob(CoreUtility.getBuildJob(fProject)); } } else { // apply changes right away try { fManager.applyChanges(); } catch (BackingStoreException e) { PHPUiPlugin.log(e); return false; } if (doBuild) { CoreUtility.getBuildJob(fProject).schedule(); } } return true; }