public void actionPerformed(ActionEvent actionevent)
        {
            string s = textField.getText().Trim();

            if (s.Length > 0)
            {
                ServerGUI.getMinecraftServer(mcServerGui).addCommand(s, mcServerGui);
            }
            textField.setText("");
        }
        /// <summary>
        /// Saves the information associated with the currently-selected reservoir.
        /// The user doesn't need to hit the return key for the gui to recognize changes.
        /// The info is saved each time the user selects a differents tation or pressed
        /// the close button.
        /// </summary>
        private void saveInformation(int record)
        {
            if (!__editable || record == -1)
            {
                return;
            }

            if (!checkInput())
            {
                return;
            }

            StateMod_RiverNetworkNode rnn = (StateMod_RiverNetworkNode)__riverNetworkNodesVector[record];

            Message.printStatus(1, "", "Setting " + record + " cstadn: " + __nodeJTextField.getText());
            rnn.setCstadn(__nodeJTextField.getText());
            Message.printStatus(1, "", "Setting " + record + " comment: " + __commentJTextField.getText());
            rnn.setComment(__commentJTextField.getText());
        }
Esempio n. 3
0
	/// <summary>
	/// Searches through the worksheet for a value, starting at the given row.
	/// If the value is found, the row is selected. </summary>
	/// <param name="row"> the row to start searching from. </param>
	public virtual void searchLeftWorksheet(int row)
	{
		string searchFor = null;
		int col = 0;
		searchFor = __searchID.getText().Trim();

		int index = __worksheetL.find(searchFor, col, row, JWorksheet.FIND_EQUAL_TO | JWorksheet.FIND_CONTAINS | JWorksheet.FIND_CASE_INSENSITIVE | JWorksheet.FIND_WRAPAROUND);
		if (index != -1)
		{
			selectLeftTableIndex(index, true, true);
		}
	}
        /// <summary>
        /// Saves the changes made in the GUI and applies them to the node in the parent GUI.
        /// </summary>
        private void applyChanges()
        {
            if (!validateData())
            {
                // if the data are not valid, don't close
                return;
            }

            HydrologyNode node = new HydrologyNode();
            PropList      p    = new PropList("");
            string        temp = null;

            temp = __textTextField.getText().Trim();
            temp = StringUtil.replaceString(temp, "\"", "'");
            p.set("Text", temp);

            temp = __xTextField.getText().Trim() + "," + __yTextField.getText().Trim();
            p.set("Point", temp);

            temp = __textPositionComboBox.getSelected();
            p.set("TextPosition", temp);

            temp = __fontNameComboBox.getSelected().Trim();
            p.set("FontName", temp);

            temp = __fontSizeTextField.getText().Trim();
            p.set("OriginalFontSize", temp);

            temp = __fontStyleComboBox.getSelected().Trim();
            p.set("FontStyle", temp);
            node.setAssociatedObject(p);

            node.setDirty(true);

            __parent.updateAnnotation(__nodeNum, node);
            __applyButton.setEnabled(false);
            __okButton.setEnabled(false);
        }
	/// <summary>
	/// Searches through the worksheet for a value, starting at the given row.
	/// If the value is found, the row is selected. </summary>
	/// <param name="row"> the row to start searching from. </param>
	public virtual void searchWorksheet(int row)
	{
		string searchFor = null;
		int col = -1;
		if (__searchIDJRadioButton.isSelected())
		{
			searchFor = __searchID.getText().Trim();
			col = 1;
		}
		else
		{
			searchFor = __searchName.getText().Trim();
			col = 2;
		}
		int index = __worksheet.find(searchFor, col, row, JWorksheet.FIND_EQUAL_TO | JWorksheet.FIND_CONTAINS | JWorksheet.FIND_CASE_INSENSITIVE | JWorksheet.FIND_WRAPAROUND);
		if (index != -1)
		{
			selectTableIndex(index);
		}
	}
        /// <summary>
        /// Called when Apply or OK is clicked.  Commits any changes to the node.
        /// </summary>
        private void applyClicked()
        {
            //TODO SAM 2007-03-01 Evaluate use
            bool   dirty         = false;
            string id            = __idTextField.getText();
            string x             = __xTextField.getText();
            string y             = __yTextField.getText();
            string desc          = __descriptionTextField.getText();
            bool   isNaturalFlow = __isNaturalFlowCheckBox.isSelected();
            bool   mport         = __isImportCheckBox.isSelected();
            string type          = __typeComboBox.getSelected();
            string dir           = __labelPositionComboBox.getSelected();
            string resDir        = __reservoirDirectionComboBox.getSelected();
            string area          = __areaTextField.getText();
            string precip        = __precipitationTextField.getText();

            __nodes[__nodeNum].setCommonID(id);
            if (!id.Equals(__origID))
            {
                dirty = true;
            }

            __nodes[__nodeNum].setX((Convert.ToDouble(x)));
            if (!x.Equals(__origX))
            {
                dirty = true;
            }

            __nodes[__nodeNum].setY((Convert.ToDouble(y)));
            if (!y.Equals(__origY))
            {
                dirty = true;
            }

            __nodes[__nodeNum].setDescription(desc);
            if (!desc.Equals(__origDesc))
            {
                dirty = true;
            }

            __nodes[__nodeNum].setIsNaturalFlow(isNaturalFlow);
            if (isNaturalFlow != __origNaturalFlow)
            {
                dirty = true;
            }

            __nodes[__nodeNum].setIsImport(mport);
            if (mport != __origImport)
            {
                dirty = true;
            }

            __nodes[__nodeNum].setPrecip((Convert.ToDouble(precip)));
            if (!precip.Equals(__origPrecipitation))
            {
                dirty = true;
            }

            __nodes[__nodeNum].setArea((Convert.ToDouble(area)));
            if (!area.Equals(__origArea))
            {
                dirty = true;
            }

            int  itype = -1;
            bool res   = false;

            if (type.Equals(__NODE_CONFLUENCE))
            {
                itype = HydrologyNode.NODE_TYPE_CONFLUENCE;
            }
            else if (type.Equals(__NODE_DIVERSION))
            {
                itype = HydrologyNode.NODE_TYPE_DIV;
            }
            else if (type.Equals(__NODE_DIVERSION_AND_WELL))
            {
                itype = HydrologyNode.NODE_TYPE_DIV_AND_WELL;
            }
            else if (type.Equals(__NODE_END))
            {
                itype = HydrologyNode.NODE_TYPE_END;
            }
            else if (type.Equals(__NODE_INSTREAM_FLOW))
            {
                itype = HydrologyNode.NODE_TYPE_ISF;
            }
            else if (type.Equals(__NODE_OTHER))
            {
                itype = HydrologyNode.NODE_TYPE_OTHER;
            }
            else if (type.Equals(__NODE_PLAN))
            {
                itype = HydrologyNode.NODE_TYPE_PLAN;
            }
            else if (type.Equals(__NODE_RESERVOIR))
            {
                itype = HydrologyNode.NODE_TYPE_RES;
                res   = true;
            }
            else if (type.Equals(__NODE_STREAMFLOW))
            {
                itype = HydrologyNode.NODE_TYPE_FLOW;
            }
            else if (type.Equals(__NODE_WELL))
            {
                itype = HydrologyNode.NODE_TYPE_WELL;
            }
            else if (type.Equals(__NODE_XCONFLUENCE))
            {
                itype = HydrologyNode.NODE_TYPE_XCONFLUENCE;
            }
            else
            {
                int index = type.IndexOf(":", StringComparison.Ordinal);
                type  = type.Substring(index + 1).Trim();
                itype = Integer.decode(type).intValue();
            }
            __nodes[__nodeNum].setType(itype);
            if (!type.Equals(__origType))
            {
                dirty = true;
            }

            int idir = -1;

            if (dir.Equals(__ABOVE_CENTER))
            {
                idir = 1;
            }
            else if (dir.Equals(__UPPER_RIGHT))
            {
                idir = 7;
            }
            else if (dir.Equals(__RIGHT))
            {
                idir = 4;
            }
            else if (dir.Equals(__LOWER_RIGHT))
            {
                idir = 8;
            }
            else if (dir.Equals(__BELOW_CENTER))
            {
                idir = 2;
            }
            else if (dir.Equals(__LOWER_LEFT))
            {
                idir = 5;
            }
            else if (dir.Equals(__LEFT))
            {
                idir = 3;
            }
            else if (dir.Equals(__UPPER_LEFT))
            {
                idir = 6;
            }
            else if (dir.Equals(__CENTER))
            {
                idir = 9;
            }
            else
            {
                int index = dir.IndexOf(":", StringComparison.Ordinal);
                dir  = dir.Substring(index + 1).Trim();
                idir = Integer.decode(dir).intValue();
            }
            int iresdir = 0;

            if (res)
            {
                if (resDir.Equals(__TOP))
                {
                    iresdir = 2;
                }
                else if (resDir.Equals(__BOTTOM))
                {
                    iresdir = 1;
                }
                else if (resDir.Equals(__LEFT))
                {
                    iresdir = 4;
                }
                else if (resDir.Equals(__RIGHT))
                {
                    iresdir = 3;
                }
                else
                {
                    int index = resDir.IndexOf(":", StringComparison.Ordinal);
                    resDir  = resDir.Substring(index + 1).Trim();
                    iresdir = Integer.decode(resDir).intValue();
                }
            }

            __nodes[__nodeNum].setLabelDirection((iresdir * 10) + idir);
            if (!resDir.Equals(__origResDir) || !dir.Equals(__origDir))
            {
                dirty = true;
            }

            // Only set the dirty flag if it was false previously because a previous edit may have marked
            // dirty and this edit may not have introduced additional changes.
            if (!__nodes[__nodeNum].isDirty())
            {
                __nodes[__nodeNum].setDirty(dirty);
            }
            __nodes[__nodeNum].setBoundsCalculated(false);

            __parent.nodePropertiesChanged();
        }
        /// <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>
        /// 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);
                }
            }
        }