List of usage examples for org.eclipse.jface.dialogs IDialogConstants NO_ID
int NO_ID
To view the source code for org.eclipse.jface.dialogs IDialogConstants NO_ID.
Click Source Link
From source file:net.refractions.udig.project.ui.internal.SaveDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false); createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true); }
From source file:net.sf.eclipsensis.settings.NSISSettingsEditorGeneralPage.java
License:Open Source License
/** * @param parent/* www . j a va2 s .c o m*/ */ protected void createProcessPriorityCombo(Composite parent) { Label l; mProcessPriority = createCombo(parent, EclipseNSISPlugin.getResourceString("process.priority.text"), //$NON-NLS-1$ EclipseNSISPlugin.getResourceString("process.priority.tooltip"), //$NON-NLS-1$ INSISSettingsConstants.PROCESS_PRIORITY_ARRAY, mSettings.getProcessPriority() + 1); mProcessPriorityIndex = mProcessPriority.getSelectionIndex(); l = new Label(parent, SWT.None); l.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); mProcessPriority.setData(LABELS, new Object[] { mProcessPriority.getData(LABEL), l }); mProcessPriority.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (isProcessPrioritySupported()) { if (isWarnProcessPriority()) { if (mProcessPriority.getSelectionIndex() > INSISSettingsConstants.PROCESS_PRIORITY_HIGH && mProcessPriorityIndex <= INSISSettingsConstants.PROCESS_PRIORITY_HIGH) { MessageDialogWithToggle dialog = new MessageDialogWithToggle( mProcessPriority.getShell(), EclipseNSISPlugin.getResourceString("confirm.title"), //$NON-NLS-1$ EclipseNSISPlugin.getShellImage(), EclipseNSISPlugin.getResourceString("process.priority.question"), //$NON-NLS-1$ MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1, EclipseNSISPlugin.getResourceString("process.priority.toggle"), //$NON-NLS-1$ false); dialog.open(); setWarnProcessPriority(!dialog.getToggleState()); if (dialog.getReturnCode() == IDialogConstants.NO_ID) { mProcessPriority.select(mProcessPriorityIndex); return; } } } } mProcessPriorityIndex = mProcessPriority.getSelectionIndex(); } }); }
From source file:net.sf.eclipsensis.startup.FileAssociationChecker.java
License:Open Source License
private void scheduleJob(final FileAssociationDef def) { if (def != null) { Job job = new UIJob(mJobName) { private boolean isValidEditor(String[] editorIds, IEditorDescriptor descriptor) { if (descriptor != null) { String id = descriptor.getId(); for (int i = 0; i < editorIds.length; i++) { if (editorIds[i].equals(id)) { return true; }//from w w w. j a va 2s .c o m } } return false; } @Override public IStatus runInUIThread(final IProgressMonitor monitor) { if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } if (!cCheckedAssociations.contains(def.getAssociationId())) { final boolean toggleState = getFileAssociationChecking(def.getAssociationId()); if (toggleState) { cCheckedAssociations.add(def.getAssociationId()); final String[] fileTypes = def.getFileTypes(); for (int i = 0; i < fileTypes.length; i++) { if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } if (!isValidEditor(def.getEditorIds(), mEditorRegistry.getDefaultEditor(fileTypes[i]))) { if (!monitor.isCanceled()) { String[] args = new String[] { def.getFileTypesName(), def.getEditorsName() }; MessageDialogWithToggle dialog = MessageDialogWithToggle .openYesNoCancelQuestion( PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getShell(), mDialogTitleFormat.format(args), mDialogMessageFormat.format(args), mDialogToggleMessageFormat.format(args), !toggleState, null, null); int rc = dialog.getReturnCode(); switch (rc) { case IDialogConstants.YES_ID: { for (int j = 0; j < fileTypes.length; j++) { mEditorRegistry.setDefaultEditor(fileTypes[j], def.getEditorIds()[0]); } //Cast to inner class because otherwise it cannot be saved. ((EditorRegistry) mEditorRegistry).saveAssociations(); //Fall through to next case to save the toggle state } //$FALL-THROUGH$ case IDialogConstants.NO_ID: { boolean newToggleState = !dialog.getToggleState(); if (toggleState != newToggleState) { setFileAssociationChecking(def.getAssociationId(), newToggleState); } break; } case IDialogConstants.CANCEL_ID: return Status.CANCEL_STATUS; } } break; } } } } if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } else { return Status.OK_STATUS; } } }; job.setRule(cSchedulingRule); job.schedule(5000); } }
From source file:net.sf.eclipsensis.wizard.NSISWizardContentsPage.java
License:Open Source License
/** * @param tv// w ww .j a va 2 s . c o m * @param sel */ private void deleteElements(final TreeViewer tv, ISelection sel) { if (sel instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) sel; if (!ssel.isEmpty()) { try { int buttonId = -1; for (Iterator<?> iter = ssel.iterator(); iter.hasNext();) { INSISInstallElement element = (INSISInstallElement) iter.next(); if (element.hasChildren()) { if (buttonId == IDialogConstants.NO_TO_ALL_ID) { continue; } else if (buttonId != IDialogConstants.YES_TO_ALL_ID) { int index = new MessageDialog(getShell(), cDeleteConfirmTitle, EclipseNSISPlugin.getShellImage(), MessageFormat .format(cDeleteConfirmMessageFormat, new Object[] { element.getDisplayName() }), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL }, 0).open(); if (index >= 0) { buttonId = cDeleteConfirmButtonIds[index]; } else { return; } if (buttonId == IDialogConstants.NO_ID || buttonId == IDialogConstants.NO_TO_ALL_ID) { continue; } } } INSISInstallElement parent = element.getParent(); if (parent != null) { parent.removeChild(element); tv.refresh(parent, true); } } setPageComplete(validatePage(VALIDATE_ALL)); } catch (Exception ex) { delayedValidateAfterError(ex.getLocalizedMessage(), 2000); } finally { tv.refresh(false); } } } }
From source file:net.sourceforge.eclipseccase.ClearCaseModificationHandler.java
License:Open Source License
/** * Checks out the specified files.//w w w . java 2 s.c o m * * @param files * @return a status describing the result */ private IStatus checkout(final IFile[] files) { ClearCaseProvider provider = getProvider(files); if (PreventCheckoutHelper.isPreventedFromCheckOut(provider, files, ClearCasePreferences.isSilentPrevent())) { return CANCEL; } if (!PreventCheckoutHelper.isPromtedCoTypeOk()) { return CANCEL; } if (ClearCasePreferences.isCheckoutAutoNever()) return CANCEL; if (!ClearCasePreferences.isCheckoutAutoAlways()) { //CheckoutQuestionRunnable checkoutQuestion = new CheckoutQuestionRunnable(); CheckoutQuestionRunnable checkoutQuestion = new CheckoutQuestionRunnable(files); getDisplay().syncExec(checkoutQuestion); int returncode = checkoutQuestion.getResult(); if (checkoutQuestion.isRemember()) { if (returncode == IDialogConstants.YES_ID) ClearCasePreferences.setCheckoutAutoAlways(); else if (returncode == IDialogConstants.NO_ID) ClearCasePreferences.setCheckoutAutoNever(); } if (returncode != IDialogConstants.YES_ID) return new Status(IStatus.CANCEL, ClearCasePlugin.PLUGIN_ID, "Checkout operation failed, operation was cancelled by user."); } // check for provider if (null == provider) return new Status(IStatus.ERROR, ClearCaseProvider.ID, TeamException.NOT_CHECKED_OUT, "No ClearCase resources!", new IllegalStateException("Provider is null!")); // checkout try { synchronized (provider) { boolean refreshing = setResourceRefreshing(provider, false); try { if (ClearCasePreferences.isUseClearDlg()) { ClearDlgHelper.checkout(files); } for (int i = 0; i < files.length; i++) { IFile file = files[i]; if (!ClearCasePreferences.isUseClearDlg()) { provider.checkout(new IFile[] { file }, IResource.DEPTH_ZERO, null); } file.refreshLocal(IResource.DEPTH_ZERO, null); } } finally { setResourceRefreshing(provider, refreshing); } } } catch (CoreException ex) { return ex.getStatus(); } return OK; }
From source file:nexcore.tool.uml.ui.core.registry.ResourceManager.java
License:Open Source License
/** * /*from w ww . ja v a 2s . c om*/ * * void */ private void addUMLResourceChangeListener() { UMLResourceChangeManager rcm = UMLResourceChangeManager.getInstance(); rcm.addResourceChangeListener(new UMLResourceChangeAdapter() { public void preProjectClose(IResourceChangeEvent event) { preProjectDelete(event); } public void preProjectDelete(final IResourceChangeEvent event) { // ? Display.getDefault().syncExec(new Runnable() { public void run() { try { ProjectUtil.closeEditor((IProject) event.getResource()); } catch (Exception e) { e.printStackTrace(); } List<Resource> saveableList = hasModifiedResource( new IResource[] { (IProject) event.getResource() }); boolean isSave = false; int choice = IDialogConstants.NO_ID; if (saveableList.size() > 0) { final boolean canCancel = true; String[] buttons; buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; String message = String.format("'%s' has been modified. Save changes?", saveableList.get(0).getURI()); ; MessageDialog dialog = new MessageDialog(getShell(), "Save Resource", null, message, MessageDialog.QUESTION, buttons, 0) { protected int getShellStyle() { return (canCancel ? SWT.CLOSE : SWT.NONE) | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL | getDefaultOrientation(); } }; choice = dialog.open(); switch (choice) { case ISaveablePart2.YES: isSave = true; cleanResource(new NullProgressMonitor(), new IResource[] { (IProject) event.getResource() }, isSave); break; case ISaveablePart2.NO: isSave = false; cleanResource(new NullProgressMonitor(), new IResource[] { (IProject) event.getResource() }, isSave); break; case ISaveablePart2.CANCEL: break; default: break; } } else { cleanResource(new NullProgressMonitor(), new IResource[] { (IProject) event.getResource() }, isSave); } ProjectUtil.refreshExplorer(); // IProject[] activeUMLProjects = ProjectUtil.getActiveUMLProjects(); // // for(IProject project : activeUMLProjects) { // try { // project.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor()); // } catch (CoreException e) { // e.printStackTrace(); // } // } } }); } public void projectOpened(IProject[] projects) { if (PROJECT_OPEN_IMPORT) { // import ? ? for (IProject project : projects) { openProject.add(project); } return; } for (IProject project : projects) { if (referencedProject.containsKey(project)) { referencedProject.put(project, Boolean.TRUE); IProject[] refProjects = referencedProject.keySet().toArray(new IProject[0]); boolean isOpened = allOpened(); if (isOpened) { initializeModelingData(refProjects, false); referencedProject.clear(); } return; } } initializeModelingData(projects, false); } public boolean allOpened() { for (Iterator<IProject> iterator = referencedProject.keySet().iterator(); iterator.hasNext();) { IProject project = (IProject) iterator.next(); if (!referencedProject.get(project)) { return false; } } return true; } }); // UMLResourceChangeAdapter listener = new UMLResourceChangeAdapter() { // @Override // public void projectOpened(IProject[] projects) { // for (IProject project : projects) { //// referencedProject.remove(project); // } // } // }; // rcm.addResourceChangeListener(listener); }
From source file:nexcore.tool.uml.ui.project.builder.CleanAction.java
License:Open Source License
/** * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) *//*from ww w .j a v a 2 s . co m*/ @SuppressWarnings("unchecked") public void run(final IAction action) { if ((null == selection) || (!(selection instanceof IStructuredSelection))) { return; } final List<IProject> projectList = new ArrayList<IProject>(); for (Iterator iterator = ((IStructuredSelection) selection).iterator(); iterator.hasNext();) { Object obj = (Object) iterator.next(); IProject project = ProjectUtil.findProject(obj); if (ProjectUtil.isActiveUMLProject(project) && !projectList.contains(project)) { projectList.add(project); } } Display.getDefault().syncExec(new Runnable() { public void run() { CommonViewer commonViewer = ViewerRegistry.getViewer(); TreePath[] expanedTreePaths = TreeItemUtil.getExpandTreePaths(commonViewer.getTree()).clone(); List<Resource> saveableList = ResourceManager .hasModifiedResource(projectList.toArray(new IResource[] {})); boolean isSave = false; int choice = IDialogConstants.NO_ID; if (saveableList.size() > 0) { final boolean canCancel = true; String[] buttons; buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; String message = NLS.bind(WorkbenchMessages.EditorManager_saveChangesQuestion, saveableList.get(0).getURI()); MessageDialog dialog = new MessageDialog(ViewerRegistry.getViewer().getTree().getShell(), WorkbenchMessages.Save_Resource, null, message, MessageDialog.QUESTION, buttons, 0) { protected int getShellStyle() { return (canCancel ? SWT.CLOSE : SWT.NONE) | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL | getDefaultOrientation(); } }; choice = dialog.open(); switch (choice) { case ISaveablePart2.YES: isSave = true; break; case ISaveablePart2.NO: isSave = false; break; case ISaveablePart2.CANCEL: // return; default: break; } } ResourceManager.cleanResource(new NullProgressMonitor(), projectList.toArray(new IResource[] {}), isSave); cleanTreeNode(projectList); TreeItemUtil.expandTreePath(expanedTreePaths, selection); } private void cleanTreeNode(final List<IProject> projectList) { Map<String, ITreeNode> treeNodes = ProjectRegistry.UMLTreeNodeRegistry.getTreeNodes(); List<Object> removeTarget = new ArrayList<Object>(); for (Iterator<String> iterator = treeNodes.keySet().iterator(); iterator.hasNext();) { String type = (String) iterator.next(); for (IResource resource : projectList) { URI uri = URI.createURI(resource.getFullPath().toString()); if (type.indexOf(uri.toString()) > -1) { removeTarget.add(type); treeNodes.get(type).refresh(); } } } // UMLTreeNodeRegistry.getTreeNodes() ? ? for (Object o : removeTarget) { // ProjectRegistry.UMLTreeNodeRegistry.removeTreeNode(o); } for (IProject project : projectList) { ViewerRegistry.getViewer().refresh(project); } ResourceManager.getInstance().initializeModelingData(projectList.toArray(new IProject[] {}), true); } }); }
From source file:org.apache.felix.sigil.eclipse.ui.internal.preferences.OptionalPrompt.java
License:Apache License
public static int optionallyPromptWithCancel(IPreferenceStore prefStore, String prefName, String title, String text, Shell parentShell) { int result = IDialogConstants.NO_ID; PromptablePreference value = preference(prefStore, prefName); switch (value) { case Always://from w w w . j a va 2 s . c o m result = IDialogConstants.YES_ID; break; case Never: result = IDialogConstants.NO_ID; break; case Prompt: MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion(parentShell, title, text, "Do not ask this again", false, null, null); result = dialog.getReturnCode(); if (result != IDialogConstants.CANCEL_ID) { if (dialog.getToggleState()) { // User said don't ask again... take the current answer as the new preference prefStore.setValue(prefName, (result == IDialogConstants.YES_ID) ? PromptablePreference.Always.name() : PromptablePreference.Never.name()); } } } return result; }
From source file:org.apache.felix.sigil.eclipse.ui.util.ProjectUtils.java
License:Apache License
private static int checkRebuild(Shell shell) { if (SigilCore.getRoot().getProjects().isEmpty()) { return IDialogConstants.NO_ID; } else {//from w ww .j a va2 s.c o m return OptionalPrompt.optionallyPromptWithCancel(SigilCore.PREFERENCES_REBUILD_PROJECTS, "Rebuild", "Do you wish to rebuild all Sigil projects", shell); } }
From source file:org.apache.felix.sigil.ui.eclipse.ui.preferences.OptionalPrompt.java
License:Apache License
public static int optionallyPromptWithCancel(IPreferenceStore prefStore, String prefName, String title, String text, Shell parentShell) { int result = IDialogConstants.NO_ID; PromptablePreference value = PromptablePreference.valueOf(prefStore.getString(prefName)); switch (value) { case Always:/*from w w w . j a va 2 s.com*/ result = IDialogConstants.YES_ID; break; case Never: result = IDialogConstants.NO_ID; break; case Prompt: MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion(parentShell, title, text, "Do not ask this again", false, null, null); result = dialog.getReturnCode(); if (result != IDialogConstants.CANCEL_ID) { if (dialog.getToggleState()) { // User said don't ask again... take the current answer as the new preference prefStore.setValue(prefName, (result == IDialogConstants.YES_ID) ? PromptablePreference.Always.name() : PromptablePreference.Never.name()); } } } return result; }