Server Panels

  • Unlike other "standard file" dialogs, the resource chooser can offer browsing of multiple file repositories--local, Collective, even CVS.
  • Like other "standard file" dialogs, the resource chooser has a showOpenDialog() method that returns either APPROVE_OPTION or CANCEL_OPTION.
  • If the dialog returns the APPROVE_OPTION, Kahuna calls getSelectedResource() to get the user's approved choice.
ResourceChooser
+ APPROVE_OPTION : int
+ CANCEL_OPTION : int
+ ResourceChooser(ResourceFactory)
+ showOpenDialog(Component) : int
+ getSelectedResource() : Resource
* approve(Resource)
* cancel()
+ addChoosableResourceFilter(ResourceFilter)
+ setResourceFilter(ResourceFilter)
+ getTabAndCategory() : String
+ setTabAndCategory(String)
ServerPanel
ServerPanel(ResourceServer, ResourceChooser)
getSelectedResource() : Resource
addChoosableResourceFilter(ResourceFilter)
setResourceFilter(ResourceFilter)
setSelectedCategory(Category)
getCurrentCategory() : String
setCurrentCategory(String)
  • Unlike other "standard file" dialogs, the resource chooser does not have a showSaveDialog() method (yet).
public class ResourceChooser {
    private JDialog dialog = null;
    private int returnValue = CANCEL_OPTION;
    private Resource selectedResource = null;
    private ServerPanel[] serverPanels;
    private JTabbedPane tabbedPane = new JTabbedPane();

    public ResourceChooser(ResourceFactory factory) {
        ResourceServer[] servers = factory.getResourceServers();
        serverPanels = new ServerPanel[servers.length];
        for (int i = 0; i < servers.length; i++) {
            serverPanels[i] = new ServerPanel(servers[i], this);
            tabbedPane.add(serverPanels[i].getLabel(), 
                           serverPanels[i]);
        }
    }

    public void setResourceFilter(ResourceFilter filter) {
        for (int i = 0; i < serverPanels.length; i++) {
            serverPanels[i].setResourceFilter(filter);
        }
    }

    public int showOpenDialog(Component parent) {
        if (dialog == null) {
            createDialog(parent);
        }
        dialog.setVisible(true);
        return returnValue;
    }

    void approve(Resource resource) {
        selectedResource = resource;
        returnValue = APPROVE_OPTION;
        dialog.setVisible(false);
    }

    void cancel() {
        selectedResource = null;
        returnValue = CANCEL_OPTION;
        dialog.setVisible(false);
    }

    public Resource getSelectedResource() {
        return selectedResource;
    }
}