Ignore:
Timestamp:
2003-05-27T15:57:37+12:00 (21 years ago)
Author:
kjdon
Message:

re-tabbed the code for java

File:
1 edited

Legend:

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

    r4293 r4366  
    7878 */
    7979public class MetaAuditFrame
    80     extends JDialog
    81     implements TreeSelectionListener {
    82     public AutofilterDialog autofilter_dialog;
    83     /** Whether the selection has changed since the last time we built the model (because it has been hidden and theres no point refreshing a model you can't see!). */
    84     private boolean invalid = true;
    85     /** An array holding the most recent list of paths selected (plus some nulls for those paths removed). */
    86     private FileNode records[];
    87     /** A reference to ourselves so that inner classes can interact with us. */
    88     private MetaAuditFrame self;
    89     /** The table in which the metadata is shown. */
    90     private MetaAuditTable table;
    91     /** The default size for the metaaudit dialog. */
    92     static final private Dimension SIZE = new Dimension(640,480);
    93     /** The tolerance used to determine between a column resize, and a request for an AutoFilterDialog. */
    94     static final private int TOLERANCE = 3;
    95     /** Constructor.*/
    96     public MetaAuditFrame(TreeSynchronizer tree_sync, FileNode records[]) {
    97           super();
    98           // Arguments
    99           this.autofilter_dialog = new AutofilterDialog(this);
    100           this.records = records;
    101           this.self = this;
    102           this.table = new MetaAuditTable(this);
    103           // Creation
    104           setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
    105           setSize(SIZE);
    106           setTitle(get("Title"));
    107 
    108           JPanel content_pane = (JPanel) getContentPane();
    109           JPanel button_pane = new JPanel();
    110 
    111           JButton close_button = new JButton(get("Close"));
    112           close_button.setMnemonic(KeyEvent.VK_C);
    113           // Connection
    114           close_button.addActionListener(new CloseListener());
    115           tree_sync.addTreeSelectionListener(this);
    116           // Layout
    117           button_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    118           button_pane.setLayout(new BorderLayout());
    119           button_pane.add(close_button, BorderLayout.CENTER);
     80    extends JDialog
     81    implements TreeSelectionListener {
     82    public AutofilterDialog autofilter_dialog;
     83    /** Whether the selection has changed since the last time we built the model (because it has been hidden and theres no point refreshing a model you can't see!). */
     84    private boolean invalid = true;
     85    /** An array holding the most recent list of paths selected (plus some nulls for those paths removed). */
     86    private FileNode records[];
     87    /** A reference to ourselves so that inner classes can interact with us. */
     88    private MetaAuditFrame self;
     89    /** The table in which the metadata is shown. */
     90    private MetaAuditTable table;
     91    /** The default size for the metaaudit dialog. */
     92    static final private Dimension SIZE = new Dimension(640,480);
     93    /** The tolerance used to determine between a column resize, and a request for an AutoFilterDialog. */
     94    static final private int TOLERANCE = 3;
     95    /** Constructor.*/
     96    public MetaAuditFrame(TreeSynchronizer tree_sync, FileNode records[]) {
     97    super();
     98    // Arguments
     99    this.autofilter_dialog = new AutofilterDialog(this);
     100    this.records = records;
     101    this.self = this;
     102    this.table = new MetaAuditTable(this);
     103    // Creation
     104    setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
     105    setSize(SIZE);
     106    setTitle(get("Title"));
     107
     108    JPanel content_pane = (JPanel) getContentPane();
     109    JPanel button_pane = new JPanel();
     110
     111    JButton close_button = new JButton(get("Close"));
     112    close_button.setMnemonic(KeyEvent.VK_C);
     113    // Connection
     114    close_button.addActionListener(new CloseListener());
     115    tree_sync.addTreeSelectionListener(this);
     116    // Layout
     117    button_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     118    button_pane.setLayout(new BorderLayout());
     119    button_pane.add(close_button, BorderLayout.CENTER);
    120120         
    121           content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    122           content_pane.setLayout(new BorderLayout());
    123           content_pane.add(new JScrollPane(table), BorderLayout.CENTER);
    124           content_pane.add(button_pane, BorderLayout.SOUTH);
     121    content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     122    content_pane.setLayout(new BorderLayout());
     123    content_pane.add(new JScrollPane(table), BorderLayout.CENTER);
     124    content_pane.add(button_pane, BorderLayout.SOUTH);
    125125         
    126           Dimension screen_size = Gatherer.config.screen_size;
    127           setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2);
    128           screen_size = null;
    129           close_button = null;
    130           button_pane = null;
    131           content_pane = null;
    132     }
    133     /** Destructor. */
    134     public void destroy() {
    135           records = null;
    136           self = null;
    137           table = null;
    138     }
    139     /** Display the dialog on screen. */
    140     public void display() {
    141           if(invalid) {
    142                 rebuildModel();
    143           }
    144           show();
    145     }
    146     /** This method is called whenever the selection within the collection tree changes. This causes the table to be rebuilt with a new model.
    147       * @param event A <strong>TreeSelectionEvent</strong> containing information about the event.
    148       */
    149     public void valueChanged(TreeSelectionEvent event) {
    150           if(event.getSource() instanceof JTree) {
    151                 TreePath paths[] = Gatherer.g_man.metaedit_pane.collection_tree.getSelectionPaths();
    152                 if(paths != null) {
    153                      records = new FileNode[paths.length];
    154                      for(int i = 0; i < paths.length; i++) {
    155                           records[i] = (FileNode) paths[i].getLastPathComponent();
    156                      }
    157                      if(isVisible()) {
    158                           rebuildModel();
    159                      }
    160                      else {
    161                           invalid = true;
    162                      }
    163                 }
    164           }
    165     }
    166 
    167     public void wait(boolean waiting) {
    168           Component glass_pane = getGlassPane();
    169           if(waiting) {
     126    Dimension screen_size = Gatherer.config.screen_size;
     127    setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2);
     128    screen_size = null;
     129    close_button = null;
     130    button_pane = null;
     131    content_pane = null;
     132    }
     133    /** Destructor. */
     134    public void destroy() {
     135    records = null;
     136    self = null;
     137    table = null;
     138    }
     139    /** Display the dialog on screen. */
     140    public void display() {
     141    if(invalid) {
     142        rebuildModel();
     143    }
     144    show();
     145    }
     146    /** This method is called whenever the selection within the collection tree changes. This causes the table to be rebuilt with a new model.
     147     * @param event A <strong>TreeSelectionEvent</strong> containing information about the event.
     148     */
     149    public void valueChanged(TreeSelectionEvent event) {
     150    if(event.getSource() instanceof JTree) {
     151        TreePath paths[] = Gatherer.g_man.metaedit_pane.collection_tree.getSelectionPaths();
     152        if(paths != null) {
     153        records = new FileNode[paths.length];
     154        for(int i = 0; i < paths.length; i++) {
     155            records[i] = (FileNode) paths[i].getLastPathComponent();
     156        }
     157        if(isVisible()) {
     158            rebuildModel();
     159        }
     160        else {
     161            invalid = true;
     162        }
     163        }
     164    }
     165    }
     166
     167    public void wait(boolean waiting) {
     168    Component glass_pane = getGlassPane();
     169    if(waiting) {
    170170                // Show wait cursor.
    171                 glass_pane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    172                 glass_pane.setVisible(true);
    173           }
    174           else {
     171        glass_pane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
     172        glass_pane.setVisible(true);
     173    }
     174    else {
    175175                // Hide wait cursor.
    176                 glass_pane.setVisible(false);
    177                 glass_pane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    178           }
    179           glass_pane = null;
    180     }
    181 
    182     /** Retrieve a phrase from the Dictionary.
    183       * @param key A <strong>String</strong> which uniquely maps to a phrase.
    184       * @return The desired phrase as a </strong>String</strong>.
    185       * @see org.greenstone.gatherer.Dictionary
    186       */
    187     private String get(String key) {
    188           return Gatherer.dictionary.get("MetaAudit." + key);
    189     }
    190     /** Rebuild the metaaudit table model using the current collection tree selection.
    191       */
    192     private void rebuildModel() {
    193           // Build and set model
    194           table.newModel(records);
    195           // Done.
    196           invalid = false;
    197     }
    198     /** Listens for actions apon the close button, and if detected closes the dialog (storing its current size first). */
    199     private class CloseListener
    200           implements ActionListener {
    201           /** Any implementation of ActionListener must include this method so that we can be informed when an action has been performed on our target control(s).
    202             * @param event An <strong>ActionEvent</strong> containing information about the event.
    203             */
    204           public void actionPerformed(ActionEvent event) {
    205                 self.hide();
    206           }
    207     }
     176        glass_pane.setVisible(false);
     177        glass_pane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
     178    }
     179    glass_pane = null;
     180    }
     181
     182    /** Retrieve a phrase from the Dictionary.
     183     * @param key A <strong>String</strong> which uniquely maps to a phrase.
     184     * @return The desired phrase as a </strong>String</strong>.
     185     * @see org.greenstone.gatherer.Dictionary
     186     */
     187    private String get(String key) {
     188    return Gatherer.dictionary.get("MetaAudit." + key);
     189    }
     190    /** Rebuild the metaaudit table model using the current collection tree selection.
     191     */
     192    private void rebuildModel() {
     193    // Build and set model
     194    table.newModel(records);
     195    // Done.
     196    invalid = false;
     197    }
     198    /** Listens for actions apon the close button, and if detected closes the dialog (storing its current size first). */
     199    private class CloseListener
     200    implements ActionListener {
     201    /** Any implementation of ActionListener must include this method so that we can be informed when an action has been performed on our target control(s).
     202     * @param event An <strong>ActionEvent</strong> containing information about the event.
     203     */
     204    public void actionPerformed(ActionEvent event) {
     205        self.hide();
     206    }
     207    }
    208208}
    209209     
Note: See TracChangeset for help on using the changeset viewer.