All actions and menus activation
Bruno JOFRET [Thu, 30 Jul 2009 15:57:12 +0000 (17:57 +0200)]
39 files changed:
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/ASCIIEncodingAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/AboutAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/AutoIndentAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/ColorizeAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/CommentAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/CopyAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/CutAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/DefaultAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/DefaultCheckAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/DeleteAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/EvaluateSelectionAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/ExitAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/FindAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/FindNextAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/FindPreviousAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/GotoLineAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/HelpAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/IndentAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/LineNumbersAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/LoadIntoScilabAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/NewAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/OpenAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/PageSetupAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/PasteAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/PrintAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/PrintPreviewAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/RedoAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/SaveAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/SaveAsAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/ScilabStyleAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/SelectAllAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/SetColorsAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/ShowToolBarAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/TextStyleAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/UTF8EncodingAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/UnCommentAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/UndoAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/WordWrapAction.java [new file with mode: 0644]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/XMLStyleAction.java [new file with mode: 0644]

diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/ASCIIEncodingAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/ASCIIEncodingAction.java
new file mode 100644 (file)
index 0000000..6302daf
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class ASCIIEncodingAction extends DefaultCheckAction {
+
+    public ASCIIEncodingAction(Xpad editor) {
+       super("ASCII Encoding", editor);
+    }
+    
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/AboutAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/AboutAction.java
new file mode 100644 (file)
index 0000000..ab7864e
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class AboutAction extends DefaultAction {
+
+    public AboutAction(Xpad editor) {
+       super("About...", editor);
+    }
+
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/AutoIndentAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/AutoIndentAction.java
new file mode 100644 (file)
index 0000000..eae8398
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class AutoIndentAction extends DefaultCheckAction  {
+
+
+    public AutoIndentAction(Xpad editor) {
+       super("Auto Indent", editor);
+    }
+
+    public void doAction() {
+       getEditor().setAutoIndent(this.getState());
+    }
+
+
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/ColorizeAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/ColorizeAction.java
new file mode 100644 (file)
index 0000000..9053c7a
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+import org.scilab.modules.xpad.style.ScilabStyleDocument;
+
+public class ColorizeAction extends DefaultAction {
+
+       public ColorizeAction(Xpad editor) {
+               super("Colorize", editor);
+       }
+
+       public void doAction() {
+               ((ScilabStyleDocument) getEditor().getTextPane().getStyledDocument()).colorize();
+       }
+
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/CommentAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/CommentAction.java
new file mode 100644 (file)
index 0000000..846cf36
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class CommentAction extends DefaultAction {
+
+       public CommentAction(Xpad editor) {
+               super("Comment Selection", editor);
+       }
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/CopyAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/CopyAction.java
new file mode 100644 (file)
index 0000000..d6f96e2
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import javax.swing.text.DefaultEditorKit;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class CopyAction extends DefaultAction {
+
+    public CopyAction(Xpad editor) {
+       super("Copy", editor);
+       setMnemonic('c');
+    }
+    
+    public void doAction() {
+       getEditor().getTextPane().getActionMap().get(DefaultEditorKit.copyAction).actionPerformed(null);
+    }
+
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/CutAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/CutAction.java
new file mode 100644 (file)
index 0000000..571ba25
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import javax.swing.text.DefaultEditorKit;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class CutAction extends DefaultAction {
+
+    public CutAction(Xpad editor) {
+       super("Cut", editor);
+       setMnemonic('c');
+    }
+    
+    public void doAction() {
+       getEditor().getTextPane().getActionMap().get(DefaultEditorKit.cutAction).actionPerformed(null);
+    }
+
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/DefaultAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/DefaultAction.java
new file mode 100644 (file)
index 0000000..e76fa6a
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.JOptionPane;
+
+import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem;
+import org.scilab.modules.gui.events.callback.CallBack;
+import org.scilab.modules.gui.menuitem.MenuItem;
+import org.scilab.modules.gui.menuitem.SimpleMenuItem;
+import org.scilab.modules.xpad.Xpad;
+
+public class DefaultAction extends SwingScilabMenuItem implements MenuItem {
+    private Xpad _editor;
+
+    public DefaultAction(Xpad editor) {
+       super();
+       setText("Default...");
+       _editor = editor;
+       setCallback(new CallBack("Default...") {
+
+           public void callBack() {
+               doAction();
+           }
+
+           public void actionPerformed(ActionEvent e) {
+               callBack();
+           } 
+       });
+    }
+
+    protected DefaultAction(String label, Xpad editor) {
+       super();
+       setText(label);
+       _editor = editor;
+       setCallback(new CallBack("Default...") {
+           public void callBack() {
+               doAction();
+           }
+
+           public void actionPerformed(ActionEvent e) {
+               callBack();
+           } 
+       });
+    }
+
+    public Xpad getEditor() {
+       return _editor;
+    }
+
+    public SimpleMenuItem getAsSimpleMenuItem() {
+       return (SwingScilabMenuItem) this;
+    }
+
+    public void doAction() {
+         JOptionPane.showMessageDialog(getEditor(), "Not Implemented Now !!!", null, JOptionPane.ERROR_MESSAGE);
+    }
+
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/DefaultCheckAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/DefaultCheckAction.java
new file mode 100644 (file)
index 0000000..98afa5e
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.JOptionPane;
+
+import org.scilab.modules.gui.bridge.checkboxmenuitem.SwingScilabCheckBoxMenuItem;
+import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem;
+import org.scilab.modules.gui.checkboxmenuitem.SimpleCheckBoxMenuItem;
+import org.scilab.modules.gui.events.callback.CallBack;
+import org.scilab.modules.gui.menuitem.SimpleMenuItem;
+import org.scilab.modules.xpad.Xpad;
+
+public class DefaultCheckAction extends SwingScilabCheckBoxMenuItem implements CheckBoxMenuItem {
+    private Xpad _editor;
+
+    public DefaultCheckAction(Xpad editor) {
+       super();
+       setText("Default...");
+       setState(true);
+       _editor = editor;
+       setCallback(new CallBack("Default...") {
+
+           public void callBack() {
+               doAction();
+           }
+
+           public void actionPerformed(ActionEvent e) {
+               callBack();
+           } 
+       });
+    }
+
+    protected DefaultCheckAction(String label, Xpad editor) {
+       super();
+       setText(label);
+       setState(true);
+       _editor = editor;
+       setCallback(new CallBack("Default...") {
+           public void callBack() {
+               doAction();
+           }
+
+           public void actionPerformed(ActionEvent e) {
+               callBack();
+           } 
+       });
+    }
+
+    public Xpad getEditor() {
+       return _editor;
+    }
+
+    public SimpleCheckBoxMenuItem getAsSimpleCheckBoxMenuItem() {
+       return (SwingScilabCheckBoxMenuItem) this;
+    }
+
+    public SimpleMenuItem getAsSimpleMenuItem() {
+       return null;
+    }
+
+    public void doAction() {
+         JOptionPane.showMessageDialog(getEditor(), "Not Implemented Now !!! (state = "+getState()+")", null, JOptionPane.ERROR_MESSAGE);
+    }
+
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/DeleteAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/DeleteAction.java
new file mode 100644 (file)
index 0000000..3afbbb5
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import javax.swing.text.DefaultEditorKit;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class DeleteAction extends DefaultAction {
+
+    public DeleteAction(Xpad editor) {
+       super("Delete", editor);
+    }
+    
+    public void doAction() {
+       getEditor().getTextPane().getActionMap().get(DefaultEditorKit.deleteNextCharAction).actionPerformed(null);
+    }
+
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/EvaluateSelectionAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/EvaluateSelectionAction.java
new file mode 100644 (file)
index 0000000..850ffa5
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.action_binding.InterpreterManagement;
+import org.scilab.modules.gui.console.ScilabConsole;
+import org.scilab.modules.xpad.Xpad;
+
+
+public class EvaluateSelectionAction extends DefaultAction {
+
+       public EvaluateSelectionAction(Xpad editor) {
+               super("Evaluate Selection", editor);
+       }
+
+       public void doAction() {
+           /* Will do the job as if it was copy / paste in scilab Console */
+           //InterpreterManagement.requestScilabExec(getEditor().getTextPane().getText());
+           ScilabConsole.getConsole().getAsSimpleConsole().sendCommandsToScilab(getEditor().getTextPane().getSelectedText(), true, false);
+       }
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/ExitAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/ExitAction.java
new file mode 100644 (file)
index 0000000..45590ab
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+
+import org.scilab.modules.xpad.Xpad;
+
+public class ExitAction extends DefaultAction {
+    
+    public ExitAction(Xpad editor) {
+        super("Exit", editor);
+        setMnemonic('X');
+    }
+    
+    public void doAction() {
+       getEditor().getParentWindow().getAsSimpleWindow().close();
+    }
+}
\ No newline at end of file
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/FindAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/FindAction.java
new file mode 100644 (file)
index 0000000..a197456
--- /dev/null
@@ -0,0 +1,288 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Sylvestre KOUMAR
+ *
+ * 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.xpad.actions;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Vector;
+
+import javax.swing.BorderFactory;
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JTextField;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.DefaultHighlighter;
+import javax.swing.text.Highlighter;
+
+import org.scilab.modules.xpad.Xpad;
+import org.scilab.modules.xpad.style.ScilabStyleDocument;
+
+public class FindAction extends DefaultAction {
+
+       private JFrame frame;
+       private JTextField textfieldFind;
+       private JTextField textfieldReplace;
+       private JRadioButton buttonForward;
+       private JRadioButton buttonBackward;
+       private JRadioButton buttonAll;
+       private JRadioButton buttonSelection;
+       private ButtonGroup groupDirection;
+       private ButtonGroup groupScope;
+       private JCheckBox caseSensitive;
+       private JCheckBox wrap;
+       private JCheckBox wholeWord;
+       private JCheckBox regularExp;
+       private JButton buttonFind;
+       private JButton buttonReplaceFind;
+       private JButton buttonReplace;
+       private JButton buttonReplaceAll;
+       private JButton buttonClose;
+
+       private String oldword;
+       private String newWord;
+
+       private String wordToFind;
+
+
+       public FindAction(Xpad editor) {
+               super("Find/Replace...", editor);
+               setMnemonic('F');
+       }
+
+       public void doAction() {
+
+               findReplaceBox();
+       }
+
+       public void findReplaceBox() {
+
+               //Find & Replace Frame
+               frame = new JFrame();
+               frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+               frame.setPreferredSize(new Dimension(300, 600));
+               frame.setTitle("Find/Replace");
+               frame.pack();
+               frame.setLocationRelativeTo(null);
+               frame.setVisible(true);         
+               JPanel panel = new JPanel();
+               panel.setLayout(new GridBagLayout());
+               frame.setContentPane(panel);
+
+               JPanel direction = new JPanel();
+               direction.setLayout(new GridBagLayout());
+               JPanel scope = new JPanel();
+               scope.setLayout(new GridBagLayout());
+               JPanel options = new JPanel();
+               options.setLayout(new GridBagLayout());
+
+               GridBagConstraints gbc = new GridBagConstraints();
+               gbc.anchor = GridBagConstraints.WEST;           
+               gbc.insets = new Insets(10,5,10,5);
+
+               //Find & Replace label, text field
+               JLabel labelFind = new JLabel("Find :");
+               JLabel labelReplace = new JLabel("Replace with :");
+               textfieldFind = new JTextField();
+               textfieldFind.setPreferredSize(new Dimension(150, 20));
+               textfieldReplace = new JTextField();
+               textfieldReplace.setPreferredSize(new Dimension(150, 20));
+
+               panel.add(labelFind, gbc);
+               gbc.gridwidth = GridBagConstraints.REMAINDER;
+               panel.add(textfieldFind, gbc);
+               gbc.gridwidth = 1;
+
+               panel.add(labelReplace, gbc);
+               gbc.gridwidth = GridBagConstraints.REMAINDER;
+               panel.add(textfieldReplace, gbc);
+               gbc.gridwidth = 1;
+
+               panel.add(direction, gbc);
+               gbc.gridwidth = GridBagConstraints.REMAINDER;
+               panel.add(scope, gbc);
+               gbc.gridwidth = 1;
+               gbc.gridwidth = GridBagConstraints.REMAINDER;
+               panel.add(options, gbc);
+
+               //Find & Replace direction
+               direction.setBorder(BorderFactory.createTitledBorder("Direction"));
+
+               buttonForward = new JRadioButton("Forward");
+               buttonBackward = new JRadioButton("Backward");
+
+               groupDirection = new ButtonGroup();
+               groupDirection.add(buttonForward);
+               groupDirection.add(buttonBackward);
+               buttonForward.setSelected(true);
+
+               gbc.gridwidth = GridBagConstraints.REMAINDER;
+               direction.add(buttonForward, gbc);
+               gbc.gridwidth = 1;
+
+               gbc.gridwidth = GridBagConstraints.REMAINDER;
+               direction.add(buttonBackward, gbc);
+               gbc.gridwidth = 1;
+
+               //Find & Replace scope
+               scope.setBorder(BorderFactory.createTitledBorder("Scope"));
+
+               buttonAll = new JRadioButton("All");
+               buttonSelection = new JRadioButton("Selected lines");
+
+               groupScope = new ButtonGroup();
+               groupScope.add(buttonAll);
+               groupScope.add(buttonSelection);
+               buttonAll.setSelected(true);
+
+               gbc.gridwidth = GridBagConstraints.REMAINDER;
+               scope.add(buttonAll, gbc);
+               gbc.gridwidth = 1;
+
+               gbc.gridwidth = GridBagConstraints.REMAINDER;
+               scope.add(buttonSelection, gbc);
+               gbc.gridwidth = 1;
+
+               //Find & Replace options
+               options.setBorder(BorderFactory.createTitledBorder("Options"));
+
+               caseSensitive = new JCheckBox("Case sensitive");
+               wrap = new JCheckBox("Wrap search");
+               wholeWord = new JCheckBox("Whole word");
+               regularExp = new JCheckBox("Regular expressions");
+
+               gbc.anchor = GridBagConstraints.WEST;
+
+               gbc.gridwidth = GridBagConstraints.REMAINDER;
+               options.add(caseSensitive, gbc);
+               options.add(wrap, gbc);
+               gbc.gridwidth = GridBagConstraints.REMAINDER;
+               options.add(wholeWord, gbc);
+               options.add(regularExp, gbc);
+
+               //Find & Replace buttons
+               buttonFind = new JButton("Find");
+               buttonReplaceFind = new JButton("Replace/Find");
+               buttonReplace = new JButton("Replace");
+               buttonReplaceAll = new JButton("Replace All");
+               buttonClose = new JButton("Close");
+
+               buttonFind.setPreferredSize(buttonReplaceFind.getPreferredSize());
+               buttonReplace.setPreferredSize(buttonReplaceFind.getPreferredSize());
+               buttonReplaceAll.setPreferredSize(buttonReplaceFind.getPreferredSize());
+               buttonClose.setPreferredSize(buttonReplaceFind.getPreferredSize());
+
+               gbc.gridwidth = 1;
+               panel.add(buttonFind, gbc);
+               gbc.gridwidth = GridBagConstraints.REMAINDER;
+               panel.add(buttonReplaceFind, gbc);
+               gbc.gridwidth = 1;
+
+               panel.add(buttonReplace, gbc);
+               gbc.gridwidth = GridBagConstraints.REMAINDER;
+               panel.add(buttonReplaceAll, gbc);
+               gbc.gridwidth = 1;
+
+               gbc.anchor = GridBagConstraints.EAST;
+
+               gbc.gridwidth = GridBagConstraints.REMAINDER;
+               panel.add(buttonClose, gbc);
+
+
+               buttonFind.addActionListener(new ActionListener() {
+                       int click = 0;
+                       Vector<Integer> offsets;
+
+                       public void actionPerformed(ActionEvent e) {
+
+                               //Get the word we have to find
+                               wordToFind = textfieldFind.getText();
+
+                               //Find all matching words and return their starting position into a vector
+                               offsets = ((ScilabStyleDocument) getEditor().getTextPane().getStyledDocument()).findWord(wordToFind);
+
+                               Highlighter highlight = getEditor().getTextPane().getHighlighter();
+                               highlight.removeAllHighlights();
+
+                               //Here we highlight all the matching words
+                               for (int i = 0; i < offsets.size(); i++) {
+                                       try {
+                                               highlight.addHighlight(offsets.elementAt(i), offsets.elementAt(i)+wordToFind.length(), new DefaultHighlighter.DefaultHighlightPainter(Color.green));
+                                       } catch (BadLocationException e1) {
+                                               e1.printStackTrace();
+                                       }
+                               }
+
+                               //Here we highlight matching word one by one
+                               if (click == offsets.size()) {
+                                       System.out.println("You have reached the end of the document");
+                                       click = 0;
+                               }
+
+                               boolean changeHighlight = false;
+                               Highlighter.Highlight myHighlight = null;
+                               Highlighter.Highlight[] highlights = getEditor().getTextPane().getHighlighter().getHighlights();
+
+                               for(int i=0; i < highlights.length; i++) {
+                                       myHighlight = highlights[i];
+                                       //Should equal zero
+                                       if(myHighlight.getStartOffset() == offsets.elementAt(click)) {
+                                               changeHighlight = true;
+                                               break;
+                                       }
+                               }
+
+                               if(changeHighlight) {
+                                       Highlighter hl = getEditor().getTextPane().getHighlighter();
+                                       try {
+                                               Xpad editor = getEditor();
+                                               editor.getTextPane().setCaretPosition(offsets.elementAt(click));
+                                               editor.getTextPane().select(offsets.elementAt(click), offsets.elementAt(click)+wordToFind.length());
+                                               highlight.addHighlight(offsets.elementAt(click), offsets.elementAt(click)+wordToFind.length(), DefaultHighlighter.DefaultPainter);
+                                               hl.changeHighlight(myHighlight, myHighlight.getStartOffset()+wordToFind.length(), myHighlight.getEndOffset());
+                                       } catch (BadLocationException e1) {
+                                               e1.printStackTrace();
+                                       }
+                               }
+                               click++;
+                       }
+               });
+
+               buttonReplaceAll.addActionListener(new ActionListener() {
+                       public void actionPerformed(ActionEvent e) {
+                               oldword = textfieldFind.getText();
+                               newWord = textfieldReplace.getText();
+
+                               //Call replace
+                               
+                       }
+               });
+
+               buttonClose.addActionListener(new ActionListener() {
+
+                       public void actionPerformed(ActionEvent e) {
+                               frame.dispose();
+                       }
+               });
+       }
+
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/FindNextAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/FindNextAction.java
new file mode 100644 (file)
index 0000000..0099541
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class FindNextAction extends DefaultAction {
+
+    public FindNextAction(Xpad editor) {
+       super("Find Next...", editor);
+    }
+    
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/FindPreviousAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/FindPreviousAction.java
new file mode 100644 (file)
index 0000000..ab7da93
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class FindPreviousAction extends DefaultAction {
+
+    public FindPreviousAction(Xpad editor) {
+       super("Find Previous...", editor);
+    }
+    
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/GotoLineAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/GotoLineAction.java
new file mode 100644 (file)
index 0000000..9e57e58
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class GotoLineAction extends DefaultAction {
+
+       public GotoLineAction(Xpad editor) {
+               super("Goto Line...", editor);
+       }
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/HelpAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/HelpAction.java
new file mode 100644 (file)
index 0000000..88ac0f5
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.action_binding.InterpreterManagement;
+import org.scilab.modules.xpad.Xpad;
+
+public class HelpAction extends DefaultAction {
+
+    public HelpAction(Xpad editor) {
+       super("Help...", editor);
+    }
+    
+    public void doAction() {
+       InterpreterManagement.requestScilabExec("help('xpad')");
+    }
+
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/IndentAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/IndentAction.java
new file mode 100644 (file)
index 0000000..c937cce
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+import org.scilab.modules.xpad.style.ScilabStyleDocument;
+
+public class IndentAction extends DefaultAction {
+       
+       public IndentAction(Xpad editor) {
+               super("Indent", editor);
+       }
+       
+       public void doAction() {
+               
+               int start = getEditor().getTextPane().getSelectionStart();
+               int end = getEditor().getTextPane().getSelectionEnd();
+               ((ScilabStyleDocument) getEditor().getTextPane().getStyledDocument()).indent(start, end);
+               getEditor().getTextPane().setSelectionStart(start);
+               getEditor().getTextPane().setSelectionEnd(getEditor().getTextPane().getCaretPosition());
+               //((ScilabStyleDocument) _editor.getStyledDocument()).indent();
+       }
+
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/LineNumbersAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/LineNumbersAction.java
new file mode 100644 (file)
index 0000000..a633d43
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class LineNumbersAction extends DefaultCheckAction {
+
+    public LineNumbersAction(Xpad editor) {
+       super("Line Numbers", editor);
+    }
+    
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/LoadIntoScilabAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/LoadIntoScilabAction.java
new file mode 100644 (file)
index 0000000..45e78d5
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.gui.console.ScilabConsole;
+import org.scilab.modules.xpad.Xpad;
+
+public class LoadIntoScilabAction extends DefaultAction {
+
+       public LoadIntoScilabAction(Xpad editor) {
+               super("Load Into Scilab", editor);
+       }
+
+       public void doAction() {
+           /* Will do the job as if it was copy / paste in scilab Console */
+           //InterpreterManagement.requestScilabExec(getEditor().getTextPane().getText());
+           ScilabConsole.getConsole().getAsSimpleConsole().sendCommandsToScilab(getEditor().getTextPane().getText(), true, false);
+       }
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/NewAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/NewAction.java
new file mode 100644 (file)
index 0000000..7ab66e2
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class NewAction extends DefaultAction {
+
+       public NewAction(Xpad editor) {
+               super("New...", editor);
+       }
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/OpenAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/OpenAction.java
new file mode 100644 (file)
index 0000000..173fcdc
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import java.io.File;
+
+import javax.swing.JFileChooser;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class OpenAction extends DefaultAction {
+
+    public OpenAction(Xpad editor) {
+       super("Open...", editor);
+       setMnemonic('O');
+    }
+
+    public void doAction() {
+       JFileChooser _fileChooser = new JFileChooser();
+       int retval = _fileChooser.showOpenDialog(getEditor());
+       if (retval == JFileChooser.APPROVE_OPTION) {
+           File f = _fileChooser.getSelectedFile();
+           getEditor().readFile(f);
+       }
+    }
+
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/PageSetupAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/PageSetupAction.java
new file mode 100644 (file)
index 0000000..8fffdf1
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class PageSetupAction extends DefaultAction {
+
+       public PageSetupAction(Xpad editor) {
+               super("Page Setup...", editor);
+       }
+
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/PasteAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/PasteAction.java
new file mode 100644 (file)
index 0000000..2a0525e
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import javax.swing.text.DefaultEditorKit;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class PasteAction extends DefaultAction {
+
+    public PasteAction(Xpad editor) {
+       super("Paste", editor);
+       setMnemonic('c');
+    }
+    
+    public void doAction() {
+       getEditor().getTextPane().getActionMap().get(DefaultEditorKit.pasteAction).actionPerformed(null);
+    }
+
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/PrintAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/PrintAction.java
new file mode 100644 (file)
index 0000000..f4bcfc8
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class PrintAction extends DefaultAction {
+
+       public PrintAction(Xpad editor) {
+               super("Print...", editor);
+       }
+
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/PrintPreviewAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/PrintPreviewAction.java
new file mode 100644 (file)
index 0000000..0a96558
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class PrintPreviewAction extends DefaultAction {
+
+    public PrintPreviewAction(Xpad editor) {
+       super("Print Preview...", editor);
+    }
+    
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/RedoAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/RedoAction.java
new file mode 100644 (file)
index 0000000..ceddd5d
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class RedoAction extends DefaultAction {
+
+       public RedoAction(Xpad editor) {
+               super("Redo", editor);
+       }
+
+       public void doAction() {
+               getEditor().redo();
+       }
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/SaveAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/SaveAction.java
new file mode 100644 (file)
index 0000000..e027f76
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import java.io.File;
+import java.io.FileWriter;
+
+import javax.swing.JFileChooser;
+import javax.swing.JOptionPane;
+import javax.swing.JTextPane;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+import javax.swing.text.StyleConstants;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class SaveAction extends DefaultAction {
+
+       public SaveAction(Xpad editor) {
+               super("Save", editor);
+               setMnemonic('S');
+       }
+
+       public void doAction() {
+               JFileChooser _fileChooser = new JFileChooser();
+               int retval = _fileChooser.showSaveDialog(getEditor());
+               if (retval == JFileChooser.APPROVE_OPTION) {
+                       File f = _fileChooser.getSelectedFile();
+                       try {
+
+                               String doc = getIndentedText(getEditor().getTextPane());
+
+                               FileWriter writer = new FileWriter(f);
+                               writer.write(doc);
+                               writer.flush();
+                               writer.close();
+
+                       } catch (Exception ioex) {
+                           JOptionPane.showMessageDialog(getEditor(), ioex);
+                       }
+               }
+       }
+
+       public String getIndentedText(JTextPane ed) {
+               
+               int startOffset;
+               int endOffset;
+               double indent;
+               String textLine = "";
+               
+               Document doc = ed.getStyledDocument();
+               String text = "";
+               String space = "";
+
+               for (int i = 0; i < doc.getLength(); ) {
+
+                       startOffset = ed.getStyledDocument().getParagraphElement(i).getStartOffset();
+                       endOffset = ed.getStyledDocument().getParagraphElement(i).getEndOffset();
+                       String ind = ed.getStyledDocument().getParagraphElement(i).getAttributes().getAttribute(StyleConstants.LeftIndent).toString();
+                       indent = Double.parseDouble(ind);
+
+                       try {
+                               textLine = ed.getStyledDocument().getText(startOffset, endOffset - startOffset);
+                       } catch (BadLocationException e) {
+                               e.printStackTrace();
+                       }
+
+                       for (int j = 0; j < indent; j=j+10) {
+                               if (indent == 0) {
+                                       space = "";
+                               } else {
+                                       space += " ";
+                               }
+                       }
+
+                       text += space + textLine;
+
+                       space = "";
+                       i = endOffset;
+               }       
+               return text;            
+       }
+
+}
\ No newline at end of file
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/SaveAsAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/SaveAsAction.java
new file mode 100644 (file)
index 0000000..103444b
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class SaveAsAction extends DefaultAction {
+
+       public SaveAsAction(Xpad editor) {
+               super("Save As...", editor);
+       }
+
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/ScilabStyleAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/ScilabStyleAction.java
new file mode 100644 (file)
index 0000000..5261216
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class ScilabStyleAction extends DefaultCheckAction {
+
+    public ScilabStyleAction(Xpad editor) {
+       super("Scilab", editor);
+    }
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/SelectAllAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/SelectAllAction.java
new file mode 100644 (file)
index 0000000..cfebcc9
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import javax.swing.text.DefaultEditorKit;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class SelectAllAction extends DefaultAction {
+
+    public SelectAllAction(Xpad editor) {
+       super("Select All", editor);
+    }
+    
+    public void doAction() {
+       getEditor().getTextPane().getActionMap().get(DefaultEditorKit.selectAllAction).actionPerformed(null);
+    }
+
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/SetColorsAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/SetColorsAction.java
new file mode 100644 (file)
index 0000000..bd22b16
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class SetColorsAction extends DefaultAction {
+
+    public SetColorsAction(Xpad editor) {
+       super("Set Colors...", editor);
+    }
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/ShowToolBarAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/ShowToolBarAction.java
new file mode 100644 (file)
index 0000000..9bc2242
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class ShowToolBarAction extends DefaultCheckAction {
+
+    public ShowToolBarAction(Xpad editor) {
+       super("Show/Hide ToolBar", editor);
+    }
+    
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/TextStyleAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/TextStyleAction.java
new file mode 100644 (file)
index 0000000..ec74abb
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class TextStyleAction extends DefaultCheckAction {
+
+    public TextStyleAction(Xpad editor) {
+       super("Plain Text", editor);
+    }
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/UTF8EncodingAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/UTF8EncodingAction.java
new file mode 100644 (file)
index 0000000..7d65774
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class UTF8EncodingAction extends DefaultCheckAction {
+
+    public UTF8EncodingAction(Xpad editor) {
+       super("UTF-8 Encoding", editor);
+    }
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/UnCommentAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/UnCommentAction.java
new file mode 100644 (file)
index 0000000..958f8bc
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class UnCommentAction extends DefaultAction {
+
+       public UnCommentAction(Xpad editor) {
+               super("Uncomment Selection", editor);
+       }
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/UndoAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/UndoAction.java
new file mode 100644 (file)
index 0000000..3363383
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class UndoAction extends DefaultAction {
+
+       public UndoAction(Xpad editor) {
+               super("Undo", editor);
+       }
+
+       public void doAction() {
+               getEditor().undo();
+       }
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/WordWrapAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/WordWrapAction.java
new file mode 100644 (file)
index 0000000..3cac440
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class WordWrapAction extends DefaultCheckAction {
+    
+    public WordWrapAction(Xpad editor) {
+       super("Word Wrap", editor);
+    }
+    
+}
diff --git a/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/XMLStyleAction.java b/scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/XMLStyleAction.java
new file mode 100644 (file)
index 0000000..46caa26
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ *
+ * 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.xpad.actions;
+
+import org.scilab.modules.xpad.Xpad;
+
+public class XMLStyleAction extends DefaultCheckAction {
+
+    public XMLStyleAction(Xpad editor) {
+       super("XML", editor);
+    }
+}