Author: echatellier Date: 2009-10-15 14:16:19 +0200 (Thu, 15 Oct 2009) New Revision: 227 Modified: trunk/src/main/java/org/nuiton/widget/editor/DefaultEditor.java trunk/src/main/java/org/nuiton/widget/editor/Editor.java trunk/src/main/java/org/nuiton/widget/editor/EditorInterface.java trunk/src/main/java/org/nuiton/widget/editor/JEditEditor.java trunk/src/main/java/org/nuiton/widget/editor/NullEditor.java trunk/src/main/java/org/nuiton/widget/editor/RSyntaxEditor.java Log: Add copy,cut,paste on all editors Modified: trunk/src/main/java/org/nuiton/widget/editor/DefaultEditor.java =================================================================== --- trunk/src/main/java/org/nuiton/widget/editor/DefaultEditor.java 2009-10-11 11:27:29 UTC (rev 226) +++ trunk/src/main/java/org/nuiton/widget/editor/DefaultEditor.java 2009-10-15 12:16:19 UTC (rev 227) @@ -178,43 +178,56 @@ } /* - * (non-Javadoc) - * - * @see - * org.codelutin.widget.editor.EditorInterface#setText(java.lang.String) + * @see org.codelutin.widget.editor.EditorInterface#setText(java.lang.String) */ public void setText(String text) { editor.setText(text); } /* - * (non-Javadoc) - * - * @seejavax.swing.event.DocumentListener#insertUpdate(javax.swing.event. - * DocumentEvent) + * @seejavax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent) */ public void insertUpdate(DocumentEvent e) { isModified = true; } /* - * (non-Javadoc) - * - * @seejavax.swing.event.DocumentListener#removeUpdate(javax.swing.event. - * DocumentEvent) + * @seejavax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent) */ + @Override public void removeUpdate(DocumentEvent e) { isModified = true; } /* - * (non-Javadoc) - * - * @seejavax.swing.event.DocumentListener#changedUpdate(javax.swing.event. - * DocumentEvent) + * @seejavax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent) */ + @Override public void changedUpdate(DocumentEvent e) { isModified = true; } + /* + * @see org.nuiton.widget.editor.EditorInterface#copy() + */ + @Override + public void copy() { + editor.copy(); + } + + /* + * @see org.nuiton.widget.editor.EditorInterface#cut() + */ + @Override + public void cut() { + editor.cut(); + } + + /* + * @see org.nuiton.widget.editor.EditorInterface#paste() + */ + @Override + public void paste() { + editor.paste(); + } } Modified: trunk/src/main/java/org/nuiton/widget/editor/Editor.java =================================================================== --- trunk/src/main/java/org/nuiton/widget/editor/Editor.java 2009-10-11 11:27:29 UTC (rev 226) +++ trunk/src/main/java/org/nuiton/widget/editor/Editor.java 2009-10-15 12:16:19 UTC (rev 227) @@ -367,12 +367,6 @@ return result; } - // ///////////////////////////////////////////////////////////////////////// - // - // EditorInterface method implementation - // - // ///////////////////////////////////////////////////////////////////////// - /** * if return true, this editor support this file type. Default implantation * return true @@ -450,24 +444,41 @@ } /* - * (non-Javadoc) - * - * @see - * org.codelutin.widget.editor.EditorInterface#addDocumentListener(javax - * .swing.event.DocumentListener) + * @see org.nuiton.widget.editor.EditorInterface#copy() */ + @Override + public void copy() { + currentEditor.copy(); + } + + /* + * @see org.nuiton.widget.editor.EditorInterface#cut() + */ + @Override + public void cut() { + currentEditor.cut(); + } + + /* + * @see org.nuiton.widget.editor.EditorInterface#paste() + */ + @Override + public void paste() { + currentEditor.paste(); + } + + /* + * @see org.codelutin.widget.editor.EditorInterface#addDocumentListener(javax.swing.event.DocumentListener) + */ public void addDocumentListener(DocumentListener listener) { listeners.add(listener); getCurrentEditor().addDocumentListener(listener); } /* - * (non-Javadoc) - * - * @see - * org.codelutin.widget.editor.EditorInterface#removeDocumentListener(javax - * .swing.event.DocumentListener) + * @see org.codelutin.widget.editor.EditorInterface#removeDocumentListener(javax.swing.event.DocumentListener) */ + @Override public void removeDocumentListener(DocumentListener listener) { listeners.remove(listener); getCurrentEditor().removeDocumentListener(listener); @@ -508,5 +519,4 @@ } } } - } Modified: trunk/src/main/java/org/nuiton/widget/editor/EditorInterface.java =================================================================== --- trunk/src/main/java/org/nuiton/widget/editor/EditorInterface.java 2009-10-11 11:27:29 UTC (rev 226) +++ trunk/src/main/java/org/nuiton/widget/editor/EditorInterface.java 2009-10-15 12:16:19 UTC (rev 227) @@ -1,5 +1,5 @@ /* *##% Graphical Widget - * Copyright (C) 2004 - 2008 CodeLutin + * Copyright (C) 2004 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -15,18 +15,6 @@ * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ -/* * - * EditorInterface.java - * - * Created: 6 août 2006 12:54:19 - * - * @author poussin - * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ - */ - package org.nuiton.widget.editor; import java.io.File; @@ -34,39 +22,47 @@ import javax.swing.event.DocumentListener; /** + * EditorInterface. + * * @author poussin * + * Created: 6 août 2006 12:54:19 + * + * @author poussin + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author$ */ - public interface EditorInterface { /** - * Add listener + * Add document listener. * - * @param listener + * @param listener listener */ public void addDocumentListener(DocumentListener listener); /** - * Remove listener + * Remove document listener. * - * @param listener + * @param listener listener */ public void removeDocumentListener(DocumentListener listener); /** - * if return true, this editor support this file type. Default implantation - * return true + * If return true, this editor support this file type. + * Default implementation return {@code true}. * - * @param file - * @return if return true, this editor support this file type. + * @param file file to test + * @return if return {@code true}, this editor support this file type. */ public boolean accept(File file); /** - * indicate if current opened file has been modified + * Indicate if current opened file has been modified. * - * @return true if currend file is modified + * @return {@code true} if current file is modified */ public boolean isModified(); @@ -79,7 +75,7 @@ public boolean open(File file); /** - * Replace the current edited file by file passed in argument + * Replace the current edited file by file passed in argument. * * @param file the file to open * @return true if file has been saved and reopen with new name @@ -87,16 +83,31 @@ public boolean saveAs(File file); /** - * Return the current content text of the editor as String + * Return the current content text of the editor as {@link String}. * - * @return Return the current content text of the editor as String + * @return return the current content text of the editor as {@link String} */ public String getText(); /** - * Set all text with text in argument + * Set all text with text in argument. * * @param text test to set */ public void setText(String text); + + /** + * Cut current editor selection into system clipboard. + */ + public void cut(); + + /** + * Copy current current selection into system clipboard. + */ + public void copy(); + + /** + * Paste current clicboard content into editor at caret position. + */ + public void paste(); } Modified: trunk/src/main/java/org/nuiton/widget/editor/JEditEditor.java =================================================================== --- trunk/src/main/java/org/nuiton/widget/editor/JEditEditor.java 2009-10-11 11:27:29 UTC (rev 226) +++ trunk/src/main/java/org/nuiton/widget/editor/JEditEditor.java 2009-10-15 12:16:19 UTC (rev 227) @@ -214,4 +214,28 @@ public void removeUpdate(DocumentEvent e) { isModified = true; } + + /* + * @see org.nuiton.widget.editor.EditorInterface#copy() + */ + @Override + public void copy() { + editor.copy(); + } + + /* + * @see org.nuiton.widget.editor.EditorInterface#cut() + */ + @Override + public void cut() { + editor.cut(); + } + + /* + * @see org.nuiton.widget.editor.EditorInterface#paste() + */ + @Override + public void paste() { + editor.paste(); + } } Modified: trunk/src/main/java/org/nuiton/widget/editor/NullEditor.java =================================================================== --- trunk/src/main/java/org/nuiton/widget/editor/NullEditor.java 2009-10-11 11:27:29 UTC (rev 226) +++ trunk/src/main/java/org/nuiton/widget/editor/NullEditor.java 2009-10-15 12:16:19 UTC (rev 227) @@ -120,4 +120,27 @@ public void setText(String text) { } + /* + * @see org.nuiton.widget.editor.EditorInterface#copy() + */ + @Override + public void copy() { + + } + + /* + * @see org.nuiton.widget.editor.EditorInterface#cut() + */ + @Override + public void cut() { + + } + + /* + * @see org.nuiton.widget.editor.EditorInterface#paste() + */ + @Override + public void paste() { + + } } Modified: trunk/src/main/java/org/nuiton/widget/editor/RSyntaxEditor.java =================================================================== --- trunk/src/main/java/org/nuiton/widget/editor/RSyntaxEditor.java 2009-10-11 11:27:29 UTC (rev 226) +++ trunk/src/main/java/org/nuiton/widget/editor/RSyntaxEditor.java 2009-10-15 12:16:19 UTC (rev 227) @@ -63,7 +63,7 @@ public RSyntaxEditor() { editor = new RSyntaxTextArea(); - + RTextScrollPane sp = new RTextScrollPane(editor); setLayout(new BorderLayout()); add(sp, BorderLayout.CENTER); @@ -238,4 +238,28 @@ public void removeUpdate(DocumentEvent e) { isModified = true; } + + /* + * @see org.nuiton.widget.editor.EditorInterface#copy() + */ + @Override + public void copy() { + editor.copy(); + } + + /* + * @see org.nuiton.widget.editor.EditorInterface#cut() + */ + @Override + public void cut() { + editor.cut(); + } + + /* + * @see org.nuiton.widget.editor.EditorInterface#paste() + */ + @Override + public void paste() { + editor.paste(); + } }
participants (1)
-
echatellier@users.nuiton.org