[Jsxe-cvs] SF.net SVN: jsxe: [1088] branches/treeview2
Status: Inactive
Brought to you by:
ian_lewis
From: <ian...@us...> - 2006-07-29 04:41:54
|
Revision: 1088 Author: ian_lewis Date: 2006-07-28 21:41:34 -0700 (Fri, 28 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1088&view=rev Log Message: ----------- Merge from trunk/treeview of revision 1086 ViewCVS Links: ------------- http://svn.sourceforge.net/jsxe/?rev=1086&view=rev Modified Paths: -------------- branches/treeview2/Changelog branches/treeview2/build.xml branches/treeview2/dependency.props branches/treeview2/messages/messages.de branches/treeview2/src/treeview/DefaultView.java branches/treeview2/src/treeview/DefaultViewTreeModel.java branches/treeview2/src/treeview/NodeTransferHandler.java branches/treeview2/src/treeview/TransferableNode.java branches/treeview2/src/treeview/TreeViewPlugin.java branches/treeview2/src/treeview/action/AddAttributeAction.java branches/treeview2/src/treeview/action/AddDocTypeAction.java branches/treeview2/src/treeview/action/AddNodeAction.java branches/treeview2/src/treeview/action/CopyNodeAction.java branches/treeview2/src/treeview/action/CutNodeAction.java branches/treeview2/src/treeview/action/EditNodeAction.java branches/treeview2/src/treeview/action/PasteNodeAction.java branches/treeview2/src/treeview/action/RemoveAttributeAction.java branches/treeview2/src/treeview/action/RemoveNodeAction.java branches/treeview2/src/treeview/action/RenameNodeAction.java branches/treeview2/src/treeview/treeview.props Added Paths: ----------- branches/treeview2/messages/messages branches/treeview2/messages/messages.ja branches/treeview2/src/treeview/TreeViewOptionPane.java branches/treeview2/src/treeview/TreeViewTree.java Removed Paths: ------------- branches/treeview2/messages/messages.en branches/treeview2/src/treeview/DefaultViewOptionsPanel.java branches/treeview2/src/treeview/DefaultViewTree.java Modified: branches/treeview2/Changelog =================================================================== --- branches/treeview2/Changelog 2006-07-29 04:40:06 UTC (rev 1087) +++ branches/treeview2/Changelog 2006-07-29 04:41:34 UTC (rev 1088) @@ -1,3 +1,58 @@ +07/20/2006 Ian Lewis <Ian...@me...> + + * Updated actions and messages for options. + * Added Japanese translation. + +07/13/2006 Ian Lewis <Ian...@me...> + + * Fixed problem where the shortcut for Adding an element node wasn't + showing in the popup menu. + * Fixed problem where the shortcut for Adding and removing an attribute + wasn't showing in the popup menu. + +07/12/2006 Ian Lewis <Ian...@me...> + + * Updated TreeViewTree to use the WrappingMenu instead of EnhancedMenu + since it was renamed. + +07/06/2006 Ian Lewis <Ian...@me...> + + * Updated to support the new Messages format. + +06/25/2006 Ian Lewis <Ian...@me...> + + * Feature Request 1494444: Updated the tree view so that if no attributes + are defined in the Schema/DTD for the element then the Edit Node dialog + will not be displayed. + +06/23/2006 Ian Lewis <Ian...@me...> + + * Added back rudimentary key bindings using Swing Actions so they get + dispached by Swing and are displayed in menus. But infrastructure is + in place to allow jsXe to catch key bindings itself. + +06/21/2006 Ian Lewis <Ian...@me...> + + * Updated TreeViewTree to use the new package for EnhancedMenu so it + compiles properly. + +06/20/2006 Ian Lewis <Ian...@me...> + + * Updated the treeview's actions to extend the new LocalizedAction class. + +06/15/2006 Ian Lewis <Ian...@me...> + + * Updated how properties are loaded for the tree view + +06/13/2006 Ian Lewis <Ian...@me...> + + * Updated the options pane extend AbstractOptionPane + * Renamed the DefaultViewTree to TreeViewTree + +06/09/2006 Ian Lewis <Ian...@me...> + + * Updated version and dependency info + 06/03/2006 Ian Lewis <Ian...@me...> * Updated the Tree View to use the new XMLDocumentListener interface Modified: branches/treeview2/build.xml =================================================================== --- branches/treeview2/build.xml 2006-07-29 04:40:06 UTC (rev 1087) +++ branches/treeview2/build.xml 2006-07-29 04:41:34 UTC (rev 1088) @@ -1,7 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - This is a build.xml file for building the Tree View for jsXe. - Version: $Id$ + :tabSize=2:indentSize=2:noTabs=true: + :folding=explicit:collapseFolds=1: + + This is a build.xml file for building the Tree View for jsXe. + Version: $Id$ --> <project basedir="." default="usage" name="treeview"> @@ -26,7 +29,7 @@ <property name="build.help" value="${build.docs}/help"/> <property name="jsxe.dir" value="${root.dir}/../.."/> <property name="jsxe.jar" value="${jsxe.dir}/jsXe.jar"/> - <property name="jsxe.lib.dir" value="${jsxe.dir}/lib"/> + <property name="jsxe.lib.dir" value="${jsxe.dir}/../lib"/> <property name="javac.debug" value="on"/> <property name="javac.optimize" value="off"/> <property name="javac.deprecation" value="on"/> @@ -35,7 +38,7 @@ <property name="javadoc.link" value="http://java.sun.com/j2se/1.3/docs/api/"/> <property name="main.class" value="treeview.TreeViewPlugin"/> <property name="major.version" value="0"/> - <property name="minor.version" value="4"/> + <property name="minor.version" value="5"/> <property name="build.version" value="3"/> <property name="app.version" value="${major.version}.${minor.version}.${build.version}"/> <property name="app_version" value="${major.version}_${minor.version}_${build.version}"/> @@ -73,11 +76,14 @@ <mkdir dir="${build.dir}"/> <mkdir dir="${build.messages}"/> - <copy todir="${build.messages}"> + <!--<copy todir="${build.messages}"> <fileset dir="${messages.dir}"> <include name="**/messages.*"/> </fileset> - </copy> + </copy>--> + + <!-- run native2ascii on these files --> + <native2ascii encoding="UTF-8" src="${messages.dir}" dest="${build.messages}" includes="messages*"/> </target> <!-- }}} --> <!-- {{{ ============ Prepares the documentation ======================= --> @@ -131,6 +137,8 @@ <attribute name="jsxe-plugin-name" value="${app.name}"/> <attribute name="jsxe-plugin-human-readable-name" value="${readable.name}"/> <attribute name="jsxe-plugin-version" value="${implementation.version}"/> + <attribute name="jsxe-plugin-author" value="Ian Lewis"/> + <!--<attribute name="jsxe-plugin-release-date" value=""/>--> <attribute name="jsxe-plugin-url" value="http://jsxe.sourceforge.net/"/> <attribute name="jsxe-plugin-class" value="${main.class}"/> <attribute name="jsxe-plugin-description" value="${description}"/> @@ -139,7 +147,7 @@ <jar jarfile="${root.dir}/../${app.name}.jar" manifest="${app.name}.manifest"> <fileset dir="${build.dir}"> - <include name="messages/messages.*"/> + <include name="messages/messages*"/> </fileset> <fileset dir="${build.dest}"> <include name="**/*.class"/> Modified: branches/treeview2/dependency.props =================================================================== --- branches/treeview2/dependency.props 2006-07-29 04:40:06 UTC (rev 1087) +++ branches/treeview2/dependency.props 2006-07-29 04:41:34 UTC (rev 1088) @@ -1 +1 @@ -dependency.0=jsxe 00.04.03.00 +dependency.0=jsxe 00.05.03.00 Copied: branches/treeview2/messages/messages (from rev 1084, trunk/treeview/messages/messages) =================================================================== --- branches/treeview2/messages/messages (rev 0) +++ branches/treeview2/messages/messages 2006-07-29 04:41:34 UTC (rev 1088) @@ -0,0 +1,30 @@ +# JSXE tree view English properties file +# $Id$ +#:mode=properties: +#:tabSize=4:indentSize=4:noTabs=true: +#:folding=explicit:collapseFolds=1: + +TreeView.Options.Title=Tree View + +TreeView.Options.Show.Comments=Show comment nodes +TreeView.Options.Continuous.Layout=Continuous layout for split-panes +TreeView.Options.Show.Attributes=Show element attributes in tree: +Show.Attributes.None=None +Show.Attributes.ID.Only=ID only +Show.Attributes.All=All + + +treeview.rename.node.label=Rename Node +treeview.remove.node.label=Remove Node +treeview.add.attribute.label=Add Attribute +treeview.remove.attribute.label=Remove Attribute +treeview.edit.node.label=Edit Node +TreeView.EditDocType.Title=Edit Document Type Definition +Edit.Node.Dialog.Title=Edit Node + +treeview.add.doctype.node.label=Add Document Type Definition +treeview.add.element.node.label=Add Element Node +treeview.add.text.node.label=Add Text Node +treeview.add.cdata.node.label=Add CDATA Node +treeview.add.pi.node.label=Add Processing Instruction +treeview.add.comment.node.label=Add Comment Modified: branches/treeview2/messages/messages.de =================================================================== --- branches/treeview2/messages/messages.de 2006-07-29 04:40:06 UTC (rev 1087) +++ branches/treeview2/messages/messages.de 2006-07-29 04:41:34 UTC (rev 1088) @@ -5,19 +5,18 @@ #:tabSize=4:indentSize=4:noTabs=true: #:folding=explicit:collapseFolds=1: +# ä Ä é ö Ö ü Ü ß -#{{{ TreeView TreeView.Options.Title=Tree View Optionen TreeView.Options.Show.Comments=Kommentar Knoten anzeigen -TreeView.Options.Show.Comments.ToolTip =Beim Deaktivieren werden s�mtliche Kommentare in der momentan ge�ffneten XML Datei ausgeblendet. -TreeView.Options.Continuous.Layout=Durchg�ngiges Layout f�r split-panes -TreeView.Options.Continuous.Layout.ToolTip =<HTML>Dies beeinflusst das Aussehen des vertikalen Balkens in der Mitte des jsXE Screens.<BR>Ist dieses Auswahlk�stchen nicht ausgew�hlt w�hrend der vertikale Balken vor und zur�ck �ber den Screen <BR>gezogen wird, bewegt er sich ohne Umst�nde.<BR>Ist dieses Auswahlk�stchen nicht aktiviert w�hrend der vertikale Balken verschoben wird, ver�ndert er sich in <BR>eine dicke schwarze Linie.</HTML> +TreeView.Options.Show.Comments.ToolTip=Beim Deaktivieren werden sämtliche Kommentare in der momentan geöffneten XML Datei ausgeblendet. +TreeView.Options.Continuous.Layout=Durchgängiges Layout für split-panes +TreeView.Options.Continuous.Layout.ToolTip=<HTML>Dies beeinflusst das Aussehen des vertikalen Balkens in der Mitte des jsXE Screens.<BR>Ist dieses Auswahlkästchen nicht ausgewählt während der vertikale Balken vor und zurück über den Screen <BR>gezogen wird, bewegt er sich ohne Umstände.<BR>Ist dieses Auswahlkästchen nicht aktiviert während der vertikale Balken verschoben wird, verändert er sich in <BR>eine dicke schwarze Linie.</HTML> TreeView.Options.Show.Attributes=Show element attributes in tree: -TreeView.Options.Show.Attributes.ToolTip =<HTML>Diese Option verlaubt es, die XML Datei auf verschiedene Arten anzuzeigen. <BR><ul><li><strong>Keine</strong> - blendet alle Attribut-Informationen der Datei aus. </li><li><strong>Nur ID</strong> - nur Attribut-Informationen, die zu einem XML Element mit ID geh�ren, werden angezeigt.</li><li><strong>Alle</strong> - alle Attribut-Informationen werden angezeigt.</li></ul><HTML> +TreeView.Options.Show.Attributes.ToolTip=<HTML>Diese Option verlaubt es, die XML Datei auf verschiedene Arten anzuzeigen. <ul><li><strong>Keine</strong> - blendet alle Attribut-Informationen der Datei aus. </li><li><strong>Nur ID</strong> - nur Attribut-Informationen, die zu einem XML Element mit ID gehören, werden angezeigt.</li><li><strong>Alle</strong> - alle Attribut-Informationen werden angezeigt.</li></ul><HTML> TreeView.RenameNode=Knoten umbenennen TreeView.RemoveNode=Knoten entfernen -TreeView.AddAttribute=Attribut hinzuf�gen +TreeView.AddAttribute=Attribut hinzufügen TreeView.RemoveAttribute=Attribut entfernen TreeView.EditNode=Knoten bearbeiten Edit.Node.Dialog.Title=Knoten bearbeitenn -#}}} Deleted: branches/treeview2/messages/messages.en =================================================================== --- branches/treeview2/messages/messages.en 2006-07-29 04:40:06 UTC (rev 1087) +++ branches/treeview2/messages/messages.en 2006-07-29 04:41:34 UTC (rev 1088) @@ -1,19 +0,0 @@ -# JSXE tree view English properties file -# $Id$ -#:mode=properties: -#:tabSize=4:indentSize=4:noTabs=true: -#:folding=explicit:collapseFolds=1: - -#{{{ TreeView -TreeView.Options.Title=Tree View Options -TreeView.Options.Show.Comments=Show comment nodes -TreeView.Options.Continuous.Layout=Continuous layout for split-panes -TreeView.Options.Show.Attributes=Show element attributes in tree: -TreeView.RenameNode=Rename Node -TreeView.RemoveNode=Remove Node -TreeView.AddAttribute=Add Attribute -TreeView.RemoveAttribute=Remove Attribute -TreeView.EditNode=Edit Node -TreeView.EditDocType.Title=Edit Document Type Definition -Edit.Node.Dialog.Title=Edit Node -#}}} Copied: branches/treeview2/messages/messages.ja (from rev 1084, trunk/treeview/messages/messages.ja) =================================================================== --- branches/treeview2/messages/messages.ja (rev 0) +++ branches/treeview2/messages/messages.ja 2006-07-29 04:41:34 UTC (rev 1088) @@ -0,0 +1,29 @@ +# JSXE tree view Japanese properties file +# $Id$ +# Maintained by Ian Lewis +#:mode=properties: +#:tabSize=4:indentSize=4:noTabs=true: +#:folding=explicit:collapseFolds=1: + +TreeView.Options.Title=ツリー表示 + +TreeView.Options.Show.Comments=コメントノードを表示する +TreeView.Options.Show.Attributes=要素の属性を表示する: +Show.Attributes.None=なし +Show.Attributes.ID.Only=IDだけ +Show.Attributes.All=全て + +treeview.rename.node.label=ノードをリネーム +treeview.remove.node.label=ノードを削除 +treeview.add.attribute.label=属性を追加 +treeview.remove.attribute.label=属性を削除 +treeview.add.doctype.node.label=DTDを追加 +treeview.edit.node.label=ノードを編集 +TreeView.EditDocType.Title=DTDを編集 +Edit.Node.Dialog.Title=ノードを編集 + +treeview.add.element.node.label=要素を追加 +treeview.add.text.node.label=テキストを追加 +treeview.add.cdata.node.label=CDATA セクションを追加 +treeview.add.pi.node.label=処理命令を追加 +treeview.add.comment.node.label=コメントを追加 Modified: branches/treeview2/src/treeview/DefaultView.java =================================================================== --- branches/treeview2/src/treeview/DefaultView.java 2006-07-29 04:40:06 UTC (rev 1087) +++ branches/treeview2/src/treeview/DefaultView.java 2006-07-29 04:41:34 UTC (rev 1088) @@ -31,13 +31,11 @@ //{{{ jsXe classes import net.sourceforge.jsxe.dom.*; import net.sourceforge.jsxe.dom.completion.ElementDecl; -import net.sourceforge.jsxe.jsXe; -import net.sourceforge.jsxe.DocumentBuffer; -import net.sourceforge.jsxe.ViewPlugin; -import net.sourceforge.jsxe.gui.OptionsPanel; +import net.sourceforge.jsxe.*; import net.sourceforge.jsxe.gui.DocumentView; import net.sourceforge.jsxe.gui.Messages; import net.sourceforge.jsxe.util.Log; +import net.sourceforge.jsxe.msg.PropertyChanged; //}}} //{{{ Swing components @@ -75,7 +73,7 @@ * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ */ -public class DefaultView extends JPanel implements DocumentView { +public class DefaultView extends JPanel implements DocumentView, EBListener { //{{{ Private static members private static final Properties m_defaultProperties; @@ -108,6 +106,8 @@ m_plugin = plugin; + enableEvents(java.awt.AWTEvent.KEY_EVENT_MASK); + setLayout(new BorderLayout()); //{{{ init html editor pane @@ -168,11 +168,11 @@ //TODO: get cut/copy/paste to work in the right hand text window m_editMenu = new JMenu(Messages.getMessage("Edit.Menu")); m_editMenu.setMnemonic('E'); - JMenuItem menuItem = new JMenuItem(jsXe.getAction("treeview.cut.node")); + JMenuItem menuItem = new JMenuItem(ActionManager.getAction("cut")); m_editMenu.add(menuItem); - menuItem = new JMenuItem(jsXe.getAction("treeview.copy.node")); + menuItem = new JMenuItem(ActionManager.getAction("copy")); m_editMenu.add(menuItem); - menuItem = new JMenuItem(jsXe.getAction("treeview.paste.node")); + menuItem = new JMenuItem(ActionManager.getAction("paste")); m_editMenu.add(menuItem); //}}} @@ -203,8 +203,8 @@ Container parent = getParent(); if (parent != null) { Dimension size = parent.getSize(); - float vertPercent = Integer.valueOf(m_document.getProperty(VERT_SPLIT_LOCATION)).floatValue(); - float horizPercent = Integer.valueOf(m_document.getProperty(HORIZ_SPLIT_LOCATION)).floatValue(); + float vertPercent = Integer.valueOf(jsXe.getProperty(VERT_SPLIT_LOCATION)).floatValue(); + float horizPercent = Integer.valueOf(jsXe.getProperty(HORIZ_SPLIT_LOCATION)).floatValue(); int vertLoc = (int)((vertPercent/100.0)*size.getHeight()); int horizLoc = (int)((horizPercent/100.0)*size.getWidth()); @@ -219,12 +219,13 @@ });//}}} setDocumentBuffer(document); + + EditBus.addToBus(this); }//}}} //{{{ DocumentView methods //{{{ close() - public boolean close() { //m_document should only be null if setDocumentBuffer was never called. @@ -236,13 +237,15 @@ String vert = Integer.toString((int)(vertSplitPane.getDividerLocation()/size.getHeight()*100)); String horiz = Integer.toString((int)(horizSplitPane.getDividerLocation()/size.getWidth()*100)); - m_document.setProperty(VERT_SPLIT_LOCATION,vert); - m_document.setProperty(HORIZ_SPLIT_LOCATION,horiz); + jsXe.setProperty(VERT_SPLIT_LOCATION,vert); + jsXe.setProperty(HORIZ_SPLIT_LOCATION,horiz); m_document.removeXMLDocumentListener(m_documentListener); } } + EditBus.removeFromBus(this); + return true; }//}}} @@ -271,7 +274,6 @@ }//}}} //{{{ setDocumentBuffer() - public void setDocumentBuffer(DocumentBuffer document) throws IOException { try { @@ -284,8 +286,6 @@ throw new IOException(e.toString()); } - ensureDefaultProps(document); - AdapterNode adapter = document.getAdapterNode(); DefaultViewTreeModel treeModel = new DefaultViewTreeModel(this, document); @@ -304,7 +304,7 @@ styledDoc.addDocumentListener(docListener); //get the splitpane layout options - boolean layout = Boolean.valueOf(document.getProperty(CONTINUOUS_LAYOUT)).booleanValue(); + boolean layout = Boolean.valueOf(jsXe.getProperty(CONTINUOUS_LAYOUT)).booleanValue(); vertSplitPane.setContinuousLayout(layout); horizSplitPane.setContinuousLayout(layout); @@ -330,12 +330,27 @@ //}}} - //{{{ getDefaultViewTree() + //{{{ handleMessage() + public void handleMessage(EBMessage message) { + if (message instanceof PropertyChanged) { + String key = ((PropertyChanged)message).getKey(); + if (CONTINUOUS_LAYOUT.equals(key)) { + boolean layout = Boolean.valueOf(jsXe.getProperty(CONTINUOUS_LAYOUT)).booleanValue(); + vertSplitPane.setContinuousLayout(layout); + horizSplitPane.setContinuousLayout(layout); + } + if (CONTINUOUS_LAYOUT.equals(key) || SHOW_COMMENTS.equals(key) || SHOW_ATTRIBUTES.equals(key)) { + tree.updateUI(); + } + } + }//}}} + + //{{{ getTree() /** * Gets the tree component for this DefaultView. * @return the tree component */ - public DefaultViewTree getDefaultViewTree() { + public TreeViewTree getTree() { return tree; }//}}} @@ -366,18 +381,6 @@ return (node.getNodeValue() != null); }//}}} - //{{{ ensureDefaultProps() - - private void ensureDefaultProps(XMLDocument document) { - //get default properties from jsXe - document.setProperty(CONTINUOUS_LAYOUT, document.getProperty(CONTINUOUS_LAYOUT, m_defaultProperties.getProperty(CONTINUOUS_LAYOUT))); - document.setProperty(HORIZ_SPLIT_LOCATION, document.getProperty(HORIZ_SPLIT_LOCATION, m_defaultProperties.getProperty(HORIZ_SPLIT_LOCATION))); - document.setProperty(VERT_SPLIT_LOCATION, document.getProperty(VERT_SPLIT_LOCATION, m_defaultProperties.getProperty(VERT_SPLIT_LOCATION))); - document.setProperty(SHOW_COMMENTS, document.getProperty(SHOW_COMMENTS, m_defaultProperties.getProperty(SHOW_COMMENTS))); - document.setProperty(SHOW_ATTRIBUTES, document.getProperty(SHOW_ATTRIBUTES, m_defaultProperties.getProperty(SHOW_ATTRIBUTES))); - // document.setProperty(SHOW_EMPTY_NODES, document.getProperty(SHOW_EMPTY_NODES, m_defaultProperties.getProperty(SHOW_EMPTY_NODES))); - }//}}} - //{{{ TablePopupListener class private class TablePopupListener extends MouseAdapter { @@ -410,14 +413,10 @@ JPopupMenu popup = new JPopupMenu(); JMenuItem popupMenuItem; - popupMenuItem = new JMenuItem("Add Attribute"); - popupMenuItem.addActionListener(jsXe.getAction("treeview.add.attribute")); - popup.add(popupMenuItem); + popup.add(ActionManager.getAction("treeview.add.attribute")); if (row != attributesTable.getRowCount()-1) { - popupMenuItem = new JMenuItem("Remove Attribute"); - popupMenuItem.addActionListener(jsXe.getAction("treeview.remove.attribute")); - popup.add(popupMenuItem); + popup.add(ActionManager.getAction("treeview.remove.attribute")); } popup.show(e.getComponent(), e.getX(), e.getY()); } @@ -524,7 +523,7 @@ }//}}} - private DefaultViewTree tree = new DefaultViewTree(); + private TreeViewTree tree = new TreeViewTree(); private JTextArea m_valueTextArea = new JTextArea(""); private DefaultViewTable attributesTable = new DefaultViewTable(); private JSplitPane vertSplitPane; @@ -577,17 +576,8 @@ };//}}} private XMLDocumentListener m_documentListener = new XMLDocumentListener() {///{{{ - //{{{ propertiesChanged - public void propertyChanged(XMLDocument source, String key, String oldValue) { - if (CONTINUOUS_LAYOUT.equals(key)) { - boolean layout = Boolean.valueOf(source.getProperty(CONTINUOUS_LAYOUT)).booleanValue(); - vertSplitPane.setContinuousLayout(layout); - horizSplitPane.setContinuousLayout(layout); - } - if (CONTINUOUS_LAYOUT.equals(key) || SHOW_COMMENTS.equals(key) || SHOW_ATTRIBUTES.equals(key)) { - tree.updateUI(); - } - }//}}} + //{{{ propertiesChanged() + public void propertyChanged(XMLDocument source, String key, String oldValue) {}//}}} //{{{ structureChanged() public void structureChanged(XMLDocument source, AdapterNode location) { @@ -601,21 +591,6 @@ attributesTable.updateUI(); }//}}} - //{{{ insertUpdate() - public void insertUpdate(XMLDocumentEvent event) { - structureChanged(event.getXMLDocument(), null); - }//}}} - - //{{{ removeUpdate() - public void removeUpdate(XMLDocumentEvent event) { - structureChanged(event.getXMLDocument(), null); - }//}}} - - //{{{ changeUpdate() - public void changeUpdate(XMLDocumentEvent event) { - structureChanged(event.getXMLDocument(), null); - }//}}} - };//}}} //}}} Deleted: branches/treeview2/src/treeview/DefaultViewOptionsPanel.java =================================================================== --- branches/treeview2/src/treeview/DefaultViewOptionsPanel.java 2006-07-29 04:40:06 UTC (rev 1087) +++ branches/treeview2/src/treeview/DefaultViewOptionsPanel.java 2006-07-29 04:41:34 UTC (rev 1088) @@ -1,179 +0,0 @@ -/* -DefaultViewOptionsPanel.java -:tabSize=4:indentSize=4:noTabs=true: -:folding=explicit:collapseFolds=1: - -Copyright (C) 2002 Ian Lewis (Ian...@me...) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -Optionally, you may find a copy of the GNU General Public License -from http://www.fsf.org/copyleft/gpl.txt -*/ - -package treeview; - -//{{{ imports - -//{{{ jsXe classes -import net.sourceforge.jsxe.dom.*; -import net.sourceforge.jsxe.DocumentBuffer; -import net.sourceforge.jsxe.gui.OptionsPanel; -import net.sourceforge.jsxe.gui.DocumentView; -import net.sourceforge.jsxe.gui.Messages; -//}}} - -//{{{ Swing components -import javax.swing.*; -import javax.swing.text.PlainDocument; -import javax.swing.event.*; -import javax.swing.tree.*; -//}}} - -//{{{ AWT components -import java.awt.*; -import java.awt.event.*; -//}}} - -//{{{ Java base classes -import java.io.IOException; -import java.io.InputStream; -import java.util.Enumeration; -import java.util.Properties; -//}}} - -//}}} - - -public class DefaultViewOptionsPanel extends OptionsPanel { - - //{{{ DefaultViewOptionsPanel constructor - - public DefaultViewOptionsPanel(DocumentBuffer buffer) { - - m_document = buffer; - - GridBagLayout layout = new GridBagLayout(); - GridBagConstraints constraints = new GridBagConstraints(); - - setLayout(layout); - - int gridY = 0; - - boolean showCommentNodes = Boolean.valueOf(m_document.getProperty(DefaultView.SHOW_COMMENTS, "false")).booleanValue(); - // boolean showEmptyNodes = Boolean.valueOf(m_document.getProperty(SHOW_EMPTY_NODES, "false")).booleanValue(); - boolean continuousLayout = Boolean.valueOf(m_document.getProperty(DefaultView.CONTINUOUS_LAYOUT, "false")).booleanValue(); - String showAttrs = m_document.getProperty(DefaultView.SHOW_ATTRIBUTES, "ID only"); - - showCommentsCheckBox = new JCheckBox(Messages.getMessage("TreeView.Options.Show.Comments"),showCommentNodes); - showCommentsCheckBox.setToolTipText(Messages.getMessage("TreeView.Options.Show.Comments.ToolTip")); - // showEmptyNodesCheckBox = new JCheckBox("Show whitespace-only nodes",showEmptyNodes); - ContinuousLayoutCheckBox = new JCheckBox(Messages.getMessage("TreeView.Options.Continuous.Layout"),continuousLayout); - ContinuousLayoutCheckBox.setToolTipText(Messages.getMessage("TreeView.Options.Continuous.Layout.ToolTip")); - - JLabel showAttrsLabel = new JLabel(Messages.getMessage("TreeView.Options.Show.Attributes")); - m_showAttrsComboBox = new JComboBox(new String [] {"None", "ID only", "All"}); - - m_showAttrsComboBox.setSelectedItem(showAttrs); - m_showAttrsComboBox.setToolTipText(Messages.getMessage("TreeView.Options.Show.Attributes.ToolTip")); - - constraints.gridy = gridY; - constraints.gridx = 1; - constraints.gridheight = 1; - constraints.gridwidth = 1; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(showAttrsLabel, constraints); - add(showAttrsLabel); - - constraints.gridy = gridY++; - constraints.gridx = 2; - constraints.gridheight = 1; - constraints.gridwidth = 1; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(m_showAttrsComboBox, constraints); - add(m_showAttrsComboBox); - - constraints.gridy = gridY++; - constraints.gridx = 1; - constraints.gridheight = 1; - constraints.gridwidth = 2; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(showCommentsCheckBox, constraints); - add(showCommentsCheckBox); - - // constraints.gridy = gridY++; - // constraints.gridx = 1; - // constraints.gridheight = 1; - // constraints.gridwidth = 1; - // constraints.weightx = 1.0f; - // constraints.fill = GridBagConstraints.BOTH; - // constraints.insets = new Insets(1,0,1,0); - - // layout.setConstraints(showEmptyNodesCheckBox, constraints); - // add(showEmptyNodesCheckBox); - - constraints.gridy = gridY++; - constraints.gridx = 1; - constraints.gridheight = 1; - constraints.gridwidth = 2; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(ContinuousLayoutCheckBox, constraints); - add(ContinuousLayoutCheckBox); - }//}}} - - //{{{ save() - - public void save() { - m_document.setProperty(DefaultView.SHOW_COMMENTS,String.valueOf(showCommentsCheckBox.isSelected())); - // m_document.setProperty(SHOW_EMPTY_NODES,(new Boolean(showEmptyNodesCheckBox.isSelected())).toString()); - m_document.setProperty(DefaultView.CONTINUOUS_LAYOUT,String.valueOf(ContinuousLayoutCheckBox.isSelected())); - m_document.setProperty(DefaultView.SHOW_ATTRIBUTES, m_showAttrsComboBox.getSelectedItem().toString()); - }//}}} - - //{{{ getName() - - public String getName() { - return "defaultview"; - }//}}} - - //{{{ getTitle() - - public String getTitle() { - return Messages.getMessage("TreeView.Options.Title"); - }//}}} - - //{{{ Private Members - - private JCheckBox showCommentsCheckBox; - // private JCheckBox showEmptyNodesCheckBox; - private JCheckBox ContinuousLayoutCheckBox; - private JComboBox m_showAttrsComboBox; - - private DocumentBuffer m_document; - - //}}} - -}//}}} Deleted: branches/treeview2/src/treeview/DefaultViewTree.java =================================================================== --- branches/treeview2/src/treeview/DefaultViewTree.java 2006-07-29 04:40:06 UTC (rev 1087) +++ branches/treeview2/src/treeview/DefaultViewTree.java 2006-07-29 04:41:34 UTC (rev 1088) @@ -1,1121 +0,0 @@ -/* -DefaultViewTree.java -:tabSize=4:indentSize=4:noTabs=true: -:folding=explicit:collapseFolds=1: - -jsXe is the Java Simple XML Editorh -jsXe is a gui application that can edit an XML document and create a tree view. -The user can then edit this tree and the content in the tree and save the -document. - -This file contains the tree class that is used in the default view. - -This file written by Ian Lewis (Ian...@me...) -Copyright (C) 2002 Ian Lewis - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -Optionally, you may find a copy of the GNU General Public License -from http://www.fsf.org/copyleft/gpl.txt -*/ - -package treeview; - -//{{{ imports - -import treeview.action.AddNodeAction; - -//{{{ jsXe classes -import net.sourceforge.jsxe.jsXe; -import net.sourceforge.jsxe.gui.Messages; -import net.sourceforge.jsxe.gui.EnhancedMenu; -import net.sourceforge.jsxe.dom.*; -import net.sourceforge.jsxe.dom.completion.*; -import net.sourceforge.jsxe.util.Log; -//}}} - -//{{{ Swing components -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.tree.*; -//}}} - -//{{{ AWT components -import java.awt.*; -import java.awt.datatransfer.*; -import java.awt.dnd.*; -import java.awt.event.*; -//}}} - -//{{{ DOM classes -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.DOMException; -import org.w3c.dom.Node; -//}}} - -//{{{ Java base classes -import java.io.IOException; -import java.util.*; -//}}} - -//}}} - -/** - * The DefaultViewTree is the tree that is displayed in the upper-left of - * the DefaultView in jsXe. This class defines methods specific to the tree - * display. - * - * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) - * @version $Id$ - * @see DefaultView - */ -public class DefaultViewTree extends JTree implements Autoscroll, ClipboardOwner { - - //{{{ Properties - private final String NODE_EXPANDED = "tree.expandedstate"; - //}}} - - //{{{ DefaultViewTree constructor - /** - * Creates a new DefaultViewTree with the default TreeModel - */ - public DefaultViewTree() { - - //{{{ intitalize Drag n Drop - m_dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, m_treeDGListener); - m_dropTarget = new DropTarget(this, m_acceptableActions, m_treeDTListener, true); - //}}} - - addMouseListener(new TreePopupListener()); - setEditable(false); - addTreeExpansionListener(new TreeExpansionListener() {//{{{ - - //{{{ treeExpanded() - - public void treeExpanded(TreeExpansionEvent event) { - try { - AdapterNode node = (AdapterNode)event.getPath().getLastPathComponent(); - node.setProperty(NODE_EXPANDED, "true"); - } catch (ClassCastException e) {} - }//}}} - - //{{{ treeCollapsed() - - public void treeCollapsed(TreeExpansionEvent event) { - try { - AdapterNode node = (AdapterNode)event.getPath().getLastPathComponent(); - node.setProperty(NODE_EXPANDED, "false"); - } catch (ClassCastException e) {} - }//}}} - - });//}}} - - getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); - - DefaultViewTreeCellRenderer renderer = new DefaultViewTreeCellRenderer(); - setCellRenderer(renderer); - - //Since elements are the only editable nodes... - renderer = new DefaultViewTreeCellRenderer(); - setCellEditor(new DefaultTreeCellEditor(this, renderer, new ElementCellEditor(this, renderer))); - - - ToolTipManager.sharedInstance().registerComponent(this); - - }//}}} - - //{{{ isEditable() - /** - * Indicates if a node is capable of being edited in - * this tree. - * @param node the node to check - * @return true if the node can be edited in this tree - */ - public boolean isEditable(AdapterNode node) { - if (node != null) { - int nodeType = node.getNodeType(); - return (nodeType == Node.ELEMENT_NODE || nodeType == Node.PROCESSING_INSTRUCTION_NODE); - } else { - return false; - } - }//}}} - - //{{{ isExpanded() - - public boolean isExpanded(AdapterNode node) { - return Boolean.valueOf(node.getProperty(NODE_EXPANDED)).booleanValue(); - }//}}} - - //{{{ startEditingAtPath() - - public void startEditingAtPath(TreePath path) { - if (path != null && isEditable((AdapterNode)path.getLastPathComponent())) { - //When editing is finished go back to uneditable - getCellEditor().addCellEditorListener(new CellEditorListener() {//{{{ - public void editingCanceled(ChangeEvent e) { - setEditable(false); - getCellEditor().removeCellEditorListener(this); - } - public void editingStopped(ChangeEvent e) { - setEditable(false); - getCellEditor().removeCellEditorListener(this); - } - });//}}} - setEditable(true); - super.startEditingAtPath(path); - } - }//}}} - - //{{{ getSelectedNode() - /** - * Gets the current node that is selected for editing. - * @return the current selected node or null if no node is selected. - */ - public AdapterNode getSelectedNode() { - TreePath selPath = getLeadSelectionPath(); - AdapterNode selectedNode = null; - if (selPath != null) { - selectedNode = (AdapterNode)selPath.getLastPathComponent(); - } - return selectedNode; - }//}}} - - //{{{ cut() - /** - * Cuts the currently selected node out of the tree and places it in the - * clipboard. - * @return true if the node was successfully cut - * @throws DOMException if the node cannot be removed from the tree. - */ - public boolean cut() throws DOMException { - AdapterNode selectedNode = getSelectedNode(); - Clipboard clipBoard = getToolkit().getSystemClipboard(); - if (selectedNode != null) { - try { - clipBoard.setContents(new TransferableNode(selectedNode), this); - selectedNode.getParentNode().remove(selectedNode); - updateUI(); - return true; - } catch (IllegalStateException e) { - Log.log(Log.ERROR, this, e); - } catch (HeadlessException e) { - Log.log(Log.ERROR, this, e); - } catch (DOMException e) { - clipBoard.setContents(null, this); - throw e; - } - } - return false; - }//}}} - - //{{{ copy() - /** - * Copies the currently selected node to the clipboard. - * @return true if the node was copied successfully - */ - public boolean copy() { - AdapterNode selectedNode = getSelectedNode(); - if (selectedNode != null) { - try { - Clipboard clipBoard = getToolkit().getSystemClipboard(); - AdapterNode newNode = selectedNode.copy(true); - clipBoard.setContents(new TransferableNode(newNode), this); - return true; - } catch (IllegalStateException e) { - Log.log(Log.ERROR, this, e); - } catch (HeadlessException e) { - Log.log(Log.ERROR, this, e); - } - } - return false; - }//}}} - - //{{{ paste() - /** - * Pastes the contents of the clipboard into the currently selected node - * in the document tree. - * @return true if the node was pasted successfully - * @throws DOMException if the node cannot be inserted in the current - * location. - */ - public boolean paste() throws DOMException { - AdapterNode selectedNode = getSelectedNode(); - if (selectedNode != null) { - try { - Clipboard clipBoard = getToolkit().getSystemClipboard(); - Transferable contents = clipBoard.getContents(this); - if (contents != null) { - if (contents.isDataFlavorSupported(TransferableNode.nodeFlavor)) { - AdapterNode node = (AdapterNode)contents.getTransferData(TransferableNode.nodeFlavor); - TreePath pastePath = getLeadSelectionPath(); - selectedNode.addAdapterNode(node); - - //reset the clipboard - StringSelection sel = new StringSelection(""); - clipBoard.setContents(sel, sel); - - refreshExpandedStates(pastePath); - addSelectionPath(pastePath.pathByAddingChild(node)); - updateUI(); - return true; - } - } - } catch (IllegalStateException e) { - Log.log(Log.ERROR, this, e); - } catch (HeadlessException e) { - Log.log(Log.ERROR, this, e); - } catch (UnsupportedFlavorException e) { - Log.log(Log.ERROR, this, e); - } catch (IOException e) { - Log.log(Log.ERROR, this, e); - } - } - return false; - }//}}} - - //{{{ Autoscroll methods - - //{{{ autoscroll() - - public void autoscroll(Point cursorLocn) { - int row = getClosestRowForLocation(cursorLocn.x, cursorLocn.y); - - if (row < 0) { - return; - } - - Rectangle bounds = getBounds(); - - if (cursorLocn.y + bounds.y <= m_AUTOSCROLL_MARGIN) { - if (row <= 0) { - row = 0; - } else { - row -=1; - } - } else { - if (row < getRowCount() - 1) { - row += 1; - } - } - scrollRowToVisible(row); - }//}}} - - //{{{ getAutoscrollInsets() - - public Insets getAutoscrollInsets() { - - Rectangle outerBounds = getBounds(); - Rectangle innerBounds = getParent().getBounds(); - int top = innerBounds.y - outerBounds.y + m_AUTOSCROLL_MARGIN; - int left = innerBounds.x - outerBounds.x + m_AUTOSCROLL_MARGIN; - int bottom = outerBounds.height - innerBounds.height - innerBounds.y + outerBounds.y + m_AUTOSCROLL_MARGIN; - int right = outerBounds.width - innerBounds.width - innerBounds.x + outerBounds.y + m_AUTOSCROLL_MARGIN; - return new Insets(top, left, bottom, right); - }//}}} - - //}}} - - //{{{ ClipboardOwner methods - - //{{{ lostOwnership() - - public void lostOwnership(Clipboard clipboard, Transferable contents) { - // Nothing right now. - }//}}} - - //}}} - - //{{{ Private static members - private static final ImageIcon m_elementIcon = new ImageIcon(DefaultView.class.getResource("/net/sourceforge/jsxe/icons/Element.png"), "Element"); - private static final ImageIcon m_textIcon = new ImageIcon(DefaultView.class.getResource("/net/sourceforge/jsxe/icons/Text.png"), "Text"); - private static final ImageIcon m_CDATAIcon = new ImageIcon(DefaultView.class.getResource("/net/sourceforge/jsxe/icons/CDATA.png"), "CDATA"); - private static final ImageIcon m_commentIcon = new ImageIcon(DefaultView.class.getResource("/net/sourceforge/jsxe/icons/Comment.png"), "Comment"); - // private static final ImageIcon m_externalEntityIcon = new ImageIcon(DefaultView.class.getResource("/net/sourceforge/jsxe/icons/ExternalEntity.png"), "External Entity"); - private static final ImageIcon m_internalEntityIcon = new ImageIcon(DefaultView.class.getResource("/net/sourceforge/jsxe/icons/InternalEntity.png"), "Internal Entity"); - - private static final int m_AUTOSCROLL_MARGIN = 12; - //}}} - - //{{{ Private members - - //{{{ refreshExpandedStates() - /** - * Refreshes the expanded states of all the node pointed to by - * the treepath and all nodes below it. Used after a drag and - * drop is done because the JTree uses TreePaths to keep track - * of expanded states. When a drag and drop is done the - * path is broken and the expanded states are lost. - */ - private void refreshExpandedStates(TreePath path) { - AdapterNode node = (AdapterNode)path.getLastPathComponent(); - boolean expandedState = isExpanded(node); - if (node.childCount() > 0) { - expandPath(path); //expand all nodes out - //still have to set expanded states - int children = node.childCount(); - for (int i=0;i < children; i++) { - TreePath newPath = path.pathByAddingChild(node.child(i)); - refreshExpandedStates(newPath); - } - if (expandedState) { //close non-expanded nodes - expandPath(path); - } else { - collapsePath(path); - } - } - }//}}} - - //{{{ toString() - /** - * Creates the string that will be displayed in the tree node - * @param showattrs "ID only", "All" or "None" - */ - private static String toString(AdapterNode node) { - StringBuffer s = new StringBuffer(); - if (node.getNodeType() == Node.DOCUMENT_NODE) - return "Document Root"; - String nodeName = node.getNodeName(); - if (! nodeName.startsWith("#")) { - s.append(nodeName); - if (node.getNodeType() == AdapterNode.ELEMENT_NODE) { - NamedNodeMap attributes = node.getAttributes(); - ElementDecl decl = node.getElementDecl(); - XMLDocument document = node.getOwnerDocument(); - String showAttrs = document.getProperty(DefaultView.SHOW_ATTRIBUTES); - for (int i=0; i<attributes.getLength(); i++) { - Node attr = attributes.item(i); - ElementDecl.AttributeDecl attrDecl = (decl != null) ? decl.getAttribute(attr.getNodeName()) : null; - if (showAttrs.equals("All") || - (showAttrs.equals("ID only") && - ((attr.getNodeName().equalsIgnoreCase("id") || - (attrDecl != null && attrDecl.type.equals("ID")))))) - { - s.append(' '+attr.getNodeName() + "=\"" + attr.getNodeValue() + '"'); - } - } - } - } - if (s.length()==0) { - if (node.getNodeValue() != null) { - String t = node.getNodeValue().trim(); - int x = t.indexOf("\n"); - if (x >= 0) { - t = t.substring(0, x); - } - if (t.length() > 50) { - t = t.substring(0, 50) + "..."; - } - s.append(t); - } - } - return s.toString(); - }//}}} - - //{{{ TreePopupListener class - //TODO: rework this class - private class TreePopupListener extends MouseAdapter { - - //{{{ mousePressed() - - public void mousePressed(MouseEvent e) { - maybeShowPopup(e); - }//}}} - - //{{{ mouseReleased() - - public void mouseReleased(MouseEvent e) { - maybeShowPopup(e); - }//}}} - - //{{{ maybeShowPopup() - - private void maybeShowPopup(MouseEvent e) { - TreePath selPath = getPathForLocation(e.getX(), e.getY()); - if (e.isPopupTrigger() && selPath != null) { - setSelectionPath(selPath); - - //Don't want to interact with AdapterNodes too much. Maybe change this. - AdapterNode selectedNode = ((AdapterNode)selPath.getLastPathComponent()); - XMLDocument ownerDocument = selectedNode.getOwnerDocument(); - - JMenuItem popupMenuItem; - JMenu addNodeItem = new JMenu(Messages.getMessage("common.add")); - JPopupMenu popup = new JPopupMenu(); - boolean showpopup = false; - boolean addNodeShown = false; - - if (selectedNode.getNodeType() == Node.ELEMENT_NODE) { - - JMenu addElement = new EnhancedMenu(Messages.getMessage("xml.element"), 20); - addNodeItem.add(addElement); - - addElement.add(jsXe.getAction("treeview.add.element.node")); - Iterator allowedElements = selectedNode.getAllowedElements().iterator(); - while (allowedElements.hasNext()) { - ElementDecl decl = (ElementDecl)allowedElements.next(); - addElement.add(new AddNodeAction(decl, decl.name)); - } - - //Add the allowed entities even if no matter what - - JMenu addEntity = new EnhancedMenu(Messages.getMessage("xml.entity.reference"), 20); - addNodeItem.add(addEntity); - - Iterator allowedEntities = ownerDocument.getAllowedEntities().iterator(); - while (allowedEntities.hasNext()) { - EntityDecl decl = (EntityDecl)allowedEntities.next(); - popupMenuItem = new JMenuItem(new AddNodeAction(decl.name, decl.name, decl.value, AdapterNode.ENTITY_REFERENCE_NODE)); - addEntity.add(popupMenuItem); - } - - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.add.text.node")); - popupMenuItem.setText(Messages.getMessage("xml.text")); - addNodeItem.add(popupMenuItem); - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.add.cdata.node")); - popupMenuItem.setText(Messages.getMessage("xml.cdata")); - addNodeItem.add(popupMenuItem); - - // popupMenuItem = new JMenuItem(new AddNodeAction("New_Entity", "", Node.ENTITY_REFERENCE_NODE)); - // addNodeItem.add(popupMenuItem); - addNodeShown = true; - showpopup = true; - } - - if (selectedNode.getNodeType() == Node.DOCUMENT_NODE) { - if (ownerDocument.getDocType() == null) { - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.add.doctype.node")); - popupMenuItem.setText(Messages.getMessage("xml.doctypedef")); - addNodeItem.add(popupMenuItem); - showpopup = true; - } - } - - if (selectedNode.getNodeType() == Node.DOCUMENT_NODE || selectedNode.getNodeType() == Node.ELEMENT_NODE) { - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.add.processing.instruction.node")); - popupMenuItem.setText(Messages.getMessage("xml.processing.instruction")); - addNodeItem.add(popupMenuItem); - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.add.comment.node")); - popupMenuItem.setText(Messages.getMessage("xml.comment")); - addNodeItem.add(popupMenuItem); - addNodeShown = true; - showpopup = true; - } - - if (addNodeShown) { - popup.add(addNodeItem); - } - - //Add the edit node action - if (selectedNode.getNodeType() == Node.ELEMENT_NODE && ownerDocument.getElementDecl(selectedNode.getNodeName()) != null) { - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.edit.node")); - popup.add(popupMenuItem); - showpopup = true; - } - - if (selectedNode.getNodeType() == Node.ELEMENT_NODE || selectedNode.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) { - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.rename.node")); - popup.add(popupMenuItem); - showpopup = true; - } - //if the node is not the document, document type, or the document root. - if (selectedNode.getNodeType() != Node.DOCUMENT_NODE && - selectedNode.getNodeType() != Node.DOCUMENT_TYPE_NODE && - !(selectedNode.getNodeType() == Node.ELEMENT_NODE && - selectedNode.getParentNode().getNodeType() == Node.DOCUMENT_NODE)) - { - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.remove.node")); - popup.add(popupMenuItem); - showpopup = true; - } - - if (selectedNode.getNodeType() != Node.DOCUMENT_NODE && - selectedNode.getNodeType() != Node.DOCUMENT_TYPE_NODE) - { - popup.addSeparator(); - if(!(selectedNode.getNodeType() == Node.ELEMENT_NODE && - selectedNode.getParentNode().getNodeType() == Node.DOCUMENT_NODE)) - { - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.cut.node")); - popup.add(popupMenuItem); - } - - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.copy.node")); - popup.add(popupMenuItem); - - if (selectedNode.getNodeType() == Node.ELEMENT_NODE) { - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.paste.node")); - popup.add(popupMenuItem); - } - showpopup = true; - } - - if (showpopup) { - popup.show(e.getComponent(), e.getX(), e.getY()); - } - } - }//}}} - - }//}}} - - //{{{ DefaultViewTreeCellRenderer class - - private class DefaultViewTreeCellRenderer extends DefaultTreeCellRenderer { - - //{{{ DefaultViewTreeCellRenderer constructor - - DefaultViewTreeCellRenderer() { - m_defaultLeafIcon = getLeafIcon(); - m_defaultOpenIcon = getOpenIcon(); - m_defaultClosedIcon = getClosedIcon(); - m_defaultBackgroundSelectionColor = this.backgroundSelectionColor; - }//}}} - - //{{{ getTreeCellRendererComponent() - - public Component getTreeCellRendererComponent(JTree tree, - Object value, boolean selected, boolean expanded, - boolean leaf, int row, boolean hasFocus) - { - - int type = -1; - try { - AdapterNode node = (AdapterNode)value; - type = node.getNodeType(); - setText(DefaultViewTree.toString(node)); - } catch (ClassCastException e) {} - - this.selected = selected; - if (value != null && m_dragOverTarget == value) { - this.selected = true; - backgroundSelectionColor = m_dragSelectionColor; - } else { - backgroundSelectionColor = m_defaultBackgroundSelectionColor; - } - - switch (type) { - case Node.ELEMENT_NODE: - setIcon(m_elementIcon); - setLeafIcon(m_elementIcon); - setOpenIcon(m_elementIcon); - setClosedIcon(m_elementIcon); - setToolTipText(Messages.getMessage("xml.element")); - break; - case Node.TEXT_NODE: - setIcon(m_textIcon); - setLeafIcon(m_textIcon); - setOpenIcon(m_textIcon); - setClosedIcon(m_textIcon); - setToolTipText(Messages.getMessage("xml.text")); - break; - case Node.CDATA_SECTION_NODE: - setIcon(m_CDATAIcon); - setLeafIcon(m_CDATAIcon); - setOpenIcon(m_CDATAIcon); - setClosedIcon(m_CDATAIcon); - setToolTipText(Messages.getMessage("xml.cdata")); - break; - case Node.COMMENT_NODE: - setIcon(m_commentIcon); - setLeafIcon(m_commentIcon); - setOpenIcon(m_commentIcon); - setClosedIcon(m_commentIcon); - setToolTipText(Messages.getMessage("xml.comment")); - break; - case Node.ENTITY_REFERENCE_NODE: - setIcon(m_internalEntityIcon); - setLeafIcon(m_internalEntityIcon); - setOpenIcon(m_internalEntityIcon); - setClosedIcon(m_internalEntityIcon); - setToolTipText(Messages.getMessage("xml.entity.reference")); - break; - case Node.DOCUMENT_NODE: - setIcon(m_defaultClosedIcon); - setLeafIcon(m_defaultLeafIcon); - setOpenIcon(m_defaultOpenIcon); - setClosedIcon(m_defaultClosedIcon); - setToolTipText(Messages.getMessage("xml.document")); - break; - case Node.PROCESSING_INSTRUCTION_NODE: - setIcon(m_defaultLeafIcon); - setLeafIcon(m_defaultLeafIcon); - setOpenIcon(m_defaultLeafIcon); - setClosedIcon(m_defaultLeafIcon); - setToolTipText(Messages.getMessage("xml.processing.instruction")); - break; - case Node.DOCUMENT_TYPE_NODE: - setIcon(m_defaultLeafIcon); - setLeafIcon(m_defaultLeafIcon); - setOpenIcon(m_defaultLeafIcon); - setClosedIcon(m_defaultLeafIcon); - setToolTipText(Messages.getMessage("xml.doctypedef")); - break; - default: - if (leaf) { - setIcon(m_defaultLeafIcon); - } else { - if (expanded) { - setIcon(m_defaultOpenIcon); - } else { - setIcon(m_defaultClosedIcon); - } - } - - setLeafIcon(m_defaultLeafIcon); - setOpenIcon(m_defaultOpenIcon); - setClosedIcon(m_defaultClosedIcon); - setToolTipText("Unknown node"); - break; - } - - return this; - }//}}} - - //{{{ Private members - - private Icon m_defaultLeafIcon; - private Icon m_defaultOpenIcon; - private Icon m_defaultClosedIcon; - private Color m_defaultBackgroundSelectionColor; - //}}} - - }//}}} - - //{{{ ElementTreeCellRenderer class - - private class ElementTreeCellRenderer extends DefaultTreeCellRenderer { - - //{{{ ElementTreeCellRenderer constructor - - public ElementTreeCellRenderer() { - m_defaultLe... [truncated message content] |