1 /**********************************************************************
2 * Copyright (c) 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM - Initial API and implementation
10 **********************************************************************/
11 package net.sourceforge.phpdt.monitor.ui.internal;
13 import org.eclipse.swt.*;
14 import org.eclipse.swt.layout.*;
15 import org.eclipse.swt.widgets.Button;
16 import org.eclipse.swt.widgets.Composite;
17 import org.eclipse.swt.widgets.Control;
18 import org.eclipse.swt.widgets.Label;
19 import org.eclipse.jface.dialogs.Dialog;
20 import org.eclipse.jface.preference.PreferencePage;
21 import org.eclipse.ui.IWorkbench;
22 import org.eclipse.ui.IWorkbenchPreferencePage;
23 import org.eclipse.ui.help.WorkbenchHelp;
25 * The preference page that holds monitor properties.
27 public class MonitorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
28 protected Button displayButton;
31 * MonitorPreferencePage constructor comment.
33 public MonitorPreferencePage() {
35 noDefaultAndApplyButton();
39 * Create the preference options.
41 * @param parent org.eclipse.swt.widgets.Composite
42 * @return org.eclipse.swt.widgets.Control
44 protected Control createContents(Composite parent) {
45 initializeDialogUnits(parent);
47 Composite composite = new Composite(parent, SWT.NONE);
48 GridLayout layout = new GridLayout();
49 layout.numColumns = 1;
50 layout.horizontalSpacing = convertHorizontalDLUsToPixels(4);
51 layout.verticalSpacing = convertVerticalDLUsToPixels(4);
52 layout.marginWidth = 0;
53 layout.marginHeight = 0;
54 composite.setLayout(layout);
55 GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
56 composite.setLayoutData(data);
57 WorkbenchHelp.setHelp(composite, ContextIds.PREF);
59 Label label = new Label(composite, SWT.WRAP);
60 label.setText(MonitorUIPlugin.getResource("%preferenceDescription"));
61 data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
62 label.setLayoutData(data);
64 displayButton = new Button(composite, SWT.CHECK);
65 displayButton.setText(MonitorUIPlugin.getResource("%prefShowView"));
66 displayButton.setSelection(MonitorUIPlugin.getShowOnActivityPreference());
67 WorkbenchHelp.setHelp(displayButton, ContextIds.PREF_SHOW);
69 label = new Label(composite, SWT.NONE);
72 MonitorComposite monitorComp = new MonitorComposite(composite, SWT.NONE);
73 data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
74 monitorComp.setLayoutData(data);
76 Dialog.applyDialogFont(composite);
82 * Initializes this preference page using the passed desktop.
84 * @param desktop the current desktop
86 public void init(IWorkbench workbench) {
90 * Performs special processing when this page's Defaults button has been pressed.
92 * This is a framework hook method for sublcasses to do special things when
93 * the Defaults button has been pressed.
94 * Subclasses may override, but should call <code>super.performDefaults</code>.
97 protected void performDefaults() {
98 displayButton.setSelection(MonitorUIPlugin.getDefaultShowOnActivityPreference());
99 super.performDefaults();
103 * Method declared on IPreferencePage.
104 * Subclasses should override
106 public boolean performOk() {
107 MonitorUIPlugin.setShowOnActivityPreference(displayButton.getSelection());
108 MonitorUIPlugin.getInstance().savePluginPreferences();