コード例 #1
0
        /// <summary>
        /// Creates a JScrollWorksheet for the current data and returns it. </summary>
        /// <returns> a JScrollWorksheet containing the data Vector passed in to the
        /// constructor. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected RTi.Util.GUI.JScrollWorksheet buildJScrollWorksheet() throws Exception
        protected internal override JScrollWorksheet buildJScrollWorksheet()
        {
            StateCU_ClimateStation_TableModel   tableModel   = new StateCU_ClimateStation_TableModel(_data, _editable);
            StateCU_ClimateStation_CellRenderer cellRenderer = new StateCU_ClimateStation_CellRenderer(tableModel);

            // _props is defined in the super class
            return(new JScrollWorksheet(cellRenderer, tableModel, _props));
        }
コード例 #2
0
	/// <summary>
	/// Sets up the GUI. </summary>
	/// <param name="index"> the index to select </param>
	private void setupGUI(int index)
	{
		string routine = "setupGUI";

		addWindowListener(this);

		JPanel p1 = new JPanel(); // first 6 months' effeciency
		//JPanel p2 = new JPanel();	// last 6 months' effeciency
		JPanel p3 = new JPanel(); // div sta id -> switch for diversion
		JPanel p4 = new JPanel(); // user name -> data type switch

		JPanel left_panel = new JPanel(); // multilist and search area

		__stationIDJTextField = new JTextField(12);
		__nameJTextField = new JTextField(24);
		__latitudeJTextField = new JTextField(12);
		__elevationJTextField = new JTextField(12);
		__region1JTextField = new JTextField(12);
		__region2JTextField = new JTextField(12);

		__searchID = new JTextField(10);
		__searchName = new JTextField(10);
		__searchName.setEditable(false);
		__findNextStation = new JButton(__BUTTON_FIND_NEXT);
		__searchCriteriaGroup = new ButtonGroup();
		__searchIDJRadioButton = new JRadioButton(__BUTTON_ID, true);
		__searchNameJRadioButton = new JRadioButton(__BUTTON_NAME, false);
		__searchCriteriaGroup.add(__searchIDJRadioButton);
		__searchCriteriaGroup.add(__searchNameJRadioButton);

		JButton applyJButton = new JButton(__BUTTON_APPLY);
		JButton cancelJButton = new JButton(__BUTTON_CANCEL);
		JButton helpJButton = new JButton(__BUTTON_HELP);
		helpJButton.setEnabled(false);
		JButton closeJButton = new JButton(__BUTTON_CLOSE);

		GridBagLayout gb = new GridBagLayout();
		JPanel mainJPanel = new JPanel();
		mainJPanel.setLayout(gb);
		p1.setLayout(new GridLayout(4, 6, 2, 0));
		p3.setLayout(gb);
		p4.setLayout(gb);
		left_panel.setLayout(gb);

		int y;

		PropList p = new PropList("StateCU_ClimateStation_JFrame.JWorksheet");

		p.add("JWorksheet.CellFont=Courier");
		p.add("JWorksheet.CellStyle=Plain");
		p.add("JWorksheet.CellSize=11");
		p.add("JWorksheet.HeaderFont=Arial");
		p.add("JWorksheet.HeaderStyle=Plain");
		p.add("JWorksheet.HeaderSize=11");
		p.add("JWorksheet.HeaderBackground=LightGray");
		p.add("JWorksheet.RowColumnPresent=false");
		p.add("JWorksheet.ShowPopupMenu=true");
		p.add("JWorksheet.SelectionMode=SingleRowSelection");

		int[] widths = null;
		try
		{
			StateCU_ClimateStation_TableModel tmw = new StateCU_ClimateStation_TableModel(__stationsVector);
			StateCU_ClimateStation_CellRenderer crw = new StateCU_ClimateStation_CellRenderer(tmw);

			__worksheet = new JWorksheet(crw, tmw, p);

			widths = crw.getColumnWidths();
		}
		catch (Exception e)
		{
			Message.printWarning(2, routine, e);
			__worksheet = new JWorksheet(0, 0, p);
			Console.WriteLine(e.ToString());
			Console.Write(e.StackTrace);
		}
		__worksheet.setPreferredScrollableViewportSize(null);
		__worksheet.setHourglassJFrame(this);
		__worksheet.addMouseListener(this);
		__worksheet.addKeyListener(this);

		JGUIUtil.addComponent(left_panel, new JScrollPane(__worksheet), 0, 0, 6, 6, 1, 1, 0, 0, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.CENTER);

		y = 0;
		JGUIUtil.addComponent(p3, new JLabel("Station ID:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST);
		JGUIUtil.addComponent(p3, __stationIDJTextField, 1, y, 1, 1, 1, 0, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST);
		__stationIDJTextField.setEditable(false);

		y++;
		JGUIUtil.addComponent(p3, new JLabel("Name:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST);
		JGUIUtil.addComponent(p3, __nameJTextField, 1, y, 1, 1, 1, 0, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST);

		y++;
		JGUIUtil.addComponent(p3, new JLabel("Latitude (Dec. Deg.):"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST);
		JGUIUtil.addComponent(p3, __latitudeJTextField, 1, y, 1, 1, 1, 0, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST);

		y++;
		JGUIUtil.addComponent(p3, new JLabel("Elevation (Feet):"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST);
		JGUIUtil.addComponent(p3, __elevationJTextField, 1, y, 1, 1, 1, 0, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST);

		y++;
		JGUIUtil.addComponent(p3, new JLabel("Region 1:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST);
		JGUIUtil.addComponent(p3, __region1JTextField, 1, y, 1, 1, 1, 0, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST);

		y++;
		JGUIUtil.addComponent(p3, new JLabel("Region 2:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST);
		JGUIUtil.addComponent(p3, __region2JTextField, 1, y, 1, 1, 1, 0, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST);
		y++;

		JPanel graphPanel = new JPanel();
		graphPanel.setLayout(gb);
		graphPanel.setBorder(BorderFactory.createTitledBorder("Time Series"));
		int yy = 0;
		__precipitationCheckBox = new JCheckBox("Precipitation (Monthly)");
		__temperatureCheckBox = new JCheckBox("Temperature (Monthly)");
		__frostDatesCheckBox = new JCheckBox("Frost Dates (Yearly)");

		JGUIUtil.addComponent(graphPanel, __precipitationCheckBox, 0, yy++, 3, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
		JGUIUtil.addComponent(graphPanel, __temperatureCheckBox, 0, yy++, 3, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
		JGUIUtil.addComponent(graphPanel, __frostDatesCheckBox, 0, yy++, 3, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);

		if (!__dataset.getComponentForComponentType(StateCU_DataSet.COMP_PRECIPITATION_TS_MONTHLY).hasData())
		{
			__precipitationCheckBox.setEnabled(false);
		}
		if (!__dataset.getComponentForComponentType(StateCU_DataSet.COMP_TEMPERATURE_TS_MONTHLY_AVERAGE).hasData())
		{
			__temperatureCheckBox.setEnabled(false);
		}
		if (!__dataset.getComponentForComponentType(StateCU_DataSet.COMP_FROST_DATES_TS_YEARLY).hasData())
		{
			__frostDatesCheckBox.setEnabled(false);
		}

		JButton graphButton = new SimpleJButton(__BUTTON_GRAPH, __BUTTON_GRAPH, this);
		JButton tableButton = new SimpleJButton(__BUTTON_TABLE, __BUTTON_TABLE, this);
		JButton summaryButton = new SimpleJButton(__BUTTON_SUMMARY, __BUTTON_SUMMARY, this);

		JGUIUtil.addComponent(graphPanel, graphButton, 0, yy, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
		JGUIUtil.addComponent(graphPanel, tableButton, 1, yy, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
		JGUIUtil.addComponent(graphPanel, summaryButton, 2, yy++, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

		JGUIUtil.addComponent(p3, graphPanel, 0, y++, 2, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);

		// add search areas
		y = 7;
		JPanel searchPanel = new JPanel();
		searchPanel.setLayout(gb);
		searchPanel.setBorder(BorderFactory.createTitledBorder("Search above list for:     "));

		JGUIUtil.addComponent(left_panel, searchPanel, 0, y, 4, 1, 0, 0, 10, 10, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

		int y2 = 0;
		JGUIUtil.addComponent(searchPanel, __searchIDJRadioButton, 0, y2, 1, 1, 0, 0, 5, 10, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
		__searchIDJRadioButton.addActionListener(this);
		JGUIUtil.addComponent(searchPanel, __searchID, 1, y2, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST);
		__searchID.addActionListener(this);

		y2++;
		JGUIUtil.addComponent(searchPanel, __searchNameJRadioButton, 0, y2, 1, 1, 0, 0, 5, 10, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
		__searchNameJRadioButton.addActionListener(this);
		JGUIUtil.addComponent(searchPanel, __searchName, 1, y2, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST);
		__searchName.addActionListener(this);

		y2++;
		JGUIUtil.addComponent(searchPanel, __findNextStation, 0, y2, 4, 1, 0, 0, 20, 10, 20, 10, GridBagConstraints.NONE, GridBagConstraints.WEST);
		__findNextStation.addActionListener(this);
		// add buttons which lead to station water rights,
		// direct flow demand, and return flow information
		y = 6;
		FlowLayout fl = new FlowLayout(FlowLayout.CENTER);
		JPanel p5 = new JPanel();
		p5.setLayout(new GridLayout(5, 2));

		// add help and close buttons
		y = 10;
		JPanel p6 = new JPanel();
		p6.setLayout(fl);
		if (__editable)
		{
			p6.add(applyJButton);
			p6.add(cancelJButton);
		}
		p6.add(helpJButton);
		p6.add(closeJButton);

		// two top panels of info
		JGUIUtil.addComponent(mainJPanel, p3, 6, 0, 1, 6, 0, 1, 0, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
		JGUIUtil.addComponent(mainJPanel, p6, 6, 7, 1, 1, 0, 0, 30, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.SOUTH);
		applyJButton.addActionListener(this);
		cancelJButton.addActionListener(this);
		helpJButton.addActionListener(this);
		closeJButton.addActionListener(this);

		JGUIUtil.addComponent(mainJPanel, left_panel, 0, 0, 4, 10, 1, 1, 10, 10, 10, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST);

		getContentPane().add(mainJPanel);

		JPanel bottomJPanel = new JPanel();
		bottomJPanel.setLayout(gb);
		__messageJTextField = new JTextField();
		__messageJTextField.setEditable(false);
		JGUIUtil.addComponent(bottomJPanel, __messageJTextField, 0, 0, 7, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
		__statusJTextField = new JTextField(5);
		__statusJTextField.setEditable(false);
		JGUIUtil.addComponent(bottomJPanel, __statusJTextField, 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST);
		getContentPane().add("South", bottomJPanel);

		initializeDisables();

	//	JGUIUtil.center(this);
		pack();
		setSize(900,440);
		selectTableIndex(index);
		setVisible(true);

		if (widths != null)
		{
			__worksheet.setColumnWidths(widths);
		}
	}