Changeset 11622


Ignore:
Timestamp:
2006-04-07T13:19:24+12:00 (18 years ago)
Author:
mdewsnip
Message:

Lots more object-orientation improvements to the collection and workspace trees.

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionTree.java

    r11620 r11622  
    4343    implements MouseListener
    4444{
    45     public CollectionTree(String name, CollectionTreeModel collection_tree_model, boolean mixed_selection)
    46     {
    47     super(name, collection_tree_model, mixed_selection);
     45    public CollectionTree(CollectionTreeModel collection_tree_model, boolean mixed_selection)
     46    {
     47    super(collection_tree_model, mixed_selection);
    4848    addMouseListener(this);
    4949
     
    5959
    6060
     61    public boolean isDraggable()
     62    {
     63    return true;
     64    }
     65
     66
     67    public boolean isDroppable()
     68    {
     69    return true;
     70    }
     71
     72
    6173    public void mouseClicked(MouseEvent event)
    6274    {
     
    7385
    7486    public void mouseReleased(MouseEvent event) { }
     87
     88
     89    public String toString()
     90    {
     91    return "Collection";
     92    }
    7593
    7694
  • trunk/gli/src/org/greenstone/gatherer/file/WorkspaceTree.java

    r11620 r11622  
    4949
    5050
    51     public WorkspaceTree(String name)
    52     {
    53     super(name, WorkspaceTreeModel.getWorkspaceTreeModel(), true);
     51    public WorkspaceTree()
     52    {
     53    super(WorkspaceTreeModel.getWorkspaceTreeModel(), true);
    5454    addMouseListener(this);
    5555
     
    7171    // Now update the tree
    7272    refresh(FOLDER_SHORTCUTS_CHANGED);
     73    }
     74
     75
     76    public boolean isDraggable()
     77    {
     78    return true;
     79    }
     80
     81
     82    public boolean isDroppable()
     83    {
     84    return false;
    7385    }
    7486
     
    170182    // Update tree
    171183    refresh(FOLDER_SHORTCUTS_CHANGED);
     184    }
     185
     186
     187    public String toString()
     188    {
     189    return "Workspace";
    172190    }
    173191
  • trunk/gli/src/org/greenstone/gatherer/gui/EnrichPane.java

    r11620 r11622  
    6666    /** The currently reported selection. */
    6767    private CollectionTreeNode[] file_nodes = null;
    68     /** Used to dynamically filter the collection tree. Synchronized with the same filter in the Gather view. */
     68    /** Used to dynamically filter the collection tree. */
    6969    private Filter collection_filter = null;
    7070    /** The label at the top of the collection tree, which shows the collection name. */
     
    127127
    128128    DragGroup group = new DragGroup();
    129     collection_tree = new CollectionTree("Enrich", Gatherer.c_man.getCollectionTreeModel(), false);
     129    collection_tree = new CollectionTree(Gatherer.c_man.getCollectionTreeModel(), false);
    130130    group.add(collection_tree);
    131131    collection_tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
  • trunk/gli/src/org/greenstone/gatherer/gui/GatherPane.java

    r11620 r11622  
    219219    Dictionary.registerText(workspace_label, "Collection.Workspace");
    220220
    221     workspace_tree = new WorkspaceTree(Utility.WORKSPACE_TREE);
     221    workspace_tree = new WorkspaceTree();
    222222    group.add(workspace_tree);
    223223    workspace_scroll = new JScrollPane(workspace_tree);
     
    234234    Dictionary.registerText(collection_label, "Collection.No_Collection");
    235235
    236     collection_tree = new CollectionTree(Utility.COLLECTION_TREE, Gatherer.c_man.getCollectionTreeModel(), true);
     236    collection_tree = new CollectionTree(Gatherer.c_man.getCollectionTreeModel(), true);
    237237    collection_tree.setEnabled(Gatherer.c_man.getCollectionTreeModel() != null);
    238238    group.add(collection_tree);
  • trunk/gli/src/org/greenstone/gatherer/gui/tree/DragTree.java

    r11620 r11622  
    5050    /** The region borderer by the upper cue line. */
    5151    private Rectangle upper_cue_line;
    52     /** The identifying name of this Tree. */
    53     private String name;
    5452    /** The last tree path the drag was hovered over. */
    5553    private TreePath previous_path = null;
     
    6664
    6765
    68     public DragTree(String name, TreeModel model, boolean mixed_selection)
     66    public DragTree(TreeModel model, boolean mixed_selection)
    6967    {
    7068    super();
     
    7876    }
    7977
    80     init(name, mixed_selection);
     78    init(mixed_selection);
    8179    if (model != null) {
    8280        setModel(model);
     
    8482    }
    8583
    86     public void init(String name, boolean mixed_selection) {
     84    public void init(boolean mixed_selection) {
    8785    if (NO_DRAG_CURSOR == null) {
    8886        NO_DRAG_CURSOR = DragSource.DefaultMoveNoDrop;
     
    9088
    9189    // Init
    92     this.name = name;
    9390    this.filter = new Filter(this, null);
    9491
     
    213210     * the drag event.
    214211     */
    215     public void dragGestureRecognized(DragGestureEvent event) {
    216     // Can never drag from Enrich tree
    217     if(name.equals("Enrich")) {
     212    public void dragGestureRecognized(DragGestureEvent event)
     213    {
     214    // Check that the tree is draggable
     215    if (!isDraggable()) {
    218216        return;
    219217    }
     218
    220219    // Disable editing, unless you want to have the edit box pop-up part way through dragging.
    221220    this.setEditable(false);
     
    365364    ///start = System.currentTimeMillis();
    366365    ///ystem.err.println("Drop target drop: " + this);
     366    if (!isDroppable()) {
     367        return;
     368    }
     369
    367370    event.acceptDrop(drag_action);
    368     if(!name.equals(Utility.WORKSPACE_TREE)) {
    369         // Determine what node we dropped over.
    370         Point pt = event.getLocation();
    371         TreePath target_path = this.getPathForLocation(pt.x, pt.y);
    372         FileNode target = null;
    373         if(target_path != null) {
    374         if(isValidDrop(target_path)) {
    375             target = (FileNode) target_path.getLastPathComponent();
    376         } else if (isValidDropOntoFile(target_path)) {
    377             target = (FileNode) target_path.getParentPath().getLastPathComponent();
     371
     372    // Determine what node we dropped over.
     373    Point pt = event.getLocation();
     374    TreePath target_path = this.getPathForLocation(pt.x, pt.y);
     375    FileNode target = null;
     376    if(target_path != null) {
     377        if(isValidDrop(target_path)) {
     378        target = (FileNode) target_path.getLastPathComponent();
     379        } else if (isValidDropOntoFile(target_path)) {
     380        target = (FileNode) target_path.getParentPath().getLastPathComponent();
     381        }
     382    }
     383    else {
     384        TreeModel m = getModel();
     385        // check that we have a model and is a FileSystemModel (ie check that a collection is loaded
     386        if (m != null && m instanceof FileSystemModel) {
     387        target = (FileNode) m.getRoot();
     388        }
     389    }
     390    target_path = null;
     391    pt = null;
     392    if(target != null) {
     393        ///ystem.err.println("Valid drop.");
     394        TreePath[] selection = group.getSelection();
     395        if(target != null && selection != null) {
     396        FileNode[] source_nodes = new FileNode[selection.length];
     397        for(int i = 0; i < source_nodes.length; i++) {
     398            source_nodes[i] = (FileNode) selection[i].getLastPathComponent();
    378399        }
    379         }
    380         else {
    381         TreeModel m = getModel();
    382         // check that we have a model and is a FileSystemModel (ie check that a collection is loaded
    383         if (m != null && m instanceof FileSystemModel) {
    384             target = (FileNode) m.getRoot();
    385         }
    386         }
    387         target_path = null;
    388         pt = null;
    389         if(target != null) {
    390         ///ystem.err.println("Valid drop.");
    391         TreePath[] selection = group.getSelection();
    392         if(target != null && selection != null) {
    393             FileNode[] source_nodes = new FileNode[selection.length];
    394             for(int i = 0; i < source_nodes.length; i++) {
    395             source_nodes[i] = (FileNode) selection[i].getLastPathComponent();
    396             }
    397             Gatherer.f_man.action(group.getSource(), source_nodes, this, target);
    398             source_nodes = null;
    399         }
    400         group.setSelection(null);
    401         group.setSource(null);
    402         selection = null;
    403         target = null;
    404         }
    405     }
     400        Gatherer.f_man.action(group.getSource(), source_nodes, this, target);
     401        source_nodes = null;
     402        }
     403        group.setSelection(null);
     404        group.setSource(null);
     405        selection = null;
     406        target = null;
     407    }
     408
    406409    // Clear up the group.image_ghost
    407410    paintImmediately(ra_ghost.getBounds());
     
    469472    return (FileSystemModel) getModel();
    470473    }
     474
     475
     476    protected abstract boolean isDraggable();
     477
     478
     479    protected abstract boolean isDroppable();
     480
    471481
    472482    /** This method is used to inform this component when it loses focus,
     
    624634    ((DefaultTreeCellRenderer)cellRenderer).setTextSelectionColor(color);
    625635    repaint();
    626     }
    627 
    628     public String toString() {
    629     return name;
    630636    }
    631637
  • trunk/gli/src/org/greenstone/gatherer/util/Utility.java

    r11481 r11622  
    6565    static final public String CFG_CLASSIFY_SORT = "-sort";
    6666    static final public String CFG_FORMAT = "format";
    67     static final public String COLLECTION_TREE = "Collection";
    6867    /** Definition of an important directory name, in this case the file the collection configuration is expect to be in. */
    6968    static final public String CONFIG_FILE = "etc" + File.separator + "collect.cfg";
     
    8483    /** The current version of the GLI. */
    8584    static final public String PROGRAM_VERSION = "v2.70";
    86     static final public String WORKSPACE_TREE = "Workspace";
    8785
    8886
Note: See TracChangeset for help on using the changeset viewer.