| /******************************************************************************* |
| * Copyright (c) 2003, 2008 IBM Corporation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * IBM Corporation - Initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.wst.server.ui.internal; |
| |
| import org.eclipse.jface.dialogs.Dialog; |
| import org.eclipse.jface.preference.PreferencePage; |
| import org.eclipse.swt.SWT; |
| import org.eclipse.swt.layout.GridData; |
| import org.eclipse.swt.layout.GridLayout; |
| import org.eclipse.swt.widgets.Button; |
| import org.eclipse.swt.widgets.Composite; |
| import org.eclipse.swt.widgets.Control; |
| import org.eclipse.ui.IWorkbench; |
| import org.eclipse.ui.IWorkbenchPreferencePage; |
| import org.eclipse.ui.PlatformUI; |
| import org.eclipse.ui.help.IWorkbenchHelpSystem; |
| import org.eclipse.wst.server.core.internal.ServerPreferences; |
| /** |
| * The preference page that holds server properties. |
| */ |
| public class ServerPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { |
| protected ServerPreferences preferences; |
| protected ServerUIPreferences uiPreferences; |
| |
| protected Button showOnActivity; |
| |
| /** |
| * ServerPreferencesPage constructor comment. |
| */ |
| public ServerPreferencePage() { |
| super(); |
| |
| preferences = ServerPreferences.getInstance(); |
| uiPreferences = ServerUIPlugin.getPreferences(); |
| } |
| |
| /** |
| * Create the preference options. |
| * |
| * @param parent org.eclipse.swt.widgets.Composite |
| * @return org.eclipse.swt.widgets.Control |
| */ |
| protected Control createContents(Composite parent) { |
| initializeDialogUnits(parent); |
| IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); |
| whs.setHelp(parent, ContextIds.PREF_GENERAL); |
| |
| Composite composite = new Composite(parent, SWT.NONE); |
| GridLayout layout = new GridLayout(); |
| layout.horizontalSpacing = convertHorizontalDLUsToPixels(4); |
| layout.verticalSpacing = convertVerticalDLUsToPixels(4); |
| layout.marginWidth = 0; |
| layout.marginHeight = 0; |
| layout.numColumns = 3; |
| composite.setLayout(layout); |
| GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); |
| composite.setLayoutData(data); |
| |
| showOnActivity = new Button(composite, SWT.CHECK); |
| showOnActivity.setText(Messages.prefShowOnActivity); |
| data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); |
| data.horizontalSpan = 3; |
| showOnActivity.setLayoutData(data); |
| showOnActivity.setSelection(uiPreferences.getShowOnActivity()); |
| whs.setHelp(showOnActivity, ContextIds.PREF_GENERAL_SHOW_ON_ACTIVITY); |
| |
| Dialog.applyDialogFont(composite); |
| |
| return composite; |
| } |
| |
| /** |
| * Initializes this preference page using the passed workbench. |
| * |
| * @param workbench the current workbench |
| */ |
| public void init(IWorkbench workbench) { |
| // do nothing |
| } |
| |
| /** |
| * Performs special processing when this page's Defaults button has been pressed. |
| */ |
| protected void performDefaults() { |
| showOnActivity.setSelection(uiPreferences.getDefaultShowOnActivity()); |
| |
| super.performDefaults(); |
| } |
| |
| /** |
| * @see org.eclipse.jface.preference.IPreferencePage#performOk() |
| */ |
| public boolean performOk() { |
| uiPreferences.setShowOnActivity(showOnActivity.getSelection()); |
| |
| return true; |
| } |
| } |