Class CatalogChooser

  • All Implemented Interfaces:
    ImageObserver, MenuContainer, Serializable, Accessible

    public class CatalogChooser
    extends JPanel
    A Swing widget for THREDDS clients to access and choose from Dataset Inventory catalogs. State is maintained in a ucar.util.Preferences store.

    A list of catalogs is kept in a ComboBox, and the user can choose from them and add new ones. When a catalog is chosen, its contents are displayed in a CatalogTreeView. As the datasets are browsed, the metadata is displayed in an HtmlBrowser widget.

    When a new dataset is selected, a java.beans.PropertyChangeEvent is thrown, see addPropertyChangeListener.

    Use Example:

        // create widgets
        catalogChooser = new thredds.ui.CatalogChooser( prefs);
        catalogChooserDialog = catalogChooser.makeDialog(rootPaneContainer, "Open THREDDS dataset", true);
    
          // listen for selection
        catalogChooser.addPropertyChangeListener(  new java.beans.PropertyChangeListener() {
          public void propertyChange( java.beans.PropertyChangeEvent e) {
            if (e.getPropertyName().equals("Dataset")) {
              ..
            }
         }
       });
    
          // popup dialog
        catalogChooserDialog.show();
     
    You can use the CatalogChooser alone, wrap it into a JDialog for popping up, or use a ThreddsDatasetChooser instead, for a more complete interface.
    See Also:
    Serialized Form
    • Constructor Detail

      • CatalogChooser

        public CatalogChooser​(PreferencesExt prefs,
                              boolean showComboChooser,
                              boolean showOpenButton,
                              boolean showFileChooser)
        Constructor, with control over whether a comboBox of previous catalogs is shown.
        Parameters:
        prefs - persistent storage, may be null.
        showComboChooser - comboBox persists catalog URLs
        showOpenButton - show the "open" button.
        showFileChooser - show a FileChooser (must have showComboChooser true)
    • Method Detail

      • save

        public void save()
        Save persistent state.
      • addButton

        public void addButton​(JButton b)
        Add this button to the button panel.
        Parameters:
        b - button to add
      • setAccessOnly

        public void setAccessOnly​(boolean accessOnly)
        Whether to throw events only if dataset has an Access.
        Parameters:
        accessOnly - if true, throw events only if dataset has an Access
      • setCatrefEvents

        public void setCatrefEvents​(boolean catrefEvents)
        Whether to throw events if catref URL was chosen catref URL was chosen in HtmlViewer (default false).
      • setDatasetEvents

        public void setDatasetEvents​(boolean datasetEvents)
        Whether to throw events if dataset URL was chosen in HtmlViewer (default true).
      • setSelectedItem

        public void setSelectedItem​(String item)
        Set the string value in the combo box
        Parameters:
        item - to this item
      • setSelectedDataset

        public void setSelectedDataset​(Dataset ds)
        Set the currently selected InvDataset.
        Parameters:
        ds - select this InvDataset, must be already in the tree.
      • getSelectedDataset

        public DatasetNode getSelectedDataset()
      • getCurrentCatalog

        public Catalog getCurrentCatalog()
        Get the current catalog being shown.
        Returns:
        current catalog, or null.
      • getTreeView

        public CatalogTreeView getTreeView()
        Get the TreeView component.
        Returns:
        the TreeView component.
      • getCurrentURL

        public String getCurrentURL()
        Get the current URL string. This may be the top catalog, or a catalogRef, depending on what was last selected. Used to implement the " showSource" debugging tool.
        Returns:
        current URL string
      • setCatalog

        public void setCatalog​(Catalog catalog)
        Set the current catalog.
      • setCatalog

        public void setCatalog​(String catalogURL)
        Set the current catalog with a string URL. May be of form catalog#datasetId
      • makeDialog

        public JDialog makeDialog​(RootPaneContainer parent,
                                  String title,
                                  boolean modal)
        Wrap this in a JDialog component.
        Parameters:
        parent - JFrame (application) or JApplet (applet) or null
        title - dialog window title
        modal - is modal