]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.views.swt.client/src/org/simantics/views/swt/client/impl/SWTTrackedText.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.views.swt.client / src / org / simantics / views / swt / client / impl / SWTTrackedText.java
index 4370b7c2d5269fea05c110ef1cb8d357e7788f97..404e1910eb59f45334988397a6733f37cd034b71 100644 (file)
-package org.simantics.views.swt.client.impl;\r
-\r
-import java.util.ArrayList;\r
-\r
-import org.eclipse.jface.dialogs.IInputValidator;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Text;\r
-import org.simantics.datatypes.literal.RGB;\r
-import org.simantics.scl.runtime.function.Function1;\r
-import org.simantics.ui.colors.Colors;\r
-import org.simantics.utils.ui.widgets.ITrackedColorProvider;\r
-import org.simantics.utils.ui.widgets.TrackedModifyEvent;\r
-import org.simantics.utils.ui.widgets.TrackedModifyListener;\r
-import org.simantics.utils.ui.widgets.TrackedText;\r
-import org.simantics.views.swt.client.base.SingleSWTViewNode;\r
-\r
-public class SWTTrackedText extends SingleSWTViewNode<Text> {\r
-       \r
-       private static final RGB.Integer WHITE = new RGB.Integer(255, 255, 255);\r
-       \r
-       private static final long serialVersionUID = 7932335224632082902L;\r
-       \r
-       private TrackedText tt;\r
-       \r
-       protected Color invalidBackgroundColor;\r
-       protected Color inactiveBackgroundColor;\r
-       protected Color hoverBackgroundColor;\r
-       protected Color editingBackgroundColor;\r
-\r
-       public Function1<String, String> modifier;\r
-       public Function1<String, String> validator;\r
-       \r
-       public RGB.Integer invalidBackground = WHITE;\r
-       public RGB.Integer inactiveBackground = WHITE;\r
-       public RGB.Integer hoverBackground = WHITE;\r
-       public RGB.Integer editingBackground = WHITE;\r
-\r
-       protected ArrayList<TrackedModifyListener> listeners = new ArrayList<TrackedModifyListener>();\r
-       \r
-       public void addModifyListener(TrackedModifyListener listener) {\r
-               this.listeners.add(listener);\r
-       }\r
-       \r
-       @Override\r
-       public void createControls(Composite parent) {\r
-               \r
-               tt = new TrackedText(parent, style);\r
-               control = tt.getWidget();\r
-\r
-               setProperties();\r
-               \r
-               tt.setColorProvider(new ITrackedColorProvider() {\r
-                       \r
-                       @Override\r
-                       public Color getInvalidBackground() {\r
-                               return invalidBackgroundColor;\r
-                       }\r
-                       \r
-                       @Override\r
-                       public Color getInactiveBackground() {\r
-                               return inactiveBackgroundColor;\r
-                       }\r
-                       \r
-                       @Override\r
-                       public Color getHoverBackground() {\r
-                               return hoverBackgroundColor;\r
-                       }\r
-                       \r
-                       @Override\r
-                       public Color getEditingBackground() {\r
-                               return editingBackgroundColor;\r
-                       }\r
-                       \r
-               });\r
-               \r
-               tt.setInputValidator(new IInputValidator() {\r
-                       \r
-                       @Override\r
-                       public String isValid(String newText) {\r
-                               if(validator != null) return validator.apply(newText);\r
-                               else return null;\r
-                       }\r
-                       \r
-               });\r
-               \r
-               tt.addModifyListener(new TrackedModifyListener() {\r
-                       \r
-                       @Override\r
-                       public void modifyText(TrackedModifyEvent e) {\r
-                               if(modifier != null)\r
-                                       modifier.apply(e.getText());\r
-                               for(TrackedModifyListener listener : listeners) listener.modifyText(e);\r
-                       }\r
-                       \r
-               });\r
-               \r
-       }\r
-\r
-       @Override\r
-       public void synchronizeText(String text) {\r
-               if(text != null) control.setText(text);\r
-       }\r
-       \r
-       final public void synchronizeInvalidBackground(RGB.Integer invalidBackground) {\r
-               if(invalidBackground != null) invalidBackgroundColor = Colors.swt(control.getDisplay(), invalidBackground);\r
-       }\r
-\r
-       final public void synchronizeInactiveBackground(RGB.Integer inactiveBackground) {\r
-               if(inactiveBackground != null) inactiveBackgroundColor = Colors.swt(control.getDisplay(), inactiveBackground);\r
-       }\r
-\r
-       final public void synchronizeHoverBackground(RGB.Integer hoverBackground) {\r
-               if(hoverBackground != null) hoverBackgroundColor = Colors.swt(control.getDisplay(), hoverBackground);\r
-       }\r
-\r
-       final public void synchronizeEditingBackground(RGB.Integer editingBackground) {\r
-               if(editingBackground != null) editingBackgroundColor = Colors.swt(control.getDisplay(), editingBackground);\r
-       }\r
-       \r
-       final public void synchronizeValidator(Function1<String, String> validator) {\r
-               \r
-       }\r
-\r
-       final public void synchronizeModifier(Function1<String, String> modifier) {\r
-               \r
-       }\r
-       \r
-}\r
+package org.simantics.views.swt.client.impl;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.simantics.datatypes.literal.RGB;
+import org.simantics.scl.runtime.function.Function1;
+import org.simantics.ui.colors.Colors;
+import org.simantics.utils.ui.widgets.ITrackedColorProvider;
+import org.simantics.utils.ui.widgets.TrackedModifyEvent;
+import org.simantics.utils.ui.widgets.TrackedModifyListener;
+import org.simantics.utils.ui.widgets.TrackedText;
+import org.simantics.views.swt.client.base.SingleSWTViewNode;
+
+public class SWTTrackedText extends SingleSWTViewNode<Text> {
+       
+       private static final RGB.Integer WHITE = new RGB.Integer(255, 255, 255);
+       
+       private static final long serialVersionUID = 7932335224632082902L;
+       
+       private TrackedText tt;
+       
+       protected Color invalidBackgroundColor;
+       protected Color inactiveBackgroundColor;
+       protected Color hoverBackgroundColor;
+       protected Color editingBackgroundColor;
+
+       public Function1<String, String> modifier;
+       public Function1<String, String> validator;
+       
+       public RGB.Integer invalidBackground = WHITE;
+       public RGB.Integer inactiveBackground = WHITE;
+       public RGB.Integer hoverBackground = WHITE;
+       public RGB.Integer editingBackground = WHITE;
+
+       protected ArrayList<TrackedModifyListener> listeners = new ArrayList<TrackedModifyListener>();
+       
+       public void addModifyListener(TrackedModifyListener listener) {
+               this.listeners.add(listener);
+       }
+       
+       @Override
+       public void createControls(Composite parent) {
+               
+               tt = new TrackedText(parent, style);
+               control = tt.getWidget();
+
+               setProperties();
+               
+               tt.setColorProvider(new ITrackedColorProvider() {
+                       
+                       @Override
+                       public Color getInvalidBackground() {
+                               return invalidBackgroundColor;
+                       }
+                       
+                       @Override
+                       public Color getInactiveBackground() {
+                               return inactiveBackgroundColor;
+                       }
+                       
+                       @Override
+                       public Color getHoverBackground() {
+                               return hoverBackgroundColor;
+                       }
+                       
+                       @Override
+                       public Color getEditingBackground() {
+                               return editingBackgroundColor;
+                       }
+                       
+               });
+               
+               tt.setInputValidator(new IInputValidator() {
+                       
+                       @Override
+                       public String isValid(String newText) {
+                               if(validator != null) return validator.apply(newText);
+                               else return null;
+                       }
+                       
+               });
+               
+               tt.addModifyListener(new TrackedModifyListener() {
+                       
+                       @Override
+                       public void modifyText(TrackedModifyEvent e) {
+                               if(modifier != null)
+                                       modifier.apply(e.getText());
+                               for(TrackedModifyListener listener : listeners) listener.modifyText(e);
+                       }
+                       
+               });
+               
+       }
+
+       @Override
+       public void synchronizeText(String text) {
+               if(text != null) control.setText(text);
+       }
+       
+       final public void synchronizeInvalidBackground(RGB.Integer invalidBackground) {
+               if(invalidBackground != null) invalidBackgroundColor = Colors.swt(control.getDisplay(), invalidBackground);
+       }
+
+       final public void synchronizeInactiveBackground(RGB.Integer inactiveBackground) {
+               if(inactiveBackground != null) inactiveBackgroundColor = Colors.swt(control.getDisplay(), inactiveBackground);
+       }
+
+       final public void synchronizeHoverBackground(RGB.Integer hoverBackground) {
+               if(hoverBackground != null) hoverBackgroundColor = Colors.swt(control.getDisplay(), hoverBackground);
+       }
+
+       final public void synchronizeEditingBackground(RGB.Integer editingBackground) {
+               if(editingBackground != null) editingBackgroundColor = Colors.swt(control.getDisplay(), editingBackground);
+       }
+       
+       final public void synchronizeValidator(Function1<String, String> validator) {
+               
+       }
+
+       final public void synchronizeModifier(Function1<String, String> modifier) {
+               
+       }
+       
+}