[Jsxe-cvs] SF.net SVN: jsxe: [1215] trunk/treeview
Status: Inactive
Brought to you by:
ian_lewis
|
From: <ian...@us...> - 2006-08-31 20:41:53
|
Revision: 1215
http://svn.sourceforge.net/jsxe/?rev=1215&view=rev
Author: ian_lewis
Date: 2006-08-31 13:41:42 -0700 (Thu, 31 Aug 2006)
Log Message:
-----------
merge from 05pre3 branch rev. 1213
Modified Paths:
--------------
trunk/treeview/Changelog
trunk/treeview/src/treeview/DefaultView.java
trunk/treeview/src/treeview/TreeViewPlugin.java
trunk/treeview/src/treeview/TreeViewTree.java
trunk/treeview/src/treeview/action/CopyNodeAction.java
trunk/treeview/src/treeview/action/CutNodeAction.java
trunk/treeview/src/treeview/action/PasteNodeAction.java
Modified: trunk/treeview/Changelog
===================================================================
--- trunk/treeview/Changelog 2006-08-31 20:41:10 UTC (rev 1214)
+++ trunk/treeview/Changelog 2006-08-31 20:41:42 UTC (rev 1215)
@@ -1,3 +1,8 @@
+08/31/2006 Ian Lewis <Ian...@me...>
+
+ * Updated the sourceview actions to use the new ContextSpecificActions in
+ jsXe.
+
08/30/2006 Ian Lewis <Ian...@me...>
* Fixed null pointer exception when trying to cut a node that can't be
Modified: trunk/treeview/src/treeview/DefaultView.java
===================================================================
--- trunk/treeview/src/treeview/DefaultView.java 2006-08-31 20:41:10 UTC (rev 1214)
+++ trunk/treeview/src/treeview/DefaultView.java 2006-08-31 20:41:42 UTC (rev 1215)
@@ -32,8 +32,10 @@
import net.sourceforge.jsxe.dom.*;
import net.sourceforge.jsxe.dom.completion.ElementDecl;
import net.sourceforge.jsxe.*;
+import net.sourceforge.jsxe.action.ContextSpecificAction;
import net.sourceforge.jsxe.gui.DocumentView;
import net.sourceforge.jsxe.gui.Messages;
+import net.sourceforge.jsxe.gui.TabbedView;
import net.sourceforge.jsxe.util.Log;
import net.sourceforge.jsxe.msg.PropertyChanged;
import net.sourceforge.jsxe.msg.UndoEvent;
@@ -120,6 +122,7 @@
m_valueTextArea.setFont(new Font("Monospaced", 0, 12));
m_valueTextArea.setLineWrap(false);
JScrollPane htmlView = new JScrollPane(m_valueTextArea);
+
//}}}
//{{{ init attributes table
@@ -138,6 +141,11 @@
JScrollPane treeView = new JScrollPane(tree);
tree.addTreeSelectionListener(new DefaultTreeSelectionListener(this));
+ //add context specific actions for the tree.
+ ActionManager.addActionImplementation("cut", tree, new CutNodeAction());
+ ActionManager.addActionImplementation("copy", tree, new CopyNodeAction());
+ ActionManager.addActionImplementation("paste", tree, new PasteNodeAction());
+
//starts editing if the user start typing on one of the nodes
//seems to catch user shortcuts too. Not sure how to resolve that.
@@ -233,6 +241,10 @@
}
}
+ ActionManager.removeActionImplementation("cut", tree);
+ ActionManager.removeActionImplementation("copy", tree);
+ ActionManager.removeActionImplementation("paste", tree);
+
EditBus.removeFromBus(this);
return true;
Modified: trunk/treeview/src/treeview/TreeViewPlugin.java
===================================================================
--- trunk/treeview/src/treeview/TreeViewPlugin.java 2006-08-31 20:41:10 UTC (rev 1214)
+++ trunk/treeview/src/treeview/TreeViewPlugin.java 2006-08-31 20:41:42 UTC (rev 1215)
@@ -63,9 +63,6 @@
addAction(new RemoveAttributeAction());
addAction(new EditNodeAction());
addAction(new AddDocTypeAction());
- addAction(new CutNodeAction());
- addAction(new CopyNodeAction());
- addAction(new PasteNodeAction());
}//}}}
//{{{ newDocumentView()
Modified: trunk/treeview/src/treeview/TreeViewTree.java
===================================================================
--- trunk/treeview/src/treeview/TreeViewTree.java 2006-08-31 20:41:10 UTC (rev 1214)
+++ trunk/treeview/src/treeview/TreeViewTree.java 2006-08-31 20:41:42 UTC (rev 1215)
@@ -684,48 +684,48 @@
}//}}}
- //{{{ ElementTreeCellRenderer class
+ // //{{{ ElementTreeCellRenderer class
- private class ElementTreeCellRenderer extends DefaultTreeCellRenderer {
+ // private class ElementTreeCellRenderer extends DefaultTreeCellRenderer {
- //{{{ ElementTreeCellRenderer constructor
+ // //{{{ ElementTreeCellRenderer constructor
- public ElementTreeCellRenderer() {
- m_defaultLeafIcon = getLeafIcon();
- }//}}}
+ // public ElementTreeCellRenderer() {
+ // m_defaultLeafIcon = getLeafIcon();
+ // }//}}}
- //{{{ getTreeCellRendererComponent
+ // //{{{ getTreeCellRendererComponent
- public Component getTreeCellRendererComponent(JTree tree,
- Object value, boolean selected, boolean expanded,
- boolean leaf, int row, boolean hasFocus)
- {
- AdapterNode node = (AdapterNode)value;
+ // public Component getTreeCellRendererComponent(JTree tree,
+ // Object value, boolean selected, boolean expanded,
+ // boolean leaf, int row, boolean hasFocus)
+ // {
+ // AdapterNode node = (AdapterNode)value;
- // We can rename processing instruction nodes here too.
- if (node.getNodeType() == AdapterNode.PROCESSING_INSTRUCTION_NODE) {
- setIcon(m_defaultLeafIcon);
- setLeafIcon(m_defaultLeafIcon);
- setOpenIcon(m_defaultLeafIcon);
- setClosedIcon(m_defaultLeafIcon);
- setToolTipText(Messages.getMessage("xml.processing.instruction"));
- } else {
- setIcon(m_elementIcon);
- setLeafIcon(m_elementIcon);
- setOpenIcon(m_elementIcon);
- setClosedIcon(m_elementIcon);
- setToolTipText(Messages.getMessage("xml.element"));
- }
+ // // We can rename processing instruction nodes here too.
+ // if (node.getNodeType() == AdapterNode.PROCESSING_INSTRUCTION_NODE) {
+ // setIcon(m_defaultLeafIcon);
+ // setLeafIcon(m_defaultLeafIcon);
+ // setOpenIcon(m_defaultLeafIcon);
+ // setClosedIcon(m_defaultLeafIcon);
+ // setToolTipText(Messages.getMessage("xml.processing.instruction"));
+ // } else {
+ // setIcon(m_elementIcon);
+ // setLeafIcon(m_elementIcon);
+ // setOpenIcon(m_elementIcon);
+ // setClosedIcon(m_elementIcon);
+ // setToolTipText(Messages.getMessage("xml.element"));
+ // }
- //just use the node name, we don't want attributes and such.
- setText(((AdapterNode)value).getNodeName());
- return this;
+ // //just use the node name, we don't want attributes and such.
+ // setText(((AdapterNode)value).getNodeName());
+ // return this;
- }//}}}
+ // }//}}}
- private Icon m_defaultLeafIcon;
+ // private Icon m_defaultLeafIcon;
- }//}}}
+ // }//}}}
//{{{ ElementCellEditor class
Modified: trunk/treeview/src/treeview/action/CopyNodeAction.java
===================================================================
--- trunk/treeview/src/treeview/action/CopyNodeAction.java 2006-08-31 20:41:10 UTC (rev 1214)
+++ trunk/treeview/src/treeview/action/CopyNodeAction.java 2006-08-31 20:41:42 UTC (rev 1215)
@@ -29,10 +29,8 @@
import treeview.*;
//{{{ AWT classes
-import java.awt.datatransfer.Clipboard;
import java.awt.event.ActionEvent;
-import java.awt.Toolkit;
-import java.awt.HeadlessException;
+import java.awt.Component;
//}}}
//{{{ Swing classes
@@ -43,7 +41,7 @@
//{{{ jsXe classes
import net.sourceforge.jsxe.jsXe;
-import net.sourceforge.jsxe.LocalizedAction;
+import net.sourceforge.jsxe.action.ContextSpecificAction;
import net.sourceforge.jsxe.gui.DocumentView;
import net.sourceforge.jsxe.gui.Messages;
import net.sourceforge.jsxe.gui.TabbedView;
@@ -60,24 +58,10 @@
* @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>)
* @version $Id$
*/
-public class CopyNodeAction extends LocalizedAction {
+public class CopyNodeAction implements ContextSpecificAction.ActionImplementation {
- //{{{ CopyNodeAction constructor
- /**
- * Creates a action that copies the current node out of the tree and into
- * the clipboard.
- */
- public CopyNodeAction() {
- super(TreeViewPlugin.PLUGIN_NAME+".copy");
- }//}}}
-
- //{{{ getLabel()
- public String getLabel() {
- return Messages.getMessage("common.copy");
- }//}}}
-
//{{{ invoke()
- public void invoke(TabbedView view, ActionEvent evt) {
+ public void invoke(TabbedView view, Component comp, ActionEvent evt) {
DocumentView docView = view.getDocumentView();
if (docView instanceof DefaultView) {
DefaultView defView = (DefaultView)docView;
Modified: trunk/treeview/src/treeview/action/CutNodeAction.java
===================================================================
--- trunk/treeview/src/treeview/action/CutNodeAction.java 2006-08-31 20:41:10 UTC (rev 1214)
+++ trunk/treeview/src/treeview/action/CutNodeAction.java 2006-08-31 20:41:42 UTC (rev 1215)
@@ -30,6 +30,7 @@
//{{{ AWT classes
import java.awt.event.ActionEvent;
+import java.awt.Component;
//}}}
//{{{ Swing classes
@@ -45,7 +46,7 @@
//{{{ jsXe classes
import net.sourceforge.jsxe.jsXe;
-import net.sourceforge.jsxe.LocalizedAction;
+import net.sourceforge.jsxe.action.ContextSpecificAction;
import net.sourceforge.jsxe.gui.DocumentView;
import net.sourceforge.jsxe.gui.Messages;
import net.sourceforge.jsxe.gui.TabbedView;
@@ -63,25 +64,10 @@
* @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>)
* @version $Id$
*/
-public class CutNodeAction extends LocalizedAction {
+public class CutNodeAction implements ContextSpecificAction.ActionImplementation {
- //{{{ CutNodeAction constructor
- /**
- * Creates a action that cuts the current node out of the tree and into
- * the clipboard.
- */
- public CutNodeAction() {
- super(TreeViewPlugin.PLUGIN_NAME+".cut");
- // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl X"));
- }//}}}
-
- //{{{ getLabel()
- public String getLabel() {
- return Messages.getMessage("common.cut");
- }//}}}
-
//{{{ invoke()
- public void invoke(TabbedView view, ActionEvent evt) {
+ public void invoke(TabbedView view, Component comp, ActionEvent evt) {
DocumentView docView = view.getDocumentView();
if (docView instanceof DefaultView) {
DefaultView defView = (DefaultView)docView;
Modified: trunk/treeview/src/treeview/action/PasteNodeAction.java
===================================================================
--- trunk/treeview/src/treeview/action/PasteNodeAction.java 2006-08-31 20:41:10 UTC (rev 1214)
+++ trunk/treeview/src/treeview/action/PasteNodeAction.java 2006-08-31 20:41:42 UTC (rev 1215)
@@ -29,10 +29,8 @@
import treeview.*;
//{{{ AWT classes
-import java.awt.datatransfer.Clipboard;
import java.awt.event.ActionEvent;
-import java.awt.Toolkit;
-import java.awt.HeadlessException;
+import java.awt.Component;
//}}}
//{{{ Swing classes
@@ -48,7 +46,7 @@
//{{{ jsXe classes
import net.sourceforge.jsxe.jsXe;
-import net.sourceforge.jsxe.LocalizedAction;
+import net.sourceforge.jsxe.action.ContextSpecificAction;
import net.sourceforge.jsxe.gui.DocumentView;
import net.sourceforge.jsxe.gui.Messages;
import net.sourceforge.jsxe.gui.TabbedView;
@@ -65,24 +63,10 @@
* @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>)
* @version $Id$
*/
-public class PasteNodeAction extends LocalizedAction {
+public class PasteNodeAction implements ContextSpecificAction.ActionImplementation {
- //{{{ PasteNodeAction constructor
- /**
- * Creates an action that pastes the node in the clipboard to the currently
- * selected node in the tree.
- */
- public PasteNodeAction() {
- super(TreeViewPlugin.PLUGIN_NAME+".paste");
- }//}}}
-
- //{{{ getLabel()
- public String getLabel() {
- return Messages.getMessage("common.paste");
- }//}}}
-
//{{{ invoke()
- public void invoke(TabbedView view, ActionEvent evt) {
+ public void invoke(TabbedView view, Component comp, ActionEvent evt) {
DocumentView docView = view.getDocumentView();
if (docView instanceof DefaultView) {
DefaultView defView = (DefaultView)docView;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|