-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
193 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,66 @@ | ||
| ||
using System; | ||
using Wreck.Entity; | ||
|
||
namespace WreckGui.Model | ||
namespace Wreck.Model | ||
{ | ||
/// <summary> | ||
/// Description of GuiModel. | ||
/// </summary> | ||
public class GuiModel | ||
{ | ||
// private static readonly Pattern DIGITS = Pattern.compile("^[0-9]+$"); | ||
|
||
private readonly SampleTableModel<FileBean> tableModel; | ||
// private readonly ButtonModel metadataModel; | ||
// private readonly IDictionary<SourceEnum, ButtonModel> sourceModel; | ||
// private readonly Document dateTimeDocument; | ||
// private readonly SpinnerNumberModel customDateTimeYearModel; | ||
// private readonly SpinnerNumberModel customDateTimeMonthModel; | ||
// private readonly SpinnerNumberModel customDateTimeDayModel; | ||
// private readonly SpinnerDateModel customDateTimeModel; | ||
|
||
// private readonly IDictionary<CorrectionEnum, ButtonModel> correctionModel; | ||
|
||
// private readonly DefaultButtonModel backupModel; | ||
// private readonly DefaultButtonModel restoreModel; | ||
// private readonly DefaultButtonModel verifyModel; | ||
|
||
private readonly SampleTableModel<FileStatisticsBean> fileStatisticsTableModel; | ||
private readonly SampleTableModel<MetadataStatisticsBean> metadataStatisticsTableModel; | ||
private readonly SampleTableModel<ExtensionStatisticsBean> extensionStatisticsTableModel; | ||
|
||
// private readonly DefaultListModel<AboutBean> aboutModel; | ||
|
||
// private readonly BoundedRangeModel scanningProgressModel; | ||
|
||
public GuiModel() | ||
{ | ||
this.tableModel = new SampleTableModel<FileBean>(typeof(FileBean)); | ||
|
||
this.fileStatisticsTableModel = new SampleTableModel<FileStatisticsBean>(typeof(FileStatisticsBean)); | ||
this.metadataStatisticsTableModel = new SampleTableModel<MetadataStatisticsBean>(typeof(MetadataStatisticsBean)); | ||
this.extensionStatisticsTableModel = new SampleTableModel<ExtensionStatisticsBean>(typeof(ExtensionStatisticsBean)); | ||
} | ||
|
||
public SampleTableModel<FileBean> TableModel | ||
{ | ||
get { return tableModel; } | ||
} | ||
|
||
public SampleTableModel<FileStatisticsBean> FileStatisticsTableModel | ||
{ | ||
get { return fileStatisticsTableModel; } | ||
} | ||
|
||
public SampleTableModel<MetadataStatisticsBean> MetadataStatisticsTableModel | ||
{ | ||
get { return metadataStatisticsTableModel; } | ||
} | ||
|
||
public SampleTableModel<ExtensionStatisticsBean> ExtensionStatisticsTableModel | ||
{ | ||
get { return extensionStatisticsTableModel; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
| ||
using System; | ||
using System.Collections.Generic; | ||
using System.Security; | ||
|
||
using log4net; | ||
|
||
namespace Wreck.Model | ||
{ | ||
/// <summary> | ||
/// Description of SampleTableModel. | ||
/// </summary> | ||
public class SampleTableModel<T> | ||
{ | ||
private static readonly ILog LOG = LogManager.GetLogger(typeof(SampleTableModel<T>)); | ||
|
||
private IList<string> columns = new List<string>(); | ||
private IList<T> data = new List<T>(); | ||
|
||
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<T> 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); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters