Revision: 17515
http://sourceforge.net/p/gate/code/17515
Author: markagreenwood
Date: 2014-03-03 18:05:30 +0000 (Mon, 03 Mar 2014)
Log Message:
-----------
simplified by removing all the drag-and-drop code as it was all commented out
and not working anyway (helpfully it gave a message saying would be implemented
soon)
Modified Paths:
--------------
gate/trunk/src/main/gate/gui/ontology/OntologyEditor.java
Modified: gate/trunk/src/main/gate/gui/ontology/OntologyEditor.java
===================================================================
--- gate/trunk/src/main/gate/gui/ontology/OntologyEditor.java 2014-03-03
16:53:18 UTC (rev 17514)
+++ gate/trunk/src/main/gate/gui/ontology/OntologyEditor.java 2014-03-03
18:05:30 UTC (rev 17515)
@@ -16,40 +16,67 @@
import gate.Resource;
import gate.creole.AbstractVisualResource;
import gate.creole.ResourceInstantiationException;
-import gate.creole.ontology.*;
-import gate.event.*;
-import gate.gui.*;
+import gate.creole.ontology.AnnotationProperty;
+import gate.creole.ontology.DatatypeProperty;
+import gate.creole.ontology.InvalidValueException;
+import gate.creole.ontology.Literal;
+import gate.creole.ontology.OClass;
+import gate.creole.ontology.OConstants;
+import gate.creole.ontology.OInstance;
+import gate.creole.ontology.ONodeID;
+import gate.creole.ontology.OResource;
+import gate.creole.ontology.ObjectProperty;
+import gate.creole.ontology.Ontology;
+import gate.creole.ontology.OntologyModificationListener;
+import gate.creole.ontology.RDFProperty;
+import gate.event.GateEvent;
+import gate.gui.MainFrame;
+import gate.gui.ResizableVisualResource;
import gate.swing.XJTable;
-import java.awt.*;
-import java.awt.datatransfer.Transferable;
-import java.awt.dnd.DnDConstants;
-import java.awt.dnd.DragGestureEvent;
-import java.awt.dnd.DragGestureListener;
-import java.awt.dnd.DragGestureRecognizer;
-import java.awt.dnd.DragSource;
-import java.awt.dnd.DragSourceContext;
-import java.awt.dnd.DragSourceDragEvent;
-import java.awt.dnd.DragSourceDropEvent;
-import java.awt.dnd.DragSourceEvent;
-import java.awt.dnd.DragSourceListener;
-import java.awt.dnd.DropTarget;
-import java.awt.dnd.DropTargetDragEvent;
-import java.awt.dnd.DropTargetDropEvent;
-import java.awt.dnd.DropTargetEvent;
-import java.awt.dnd.DropTargetListener;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
-import javax.swing.*;
+import java.util.Set;
+
+import javax.swing.AbstractAction;
+import javax.swing.JButton;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JLabel;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JTable;
+import javax.swing.JToolBar;
+import javax.swing.JTree;
+import javax.swing.ListSelectionModel;
+import javax.swing.SwingUtilities;
+import javax.swing.ToolTipManager;
import javax.swing.border.TitledBorder;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
-import javax.swing.tree.*;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreePath;
+import javax.swing.tree.TreeSelectionModel;
/**
@@ -121,7 +148,7 @@
rootNode = new DefaultMutableTreeNode(null, true);
treeModel = new DefaultTreeModel(rootNode);
- tree = new DnDJTree(treeModel);
+ tree = new JTree(treeModel);
tree.setRootVisible(false);
tree.setShowsRootHandles(true);
tree.setCellRenderer(new OntoTreeCellRenderer());
@@ -137,7 +164,7 @@
propertyRootNode = new DefaultMutableTreeNode(null, true);
propertyTreeModel = new DefaultTreeModel(propertyRootNode);
- propertyTree = new DnDJTree(propertyTreeModel);
+ propertyTree = new JTree(propertyTreeModel);
propertyTree.setRootVisible(false);
propertyTree.setShowsRootHandles(true);
propertyTree.setCellRenderer(new OntoTreeCellRenderer());
@@ -2050,205 +2077,6 @@
}
}
- class DnDJTree extends JTree implements DragGestureListener,
- DropTargetListener, DragSourceListener {
-
- /** Variables needed for DnD */
- private DragSource dragSource = null;
-
- private DragSourceContext dragSourceContext = null;
-
- private DefaultMutableTreeNode selectedNode = null;
-
- private TreePath selectedTreePath = null;
-
- /**
- * Constructor
- *
- * @param model tree model
- */
- public DnDJTree(TreeModel model) {
- super(model);
- dragSource = DragSource.getDefaultDragSource();
- DragGestureRecognizer dgr = dragSource
- .createDefaultDragGestureRecognizer(this,
- DnDConstants.ACTION_MOVE, this);
- DropTarget dropTarget = new DropTarget(this, this);
- }
-
- /** DragGestureListener interface method */
- public void dragGestureRecognized(DragGestureEvent e) {
- // Get the selected node
- if(selectedNodes.isEmpty()) {
- selectedNode = null;
- selectedTreePath = null;
- return;
- }
-
- selectedNode = selectedNodes.get(0);
- selectedTreePath = new TreePath(selectedNode.getPath());
- DefaultMutableTreeNode dragNode = selectedNode;
-
- if(dragNode != null) {
-
- // Get the Transferable Object
- Transferable transferable = (Transferable)dragNode.getUserObject();
-
- // Select the appropriate cursor;
- Cursor cursor = DragSource.DefaultCopyNoDrop;
- int action = e.getDragAction();
- if(action == DnDConstants.ACTION_MOVE)
- cursor = DragSource.DefaultMoveNoDrop;
-
- // begin the drag
- dragSource.startDrag(e, cursor, transferable, this);
- }
- }
-
- /** DragSourceListener interface method */
- public void dragDropEnd(DragSourceDropEvent dsde) {
- }
-
- /** DragSourceListener interface method */
- public void dragEnter(DragSourceDragEvent dsde) {
- }
-
- /** DragSourceListener interface method */
- public void dragOver(DragSourceDragEvent dsde) {
- }
-
- /** DragSourceListener interface method */
- public void dropActionChanged(DragSourceDragEvent dsde) {
- }
-
- /** DragSourceListener interface method */
- public void dragExit(DragSourceEvent dsde) {
- }
-
- /**
- * DropTargetListener interface method - What we do when drag is
- * released
- */
- public void drop(DropTargetDropEvent e) {
- /*
- * Transferable tr = e.getTransferable();
- *
- * DefaultMutableTreeNode node =
- * (DefaultMutableTreeNode)selectedTreePath
- * .getLastPathComponent(); OResource source =
- * ((OResourceNode)node.getUserObject()).getResource();
- *
- * if(source instanceof OInstance) { e.rejectDrop();
- * SwingUtilities.invokeLater(new Runnable() { public void run() {
- * JOptionPane.showMessageDialog(MainFrame.getInstance(),
- * "Instances are not allowed to be moved!", "Error Dialog",
- * JOptionPane.ERROR_MESSAGE); } }); return; } // now check if the
- * class to be moved under the class is not a // super class of
- * the later. // get new parent node Point loc = e.getLocation();
- * TreePath destinationPath = getPathForLocation(loc.x, loc.y);
- * if(destinationPath == null) { e.rejectDrop(); return; }
- *
- * OResource target =
- * ((OResourceNode)((DefaultMutableTreeNode)destinationPath
- * .getLastPathComponent()).getUserObject()).getResource();
- *
- * if(target instanceof OInstance) { e.rejectDrop();
- * SwingUtilities.invokeLater(new Runnable() { public void run() {
- * JOptionPane.showMessageDialog(MainFrame.getInstance(), "Invalid
- * Operation!", "Error Dialog", JOptionPane.ERROR_MESSAGE); } });
- * return; }
- *
- * if(source instanceof OClass && target instanceof OClass) {
- * if(((OClass)target).isSubClassOf((OClass)source,
- * OConstants.TRANSITIVE_CLOSURE)) { e.rejectDrop();
- * SwingUtilities.invokeLater(new Runnable() { public void run() {
- * JOptionPane.showMessageDialog(MainFrame.getInstance(), "A super
- * class can not be set as a sub class!", "Error Dialog",
- * JOptionPane.ERROR_MESSAGE); } }); return; } }
- *
- * if(source instanceof RDFProperty && target instanceof
- * RDFProperty) {
- * if(((RDFProperty)target).isSubPropertyOf((RDFProperty)source,
- * OConstants.TRANSITIVE_CLOSURE)) { e.rejectDrop();
- * SwingUtilities.invokeLater(new Runnable() { public void run() {
- * JOptionPane.showMessageDialog(MainFrame.getInstance(), "A super
- * property can not be set as a sub property!", "Error Dialog",
- * JOptionPane.ERROR_MESSAGE); } });
- *
- * return; }
- *
- * if(source instanceof AnnotationProperty || target instanceof
- * AnnotationProperty) { e.rejectDrop();
- * SwingUtilities.invokeLater(new Runnable() { public void run() {
- * JOptionPane .showMessageDialog( MainFrame.getInstance(),
- * "Annotation Properties cannot be set as sub or super
- * properties!", "Error Dialog", JOptionPane.ERROR_MESSAGE); } });
- * return; } }
- *
- * if(!source.getClass().getName().equals(target.getClass().getName())) {
- * e.rejectDrop(); SwingUtilities.invokeLater(new Runnable() {
- * public void run() {
- * JOptionPane.showMessageDialog(MainFrame.getInstance(), "Invalid
- * Operation!", "Error Dialog", JOptionPane.ERROR_MESSAGE); } });
- * return; }
- *
- * if(source instanceof OClass && target instanceof OClass) { //
- * first find out the source's super classes OClass sc =
- * (OClass)source; Set<OClass> superClasses = sc
- * .getSuperClasses(OConstants.DIRECT_CLOSURE); // lets check if
- * the
- *
- * for(OClass sClass : superClasses) { sClass.removeSubClass(sc); }
- *
- * ((OClass)target).addSubClass(sc);
- *
- * return; }
- *
- * if(source instanceof RDFProperty && target instanceof
- * RDFProperty) { // first find out the source's super classes
- * RDFProperty sp = (RDFProperty)source; Set<RDFProperty>
- * superProps = sp .getSuperProperties(OConstants.DIRECT_CLOSURE);
- *
- * for(RDFProperty sProp : superProps) {
- * sProp.removeSubProperty(sp); }
- *
- * ((RDFProperty)target).addSubProperty(sp);
- *
- * return; }
- *
- */
- int action = e.getDropAction();
- e.rejectDrop();
- e.getDropTargetContext().dropComplete(false);
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- JOptionPane
- .showMessageDialog(
- MainFrame.getInstance(),
- "This feature is being implemented and will be
provided soon",
- "Coming Soon!", JOptionPane.INFORMATION_MESSAGE);
- }
- });
- } // end of method
-
- /** DropTaregetListener interface method */
- public void dragEnter(DropTargetDragEvent e) {
- }
-
- /** DropTaregetListener interface method */
- public void dragExit(DropTargetEvent e) {
- }
-
- /** DropTaregetListener interface method */
- public void dragOver(DropTargetDragEvent e) {
- }
-
- /** DropTaregetListener interface method */
- public void dropActionChanged(DropTargetDragEvent e) {
- }
-
- } // end of DnDJTree
-
public void selectResourceInClassTree(final OResource resource) {
SwingUtilities.invokeLater(new Runnable() { public void run() {
tabbedPane.setSelectedComponent(scroller);
@@ -2271,12 +2099,12 @@
/**
* The tree view.
*/
- protected DnDJTree tree;
+ protected JTree tree;
/**
* The property treeView
*/
- protected DnDJTree propertyTree;
+ protected JTree propertyTree;
/**
* The mode, for the tree.
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries. Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs