]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/widget/SCLTextEditor.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.document.swt.core / src / org / simantics / document / swt / core / widget / SCLTextEditor.java
index f4795bfbecbc3099a75028dfa828d904361e05ab..d33e82fe71f682d3b93d5b99895a7b138f80fff7 100644 (file)
@@ -1,74 +1,74 @@
-package org.simantics.document.swt.core.widget;\r
-\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.ui.PlatformUI;\r
-import org.simantics.document.server.JSONObject;\r
-import org.simantics.document.server.handler.AbstractEventHandler;\r
-import org.simantics.document.server.io.CommandContextImpl;\r
-import org.simantics.document.swt.core.SWTDocument;\r
-import org.simantics.document.swt.core.base.LeafWidgetManager;\r
-import org.simantics.scl.ui.editor.SCLTextEditorNew;\r
-import org.simantics.scl.ui.editor.TextAndErrors;\r
-import org.simantics.utils.ui.workbench.FocusContextActivator;\r
-\r
-public class SCLTextEditor extends LeafWidgetManager<SCLTextEditorNew> {\r
-       \r
-       public static class State {\r
-               \r
-               final private SWTDocument document;\r
-               final private SCLTextEditorNew editor;\r
-               public AbstractEventHandler onModify;\r
-\r
-               public State(SWTDocument document, SCLTextEditorNew editor) {\r
-                       this.document = document;\r
-                       this.editor = editor;\r
-               }\r
-\r
-               public void fireText() {\r
-                       if(onModify != null) {\r
-                               CommandContextImpl parameters = new CommandContextImpl();\r
-                               parameters.putString("text", editor.getContent());\r
-                               document.post(onModify, parameters);\r
-                       }\r
-               }\r
-               \r
-       }\r
-       \r
-       @Override\r
-       protected SCLTextEditorNew doCreateControl(SWTDocument document, Composite parent, JSONObject object) {\r
-               \r
-               SCLTextEditorNew editor = new SCLTextEditorNew(parent, SWT.NONE);\r
-               State state = new State(document, editor);\r
-\r
-               editor.viewer.getTextWidget().setData("state", state);\r
-               new FocusContextActivator("org.simantics.document.swt.core.widget.SCLTextEditor", editor.viewer.getTextWidget(), PlatformUI.getWorkbench().getActiveWorkbenchWindow());\r
-        \r
-               return editor;\r
-               \r
-       }\r
-       \r
-       @Override\r
-       protected void doUpdateProperties(SWTDocument document, SCLTextEditorNew control, JSONObject object) {\r
-\r
-               if(control.isDisposed()) return;\r
-               \r
-               TextAndErrors textAndErrors = object.getValue("textAndErrors");\r
-               if(textAndErrors == null) return;\r
-\r
-               // Disable updates during setContent\r
-\r
-               int caret = control.viewer.getTextWidget().getCaretOffset();\r
-               \r
-               control.setContent(textAndErrors.text, textAndErrors.errors);\r
-               \r
-               // For updates, restore caret\r
-               control.viewer.getTextWidget().setCaretOffset(caret);\r
-               \r
-               final AbstractEventHandler onModify = object.getValue("onModify");\r
-               State state = (State)control.viewer.getTextWidget().getData("state");\r
-               state.onModify = onModify;\r
-               \r
-       }\r
-       \r
-}\r
+package org.simantics.document.swt.core.widget;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PlatformUI;
+import org.simantics.document.server.JSONObject;
+import org.simantics.document.server.handler.AbstractEventHandler;
+import org.simantics.document.server.io.CommandContextImpl;
+import org.simantics.document.swt.core.SWTDocument;
+import org.simantics.document.swt.core.base.LeafWidgetManager;
+import org.simantics.scl.ui.editor.SCLTextEditorNew;
+import org.simantics.scl.ui.editor.TextAndErrors;
+import org.simantics.utils.ui.workbench.FocusContextActivator;
+
+public class SCLTextEditor extends LeafWidgetManager<SCLTextEditorNew> {
+       
+       public static class State {
+               
+               final private SWTDocument document;
+               final private SCLTextEditorNew editor;
+               public AbstractEventHandler onModify;
+
+               public State(SWTDocument document, SCLTextEditorNew editor) {
+                       this.document = document;
+                       this.editor = editor;
+               }
+
+               public void fireText() {
+                       if(onModify != null) {
+                               CommandContextImpl parameters = new CommandContextImpl();
+                               parameters.putString("text", editor.getContent());
+                               document.post(onModify, parameters);
+                       }
+               }
+               
+       }
+       
+       @Override
+       protected SCLTextEditorNew doCreateControl(SWTDocument document, Composite parent, JSONObject object) {
+               
+               SCLTextEditorNew editor = new SCLTextEditorNew(parent, SWT.NONE);
+               State state = new State(document, editor);
+
+               editor.viewer.getTextWidget().setData("state", state);
+               new FocusContextActivator("org.simantics.document.swt.core.widget.SCLTextEditor", editor.viewer.getTextWidget(), PlatformUI.getWorkbench().getActiveWorkbenchWindow());
+        
+               return editor;
+               
+       }
+       
+       @Override
+       protected void doUpdateProperties(SWTDocument document, SCLTextEditorNew control, JSONObject object) {
+
+               if(control.isDisposed()) return;
+               
+               TextAndErrors textAndErrors = object.getValue("textAndErrors");
+               if(textAndErrors == null) return;
+
+               // Disable updates during setContent
+
+               int caret = control.viewer.getTextWidget().getCaretOffset();
+               
+               control.setContent(textAndErrors.text, textAndErrors.errors);
+               
+               // For updates, restore caret
+               control.viewer.getTextWidget().setCaretOffset(caret);
+               
+               final AbstractEventHandler onModify = object.getValue("onModify");
+               State state = (State)control.viewer.getTextWidget().getData("state");
+               state.onModify = onModify;
+               
+       }
+       
+}