Changeset 6209


Ignore:
Timestamp:
2003-12-10T16:40:41+13:00 (20 years ago)
Author:
jmt12
Message:

Replaced pollo.FileExtensionFilter with my own

File:
1 edited

Legend:

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

    r6154 r6209  
    3939import java.awt.*;
    4040import java.awt.event.*;
    41 import java.io.*;
     41import java.io.File;
    4242import java.util.*;
    4343import javax.swing.*;
    4444import javax.swing.event.*;
     45import javax.swing.filechooser.*;
    4546import javax.swing.table.*;
    4647import org.greenstone.gatherer.Dictionary;
     
    5455import org.greenstone.gatherer.util.TableUtils;
    5556import org.greenstone.gatherer.util.Utility;
    56 import org.outerj.pollo.util.*;
    5757
    5858/** The file association allows the entry of new file associations and the modification of existing ones.
     
    253253    }
    254254
     255    /** Batch filter shows only files ending in bat. Based on ImageFilter.java which is a 1.4 example used by FileChooserDemo2.java. */
     256    private class BatchFileFilter
     257    extends FileFilter {
     258
     259    /** Accept all .exe files
     260     * @param file a File
     261     * @return true is this file should be shown, false otherwise
     262     */
     263    public boolean accept(File file) {
     264        return file.getName().toLowerCase().endsWith(".bat");
     265    }
     266
     267    /** The description of this filter
     268     * @return a String
     269     */
     270    public String getDescription() {
     271        return Dictionary.get("FileAssociationDialog.Batch_File");
     272    }
     273    }
     274
    255275    /** Whenever the user clicks the browse button, we should open up a file browser to allow them to select an executable file from somewhere in the file system. */
    256276    private class BrowseButtonListener
     
    263283        OpenCollectionDialog.disableRename(chooser);
    264284        chooser.setDialogTitle(Dictionary.get("FileAssociationDialog.Browse_Title"));
    265         chooser.setFileFilter(new ExtensionFileFilter(".bat", Dictionary.get("FileAssociationDialog.Batch_File")));
    266         chooser.setFileFilter(new ExtensionFileFilter(".com", Dictionary.get("FileAssociationDialog.Command_File")));
    267         chooser.setFileFilter(new ExtensionFileFilter(".exe", Dictionary.get("FileAssociationDialog.Executable_File")));
     285        chooser.setFileFilter(new BatchFileFilter());
     286        chooser.setFileFilter(new CoreObjectModelFileFilter());
     287        chooser.setFileFilter(new ExecutableFileFilter());
    268288        chooser.setAcceptAllFileFilterUsed(true);
    269289        if(chooser.showOpenDialog(Gatherer.g_man) == JFileChooser.APPROVE_OPTION) {
     
    281301        replace_button.setEnabled(false);
    282302        self.dispose();
     303    }
     304    }
     305
     306    /** Command filter shows only files ending in com. Based on ImageFilter.java which is a 1.4 example used by FileChooserDemo2.java. */
     307    private class CoreObjectModelFileFilter
     308    extends FileFilter {
     309
     310    /** Accept all .exe files
     311     * @param file a File
     312     * @return true is this file should be shown, false otherwise
     313     */
     314    public boolean accept(File file) {
     315        return file.getName().toLowerCase().endsWith(".com");
     316    }
     317
     318    /** The description of this filter
     319     * @return a String
     320     */
     321    public String getDescription() {
     322        return Dictionary.get("FileAssociationDialog.Command_File");
    283323    }
    284324    }
     
    368408    }
    369409
     410    /** Executable filter shows only files ending in exe. Based on ImageFilter.java which is a 1.4 example used by FileChooserDemo2.java. */
     411    private class ExecutableFileFilter
     412    extends FileFilter {
     413
     414    /** Accept all .exe files
     415     * @param file a File
     416     * @return true is this file should be shown, false otherwise
     417     */
     418    public boolean accept(File file) {
     419        return file.getName().toLowerCase().endsWith(".exe");
     420    }
     421
     422    /** The description of this filter
     423     * @return a String
     424     */
     425    public String getDescription() {
     426        return Dictionary.get("FileAssociationDialog.Executable_File");
     427    }
     428    }
     429
    370430    private class ExistingAssociationsTableListener
    371431    implements ListSelectionListener {
Note: See TracChangeset for help on using the changeset viewer.