Example #1
0
 /*
  * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
  */
 public void actionPerformed(ActionEvent e) {
     if (e.getActionCommand().equals("Exit")) {
         quit();
     } else if (e.getActionCommand().equals("ChooseDir")) {
         chooseBaseDir();
     }
 }
        /// <summary>
        /// Responds to button presses. </summary>
        /// <param name="event"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent @event)
        {
            string command = @event.getActionCommand();

            if (command.Equals(__BUTTON_APPLY))
            {
                applyChanges();
                __node = __parent.getAnnotationNode(__nodeNum);
                __applyButton.setEnabled(false);
                __okButton.setEnabled(false);
            }
            else if (command.Equals(__BUTTON_CANCEL))
            {
                closeWindow();
            }
            else if (command.Equals(__BUTTON_OK))
            {
                if (__editable)
                {
                    applyChanges();
                }
                closeWindow();
            }
            else
            {
                // a combo box action triggered it.
                validateData();
            }
        }
        /// <summary>
        /// Handle action events. </summary>
        /// <param name="event"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent @event)
        {
            string routine = "StateMod_QueryTool_JFrame.actionPerformed";

            string action = @event.getActionCommand();

            if (action.Equals(__Cancel_String))
            {
                closeWindow();
            }
            else if (action.Equals(__Display_String))
            {
                try
                {
                    displayQueryResults();
                }
                catch (Exception e)
                {
                    Message.printWarning(1, routine, "Unable to display query results.", this);
                    Message.printWarning(2, routine, e);
                }
            }
            else if (action.Equals(__Query_String))
            {
                try
                {
                    doQuery();
                }
                catch (Exception)
                {
                    __status_JTextField.setText(__Ready);
                    JGUIUtil.setWaitCursor(this, false);
                }
            }
        }
Example #4
0
        /// <summary>
        /// Responds to action performed events. </summary>
        /// <param name="ae"> the ActionEvent that occurred. </param>
        public virtual void actionPerformed(ActionEvent ae)
        {
            string action = ae.getActionCommand();

            if (action.Equals(__BUTTON_BROWSE))
            {
                string file = browseForFile();
                if (file.Trim().Equals(""))
                {
                    return;
                }
                __tableModel.setValueAt(file, __worksheet.getSelectedRow(), StateMod_Response_TableModel.COL_NAME);
            }
            else if (action.Equals(__BUTTON_APPLY))
            {
                saveData();
            }
            else if (action.Equals(__BUTTON_CANCEL))
            {
                closeWindow();
            }
            else if (action.Equals(__BUTTON_CLOSE))
            {
                if (saveData())
                {
                    closeWindow();
                }
            }
            else if (action.Equals(__BUTTON_HELP))
            {
                // TODO HELP(JTS - 2003-09-10)
            }
        }
        /// <summary>
        /// Responds to action performed events. </summary>
        /// <param name="e"> the ActionEvent that occurred. </param>
        public virtual void actionPerformed(ActionEvent e)
        {
            string action = e.getActionCommand();

            if (action.Equals(__BUTTON_ADD_OWNER))
            {
                StateMod_ReservoirAccount anAccount = new StateMod_ReservoirAccount();
                anAccount._isClone = true;
                int rowCount = __worksheet.getRowCount();
                if (rowCount == 0)
                {
                    anAccount.setID(1);
                }
                else
                {
                    StateMod_ReservoirAccount lastAccount = (StateMod_ReservoirAccount)__worksheet.getLastRowData();
                    string id = lastAccount.getID();
                    anAccount.setID("" + ((Convert.ToInt32(id)) + 1));
                }
                __worksheet.addRow(anAccount);
                __worksheet.scrollToLastRow();
                __worksheet.selectLastRow();
                __deleteOwner.setEnabled(true);
            }
            else if (action.Equals(__BUTTON_DEL_OWNER))
            {
                int row = __worksheet.getSelectedRow();
                if (row != -1)
                {
                    int x = (new ResponseJDialog(this, "Delete owner", "Delete owner?", ResponseJDialog.YES | ResponseJDialog.NO)).response();
                    if (x == ResponseJDialog.NO)
                    {
                        return;
                    }
                    __worksheet.deleteRow(row);
                    __deleteOwner.setEnabled(false);
                }
            }
            else if (action.Equals(__BUTTON_CLOSE))
            {
                if (saveData())
                {
                    setVisible(false);
                    dispose();
                }
            }
            else if (action.Equals(__BUTTON_APPLY))
            {
                saveData();
            }
            else if (action.Equals(__BUTTON_CANCEL))
            {
                setVisible(false);
                dispose();
            }
            else if (action.Equals(__BUTTON_HELP))
            {
                // REVISIT HELP (JTS - 2003-06-09)
            }
        }
        /// <summary>
        /// Responds to action events. </summary>
        /// <param name="event"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent @event)
        {
            if (__ignoreEvents)
            {
                return;
            }
            string action = @event.getActionCommand();
            object source = @event.getSource();

            if (action.Equals(__BUTTON_CANCEL))
            {
                cancelClicked();
            }
            else if (action.Equals(__BUTTON_OK) || action.Equals(__BUTTON_APPLY))
            {
                applyClicked();
                if (action.Equals(__BUTTON_OK))
                {
                    setVisible(false);
                    dispose();
                }
            }
            else if (source == __typeComboBox)
            {
                string type = __typeComboBox.getSelected();
                if (type.Equals(__NODE_RESERVOIR))
                {
                    __reservoirDirectionLabel.setVisible(true);
                    __reservoirDirectionComboBox.setVisible(true);
                }
                else
                {
                    __reservoirDirectionLabel.setVisible(false);
                    __reservoirDirectionComboBox.setVisible(false);
                }
            }
            else if (source == __isNaturalFlowCheckBox)
            {
                if (__isNaturalFlowCheckBox.isSelected())
                {
                    __areaTextField.setEnabled(true);
                    __precipitationTextField.setEnabled(true);
                }
                else
                {
                    __areaTextField.setEnabled(false);
                    __precipitationTextField.setEnabled(false);
                }
            }
            else if (source == __isImportCheckBox)
            {
                if (__isImportCheckBox.isSelected())
                {
                }
                else
                {
                }
            }
        }
Example #7
0
        /// <summary>
        /// Responds to action performed events. </summary>
        /// <param name="e"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent e)
        {
            string action = e.getActionCommand();

            if (action.Equals(__GraphArea_String))
            {
                graph(__GraphArea_String);
            }
            else if (action.Equals(__GraphSeepage_String))
            {
                graph(__GraphSeepage_String);
            }
            else if (action.Equals(__BUTTON_ADD_AREA_CAPACITY))
            {
                StateMod_ReservoirAreaCap anAreaCapNode = new StateMod_ReservoirAreaCap();
                anAreaCapNode._isClone = true;
                __worksheet.addRow(anAreaCapNode);
                __worksheet.scrollToLastRow();
                __worksheet.selectLastRow();
                __deleteAreaCap.setEnabled(true);
            }
            else if (action.Equals(__BUTTON_DEL_AREA_CAPACITY))
            {
                int row = __worksheet.getSelectedRow();
                if (row != -1)
                {
                    int x = (new ResponseJDialog(this, "Delete Content/Area/Seepage line?", "Delete Content/Area/Seepage line?", ResponseJDialog.YES | ResponseJDialog.NO)).response();
                    if (x == ResponseJDialog.NO)
                    {
                        return;
                    }
                    __worksheet.deleteRow(row);
                    __deleteAreaCap.setEnabled(false);
                }
            }
            else if (action.Equals(__BUTTON_CLOSE))
            {
                if (saveData())
                {
                    setVisible(false);
                    dispose();
                }
            }
            else if (action.Equals(__BUTTON_APPLY))
            {
                saveData();
            }
            else if (action.Equals(__BUTTON_CANCEL))
            {
                setVisible(false);
                dispose();
            }
            else if (action.Equals(__BUTTON_HELP))
            {
                // REVISIT HELP (JTS - 2003-06-09)
            }
        }
	/// <summary>
	/// Responds to action performed events. </summary>
	/// <param name="e"> the ActionEvent that happened. </param>
	public virtual void actionPerformed(ActionEvent e)
	{
		try
		{
		string action = e.getActionCommand();
		object source = e.getSource();

		if (action.Equals(__BUTTON_HELP))
		{
			// REVISIT HELP (JTS - 2003-06-10
		}
		else if (action.Equals(__BUTTON_CLOSE))
		{
			saveCurrentRecord();
			dispose();
		}
		else if (action.Equals(__BUTTON_APPLY))
		{
			saveCurrentRecord();
		}
		else if (action.Equals(__BUTTON_CANCEL))
		{
			dispose();
		}
		else if (action.Equals(__BUTTON_GRAPH) || action.Equals(__BUTTON_TABLE) || action.Equals(__BUTTON_SUMMARY))
		{
			displayTSViewJFrame(action);
		}
		else if (source == __findNextStation)
		{
			searchWorksheet(__worksheet.getSelectedRow() + 1);
		}
		else if (source == __searchID || source == __searchName)
		{
			searchWorksheet();
		}
		else if (source == __searchNameJRadioButton)
		{
			__searchName.setEditable(true);
			__searchID.setEditable(false);
		}
		else if (source == __searchIDJRadioButton)
		{
			__searchName.setEditable(false);
			__searchID.setEditable(true);
		}

		}
		catch (Exception ex)
		{
			Console.WriteLine(ex.ToString());
			Console.Write(ex.StackTrace);
		}
	}
        /// <summary>
        /// Responds to action performed events. </summary>
        /// <param name="e"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent e)
        {
            string action = e.getActionCommand();

            if (action.Equals(__BUTTON_ADD_DEPLETION))
            {
                StateMod_ReturnFlow aReturnFlow = new StateMod_ReturnFlow(StateMod_DataSet.COMP_WELL_STATIONS);
                aReturnFlow._isClone = true;
                __worksheet.addRow(aReturnFlow);
                __worksheet.scrollToLastRow();
                __worksheet.selectLastRow();
                __deleteDepletion.setEnabled(true);
            }
            else if (action.Equals(__BUTTON_DELETE_DEPLETION))
            {
                int row = __worksheet.getSelectedRow();
                if (row != -1)
                {
                    int x = (new ResponseJDialog(this, "Delete Depletion", "Delete depletion?", ResponseJDialog.YES | ResponseJDialog.NO)).response();
                    if (x == ResponseJDialog.NO)
                    {
                        return;
                    }
                    __worksheet.cancelEditing();
                    __worksheet.deleteRow(row);
                    __deleteDepletion.setEnabled(false);
                }
            }
            else if (action.Equals(__BUTTON_CLOSE))
            {
                if (saveData())
                {
                    setVisible(false);
                    dispose();
                }
            }
            else if (action.Equals(__BUTTON_APPLY))
            {
                saveData();
            }
            else if (action.Equals(__BUTTON_CANCEL))
            {
                setVisible(false);
                dispose();
            }
            else if (action.Equals(__BUTTON_HELP))
            {
                // REVISIT HELP (JTS - 2003-06-24)
            }
        }
Example #10
0
        /// <summary>
        /// Responds to action events. </summary>
        /// <param name="event"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent @event)
        {
            string routine = "StateMod_Data_JFrame.actionPerformed";

            string action = @event.getActionCommand();

            if (action.Equals(_BUTTON_APPLY))
            {
                _worksheet.stopEditing();
                apply();
            }
            else if (action.Equals(_BUTTON_CANCEL))
            {
                _worksheet.cancelEditing();
                cancel();
                closeJFrame();
            }
            else if (action.Equals(_BUTTON_EXPORT))
            {
                string[] s = getFilenameAndFormat();

                if (s == null)
                {
                    // user cancelled
                    return;
                }

                IList <string> v = formatOutput(s[1], true, true);
                try
                {
                    export(s[0], v);
                }
                catch (Exception e)
                {
                    Message.printWarning(1, routine, "Error exporting data.");
                    Message.printWarning(2, routine, e);
                }
            }
            else if (action.Equals(_BUTTON_OK))
            {
                _worksheet.stopEditing();
                apply();
                closeJFrame();
            }
            else if (action.Equals(_BUTTON_PRINT))
            {
                print();
            }
        }
        /// <summary>
        /// Responds to action events. </summary>
        /// <param name="event"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent @event)
        {
            string action = @event.getActionCommand();

            if (action.Equals(__BUTTON_CANCEL))
            {
                dispose();
            }
            else if (action.Equals(__BUTTON_OK))
            {
                __device.addLink(__node1ComboBox.getSelected(), __node2ComboBox.getSelected(), __linkId_JTextField.getText(), __lineStyleComboBox.getSelected(), __fromArrowStyleComboBox.getSelected(), __toArrowStyleComboBox.getSelected());
                dispose();
            }
            else
            {
                checkValidity();
            }
        }
        /// <summary>
        /// Handle action events.
        /// </summary>
        public virtual void actionPerformed(ActionEvent @event)
        {
            string action = @event.getActionCommand();

            if (action.Equals(__RemoveAllAnnotationsString))
            {
                // Remove from the list and the original data that was passed in
                __annotationJListModel.clear();
                if (__annotationDataList != null)
                {
                    if (__networkJComponent != null)
                    {
                        // TODO SAM 2010-12-28 Enable
                        __networkJComponent.clearAnnotations();                 // This will modify __annotationDataList
                    }
                }
                checkVisibility();
            }
        }
        /// <summary>
        /// Responds to action performed events. </summary>
        /// <param name="e"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent e)
        {
            string action = e.getActionCommand();

            if (action.Equals(__BUTTON_VIEW_EDIT))
            {
                editSelectedFile();
            }
            else if (e.getSource() == __fileJList)
            {
                editSelectedFile();
            }
            else if (action.Equals(__BUTTON_HELP))
            {
                // REVISIT HELP (JTS - 2003-08-20)
            }
            else if (action.Equals(__BUTTON_CLOSE))
            {
                closeWindow();
            }
        }
Example #14
0
        /* Events */

        /**
         * Actions for button presses.
         * @param e the ActionEvent
         */
        public void actionPerformed(ActionEvent e)
        {
            String command = e.getActionCommand();

            if (debug)
            {
                Console.WriteLine(command);
            }
            if (command == "voronoi")
            {
                isVoronoi = true;
            }
            else if (command == "delaunay")
            {
                isVoronoi = false;
            }
            else if (command == "clear")
            {
                dt = new DelaunayTriangulation(initialTriangle);
            }
            repaint();
        }
Example #15
0
        /// <summary>
        /// Responds to action performed events. </summary>
        /// <param name="ae"> the ActionEvent that occurred. </param>
        public virtual void actionPerformed(ActionEvent ae)
        {
            string action = ae.getActionCommand();

            if (action.Equals(__BUTTON_CANCEL))
            {
                closeWindow();
            }
            else if (action.Equals(__BUTTON_SAVE))
            {
                if (saveData())
                {
                    if (__dataset_wm != null)
                    {
                        __dataset_wm.updateWindowStatus(StateMod_DataSet_WindowManager.WINDOW_MAIN);
                    }
                    closeWindow();
                }
            }
            else if (action.Equals(__BUTTON_HELP))
            {
                // TODO HELP (JTS - 2003-09-10)
            }
        }
        /// <summary>
        /// Responds to action performed events. </summary>
        /// <param name="e"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent e)
        {
            string routine = "StateMod_RunReport_JFrame.actionPerformed";
            string action  = e.getActionCommand();

            if (action.Equals(__BUTTON_RUN_REPORT))
            {
                JRadioButton cb = getSelectedJRadioButton();
                if (cb == null)
                {
                    return;
                }
                StringBuilder sb = new StringBuilder("-report ");
                sb.Append(cb.getText());

                // now check if station id is needed; if so, append it
                if (cb == __xdgJRadioButton)
                {
                    sb.Append(" -");
                    sb.Append(StringUtil.getToken(__xdgSimpleJComboBox.getSelected(), " ", 0, 0));
                }
                else if (cb == __xrgJRadioButton)
                {
                    sb.Append(" -");
                    sb.Append(StringUtil.getToken(__xrgSimpleJComboBox.getSelected(), " ", 0, 0));
                }
                else if (cb == __xwgJRadioButton)
                {
                    sb.Append(" -");
                    sb.Append(StringUtil.getToken(__xwgSimpleJComboBox.getSelected(), " ", 0, 0));
                }

                string s = sb.ToString();
                try
                {         // Run the report using the process manager dialog.
                    // Pass in the main GUI class so that the modal process
                    // manager dialog is on top of that window.
                    Message.printStatus(1, routine, "Running statemod " + "with command line options: '" + sb + "'");
                    StateMod_Util.runStateMod(__dataset, s, true, __dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_MAIN));
                }
                catch (Exception)
                {
                    Message.printWarning(1, routine, "There was an error running:  \n" + s, this);
                }
            }
            else if (action.Equals(__BUTTON_CANCEL))
            {
                if (__dataset_wm != null)
                {
                    __dataset_wm.closeWindow(StateMod_DataSet_WindowManager.WINDOW_RUN_REPORT);
                }
                else
                {
                    JGUIUtil.close(this);
                }
            }
            else if (action.Equals(__BUTTON_HELP))
            {
                // REVISIT HELP (JTS - 2003-08-21)
            }
        }
        /// <summary>
        /// Responds to action performed events. </summary>
        /// <param name="e"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent e)
        {
            string routine = "StateMod_RiverNetworkNode_JFrame.actionPerformed";

            if (Message.isDebugOn)
            {
                Message.printDebug(1, routine, "In actionPerformed: " + e.getActionCommand());
            }
            object source = e.getSource();

            if (source == __closeJButton)
            {
                saveCurrentRecord();
                int size = __riverNetworkNodesVector.Count;
                StateMod_RiverNetworkNode r = null;
                bool changed = false;
                for (int i = 0; i < size; i++)
                {
                    r = __riverNetworkNodesVector[i];
                    if (!changed && r.changed())
                    {
                        changed = true;
                    }
                    r.acceptChanges();
                }
                if (changed)
                {
                    __dataset.setDirty(StateMod_DataSet.COMP_RIVER_NETWORK, true);
                }
                if (__dataset_wm != null)
                {
                    __dataset_wm.closeWindow(StateMod_DataSet_WindowManager.WINDOW_RIVER_NETWORK);
                }
                else
                {
                    JGUIUtil.close(this);
                }
            }
            else if (source == __applyJButton)
            {
                saveCurrentRecord();
                int size = __riverNetworkNodesVector.Count;
                StateMod_RiverNetworkNode r = null;
                bool changed = false;
                for (int i = 0; i < size; i++)
                {
                    r = __riverNetworkNodesVector[i];
                    if (!changed && r.changed())
                    {
                        changed = true;
                    }
                    r.createBackup();
                }
                if (changed)
                {
                    __dataset.setDirty(StateMod_DataSet.COMP_RIVER_NETWORK, true);
                }
            }
            else if (source == __cancelJButton)
            {
                int size = __riverNetworkNodesVector.Count;
                StateMod_RiverNetworkNode r = null;
                for (int i = 0; i < size; i++)
                {
                    r = __riverNetworkNodesVector[i];
                    r.restoreOriginal();
                }
                if (__dataset_wm != null)
                {
                    __dataset_wm.closeWindow(StateMod_DataSet_WindowManager.WINDOW_RIVER_NETWORK);
                }
                else
                {
                    JGUIUtil.close(this);
                }
            }
            else if (source == __helpJButton)
            {
                // REVISIT HELP (JTS - 2003-08-18)
            }
            else if (source == __searchIDJRadioButton)
            {
                __searchName.setEditable(false);
                __searchID.setEditable(true);
            }
            else if (source == __searchNameJRadioButton)
            {
                __searchName.setEditable(true);
                __searchID.setEditable(false);
            }
            else if (source == __showOnMap_JButton)
            {
                GeoRecord geoRecord = getSelectedRiverNetworkNode().getGeoRecord();
                GRShape   shape     = geoRecord.getShape();
                __dataset_wm.showOnMap(getSelectedRiverNetworkNode(), "Node: " + getSelectedRiverNetworkNode().getID() + " - " + getSelectedRiverNetworkNode().getName(), new GRLimits(shape.xmin, shape.ymin, shape.xmax, shape.ymax), geoRecord.getLayer().getProjection());
            }
            else if (source == __showOnNetwork_JButton)
            {
                StateMod_Network_JFrame networkEditor = __dataset_wm.getNetworkEditor();
                if (networkEditor != null)
                {
                    HydrologyNode node = networkEditor.getNetworkJComponent().findNode(getSelectedRiverNetworkNode().getID(), false, false);
                    if (node != null)
                    {
                        __dataset_wm.showOnNetwork(getSelectedRiverNetworkNode(), "Node: " + getSelectedRiverNetworkNode().getID() + " - " + getSelectedRiverNetworkNode().getName(), new GRLimits(node.getX(), node.getY(), node.getX(), node.getY()));
                    }
                }
            }
            else if (source == __findNext)
            {
                searchWorksheet(__worksheet.getSelectedRow() + 1);
            }
            else if (source == __searchID || source == __searchName)
            {
                searchWorksheet(0);
            }
        }
        /// <summary>
        /// Responds to action performed events. </summary>
        /// <param name="ae"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent ae)
        {
            string routine = "StateMod_OutputControl_JFrame.actionPerformed";
            string action  = ae.getActionCommand();

            if (action.Equals(__BUTTON_ADD_ROW))
            {
                if (!__tableModel.canAddNewRow())
                {
                    return;
                }
                __dirty = true;
                int row = __worksheet.getRowCount();

                StateMod_GraphNode n = new StateMod_GraphNode();
                __worksheet.addRow(n);
                n.setType("");
                n.setID("");
                n.setSwitch(-1);
                __tableModel.setDirty(true);

                // when a row is added, mark the second and third columns
                // as uneditable.  They will be set to editable as soon as
                // the user enters a value in the first column
                __worksheet.setCellEditable(row, 1, false);
                __worksheet.setCellEditable(row, 2, false);
            }
            else if (action.Equals(__BUTTON_CLEAR_LIST))
            {
                __dirty = true;
                __worksheet.clear();
                setMessages("Add station to list.", "Ready");
                __tableModel.setDirty(true);
            }
            else if (action.Equals(__BUTTON_CLOSE))
            {
                closeWindow();
            }
            else if (action.Equals(__BUTTON_DELETE_ROW))
            {
                int[] rows = __worksheet.getSelectedRows();

                int length = rows.Length;
                __tableModel.setDirty(true);

                if (length == 0)
                {
                    return;
                }

                for (int i = (length - 1); i >= 0; i--)
                {
                    __worksheet.deleteRow(rows[i]);
                }
                __dirty = true;
                setMessages("Time series list has changed.", "Ready");
            }
            else if (action.Equals(__BUTTON_HELP))
            {
                // REVISIT HELP (JTS - 2003-07-09)
            }
            else if (action.Equals(__BUTTON_SAVE_FILE))
            {
                JGUIUtil.setWaitCursor(this, true);
                string lastDirectorySelected = JGUIUtil.getLastFileDialogDirectory();

                JFileChooser fc = null;
                if (!string.ReferenceEquals(lastDirectorySelected, null))
                {
                    fc = new JFileChooser(lastDirectorySelected);
                }
                else
                {
                    fc = new JFileChooser();
                }

                fc.setDialogTitle("Select Output Control File");
                SimpleFileFilter @out = new SimpleFileFilter("out", "StateMod Output Control Files");
                fc.addChoosableFileFilter(@out);
                SimpleFileFilter tpl = new SimpleFileFilter("tpo", "StateMod Output Control Files");
                fc.addChoosableFileFilter(tpl);
                SimpleFileFilter xou = new SimpleFileFilter("xou", "StateMod Output Control Files");
                fc.addChoosableFileFilter(xou);
                fc.setAcceptAllFileFilterUsed(false);
                fc.setFileFilter(tpl);
                fc.setDialogType(JFileChooser.SAVE_DIALOG);

                JGUIUtil.setWaitCursor(this, false);

                int retVal = fc.showSaveDialog(this);
                if (retVal != JFileChooser.APPROVE_OPTION)
                {
                    return;
                }

                string currDir = (fc.getCurrentDirectory()).ToString();

                if (!currDir.Equals(lastDirectorySelected, StringComparison.OrdinalIgnoreCase))
                {
                    JGUIUtil.setLastFileDialogDirectory(currDir);
                }
                string filename = fc.getSelectedFile().getName();

                FileFilter ff = fc.getFileFilter();
                if (ff == @out)
                {
                    filename = IOUtil.enforceFileExtension(filename, "out");
                }
                else if (ff == tpl)
                {
                    filename = IOUtil.enforceFileExtension(filename, "tpo");
                }
                else if (ff == xou)
                {
                    filename = IOUtil.enforceFileExtension(filename, "xou");
                }

                __dirty = false;
                __tableModel.setDirty(false);

                System.Collections.IList theGraphNodes = __worksheet.getAllData();

                try
                {
                    StateMod_GraphNode.writeStateModOutputControlFile(null, currDir + File.separator + filename, theGraphNodes, null);
                }
                catch (Exception e)
                {
                    Message.printWarning(1, routine, "Error saving output control file\n" + "\"" + currDir + File.separator + filename + "\"", this);
                    Message.printWarning(2, routine, e);
                }
            }
            else if (action.Equals(__BUTTON_LOAD_FILE))
            {
                JGUIUtil.setWaitCursor(this, true);
                string lastDirectorySelected = JGUIUtil.getLastFileDialogDirectory();

                JFileChooser fc = null;
                if (!string.ReferenceEquals(lastDirectorySelected, null))
                {
                    fc = new JFileChooser(lastDirectorySelected);
                }
                else
                {
                    fc = new JFileChooser();
                }

                fc.setDialogTitle("Select Output Control File");
                SimpleFileFilter @out = new SimpleFileFilter("out", "StateMod Output Control Files");
                fc.addChoosableFileFilter(@out);
                SimpleFileFilter tpl = new SimpleFileFilter("tpo", "StateMod Output Control Files");
                fc.addChoosableFileFilter(tpl);
                SimpleFileFilter xou = new SimpleFileFilter("xou", "StateMod Output Control Files");
                fc.addChoosableFileFilter(xou);
                fc.setAcceptAllFileFilterUsed(false);
                fc.setFileFilter(tpl);
                fc.setDialogType(JFileChooser.OPEN_DIALOG);

                JGUIUtil.setWaitCursor(this, false);
                int retVal = fc.showOpenDialog(this);
                if (retVal != JFileChooser.APPROVE_OPTION)
                {
                    return;
                }

                string currDir = (fc.getCurrentDirectory()).ToString();

                if (!currDir.Equals(lastDirectorySelected, StringComparison.OrdinalIgnoreCase))
                {
                    JGUIUtil.setLastFileDialogDirectory(currDir);
                }
                string filename = fc.getSelectedFile().getName();

                JGUIUtil.setWaitCursor(this, true);

                __dirty = false;

                System.Collections.IList theGraphNodes = new List <object>(20, 1);

                try
                {
                    __worksheet.clear();
                    __tableModel.setDirty(false);
                    StateMod_GraphNode.readStateModOutputControlFile(theGraphNodes, currDir + File.separator + filename);

                    int size             = theGraphNodes.Count;
                    StateMod_GraphNode g = null;
                    int row = 0;
                    for (int i = 0; i < size; i++)
                    {
                        row = __worksheet.getRowCount();
                        g   = (StateMod_GraphNode)theGraphNodes[i];
                        if (i == 0)
                        {
                            if (g.getID().Equals("All"))
                            {
                                __useAllJCheckBox.setSelected(true);
                            }
                            else
                            {
                                __useAllJCheckBox.setSelected(false);
                            }
                        }
                        __worksheet.addRow(g);

                        __tableModel.fillIDColumn(row, g.getType());
                    }
                    __worksheet.setData(theGraphNodes);
                }
                catch (Exception e)
                {
                    Message.printWarning(1, routine, "Error loading output control file\n" + "\"" + currDir + File.separator + filename + "\"", this);
                    Message.printWarning(2, routine, e);
                }
                JGUIUtil.setWaitCursor(this, false);
            }
            else if (action.Equals(__CHECKBOX_USE_ALL))
            {
                // if the use all checkbox is selected, subtle changes from the
                // default functionality are made.  The buttons to add and
                // delete rows are disabled, and the ID of the only record
                // in the worksheet is set to "All".  This ID value is used
                // in the table model to determine when the checkbox is
                // selected.  In addition, the ComboBox functionality of the
                // first and third data columns is turned off.

                if (__useAllJCheckBox.isSelected())
                {
                    __addRowButton.setEnabled(false);
                    __deleteRowButton.setEnabled(false);
                    __worksheet.setColumnJComboBoxValues(0, null);
                    __worksheet.setColumnJComboBoxValues(2, null);
                    __worksheet.clear();
                    StateMod_GraphNode g = new StateMod_GraphNode();
                    g.setID("All");
                    __worksheet.setCellEditable(0, 0, false);
                    __worksheet.setCellEditable(0, 1, false);
                    __worksheet.setCellEditable(0, 2, false);
                    __worksheet.addRow(g);
                }
                else
                {
                    __addRowButton.setEnabled(true);
                    __deleteRowButton.setEnabled(true);
                    System.Collections.IList v = StateMod_Util.arrayToList(StateMod_GraphNode.node_types);
                    v.Add("Other");
                    __worksheet.setColumnJComboBoxValues(0, v);
                    __worksheet.clear();
                    System.Collections.IList offOn = new List <object>();
                    offOn.Add("Off");
                    offOn.Add("On");
                    __worksheet.setCellEditable(0, 0, true);
                    __worksheet.setColumnJComboBoxValues(2, offOn);
                }
            }
        }
        /// <summary>
        /// Reponds to action performed events. </summary>
        /// <param name="e"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent e)
        {
            string action = e.getActionCommand();

            if (action.Equals(__BUTTON_ADD_PRECIPITATION_STATION))
            {
                StateMod_ReservoirClimate aClimateNode = new StateMod_ReservoirClimate();
                aClimateNode._isClone = true;
                aClimateNode.setType(StateMod_ReservoirClimate.CLIMATE_PTPX);
                __worksheetP.addRow(aClimateNode);
                __worksheetP.scrollToLastRow();
                __worksheetP.selectLastRow();
                checkDeleteStationButton();
            }
            else if (action.Equals(__BUTTON_ADD_EVAPORATION_STATION))
            {
                StateMod_ReservoirClimate aClimateNode = new StateMod_ReservoirClimate();
                aClimateNode._isClone = true;
                aClimateNode.setType(StateMod_ReservoirClimate.CLIMATE_EVAP);
                __worksheetE.addRow(aClimateNode);
                __worksheetE.scrollToLastRow();
                __worksheetE.selectLastRow();
                checkDeleteStationButton();
            }
            else if (action.Equals(__BUTTON_DELETE_PRECIPITATION_STATION))
            {
                int rowP  = __worksheetP.getSelectedRow();
                int rowE  = __worksheetE.getSelectedRow();
                int count = 0;
                if (rowP > -1)
                {
                    count++;
                }
                if (rowE > -1)
                {
                    count++;
                }
                if (count > 0)
                {
                    string plural = "s";
                    if (count == 1)
                    {
                        plural = "";
                    }
                    int x = (new ResponseJDialog(this, "Delete climate station" + plural, "Delete climate station" + plural + "?", ResponseJDialog.YES | ResponseJDialog.NO)).response();
                    if (x == ResponseJDialog.NO)
                    {
                        return;
                    }
                    if (rowP > -1)
                    {
                        __worksheetP.deleteRow(rowP);
                        __deleteStation.setEnabled(false);
                        __worksheetP.scrollToLastRow();
                    }
                    if (rowE > -1)
                    {
                        __worksheetE.deleteRow(rowE);
                        __deleteStation.setEnabled(false);
                        __worksheetE.scrollToLastRow();
                    }
                }
            }
            else if (action.Equals(__BUTTON_CLOSE))
            {
                if (saveData())
                {
                    setVisible(false);
                    dispose();
                }
            }
            else if (action.Equals(__BUTTON_APPLY))
            {
                saveData();
            }
            else if (action.Equals(__BUTTON_CANCEL))
            {
                setVisible(false);
                dispose();
            }
            else if (action.Equals(__BUTTON_HELP))
            {
                // REVISIT HELP (JTS - 2003-06-09)
            }
        }
        /// <summary>
        /// Responds to action performed events sent by popup menus of the tree nodes. </summary>
        /// <param name="event"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent @event)
        {
            string action  = @event.getActionCommand();
            string routine = "StateMod_DataSet_JTree.actionPerformed";

            object data = __popup_Node.getData();

            if (data is DataSetComponent)
            {
                DataSetComponent comp = (DataSetComponent)data;
                int comp_type         = comp.getComponentType();
                if (comp_type == StateMod_DataSet.COMP_CONTROL_GROUP)
                {
                    __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_CONTROL, __editable);
                }
                else if (comp_type == StateMod_DataSet.COMP_STREAMGAGE_GROUP)
                {
                    __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMGAGE, __editable);
                }
                else if (comp_type == StateMod_DataSet.COMP_DELAY_TABLE_MONTHLY_GROUP)
                {
                    __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_MONTHLY, __editable);
                }
                else if (comp_type == StateMod_DataSet.COMP_DELAY_TABLE_DAILY_GROUP)
                {
                    __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_DAILY, __editable);
                }
                else if (comp_type == StateMod_DataSet.COMP_DIVERSION_GROUP)
                {
                    __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DIVERSION, __editable);
                }
                else if (comp_type == StateMod_DataSet.COMP_PRECIPITATION_GROUP)
                {
                    __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_PRECIPITATION, __editable);
                }
                else if (comp_type == StateMod_DataSet.COMP_EVAPORATION_GROUP)
                {
                    __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_EVAPORATION, __editable);
                }
                else if (comp_type == StateMod_DataSet.COMP_RESERVOIR_GROUP)
                {
                    __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_RESERVOIR, __editable);
                }
                else if (comp_type == StateMod_DataSet.COMP_INSTREAM_GROUP)
                {
                    __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_INSTREAM, __editable);
                }
                else if (comp_type == StateMod_DataSet.COMP_WELL_GROUP)
                {
                    __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_WELL, __editable);
                }
                else if (comp_type == StateMod_DataSet.COMP_PLAN_GROUP)
                {
                    __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_PLAN, __editable);
                }
                else if (comp_type == StateMod_DataSet.COMP_STREAMESTIMATE_GROUP)
                {
                    __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMESTIMATE, __editable);
                }
                else if (comp_type == StateMod_DataSet.COMP_RIVER_NETWORK_GROUP)
                {
                    __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_RIVER_NETWORK, __editable);
                }
                else if (comp_type == StateMod_DataSet.COMP_OPERATION_GROUP)
                {
                    __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_OPERATIONAL_RIGHT, __editable);
                }
            }
            // Below here are specific instances of objects.  Similar to above,
            // display the main window but then also select the specific object...
            else if (data is StateMod_StreamGage)
            {
                __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMGAGE, __editable);
                ((StateMod_StreamGage_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMGAGE)).selectID(((StateMod_StreamGage)data).getID());
            }
            else if (data is StateMod_DelayTable)
            {
                StateMod_DelayTable dt = (StateMod_DelayTable)data;
                if (dt.isMonthly())
                {
                    __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_MONTHLY, __editable);
                    ((StateMod_DelayTable_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_MONTHLY)).selectID(dt.getID());
                }
                else
                {
                    __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_DAILY, __editable);
                    ((StateMod_DelayTable_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_DAILY)).selectID(dt.getID());
                }
            }
            else if (data is StateMod_Diversion)
            {
                if (action.IndexOf(__SUMMARIZE_HOW1, StringComparison.Ordinal) >= 0)
                {
                    PropList props = new PropList("Diversion");
                    props.set("Title=" + ((StateMod_Diversion)data).getID() + " Diversion use in Data Set");
                    new ReportJFrame(__dataset.getDataObjectDetails(StateMod_DataSet.COMP_DIVERSION_STATIONS, ((StateMod_Diversion)data).getID()), props);
                }
                else
                {
                    // Assume properties...
                    __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DIVERSION, __editable);
                    ((StateMod_Diversion_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_DIVERSION)).selectID(((StateMod_Diversion)data).getID());
                }
            }
            else if (data is TS)
            {
                // Might be precipitation or evaporation.  Check the data type to determine...
                TS       ts    = (TS)data;
                PropList props = new PropList("Precipitation/Evaporation");
                if (action.IndexOf(__SUMMARIZE_HOW1, StringComparison.Ordinal) >= 0)
                {
                    if (StringUtil.startsWithIgnoreCase(ts.getDataType(), "e"))
                    {
                        props.set("Title=" + ts.getLocation() + " Evaporation TS use in Data Set");
                        new ReportJFrame(__dataset.getDataObjectDetails(StateMod_DataSet.COMP_EVAPORATION_TS_MONTHLY, ts.getLocation()), props);
                    }
                    else if (StringUtil.startsWithIgnoreCase(ts.getDataType(), "p"))
                    {
                        props.set("Title=" + ts.getLocation() + " Precipitation TS use in Data Set");
                        new ReportJFrame(__dataset.getDataObjectDetails(StateMod_DataSet.COMP_PRECIPITATION_TS_MONTHLY, ts.getLocation()), props);
                    }
                }
                else if (action.IndexOf(__PROPERTIES, StringComparison.Ordinal) >= 0)
                {
                    if (StringUtil.startsWithIgnoreCase(ts.getDataType(), "e"))
                    {
                        props.set("Title=Evaporation");
                    }
                    else if (StringUtil.startsWithIgnoreCase(ts.getDataType(), "p"))
                    {
                        props.set("Title=Precipitation");
                    }
                    props.set("InitialView=Graph");
                    props.set("GraphType=Bar");
                    System.Collections.IList tslist = new List <object>(1);
                    tslist.Add(ts);
                    try
                    {
                        new TSViewJFrame(tslist, props);
                    }
                    catch (Exception)
                    {
                        Message.printWarning(1, routine, "Error displaying data.");
                    }
                }
            }
            else if (data is StateMod_Reservoir)
            {
                __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_RESERVOIR, __editable);
                ((StateMod_Reservoir_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_RESERVOIR)).selectID(((StateMod_Reservoir)data).getID());
            }
            else if (data is StateMod_InstreamFlow)
            {
                __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_INSTREAM, __editable);
                ((StateMod_InstreamFlow_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_INSTREAM)).selectID(((StateMod_InstreamFlow)data).getID());
            }
            else if (data is StateMod_Well)
            {
                __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_WELL, __editable);
                ((StateMod_Well_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_WELL)).selectID(((StateMod_Well)data).getID());
            }
            else if (data is StateMod_Plan)
            {
                __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_PLAN, __editable);
                ((StateMod_Plan_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_PLAN)).selectID(((StateMod_Plan)data).getID());
            }
            else if (data is StateMod_StreamEstimate)
            {
                __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMESTIMATE, __editable);
                ((StateMod_StreamEstimate_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMESTIMATE)).selectID(((StateMod_StreamEstimate)data).getID());
            }
            else if (data is StateMod_RiverNetworkNode)
            {
                __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_RIVER_NETWORK, __editable);
                ((StateMod_RiverNetworkNode_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_RIVER_NETWORK)).selectID(((StateMod_RiverNetworkNode)data).getID());
            }
            else if (data is StateMod_OperationalRight)
            {
                __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_OPERATIONAL_RIGHT, __editable);
                ((StateMod_OperationalRight_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_OPERATIONAL_RIGHT)).selectID(((StateMod_OperationalRight)data).getID());
            }
        }
Example #21
0
    //when the user copies to clip board, select the entire table.
    //then pull the data off of the grid and create a string object
    //that is the formatted matrix that the UCI file expects.
    public void actionPerformed(ActionEvent e)
    {
        if (e.getActionCommand().compareTo("Copy") == 0)
        {
            StringBuffer sbf = new StringBuffer();
            // Check to ensure we have selected only a contiguous block of cells
            int numcols = jTable1.getColumnCount(); //jTable1.getSelectedColumnCount();
            int numrows = jTable1.getRowCount();    //jTable1.getSelectedRowCount();

            jTable1.selectAll();

            int[] rowsselected = jTable1.getSelectedRows();
            int[] colsselected = jTable1.getSelectedColumns();
            if (!((numrows - 1 == rowsselected[rowsselected.length - 1] - rowsselected[0] &&
                   numrows == rowsselected.length) &&
                  (numcols - 1 == colsselected[colsselected.length - 1] - colsselected[0] &&
                   numcols == colsselected.length)))
            {
                JOptionPane.showMessageDialog(null, "Invalid Copy Selection",
                                              "Invalid Copy Selection",
                                              JOptionPane.ERROR_MESSAGE);
                return;
            }
            //write the name of the calculator to the string buffer
            //xyang  sbf.append(" *** " + this.calculatorType + " ***\n");

            if (this.calculatorType == "TRAPEZOIDAL")
            {
                string txt = plotdata.trapPanel.lblChannelDepth.getText();      //xyang
                sbf.append(" *** " + txt + "      ");
                double outvalue = plotdata.value[0];
                sbf.append(outvalue + "***\n");

                txt = plotdata.trapPanel.lblTopChannelWidth.getText();
                sbf.append(" *** " + txt + "      ");
                outvalue = plotdata.value[1];
                sbf.append(outvalue + "***\n");

                txt = plotdata.trapPanel.lblSideChannelSlope.getText();
                sbf.append(" *** " + txt + "      ");
                outvalue = plotdata.value[2];
                sbf.append(outvalue + "***\n");

                txt = plotdata.trapPanel.lblChannelLength.getText();
                sbf.append(" *** " + txt + "      ");
                outvalue = plotdata.value[3];
                sbf.append(outvalue + "***\n");

                /*txt = plotdata.trapPanel.lblChannelMannigsValue.getText();
                 * sbf.append(" *** " + txt + "      ");
                 * outvalue = plotdata.value[4];
                 * sbf.append(outvalue + "***\n");*/

                /* txt = plotdata.trapPanel.lblChannelAvgSlope.getText();
                 * sbf.append(" *** " + txt + "      ");
                 * outvalue = plotdata.value[5];
                 * sbf.append(outvalue + "***\n");*/

                txt = plotdata.trapPanel.lblIncrement.getText();
                sbf.append(" *** " + txt + "      ");
                outvalue = plotdata.value[6];
                sbf.append(outvalue + "***\n");
            }
            else if (this.calculatorType == "PARABOLIC")
            {
                string txt = plotdata.parabolicPanel.lblChannelLength.getText();     //xyang
                sbf.append(" *** " + txt + "      ");
                double outvalue = plotdata.value[0];
                sbf.append(outvalue + "***\n");

                txt = plotdata.parabolicPanel.lblChannelWidth.getText();
                sbf.append(" *** " + txt + "      ");
                outvalue = plotdata.value[1];
                sbf.append(outvalue + "***\n");

                txt = plotdata.parabolicPanel.lblChannelDepth.getText();
                sbf.append(" *** " + txt + "      ");
                outvalue = plotdata.value[2];
                sbf.append(outvalue + "***\n");

                /*txt = plotdata.parabolicPanel.lblChannelMannigsValue.getText();
                 * sbf.append(" *** " + txt + "      ");
                 * outvalue = plotdata.value[3];
                 * sbf.append(outvalue + "***\n");
                 *
                 * txt = plotdata.parabolicPanel.lblChannelAvgSlope.getText();
                 * sbf.append(" *** " + txt + "      ");
                 * outvalue = plotdata.value[4];
                 * sbf.append(outvalue + "***\n");*/

                txt = plotdata.parabolicPanel.lblIncrement.getText();
                sbf.append(" *** " + txt + "      ");
                outvalue = plotdata.value[5];
                sbf.append(outvalue + "***\n");
            }
            else if (this.calculatorType == "CIRCULAR")
            {
                string txt = plotdata.circPanel.lblChannelLength.getText();     //xyang
                sbf.append(" *** " + txt + "      ");
                double outvalue = plotdata.value[0];
                sbf.append(outvalue + "***\n");

                txt = plotdata.circPanel.lblChannelDiameter.getText();      //xyang
                sbf.append(" *** " + txt + "      ");
                outvalue = plotdata.value[1];
                sbf.append(outvalue + "***\n");

                /*txt = plotdata.circPanel.lblChannelMannigsValue.getText();//xyang
                 * sbf.append(" *** " + txt + "      ");
                 * outvalue = plotdata.value[2];
                 * sbf.append(outvalue + "***\n");*/

                txt = plotdata.circPanel.lblChannelAvgSlope.getText();      //xyang
                sbf.append(" *** " + txt + "      ");
                outvalue = plotdata.value[3];
                sbf.append(outvalue + "***\n");

                txt = plotdata.circPanel.lblIncrement.getText();      //xyang
                sbf.append(" *** " + txt + "      ");
                outvalue = plotdata.value[4];
                sbf.append(outvalue + "***\n");
            }
            else if (this.calculatorType == "RECTANGULAR")
            {
                string txt = plotdata.recPanel.lblChannelDepth.getText();     //xyang
                sbf.append(" *** " + txt + "      ");
                double outvalue = plotdata.value[0];
                sbf.append(outvalue + "***\n");

                txt = plotdata.recPanel.lblChannelWidth.getText();      //xyang
                sbf.append(" *** " + txt + "      ");
                outvalue = plotdata.value[1];
                sbf.append(outvalue + "***\n");

                txt = plotdata.recPanel.lblChannelLength.getText();      //xyang
                sbf.append(" *** " + txt + "      ");
                outvalue = plotdata.value[2];
                sbf.append(outvalue + "***\n");

                /*txt = plotdata.recPanel.lblChannelMannigsValue.getText();//xyang
                 * sbf.append(" *** " + txt + "      ");
                 * outvalue = plotdata.value[3];
                 * sbf.append(outvalue + "***\n");*/

                /*txt = plotdata.recPanel.lblChannelAvgSlope.getText();//xyang
                 * sbf.append(" *** " + txt + "      ");
                 * outvalue = plotdata.value[4];
                 * sbf.append(outvalue + "***\n");*/

                txt = plotdata.recPanel.lblIncrement.getText();      //xyang
                sbf.append(" *** " + txt + "      ");
                outvalue = plotdata.value[5];
                sbf.append(outvalue + "***\n");
            }

            else if (this.calculatorType == "TRIANGULAR")
            {
                string txt = plotdata.triPanel.lblChannelDepth.getText();     //xyang
                sbf.append(" *** " + txt + "      ");
                double outvalue = plotdata.value[0];
                sbf.append(outvalue + "***\n");

                txt = plotdata.triPanel.lblChannelWidth.getText();      //xyang
                sbf.append(" *** " + txt + "      ");
                outvalue = plotdata.value[1];
                sbf.append(outvalue + "***\n");

                txt = plotdata.triPanel.lblChannelLength.getText();      //xyang
                sbf.append(" *** " + txt + "      ");
                outvalue = plotdata.value[2];
                sbf.append(outvalue + "***\n");

                /*txt = plotdata.triPanel.lblChannelMannigsValue.getText();//xyang
                 * sbf.append(" *** " + txt + "      ");
                 * outvalue = plotdata.value[3];
                 * sbf.append(outvalue + "***\n");
                 *
                 * txt = plotdata.triPanel.lblChannelAvgSlope.getText();//xyang
                 * sbf.append(" *** " + txt + "      ");
                 * outvalue = plotdata.value[4];
                 * sbf.append(outvalue + "***\n");*/

                txt = plotdata.triPanel.lblIncrement.getText();      //xyang
                sbf.append(" *** " + txt + "      ");
                outvalue = plotdata.value[5];
                sbf.append(outvalue + "***\n");
            }
            //xyang end

            sbf.append("  FTABLE    999\n");
            //sbf.append("  999's are placeholders for user provided ID 1-3 digits in length***");
            //sbf.append("\n");

            sbf.append(" rows cols                               ***\n");
            //the following section requires me to do a calculation to correctly right justify the rows and cols figures.

            sbf.append(FiveSpaceFormat(numrows.toString()) + FiveSpaceFormat(numcols.toString()) + "\n");
            for (int i = 0; i < numcols; i++)
            {
                string colName = jTable1.getColumnModel().getColumn(i).getHeaderValue().toString();
                colName = colName.substring(0, colName.indexOf("("));
                sbf.append(TenSpaceFormat(colName));
            }
            sbf.append(" ***");
            sbf.append("\n");
            for (int i = 0; i < numrows; i++)
            {
                for (int j = 0; j < numcols; j++)
                {
                    //jTable1.getValueAt(rowsselected[i],colsselected[j]);
                    double newValue = double.valueOf(jTable1.getValueAt(rowsselected[i], colsselected[j]).toString());
                    if (newValue.equals(double.NaN))
                    {
                        newValue = 0.000000d;
                    }
                    DecimalFormat df = new DecimalFormat("#.######");
//	                if (newValue <= 9E-6){
//	                    sbf.append(TenSpaceFormat("0.00000"));
//	                }
//	                else{
                    sbf.append(TenSpaceFormat(df.format(newValue)));
                    //}

                    //if (j<numcols-1) sbf.append("\t");
                }
                sbf.append("\n");
            }
            sbf.append("\n");
            sbf.append("\n");
            sbf.append(FiveSpaceFormat("  END FTABLE999"));

            /*stsel  = new StringSelection(sbf.toString());
             * system = Toolkit.getDefaultToolkit().getSystemClipboard();
             * system.setContents(stsel,stsel);*/
            this.jTArea.setText(sbf.toString());
        }
    }
Example #22
0
        /// <summary>
        /// Responds to action performed events. </summary>
        /// <param name="e"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent e)
        {
            string routine = "StateMod_Well_Right_JFrame.actionPerformed";

            string action = e.getActionCommand();

            if (action.Equals(__BUTTON_ADD_RIGHT))
            {
                StateMod_WellRight aRight = new StateMod_WellRight();
                aRight._isClone = true;
                StateMod_WellRight last = (StateMod_WellRight)__worksheet.getLastRowData();

                if (last == null)
                {
                    aRight.setID(StateMod_Util.createNewID(__currentWell.getID()));
                    aRight.setCgoto(__currentWell.getID());
                }
                else
                {
                    aRight.setID(StateMod_Util.createNewID(last.getID()));
                    aRight.setCgoto(last.getCgoto());
                }
                __worksheet.addRow(aRight);
                __worksheet.scrollToLastRow();
                __worksheet.selectLastRow();
                __deleteRight.setEnabled(true);
            }
            else if (action.Equals(__BUTTON_DEL_RIGHT))
            {
                int row = __worksheet.getSelectedRow();
                if (row != -1)
                {
                    int x = (new ResponseJDialog(this, "Delete right", "Delete well right?", ResponseJDialog.YES | ResponseJDialog.NO)).response();
                    if (x == ResponseJDialog.NO)
                    {
                        return;
                    }

                    __worksheet.cancelEditing();
                    __worksheet.deleteRow(row);
                    __deleteRight.setEnabled(false);
                }
                else
                {
                    Message.printWarning(1, routine, "Must select desired right to delete.");
                }
            }
            else if (action.Equals(__BUTTON_HELP))
            {
                // REVISIT HELP (JTS - 2003-06-10)
            }
            else if (action.Equals(__BUTTON_CLOSE))
            {
                if (saveData())
                {
                    setVisible(false);
                    dispose();
                }
            }
            else if (action.Equals(__BUTTON_APPLY))
            {
                saveData();
            }
            else if (action.Equals(__BUTTON_CANCEL))
            {
                setVisible(false);
                dispose();
            }
        }
        /// <summary>
        /// Responds to action performed events. </summary>
        /// <param name="e"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent e)
        {
            string routine = "StateMod_Reservoir_Return_JFrame::actionPerformed";

            string action = e.getActionCommand();

            if (action.Equals(__BUTTON_ADD_RETURN))
            {
                StateMod_ReturnFlow aReturn = new StateMod_ReturnFlow(StateMod_DataSet.COMP_RESERVOIR_RETURN);
                aReturn._isClone = true;
                StateMod_ReturnFlow last = (StateMod_ReturnFlow)__worksheet.getLastRowData();

                if (last == null)
                {
                    aReturn.setID(StateMod_Util.createNewID(__currentRes.getID()));
                    aReturn.setCgoto(__currentRes.getID());
                }
                else
                {
                    aReturn.setID(StateMod_Util.createNewID(last.getID()));
                    aReturn.setCgoto(last.getCgoto());
                }
                __worksheet.scrollToLastRow();
                __worksheet.addRow(aReturn);
                __worksheet.selectLastRow();
                __deleteReturn_JButton.setEnabled(true);
            }
            else if (action.Equals(__BUTTON_DEL_RETURN))
            {
                int row = __worksheet.getSelectedRow();
                if (row != -1)
                {
                    int x = (new ResponseJDialog(this, "Delete return", "Delete reservoir return?", ResponseJDialog.YES | ResponseJDialog.NO)).response();
                    if (x == ResponseJDialog.NO)
                    {
                        return;
                    }

                    __worksheet.cancelEditing();
                    __worksheet.deleteRow(row);
                    __deleteReturn_JButton.setEnabled(false);
                }
                else
                {
                    Message.printWarning(1, routine, "Must select desired return to delete.");
                }
            }
            else if (action.Equals(__BUTTON_CLOSE))
            {
                if (saveData())
                {
                    setVisible(false);
                    dispose();
                }
            }
            else if (action.Equals(__BUTTON_APPLY))
            {
                saveData();
            }
            else if (action.Equals(__BUTTON_CANCEL))
            {
                setVisible(false);
                dispose();
            }
            else if (e.getSource() == __help_JButton)
            {
                // TODO HELP (JTS - 2003-06-09)
            }
        }
Example #24
0
	/// <summary>
	/// Responds to action performed events. </summary>
	/// <param name="e"> the ActionEvent that happened. </param>
	public virtual void actionPerformed(ActionEvent e)
	{
		string routine = "StateMod_DelayTable_JFrame"
			+ ".actionPerformed";
		if (Message.isDebugOn)
		{
			Message.printDebug(1, routine, "In actionPerformed: " + e.getActionCommand());
		}

		string action = e.getActionCommand();

		if (action.Equals(__BUTTON_HELP))
		{
			// REVISIT HELP (JTS - 2003-06-09)
		}
		else if (action.Equals(__BUTTON_CLOSE))
		{
			closeWindow();
		}
		else if (action.Equals(__BUTTON_APPLY))
		{
			saveDelayTable();
			int size = __delaysVector.Count;
			StateMod_DelayTable dt = null;
			bool changed = false;
			for (int i = 0; i < size; i++)
			{
				dt = (StateMod_DelayTable)__delaysVector[i];
				if (!changed && dt.changed())
				{
					changed = true;
				}
				dt.createBackup();
			}
			if (changed)
			{
				__dataset.setDirty(__componentType, true);
			}
		}
		else if (action.Equals(__BUTTON_CANCEL))
		{
			__worksheetR.deselectAll();
			int size = __delaysVector.Count;
			StateMod_DelayTable dt = null;
			bool changed = false;
			for (int i = 0; i < size; i++)
			{
				dt = (StateMod_DelayTable)__delaysVector[i];
				if (!changed && dt.changed())
				{
					changed = true;
				}
				dt.restoreOriginal();
			}
			if (__dataset_wm != null)
			{
				__dataset_wm.closeWindow(__window_type);
			}
			else
			{
				JGUIUtil.close(this);
			}
		}
		else if (action.Equals(__BUTTON_ADD_RETURN))
		{
			int row = __worksheetR.getSelectedRow();

			int total_num_rows = __worksheetR.getRowCount() - 1;

			if (row == -1)
			{
				row = total_num_rows;
			}

			if (row != -1)
			{
				if (row == total_num_rows)
				{
					int x = new ResponseJDialog(this, "Insert row", "Do you wish to add a new row above " + "the last row?\n" + "uniquetempvar.response();
					if (x == ResponseJDialog.CANCEL)
					{
						return;
					}
					else if (x == ResponseJDialog.NO)
					{
						row += 1;
					}
				}
				__worksheetR.insertRowAt(new double?(0), row);
				__worksheetR.scrollToRow(row);
				__worksheetR.selectRow(row);
			}
			else
			{
				__worksheetR.addRow(new double?(0));
				__worksheetR.scrollToRow(0);
				__worksheetR.selectRow(0);
			}
			__deleteReturn.setEnabled(true);
		}
		else if (action.Equals(__BUTTON_DELETE_RETURN))
		{
			int row = __worksheetR.getSelectedRow();
			if (row != -1)
			{
				int x = (new ResponseJDialog(this, "Delete Return", "Delete return?", ResponseJDialog.YES | ResponseJDialog.NO)).response();
				if (x == ResponseJDialog.NO)
				{
					return;
				}
				//StateMod_DelayTable dt = (StateMod_DelayTable)
					//__worksheetL.getRowData(
					//__worksheetL.getSelectedRow());
				__worksheetR.deleteRow(row);
				__deleteReturn.setEnabled(false);
			}
			else
			{
				Message.printWarning(1, routine, "Must select desired right to delete.");
			}
		}
		else if (e.getSource() == __findNextDelay)
		{
			searchLeftWorksheet(__worksheetL.getSelectedRow() + 1);
		}
		else if (e.getSource() == __searchID)
		{
			searchLeftWorksheet();
		}
		else
		{
			if (__worksheetL.getSelectedRow() == -1)
			{
				new ResponseJDialog(this, "You must first select a delay from the list.", ResponseJDialog.OK);
				return;
			}
			else if (e.getSource() == __graphDelayJButton)
			{
				try
				{
					__worksheetR.deselectAll();

					int index = __worksheetL.getSelectedRow();
					if (index == -1)
					{
						return;
					}

					StateMod_DelayTable currentDelay = ((StateMod_DelayTable) __delaysVector[index]);

					int j;

					DateTime date;

					TSIdent tsident = new TSIdent();
					tsident.setLocation(currentDelay.getID());
					tsident.setSource("StateMod");
					if (__monthly_data)
					{
						tsident.setInterval("Month");
					}
					else
					{
						tsident.setInterval("Day");
					}
					tsident.setType("Delay");

					DateTime date1 = null;
					DateTime date2 = null;
					int interval_base;
					if (__monthly_data)
					{
						date1 = new DateTime(DateTime.PRECISION_MONTH);
						date2 = new DateTime(DateTime.PRECISION_MONTH);
						interval_base = TimeInterval.MONTH;
					}
					else
					{
						date1 = new DateTime(DateTime.PRECISION_DAY);
						date2 = new DateTime(DateTime.PRECISION_DAY);
						interval_base = TimeInterval.DAY;
					}
					date1.setMonth(1);
					date1.setYear(1);
					date2.setMonth(1);
					date2.setYear(1);
					date2.addInterval(interval_base, (currentDelay.getNdly() - 1));

					TS ts = null;
					if (__monthly_data)
					{
						ts = new MonthTS();
					}
					else
					{
						ts = new DayTS();
					}
					ts.setDate1(date1);
					ts.setDate2(date2);
					ts.setIdentifier(tsident);
					if (__monthly_data)
					{
						ts.setDescription(ts.getLocation() + " Monthly Delay Table");
					}
					else
					{
						ts.setDescription(ts.getLocation() + " Daily Delay Table");
					}
					ts.setDataType("Delay");
					ts.setDataUnits(currentDelay.getUnits());
					ts.allocateDataSpace();

					double max = 0.0;
					for (date = new DateTime(date1), j = 0; date.lessThanOrEqualTo(date2); date.addInterval(interval_base, 1), j++)
					{
						ts.setDataValue(date, currentDelay.getRet_val(j));
						if (currentDelay.getRet_val(j) > max)
						{
							max = currentDelay.getRet_val(j);
						}
					}
					IList<TS> tslist = new List<TS>();
					tslist.Add(ts);

					PropList graphProps = new PropList("TSView");
					// If dealing with small values, use a high
					// of precision...
					if (max < 1.0)
					{
						graphProps.set("YAxisPrecision","6");
						graphProps.set("OutputPrecision","6");
					}
					else
					{
						graphProps.set("YAxisPrecision","3");
						graphProps.set("OutputPrecision","3");
					}
					graphProps.set("InitialView", "Graph");
					graphProps.set("TotalWidth", "600");
					graphProps.set("TotalHeight", "400");
					if (__monthly_data)
					{
						graphProps.set("Title", ts.getLocation() + " Monthly Delay Table");
					}
					else
					{
						graphProps.set("Title", ts.getLocation() + " Daily Delay Table");
					}
					graphProps.set("DisplayFont", "Courier");
					graphProps.set("DisplaySize", "11");
					graphProps.set("PrintFont", "Courier");
					graphProps.set("PrintSize", "7");
					graphProps.set("PageLength", "100");
					new TSViewJFrame(tslist, graphProps);
				}
				catch (Exception)
				{
					Message.printWarning(1, routine, "Unable to graph delay. ");
				}
			}
		}
	}
        /// <summary>
        /// Responds to action events. </summary>
        /// <param name="event"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent @event)
        {
            string action = @event.getActionCommand();
            object o      = @event.getSource();

            if (action.Equals(__BUTTON_CANCEL))
            {
                dispose();
            }
            else if (action.Equals(__BUTTON_OK))
            {
                int    type = -1;
                string s    = __nodeTypeComboBox.getSelected();
                if (s.Equals(__NODE_CONFLUENCE))
                {
                    type = HydrologyNode.NODE_TYPE_CONFLUENCE;
                }
                else if (s.Equals(__NODE_DIVERSION))
                {
                    type = HydrologyNode.NODE_TYPE_DIV;
                }
                else if (s.Equals(__NODE_DIVERSION_AND_WELL))
                {
                    type = HydrologyNode.NODE_TYPE_DIV_AND_WELL;
                }
                else if (s.Equals(__NODE_END))
                {
                    type = HydrologyNode.NODE_TYPE_END;
                }
                else if (s.Equals(__NODE_INSTREAM_FLOW))
                {
                    type = HydrologyNode.NODE_TYPE_ISF;
                }
                else if (s.Equals(__NODE_OTHER))
                {
                    type = HydrologyNode.NODE_TYPE_OTHER;
                }
                else if (s.Equals(__NODE_PLAN))
                {
                    type = HydrologyNode.NODE_TYPE_PLAN;
                }
                else if (s.Equals(__NODE_RESERVOIR))
                {
                    type = HydrologyNode.NODE_TYPE_RES;
                }
                else if (s.Equals(__NODE_STREAMFLOW))
                {
                    type = HydrologyNode.NODE_TYPE_FLOW;
                }
                else if (s.Equals(__NODE_WELL))
                {
                    type = HydrologyNode.NODE_TYPE_WELL;
                }
                else if (s.Equals(__NODE_XCONFLUENCE))
                {
                    type = HydrologyNode.NODE_TYPE_XCONFLUENCE;
                }

                StateMod_NodeNetwork network = __parent.getNetwork();

                string up = __upstreamIDComboBox.getSelected().Trim();
                if (up.Equals("[none]"))
                {
                    up = null;
                }
                network.addNode(__nodeNameJTextField.getText().Trim(), type, up, __downstreamIDJTextField.getText().Trim(), __naturalFlowJCheckBox.isSelected(), __importJCheckBox.isSelected());
                __parent.setNetwork(network, true, true);
                //		__parent.resetNodeSize();
                __parent.endAddNode();
                dispose();
            }
            else if (o == __nodeTypeComboBox)
            {
                string selected = __nodeTypeComboBox.getSelected();

                if (!selected.Equals(__NODE_END))
                {
                    __naturalFlowJCheckBox.setEnabled(true);
                    __importJCheckBox.setEnabled(true);
                }
            }
        }