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.sf.eclipsensis.util.NSISCompileTestUtility.java
License:Open Source License
private boolean saveEditors(List<IEditorPart> editors, int beforeCompileSave) { List<IEditorPart> editors2 = editors; if (!Common.isEmptyCollection(editors2)) { boolean ok = false; String message = null;//from w ww . ja v a 2s.c o m switch (beforeCompileSave) { case INSISPreferenceConstants.BEFORE_COMPILE_SAVE_ASSOCIATED_CONFIRM: if (editors2.size() > 1) { StringBuffer buf = new StringBuffer(); for (Iterator<IEditorPart> iter = editors2.iterator(); iter.hasNext();) { IEditorPart editor = iter.next(); buf.append(INSISConstants.LINE_SEPARATOR).append( ((IFileEditorInput) editor.getEditorInput()).getFile().getFullPath().toString()); } message = EclipseNSISPlugin.getFormattedString("compile.save.associated.confirmation", //$NON-NLS-1$ new String[] { buf.toString() }); break; } //$FALL-THROUGH$ case INSISPreferenceConstants.BEFORE_COMPILE_SAVE_CURRENT_CONFIRM: IEditorPart editor = editors2.get(0); if (editors2.size() > 1) { editors2 = editors2.subList(0, 1); } IPathEditorInput input = NSISEditorUtilities.getPathEditorInput(editor); IPath path = (input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile().getFullPath() : input.getPath()); message = EclipseNSISPlugin.getFormattedString("compile.save.current.confirmation", //$NON-NLS-1$ new String[] { path.toString() }); break; case INSISPreferenceConstants.BEFORE_COMPILE_SAVE_ALL_CONFIRM: message = EclipseNSISPlugin.getResourceString("compile.save.all.confirmation"); //$NON-NLS-1$ break; case INSISPreferenceConstants.BEFORE_COMPILE_SAVE_CURRENT_AUTO: case INSISPreferenceConstants.BEFORE_COMPILE_SAVE_ASSOCIATED_AUTO: case INSISPreferenceConstants.BEFORE_COMPILE_SAVE_ALL_AUTO: ok = true; } Shell shell = Display.getDefault().getActiveShell(); if (!ok) { MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, EclipseNSISPlugin.getResourceString("confirm.title"), //$NON-NLS-1$ EclipseNSISPlugin.getShellImage(), message, MessageDialog.QUESTION, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0, EclipseNSISPlugin.getResourceString("compile.save.toggle.message"), false); //$NON-NLS-1$ dialog.open(); ok = dialog.getReturnCode() == IDialogConstants.OK_ID; if (ok && dialog.getToggleState()) { NSISPreferences.getInstance().setBeforeCompileSave( beforeCompileSave | INSISPreferenceConstants.BEFORE_COMPILE_SAVE_AUTO_FLAG); NSISPreferences.getInstance().store(); } } if (ok) { ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); dialog.open(); IProgressMonitor progressMonitor = dialog.getProgressMonitor(); if (editors2.size() > 1) { progressMonitor.beginTask( EclipseNSISPlugin.getResourceString("saving.before.compilation.task.name"), //$NON-NLS-1$ editors2.size()); for (Iterator<IEditorPart> iter = editors2.iterator(); iter.hasNext();) { IEditorPart editor = iter.next(); SubProgressMonitor monitor = new SubProgressMonitor(progressMonitor, 1); editor.doSave(monitor); if (monitor.isCanceled()) { break; } } } else { editors2.get(0).doSave(progressMonitor); } dialog.close(); if (progressMonitor.isCanceled()) { return false; } } return ok; } return true; }
From source file:net.sf.jmoney.entrytable.BaseEntryRowControl.java
License:Open Source License
/** * Validate the changes made by the user to this row and, if they are valid, * commit them./*from w w w.j a v a 2s . c om*/ * <P> * The changes may not be committed for a number of reasons. Perhaps they * did not meet the restrictions imposed by a validating listener, or * perhaps the user responded to a dialog in a way that indicated that the * changes should not be committed. * <P> * If false is returned then the caller should not move the selection off * this row. * * @return true if the changes are either valid and were committed or were * discarded by the user, false if the changes were neither committed * nor discarded (and thus remain outstanding) */ public boolean commitChanges(String transactionLabel) { // If changes have been made then check they are valid and ask // the user if the changes should be committed. if (transactionManager.hasChanges()) { // Validate the transaction. // TODO: itemWithError is not actually used. See if there is an // easy way of accessing the relevant controls. Otherwise we should // delete this. try { baseValidation(uncommittedEntryData.getEntry().getTransaction()); // Do any specific processing in derived classes. specificValidation(); } catch (InvalidUserEntryException e) { MessageDialog dialog = new MessageDialog(getShell(), Messages.BaseEntryRowControl_ErrorTitle, null, // accept the default window icon e.getLocalizedMessage(), MessageDialog.ERROR, new String[] { Messages.BaseEntryRowControl_Discard, IDialogConstants.CANCEL_LABEL }, 1); int result = dialog.open(); if (result == 0) { // Discard // TODO: Some of this code is duplicated below. transactionManager = new TransactionManager(committedEntryData.getBaseSessionManager()); Entry entryInTransaction; if (committedEntryData.getEntry() == null) { Transaction newTransaction = transactionManager.getSession().createTransaction(); entryInTransaction = createNewEntry(newTransaction); } else { entryInTransaction = transactionManager.getCopyInTransaction(committedEntryData.getEntry()); } // Update the controls. /* * We create a new EntryData object. This is important so * that we start over with the 'fluid' fields and other * stuff. These are reset when we set the input. We reset * the input to the same value to get the 'fluid' fields * reset. We are re-using the objects for the new entry, but * if fields have been set to be not fluid then we must * ensure they are fluid again. Without this calculated * values are not being calculated. */ uncommittedEntryData = createUncommittedEntryData(entryInTransaction, transactionManager); uncommittedEntryData.setIndex(committedEntryData.getIndex()); uncommittedEntryData.setBalance(committedEntryData.getBalance()); for (final IPropertyControl<? super T> control : controls.values()) { control.load(uncommittedEntryData); } this.setInput(uncommittedEntryData); return true; } else { // Cancel the selection change if (e.getItemWithError() != null) { e.getItemWithError().setFocus(); } return false; } } // Commit the changes to the transaction transactionManager.commit(transactionLabel); // Sound the tone // clip.play(); /* * It may be that this was a new entry not previously committed. If * so, the committed entry in the EntryData object will be null. In * this case we now clear out the controls so that it is ready for * the next new transaction. (A new row will have been created for * the new entry that we have just committed because the table is * listening for new entries). * * This listener should also have caused the balance for the new * entry row to be updated. */ if (committedEntryData.getEntry() == null) { Transaction newTransaction = transactionManager.getSession().createTransaction(); Entry entryInTransaction = createNewEntry(newTransaction); // Update the controls. uncommittedEntryData = createUncommittedEntryData(entryInTransaction, transactionManager); uncommittedEntryData.setIndex(committedEntryData.getIndex()); uncommittedEntryData.setBalance(committedEntryData.getBalance()); // Load all top level controls with this data. for (final IPropertyControl<? super T> control : controls.values()) { control.load(uncommittedEntryData); } } } return true; }
From source file:net.sf.jmoney.gnucashXML.AccountChooser.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { // create OK and Cancel buttons by default okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); //do this here because setting the text will set enablement on the ok button text.setFocus();/*from ww w.j a v a 2s . c o m*/ if (value != null) { text.setText(value); text.selectAll(); } }
From source file:net.sf.jmoney.qif.AccountChooser.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { // create OK and Cancel buttons by default okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); //do this here because setting the text will set enablement on the ok button text.setFocus();// w ww . j a va 2 s . c o m if (value != null) { text.setText(value); text.selectAll(); } }
From source file:net.sf.jmoney.reconciliation.reconcilePage.NewStatementDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { // create OK and Cancel buttons by default okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); }
From source file:net.sf.jmoney.serializeddatastore.SessionManager.java
License:Open Source License
boolean requestSave(IWorkbenchWindow window) { String title = Messages.SessionManager_SaveTitle; String question = Messages.SessionManager_SaveQuestion; MessageDialog dialog = new MessageDialog(window.getShell(), title, null, // accept the default window icon question, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); // CANCEL is the // default//from w w w . j a va 2 s . c om int answer = dialog.open(); switch (answer) { case 0: // YES saveSession(window); return true; case 1: // NO return true; case 2: // CANCEL return false; default: throw new RuntimeException("bad switch value"); //$NON-NLS-1$ } }
From source file:net.sf.jmoney.transactionDialog.TransactionDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { createButton(parent, NEW_SPLIT_ID, Messages.TransactionDialog_ButtonTextNewSplit, false); createButton(parent, DELETE_SPLIT_ID, Messages.TransactionDialog_ButtonTextDeleteSplit, false); createButton(parent, ADJUST_AMOUNT_ID, Messages.TransactionDialog_ButtonTextAdjustAmont, false); // create OK and Cancel buttons by default createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); }
From source file:net.sf.jmoney.views.feedback.FeedbackHistorySelectionDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OPEN_LABEL, true); createButton(parent, IDialogConstants.OPEN_ID, "Open in &New", false); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); }
From source file:net.sf.versiontree.views.VersionTreeView.java
License:Open Source License
private boolean confirmOverwrite() { IFile file = getFile();//from w w w. jav a 2 s. co m if (file != null && file.exists()) { ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file); try { if (cvsFile.isModified(null)) { String title = VersionTreePlugin.getResourceString("VersionTreeView.CVS_Version_Tree_Name"); //$NON-NLS-1$ String msg = VersionTreePlugin.getResourceString("VersionTreeView.Overwrite_Changes_Question"); //$NON-NLS-1$ final MessageDialog dialog = new MessageDialog(getViewSite().getShell(), title, null, msg, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, 0); final int[] result = new int[1]; getViewSite().getShell().getDisplay().syncExec(new Runnable() { public void run() { result[0] = dialog.open(); } }); if (result[0] != 0) { // cancel return false; } } } catch (CVSException e) { CVSUIPlugin.log(e.getStatus()); } } return true; }
From source file:net.sourceforge.sqlexplorer.dialogs.FilterStructureDialog.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); }