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.jdt.internal.ui.preferences;
011:
012: import org.eclipse.core.runtime.IAdaptable;
013:
014: import org.eclipse.core.resources.IProject;
015:
016: import org.eclipse.swt.widgets.Composite;
017: import org.eclipse.swt.widgets.Control;
018:
019: import org.eclipse.jface.preference.IPreferencePageContainer;
020:
021: import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
022: import org.eclipse.ui.preferences.IWorkingCopyManager;
023: import org.eclipse.ui.preferences.WorkingCopyManager;
024:
025: import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileConfigurationBlock;
026:
027: public abstract class ProfilePreferencePage extends
028: PropertyAndPreferencePage {
029:
030: private ProfileConfigurationBlock fConfigurationBlock;
031:
032: public ProfilePreferencePage() {
033: super ();
034: }
035:
036: protected abstract ProfileConfigurationBlock createConfigurationBlock(
037: PreferencesAccess access);
038:
039: public void createControl(Composite parent) {
040: IPreferencePageContainer container = getContainer();
041: IWorkingCopyManager workingCopyManager;
042: if (container instanceof IWorkbenchPreferenceContainer) {
043: workingCopyManager = ((IWorkbenchPreferenceContainer) container)
044: .getWorkingCopyManager();
045: } else {
046: workingCopyManager = new WorkingCopyManager(); // non shared
047: }
048: PreferencesAccess access = PreferencesAccess
049: .getWorkingCopyPreferences(workingCopyManager);
050: fConfigurationBlock = createConfigurationBlock(access);
051:
052: super .createControl(parent);
053: }
054:
055: protected Control createPreferenceContent(Composite composite) {
056: return fConfigurationBlock.createContents(composite);
057: }
058:
059: protected boolean hasProjectSpecificOptions(IProject project) {
060: return fConfigurationBlock.hasProjectSpecificOptions(project);
061: }
062:
063: protected void enableProjectSpecificSettings(
064: boolean useProjectSpecificSettings) {
065: super .enableProjectSpecificSettings(useProjectSpecificSettings);
066: if (fConfigurationBlock != null) {
067: fConfigurationBlock
068: .enableProjectSpecificSettings(useProjectSpecificSettings);
069: }
070: }
071:
072: public void dispose() {
073: if (fConfigurationBlock != null) {
074: fConfigurationBlock.dispose();
075: }
076: super .dispose();
077: }
078:
079: protected void performDefaults() {
080: if (fConfigurationBlock != null) {
081: fConfigurationBlock.performDefaults();
082: }
083: super .performDefaults();
084: }
085:
086: public boolean performOk() {
087: if (fConfigurationBlock != null
088: && !fConfigurationBlock.performOk()) {
089: return false;
090: }
091: return super .performOk();
092: }
093:
094: public void performApply() {
095: if (fConfigurationBlock != null) {
096: fConfigurationBlock.performApply();
097: }
098: super .performApply();
099: }
100:
101: public void setElement(IAdaptable element) {
102: super .setElement(element);
103: setDescription(null); // no description for property page
104: }
105:
106: }
|