001: /*******************************************************************************
002: * Copyright (c) 2005, 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.properties;
011:
012: import org.eclipse.core.resources.IProject;
013: import org.eclipse.core.resources.ProjectScope;
014: import org.eclipse.jface.dialogs.Dialog;
015: import org.eclipse.pde.internal.core.ICoreConstants;
016: import org.eclipse.pde.internal.core.PDECore;
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.IWorkbenchPropertyPage;
027: import org.eclipse.ui.dialogs.PropertyPage;
028: import org.osgi.service.prefs.BackingStoreException;
029: import org.osgi.service.prefs.Preferences;
030:
031: public class PluginDevelopmentPage extends PropertyPage implements
032: IWorkbenchPropertyPage {
033:
034: private Button fExtensionButton;
035: private Button fEquinoxButton;
036:
037: public PluginDevelopmentPage() {
038: noDefaultAndApplyButton();
039: }
040:
041: protected Control createContents(Composite parent) {
042: Composite composite = new Composite(parent, SWT.NONE);
043: composite.setLayout(new GridLayout());
044: composite.setLayoutData(new GridData(GridData.FILL_BOTH));
045:
046: Group group = new Group(composite, SWT.NONE);
047: group.setText(PDEUIMessages.PluginDevelopmentPage_presentation);
048: group.setLayout(new GridLayout());
049: group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
050:
051: fExtensionButton = new Button(group, SWT.CHECK);
052: fExtensionButton
053: .setText(PDEUIMessages.PluginDevelopmentPage_extensions);
054:
055: fEquinoxButton = new Button(group, SWT.CHECK);
056: fEquinoxButton
057: .setText(PDEUIMessages.PluginDevelopmentPage_equinox);
058:
059: initialize();
060: Dialog.applyDialogFont(composite);
061: return composite;
062: }
063:
064: private void initialize() {
065: Preferences pref = getPreferences((IProject) getElement()
066: .getAdapter(IProject.class));
067: if (pref != null) {
068: fExtensionButton.setSelection(pref.getBoolean(
069: ICoreConstants.EXTENSIONS_PROPERTY, true));
070: fEquinoxButton.setSelection(pref.getBoolean(
071: ICoreConstants.EQUINOX_PROPERTY, true));
072: }
073: }
074:
075: private Preferences getPreferences(IProject project) {
076: return new ProjectScope(project).getNode(PDECore.PLUGIN_ID);
077: }
078:
079: public boolean performOk() {
080: Preferences pref = getPreferences((IProject) getElement()
081: .getAdapter(IProject.class));
082: if (pref != null) {
083: if (!fExtensionButton.getSelection())
084: pref.putBoolean(ICoreConstants.EXTENSIONS_PROPERTY,
085: false);
086: else
087: pref.remove(ICoreConstants.EXTENSIONS_PROPERTY);
088:
089: if (!fEquinoxButton.getSelection())
090: pref.putBoolean(ICoreConstants.EQUINOX_PROPERTY, false);
091: else
092: pref.remove(ICoreConstants.EQUINOX_PROPERTY);
093:
094: try {
095: pref.flush();
096: } catch (BackingStoreException e) {
097: PDEPlugin.logException(e);
098: }
099: }
100: return super.performOk();
101: }
102:
103: }
|