001: /*******************************************************************************
002: * Copyright (c) 2000, 2005 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.dialogs;
011:
012: import org.eclipse.jface.dialogs.IDialogConstants;
013: import org.eclipse.swt.widgets.Composite;
014: import org.eclipse.swt.widgets.Shell;
015: import org.eclipse.ui.PlatformUI;
016: import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
017:
018: /**
019: * YesNoCancelListSelectionDialog is a list selection dialog that also allows
020: * the user to select no as a result.
021: *
022: * @deprecated Providing Cancel in addition to Yes/No is confusing. It is better
023: * to subclass the regular ListSelectionDialog, which uses
024: * OK/Cancel, and provide a separate checkbox if necessary.
025: */
026: public class YesNoCancelListSelectionDialog extends ListSelectionDialog {
027: /**
028: *
029: * Create a list selection dialog with a possible Yes/No or Cancel result.
030: *
031: * @param parentShell
032: * @param input
033: * @param contentProvider
034: * @param labelProvider
035: * @param message
036: * @deprecated see class comment
037: */
038: public YesNoCancelListSelectionDialog(
039: org.eclipse.swt.widgets.Shell parentShell,
040: Object input,
041: org.eclipse.jface.viewers.IStructuredContentProvider contentProvider,
042: org.eclipse.jface.viewers.ILabelProvider labelProvider,
043: String message) {
044: super (parentShell, input, contentProvider, labelProvider,
045: message);
046: }
047:
048: /*
049: * (non-Javadoc) Method declared on Dialog.
050: */
051: protected void buttonPressed(int buttonId) {
052: switch (buttonId) {
053: case IDialogConstants.YES_ID: {
054: yesPressed();
055: return;
056: }
057: case IDialogConstants.NO_ID: {
058: noPressed();
059: return;
060: }
061: case IDialogConstants.CANCEL_ID: {
062: cancelPressed();
063: return;
064: }
065: }
066: }
067:
068: /*
069: * (non-Javadoc) Method declared in Window.
070: */
071: protected void configureShell(Shell shell) {
072: super .configureShell(shell);
073: PlatformUI
074: .getWorkbench()
075: .getHelpSystem()
076: .setHelp(
077: shell,
078: IWorkbenchHelpContextIds.YES_NO_CANCEL_LIST_SELECTION_DIALOG);
079: }
080:
081: /*
082: * (non-Javadoc) Method declared on Dialog.
083: */
084: protected void createButtonsForButtonBar(Composite parent) {
085: createButton(parent, IDialogConstants.YES_ID,
086: IDialogConstants.YES_LABEL, true);
087: createButton(parent, IDialogConstants.NO_ID,
088: IDialogConstants.NO_LABEL, false);
089: createButton(parent, IDialogConstants.CANCEL_ID,
090: IDialogConstants.CANCEL_LABEL, false);
091: }
092:
093: /**
094: * Notifies that the no button of this dialog has been pressed.
095: * <p>
096: * The <code>Dialog</code> implementation of this framework method sets
097: * this dialog's return code to <code>IDialogConstants.NO_ID</code> and
098: * closes the dialog. Subclasses may override if desired.
099: * </p>
100: */
101: protected void noPressed() {
102: setReturnCode(IDialogConstants.NO_ID);
103: close();
104: }
105:
106: /**
107: * Notifies that the yes button of this dialog has been pressed. Do the same
108: * as an OK but set the return code to YES_ID instead.
109: */
110: protected void yesPressed() {
111: okPressed();
112: setReturnCode(IDialogConstants.YES_ID);
113: }
114: }
|