Beispiel #1
0
	/// <summary>
	/// Constructor. </summary>
	/// <param name="delay"> the Delay to show </param>
	/// <param name="monthly_data"> If true, display the monthly delay tables.  If false,
	/// display the daily delay tables. </param>
	/// <param name="editable"> whether the gui data is editable or not </param>
	public StateMod_DelayTable_JFrame(StateMod_DelayTable delay, bool monthly_data, bool editable)
	{
		__monthly_data = monthly_data;
		JGUIUtil.setIcon(this, JGUIUtil.getIconImage());
		string interval = " (Monthly)";
		if (__monthly_data)
		{
			__window_type = StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_MONTHLY;
			__componentType = StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY;
		}
		else
		{
			__window_type = StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_DAILY;
			__componentType = StateMod_DataSet.COMP_DELAY_TABLES_DAILY;
			interval = " (Daily)";
		}
		StateMod_GUIUtil.setTitle(this, null, "Delay Table" + interval, null);
		__delaysVector = new List<StateMod_DelayTable>();
		__delaysVector.Add(delay);

		int size = __delaysVector.Count;
		StateMod_DelayTable dt = null;
		for (int i = 0; i < size; i++)
		{
			dt = __delaysVector[i];
			dt.createBackup();
		}

		__editable = editable;

		setupGUI(0);
	}
        /// <summary>
        /// Creates backups of all the data objects in the Vector so that changes can later be cancelled if necessary.
        /// </summary>
        protected internal override void createDataBackup()
        {
            StateMod_DelayTable delay = null;
            int size = _data.Count;

            for (int i = 0; i < size; i++)
            {
                delay = (StateMod_DelayTable)_data[i];
                delay.createBackup();
            }
        }
Beispiel #3
0
	/// <summary>
	/// Constructor. </summary>
	/// <param name="dataset"> the dataset containing the data to display </param>
	/// <param name="dataset_wm"> the dataset window manager or null if the data set windows
	/// are not being managed. </param>
	/// <param name="delayTable"> the delay table to display. </param>
	/// <param name="monthly_data"> If true, display the monthly delay tables.  If false,
	/// display the daily delay tables. </param>
	/// <param name="editable"> whether the data is editable or not </param>
	public StateMod_DelayTable_JFrame(StateMod_DataSet dataset, StateMod_DataSet_WindowManager dataset_wm, StateMod_DelayTable delayTable, bool monthly_data, bool editable)
	{
		__dataset = dataset;
		__dataset_wm = dataset_wm;
		__monthly_data = monthly_data;
		JGUIUtil.setIcon(this, JGUIUtil.getIconImage());
		string interval = " (Monthly)";
		if (__monthly_data)
		{
			__window_type = StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_MONTHLY;
			__delayComponent = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY);
			__componentType = StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY;
		}
		else
		{
			__window_type = StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_DAILY;
			__delayComponent = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_DAILY);
			__componentType = StateMod_DataSet.COMP_DELAY_TABLES_DAILY;
			interval = " (Daily)";
		}
		StateMod_GUIUtil.setTitle(this, dataset, "Delay Tables" + interval, null);

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_DelayTable> delaysList = (java.util.List<StateMod_DelayTable>)__delayComponent.getData();
		IList<StateMod_DelayTable> delaysList = (IList<StateMod_DelayTable>)__delayComponent.getData();
		__delaysVector = delaysList;

		int size = __delaysVector.Count;
		StateMod_DelayTable dt = null;
		for (int i = 0; i < size; i++)
		{
			dt = __delaysVector[i];
			dt.createBackup();
		}

		string id = delayTable.getID();
		int index = StateMod_Util.IndexOf(__delaysVector, id);

		__editable = editable;
		setupGUI(index);
	}
Beispiel #4
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. ");
				}
			}
		}
	}