List of usage examples for org.eclipse.jface.dialogs IDialogConstants CANCEL_LABEL
String CANCEL_LABEL
To view the source code for org.eclipse.jface.dialogs IDialogConstants CANCEL_LABEL.
Click Source Link
From source file:net.xmind.workbench.ui.internal.NewsletterSubscriptionDialog.java
@Override protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); text.setFocus();/*from w ww . j a v a 2 s . c o m*/ if (value != null) { text.setText(value); text.selectAll(); } }
From source file:net.yatomiya.e4.ui.dialogs.TextMessageDialog.java
License:Open Source License
static String[] getButtonLabels(Type type) { String[] dialogButtonLabels;/* www . j a va 2 s. c o m*/ switch (type) { case NONE: case ERROR: case INFORMATION: case WARNING: { dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL }; break; } case CONFIRM: { dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }; break; } case QUESTION: { dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; break; } case QUESTION_WITH_CANCEL: { dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; break; } default: { throw new IllegalArgumentException("Illegal value for kind in NMessageDialog.open()"); //$NON-NLS-1$ } } return dialogButtonLabels; }
From source file:nexcore.tool.uml.ui.core.registry.ResourceManager.java
License:Open Source License
/** * /*from w w w.ja v a 2 s . co m*/ * * 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 ava 2 s. c om*/ @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:nexcore.tool.uml.ui.project.explorer.dialog.FragmentSaveDialog.java
License:Open Source License
/** * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) *//*from ww w .j ava 2 s .c o m*/ protected void createButtonsForButtonBar(Composite parent) { okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); }
From source file:no.javatime.inplace.ui.dialogs.DependencyDialog.java
License:Open Source License
/** * Create a default, cancel and ok button in the button bar. * @param parent the title area dialog/*from w w w . j av a 2 s . c o m*/ */ @Override protected void createButtonsForButtonBar(Composite parent) { Button btnDefault = createButton(parent, DEFAULT_ID, DEAFAULT_LABEL, false); btnDefault.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { defaultDependencies(); } }); createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); Button btnCancel = createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { cancel(); } }); }
From source file:org.activiti.designer.kickstart.eclipse.sync.FileExistsInFolderDialog.java
License:Apache License
@Override protected void createButtonsForButtonBar(Composite parent) { if (defaultSetup) { createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); Button newVersionButton = createButton(parent, SyncConstants.NEW_VERSION_BUTTON_ID, "Create new version", true); newVersionButton.addSelectionListener(new SelectionAdapter() { @Override/*w w w .j a va 2 s.c om*/ public void widgetSelected(SelectionEvent e) { SyncUtil.startProcessSynchronizationBackgroundJob( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), destination, targetFileName, false, true, sourceFile); close(); } }); } else if (repoVersionIsHigher) { createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true); Button useLocalContentButton = createButton(parent, SyncConstants.USE_LOCAL_CONTENT_BUTTON_ID, "Copy local version to repository", false); useLocalContentButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { SyncUtil.startProcessSynchronizationBackgroundJob( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), destination, targetFileName, false, true, sourceFile); close(); } }); Button useRepoContentButton = createButton(parent, SyncConstants.USE_REPO_CONTENT_BUTTON_ID, "Copy repo version to local file", false); useRepoContentButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { SyncUtil.copyRepoFileToLocalFile(getShell(), sourceFile, destination); close(); } }); } }
From source file:org.apache.directory.studio.aciitemeditor.dialogs.ACIItemDialog.java
License:Apache License
/** * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) *//* w ww . j a va 2s . c o m*/ protected void createButtonsForButtonBar(Composite parent) { createButton(parent, FORMAT_BUTTON, Messages.getString("ACIItemDialog.button.format"), false); //$NON-NLS-1$ createButton(parent, CHECK_SYNTAX_BUTTON, Messages.getString("ACIItemDialog.button.checkSyntax"), false); //$NON-NLS-1$ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); }
From source file:org.apache.directory.studio.apacheds.configuration.editor.ServerConfigurationEditorUtils.java
License:Apache License
/** * Performs the "Save as..." action./*ww w .ja v a 2 s . c om*/ * * @param monitor the monitor * @param shell the shell * @param input the editor input * @param configWriter the configuration writer * @param newInput a flag to indicate if a new input is required * @return the new input for the editor * @throws Exception */ public static IEditorInput saveAs(IProgressMonitor monitor, Shell shell, IEditorInput input, ConfigWriter configWriter, Configuration configuration, boolean newInput) throws Exception { // detect IDE or RCP: // check if perspective org.eclipse.ui.resourcePerspective is available boolean isIDE = CommonUIUtils.isIDEEnvironment(); if (isIDE) { // Asking the user for the location where to 'save as' the file SaveAsDialog dialog = new SaveAsDialog(shell); String inputClassName = input.getClass().getName(); if (input instanceof FileEditorInput) { // FileEditorInput class is used when the file is opened // from a project in the workspace. dialog.setOriginalFile(((FileEditorInput) input).getFile()); } else if (input instanceof IPathEditorInput) { dialog.setOriginalFile( ResourcesPlugin.getWorkspace().getRoot().getFile(((IPathEditorInput) input).getPath())); } else if (inputClassName.equals("org.eclipse.ui.internal.editors.text.JavaFileEditorInput") //$NON-NLS-1$ || inputClassName.equals("org.eclipse.ui.ide.FileStoreEditorInput")) //$NON-NLS-1$ { // The class 'org.eclipse.ui.internal.editors.text.JavaFileEditorInput' // is used when opening a file from the menu File > Open... in Eclipse 3.2.x // The class 'org.eclipse.ui.ide.FileStoreEditorInput' is used when // opening a file from the menu File > Open... in Eclipse 3.3.x dialog.setOriginalFile( ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(input.getToolTipText()))); } else { dialog.setOriginalName(ApacheDS2ConfigurationPluginConstants.CONFIG_LDIF); } // Open the dialog if (openDialogInUIThread(dialog) != Dialog.OK) { return null; } // Getting if the resulting file IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(dialog.getResult()); // Creating the file if it does not exist if (!file.exists()) { file.create(new ByteArrayInputStream("".getBytes()), true, null); //$NON-NLS-1$ } // Creating the new input for the editor FileEditorInput fei = new FileEditorInput(file); // Saving the file to disk File configFile = fei.getPath().toFile(); saveConfiguration(configFile, configWriter, configuration); return fei; } else { boolean canOverwrite = false; String path = null; while (!canOverwrite) { // Open FileDialog path = openFileDialogInUIThread(shell); if (path == null) { return null; } // Check whether file exists and if so, confirm overwrite final File externalFile = new File(path); if (externalFile.exists()) { String question = NLS.bind( Messages.getString("ServerConfigurationEditorUtils.TheFileAlreadyExistsWantToReplace"), //$NON-NLS-1$ path); MessageDialog overwriteDialog = new MessageDialog(shell, Messages.getString("ServerConfigurationEditorUtils.Question"), null, question, //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); int overwrite = openDialogInUIThread(overwriteDialog); switch (overwrite) { case 0: // Yes canOverwrite = true; break; case 1: // No break; case 2: // Cancel default: return null; } } else { canOverwrite = true; } } // Saving the file to disk saveConfiguration(new File(path), configWriter, configuration); // Checking if a new input is required if (newInput) { // Creating the new input for the editor return new PathEditorInput(new Path(path)); } else { return null; } } }
From source file:org.apache.directory.studio.connection.ui.dialogs.ResetPasswordDialog.java
License:Apache License
/** * {@inheritDoc}/*from w w w .j a va 2 s . c o m*/ */ @Override protected void createButtonsForButtonBar(Composite parent) { okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); validate(); }