Accessing the Main Program Window
Situations arise that necessitate accessing the main HEC-DSSVue program window. Examples of such situations are:
- Having a script determine whether it is running in an interactive mode or without a graphical display.
- Having a script gather information about interactively-selected pathnames and time windows for automated processing.
- Having a script launch the interactive graphical editor.
The ListSelection class in the hec.dssgui module facilitates these activities. An import statement of the form "from hec.dssgui import ListSelection" is necessary to use the ListSelection class. (For CWMS-VUE, the import statement is "from hec.cwmsVue import CwmsListSelection").
If the script is executing in batch mode then a main program window will not exist. If the script needs to have the user utilize the graphical editor, the script will need to create a main program window for the duration of the graphical edit session.
ListSelection Class
The static functions of the ListSelection class are listed below.
Function | Returns | Description |
|---|---|---|
createMainWindow() | ListSelection | Returns a new ListSelection object. This should not be called unless the script is not running in interactive mode. |
getMainWindow() | ListSelection | Returns the main program window (ListSelection object) of the script. Returns None if the script is not running in interactive mode. |
isInteractive() | Boolean | Returns if the program is being run interactively or in a batch mode. |
At the end of a batch script that calls createMainWindow(), you should close DSS files and exit the ListSelection call using the finish() method. This function properly shuts down the program without altering any properties. For example:
mainWindow = ListSelection.createMainWindow()
…
mainWindow.finish()
Don't call finish() when running interactively (unless you want the program to terminate). ListSelection objects can be used to gather information about pathnames and time windows that the user selected interactively before launching the script. ListSelection objects can also be used to launch the interactive graphical editor. The ListSelection methods are listed below.
ListSelection Method | Returns | Description |
|---|---|---|
addToolBarButton(JButton b) | None | Adds a button to the main toolbar. |
addToSelection(String path) | None | Adds a pathname to the selection list. |
clear() | None | Clears selected pathnames. |
close() | None | Close the current DSS file. |
copyPathnamesToClipboard() | None | Copies selected pathnames to the clipboard |
copyRecords(Boolean) | None | Copies selected records to the second DSS file opened if 0, or displays an open dialog |
delete() | None | Deletes the selected records |
duplicateRecords() | None | Duplicates the selected records |
exitProgram() | None | Exits the program, saving settings |
exportShef(String filename) | None | Exports the selected records to SHEF in the file given |
exportShef(String filename, Vector timeSeriesContainers) | None | Exports the provided data to SHEF in the file given |
exportToFile() | None | Exports images, etc. by opening a Open dialog |
fileCheck() | None | Runs a file check on the opened DSS file |
finish() | None | Exits without saving settings |
getCustomMenu() | JMenu | Returns the custom menu |
getDataManager() | CombinedDataManager | Returns the combined data manager for the current file |
getDisplayMenu() | Jmenu | Returns the Display menu |
getDSSFilename() | string | Returns the current DSS file name |
getEndTime() | HecTime | Returns the current end time of the ListSelection as an HecTime object.1 |
getEditMenu() | Jmenu | Returns the Edit menu |
getExport Menu() | Jmenu | Returns the Export menu |
getFileMenu() | Jmenu | Returns the File menu |
getImportMenu() | Jmenu | Returns the Import menu |
getNumberSelectedPathnames() | integer | Returns the number of selected pathnames |
getScriptMenu() | Jmenu | Returns the script menu |
getSecondDataManager() | CombinedDataManager | Returns the combined data manager for the second file |
ListSelection Method | Returns | Description |
getSelectedDataContainers() | List | Reads data for the selected pathnames and returns it in a list of data containers |
getSelectionList() | list of DataReference objects | Returns a list of DataReference objects that represent the interactive pathname and time window selections. |
getSelectedPaths() | Vector | Returns a Vector of Strings of pathnames in the open DSS file. |
getStartTime() | HecTime | Returns the current start time of the ListSelection as an HecTime object.1 |
getTimeWindow(HecTime startTime, HecTime endTime) | Boolean | Returns whether the start time and end time provided are defined |
getToolBar() | JtoolBar | Returns the tool bar |
getViewMenu() | Jmenu | Returns the View menu |
graphicalEdit() | None | Launches the graphical editor for the interactively-selected pathnames and time windows. |
graphicalEdit(TimeSeriesContainer tsc) | None | Launches the graphical editor for the specified TimeSeriesContainer. |
graphicalEdit(list tscList) | None | Launches the graphical editor for all TimeSeriesContainers in the list. |
importGenericFiles() | None | Launches a file open dialog to import files |
importImages() | None | Launches a file open dialog to import image files |
importShef() | None | Launches a file open dialog to import SHEF files |
importShef(string filename) | None | Imports the SHEF file |
isDssFileAccessible() | Boolean | Returns if the DSS file set earlier is accessible currently |
isRemote() | Boolean | Returns whether the DSS file opened is remote and accessed using DSSManager |
isVisible() | Boolean | Returns whether the dialog is currently visible on the screen |
math() | None | Reads the selected data and then opens the math dialog |
mergeFiles(string toDssFilename) | None | Copies all the data from the opened DSS file into the one specified |
openDSSFile (string DSSFileName) | Boolean | Opens the DSS file name of the ListSelection and returns whether it was opened or not |
pairedDataEntry() | None | Opens the paried data entry dialog |
plot() | None | Reads the selected data and then plots it |
read(string pathname) | DataContainer | Reads the recorded specified by the pathname |
read(string pathname, HecTime start, HecTime end) | DataContainer | Reads the recorded specified by the pathname and time window |
ListSelection Method | Returns | Description |
read(string pathname, String timeWindow) | DataContainer | Reads the recorded specified by the pathname and time window |
refreshCatalog() | None | Refreshes the catalog for the opened file |
registerExportPlugin(JmenuItem menuItem) | None | Adds the menu item to the export menu |
registerImportPlugin(ImportPlugin importPlugin, JmenuItem menuItem, string dropAndDragExtension) | None | Adds the menu item to the import menu and associates the plugin and drag and drop extension to that item |
registerPlugin(integer menuNumber, JmenuItem menuItem) | None | Adds the menu item to main menus. Menu numbers are the following: |
renameRecords() | None | Brings up the rename dialog for the selected pathnames |
runFile() | None | Reads the selected data and runs the programs associated with them (e.g., .pdf, .mp3) |
runFile(Vector pathnames) | None | Reads the selected pathnames and runs the programs associated with them (e.g., .pdf, .mp3) |
save(DataContainer dataContainer) | Boolean | Saves the data container in the opened DSS file. Returns if success or not |
saveAs(DataContainer dataContainer) | Boolean | Opens the Save As dialog and saves the data container in the opened DSS file. Returns if success or not |
selectAll() | Boolean | Adds all pathnames to the selection list |
setCustomMenu(string menuText) | None | Sets the text displayed on the menu bar |
setDssLogFile(string logFile) | None | Writes DSS messages to the file provided |
setScriptMenu(string menuText) | None | Sets the text displayed on the menu bar |
setSelectedPathnames(Vector selectedPathnames) | None | Sets the selected list of pathnames |
setTimeWindow(string timeWindow) | None | Sets the current time window of the ListSelection using a string value to define the start time and end time |
setTimeWindow(string start, string end) | None | Sets the current time window of the ListSelection using a string value to define the start time and end time |
setTimeWindow(HecTime start, HecTime end) | None | Sets the current time window of the ListSelection using an Hec Time object to define the start time and end time |
ListSelection Method | Returns | Description |
setVisible(Boolean visible) | None | Sets whether the dialog is visible on the screen. |
squeeze() | None | Squeezes the open DSS file |
tabulate() | Jframe | Tabulates the selected data |
tabularEdit() | Jframe | Displays the tabular editor for the selected data |
textEntry() | None | Displays the text entry dialog |
textFileEntry() | None | Displays an open dialog to read a text file into text format |
timeSeriesDataEntry() | None | Displays the time series data entry dialog |
undeleteAll() | None | Undeletes all deleted records in the DSS file |
undeleteSelected() | None | Undeletes the selected records |
updateCatalog() | None | Creates a new catalog, if needed (refreshCatalog forces a new catalog) |
updateMessageField(string message) | None | Puts the message in the message field |
1 The current start and end times of a ListSelection object are not necessarily the same as the start and end times of any DataReference objects in the ListSelection. Rather they represent the start and end times that will be applied to subsequent selections.
DataReference Class
The getSelectionList() ListSelection method returns a Vector of DataReference objects that represent the interactive selections. Each individual selection may have a different DSS filename, pathname, and time window than other selections. The methods of the DataReference class are listed below.
DataReference Method | Returns | Description |
getFilename() | string | Returns the name of the DSS file from which this selection was made. |
getNominalPathname() | string | Returns the nominal pathname for this selection. If a condensed set, this will not be a real pathname, but show the date span in the D part |
getPathname() | string | Returns the pathname for this selection |
getPathnameList() | Vector | Returns a list of the pathnames for this selection. This will be only more than one if a condensed reference |
getTimeWindow( | Boolean | Sets the startTime and endTime parameters with the start time and end time of the selection, respectively. Returns True if a time window is defined for the selection. Returns False otherwise. |
hasTimeWindow() | Boolean | Returns True if a time window is defined for the selection. Returns False otherwise. |