Revise databinding code
- Replace use of deprecated databinding APIs (untyped
PojoProperties, untyped BeanProperties, untyped WidgetProperties,
ViewerObservables, untyped ViewerProperties)
- Add more nullable annotations
- Rework code for better null analysis
- Fix potential NPE
diff --git a/ltk/org.eclipse.statet.ltk.buildpaths.ui/src/org/eclipse/statet/ltk/buildpaths/ui/SourceContainerComponent.java b/ltk/org.eclipse.statet.ltk.buildpaths.ui/src/org/eclipse/statet/ltk/buildpaths/ui/SourceContainerComponent.java
index 6290969..2411019 100644
--- a/ltk/org.eclipse.statet.ltk.buildpaths.ui/src/org/eclipse/statet/ltk/buildpaths/ui/SourceContainerComponent.java
+++ b/ltk/org.eclipse.statet.ltk.buildpaths.ui/src/org/eclipse/statet/ltk/buildpaths/ui/SourceContainerComponent.java
@@ -21,11 +21,12 @@
import org.eclipse.core.databinding.observable.list.WritableList;
import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.databinding.observable.value.IValueChangeListener;
import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.jface.databinding.swt.typed.WidgetProperties;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.StructuredSelection;
@@ -352,29 +353,33 @@
public void bind(final DataBindingSupport db) {
if (this.outputPathValue != null) {
db.getContext().bindValue(
- WidgetProperties.text(SWT.Modify).observe(this.outputPathValue),
+ WidgetProperties.text(SWT.Modify)
+ .observe(this.outputPathControl),
this.outputPathValue );
if (this.outputByContainerValue != null) {
db.getContext().bindValue(
- WidgetProperties.selection().observe(this.outputByFolderControl),
+ WidgetProperties.buttonSelection()
+ .observe(this.outputByFolderControl),
this.outputByContainerValue );
- this.outputByContainerValue.addValueChangeListener(
- (final ValueChangeEvent<? extends Boolean> event) -> {
- if (!(event.diff.getNewValue())) {
- for (final Object object : SourceContainerComponent.this.containerList) {
- final BuildpathListElement element= (BuildpathListElement) object;
- final BuildpathListElementAttribute attribute= element
- .setAttribute(IBuildpathAttribute.OUTPUT, null);
-
- if (attribute != null) {
- SourceContainerComponent.this.changedContainers.add(element);
- }
+ this.outputByContainerValue.addValueChangeListener(new IValueChangeListener<Boolean>() {
+ @Override
+ public void handleValueChange(final ValueChangeEvent<? extends Boolean> event) {
+ if (!(event.diff.getNewValue())) {
+ for (final Object object : SourceContainerComponent.this.containerList) {
+ final BuildpathListElement element= (BuildpathListElement) object;
+ final BuildpathListElementAttribute attribute= element
+ .setAttribute(IBuildpathAttribute.OUTPUT, null);
+
+ if (attribute != null) {
+ SourceContainerComponent.this.changedContainers.add(element);
}
- SourceContainerComponent.this.containerListButtons.refresh();
}
- } );
+ SourceContainerComponent.this.containerListButtons.refresh();
+ }
+ }
+ });
}
}
diff --git a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ecommons/text/ui/presentation/AbstractTextStylesConfigurationBlock.java b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ecommons/text/ui/presentation/AbstractTextStylesConfigurationBlock.java
index 882ae25..549e0d6 100644
--- a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ecommons/text/ui/presentation/AbstractTextStylesConfigurationBlock.java
+++ b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ecommons/text/ui/presentation/AbstractTextStylesConfigurationBlock.java
@@ -26,21 +26,21 @@
import java.util.Set;
import org.eclipse.core.databinding.DataBindingContext;
-import org.eclipse.core.databinding.beans.BeanProperties;
-import org.eclipse.core.databinding.observable.IObservable;
+import org.eclipse.core.databinding.beans.typed.BeanProperties;
import org.eclipse.core.databinding.observable.Observables;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory;
import org.eclipse.core.databinding.observable.masterdetail.MasterDetailObservables;
import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.databinding.observable.value.IValueChangeListener;
import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.jface.databinding.swt.typed.WidgetProperties;
import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
-import org.eclipse.jface.databinding.viewers.ViewersObservables;
+import org.eclipse.jface.databinding.viewers.typed.ViewerProperties;
import org.eclipse.jface.preference.ColorSelector;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
@@ -510,6 +510,8 @@
}
}
+ private static final Class<List<UseStyle>> List_UseStyle_TYPE= (Class)List.class;
+
private SyntaxNode[] rootNodes;
private DataBindingContext dbc;
@@ -761,58 +763,70 @@
this.dbc= new DataBindingContext(realm);
// Observe changes in selection.
- final IObservableValue<SyntaxNode> selectionValue= ViewersObservables.observeSingleSelection(this.selectionViewer);
- selectionValue.addValueChangeListener(
- (final ValueChangeEvent<? extends SyntaxNode> event) -> {
- final SyntaxNode newNode= event.diff.getNewValue();
- if (newNode != null) {
- updateEnablement(newNode, newNode.getUseStyle());
- }
- } );
+ final IObservableValue<SyntaxNode> selectionValue=
+ ViewerProperties.singleSelection(SyntaxNode.class)
+ .observe(this.selectionViewer);
+ selectionValue.addValueChangeListener(new IValueChangeListener<SyntaxNode>() {
+ @Override
+ public void handleValueChange(final ValueChangeEvent<? extends SyntaxNode> event) {
+ final SyntaxNode newNode= event.diff.getNewValue();
+ if (newNode != null) {
+ updateEnablement(newNode, newNode.getUseStyle());
+ }
+ }
+ });
// Bind use style selection
final IObservableList<UseStyle> list= MasterDetailObservables.detailList(
- BeanProperties.value("availableUseStyles", List.class).observeDetail(selectionValue),
- new IObservableFactory() {
+ BeanProperties.value("availableUseStyles", List_UseStyle_TYPE)
+ .observeDetail(selectionValue),
+ new IObservableFactory<List<UseStyle>, IObservableList<UseStyle>>() {
@Override
- public IObservable createObservable(final Object target) {
- return Observables.staticObservableList(realm, (List) target);
+ public IObservableList<UseStyle> createObservable(final List<UseStyle> target) {
+ return Observables.staticObservableList(realm, target);
}
- }, null);
- this.useViewer.setContentProvider(new ObservableListContentProvider());
+ }, null );
+ this.useViewer.setContentProvider(new ObservableListContentProvider<UseStyle>());
this.useViewer.setInput(list);
- final IObservableValue<UseStyle> useStyle= BeanProperties.value(SyntaxNode.PROP_USE, UseStyle.class)
+ final IObservableValue<UseStyle> useStyleValue= BeanProperties.value(SyntaxNode.PROP_USE, UseStyle.class)
.observeDetail(selectionValue);
- useStyle.addValueChangeListener(
- (final ValueChangeEvent<? extends UseStyle> event) -> {
- final IStructuredSelection selection= (IStructuredSelection) AbstractTextStylesConfigurationBlock.this
- .selectionViewer.getSelection();
- final UseStyle newUse= event.diff.getNewValue();
- updateEnablement((SyntaxNode) selection.getFirstElement(), newUse);
- } );
+ useStyleValue.addValueChangeListener(new IValueChangeListener<UseStyle>() {
+ @Override
+ public void handleValueChange(final ValueChangeEvent<? extends UseStyle> event) {
+ final IStructuredSelection selection= (IStructuredSelection) AbstractTextStylesConfigurationBlock.this
+ .selectionViewer.getSelection();
+ final UseStyle newUse= event.diff.getNewValue();
+ updateEnablement((SyntaxNode) selection.getFirstElement(), newUse);
+ }
+ });
this.dbc.bindValue(
- ViewersObservables.observeSingleSelection(this.useViewer),
- useStyle );
+ ViewerProperties.singleSelection(UseStyle.class)
+ .observe(this.useViewer),
+ useStyleValue );
// Bind option widgets to the properties of the current selection.
this.dbc.bindValue(
new ColorSelectorObservableValue(this.colorEditor),
BeanProperties.value(SyntaxNode.PROP_COLOR, RGB.class)
.observeDetail(selectionValue) );
this.dbc.bindValue(
- WidgetProperties.selection().observe(this.boldCheckbox),
- BeanProperties.value(SyntaxNode.PROP_BOLD, Boolean.class)
+ WidgetProperties.buttonSelection()
+ .observe(this.boldCheckbox),
+ BeanProperties.value(SyntaxNode.PROP_BOLD, Boolean.TYPE)
.observeDetail(selectionValue) );
this.dbc.bindValue(
- WidgetProperties.selection().observe(this.italicCheckbox),
- BeanProperties.value(SyntaxNode.PROP_ITALIC, Boolean.class)
+ WidgetProperties.buttonSelection()
+ .observe(this.italicCheckbox),
+ BeanProperties.value(SyntaxNode.PROP_ITALIC, Boolean.TYPE)
.observeDetail(selectionValue) );
if (isTextAttributesSupported()) {
this.dbc.bindValue(
- WidgetProperties.selection().observe(this.strikethroughCheckbox),
- BeanProperties.value(SyntaxNode.PROP_STRIKETHROUGH, Boolean.class)
+ WidgetProperties.buttonSelection()
+ .observe(this.strikethroughCheckbox),
+ BeanProperties.value(SyntaxNode.PROP_STRIKETHROUGH, Boolean.TYPE)
.observeDetail(selectionValue) );
this.dbc.bindValue(
- WidgetProperties.selection().observe(this.underlineCheckbox),
- BeanProperties.value(SyntaxNode.PROP_UNDERLINE, Boolean.class)
+ WidgetProperties.buttonSelection()
+ .observe(this.underlineCheckbox),
+ BeanProperties.value(SyntaxNode.PROP_UNDERLINE, Boolean.TYPE)
.observeDetail(selectionValue) );
}
else {
diff --git a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ecommons/text/ui/settings/IndentSettingsUI.java b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ecommons/text/ui/settings/IndentSettingsUI.java
index 7050529..cddef7e 100644
--- a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ecommons/text/ui/settings/IndentSettingsUI.java
+++ b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ecommons/text/ui/settings/IndentSettingsUI.java
@@ -17,11 +17,12 @@
import java.util.EnumMap;
import org.eclipse.core.databinding.UpdateValueStrategy;
-import org.eclipse.core.databinding.beans.BeanProperties;
+import org.eclipse.core.databinding.beans.typed.BeanProperties;
import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.databinding.observable.value.IValueChangeListener;
import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
-import org.eclipse.jface.databinding.swt.WidgetProperties;
-import org.eclipse.jface.databinding.viewers.ViewersObservables;
+import org.eclipse.jface.databinding.swt.typed.WidgetProperties;
+import org.eclipse.jface.databinding.viewers.typed.ViewerProperties;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.LabelProvider;
@@ -33,7 +34,10 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.statet.ecommons.databinding.IntegerValidator;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
+
+import org.eclipse.statet.ecommons.databinding.core.validation.IntegerValidator;
import org.eclipse.statet.ecommons.databinding.jface.DataBindingSupport;
import org.eclipse.statet.ecommons.text.IIndentSettings;
import org.eclipse.statet.ecommons.text.IIndentSettings.IndentationType;
@@ -42,6 +46,7 @@
import org.eclipse.statet.internal.ecommons.text.ui.Messages;
+@NonNullByDefault
public class IndentSettingsUI {
private final static EnumMap<IndentationType, String> INDENT_NAMES= new EnumMap<>(IndentationType.class);
@@ -137,46 +142,60 @@
public void addBindings(final DataBindingSupport db, final Object model) {
db.getContext().bindValue(
- WidgetProperties.text(SWT.Modify).observe(this.tabSizeControl),
- BeanProperties.value(IIndentSettings.TAB_SIZE_PROP)
+ WidgetProperties.text(SWT.Modify)
+ .observe(this.tabSizeControl),
+ BeanProperties.value(IIndentSettings.TAB_SIZE_PROP, Integer.TYPE)
.observe(db.getRealm(), model),
- new UpdateValueStrategy().setAfterGetValidator(new IntegerValidator(1, 32, Messages.CodeStyle_TabSize_error_message)),
- null);
+ new UpdateValueStrategy<String, Integer>()
+ .setAfterGetValidator(new IntegerValidator(1, 32,
+ Messages.CodeStyle_TabSize_error_message )),
+ null );
- final IObservableValue<IndentationType> indentTargetValue= ViewersObservables
- .observeSingleSelection(this.indentPolicyControl);
+ final IObservableValue<@Nullable IndentationType> indentTargetValue=
+ ViewerProperties.singleSelection(IndentationType.class)
+ .observe(this.indentPolicyControl);
indentTargetValue.setValue(null);
- indentTargetValue.addValueChangeListener(
- (final ValueChangeEvent<? extends IndentationType> event) -> {
- final IndentationType t= event.diff.getNewValue();
- IndentSettingsUI.this.indentSpaceCountLabel.setEnabled(t == IndentationType.SPACES);
- IndentSettingsUI.this.indentSpaceCountControl.setEnabled(t == IndentationType.SPACES);
- } );
+ indentTargetValue.addValueChangeListener(new IValueChangeListener<IndentationType>() {
+ @Override
+ public void handleValueChange(final ValueChangeEvent<? extends IndentationType> event) {
+ final IndentationType t= event.diff.getNewValue();
+ IndentSettingsUI.this.indentSpaceCountLabel.setEnabled(t == IndentationType.SPACES);
+ IndentSettingsUI.this.indentSpaceCountControl.setEnabled(t == IndentationType.SPACES);
+ }
+ });
db.getContext().bindValue(
indentTargetValue,
- BeanProperties.value(IIndentSettings.INDENT_DEFAULT_TYPE_PROP)
+ BeanProperties.value(IIndentSettings.INDENT_DEFAULT_TYPE_PROP, IndentationType.class)
.observe(db.getRealm(), model) );
db.getContext().bindValue(
- WidgetProperties.text(SWT.Modify).observe(this.indentSpaceCountControl),
- BeanProperties.value(IIndentSettings.INDENT_SPACES_COUNT_PROP)
+ WidgetProperties.text(SWT.Modify)
+ .observe(this.indentSpaceCountControl),
+ BeanProperties.value(IIndentSettings.INDENT_SPACES_COUNT_PROP, Integer.TYPE)
.observe(db.getRealm(), model),
- new UpdateValueStrategy().setAfterGetValidator(new IntegerValidator(1, 32, Messages.CodeStyle_Indent_NumOfSpaces_error_message)),
+ new UpdateValueStrategy<String, Integer>()
+ .setAfterGetValidator(new IntegerValidator(1, 32,
+ Messages.CodeStyle_Indent_NumOfSpaces_error_message )),
null );
db.getContext().bindValue(
- WidgetProperties.selection().observe(this.replaceOtherTabsControl),
- BeanProperties.value(IIndentSettings.REPLACE_TABS_WITH_SPACES_PROP)
+ WidgetProperties.buttonSelection()
+ .observe(this.replaceOtherTabsControl),
+ BeanProperties.value(IIndentSettings.REPLACE_TABS_WITH_SPACES_PROP, Boolean.TYPE)
.observe(db.getRealm(), model) );
db.getContext().bindValue(
- WidgetProperties.selection().observe(this.conserveIndentControl),
- BeanProperties.value(IIndentSettings.REPLACE_CONSERVATIVE_PROP)
+ WidgetProperties.buttonSelection()
+ .observe(this.conserveIndentControl),
+ BeanProperties.value(IIndentSettings.REPLACE_CONSERVATIVE_PROP, Boolean.TYPE)
.observe(db.getRealm(), model) );
if (this.lineWidthControl != null) {
db.getContext().bindValue(
- WidgetProperties.text(SWT.Modify).observe(this.lineWidthControl),
- BeanProperties.value(IIndentSettings.WRAP_LINE_WIDTH_PROP)
+ WidgetProperties.text(SWT.Modify)
+ .observe(this.lineWidthControl),
+ BeanProperties.value(IIndentSettings.WRAP_LINE_WIDTH_PROP, Integer.TYPE)
.observe(db.getRealm(), model),
- new UpdateValueStrategy().setAfterGetValidator(new IntegerValidator(40, 400, Messages.CodeStyle_LineWidth_error_message)),
+ new UpdateValueStrategy<String, Integer>()
+ .setAfterGetValidator(new IntegerValidator(40, 400,
+ Messages.CodeStyle_LineWidth_error_message)),
null );
}
}
diff --git a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ecommons/text/ui/Messages.java b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ecommons/text/ui/Messages.java
index 4166aa8..bcc0966 100644
--- a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ecommons/text/ui/Messages.java
+++ b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ecommons/text/ui/Messages.java
@@ -16,7 +16,11 @@
import org.eclipse.osgi.util.NLS;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+
+@NonNullByDefault
+@SuppressWarnings("null")
public class Messages extends NLS {
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 4bd7387..cdd1a9c 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
@@ -20,12 +20,11 @@
import java.util.Map;
import org.eclipse.core.databinding.UpdateValueStrategy;
-import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory;
import org.eclipse.core.databinding.observable.masterdetail.MasterDetailObservables;
import org.eclipse.core.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.swt.WidgetProperties;
-import org.eclipse.jface.databinding.viewers.ViewersObservables;
+import org.eclipse.jface.databinding.swt.typed.WidgetProperties;
+import org.eclipse.jface.databinding.viewers.typed.ViewerProperties;
import org.eclipse.jface.preference.ColorSelector;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
@@ -40,7 +39,10 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.statet.ecommons.databinding.IntegerValidator;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
+
+import org.eclipse.statet.ecommons.databinding.core.validation.IntegerValidator;
import org.eclipse.statet.ecommons.databinding.jface.DataBindingSupport;
import org.eclipse.statet.ecommons.preferences.core.Preference;
import org.eclipse.statet.ecommons.preferences.core.Preference.BooleanPref;
@@ -58,6 +60,7 @@
import org.eclipse.statet.ltk.ui.sourceediting.assist.AssistPreferences;
+@NonNullByDefault
public class EditorsPreferencePage extends ConfigurationBlockPreferencePage {
@@ -73,6 +76,7 @@
}
+@NonNullByDefault
class EditorsConfigurationBlock extends ManagedConfigurationBlock {
private static class AppearanceColorsItem {
@@ -104,14 +108,14 @@
private Button contentAssistAutoCommonControl;
- public EditorsConfigurationBlock(final StatusChangeListener statusListener) {
+ public EditorsConfigurationBlock(final @Nullable StatusChangeListener statusListener) {
super(null, Messages.Editors_title, statusListener);
}
@Override
protected void createBlockArea(final Composite pageComposite) {
- final Map<Preference<?>, String> prefs= new HashMap<>();
+ final Map<Preference<?>, @Nullable String> prefs= new HashMap<>();
final List<AppearanceColorsItem> colors= new ArrayList<>();
@@ -193,8 +197,8 @@
this.colorList.setContentProvider(new ArrayContentProvider());
this.colorList.setLabelProvider(new LabelProvider() {
@Override
- public String getText(final Object element) {
- final AppearanceColorsItem item= (AppearanceColorsItem) element;
+ public String getText(final @Nullable Object element) {
+ final AppearanceColorsItem item= (AppearanceColorsItem)element;
return item.name;
}
});
@@ -253,32 +257,38 @@
@SuppressWarnings({ "unchecked" })
protected void addBindings(final DataBindingSupport db) {
db.getContext().bindValue(
- WidgetProperties.selection().observe(this.matchingBracketsControl),
+ WidgetProperties.buttonSelection()
+ .observe(this.matchingBracketsControl),
createObservable(this.matchingBracketsPref) );
- final IObservableValue<AppearanceColorsItem> colorItem= ViewersObservables
- .observeSingleSelection(this.colorList);
+ final IObservableValue<@Nullable AppearanceColorsItem> colorItem=
+ ViewerProperties.singleSelection(AppearanceColorsItem.class)
+ .observe(this.colorList);
db.getContext().bindValue(new ColorSelectorObservableValue(this.colorEditor),
- MasterDetailObservables.detailValue(colorItem, new IObservableFactory() {
+ MasterDetailObservables.detailValue(colorItem, new IObservableFactory<AppearanceColorsItem, IObservableValue<@Nullable RGB>>() {
@Override
- public IObservable createObservable(final Object target) {
- final AppearanceColorsItem item= (AppearanceColorsItem) target;
- return EditorsConfigurationBlock.this.createObservable(item.pref);
+ public IObservableValue<@Nullable RGB> createObservable(final AppearanceColorsItem target) {
+ return EditorsConfigurationBlock.this.createObservable(target.pref);
}
}, RGB.class) );
db.getContext().bindValue(
- WidgetProperties.selection().observe(this.contentAssistShowSubstringMatchesControl),
+ WidgetProperties.buttonSelection()
+ .observe(this.contentAssistShowSubstringMatchesControl),
createObservable(this.contentAssistShowSubstringMatchesPref) );
db.getContext().bindValue(
- WidgetProperties.text(SWT.Modify).observe(this.contentAssistDelayControl),
+ WidgetProperties.text(SWT.Modify)
+ .observe(this.contentAssistDelayControl),
createObservable(this.contentAssistDelayPref),
- new UpdateValueStrategy().setAfterGetValidator(
- new IntegerValidator(10, 2000, Messages.Editors_ContentAssist_AutoTriggerDelay_error_message) ),
+ new UpdateValueStrategy<String, Integer>()
+ .setAfterGetValidator(new IntegerValidator(10, 2000,
+ Messages.Editors_ContentAssist_AutoTriggerDelay_error_message )),
null );
db.getContext().bindValue(
- WidgetProperties.selection().observe(this.contentAssistSingleControl),
+ WidgetProperties.buttonSelection()
+ .observe(this.contentAssistSingleControl),
createObservable(this.contentAssistAutoSinglePref) );
db.getContext().bindValue(
- WidgetProperties.selection().observe(this.contentAssistAutoCommonControl),
+ WidgetProperties.buttonSelection()
+ .observe(this.contentAssistAutoCommonControl),
createObservable(this.contentAssistAutoCommonPref) );
}
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 946cb5c..28c9db6 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
@@ -16,7 +16,11 @@
import org.eclipse.osgi.util.NLS;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+
+@NonNullByDefault
+@SuppressWarnings("null")
public class Messages extends NLS {
diff --git a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ltk/ui/sourceediting/SnippetEditorObservable.java b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ltk/ui/sourceediting/SnippetEditorObservable.java
index 9bb40c1..46b4d62 100644
--- a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ltk/ui/sourceediting/SnippetEditorObservable.java
+++ b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ltk/ui/sourceediting/SnippetEditorObservable.java
@@ -28,6 +28,8 @@
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+
/**
* {@link IObservable} implementation that wraps a {@link SnippetEditor}. The time at which
@@ -43,7 +45,8 @@
* changing event will fire on verify to enable vetoing of changes.</dd>
* </dl>
*/
-public class SnippetEditorObservable extends AbstractVetoableValue {
+@NonNullByDefault
+public class SnippetEditorObservable extends AbstractVetoableValue<String> {
/**
* {@link Text} widget that this is being observed.
@@ -81,7 +84,7 @@
final String newValue= SnippetEditorObservable.this.text.getText();
if (!newValue.equals(SnippetEditorObservable.this.oldValue)) {
- fireValueChange(Diffs.createValueDiff(SnippetEditorObservable.this.oldValue, newValue));
+ fireValueChange(Diffs.createValueDiff(SnippetEditorObservable.this.oldValue, newValue));
SnippetEditorObservable.this.oldValue= newValue;
}
}
@@ -123,8 +126,7 @@
@Override
public void verifyText(final VerifyEvent e) {
if (!SnippetEditorObservable.this.updating) {
- final String currentText= SnippetEditorObservable.this.text
- .getText();
+ final String currentText= SnippetEditorObservable.this.text.getText();
final String newText= currentText.substring(0, e.start) + e.text
+ currentText.substring(e.end);
if (!fireValueChanging(Diffs.createValueDiff(currentText,
@@ -155,10 +157,10 @@
* if the value is anything other than a String
*/
@Override
- protected void doSetApprovedValue(final Object value) {
+ protected void doSetApprovedValue(final String value) {
try {
this.updating= true;
- this.text.setText(value == null ? "" : value.toString()); //$NON-NLS-1$
+ this.text.setText((value == null) ? "" : value.toString()); //$NON-NLS-1$
this.oldValue= this.text.getText();
} finally {
this.updating= false;
@@ -171,7 +173,7 @@
* @see org.eclipse.core.databinding.observable.value.AbstractVetoableValue#doGetValue()
*/
@Override
- public Object doGetValue() {
+ public String doGetValue() {
return this.oldValue= this.text.getText();
}