Bug 544399: [SourceEditor] Add AssistPreferences for all editors of StatET
to LTK
- Add all properties to StatET's Text Editors preference page
Change-Id: I762143fb100885e0baea6c0c3327fbe1b1ad9bba
diff --git a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/LTKUIPreferenceInitializer.java b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/LTKUIPreferenceInitializer.java
index a1e089b..f4617dc 100644
--- a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/LTKUIPreferenceInitializer.java
+++ b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/LTKUIPreferenceInitializer.java
@@ -44,7 +44,7 @@
theme.getColorPrefValue(IWaThemeConstants.MATCHING_BRACKET_COLOR) );
}
{ final IEclipsePreferences node= context.getNode(LTKUIPreferences.ASSIST_PREF_QUALIFIER);
- node.putInt(LTKUIPreferences.CONTENT_ASSIST_DELAY_PREF_KEY, 200);
+ node.putInt(LTKUIPreferences.CONTENT_ASSIST_DELAY_PREF_KEY, 150);
node.put(LTKUIPreferences.CONTEXT_INFO_BACKGROUND_COLOR_PREF_KEY,
theme.getColorPrefValue(IWaThemeConstants.INFORMATION_BACKGROUND_COLOR) );
node.put(LTKUIPreferences.CONTEXT_INFO_FOREGROUND_COLOR_PREF_KEY,
diff --git a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/config/EditorsPreferencePage.java b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/config/EditorsPreferencePage.java
index 80f5c35..17fce6e 100644
--- a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/config/EditorsPreferencePage.java
+++ b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/config/EditorsPreferencePage.java
@@ -51,6 +51,7 @@
import org.eclipse.statet.ecommons.preferences.ui.ManagedConfigurationBlock;
import org.eclipse.statet.ecommons.preferences.ui.RGBPref;
import org.eclipse.statet.ecommons.runtime.core.StatusChangeListener;
+import org.eclipse.statet.ecommons.text.ui.settings.AssistPreferences;
import org.eclipse.statet.ecommons.text.ui.settings.DecorationPreferences;
import org.eclipse.statet.ecommons.ui.util.LayoutUtils;
@@ -93,12 +94,16 @@
private BooleanPref matchingBracketsPref;
private Button matchingBracketsControl;
+ private Button contentAssistSingleControl;
+ private BooleanPref contentAssistAutoSinglePref;
+ private Button contentAssistAutoCommonControl;
+ private BooleanPref contentAssistAutoCommonPref;
private IntPref contentAssistDelayPref;
private Text contentAssistDelayControl;
public EditorsConfigurationBlock(final StatusChangeListener statusListener) {
- super(null, statusListener);
+ super(null, Messages.Editors_title, statusListener);
}
@@ -133,9 +138,14 @@
prefs.put(color.pref, LTKUIPreferences.ASSIST_GROUP_ID);
}
+ final AssistPreferences assistPreferences= LTKUIPreferences.getAssistPreferences();
+ this.contentAssistAutoSinglePref= assistPreferences.getAutoInsertSinglePref();
+ prefs.put(this.contentAssistAutoSinglePref, LTKUIPreferences.ASSIST_GROUP_ID);
+ this.contentAssistAutoCommonPref= assistPreferences.getAutoInsertPrefixPref();
+ prefs.put(this.contentAssistAutoCommonPref, LTKUIPreferences.ASSIST_GROUP_ID);
this.contentAssistDelayPref= LTKUIPreferences.CONTENT_ASSIST_DELAY_PREF;
prefs.put(this.contentAssistDelayPref, LTKUIPreferences.ASSIST_GROUP_ID);
-
+
// Register preferences
setupPreferenceManager(prefs);
@@ -201,20 +211,32 @@
}
private Composite createAssistSection(final Composite parent) {
- final Group group= new Group(parent, SWT.NONE);
- group.setText(Messages.Editors_CodeAssist);
- group.setLayout(LayoutUtils.newGroupGrid(2));
+ final Group composite= new Group(parent, SWT.NONE);
+ composite.setText(Messages.Editors_ContentAssist);
+ composite.setLayout(LayoutUtils.newGroupGrid(2));
- { final Label label= new Label(group, SWT.LEFT);
- label.setText(Messages.Editors_CodeAssist_AutoTriggerDelay_label);
+ { final Button button= new Button(composite, SWT.CHECK);
+ button.setText(Messages.Editors_ContentAssist_AutoInsertSingle);
+ button.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
+ this.contentAssistSingleControl= button;
+ }
+ { final Button button= new Button(composite, SWT.CHECK);
+ button.setText(Messages.Editors_ContentAssist_AutoInsertCommon);
+ button.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
+ this.contentAssistAutoCommonControl= button;
+ }
+ LayoutUtils.addSmallFiller(composite, false);
+ { final Label label= new Label(composite, SWT.LEFT);
+ label.setText(Messages.Editors_ContentAssist_AutoTriggerDelay_label);
label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
- this.contentAssistDelayControl= new Text(group, SWT.SINGLE | SWT.BORDER);
+ final Text text= new Text(composite, SWT.SINGLE | SWT.BORDER);
final GridData gd= new GridData(SWT.LEFT, SWT.CENTER, true, false);
- gd.widthHint= LayoutUtils.hintWidth(this.contentAssistDelayControl, 4);
- this.contentAssistDelayControl.setLayoutData(gd);
+ gd.widthHint= LayoutUtils.hintWidth(text, 4);
+ text.setLayoutData(gd);
+ this.contentAssistDelayControl= text;
}
- return group;
+ return composite;
}
@Override
@@ -232,11 +254,18 @@
return EditorsConfigurationBlock.this.createObservable(item.pref);
}
}, RGB.class) );
+
+ db.getContext().bindValue(
+ WidgetProperties.selection().observe(this.contentAssistSingleControl),
+ createObservable(this.contentAssistAutoSinglePref) );
+ db.getContext().bindValue(
+ WidgetProperties.selection().observe(this.contentAssistAutoCommonControl),
+ createObservable(this.contentAssistAutoCommonPref) );
db.getContext().bindValue(
WidgetProperties.text(SWT.Modify).observe(this.contentAssistDelayControl),
createObservable(this.contentAssistDelayPref),
new UpdateValueStrategy().setAfterGetValidator(
- new IntegerValidator(10, 2000, Messages.Editors_CodeAssist_AutoTriggerDelay_error_message) ),
+ new IntegerValidator(10, 2000, Messages.Editors_ContentAssist_AutoTriggerDelay_error_message) ),
null );
}
diff --git a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/config/Messages.java b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/config/Messages.java
index a8daac0..9aaa984 100644
--- a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/config/Messages.java
+++ b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/config/Messages.java
@@ -20,6 +20,7 @@
public class Messages extends NLS {
+ public static String Editors_title;
public static String Editors_link;
public static String Editors_Appearance;
public static String Editors_HighlightMatchingBrackets;
@@ -28,9 +29,11 @@
public static String Editors_MatchingBracketsHighlightColor;
public static String Editors_CodeAssistParametersForegrondColor;
public static String Editors_CodeAssistParametersBackgroundColor;
- public static String Editors_CodeAssist;
- public static String Editors_CodeAssist_AutoTriggerDelay_label;
- public static String Editors_CodeAssist_AutoTriggerDelay_error_message;
+ public static String Editors_ContentAssist;
+ public static String Editors_ContentAssist_AutoInsertSingle;
+ public static String Editors_ContentAssist_AutoInsertCommon;
+ public static String Editors_ContentAssist_AutoTriggerDelay_label;
+ public static String Editors_ContentAssist_AutoTriggerDelay_error_message;
static {
diff --git a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/config/Messages.properties b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/config/Messages.properties
index 9618425..bac5754 100644
--- a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/config/Messages.properties
+++ b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/config/Messages.properties
@@ -12,7 +12,8 @@
# Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation
#=============================================================================#
-Editors_link= Additional settings for all StatET source editors.
+Editors_title= Text Editors of StatET
+Editors_link= Additional settings for all source editors of StatET.
Editors_Appearance= Appearance:
Editors_HighlightMatchingBrackets= Highlight &matching brackets
@@ -23,6 +24,8 @@
Editors_CodeAssistParametersForegrondColor= Parameter hints foreground
Editors_CodeAssistParametersBackgroundColor= Parameter hints background
-Editors_CodeAssist= Code Assist:
-Editors_CodeAssist_AutoTriggerDelay_label= Auto Trigger &Delay:
-Editors_CodeAssist_AutoTriggerDelay_error_message= Invalid delay for content assist specified.
+Editors_ContentAssist= Content Assist:
+Editors_ContentAssist_AutoInsertSingle= Insert &single proposal automatically
+Editors_ContentAssist_AutoInsertCommon= Insert common &prefixes automatically
+Editors_ContentAssist_AutoTriggerDelay_label= Auto Trigger &Delay:
+Editors_ContentAssist_AutoTriggerDelay_error_message= Invalid delay for content assist specified.
diff --git a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ltk/ui/LTKUIPreferences.java b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ltk/ui/LTKUIPreferences.java
index ef844c1..2bcf9fa 100644
--- a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ltk/ui/LTKUIPreferences.java
+++ b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ltk/ui/LTKUIPreferences.java
@@ -18,6 +18,7 @@
import org.eclipse.statet.ecommons.preferences.core.Preference.IntPref;
import org.eclipse.statet.ecommons.preferences.ui.RGBPref;
+import org.eclipse.statet.ecommons.text.ui.settings.AssistPreferences;
import org.eclipse.statet.ecommons.text.ui.settings.DecorationPreferences;
import org.eclipse.statet.internal.ltk.ui.LTKUIPlugin;
@@ -55,4 +56,10 @@
public static final RGBPref CONTEXT_INFO_FOREGROUND_COLOR_PREF= new RGBPref(
ASSIST_PREF_QUALIFIER, CONTEXT_INFO_FOREGROUND_COLOR_PREF_KEY);
+ private final static AssistPreferences ASSIST_PREFERENCES= new AssistPreferences(ASSIST_PREF_QUALIFIER);
+
+ public static AssistPreferences getAssistPreferences() {
+ return ASSIST_PREFERENCES;
+ }
+
}