001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.pde.internal.ui.preferences;
011:
012: import org.eclipse.jface.dialogs.Dialog;
013: import org.eclipse.jface.preference.IPreferenceStore;
014: import org.eclipse.jface.preference.PreferencePage;
015: import org.eclipse.pde.internal.ui.IHelpContextIds;
016: import org.eclipse.pde.internal.ui.IPreferenceConstants;
017: import org.eclipse.pde.internal.ui.PDEPlugin;
018: import org.eclipse.pde.internal.ui.PDEUIMessages;
019: import org.eclipse.swt.SWT;
020: import org.eclipse.swt.layout.GridData;
021: import org.eclipse.swt.layout.GridLayout;
022: import org.eclipse.swt.widgets.Button;
023: import org.eclipse.swt.widgets.Composite;
024: import org.eclipse.swt.widgets.Control;
025: import org.eclipse.swt.widgets.Group;
026: import org.eclipse.ui.IWorkbench;
027: import org.eclipse.ui.IWorkbenchPreferencePage;
028: import org.eclipse.ui.PlatformUI;
029:
030: public class MainPreferencePage extends PreferencePage implements
031: IWorkbenchPreferencePage {
032: private Button fUseID;
033: private Button fUseName;
034: private Button fAutoManage;
035:
036: public MainPreferencePage() {
037: setPreferenceStore(PDEPlugin.getDefault().getPreferenceStore());
038: setDescription(PDEUIMessages.Preferences_MainPage_Description);
039: }
040:
041: protected Control createContents(Composite parent) {
042: IPreferenceStore store = PDEPlugin.getDefault()
043: .getPreferenceStore();
044:
045: Composite composite = new Composite(parent, SWT.NONE);
046: GridLayout layout = new GridLayout();
047: layout.verticalSpacing = 15;
048: composite.setLayout(layout);
049:
050: Group group = new Group(composite, SWT.NONE);
051: group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
052: group.setText(PDEUIMessages.Preferences_MainPage_showObjects);
053: group.setLayout(new GridLayout());
054:
055: fUseID = new Button(group, SWT.RADIO);
056: fUseID.setText(PDEUIMessages.Preferences_MainPage_useIds);
057:
058: fUseName = new Button(group, SWT.RADIO);
059: fUseName
060: .setText(PDEUIMessages.Preferences_MainPage_useFullNames);
061:
062: if (store.getString(IPreferenceConstants.PROP_SHOW_OBJECTS)
063: .equals(IPreferenceConstants.VALUE_USE_IDS)) {
064: fUseID.setSelection(true);
065: } else {
066: fUseName.setSelection(true);
067: }
068:
069: group = new Group(composite, SWT.NONE);
070: group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
071: group.setLayout(new GridLayout());
072: group.setText(PDEUIMessages.MainPreferencePage_group2);
073:
074: fAutoManage = new Button(group, SWT.CHECK);
075: fAutoManage
076: .setText(PDEUIMessages.MainPreferencePage_updateStale);
077: fAutoManage.setSelection(store
078: .getBoolean(IPreferenceConstants.PROP_AUTO_MANAGE));
079: return composite;
080: }
081:
082: public void createControl(Composite parent) {
083: super .createControl(parent);
084: Dialog.applyDialogFont(getControl());
085: PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
086: IHelpContextIds.MAIN_PREFERENCE_PAGE);
087: }
088:
089: public boolean performOk() {
090: IPreferenceStore store = PDEPlugin.getDefault()
091: .getPreferenceStore();
092: if (fUseID.getSelection()) {
093: store.setValue(IPreferenceConstants.PROP_SHOW_OBJECTS,
094: IPreferenceConstants.VALUE_USE_IDS);
095: } else {
096: store.setValue(IPreferenceConstants.PROP_SHOW_OBJECTS,
097: IPreferenceConstants.VALUE_USE_NAMES);
098: }
099: store.setValue(IPreferenceConstants.PROP_AUTO_MANAGE,
100: fAutoManage.getSelection());
101: PDEPlugin.getDefault().savePluginPreferences();
102: return super .performOk();
103: }
104:
105: protected void performDefaults() {
106: IPreferenceStore store = PDEPlugin.getDefault()
107: .getPreferenceStore();
108: if (store.getDefaultString(
109: IPreferenceConstants.PROP_SHOW_OBJECTS).equals(
110: IPreferenceConstants.VALUE_USE_IDS)) {
111: fUseID.setSelection(true);
112: fUseName.setSelection(false);
113: } else {
114: fUseID.setSelection(false);
115: fUseName.setSelection(true);
116: }
117: fAutoManage.setSelection(false);
118: }
119:
120: /*
121: * (non-Javadoc)
122: * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
123: */
124: public void init(IWorkbench workbench) {
125: }
126: }
|