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.pde.internal.ui.editor.text.ColorManager;
020: import org.eclipse.swt.SWT;
021: import org.eclipse.swt.events.SelectionAdapter;
022: import org.eclipse.swt.events.SelectionEvent;
023: import org.eclipse.swt.layout.GridData;
024: import org.eclipse.swt.widgets.Button;
025: import org.eclipse.swt.widgets.Composite;
026: import org.eclipse.swt.widgets.Control;
027: import org.eclipse.swt.widgets.Link;
028: import org.eclipse.swt.widgets.TabFolder;
029: import org.eclipse.swt.widgets.TabItem;
030: import org.eclipse.ui.IWorkbench;
031: import org.eclipse.ui.IWorkbenchPreferencePage;
032: import org.eclipse.ui.PlatformUI;
033: import org.eclipse.ui.dialogs.PreferencesUtil;
034:
035: public class EditorPreferencePage extends PreferencePage implements
036: IWorkbenchPreferencePage, IPreferenceConstants {
037:
038: private XMLSyntaxColorTab fXMLTab;
039: private ManifestSyntaxColorTab fManifestTab;
040: private ColorManager fColorManager;
041:
042: public EditorPreferencePage() {
043: setDescription(PDEUIMessages.EditorPreferencePage_colorSettings);
044: fColorManager = new ColorManager();
045: }
046:
047: public boolean performOk() {
048: fXMLTab.performOk();
049: fManifestTab.performOk();
050: PDEPlugin.getDefault().savePluginPreferences();
051: return super .performOk();
052: }
053:
054: public void dispose() {
055: fColorManager.disposeColors(false);
056: fXMLTab.dispose();
057: fManifestTab.dispose();
058: super .dispose();
059: }
060:
061: protected void performDefaults() {
062: fXMLTab.performDefaults();
063: fManifestTab.performDefaults();
064: super .performDefaults();
065: }
066:
067: public void init(IWorkbench workbench) {
068: }
069:
070: protected Control createContents(Composite parent) {
071: final Link link = new Link(parent, SWT.NONE);
072: final String target = "org.eclipse.ui.preferencePages.GeneralTextEditor"; //$NON-NLS-1$
073: link.setText(PDEUIMessages.EditorPreferencePage_link);
074: link.addSelectionListener(new SelectionAdapter() {
075: public void widgetSelected(SelectionEvent e) {
076: PreferencesUtil.createPreferenceDialogOn(link
077: .getShell(), target, null, null);
078: }
079: });
080:
081: GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
082:
083: Button foldingButton = new Button(parent, SWT.CHECK | SWT.LEFT
084: | SWT.WRAP);
085: foldingButton
086: .setText(PDEUIMessages.EditorPreferencePage_folding);
087: foldingButton.setLayoutData(gd);
088: foldingButton.setSelection(PDEPlugin.getDefault()
089: .getPreferenceStore().getBoolean(
090: IPreferenceConstants.EDITOR_FOLDING_ENABLED));
091: foldingButton.addSelectionListener(new SelectionAdapter() {
092: public void widgetSelected(SelectionEvent e) {
093: IPreferenceStore store = PDEPlugin.getDefault()
094: .getPreferenceStore();
095: store.setValue(
096: IPreferenceConstants.EDITOR_FOLDING_ENABLED,
097: ((Button) e.getSource()).getSelection());
098: }
099: });
100:
101: TabFolder folder = new TabFolder(parent, SWT.NONE);
102: folder.setLayout(new TabFolderLayout());
103: folder.setLayoutData(new GridData(GridData.FILL_BOTH));
104:
105: createXMLTab(folder);
106: createManifestTab(folder);
107:
108: Dialog.applyDialogFont(getControl());
109: PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
110: IHelpContextIds.EDITOR_PREFERENCE_PAGE);
111:
112: return parent;
113: }
114:
115: private void createXMLTab(TabFolder folder) {
116: fXMLTab = new XMLSyntaxColorTab(fColorManager);
117: TabItem item = new TabItem(folder, SWT.NONE);
118: item.setText(PDEUIMessages.EditorPreferencePage_xml);
119: item.setControl(fXMLTab.createContents(folder));
120: }
121:
122: private void createManifestTab(TabFolder folder) {
123: fManifestTab = new ManifestSyntaxColorTab(fColorManager);
124: TabItem item = new TabItem(folder, SWT.NONE);
125: item.setText(PDEUIMessages.EditorPreferencePage_manifest);
126: item.setControl(fManifestTab.createContents(folder));
127: }
128:
129: }
|