Menus improvements: localization, code factorization, ...
Vincent COUVERT [Wed, 30 Sep 2009 12:11:19 +0000 (14:11 +0200)]
21 files changed:
scilab/modules/xcos/src/java/org/scilab/modules/graph/actions/CopyAction.java
scilab/modules/xcos/src/java/org/scilab/modules/graph/actions/CutAction.java
scilab/modules/xcos/src/java/org/scilab/modules/graph/actions/DefaultAction.java
scilab/modules/xcos/src/java/org/scilab/modules/graph/actions/GroupAction.java
scilab/modules/xcos/src/java/org/scilab/modules/graph/actions/PasteAction.java
scilab/modules/xcos/src/java/org/scilab/modules/graph/actions/RedoAction.java
scilab/modules/xcos/src/java/org/scilab/modules/graph/actions/UnGroupAction.java
scilab/modules/xcos/src/java/org/scilab/modules/graph/actions/UndoAction.java
scilab/modules/xcos/src/java/org/scilab/modules/graph/actions/ZoomInAction.java
scilab/modules/xcos/src/java/org/scilab/modules/graph/actions/ZoomOutAction.java
scilab/modules/xcos/src/java/org/scilab/modules/graph/utils/ScilabGraphMessages.java [new file with mode: 0644]
scilab/modules/xcos/src/java/org/scilab/modules/xcos/Xcos.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/DumpAction.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/NewAction.java [new file with mode: 0644]
scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/OpenAction.java [new file with mode: 0644]
scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/RunAction.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/SaveAction.java [new file with mode: 0644]
scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/SetupAction.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/StopAction.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/ViewInScicosAction.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/utils/XcosMessages.java [new file with mode: 0644]

index 8a0d209..7ef22e0 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
  * 
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
 package org.scilab.modules.graph.actions;
 
 import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
 
+import javax.swing.KeyStroke;
 import javax.swing.TransferHandler;
 
 import org.scilab.modules.graph.ScilabGraph;
+import org.scilab.modules.graph.utils.ScilabGraphMessages;
 import org.scilab.modules.gui.menuitem.MenuItem;
 import org.scilab.modules.gui.pushbutton.PushButton;
+import org.scilab.modules.xcos.utils.XcosMessages;
 
 public class CopyAction extends DefaultAction {
 
+       private CopyAction(ScilabGraph scilabGraph) {
+               super(ScilabGraphMessages.COPY, scilabGraph);
+       }
+       
     public static PushButton copyButton(ScilabGraph scilabGraph) {
-       return createButton("Copy", "edit-copy.png", new CopyAction(scilabGraph));
+       return createButton(ScilabGraphMessages.COPY, "edit-copy.png", new CopyAction(scilabGraph));
     }
     
     public static MenuItem copyMenu(ScilabGraph scilabGraph) {
-       return createMenu("Copy", "edit-copy.png", new CopyAction(scilabGraph));
+       return createMenu(ScilabGraphMessages.COPY, "edit-copy.png", new CopyAction(scilabGraph), KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
     }
     
-    public CopyAction() {
-       super();
-    }
-    
-    public CopyAction(ScilabGraph scilabGraph) {
-       super(scilabGraph);
-    }
     public void actionPerformed(ActionEvent e) {
-       TransferHandler.getCopyAction().actionPerformed(new ActionEvent(getGraph(e).getAsComponent(),
-               e.getID(), e.getActionCommand()));
+       TransferHandler.getCopyAction().actionPerformed(new ActionEvent(getGraph(e).getAsComponent(), e.getID(), e.getActionCommand()));
     }
 }
index f22b9e1..fede345 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
  * 
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
 package org.scilab.modules.graph.actions;
 
 import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
 
+import javax.swing.KeyStroke;
 import javax.swing.TransferHandler;
 
 import org.scilab.modules.graph.ScilabGraph;
+import org.scilab.modules.graph.utils.ScilabGraphMessages;
 import org.scilab.modules.gui.menuitem.MenuItem;
 import org.scilab.modules.gui.pushbutton.PushButton;
 
 public class CutAction extends DefaultAction {
     
+    public CutAction(ScilabGraph scilabGraph) {
+       super(ScilabGraphMessages.CUT, scilabGraph);
+    }
     public static PushButton cutButton(ScilabGraph scilabGraph) {
-       return createButton("Cut", "edit-cut.png", new CutAction(scilabGraph));
+       return createButton(ScilabGraphMessages.CUT, "edit-cut.png", new CutAction(scilabGraph));
     }
     
     public static MenuItem cutMenu(ScilabGraph scilabGraph) {
-       return createMenu("Cut", "edit-cut.png", new CutAction(scilabGraph));
-    }
-    
-    public CutAction() {
-       super();
+       return createMenu(ScilabGraphMessages.CUT, "edit-cut.png", new CutAction(scilabGraph), KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
     }
     
-    public CutAction(ScilabGraph scilabGraph) {
-       super(scilabGraph);
-    }
     public void actionPerformed(ActionEvent e) {
-       TransferHandler.getCutAction().actionPerformed(new ActionEvent(getGraph(e).getAsComponent(),
-               e.getID(), e.getActionCommand()));
+       TransferHandler.getCutAction().actionPerformed(new ActionEvent(getGraph(e).getAsComponent(), e.getID(), e.getActionCommand()));
     }
 }
index f7d12eb..fcb60c3 100644 (file)
@@ -16,13 +16,14 @@ import java.awt.Component;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 
-import javax.swing.AbstractAction;
 import javax.swing.ImageIcon;
 import javax.swing.JOptionPane;
+import javax.swing.KeyStroke;
 
 import org.scilab.modules.graph.ScilabGraph;
 import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem;
 import org.scilab.modules.gui.bridge.pushbutton.SwingScilabPushButton;
+import org.scilab.modules.gui.events.callback.CallBack;
 import org.scilab.modules.gui.menuitem.MenuItem;
 import org.scilab.modules.gui.menuitem.ScilabMenuItem;
 import org.scilab.modules.gui.pushbutton.PushButton;
@@ -30,17 +31,20 @@ import org.scilab.modules.gui.pushbutton.ScilabPushButton;
 
 import com.mxgraph.swing.mxGraphComponent;
 
-public class DefaultAction extends AbstractAction {
+public class DefaultAction extends CallBack {
 
     private ScilabGraph _scilabGraph = null;
 
-    public DefaultAction() { }
-
     public DefaultAction(ScilabGraph scilabGraph) {
-       _scilabGraph = scilabGraph;
+       super("Default...");
+       _scilabGraph = scilabGraph;
     }
 
-    public void actionPerformed(ActionEvent e) {
+    protected DefaultAction(String label, ScilabGraph scilabGraph) {
+       super(label);
+       _scilabGraph = scilabGraph;
+        }
+   public void actionPerformed(ActionEvent e) {
        JOptionPane.showMessageDialog(null, "Not Implemented Now !!!", null, JOptionPane.ERROR_MESSAGE);
     }
 
@@ -71,6 +75,7 @@ public class DefaultAction extends AbstractAction {
        return null;
     }
 
+    
     protected static PushButton createButton(String title, String icon, ActionListener listener) {
        PushButton button = ScilabPushButton.createPushButton(); 
        ((SwingScilabPushButton) button.getAsSimplePushButton()).addActionListener(listener);
@@ -84,11 +89,24 @@ public class DefaultAction extends AbstractAction {
        return button;
     }
 
-    protected static MenuItem createMenu(String title, String icon, ActionListener listener) {
-       MenuItem menu = ScilabMenuItem.createMenuItem();
-       ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()).addActionListener(listener);
-       menu.setText(title);
+    protected static MenuItem createMenu(String title, String icon, DefaultAction listener, KeyStroke keyStroke) {
+       MenuItem menu = ScilabMenuItem.createMenuItem();
+       menu.setCallback(listener);
+       menu.setText(title);
 
-       return menu;
+       if (keyStroke != null) {
+               ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()).setAccelerator(keyStroke);
+       }
+       
+       return menu;
+    }
+    
+    public void doAction() {
+       JOptionPane.showMessageDialog(getGraph(null).getAsComponent(), "Not Implemented Now !!!", null, JOptionPane.ERROR_MESSAGE);
     }
+
+    public void callBack() {
+       doAction();
+        }
+
 }
index 78b7f33..dca916f 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
  * 
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
@@ -15,32 +16,29 @@ package org.scilab.modules.graph.actions;
 import java.awt.event.ActionEvent;
 
 import org.scilab.modules.graph.ScilabGraph;
+import org.scilab.modules.graph.utils.ScilabGraphMessages;
 import org.scilab.modules.gui.menuitem.MenuItem;
 import org.scilab.modules.gui.pushbutton.PushButton;
 
 import com.mxgraph.swing.util.mxGraphActions;
 
 public class GroupAction extends DefaultAction {
-    
-    public static PushButton groupButton(ScilabGraph scilabGraph) {
-       return createButton("Group", null, new GroupAction(scilabGraph));
-    }
-    
-    public static MenuItem groupMenu(ScilabGraph scilabGraph) {
-       return createMenu("Group", null, new GroupAction(scilabGraph));
-    }
-    
-    public GroupAction() {
-       super();
-    }
-    
-    public GroupAction(ScilabGraph scilabGraph) {
-       super(scilabGraph);
-    }
-    
-    public void actionPerformed(ActionEvent e) {
-       mxGraphActions.getGroupAction().actionPerformed(new ActionEvent(getGraph(e).getAsComponent(),
-               e.getID(), e.getActionCommand()));
-    }
+
+       public GroupAction(ScilabGraph scilabGraph) {
+               super(ScilabGraphMessages.GROUP, scilabGraph);
+       }
+
+       public static PushButton groupButton(ScilabGraph scilabGraph) {
+               return createButton(ScilabGraphMessages.GROUP, null, new GroupAction(scilabGraph));
+       }
+
+       public static MenuItem groupMenu(ScilabGraph scilabGraph) {
+               return createMenu(ScilabGraphMessages.GROUP, null, new GroupAction(scilabGraph), null);
+       }
+
+       public void actionPerformed(ActionEvent e) {
+               mxGraphActions.getGroupAction().actionPerformed(new ActionEvent(getGraph(e).getAsComponent(),
+                               e.getID(), e.getActionCommand()));
+       }
 
 }
index 657f960..bf7dab6 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
  * 
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
 package org.scilab.modules.graph.actions;
 
 import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
 
+import javax.swing.KeyStroke;
 import javax.swing.TransferHandler;
 
 import org.scilab.modules.graph.ScilabGraph;
+import org.scilab.modules.graph.utils.ScilabGraphMessages;
 import org.scilab.modules.gui.menuitem.MenuItem;
 import org.scilab.modules.gui.pushbutton.PushButton;
 
 public class PasteAction extends DefaultAction {
-    
-    public static PushButton pasteButton(ScilabGraph scilabGraph) {
-       return createButton("Paste", "edit-paste.png", new PasteAction(scilabGraph));
-    }
-    
-    public static MenuItem pasteMenu(ScilabGraph scilabGraph) {
-       return createMenu("Paste", "edit-paste.png", new PasteAction(scilabGraph));
-    }
-    
-    public PasteAction() {
-       super();
-    }
-    
-    public PasteAction(ScilabGraph scilabGraph) {
-       super(scilabGraph);
-    }
-    public void actionPerformed(ActionEvent e) {
-       TransferHandler.getPasteAction().actionPerformed(new ActionEvent(getGraph(e).getAsComponent(),
-               e.getID(), e.getActionCommand()));
-    }
+
+       public PasteAction(ScilabGraph scilabGraph) {
+               super(ScilabGraphMessages.PASTE, scilabGraph);
+       }
+
+       public static PushButton pasteButton(ScilabGraph scilabGraph) {
+               return createButton(ScilabGraphMessages.PASTE, "edit-paste.png", new PasteAction(scilabGraph));
+       }
+
+       public static MenuItem pasteMenu(ScilabGraph scilabGraph) {
+               return createMenu(ScilabGraphMessages.PASTE, "edit-paste.png", new PasteAction(scilabGraph), KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK));
+       }
+
+       public void actionPerformed(ActionEvent e) {
+               TransferHandler.getPasteAction().actionPerformed(new ActionEvent(getGraph(e).getAsComponent(),
+                               e.getID(), e.getActionCommand()));
+       }
 }
index 0c0efc6..49ba69a 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
  * 
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
 package org.scilab.modules.graph.actions;
 
 import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
 
 import org.scilab.modules.graph.ScilabGraph;
+import org.scilab.modules.graph.utils.ScilabGraphMessages;
 import org.scilab.modules.gui.menuitem.MenuItem;
 import org.scilab.modules.gui.pushbutton.PushButton;
 
 public class RedoAction extends DefaultAction {
-    
-    public static PushButton redoButton(ScilabGraph scilabGraph) {
-       return createButton("Redo", "edit-redo.png", new RedoAction(scilabGraph));
-    }
-    
-    public static MenuItem redoMenu(ScilabGraph scilabGraph) {
-       return createMenu("Redo", "edit-redo.png", new RedoAction(scilabGraph));
-    }
-    
-    public RedoAction() {
-       super();
-    }
-    
-    public RedoAction(ScilabGraph scilabGraph) {
-       super(scilabGraph);
-    }
-    
-    public void actionPerformed(ActionEvent e) {
-       getGraph(e).redo();
-    }
-
-  
+
+       public RedoAction(ScilabGraph scilabGraph) {
+               super(ScilabGraphMessages.REDO, scilabGraph);
+       }
+
+       public static PushButton redoButton(ScilabGraph scilabGraph) {
+               return createButton(ScilabGraphMessages.REDO, "edit-redo.png", new RedoAction(scilabGraph));
+       }
+
+       public static MenuItem redoMenu(ScilabGraph scilabGraph) {
+               return createMenu(ScilabGraphMessages.REDO, "edit-redo.png", new RedoAction(scilabGraph), KeyStroke.getKeyStroke(KeyEvent.VK_Y, ActionEvent.CTRL_MASK));
+       }
+
+       public void actionPerformed(ActionEvent e) {
+               getGraph(e).redo();
+       }
+
+
 
 }
index 4ee5111..98e4282 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
  * 
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
@@ -15,6 +16,7 @@ package org.scilab.modules.graph.actions;
 import java.awt.event.ActionEvent;
 
 import org.scilab.modules.graph.ScilabGraph;
+import org.scilab.modules.graph.utils.ScilabGraphMessages;
 import org.scilab.modules.gui.menuitem.MenuItem;
 import org.scilab.modules.gui.pushbutton.PushButton;
 
@@ -22,25 +24,21 @@ import com.mxgraph.swing.util.mxGraphActions;
 
 public class UnGroupAction extends DefaultAction {
 
-    public static PushButton ungroupButton(ScilabGraph scilabGraph) {
-       return createButton("UnGroup", null, new UnGroupAction(scilabGraph));
-    }
-    
-    public static MenuItem ungroupMenu(ScilabGraph scilabGraph) {
-       return createMenu("UnGroup", null, new UnGroupAction(scilabGraph));
-    }
-    
-    public UnGroupAction() {
-       super();
-    }
-    
-    public UnGroupAction(ScilabGraph scilabGraph) {
-       super(scilabGraph);
-    }
-    
-    public void actionPerformed(ActionEvent e) {
-       mxGraphActions.getUngroupAction().actionPerformed(new ActionEvent(getGraph(e).getAsComponent(),
-               e.getID(), e.getActionCommand()));
-    }
+       public UnGroupAction(ScilabGraph scilabGraph) {
+               super(ScilabGraphMessages.UNGROUP, scilabGraph);
+       }
+
+       public static PushButton ungroupButton(ScilabGraph scilabGraph) {
+               return createButton(ScilabGraphMessages.UNGROUP, null, new UnGroupAction(scilabGraph));
+       }
+
+       public static MenuItem ungroupMenu(ScilabGraph scilabGraph) {
+               return createMenu(ScilabGraphMessages.UNGROUP, null, new UnGroupAction(scilabGraph), null);
+       }
+
+       public void actionPerformed(ActionEvent e) {
+               mxGraphActions.getUngroupAction().actionPerformed(new ActionEvent(getGraph(e).getAsComponent(),
+                               e.getID(), e.getActionCommand()));
+       }
 
 }
index 8be2887..4701217 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
  * 
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
 package org.scilab.modules.graph.actions;
 
 import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
 
 import org.scilab.modules.graph.ScilabGraph;
+import org.scilab.modules.graph.utils.ScilabGraphMessages;
 import org.scilab.modules.gui.menuitem.MenuItem;
 import org.scilab.modules.gui.pushbutton.PushButton;
 
 public class UndoAction extends DefaultAction {
 
-    public static PushButton undoButton(ScilabGraph scilabGraph) {
-       return createButton("Undo", "edit-undo.png", new UndoAction(scilabGraph));
-    }
-    
-    public static MenuItem undoMenu(ScilabGraph scilabGraph) {
-       return createMenu("Undo", "edit-undo.png", new UndoAction(scilabGraph));
-    }
-    
-    public UndoAction() {
-       super();
-    }
-    
-    public UndoAction(ScilabGraph editgraph) {
-       super(editgraph);
-    }
-
-    public void actionPerformed(ActionEvent e) {
-       getGraph(e).undo();
-    }
+       public UndoAction(ScilabGraph editgraph) {
+               super(ScilabGraphMessages.UNDO, editgraph);
+       }
+
+       public static PushButton undoButton(ScilabGraph scilabGraph) {
+               return createButton(ScilabGraphMessages.UNDO, "edit-undo.png", new UndoAction(scilabGraph));
+       }
+
+       public static MenuItem undoMenu(ScilabGraph scilabGraph) {
+               return createMenu(ScilabGraphMessages.UNDO, "edit-undo.png", new UndoAction(scilabGraph), KeyStroke.getKeyStroke(KeyEvent.VK_Z, ActionEvent.CTRL_MASK));
+       }
+
+       public void actionPerformed(ActionEvent e) {
+               getGraph(e).undo();
+       }
 
 }
index 29fd73f..4ed2901 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
  * 
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
 package org.scilab.modules.graph.actions;
 
 import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
 
 import org.scilab.modules.graph.ScilabGraph;
+import org.scilab.modules.graph.utils.ScilabGraphMessages;
 import org.scilab.modules.gui.menuitem.MenuItem;
 import org.scilab.modules.gui.pushbutton.PushButton;
 
 import com.mxgraph.swing.util.mxGraphActions;
 
-public class ZoomInAction extends DefaultAction implements ActionListener {
-    
-    public static PushButton zoominButton(ScilabGraph scilabGraph) {
-       return createButton("Zoom In", null, new ZoomInAction(scilabGraph));
-    }
-    
-    public static MenuItem zoominMenu(ScilabGraph scilabGraph) {
-       return createMenu("Zoom In", null, new ZoomInAction(scilabGraph));
-    }
-    
-    public ZoomInAction() {
-       super();
-    }
-    
-    public ZoomInAction(ScilabGraph scilabGraph) {
-       super(scilabGraph);
-    }
-    
-    public void actionPerformed(ActionEvent e) {
-       mxGraphActions.getZoomInAction().actionPerformed(new ActionEvent(getGraph(e).getAsComponent(),
-               e.getID(), e.getActionCommand()));
-    }
+public class ZoomInAction extends DefaultAction {
+
+       public ZoomInAction(ScilabGraph scilabGraph) {
+               super(ScilabGraphMessages.ZOOM_IN, scilabGraph);
+       }
+
+       public static PushButton zoominButton(ScilabGraph scilabGraph) {
+               return createButton(ScilabGraphMessages.ZOOM_IN, null, new ZoomInAction(scilabGraph));
+       }
+
+       public static MenuItem zoominMenu(ScilabGraph scilabGraph) {
+               return createMenu(ScilabGraphMessages.ZOOM_IN, null, new ZoomInAction(scilabGraph), KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, ActionEvent.CTRL_MASK));
+       }
+
+       public void actionPerformed(ActionEvent e) {
+               mxGraphActions.getZoomInAction().actionPerformed(new ActionEvent(getGraph(e).getAsComponent(),
+                               e.getID(), e.getActionCommand()));
+       }
 
 }
index 6763bff..4d8cb9f 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
  * 
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
@@ -14,34 +15,34 @@ package org.scilab.modules.graph.actions;
 
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
 
 import org.scilab.modules.graph.ScilabGraph;
+import org.scilab.modules.graph.utils.ScilabGraphMessages;
 import org.scilab.modules.gui.menuitem.MenuItem;
 import org.scilab.modules.gui.pushbutton.PushButton;
 
 import com.mxgraph.swing.util.mxGraphActions;
 
 public class ZoomOutAction extends DefaultAction implements ActionListener {
-    
-    public static PushButton zoomoutButton(ScilabGraph scilabGraph) {
-       return createButton("Zoom Out", null, new ZoomOutAction(scilabGraph));
-    }
-    
-    public static MenuItem zoomoutMenu(ScilabGraph scilabGraph) {
-       return createMenu("Zoom Out", null, new ZoomOutAction(scilabGraph));
-    }
-    
-    public ZoomOutAction() {
-       super();
-    }
-    
-    public ZoomOutAction(ScilabGraph scilabGraph) {
-       super(scilabGraph);
-    }
-    
-    public void actionPerformed(ActionEvent e) {
-       mxGraphActions.getZoomOutAction().actionPerformed(new ActionEvent(getGraph(e).getAsComponent(),
-               e.getID(), e.getActionCommand()));
-    }
+
+       public static PushButton zoomoutButton(ScilabGraph scilabGraph) {
+               return createButton(ScilabGraphMessages.ZOOM_OUT, null, new ZoomOutAction(scilabGraph));
+       }
+
+       public static MenuItem zoomoutMenu(ScilabGraph scilabGraph) {
+               return createMenu(ScilabGraphMessages.ZOOM_OUT, null, new ZoomOutAction(scilabGraph), KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, ActionEvent.CTRL_MASK));
+       }
+
+       public ZoomOutAction(ScilabGraph scilabGraph) {
+               super(ScilabGraphMessages.ZOOM_OUT, scilabGraph);
+       }
+
+       public void actionPerformed(ActionEvent e) {
+               mxGraphActions.getZoomOutAction().actionPerformed(new ActionEvent(getGraph(e).getAsComponent(),
+                               e.getID(), e.getActionCommand()));
+       }
 
 }
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/graph/utils/ScilabGraphMessages.java b/scilab/modules/xcos/src/java/org/scilab/modules/graph/utils/ScilabGraphMessages.java
new file mode 100644 (file)
index 0000000..b4eb22f
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
+ *
+ * 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.graph.utils;
+
+import org.scilab.modules.localization.Messages;
+
+public class ScilabGraphMessages {
+    
+       public static final String COPY = Messages.gettext("Copy");
+       public static final String CUT = Messages.gettext("Cut");
+       public static final String GROUP = Messages.gettext("Group");
+       public static final String UNGROUP = Messages.gettext("UnGroup");
+       public static final String PASTE = Messages.gettext("Paste");
+       public static final String REDO = Messages.gettext("Redo");
+       public static final String UNDO = Messages.gettext("Undo");
+       public static final String ZOOM_IN = Messages.gettext("Zoom In");
+       public static final String ZOOM_OUT = Messages.gettext("Zoom Out");
+       
+}
index 565c28e..5fc1283 100644 (file)
@@ -48,12 +48,16 @@ import org.scilab.modules.gui.window.ScilabWindow;
 import org.scilab.modules.gui.window.Window;
 import org.scilab.modules.xcos.actions.DumpAction;
 import org.scilab.modules.xcos.actions.RunAction;
+import org.scilab.modules.xcos.actions.SaveAction;
 import org.scilab.modules.xcos.actions.SetupAction;
 import org.scilab.modules.xcos.actions.StopAction;
 import org.scilab.modules.xcos.actions.ViewInScicosAction;
 import org.scilab.modules.xcos.block.BasicBlock;
 import org.scilab.modules.xcos.block.BlockReader;
 import org.scilab.modules.xcos.palette.XcosPalette;
+import org.scilab.modules.xcos.utils.XcosMessages;
+import org.scilab.modules.xcos.actions.NewAction;
+import org.scilab.modules.xcos.actions.OpenAction;
 
 import com.mxgraph.swing.mxGraphOutline;
 
@@ -197,25 +201,32 @@ public class Xcos extends SwingScilabTab implements Tab {
     }
     
     public static MenuBar createMenuBar(ScilabGraph scilabGraph) {
-       /*
-        * MENU BAR
-        */
-       // FILE
-       MenuBar menuBar = ScilabMenuBar.createMenuBar();
-       Menu file = ScilabMenu.createMenu();
-       file.setText("File");
-       MenuItem newItem = ScilabMenuItem.createMenuItem();
-       newItem.setText("New");
-       JMenuItem quit = new JMenuItem("Quit");
-       quit.addActionListener(new ActionListener() {
-           public void actionPerformed(ActionEvent arg0) { System.exit(0); }
-       });
-       file.add(newItem);
-       file.add(DumpAction.dumpMenu(scilabGraph));
-       file.add(ViewInScicosAction.viewInScicosMenu(scilabGraph));
-       //file.add(quit);
-       menuBar.add(file);
 
+       MenuBar menuBar = ScilabMenuBar.createMenuBar();
+
+       /** FILE MENU */
+               Menu fileMenu = ScilabMenu.createMenu();
+               fileMenu.setText(XcosMessages.FILE);
+               fileMenu.setMnemonic('F');
+               fileMenu.add(NewAction.createMenu(scilabGraph));
+               fileMenu.add(OpenAction.createMenu(scilabGraph));
+       fileMenu.addSeparator();
+               fileMenu.add(SaveAction.createMenu(scilabGraph));
+               //fileMenu.add(SaveAsAction.createMenu(scilabGraph));
+               //fileMenu.add(ExportAction.createMenu(scilabGraph));
+               //fileMenu.add(SaveAsInterfFuncAction.createMenu(scilabGraph));
+       //fileMenu.addSeparator();
+               //fileMenu.add(PrintAction.createMenu(scilabGraph));
+       //fileMenu.addSeparator();
+               //fileMenu.add(CloseAction.createMenu(scilabGraph));
+       //fileMenu.addSeparator();
+               //fileMenu.add(QuitAction.createMenu(scilabGraph));
+       fileMenu.addSeparator();
+               fileMenu.add(DumpAction.dumpMenu(scilabGraph));
+               fileMenu.add(ViewInScicosAction.viewInScicosMenu(scilabGraph));
+               
+               menuBar.add(fileMenu);
+       
        // EDIT
        Menu edit = ScilabMenu.createMenu();
        edit.setText("Edit");
index 6f1072a..7b02fbe 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
  * 
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
@@ -14,33 +15,28 @@ package org.scilab.modules.xcos.actions;
 
 import java.awt.event.ActionEvent;
 
-import javax.swing.TransferHandler;
-
 import org.scilab.modules.graph.ScilabGraph;
 import org.scilab.modules.graph.actions.DefaultAction;
 import org.scilab.modules.gui.menuitem.MenuItem;
 import org.scilab.modules.gui.pushbutton.PushButton;
 import org.scilab.modules.xcos.XcosDiagram;
+import org.scilab.modules.xcos.utils.XcosMessages;
 
 public class DumpAction extends DefaultAction {
 
+    public DumpAction(ScilabGraph scilabGraph) {
+       super(XcosMessages.DUMP, scilabGraph);
+    }
     public static PushButton dumpButton(ScilabGraph scilabGraph) {
-       return createButton("Dump", null, new DumpAction(scilabGraph));
+       return createButton(XcosMessages.DUMP, null, new DumpAction(scilabGraph));
     }
     
     public static MenuItem dumpMenu(ScilabGraph scilabGraph) {
-       return createMenu("Dump", null, new DumpAction(scilabGraph));
+       return createMenu(XcosMessages.DUMP, null, new DumpAction(scilabGraph), null);
     }
     
-    public DumpAction() {
-       super();
-    }
-    
-    public DumpAction(ScilabGraph scilabGraph) {
-       super(scilabGraph);
-    }
     public void actionPerformed(ActionEvent e) {
-       ((XcosDiagram) getGraph(e)).dumpToHdf5File(null);
+       ((XcosDiagram) getGraph(e)).dumpToHdf5File(null);
     }
 }
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/NewAction.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/NewAction.java
new file mode 100644 (file)
index 0000000..a54a7db
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
+ * 
+ * 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.xcos.actions;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
+
+import org.scilab.modules.graph.ScilabGraph;
+import org.scilab.modules.graph.actions.DefaultAction;
+import org.scilab.modules.gui.menuitem.MenuItem;
+import org.scilab.modules.gui.pushbutton.PushButton;
+import org.scilab.modules.xcos.actions.NewAction;
+import org.scilab.modules.xcos.utils.XcosMessages;
+
+public class NewAction extends DefaultAction {
+
+       private NewAction(ScilabGraph scilabGraph) {
+               super(XcosMessages.NEW, scilabGraph);
+       }
+
+       public static MenuItem createMenu(ScilabGraph scilabGraph) {
+               return createMenu(XcosMessages.NEW, null, new NewAction(scilabGraph), KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
+       }
+
+       public static PushButton createButton(ScilabGraph scilabGraph) {
+               return createButton(XcosMessages.NEW, "document-new.png", new NewAction(scilabGraph));
+       }
+
+}
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/OpenAction.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/OpenAction.java
new file mode 100644 (file)
index 0000000..774a0fa
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
+ * 
+ * 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.xcos.actions;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
+
+import org.scilab.modules.graph.ScilabGraph;
+import org.scilab.modules.graph.actions.DefaultAction;
+import org.scilab.modules.gui.menuitem.MenuItem;
+import org.scilab.modules.gui.pushbutton.PushButton;
+import org.scilab.modules.xcos.utils.XcosMessages;
+
+public class OpenAction extends DefaultAction {
+
+       private OpenAction(ScilabGraph scilabGraph) {
+               super(XcosMessages.OPEN, scilabGraph);
+       }
+
+       public static MenuItem createMenu(ScilabGraph scilabGraph) {
+               return createMenu(XcosMessages.OPEN, null, new OpenAction(scilabGraph), KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
+       }
+
+       public static PushButton createButton(ScilabGraph scilabGraph) {
+               return createButton(XcosMessages.OPEN, "document-open.png", new OpenAction(scilabGraph));
+       }
+
+}
index 1f1bdc4..9ffcf75 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
  * 
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
@@ -22,34 +23,32 @@ import org.scilab.modules.graph.actions.DefaultAction;
 import org.scilab.modules.gui.menuitem.MenuItem;
 import org.scilab.modules.gui.pushbutton.PushButton;
 import org.scilab.modules.xcos.XcosDiagram;
+import org.scilab.modules.xcos.utils.XcosMessages;
 
 public class RunAction  extends DefaultAction {
-    public static PushButton runButton(ScilabGraph scilabGraph) {
-       return createButton("Run", null, new RunAction(scilabGraph));
-    }
-
-    public static MenuItem runMenu(ScilabGraph scilabGraph) {
-       return createMenu("Run", null, new RunAction(scilabGraph));
-    }
-
-    public RunAction() {
-       super();
-    }
-
-    public RunAction(ScilabGraph scilabGraph) {
-       super(scilabGraph);
-    }
-
-    public void actionPerformed(ActionEvent e) {
-       File temp;
-       try {
-           temp = File.createTempFile("xcos",".hdf5");
-           temp.delete();
-           ((XcosDiagram) getGraph(e)).dumpToHdf5File(temp.getAbsolutePath());
-           InterpreterManagement.requestScilabExec("import_from_hdf5(\""+temp.getAbsolutePath()+"\");scicos_simulate(scs_m);");
-           temp.deleteOnExit();
-       } catch (IOException e1) {
-           e1.printStackTrace();
+
+       public RunAction(ScilabGraph scilabGraph) {
+               super(XcosMessages.RUN, scilabGraph);
+       }
+
+       public static PushButton runButton(ScilabGraph scilabGraph) {
+               return createButton(XcosMessages.RUN, null, new RunAction(scilabGraph));
+       }
+
+       public static MenuItem runMenu(ScilabGraph scilabGraph) {
+               return createMenu(XcosMessages.RUN, null, new RunAction(scilabGraph), null);
+       }
+
+       public void actionPerformed(ActionEvent e) {
+               File temp;
+               try {
+                       temp = File.createTempFile("xcos",".hdf5");
+                       temp.delete();
+                       ((XcosDiagram) getGraph(e)).dumpToHdf5File(temp.getAbsolutePath());
+                       InterpreterManagement.requestScilabExec("import_from_hdf5(\""+temp.getAbsolutePath()+"\");scicos_simulate(scs_m);");
+                       temp.deleteOnExit();
+               } catch (IOException e1) {
+                       e1.printStackTrace();
+               }
        }
-    }
 }
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/SaveAction.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/SaveAction.java
new file mode 100644 (file)
index 0000000..b03d054
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
+ * 
+ * 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.xcos.actions;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
+
+import org.scilab.modules.graph.ScilabGraph;
+import org.scilab.modules.graph.actions.DefaultAction;
+import org.scilab.modules.gui.menuitem.MenuItem;
+import org.scilab.modules.gui.pushbutton.PushButton;
+import org.scilab.modules.xcos.utils.XcosMessages;
+
+public class SaveAction extends DefaultAction {
+
+       private SaveAction(ScilabGraph scilabGraph) {
+               super(XcosMessages.SAVE, scilabGraph);
+       }
+
+       public static MenuItem createMenu(ScilabGraph scilabGraph) {
+               return createMenu(XcosMessages.SAVE, null, new SaveAction(scilabGraph), KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
+       }
+
+       public static PushButton createButton(ScilabGraph scilabGraph) {
+               return createButton(XcosMessages.SAVE, "document-save.png", new SaveAction(scilabGraph));
+       }
+
+}
index 50d7135..8178eab 100644 (file)
@@ -17,30 +17,25 @@ import java.awt.GridBagLayout;
 import java.awt.Insets;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
 import java.awt.event.WindowEvent;
 import java.awt.event.WindowListener;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 import javax.swing.JButton;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
 import javax.swing.JSpinner;
-import javax.swing.JTextField;
 import javax.swing.SpinnerNumberModel;
 
-import org.scilab.modules.action_binding.InterpreterManagement;
 import org.scilab.modules.graph.ScilabGraph;
 import org.scilab.modules.graph.actions.DefaultAction;
 import org.scilab.modules.gui.menuitem.MenuItem;
 import org.scilab.modules.gui.pushbutton.PushButton;
 import org.scilab.modules.xcos.XcosDiagram;
+import org.scilab.modules.xcos.utils.XcosMessages;
 
 
 public class SetupAction extends DefaultAction {
-       
+
        private static boolean windowAlreadyExist ;
        private JFrame mainFrame ;
        private XcosDiagram diagram ;
@@ -52,195 +47,175 @@ public class SetupAction extends DefaultAction {
        private JSpinner maxIntegrationTimeSpinner;
        private JSpinner solverSpinner;
        private JSpinner maxStepSizeSpinner;
-       
+
+       public SetupAction(ScilabGraph scilabGraph) {
+               super(XcosMessages.SETUP,scilabGraph);
+       }
+
        public static PushButton setupButton(ScilabGraph scilabGraph) {
-               return createButton("Setup", null, new SetupAction(scilabGraph));
-    }
-
-    public static MenuItem setupMenu(ScilabGraph scilabGraph) {
-       return createMenu("Setup", null, new SetupAction(scilabGraph));
-    }
-
-    public SetupAction() {
-       super();
-    }
-
-    public SetupAction(ScilabGraph scilabGraph) {
-       super(scilabGraph);
-    }
-
-    @Override
-    public void actionPerformed(ActionEvent e) {
-       // TODO Auto-generated method stub
-       
-       setupBox(e);
-       
-    }
-    
-    
-    public void setupBox (ActionEvent e){
-
-
-
-       
-       mainFrame = new JFrame();
-        mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-        mainFrame.setLayout(new GridBagLayout());
-        
-        diagram = (XcosDiagram)getGraph(e);
-
-
-        JLabel integrationLabel = new JLabel("Final inegration time");
-        SpinnerNumberModel spinnerModel = new SpinnerNumberModel(diagram.getFinalIntegrationTime( ) ,null,null, 1);
-        integrationSpinner = new JSpinner( );
-        integrationSpinner.setModel(spinnerModel);
-        integrationSpinner.setEditor(new JSpinner.NumberEditor(integrationSpinner,"0"));
-        
-               
-                 ;
-               ;
-                ;
-                 ;
-                 ;
-                ;
-                 ;
-        
-        JLabel rtsLabel = new JLabel("Real time scaling");
-        spinnerModel = new SpinnerNumberModel(diagram.getRealTimeScaling() ,null,null, 0.0000001);
-        rtsSpinner = new JSpinner( );
-        rtsSpinner.setModel(spinnerModel);
-        rtsSpinner.setEditor(new JSpinner.NumberEditor(rtsSpinner,"0.00000000"));
-        
-        JLabel integratorAbsLabel = new JLabel("Integrator absolute tolerance");
-        spinnerModel = new SpinnerNumberModel(diagram.getIntegratorAbsoluteTolerance(),null,null, 0.00001);
-        integratorAbsSpinner = new JSpinner( );
-        integratorAbsSpinner.setModel(spinnerModel);
-        integratorAbsSpinner.setEditor(new JSpinner.NumberEditor(integratorAbsSpinner,"0.00000"));
-        
-        JLabel integratorRelLabel = new JLabel("Integrator relative tolerance");
-        spinnerModel = new SpinnerNumberModel(diagram.getIntegratorRelativeTolerance(),null,null, 0.0000001);
-        integratorRelSpinner = new JSpinner( );
-        integratorRelSpinner.setModel(spinnerModel);
-        integratorRelSpinner.setEditor(new JSpinner.NumberEditor(integratorRelSpinner,"0.0000000"));
-        
-        JLabel toleranceOnTimeLabel = new JLabel("Tolerance on time");
-        spinnerModel = new SpinnerNumberModel(diagram.getToleranceOnTime(),null,null,1.000E-11);
-        toleranceOnTimeSpinner = new JSpinner( );
-        toleranceOnTimeSpinner.setModel(spinnerModel);
-        toleranceOnTimeSpinner.setEditor(new JSpinner.NumberEditor(toleranceOnTimeSpinner,"0.000E00"));
-        
-        JLabel maxIntegrationTimeLabel = new JLabel("Max integration time interval");
-        spinnerModel = new SpinnerNumberModel(diagram.getMaxIntegrationTimeinterval(),null,null, 1);
-        maxIntegrationTimeSpinner = new JSpinner( );
-        maxIntegrationTimeSpinner.setModel(spinnerModel);
-        maxIntegrationTimeSpinner.setEditor(new JSpinner.NumberEditor(maxIntegrationTimeSpinner,"0"));
-        
-        JLabel solverLabel = new JLabel("Solver 0 (CVODE)/100 (IDA)");
-        spinnerModel = new SpinnerNumberModel(diagram.getSolver(),0,100, 1);
-        solverSpinner = new JSpinner( );
-        solverSpinner.setModel(spinnerModel);
-        solverSpinner.setEditor(new JSpinner.NumberEditor(solverSpinner,"0"));//0.####E0
-        
-        JLabel maxStepSizeLabel = new JLabel("maximum step size (0 means no limit)");
-        spinnerModel = new SpinnerNumberModel((int)diagram.getMaximumStepSize(),0,null, 1);
-        maxStepSizeSpinner = new JSpinner( );
-        maxStepSizeSpinner.setModel(spinnerModel);
-        maxStepSizeSpinner.setEditor(new JSpinner.NumberEditor(maxStepSizeSpinner,"0"));//0.####E0
-        
-        JButton cancelButton = new JButton("Cancel");
-        JButton okButton = new JButton("Ok");
-        JButton defaultButton = new JButton("Default");
-        okButton.setPreferredSize(cancelButton.getPreferredSize());
-
-        GridBagConstraints gbc = new GridBagConstraints();
-
-        gbc.gridx = gbc.gridy = 0;
-        gbc.gridheight = gbc.gridwidth = 1;
-        gbc.insets = new Insets(0, 10, 0, 0);
-
-
-
-
-        gbc.gridx = 0;
-        gbc.gridy = 4;
-        gbc.gridheight = gbc.gridwidth = 1;
-        gbc.fill = GridBagConstraints.NONE;
-        gbc.insets = new Insets(0, 10, 0, 0);
-        
-        
-        mainFrame.add( integrationLabel, gbc);
-        
-        gbc.gridy = 5;
-        mainFrame.add( rtsLabel , gbc);
-        
-        gbc.gridy = 6;
-        mainFrame.add( integratorAbsLabel , gbc);
-
-        gbc.gridy = 7;
-        mainFrame.add( integratorRelLabel , gbc);
-        
-        gbc.gridy = 8;
-        mainFrame.add( toleranceOnTimeLabel , gbc);
-        
-        gbc.gridy = 9;
-        mainFrame.add( maxIntegrationTimeLabel , gbc);
-       
-        gbc.gridy = 10;
-        mainFrame.add( solverLabel , gbc);
-        
-        gbc.gridy = 11;
-        mainFrame.add( maxStepSizeLabel , gbc);
-        
-        
-        gbc.gridx = 1;
-        gbc.gridy = 4;
-        gbc.gridwidth = GridBagConstraints.REMAINDER;
-        gbc.fill = GridBagConstraints.HORIZONTAL;
-        gbc.insets = new Insets(5, 10, 0, 10);
-        mainFrame.add(integrationSpinner, gbc);
-        
-        gbc.gridy = 5;
-        mainFrame.add( rtsSpinner , gbc);
-
-        gbc.gridy = 6;
-        mainFrame.add( integratorAbsSpinner , gbc);
-
-        gbc.gridy = 7;
-        mainFrame.add( integratorRelSpinner , gbc);
-        
-        gbc.gridy = 8;
-        mainFrame.add( toleranceOnTimeSpinner , gbc);
-        
-        gbc.gridy = 9;
-        mainFrame.add( maxIntegrationTimeSpinner , gbc);
-        
-        gbc.gridy = 10;
-        mainFrame.add( solverSpinner , gbc);
-        
-        gbc.gridy = 11;
-        mainFrame.add( maxStepSizeSpinner , gbc);
-
-
-        gbc.gridx = 1;
-        gbc.gridy = 13;
-        gbc.gridheight = gbc.gridwidth = 1;
-        gbc.weightx = 1.;
-        gbc.fill = GridBagConstraints.NONE;
-        gbc.insets = new Insets(5, 0, 10, 5);
-        mainFrame.add(cancelButton, gbc);
-
-
-        gbc.gridx = 2;
-        gbc.weightx = 0.;
-        gbc.insets = new Insets(5, 0, 10, 10);
-        mainFrame.add(okButton, gbc);
-        
-        gbc.gridx = 3;
-        gbc.weightx = 0.;
-        gbc.insets = new Insets(5, 0, 10, 10);
-        mainFrame.add(defaultButton, gbc);
-
-       
+               return createButton(XcosMessages.SETUP, null, new SetupAction(scilabGraph));
+       }
+
+       public static MenuItem setupMenu(ScilabGraph scilabGraph) {
+               return createMenu(XcosMessages.SETUP, null, new SetupAction(scilabGraph), null);
+       }
+
+       public void actionPerformed(ActionEvent e) {
+               setupBox(e);
+       }
+
+
+       public void setupBox (ActionEvent e) {
+
+               mainFrame = new JFrame();
+               mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+               mainFrame.setLayout(new GridBagLayout());
+
+               diagram = (XcosDiagram)getGraph(e);
+
+
+               JLabel integrationLabel = new JLabel("Final inegration time");
+               SpinnerNumberModel spinnerModel = new SpinnerNumberModel(diagram.getFinalIntegrationTime( ) ,null,null, 1);
+               integrationSpinner = new JSpinner( );
+               integrationSpinner.setModel(spinnerModel);
+               integrationSpinner.setEditor(new JSpinner.NumberEditor(integrationSpinner,"0"));
+
+               JLabel rtsLabel = new JLabel("Real time scaling");
+               spinnerModel = new SpinnerNumberModel(diagram.getRealTimeScaling() ,null,null, 0.0000001);
+               rtsSpinner = new JSpinner( );
+               rtsSpinner.setModel(spinnerModel);
+               rtsSpinner.setEditor(new JSpinner.NumberEditor(rtsSpinner,"0.00000000"));
+
+               JLabel integratorAbsLabel = new JLabel("Integrator absolute tolerance");
+               spinnerModel = new SpinnerNumberModel(diagram.getIntegratorAbsoluteTolerance(),null,null, 0.00001);
+               integratorAbsSpinner = new JSpinner( );
+               integratorAbsSpinner.setModel(spinnerModel);
+               integratorAbsSpinner.setEditor(new JSpinner.NumberEditor(integratorAbsSpinner,"0.00000"));
+
+               JLabel integratorRelLabel = new JLabel("Integrator relative tolerance");
+               spinnerModel = new SpinnerNumberModel(diagram.getIntegratorRelativeTolerance(),null,null, 0.0000001);
+               integratorRelSpinner = new JSpinner( );
+               integratorRelSpinner.setModel(spinnerModel);
+               integratorRelSpinner.setEditor(new JSpinner.NumberEditor(integratorRelSpinner,"0.0000000"));
+
+               JLabel toleranceOnTimeLabel = new JLabel("Tolerance on time");
+               spinnerModel = new SpinnerNumberModel(diagram.getToleranceOnTime(),null,null,1.000E-11);
+               toleranceOnTimeSpinner = new JSpinner( );
+               toleranceOnTimeSpinner.setModel(spinnerModel);
+               toleranceOnTimeSpinner.setEditor(new JSpinner.NumberEditor(toleranceOnTimeSpinner,"0.000E00"));
+
+               JLabel maxIntegrationTimeLabel = new JLabel("Max integration time interval");
+               spinnerModel = new SpinnerNumberModel(diagram.getMaxIntegrationTimeinterval(),null,null, 1);
+               maxIntegrationTimeSpinner = new JSpinner( );
+               maxIntegrationTimeSpinner.setModel(spinnerModel);
+               maxIntegrationTimeSpinner.setEditor(new JSpinner.NumberEditor(maxIntegrationTimeSpinner,"0"));
+
+               JLabel solverLabel = new JLabel("Solver 0 (CVODE)/100 (IDA)");
+               spinnerModel = new SpinnerNumberModel(diagram.getSolver(),0,100, 1);
+               solverSpinner = new JSpinner( );
+               solverSpinner.setModel(spinnerModel);
+               solverSpinner.setEditor(new JSpinner.NumberEditor(solverSpinner,"0"));//0.####E0
+
+               JLabel maxStepSizeLabel = new JLabel("maximum step size (0 means no limit)");
+               spinnerModel = new SpinnerNumberModel((int)diagram.getMaximumStepSize(),0,null, 1);
+               maxStepSizeSpinner = new JSpinner( );
+               maxStepSizeSpinner.setModel(spinnerModel);
+               maxStepSizeSpinner.setEditor(new JSpinner.NumberEditor(maxStepSizeSpinner,"0"));//0.####E0
+
+               JButton cancelButton = new JButton("Cancel");
+               JButton okButton = new JButton("Ok");
+               JButton defaultButton = new JButton("Default");
+               okButton.setPreferredSize(cancelButton.getPreferredSize());
+
+               GridBagConstraints gbc = new GridBagConstraints();
+
+               gbc.gridx = gbc.gridy = 0;
+               gbc.gridheight = gbc.gridwidth = 1;
+               gbc.insets = new Insets(0, 10, 0, 0);
+
+
+
+
+               gbc.gridx = 0;
+               gbc.gridy = 4;
+               gbc.gridheight = gbc.gridwidth = 1;
+               gbc.fill = GridBagConstraints.NONE;
+               gbc.insets = new Insets(0, 10, 0, 0);
+
+
+               mainFrame.add( integrationLabel, gbc);
+
+               gbc.gridy = 5;
+               mainFrame.add( rtsLabel , gbc);
+
+               gbc.gridy = 6;
+               mainFrame.add( integratorAbsLabel , gbc);
+
+               gbc.gridy = 7;
+               mainFrame.add( integratorRelLabel , gbc);
+
+               gbc.gridy = 8;
+               mainFrame.add( toleranceOnTimeLabel , gbc);
+
+               gbc.gridy = 9;
+               mainFrame.add( maxIntegrationTimeLabel , gbc);
+
+               gbc.gridy = 10;
+               mainFrame.add( solverLabel , gbc);
+
+               gbc.gridy = 11;
+               mainFrame.add( maxStepSizeLabel , gbc);
+
+
+               gbc.gridx = 1;
+               gbc.gridy = 4;
+               gbc.gridwidth = GridBagConstraints.REMAINDER;
+               gbc.fill = GridBagConstraints.HORIZONTAL;
+               gbc.insets = new Insets(5, 10, 0, 10);
+               mainFrame.add(integrationSpinner, gbc);
+
+               gbc.gridy = 5;
+               mainFrame.add( rtsSpinner , gbc);
+
+               gbc.gridy = 6;
+               mainFrame.add( integratorAbsSpinner , gbc);
+
+               gbc.gridy = 7;
+               mainFrame.add( integratorRelSpinner , gbc);
+
+               gbc.gridy = 8;
+               mainFrame.add( toleranceOnTimeSpinner , gbc);
+
+               gbc.gridy = 9;
+               mainFrame.add( maxIntegrationTimeSpinner , gbc);
+
+               gbc.gridy = 10;
+               mainFrame.add( solverSpinner , gbc);
+
+               gbc.gridy = 11;
+               mainFrame.add( maxStepSizeSpinner , gbc);
+
+
+               gbc.gridx = 1;
+               gbc.gridy = 13;
+               gbc.gridheight = gbc.gridwidth = 1;
+               gbc.weightx = 1.;
+               gbc.fill = GridBagConstraints.NONE;
+               gbc.insets = new Insets(5, 0, 10, 5);
+               mainFrame.add(cancelButton, gbc);
+
+
+               gbc.gridx = 2;
+               gbc.weightx = 0.;
+               gbc.insets = new Insets(5, 0, 10, 10);
+               mainFrame.add(okButton, gbc);
+
+               gbc.gridx = 3;
+               gbc.weightx = 0.;
+               gbc.insets = new Insets(5, 0, 10, 10);
+               mainFrame.add(defaultButton, gbc);
+
+
                cancelButton.addActionListener(new ActionListener() {
 
                        public void actionPerformed(ActionEvent e) {
@@ -248,7 +223,7 @@ public class SetupAction extends DefaultAction {
                                mainFrame.dispose();
                        }
                });
-               
+
                defaultButton.addActionListener(new ActionListener() {
 
                        public void actionPerformed(ActionEvent e) {
@@ -261,7 +236,7 @@ public class SetupAction extends DefaultAction {
                                maxIntegrationTimeSpinner.setValue(100001.0);
                                solverSpinner.setValue(0.0);
                                maxStepSizeSpinner.setValue(0.0);
-                               
+
                                diagram.setFinalIntegrationTime((Double)integrationSpinner.getValue() ) ;
                                diagram.setRealTimeScaling((Double)rtsSpinner.getValue())   ;
                                diagram.setIntegratorAbsoluteTolerance((Double)integratorAbsSpinner.getValue() );
@@ -272,16 +247,16 @@ public class SetupAction extends DefaultAction {
                                diagram.setMaximumStepSize( ((Double)maxStepSizeSpinner.getValue()).doubleValue())  ;
                        }
                });
-        
+
                okButton.addActionListener(new ActionListener() {
 
 
-                       
-                       
+
+
                        public void actionPerformed(ActionEvent e) {
-                               
-               
-                               
+
+
+
                                diagram.setFinalIntegrationTime((Double)integrationSpinner.getValue() ) ;
                                diagram.setRealTimeScaling((Double)rtsSpinner.getValue())   ;
                                diagram.setIntegratorAbsoluteTolerance((Double)integratorAbsSpinner.getValue() );
@@ -295,50 +270,50 @@ public class SetupAction extends DefaultAction {
                                mainFrame.dispose();
                        }
                });
-       
-        
+
+
                //display the frame and set some properties
-               
+
                mainFrame.addWindowListener( new WindowListener(){
                        public void windowClosed(WindowEvent arg0) {
                                // TODO Auto-generated method stub
-                               
+
                        }
                        public void windowDeiconified(WindowEvent arg0) {
                                // TODO Auto-generated method stub
-                               
+
                        }
                        public void windowActivated(WindowEvent arg0) {
                                // TODO Auto-generated method stub
-                               
+
                        }
                        public void windowClosing(WindowEvent arg0) {
                                SetupAction.windowAlreadyExist = false ;
                                mainFrame.dispose();
-                               
+
                        }
                        public void windowDeactivated(WindowEvent arg0) {
                                // TODO Auto-generated method stub
-                               
+
                        }
                        public void windowIconified(WindowEvent arg0) {
-                               
+
                        };
                        public void windowOpened(WindowEvent arg0) {
                                // TODO Auto-generated method stub
-                               
+
                        }
-                       
+
                } );
-               
-               
-       
-        mainFrame.setTitle("Set Parameters");
-        mainFrame.pack();
-        mainFrame.setLocationRelativeTo(null);
-        mainFrame.setVisible(true);    
-}
 
 
-                 
+
+               mainFrame.setTitle("Set Parameters");
+               mainFrame.pack();
+               mainFrame.setLocationRelativeTo(null);
+               mainFrame.setVisible(true);     
+       }
+
+
+
 }
index ba1ed43..af24f45 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
  * 
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
@@ -19,25 +20,23 @@ import org.scilab.modules.graph.ScilabGraph;
 import org.scilab.modules.graph.actions.DefaultAction;
 import org.scilab.modules.gui.menuitem.MenuItem;
 import org.scilab.modules.gui.pushbutton.PushButton;
+import org.scilab.modules.xcos.utils.XcosMessages;
 
 public class StopAction  extends DefaultAction {
-    public static PushButton stopButton(ScilabGraph scilabGraph) {
-       return createButton("Stop", null, new StopAction(scilabGraph));
-    }
-
-    public static MenuItem stopMenu(ScilabGraph scilabGraph) {
-       return createMenu("Stop", null, new StopAction(scilabGraph));
-    }
-
-    public StopAction() {
-       super();
-    }
-
-    public StopAction(ScilabGraph scilabGraph) {
-       super(scilabGraph);
-    }
-
-    public void actionPerformed(ActionEvent e) {
-       InterpreterManagement.requestScilabExec("haltscicos");
-    }
+       
+       public StopAction(ScilabGraph scilabGraph) {
+               super(XcosMessages.STOP, scilabGraph);
+       }
+
+       public static PushButton stopButton(ScilabGraph scilabGraph) {
+               return createButton(XcosMessages.STOP, null, new StopAction(scilabGraph));
+       }
+
+       public static MenuItem stopMenu(ScilabGraph scilabGraph) {
+               return createMenu(XcosMessages.STOP, null, new StopAction(scilabGraph), null);
+       }
+
+       public void actionPerformed(ActionEvent e) {
+               InterpreterManagement.requestScilabExec("haltscicos");
+       }
 }
index 94af315..fa99fb0 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
  * 
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
@@ -22,34 +23,32 @@ import org.scilab.modules.graph.actions.DefaultAction;
 import org.scilab.modules.gui.menuitem.MenuItem;
 import org.scilab.modules.gui.pushbutton.PushButton;
 import org.scilab.modules.xcos.XcosDiagram;
+import org.scilab.modules.xcos.utils.XcosMessages;
 
 public class ViewInScicosAction  extends DefaultAction {
-    public static PushButton viewInScicosButton(ScilabGraph scilabGraph) {
-       return createButton("View In Scicos", null, new ViewInScicosAction(scilabGraph));
-    }
-
-    public static MenuItem viewInScicosMenu(ScilabGraph scilabGraph) {
-       return createMenu("View In Scicos", null, new ViewInScicosAction(scilabGraph));
-    }
-
-    public ViewInScicosAction() {
-       super();
-    }
-
-    public ViewInScicosAction(ScilabGraph scilabGraph) {
-       super(scilabGraph);
-    }
-
-    public void actionPerformed(ActionEvent e) {
-       File temp;
-       try {
-           temp = File.createTempFile("xcos",".hdf5");
-           System.err.println("File = "+temp.getAbsolutePath());
-           ((XcosDiagram) getGraph(e)).dumpToHdf5File(temp.getAbsolutePath());
-           InterpreterManagement.requestScilabExec("import_from_hdf5(\""+temp.getAbsolutePath()+"\");scicos(scs_m);");
-           temp.deleteOnExit();
-       } catch (IOException e1) {
-           e1.printStackTrace();
+
+       public ViewInScicosAction(ScilabGraph scilabGraph) {
+               super(XcosMessages.VIEW_IN_SCICOS, scilabGraph);
+       }
+
+       public static PushButton viewInScicosButton(ScilabGraph scilabGraph) {
+               return createButton(XcosMessages.VIEW_IN_SCICOS, null, new ViewInScicosAction(scilabGraph));
+       }
+
+       public static MenuItem viewInScicosMenu(ScilabGraph scilabGraph) {
+               return createMenu(XcosMessages.VIEW_IN_SCICOS, null, new ViewInScicosAction(scilabGraph), null);
+       }
+
+       public void actionPerformed(ActionEvent e) {
+               File temp;
+               try {
+                       temp = File.createTempFile("xcos",".hdf5");
+                       System.err.println("File = "+temp.getAbsolutePath());
+                       ((XcosDiagram) getGraph(e)).dumpToHdf5File(temp.getAbsolutePath());
+                       InterpreterManagement.requestScilabExec("import_from_hdf5(\""+temp.getAbsolutePath()+"\");scicos(scs_m);");
+                       temp.deleteOnExit();
+               } catch (IOException e1) {
+                       e1.printStackTrace();
+               }
        }
-    }
 }
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/utils/XcosMessages.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/utils/XcosMessages.java
new file mode 100644 (file)
index 0000000..dc79edd
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
+ *
+ * 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.xcos.utils;
+
+import org.scilab.modules.localization.Messages;
+
+public class XcosMessages {
+       /** File menu */
+    public static final String FILE = Messages.gettext("File");
+    public static final String NEW = Messages.gettext("New") + "...";
+    public static final String OPEN = Messages.gettext("Open") + "...";
+    public static final String SAVE = Messages.gettext("Save") + "...";
+    
+    /** Edit Menu */
+    public static final String EDIT = Messages.gettext("Edit") + "...";
+    
+    /** Simulation menu */
+    public static final String SETUP = Messages.gettext("Setup");
+    public static final String RUN = Messages.gettext("Run");
+    public static final String STOP = Messages.gettext("Stop");
+    
+    
+    public static final String DUMP = Messages.gettext("Dump");
+    public static final String VIEW_IN_SCICOS = Messages.gettext("View in Scicos");
+   
+    
+    
+    public static final String SEARCH = Messages.gettext("Search");
+    public static final String VIEW = Messages.gettext("View");
+    public static final String DOCUMENT = Messages.gettext("Document");
+    public static final String EXECUTE = Messages.gettext("Execute");
+    public static final String SYNTAX_TYPE = Messages.gettext("Syntax Type");
+    public static final String ENCODING_TYPE = Messages.gettext("Encoding Type");
+    public static final String RECENT_FILES = Messages.gettext("Recent Files");
+    
+    public static final String FILE_DOESNT_EXIST = Messages.gettext( "This file doesn't exist\n Do you want to create it?");
+    public static final String CLOSE_TAB_TIP = Messages.gettext("close this tab");
+    public static final String FILE_MODIFIED = Messages.gettext("This file has been modified since last save\nsave it?");
+    public static final String REPLACE_FILE_TITLE = Messages.gettext("This file has been modified since last save\nsave it?");
+    public static final String FILE_ALREADY_EXIST = Messages.gettext("File already exists");
+    public static final String UNTITLED = Messages.gettext("Untitled ");
+
+}