KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > dialogs > YesNoCancelListSelectionDialog


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.dialogs;
12
13 import org.eclipse.jface.dialogs.IDialogConstants;
14 import org.eclipse.swt.widgets.Composite;
15 import org.eclipse.swt.widgets.Shell;
16 import org.eclipse.ui.PlatformUI;
17 import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
18
19 /**
20  * YesNoCancelListSelectionDialog is a list selection dialog that also allows
21  * the user to select no as a result.
22  *
23  * @deprecated Providing Cancel in addition to Yes/No is confusing. It is better
24  * to subclass the regular ListSelectionDialog, which uses
25  * OK/Cancel, and provide a separate checkbox if necessary.
26  */

27 public class YesNoCancelListSelectionDialog extends ListSelectionDialog {
28     /**
29      *
30      * Create a list selection dialog with a possible Yes/No or Cancel result.
31      *
32      * @param parentShell
33      * @param input
34      * @param contentProvider
35      * @param labelProvider
36      * @param message
37      * @deprecated see class comment
38      */

39     public YesNoCancelListSelectionDialog(
40             org.eclipse.swt.widgets.Shell parentShell,
41             Object JavaDoc input,
42             org.eclipse.jface.viewers.IStructuredContentProvider contentProvider,
43             org.eclipse.jface.viewers.ILabelProvider labelProvider,
44             String JavaDoc message) {
45         super(parentShell, input, contentProvider, labelProvider, message);
46     }
47
48     /*
49      * (non-Javadoc) Method declared on Dialog.
50      */

51     protected void buttonPressed(int buttonId) {
52         switch (buttonId) {
53         case IDialogConstants.YES_ID: {
54             yesPressed();
55             return;
56         }
57         case IDialogConstants.NO_ID: {
58             noPressed();
59             return;
60         }
61         case IDialogConstants.CANCEL_ID: {
62             cancelPressed();
63             return;
64         }
65         }
66     }
67
68     /*
69      * (non-Javadoc) Method declared in Window.
70      */

71     protected void configureShell(Shell shell) {
72         super.configureShell(shell);
73         PlatformUI.getWorkbench().getHelpSystem().setHelp(shell,
74                 IWorkbenchHelpContextIds.YES_NO_CANCEL_LIST_SELECTION_DIALOG);
75     }
76
77     /*
78      * (non-Javadoc) Method declared on Dialog.
79      */

80     protected void createButtonsForButtonBar(Composite parent) {
81         createButton(parent, IDialogConstants.YES_ID,
82                 IDialogConstants.YES_LABEL, true);
83         createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL,
84                 false);
85         createButton(parent, IDialogConstants.CANCEL_ID,
86                 IDialogConstants.CANCEL_LABEL, false);
87     }
88
89     /**
90      * Notifies that the no button of this dialog has been pressed.
91      * <p>
92      * The <code>Dialog</code> implementation of this framework method sets
93      * this dialog's return code to <code>IDialogConstants.NO_ID</code> and
94      * closes the dialog. Subclasses may override if desired.
95      * </p>
96      */

97     protected void noPressed() {
98         setReturnCode(IDialogConstants.NO_ID);
99         close();
100     }
101
102     /**
103      * Notifies that the yes button of this dialog has been pressed. Do the same
104      * as an OK but set the return code to YES_ID instead.
105      */

106     protected void yesPressed() {
107         okPressed();
108         setReturnCode(IDialogConstants.YES_ID);
109     }
110 }
111
Popular Tags