| author | Marc Aubry | 2012-07-12 09:22:35 (EDT) |
|---|---|---|
| committer | sbernard | 2012-07-13 05:39:28 (EDT) |
| commit | 9dd31be91b040e676484d129d0b051b5a26245fe (patch) (side-by-side diff) | |
| tree | 7a284198c1ca44bd8fc3975e6be11eb6367aa758 | |
| parent | 9b1a3c6d5376d17f58d9a3fbe2e369dff3296da2 (diff) | |
| download | org.eclipse.koneki.ldt-9dd31be91b040e676484d129d0b051b5a26245fe.zip org.eclipse.koneki.ldt-9dd31be91b040e676484d129d0b051b5a26245fe.tar.gz org.eclipse.koneki.ldt-9dd31be91b040e676484d129d0b051b5a26245fe.tar.bz2 | |
Bug 384933 - Clean lua preference pages from broken preferences
3 files changed, 144 insertions, 3 deletions
diff --git a/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/internal/preferences/LuaCodeAssistConfigurationBlock.java b/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/internal/preferences/LuaCodeAssistConfigurationBlock.java new file mode 100644 index 0000000..a42c2f9 --- a/dev/null +++ b/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/internal/preferences/LuaCodeAssistConfigurationBlock.java @@ -0,0 +1,127 @@ +/******************************************************************************* + * Copyright (c) 2011 Sierra Wireless and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Sierra Wireless - initial API and implementation + *******************************************************************************/ + +package org.eclipse.koneki.ldt.ui.internal.preferences; + +import java.util.ArrayList; + +import org.eclipse.dltk.ui.PreferenceConstants; +import org.eclipse.dltk.ui.preferences.AbstractConfigurationBlock; +import org.eclipse.dltk.ui.preferences.OverlayPreferenceStore; +import org.eclipse.dltk.ui.preferences.OverlayPreferenceStore.OverlayKey; +import org.eclipse.dltk.ui.preferences.PreferencesMessages; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +/** + * This class is a copy of the {@link org.eclipse.dltk.ui.preferences.CodeAssistConfigurationBlock} without the option + * "Override or insert content assist" because this option is not working in LDT + */ +public class LuaCodeAssistConfigurationBlock extends AbstractConfigurationBlock { + + public LuaCodeAssistConfigurationBlock(PreferencePage mainPreferencePage, OverlayPreferenceStore store) { + super(store, mainPreferencePage); + getPreferenceStore().addKeys(createOverlayStoreKeys()); + } + + private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() { + ArrayList<OverlayKey> overlayKeys = new ArrayList<OverlayKey>(); + + getOverlayKeys(overlayKeys); + + OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; + overlayKeys.toArray(keys); + return keys; + } + + protected void getOverlayKeys(ArrayList<OverlayKey> overlayKeys) { + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOACTIVATION)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY)); + + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOINSERT)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_INSERT_COMPLETION)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_SORTER)); + } + + /** + * Creates page for appearance preferences. + * + * @param parent + * the parent composite + * @return the control for the preference page + */ + public Control createControl(Composite parent) { + initializeDialogUnits(parent); + + Composite control = new Composite(parent, SWT.NONE); + control.setLayout(new GridLayout()); + + Composite composite; + + composite = createSubsection(control, null, PreferencesMessages.CodeAssistConfigurationBlock_insertionSection_title); + + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + composite.setLayout(layout); + + addInsertionSection(composite); + + composite = createSubsection(control, null, PreferencesMessages.CodeAssistConfigurationBlock_autoactivationSection_title); + composite.setLayout(layout); + addAutoActivationSection(composite); + + return control; + } + + Control autoActivation; + + protected void addAutoActivationSection(Composite composite) { + String label; + label = PreferencesMessages.DLTKEditorPreferencePage_enableAutoActivation; + final Button autoactivation = addCheckBox(composite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION, 2); + autoactivation.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + updateAutoactivationControls(); + } + }); + + label = PreferencesMessages.DLTKEditorPreferencePage_autoActivationDelay; + Control[] ctrl = addLabelledTextField(composite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY, 4, 2, true); + autoActivation = ctrl[1]; + } + + private void updateAutoactivationControls() { + boolean autoactivation = getPreferenceStore().getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION); + if (autoActivation != null) { + autoActivation.setEnabled(autoactivation); + } + } + + protected void addInsertionSection(Composite composite) { + + String label; + label = PreferencesMessages.DLTKEditorPreferencePage_insertSingleProposalsAutomatically; + addCheckBox(composite, label, PreferenceConstants.CODEASSIST_AUTOINSERT, 2); + } + + protected void initializeFields() { + super.initializeFields(); + + updateAutoactivationControls(); + } + +} diff --git a/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/internal/preferences/LuaEditorAssistancePreferencePage.java b/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/internal/preferences/LuaEditorAssistancePreferencePage.java index 7198632..d84e8d2 100644 --- a/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/internal/preferences/LuaEditorAssistancePreferencePage.java +++ b/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/internal/preferences/LuaEditorAssistancePreferencePage.java @@ -11,7 +11,6 @@ package org.eclipse.koneki.ldt.ui.internal.preferences; import org.eclipse.dltk.ui.preferences.AbstractConfigurationBlockPreferencePage; -import org.eclipse.dltk.ui.preferences.CodeAssistConfigurationBlock; import org.eclipse.dltk.ui.preferences.IPreferenceConfigurationBlock; import org.eclipse.dltk.ui.preferences.OverlayPreferenceStore; import org.eclipse.koneki.ldt.ui.internal.Activator; @@ -29,6 +28,6 @@ public class LuaEditorAssistancePreferencePage extends AbstractConfigurationBloc } protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) { - return new CodeAssistConfigurationBlock(this, overlayPreferenceStore); + return new LuaCodeAssistConfigurationBlock(this, overlayPreferenceStore); } } diff --git a/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/internal/preferences/LuaEditorPreferencePage.java b/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/internal/preferences/LuaEditorPreferencePage.java index 4fcb86a..7228d0b 100644 --- a/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/internal/preferences/LuaEditorPreferencePage.java +++ b/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/internal/preferences/LuaEditorPreferencePage.java @@ -10,10 +10,12 @@ *******************************************************************************/ package org.eclipse.koneki.ldt.ui.internal.preferences; +import org.eclipse.dltk.ui.PreferenceConstants; import org.eclipse.dltk.ui.preferences.AbstractConfigurationBlockPreferencePage; import org.eclipse.dltk.ui.preferences.EditorConfigurationBlock; import org.eclipse.dltk.ui.preferences.IPreferenceConfigurationBlock; import org.eclipse.dltk.ui.preferences.OverlayPreferenceStore; +import org.eclipse.dltk.ui.preferences.PreferencesMessages; import org.eclipse.koneki.ldt.ui.internal.Activator; public class LuaEditorPreferencePage extends AbstractConfigurationBlockPreferencePage { @@ -30,6 +32,19 @@ public class LuaEditorPreferencePage extends AbstractConfigurationBlockPreferenc @Override protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) { - return new EditorConfigurationBlock(this, overlayPreferenceStore, EditorConfigurationBlock.FLAG_TAB_ALWAYS_INDENT); + // Use of the DLTK Editor preference page, where the 0 means we don't want any of optional parameters. + return new EditorConfigurationBlock(this, overlayPreferenceStore, 0) { + + // Filter editor color parameters + protected EditorColorItem[] createColorListModel() { + return new EditorColorItem[] { + new EditorColorItem(PreferencesMessages.EditorPreferencePage_matchingBracketsHighlightColor, + PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR), + new EditorColorItem(PreferencesMessages.EditorPreferencePage_backgroundForMethodParameters, + PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND), + new EditorColorItem(PreferencesMessages.EditorPreferencePage_foregroundForMethodParameters, + PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND), }; + } + }; } } |

