KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > preferences > ViewSettingsDialog


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 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.preferences;
12
13 import org.eclipse.jface.dialogs.Dialog;
14 import org.eclipse.jface.resource.JFaceResources;
15 import org.eclipse.swt.SWT;
16 import org.eclipse.swt.layout.GridData;
17 import org.eclipse.swt.layout.GridLayout;
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.swt.widgets.Label;
20 import org.eclipse.swt.widgets.Shell;
21
22 /**
23  * The ViewSettingsDialog is an abstract class that
24  * provides some common functionality for view preferences.
25  *
26  * @since 3.1
27  */

28 public class ViewSettingsDialog extends Dialog {
29     
30     private static int DEFAULTS_BUTTON_ID = 25;
31     
32     /**
33      * Create a new instance of the receiver.
34      * @param parentShell
35      */

36     public ViewSettingsDialog(Shell parentShell) {
37         super(parentShell);
38     }
39
40     /* (non-Javadoc)
41      * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
42      */

43     protected void buttonPressed(int buttonId) {
44         if (buttonId == DEFAULTS_BUTTON_ID) {
45             performDefaults();
46         }
47         super.buttonPressed(buttonId);
48     }
49
50      /**
51      * Performs special processing when this dialog Defaults button has been pressed.
52      * <p>
53      * This is a framework hook method for subclasses to do special things when
54      * the Defaults button has been pressed.
55      * Subclasses may override, but should call <code>super.performDefaults</code>.
56      * </p>
57      */

58     protected void performDefaults() {
59         //Do nothing by default
60

61     }
62
63     /* (non-Javadoc)
64      * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
65      */

66     protected void createButtonsForButtonBar(Composite parent) {
67         parent.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
68
69         createButton(parent, DEFAULTS_BUTTON_ID, JFaceResources.getString("defaults"), false); //$NON-NLS-1$
70

71         Label l = new Label(parent, SWT.NONE);
72         l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
73
74         l = new Label(parent, SWT.NONE);
75         l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
76
77         GridLayout layout = (GridLayout) parent.getLayout();
78         layout.numColumns += 2;
79         layout.makeColumnsEqualWidth = false;
80
81         super.createButtonsForButtonBar(parent);
82     }
83
84 }
85
Popular Tags