]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
refs #5096
authorjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 14 Jul 2014 12:50:43 +0000 (12:50 +0000)
committerjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 14 Jul 2014 12:50:43 +0000 (12:50 +0000)
Renaming ExpressionFieldUndoHandler to PropertyViewUndoHandler

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@29878 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/PropertyViewUndoHandler.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/ExpressionFieldUndoHandler.java with 51% similarity]

index 6e8d49e6b0dee37eafd66a250a5cbd4dcba0b83f..7b06dd5bb14c4e834bb7da0f042c1a8d94648638 100644 (file)
          </activeWhen>\r
       </handler>\r
             <handler\r
-            class="org.simantics.sysdyn.ui.ExpressionFieldUndoHandler"\r
+            class="org.simantics.sysdyn.ui.PropertyViewUndoHandler"\r
             commandId="org.eclipse.ui.edit.undo">\r
          <activeWhen>\r
             <reference\r
          </activeWhen>\r
       </handler>\r
       <handler\r
-            class="org.simantics.sysdyn.ui.ExpressionFieldUndoHandler"\r
+            class="org.simantics.sysdyn.ui.PropertyViewUndoHandler"\r
             commandId="org.eclipse.ui.edit.redo">\r
          <activeWhen>\r
             <reference\r
similarity index 51%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/ExpressionFieldUndoHandler.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/PropertyViewUndoHandler.java
index 3f33ea9c56c7e96e3bf79802fbb810809ea51f31..9fc3a966bc0253f6065d77af430f04d040d42b97 100644 (file)
@@ -3,36 +3,47 @@ package org.simantics.sysdyn.ui;
 import org.eclipse.core.commands.AbstractHandler;\r
 import org.eclipse.core.commands.ExecutionEvent;\r
 import org.eclipse.core.commands.ExecutionException;\r
-import org.eclipse.swt.custom.StyledText;\r
 import org.eclipse.swt.widgets.Composite;\r
 import org.eclipse.swt.widgets.Control;\r
 import org.eclipse.swt.widgets.Event;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.util.Layer0Utils;\r
+import org.eclipse.swt.widgets.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
 import org.simantics.sysdyn.ui.properties.widgets.expressions.ExpressionField;\r
+import org.simantics.ui.workbench.handler.SessionUndoHandler;\r
 \r
-public class ExpressionFieldUndoHandler extends AbstractHandler {\r
+public class PropertyViewUndoHandler extends AbstractHandler {\r
 \r
     @Override\r
     public Object execute(ExecutionEvent event) throws ExecutionException {\r
         String id = event.getCommand().getId();\r
         \r
+        Event e = (Event)event.getTrigger();\r
+        Widget w = e.widget;\r
+        Object data = w.getData(TrackedText.ID);\r
+        if (data != null) {\r
+            TrackedText text = (TrackedText) data;\r
+            if (id.equals("org.eclipse.ui.edit.undo"))\r
+                text.undo();\r
+            else\r
+                text.redo();\r
+            return null;\r
+        }\r
+        \r
+        \r
         Composite c = ((Control)((Event)event.getTrigger()).widget).getParent();\r
         if (c instanceof ExpressionField) {\r
             ExpressionField f = (ExpressionField)c;\r
-            if(id.equals("org.eclipse.ui.edit.undo")) {\r
+            if (id.equals("org.eclipse.ui.edit.undo")) {\r
                 f.getSourceViewer().getUndoManager().undo();\r
             }\r
             else {\r
                 f.getSourceViewer().getUndoManager().redo();\r
             }\r
         } else {\r
-            try {\r
-                Layer0Utils.undo();\r
-            } catch (DatabaseException e) {\r
-                // TODO Auto-generated catch block\r
-                e.printStackTrace();\r
-            }\r
+                SessionUndoHandler suh = new SessionUndoHandler();\r
+                suh.execute(event);\r
+                //Layer0Utils.undo();\r
+            \r
         }\r
         return null;\r
     }\r