1 11 package org.eclipse.pde.internal.ui.preferences; 12 13 import org.eclipse.jface.dialogs.Dialog; 14 import org.eclipse.jface.preference.IPreferenceStore; 15 import org.eclipse.jface.preference.PreferencePage; 16 import org.eclipse.pde.internal.ui.IHelpContextIds; 17 import org.eclipse.pde.internal.ui.IPreferenceConstants; 18 import org.eclipse.pde.internal.ui.PDEPlugin; 19 import org.eclipse.pde.internal.ui.PDEUIMessages; 20 import org.eclipse.pde.internal.ui.editor.text.ColorManager; 21 import org.eclipse.swt.SWT; 22 import org.eclipse.swt.events.SelectionAdapter; 23 import org.eclipse.swt.events.SelectionEvent; 24 import org.eclipse.swt.layout.GridData; 25 import org.eclipse.swt.widgets.Button; 26 import org.eclipse.swt.widgets.Composite; 27 import org.eclipse.swt.widgets.Control; 28 import org.eclipse.swt.widgets.Link; 29 import org.eclipse.swt.widgets.TabFolder; 30 import org.eclipse.swt.widgets.TabItem; 31 import org.eclipse.ui.IWorkbench; 32 import org.eclipse.ui.IWorkbenchPreferencePage; 33 import org.eclipse.ui.PlatformUI; 34 import org.eclipse.ui.dialogs.PreferencesUtil; 35 36 public class EditorPreferencePage 37 extends PreferencePage 38 implements IWorkbenchPreferencePage, IPreferenceConstants { 39 40 private XMLSyntaxColorTab fXMLTab; 41 private ManifestSyntaxColorTab fManifestTab; 42 private ColorManager fColorManager; 43 44 public EditorPreferencePage() { 45 setDescription(PDEUIMessages.EditorPreferencePage_colorSettings); 46 fColorManager = new ColorManager(); 47 } 48 49 public boolean performOk() { 50 fXMLTab.performOk(); 51 fManifestTab.performOk(); 52 PDEPlugin.getDefault().savePluginPreferences(); 53 return super.performOk(); 54 } 55 56 public void dispose() { 57 fColorManager.disposeColors(false); 58 fXMLTab.dispose(); 59 fManifestTab.dispose(); 60 super.dispose(); 61 } 62 63 protected void performDefaults() { 64 fXMLTab.performDefaults(); 65 fManifestTab.performDefaults(); 66 super.performDefaults(); 67 } 68 69 public void init(IWorkbench workbench) { 70 } 71 72 protected Control createContents(Composite parent) { 73 final Link link = new Link(parent, SWT.NONE); 74 final String target = "org.eclipse.ui.preferencePages.GeneralTextEditor"; link.setText(PDEUIMessages.EditorPreferencePage_link); 76 link.addSelectionListener(new SelectionAdapter() { 77 public void widgetSelected(SelectionEvent e) { 78 PreferencesUtil.createPreferenceDialogOn(link.getShell(), target, null, null); 79 } 80 }); 81 82 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); 83 84 Button foldingButton = new Button(parent, SWT.CHECK | SWT.LEFT | SWT.WRAP); 85 foldingButton.setText(PDEUIMessages.EditorPreferencePage_folding); 86 foldingButton.setLayoutData(gd); 87 foldingButton.setSelection( 88 PDEPlugin.getDefault().getPreferenceStore().getBoolean(IPreferenceConstants.EDITOR_FOLDING_ENABLED)); 89 foldingButton.addSelectionListener(new SelectionAdapter() { 90 public void widgetSelected(SelectionEvent e) { 91 IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore(); 92 store.setValue(IPreferenceConstants.EDITOR_FOLDING_ENABLED, ((Button) e.getSource()).getSelection()); 93 } 94 }); 95 96 TabFolder folder = new TabFolder(parent, SWT.NONE); 97 folder.setLayout(new TabFolderLayout()); 98 folder.setLayoutData(new GridData(GridData.FILL_BOTH)); 99 100 createXMLTab(folder); 101 createManifestTab(folder); 102 103 Dialog.applyDialogFont(getControl()); 104 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.EDITOR_PREFERENCE_PAGE); 105 106 return parent; 107 } 108 109 private void createXMLTab(TabFolder folder) { 110 fXMLTab = new XMLSyntaxColorTab(fColorManager); 111 TabItem item = new TabItem(folder, SWT.NONE); 112 item.setText(PDEUIMessages.EditorPreferencePage_xml); 113 item.setControl(fXMLTab.createContents(folder)); 114 } 115 116 private void createManifestTab(TabFolder folder) { 117 fManifestTab = new ManifestSyntaxColorTab(fColorManager); 118 TabItem item = new TabItem(folder, SWT.NONE); 119 item.setText(PDEUIMessages.EditorPreferencePage_manifest); 120 item.setControl(fManifestTab.createContents(folder)); 121 } 122 123 } 124 | Popular Tags |