diff --git a/WreckGui/Controller/GuiController.cs b/WreckGui/Controller/GuiController.cs index 3cd2a5f..bec68ba 100644 --- a/WreckGui/Controller/GuiController.cs +++ b/WreckGui/Controller/GuiController.cs @@ -12,7 +12,7 @@ using Wreck.IO.Task; using Wreck.Resources; using Wreck.Util.Logging; -using WreckGui.Model; +using Wreck.Model; namespace Wreck.Controller { diff --git a/WreckGui/Model/GuiModel.cs b/WreckGui/Model/GuiModel.cs index 936a245..f094624 100644 --- a/WreckGui/Model/GuiModel.cs +++ b/WreckGui/Model/GuiModel.cs @@ -1,15 +1,66 @@  using System; +using Wreck.Entity; -namespace WreckGui.Model +namespace Wreck.Model { /// /// Description of GuiModel. /// public class GuiModel { +// private static readonly Pattern DIGITS = Pattern.compile("^[0-9]+$"); + + private readonly SampleTableModel tableModel; +// private readonly ButtonModel metadataModel; +// private readonly IDictionary sourceModel; +// private readonly Document dateTimeDocument; +// private readonly SpinnerNumberModel customDateTimeYearModel; +// private readonly SpinnerNumberModel customDateTimeMonthModel; +// private readonly SpinnerNumberModel customDateTimeDayModel; +// private readonly SpinnerDateModel customDateTimeModel; + +// private readonly IDictionary correctionModel; + +// private readonly DefaultButtonModel backupModel; +// private readonly DefaultButtonModel restoreModel; +// private readonly DefaultButtonModel verifyModel; + + private readonly SampleTableModel fileStatisticsTableModel; + private readonly SampleTableModel metadataStatisticsTableModel; + private readonly SampleTableModel extensionStatisticsTableModel; + +// private readonly DefaultListModel aboutModel; + +// private readonly BoundedRangeModel scanningProgressModel; + public GuiModel() { + this.tableModel = new SampleTableModel(typeof(FileBean)); + + this.fileStatisticsTableModel = new SampleTableModel(typeof(FileStatisticsBean)); + this.metadataStatisticsTableModel = new SampleTableModel(typeof(MetadataStatisticsBean)); + this.extensionStatisticsTableModel = new SampleTableModel(typeof(ExtensionStatisticsBean)); + } + + public SampleTableModel TableModel + { + get { return tableModel; } + } + + public SampleTableModel FileStatisticsTableModel + { + get { return fileStatisticsTableModel; } + } + + public SampleTableModel MetadataStatisticsTableModel + { + get { return metadataStatisticsTableModel; } + } + + public SampleTableModel ExtensionStatisticsTableModel + { + get { return extensionStatisticsTableModel; } } } } diff --git a/WreckGui/Model/SampleTableModel.cs b/WreckGui/Model/SampleTableModel.cs new file mode 100644 index 0000000..249ece8 --- /dev/null +++ b/WreckGui/Model/SampleTableModel.cs @@ -0,0 +1,139 @@ + +using System; +using System.Collections.Generic; +using System.Security; + +using log4net; + +namespace Wreck.Model +{ + /// + /// Description of SampleTableModel. + /// + public class SampleTableModel + { + private static readonly ILog LOG = LogManager.GetLogger(typeof(SampleTableModel)); + + private IList columns = new List(); + private IList data = new List(); + + private readonly Type type; + + public SampleTableModel(Type type) : base() + { + this.type = type; + } + + public Type Type + { + get { return this.type; } + } + + public string[] Header + { + get + { + string[] header = new string[columns.Count]; + for(int i = 0; i < columns.Count; i++) + { + header[i] = columns[i].ToUpper(); + } + + return header; + } + } + + public IList Data + { + get { return data; } + } + + public int RowCount + { + get { return Data.Count; } + } + + public int ColumnCount + { + get { return columns.Count; } + } + + public object GetValueAt(int rowIndex, int columnIndex) + { + T bean = Data[rowIndex]; + string column = columns[columnIndex]; + object val = null; + try + { +// column.SetAccessible(true); +// val = column[bean]; + } + catch (ArgumentException e) + { + LOG.Error(e.ToString()); + } + catch (AccessViolationException e) + { + LOG.Error(e.ToString()); + } + catch (SecurityException e) + { + LOG.Error(e.ToString()); + } + return val; + } + + public string ColumnName(int column) + { + string n = columns[column]; + return n.Substring(0, 1).ToUpper() + n.Substring(1); + } + + public Type ColumnClass(int columnIndex) + { + + Type clazz = null; + + string field; + try + { + field = columns[columnIndex]; + + if((field != null)) + clazz = field.GetType(); + + if(clazz.IsPrimitive) + { + clazz = clazz.ReflectedType; + } +// LOG.DebugFormat("Column class: {0} -> {1}", columnIndex, clazz); + } + catch (SecurityException e) + { + LOG.Error(e.ToString()); + } + + return clazz; + } + + public void AddRow(T row) + { + data.Add(row); +// this.FireTableRowsInserted(data.Count-1, data.Count-1); + } + + public void RemoveRow(int row) + { + data.RemoveAt(row); +// this.FireTableRowsDeleted(row, row); + } + + public void Clear() { + if(data.Count > 0) + { + data.Clear(); +// this.FireTableRowsDeleted(0, this.RowCount-1); + } + } + } +} diff --git a/WreckGui/WreckGui.csproj b/WreckGui/WreckGui.csproj index e09c4b6..0097d51 100644 --- a/WreckGui/WreckGui.csproj +++ b/WreckGui/WreckGui.csproj @@ -60,6 +60,7 @@ MainForm.cs +