Editor: Added missing undo/redo for hide option 22/8722/2
Caio SOUZA [Thu, 16 Aug 2012 15:52:10 +0000 (12:52 -0300)]
Change-Id: I9c1b4afae00154f484310f52600c412d5dc454b2

scilab/locale/.gitignore [deleted file]
scilab/modules/gui/src/java/org/scilab/modules/gui/editor/Editor.java
scilab/modules/gui/src/java/org/scilab/modules/gui/editor/action/ActionHide.java [new file with mode: 0644]

diff --git a/scilab/locale/.gitignore b/scilab/locale/.gitignore
deleted file mode 100644 (file)
index 9b9c2ff..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#
-# Ignore all localization files
-#
-*.mo
-*.po
-
index 9a47f51..4fba448 100644 (file)
@@ -37,6 +37,7 @@ import org.scilab.modules.gui.editor.action.ActionMove;
 import org.scilab.modules.gui.editor.action.ActionPaste;
 import org.scilab.modules.gui.editor.action.ActionTextEdit;
 import org.scilab.modules.gui.editor.action.ActionPasteStyle;
+import org.scilab.modules.gui.editor.action.ActionHide;
 import org.scilab.modules.gui.ged.Inspector;
 import org.scilab.modules.gui.ged.SelectionEnum;
 import org.scilab.modules.gui.ged.SwapObject;
@@ -644,6 +645,7 @@ public class Editor {
     public void onClickHide() {
         if (getSelected() != null) {
             CommonHandler.setVisible(selected, false);
+            editorHistory.addAction(new ActionHide(selected));
             setSelected(null);
         }
     }
@@ -835,42 +837,42 @@ public class Editor {
         String picked = null;
         String type = null;
         switch (num) {
-            /*try pick a polyline*/
+                /*try pick a polyline*/
             case 0:
                 picked = entityPicker.pick(figureUid, pos[0], pos[1]);
                 if (picked != null) {
                     selectedType = SelectionType.POLYLINE;
                     return picked;
                 }
-            /*try pick a surface - grayplot*/
+                /*try pick a surface - grayplot*/
             case 1:
                 picked = entityPicker.pickSurface(figureUid, pos);
                 type = (String) GraphicController.getController()
-                                        .getProperty(picked, GraphicObjectProperties.__GO_TYPE__);
+                       .getProperty(picked, GraphicObjectProperties.__GO_TYPE__);
                 if (picked != null && type == "Grayplot") {
                     selectedType = SelectionType.GRAYPLOT;
                     return picked;
                 }
-            /*try pick a surface - fac3d*/
+                /*try pick a surface - fac3d*/
             case 2:
                 if (picked != null && type == "Fac3d") {
                     selectedType = SelectionType.FAC3D;
                     return picked;
                 }
-            /*try pick a surface - plot3d*/
+                /*try pick a surface - plot3d*/
             case 3:
                 if (picked != null && type == "Plot3d") {
                     selectedType = SelectionType.PLOT3D;
                     return picked;
                 }
-            /*try pick a datatip*/
+                /*try pick a datatip*/
             case 4:
                 picked = DatatipSelect.selectDatatip(figureUid, pos[0], pos[1]);
                 if (picked != null) {
                     selectedType = SelectionType.DATATIP;
                     return picked;
                 }
-            /*try pick a legend*/
+                /*try pick a legend*/
             case 5:
                 selectedLegend = entityPicker.pickLegend(figureUid, pos);
                 if (selectedLegend != null) {
diff --git a/scilab/modules/gui/src/java/org/scilab/modules/gui/editor/action/ActionHide.java b/scilab/modules/gui/src/java/org/scilab/modules/gui/editor/action/ActionHide.java
new file mode 100644 (file)
index 0000000..67c29bf
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Pedro Arthur dos S. Souza
+ * Copyright (C) 2012 - Caio Lucas dos S. Souza
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+package org.scilab.modules.gui.editor.action;
+
+import org.scilab.modules.gui.editor.action.BaseAction;
+import org.scilab.modules.graphic_objects.graphicController.GraphicController;
+import org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties;
+
+/**
+* Implements the object to store hide related actions
+*
+* @author Caio Souza <caioc2bolado@gmail.com>
+* @author Pedro Souza <bygrandao@gmail.com>
+*
+* @since 2012-06-01
+*/
+public class ActionHide extends BaseAction {
+
+
+    /**
+    * Constructor
+    *
+    * @param object the hidden Object
+    */
+    public ActionHide(String object) {
+
+        super(object, (String)GraphicController.getController().getProperty(object, GraphicObjectProperties.__GO_PARENT__));
+    }
+
+    /**
+    * Undo, unhide the object
+    */
+    public void undo() {
+
+        if (exists()) {
+            GraphicController.getController().setProperty(objectUID, GraphicObjectProperties.__GO_VISIBLE__, true);
+        } else {
+            objectUID = null;
+        }
+    }
+
+    /**
+    * Redo, hide the object
+    */
+    public void redo() {
+
+        if (exists()) {
+            GraphicController.getController().setProperty(objectUID, GraphicObjectProperties.__GO_VISIBLE__, false);
+        } else {
+            objectUID = null;
+        }
+    }
+
+    public void dispose() {
+
+        objectUID = null;
+    }
+}
\ No newline at end of file