01: /*******************************************************************************
02: * Copyright (c) 2005, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.preferences;
11:
12: import org.eclipse.jface.dialogs.Dialog;
13: import org.eclipse.jface.resource.JFaceResources;
14: import org.eclipse.swt.SWT;
15: import org.eclipse.swt.layout.GridData;
16: import org.eclipse.swt.layout.GridLayout;
17: import org.eclipse.swt.widgets.Composite;
18: import org.eclipse.swt.widgets.Label;
19: import org.eclipse.swt.widgets.Shell;
20:
21: /**
22: * The ViewSettingsDialog is an abstract class that
23: * provides some common functionality for view preferences.
24: *
25: * @since 3.1
26: */
27: public class ViewSettingsDialog extends Dialog {
28:
29: private static int DEFAULTS_BUTTON_ID = 25;
30:
31: /**
32: * Create a new instance of the receiver.
33: * @param parentShell
34: */
35: public ViewSettingsDialog(Shell parentShell) {
36: super (parentShell);
37: }
38:
39: /* (non-Javadoc)
40: * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
41: */
42: protected void buttonPressed(int buttonId) {
43: if (buttonId == DEFAULTS_BUTTON_ID) {
44: performDefaults();
45: }
46: super .buttonPressed(buttonId);
47: }
48:
49: /**
50: * Performs special processing when this dialog Defaults button has been pressed.
51: * <p>
52: * This is a framework hook method for subclasses to do special things when
53: * the Defaults button has been pressed.
54: * Subclasses may override, but should call <code>super.performDefaults</code>.
55: * </p>
56: */
57: protected void performDefaults() {
58: //Do nothing by default
59:
60: }
61:
62: /* (non-Javadoc)
63: * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
64: */
65: protected void createButtonsForButtonBar(Composite parent) {
66: parent.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
67:
68: createButton(parent, DEFAULTS_BUTTON_ID, JFaceResources
69: .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: }
|