Changeset 7098


Ignore:
Timestamp:
2004-03-19T17:55:40+13:00 (20 years ago)
Author:
kjdon
Message:

added up and down arrow handling to the workspace and collection trees

Location:
trunk/gli/src/org/greenstone/gatherer/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/EnrichPane.java

    r6886 r7098  
    392392    collection_tree.setLargeModel(true);
    393393    collection_tree.setRootVisible(false);
    394 
     394   
     395    KeyListenerImpl key_listener = new KeyListenerImpl();
     396    collection_tree.addKeyListener(key_listener);
    395397    JScrollPane collection_scroll = new JScrollPane(collection_tree);
    396398
     
    10301032        }
    10311033    }
     1034    }
     1035
     1036    /** This class listens for certain key presses, such as [Up] or [Down], -copied from Gather Pane */
     1037    private class KeyListenerImpl
     1038    extends KeyAdapter {
     1039    /** Called whenever a key that was pressed is released, it is this action that will cause the desired effects (this allows for the key event itself to be processed prior to this listener dealing with it). */
     1040    public void keyReleased(KeyEvent event) {
     1041        ///ystem.err.println("Key Release detected. " + event.getKeyCode());
     1042        if (event.getKeyCode() == KeyEvent.VK_UP || event.getKeyCode() == KeyEvent.VK_DOWN) {
     1043        DragTree tree = (DragTree)event.getSource();
     1044        // we need to manually do the up and down selections
     1045        boolean up = (event.getKeyCode() == KeyEvent.VK_UP);
     1046        int current_row = tree.getLeadSelectionRow();
     1047        tree.setImmediate(true);
     1048        if (up) {
     1049            if (current_row > 0) {
     1050            tree.clearSelection();
     1051            tree.setSelectionRow(current_row-1);
     1052            }
     1053        } else {
     1054            if (current_row < tree.getRowCount()-1){
     1055            tree.clearSelection();
     1056            tree.setSelectionRow(current_row+1);
     1057            }
     1058        }
     1059        tree.setImmediate(false);
     1060        }
     1061    }
     1062
    10321063    }
    10331064
  • trunk/gli/src/org/greenstone/gatherer/gui/GatherPane.java

    r6841 r7098  
    668668    /** Called whenever a key that was pressed is released, it is this action that will cause the desired effects (this allows for the key event itself to be processed prior to this listener dealing with it). */
    669669    public void keyReleased(KeyEvent event) {
    670                 ///ystem.err.println("Key Release detected. " + event.getKeyCode());
     670        ///ystem.err.println("Key Release detected. " + event.getKeyCode());
    671671        if(event.getKeyCode() == KeyEvent.VK_DELETE) {
    672672        // Get the selected files from the tree and removal them using the default dnd removal method.
     
    704704            }
    705705        }
    706         }
    707     }
     706        } else if (event.getKeyCode() == KeyEvent.VK_UP || event.getKeyCode() == KeyEvent.VK_DOWN) {
     707        DragTree tree = (DragTree)event.getSource();
     708        // we need to manually do the up and down selections
     709        boolean up = (event.getKeyCode() == KeyEvent.VK_UP);
     710        int current_row = tree.getLeadSelectionRow();
     711        tree.setImmediate(true);
     712        if (up) {
     713            if (current_row > 0) {
     714            tree.clearSelection();
     715            tree.setSelectionRow(current_row-1);
     716            }
     717        } else {
     718            if (current_row < tree.getRowCount()-1){
     719            tree.clearSelection();
     720            tree.setSelectionRow(current_row+1);
     721            }
     722        }
     723        tree.setImmediate(false);
     724        }
     725    }
     726
    708727    }
    709728
Note: See TracChangeset for help on using the changeset viewer.