Revision: 17456
http://sourceforge.net/p/gate/code/17456
Author: markagreenwood
Date: 2014-02-26 20:06:30 +0000 (Wed, 26 Feb 2014)
Log Message:
-----------
okay so now I really hate spaghetti
Added Paths:
-----------
gate/trunk/src/main/com/ontotext/gate/vr/MappingTreeView.java
Removed Paths:
-------------
plugins/trunk/obsolete/GAZE/src/com/ontotext/gate/vr/MappingTreeView.java
Copied: gate/trunk/src/main/com/ontotext/gate/vr/MappingTreeView.java (from rev
17455,
plugins/trunk/obsolete/GAZE/src/com/ontotext/gate/vr/MappingTreeView.java)
===================================================================
--- gate/trunk/src/main/com/ontotext/gate/vr/MappingTreeView.java
(rev 0)
+++ gate/trunk/src/main/com/ontotext/gate/vr/MappingTreeView.java
2014-02-26 20:06:30 UTC (rev 17456)
@@ -0,0 +1,232 @@
+package com.ontotext.gate.vr;
+
+import gate.creole.gazetteer.MappingDefinition;
+import gate.creole.gazetteer.MappingNode;
+import gate.creole.ontology.OClass;
+import gate.gui.MainFrame;
+import gate.util.LazyProgrammerException;
+
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.Collections;
+import java.util.List;
+import java.util.Vector;
+
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPopupMenu;
+import javax.swing.JTree;
+import javax.swing.SwingUtilities;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.TreePath;
+import javax.swing.tree.TreeSelectionModel;
+
+
+
+/**
+ * Mapping Tree View extends {@link javax.swing.JTree}
+ * in order to represent the mapping information.
+ * To be used with Gaze.
+ * borislav popov 18/04/2002 */
+public class MappingTreeView extends JTree {
+
+ private static final long serialVersionUID = 3257568420999410744L;
+
+ /**the name of the default gazetteer icon*/
+ private final static String GAZ_ICON = "lr";
+
+ /**Mapping Node Edit Action */
+ private final static int EDIT_ACTION = 1;
+ /**Mapping Node Insert Action */
+ private final static int INSERT_ACTION = 2;
+ /**Mapping Node Remove Action */
+ private final static int REMOVE_ACTION = 3;
+
+ /** reference to the mapping definition represented by this view */
+ private MappingDefinition mapping = null;
+
+ /** reference to the Gaze VR */
+ private Gaze gaze = null;
+
+ /**mapping popup menu */
+ private JPopupMenu pupMenu = new JPopupMenu();
+
+ /**insert popup action*/
+ private JMenuItem insertPuP = new JMenuItem("insert mapping");
+ /**remove popup action*/
+ private JMenuItem removePuP = new JMenuItem("remove mapping");
+
+ /**@param model the tree model
+ * @param mappingDef the mapping definition
+ * @param gazeVR gaze (gazetteer editor) visual resource */
+ public MappingTreeView(OntoTreeModel model,
+ MappingDefinition mappingDef, Gaze gazeVR) {
+
+ super(model);
+
+ if (null == mappingDef)
+ throw new LazyProgrammerException(
+ "Mapping Def cannot be null on contructing MappingTreeView");
+
+ if (null == gazeVR)
+ throw new LazyProgrammerException(
+ "Gazetteer Editor - Gaze VR - cannot be null on contructing
MappingTreeView");
+
+ mapping = mappingDef;
+ gaze = gazeVR;
+
+ init();
+
+ }// constructor
+
+ /** Initialization */
+ private void init() {
+ getSelectionModel().setSelectionMode(
+ TreeSelectionModel.SINGLE_TREE_SELECTION);
+ DefaultTreeCellRenderer renderer = new MappingTreeCR();
+ renderer.setLeafIcon(renderer.getDefaultClosedIcon());
+ this.setCellRenderer(renderer);
+
+ // listeners
+ addMouseListener(new MyMouseAdapter());
+
+ removePuP.addActionListener(new RemoveAL());
+ insertPuP.addActionListener(new InsertAL());
+
+ pupMenu.add(insertPuP);
+ pupMenu.add(removePuP);
+
+ } // init
+
+ /** Mapping Tree Cell Renderer distinguishes nodes, originating from
ontology classes from
+ * nodes, originating from gazetteer lists. */
+ class MappingTreeCR extends DefaultTreeCellRenderer {
+
+ private static final long serialVersionUID = 3546924666926085169L;
+
+ /**
+ * Sets the value of the current tree cell to <code>value</code>.
+ * If <code>selected</code> is true, the cell will be drawn as if
+ * selected. If <code>expanded</code> is true the node is currently
+ * expanded and if <code>leaf</code> is true the node represets a
+ * leaf anf if <code>hasFocus</code> is true the node currently has
+ * focus. <code>tree</code> is the JTree the receiver is being
+ * configured for.
+ * Returns the Component that the renderer uses to draw the value.
+ *
+ * @return Component that the renderer uses to draw the value.
+ */
+ public Component getTreeCellRendererComponent(JTree tree, Object value,
+ boolean selected, boolean expanded,
+ boolean leaf, int row, boolean hasFocus) {
+ super.getTreeCellRendererComponent(
+ tree, value, selected, expanded, leaf, row, hasFocus);
+
+ if ( value instanceof ClassNode ) {
+ ClassNode cn = (ClassNode) value;
+ Object source = cn.getSource();
+ if ( source instanceof MappingNode ) {
+ setIcon(MainFrame.getIcon(GAZ_ICON));
+ } // if gaz list
+ } // if node
+ return this;
+ } // getTreeCellRendererComponent()
+
+ } // class MappingTreeCR
+
+ /**The mouse adapter listens to the entire mouse activity and invokes a
popup menu if
+ * right click. */
+ class MyMouseAdapter extends MouseAdapter{
+
+ public MyMouseAdapter(){
+ }
+
+ public void mouseClicked(MouseEvent e){
+ TreePath path=MappingTreeView.this.getSelectionPath();
+
+ ClassNode node =null;
+ if (SwingUtilities.isLeftMouseButton(e)) {
+ if (2 == e.getClickCount()) {
+ if( path != null){
+ node = (ClassNode) path.getLastPathComponent();
+ if ( node.getSource() instanceof MappingNode ) {
+ MappingNode mn = (MappingNode)node.getSource();
+ gaze.displayList(mn.getList());
+ }
+ } // if !=null
+ } // double click
+ } // left
+
+ if(SwingUtilities.isRightMouseButton(e)){
+ if( path != null){
+ node = (ClassNode) path.getLastPathComponent();
+ if ( node.getSource() instanceof MappingNode ) {
+ removePuP.setEnabled(true);
+ insertPuP.setEnabled(false);
+ } else {
+ removePuP.setEnabled(false);
+ insertPuP.setEnabled(true);
+ }
+ pupMenu.show(MappingTreeView.this,e.getX(),e.getY());
+ }
+ }
+ }
+ } //class MyMouseAdapter
+
+
+ /*Action Listener of the remove pop up menu item */
+ class RemoveAL implements ActionListener{
+ public void actionPerformed(ActionEvent e) {
+ ClassNode node =
(ClassNode)MappingTreeView.this.getLastSelectedPathComponent();
+ Object source = node.getSource();
+ if (source instanceof MappingNode) {
+ TreePath pp =
MappingTreeView.this.getAnchorSelectionPath().getParentPath();
+ if (null!=pp) {
+ ClassNode pNode = (ClassNode)pp.getLastPathComponent();
+ Vector<ClassNode> kids = pNode.children();
+ kids.remove(node);
+ pNode.setChildren(kids);
+ mapping.remove(source);
+ MappingTreeView.this.updateUI();
+ gaze.updateMappingUI();
+ } // pp ! null
+ }// if map node
+ } // actionPerformed()
+ } // class RemoveAL
+
+
+ /*Action Listener of the insert pop up menu item */
+ class InsertAL implements ActionListener {
+ public void actionPerformed(ActionEvent e) {
+ ClassNode node =
(ClassNode)MappingTreeView.this.getLastSelectedPathComponent();
+ Object source = node.getSource();
+ if (source instanceof OClass) {
+ List lists = gaze.getLists();
+ Collections.sort(lists);
+
+ Object result = JOptionPane.showInputDialog(MappingTreeView.this,
+ "Map selected ontology class to a gazetteer list:",
+ "Insert Mapping Node",
+ JOptionPane.PLAIN_MESSAGE,
+ null,lists.toArray(),null);
+ if (null != result) {
+ OClass oc = (OClass) source;
+ MappingNode mn = new MappingNode((String)result,
+ oc.getOntology().getURL().toString(),
+ node.toString());
+ mapping.add(mn);
+ ClassNode cn = new ClassNode(mn);
+ Vector<ClassNode> kids = node.children();
+ kids.add(cn);
+ MappingTreeView.this.updateUI();
+ gaze.updateMappingUI();
+ } // null!=result
+ }// if map node
+ } // actionPerformed()
+ } // class InsertAL
+
+
+} //MappingTreeView
\ No newline at end of file
Property changes on:
gate/trunk/src/main/com/ontotext/gate/vr/MappingTreeView.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: svn:mergeinfo
## -0,0 +1,6 ##
+/gate/branches/cl-experiment/src/main/com/ontotext/gate/vr/MappingTreeView.java:15466-15613
+/gate/branches/new-ontology-api/src/main/com/ontotext/gate/vr/MappingTreeView.java:10584-11598
+/gate/branches/release-7.0/src/main/com/ontotext/gate/vr/MappingTreeView.java:15335-15398
+/gate/branches/sawdust/src/main/com/ontotext/gate/vr/MappingTreeView.java:17055-17079
+/gate/tags/release-7.0/src/main/com/ontotext/gate/vr/MappingTreeView.java:15399-15407
+/gate/trunk/src/main/com/ontotext/gate/vr/MappingTreeView.java:3-7
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Deleted:
plugins/trunk/obsolete/GAZE/src/com/ontotext/gate/vr/MappingTreeView.java
===================================================================
--- plugins/trunk/obsolete/GAZE/src/com/ontotext/gate/vr/MappingTreeView.java
2014-02-26 20:06:04 UTC (rev 17455)
+++ plugins/trunk/obsolete/GAZE/src/com/ontotext/gate/vr/MappingTreeView.java
2014-02-26 20:06:30 UTC (rev 17456)
@@ -1,232 +0,0 @@
-package com.ontotext.gate.vr;
-
-import gate.creole.gazetteer.MappingDefinition;
-import gate.creole.gazetteer.MappingNode;
-import gate.creole.ontology.OClass;
-import gate.gui.MainFrame;
-import gate.util.LazyProgrammerException;
-
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.util.Collections;
-import java.util.List;
-import java.util.Vector;
-
-import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.swing.JPopupMenu;
-import javax.swing.JTree;
-import javax.swing.SwingUtilities;
-import javax.swing.tree.DefaultTreeCellRenderer;
-import javax.swing.tree.TreePath;
-import javax.swing.tree.TreeSelectionModel;
-
-
-
-/**
- * Mapping Tree View extends {@link javax.swing.JTree}
- * in order to represent the mapping information.
- * To be used with Gaze.
- * borislav popov 18/04/2002 */
-public class MappingTreeView extends JTree {
-
- private static final long serialVersionUID = 3257568420999410744L;
-
- /**the name of the default gazetteer icon*/
- private final static String GAZ_ICON = "lr";
-
- /**Mapping Node Edit Action */
- private final static int EDIT_ACTION = 1;
- /**Mapping Node Insert Action */
- private final static int INSERT_ACTION = 2;
- /**Mapping Node Remove Action */
- private final static int REMOVE_ACTION = 3;
-
- /** reference to the mapping definition represented by this view */
- private MappingDefinition mapping = null;
-
- /** reference to the Gaze VR */
- private Gaze gaze = null;
-
- /**mapping popup menu */
- private JPopupMenu pupMenu = new JPopupMenu();
-
- /**insert popup action*/
- private JMenuItem insertPuP = new JMenuItem("insert mapping");
- /**remove popup action*/
- private JMenuItem removePuP = new JMenuItem("remove mapping");
-
- /**@param model the tree model
- * @param mappingDef the mapping definition
- * @param gazeVR gaze (gazetteer editor) visual resource */
- public MappingTreeView(OntoTreeModel model,
- MappingDefinition mappingDef, Gaze gazeVR) {
-
- super(model);
-
- if (null == mappingDef)
- throw new LazyProgrammerException(
- "Mapping Def cannot be null on contructing MappingTreeView");
-
- if (null == gazeVR)
- throw new LazyProgrammerException(
- "Gazetteer Editor - Gaze VR - cannot be null on contructing
MappingTreeView");
-
- mapping = mappingDef;
- gaze = gazeVR;
-
- init();
-
- }// constructor
-
- /** Initialization */
- private void init() {
- getSelectionModel().setSelectionMode(
- TreeSelectionModel.SINGLE_TREE_SELECTION);
- DefaultTreeCellRenderer renderer = new MappingTreeCR();
- renderer.setLeafIcon(renderer.getDefaultClosedIcon());
- this.setCellRenderer(renderer);
-
- // listeners
- addMouseListener(new MyMouseAdapter());
-
- removePuP.addActionListener(new RemoveAL());
- insertPuP.addActionListener(new InsertAL());
-
- pupMenu.add(insertPuP);
- pupMenu.add(removePuP);
-
- } // init
-
- /** Mapping Tree Cell Renderer distinguishes nodes, originating from
ontology classes from
- * nodes, originating from gazetteer lists. */
- class MappingTreeCR extends DefaultTreeCellRenderer {
-
- private static final long serialVersionUID = 3546924666926085169L;
-
- /**
- * Sets the value of the current tree cell to <code>value</code>.
- * If <code>selected</code> is true, the cell will be drawn as if
- * selected. If <code>expanded</code> is true the node is currently
- * expanded and if <code>leaf</code> is true the node represets a
- * leaf anf if <code>hasFocus</code> is true the node currently has
- * focus. <code>tree</code> is the JTree the receiver is being
- * configured for.
- * Returns the Component that the renderer uses to draw the value.
- *
- * @return Component that the renderer uses to draw the value.
- */
- public Component getTreeCellRendererComponent(JTree tree, Object value,
- boolean selected, boolean expanded,
- boolean leaf, int row, boolean hasFocus) {
- super.getTreeCellRendererComponent(
- tree, value, selected, expanded, leaf, row, hasFocus);
-
- if ( value instanceof ClassNode ) {
- ClassNode cn = (ClassNode) value;
- Object source = cn.getSource();
- if ( source instanceof MappingNode ) {
- setIcon(MainFrame.getIcon(GAZ_ICON));
- } // if gaz list
- } // if node
- return this;
- } // getTreeCellRendererComponent()
-
- } // class MappingTreeCR
-
- /**The mouse adapter listens to the entire mouse activity and invokes a
popup menu if
- * right click. */
- class MyMouseAdapter extends MouseAdapter{
-
- public MyMouseAdapter(){
- }
-
- public void mouseClicked(MouseEvent e){
- TreePath path=MappingTreeView.this.getSelectionPath();
-
- ClassNode node =null;
- if (SwingUtilities.isLeftMouseButton(e)) {
- if (2 == e.getClickCount()) {
- if( path != null){
- node = (ClassNode) path.getLastPathComponent();
- if ( node.getSource() instanceof MappingNode ) {
- MappingNode mn = (MappingNode)node.getSource();
- gaze.displayList(mn.getList());
- }
- } // if !=null
- } // double click
- } // left
-
- if(SwingUtilities.isRightMouseButton(e)){
- if( path != null){
- node = (ClassNode) path.getLastPathComponent();
- if ( node.getSource() instanceof MappingNode ) {
- removePuP.setEnabled(true);
- insertPuP.setEnabled(false);
- } else {
- removePuP.setEnabled(false);
- insertPuP.setEnabled(true);
- }
- pupMenu.show(MappingTreeView.this,e.getX(),e.getY());
- }
- }
- }
- } //class MyMouseAdapter
-
-
- /*Action Listener of the remove pop up menu item */
- class RemoveAL implements ActionListener{
- public void actionPerformed(ActionEvent e) {
- ClassNode node =
(ClassNode)MappingTreeView.this.getLastSelectedPathComponent();
- Object source = node.getSource();
- if (source instanceof MappingNode) {
- TreePath pp =
MappingTreeView.this.getAnchorSelectionPath().getParentPath();
- if (null!=pp) {
- ClassNode pNode = (ClassNode)pp.getLastPathComponent();
- Vector<ClassNode> kids = pNode.children();
- kids.remove(node);
- pNode.setChildren(kids);
- mapping.remove(source);
- MappingTreeView.this.updateUI();
- gaze.updateMappingUI();
- } // pp ! null
- }// if map node
- } // actionPerformed()
- } // class RemoveAL
-
-
- /*Action Listener of the insert pop up menu item */
- class InsertAL implements ActionListener {
- public void actionPerformed(ActionEvent e) {
- ClassNode node =
(ClassNode)MappingTreeView.this.getLastSelectedPathComponent();
- Object source = node.getSource();
- if (source instanceof OClass) {
- List lists = gaze.getLists();
- Collections.sort(lists);
-
- Object result = JOptionPane.showInputDialog(MappingTreeView.this,
- "Map selected ontology class to a gazetteer list:",
- "Insert Mapping Node",
- JOptionPane.PLAIN_MESSAGE,
- null,lists.toArray(),null);
- if (null != result) {
- OClass oc = (OClass) source;
- MappingNode mn = new MappingNode((String)result,
- oc.getOntology().getURL().toString(),
- node.toString());
- mapping.add(mn);
- ClassNode cn = new ClassNode(mn);
- Vector<ClassNode> kids = node.children();
- kids.add(cn);
- MappingTreeView.this.updateUI();
- gaze.updateMappingUI();
- } // null!=result
- }// if map node
- } // actionPerformed()
- } // class InsertAL
-
-
-} //MappingTreeView
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs