Skip to content

Commit

Permalink
Fixed typo. (changed HeaderColumn to ColumnHeader)
Browse files Browse the repository at this point in the history
  • Loading branch information
kimsama committed Aug 11, 2016
1 parent 2ebab18 commit 079f7f5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
20 changes: 10 additions & 10 deletions Assets/QuickSheet/Editor/BaseMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
namespace UnityQuickSheet
{
[System.Serializable]
public class HeaderColumn
public class ColumnHeader
{
public CellType type;
public string name;
public bool isEnable;
public bool isArray;
public HeaderColumn nextArrayItem;
public ColumnHeader nextArrayItem;

// used to order columns by ascending. (only need on excel-plugin)
public int OrderNO { get; set; }
Expand Down Expand Up @@ -100,22 +100,22 @@ public string WorkSheetName
[System.NonSerialized]
public bool onlyCreateDataClass = false;

public List<HeaderColumn> HeaderColumnList
public List<ColumnHeader> ColumnHeaderList
{
get { return headerColumnList; }
set { headerColumnList = value;}
get { return columnHeaderList; }
set { columnHeaderList = value; }
}

[SerializeField]
protected List<HeaderColumn> headerColumnList;
protected List<ColumnHeader> columnHeaderList;

/// <summary>
/// Return true, if the list is instantiated and has any its item more than one.
/// </summary>
/// <returns></returns>
public bool HasHeadColumn()
public bool HasColumnHeader()
{
if (headerColumnList != null && headerColumnList.Count > 0)
if (columnHeaderList != null && columnHeaderList.Count > 0)
return true;

return false;
Expand All @@ -126,8 +126,8 @@ public bool HasHeadColumn()

protected void OnEnable()
{
if (headerColumnList == null)
headerColumnList = new List<HeaderColumn>();
if (columnHeaderList == null)
columnHeaderList = new List<ColumnHeader>();
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions Assets/QuickSheet/Editor/BaseMachineEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected void CreateDataClassScript(BaseMachine machine, ScriptPrescription sp)
List<MemberFieldData> fieldList = new List<MemberFieldData>();

//FIXME: replace ValueType to CellType and support Enum type.
foreach (HeaderColumn header in machine.HeaderColumnList)
foreach (ColumnHeader header in machine.ColumnHeaderList)
{
MemberFieldData member = new MemberFieldData();
member.Name = header.name;
Expand Down Expand Up @@ -283,7 +283,7 @@ protected string GetAbsoluteBuiltinTemplatePath()

protected void DrawHeaderSetting(BaseMachine m)
{
if (m.HasHeadColumn())
if (m.HasColumnHeader())
{
GUIStyle headerStyle = GUIHelper.MakeHeader();
GUILayout.Label("Type Settings:", headerStyle);
Expand All @@ -304,7 +304,7 @@ protected void DrawHeaderSetting(BaseMachine m)
EditorGUILayout.BeginVertical("box");

//string lastCellName = string.Empty;
foreach (HeaderColumn header in m.HeaderColumnList)
foreach (ColumnHeader header in m.ColumnHeaderList)
{
GUILayout.BeginHorizontal();

Expand Down
18 changes: 9 additions & 9 deletions Assets/QuickSheet/ExcelPlugin/Editor/ExcelMachineEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Set a folder under the 'Assets' folder! \n

GUILayout.BeginHorizontal();

if (machine.HasHeadColumn())
if (machine.HasColumnHeader())
{
if (GUILayout.Button("Update"))
Import();
Expand Down Expand Up @@ -232,36 +232,36 @@ protected override void Import(bool reimport = false)

List<string> titleList = titles.ToList();

if (machine.HasHeadColumn() && reimport == false)
if (machine.HasColumnHeader() && reimport == false)
{
var headerDic = machine.HeaderColumnList.ToDictionary(header => header.name);
var headerDic = machine.ColumnHeaderList.ToDictionary(header => header.name);

// collect non-changed column headers
var exist = from t in titleList
where headerDic.ContainsKey(t) == true
select new HeaderColumn { name = t, type = headerDic[t].type, isArray = headerDic[t].isArray, OrderNO = headerDic[t].OrderNO };
select new ColumnHeader { name = t, type = headerDic[t].type, isArray = headerDic[t].isArray, OrderNO = headerDic[t].OrderNO };

// collect newly added or changed column headers
var changed = from t in titleList
where headerDic.ContainsKey(t) == false
select new HeaderColumn { name = t, type = CellType.Undefined, OrderNO = titleList.IndexOf(t) };
select new ColumnHeader { name = t, type = CellType.Undefined, OrderNO = titleList.IndexOf(t) };

// merge two list via LINQ
var merged = exist.Union(changed).OrderBy(x => x.OrderNO);

machine.HeaderColumnList.Clear();
machine.HeaderColumnList = merged.ToList();
machine.ColumnHeaderList.Clear();
machine.ColumnHeaderList = merged.ToList();
}
else
{
machine.HeaderColumnList.Clear();
machine.ColumnHeaderList.Clear();

if (titles != null)
{
int i = 0;
foreach (string s in titles)
{
machine.HeaderColumnList.Add(new HeaderColumn { name = s, type = CellType.Undefined, OrderNO = i });
machine.ColumnHeaderList.Add(new ColumnHeader { name = s, type = CellType.Undefined, OrderNO = i });
i++;
}
}
Expand Down
16 changes: 8 additions & 8 deletions Assets/QuickSheet/GDataPlugin/Editor/GoogleMachineEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public override void OnInspectorGUI()

GUILayout.BeginHorizontal();

if (machine.HasHeadColumn())
if (machine.HasColumnHeader())
{
if (GUILayout.Button("Update"))
Import();
Expand Down Expand Up @@ -201,13 +201,13 @@ protected override void Import(bool reimport = false)

Regex re = new Regex(@"\d+");

Dictionary<string, HeaderColumn> headerDic = null;
Dictionary<string, ColumnHeader> headerDic = null;
if (reimport)
machine.HeaderColumnList.Clear();
machine.ColumnHeaderList.Clear();
else
headerDic = machine.HeaderColumnList.ToDictionary(k => k.name);
headerDic = machine.ColumnHeaderList.ToDictionary(k => k.name);

List<HeaderColumn> tmpColumnList = new List<HeaderColumn>();
List<ColumnHeader> tmpColumnList = new List<ColumnHeader>();

// query the first columns only.
DoCellQuery((cell) =>
Expand All @@ -228,12 +228,12 @@ protected override void Import(bool reimport = false)
return;
}

HeaderColumn column = new HeaderColumn();
ColumnHeader column = new ColumnHeader();
column.name = cell.Value;
if (headerDic != null && headerDic.ContainsKey(cell.Value))
{
// if the column is already exist, copy its name and type from the exist one.
HeaderColumn h = machine.HeaderColumnList.Find(x => x.name == column.name);
ColumnHeader h = machine.ColumnHeaderList.Find(x => x.name == column.name);
if (h != null)
{
column.type = h.type;
Expand All @@ -249,7 +249,7 @@ protected override void Import(bool reimport = false)
});

// update (all of settings are reset when it reimports)
machine.HeaderColumnList = tmpColumnList;
machine.ColumnHeaderList = tmpColumnList;

EditorUtility.SetDirty(machine);
AssetDatabase.SaveAssets();
Expand Down

0 comments on commit 079f7f5

Please sign in to comment.