1 11 package org.eclipse.team.internal.ccvs.ui.console; 12 13 import org.eclipse.jface.dialogs.Dialog; 14 import org.eclipse.jface.preference.*; 15 import org.eclipse.jface.util.PropertyChangeEvent; 16 import org.eclipse.swt.SWT; 17 import org.eclipse.swt.layout.GridData; 18 import org.eclipse.swt.widgets.Composite; 19 import org.eclipse.swt.widgets.Label; 20 import org.eclipse.team.internal.ccvs.ui.*; 21 import org.eclipse.ui.*; 22 23 public class ConsolePreferencesPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { 24 25 public ConsolePreferencesPage() { 26 super(GRID); 27 setPreferenceStore(CVSUIPlugin.getPlugin().getPreferenceStore()); 28 } 29 private ColorFieldEditor commandColorEditor; 30 private ColorFieldEditor messageColorEditor; 31 private ColorFieldEditor errorColorEditor; 32 private BooleanFieldEditor showOnMessage; 33 private BooleanFieldEditor restrictOutput; 34 private BooleanFieldEditor wrap; 35 private IntegerFieldEditor highWaterMark; 36 private IntegerFieldEditor width; 37 38 protected void createFieldEditors() { 39 final Composite composite = getFieldEditorParent(); 40 createLabel(composite, CVSUIMessages.ConsolePreferencesPage_9); 41 IPreferenceStore store = getPreferenceStore(); 42 43 wrap = new BooleanFieldEditor(ICVSUIConstants.PREF_CONSOLE_WRAP, CVSUIMessages.ConsolePreferencesPage_6, composite); 45 addField(wrap); 46 47 width = new IntegerFieldEditor(ICVSUIConstants.PREF_CONSOLE_WIDTH, CVSUIMessages.ConsolePreferencesPage_7, composite); width.setValidRange(80, Integer.MAX_VALUE - 1); 49 addField(width); 50 width.setEnabled(store.getBoolean(ICVSUIConstants.PREF_CONSOLE_WRAP), composite); 51 52 restrictOutput = new BooleanFieldEditor(ICVSUIConstants.PREF_CONSOLE_LIMIT_OUTPUT, CVSUIMessages.ConsolePreferencesPage_5, composite); 54 addField(restrictOutput); 55 56 highWaterMark = new IntegerFieldEditor(ICVSUIConstants.PREF_CONSOLE_HIGH_WATER_MARK, CVSUIMessages.ConsolePreferencesPage_8, composite); highWaterMark.setValidRange(1000, Integer.MAX_VALUE - 1); 58 addField(highWaterMark); 59 highWaterMark.setEnabled(store.getBoolean(ICVSUIConstants.PREF_CONSOLE_LIMIT_OUTPUT), composite); 60 61 showOnMessage = new BooleanFieldEditor(ICVSUIConstants.PREF_CONSOLE_SHOW_ON_MESSAGE, CVSUIMessages.ConsolePreferencesPage_4, composite); 63 addField(showOnMessage); 64 65 createLabel(composite, CVSUIMessages.ConsolePreferencePage_consoleColorSettings); 66 67 commandColorEditor = createColorFieldEditor(ICVSUIConstants.PREF_CONSOLE_COMMAND_COLOR, 69 CVSUIMessages.ConsolePreferencePage_commandColor, composite); 70 addField(commandColorEditor); 71 72 messageColorEditor = createColorFieldEditor(ICVSUIConstants.PREF_CONSOLE_MESSAGE_COLOR, 73 CVSUIMessages.ConsolePreferencePage_messageColor, composite); 74 addField(messageColorEditor); 75 76 errorColorEditor = createColorFieldEditor(ICVSUIConstants.PREF_CONSOLE_ERROR_COLOR, 77 CVSUIMessages.ConsolePreferencePage_errorColor, composite); 78 addField(errorColorEditor); 79 80 Dialog.applyDialogFont(composite); 81 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.CONSOLE_PREFERENCE_PAGE); 82 } 83 84 85 public void propertyChange(PropertyChangeEvent event) { 86 super.propertyChange(event); 87 highWaterMark.setEnabled(restrictOutput.getBooleanValue(), getFieldEditorParent()); 88 width.setEnabled(wrap.getBooleanValue(), getFieldEditorParent()); 89 } 90 91 99 private Label createLabel(Composite parent, String text) { 100 Label label = new Label(parent, SWT.LEFT); 101 label.setText(text); 102 GridData data = new GridData(); 103 data.horizontalSpan = 2; 104 data.horizontalAlignment = GridData.FILL; 105 label.setLayoutData(data); 106 return label; 107 } 108 111 private ColorFieldEditor createColorFieldEditor(String preferenceName, String label, Composite parent) { 112 ColorFieldEditor editor = new ColorFieldEditor(preferenceName, label, parent); 113 editor.setPreferencePage(this); 114 editor.setPreferenceStore(getPreferenceStore()); 115 return editor; 116 } 117 118 121 public void init(IWorkbench workbench) { 122 } 123 124 127 public boolean performOk() { 128 CVSUIPlugin.getPlugin().savePluginPreferences(); 129 return super.performOk(); 130 } 131 } 132 | Popular Tags |