-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
11 changed files
with
360 additions
and
140 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.github.miachm.sods; | ||
|
||
class CellCollection extends TableCollection<Cell> { | ||
|
||
public boolean isEmpty() | ||
{ | ||
for (Cell cell : items.values()) { | ||
if (!cell.isBlank()) | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
protected Cell createItem() { | ||
return new Cell(); | ||
} | ||
} |
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,23 @@ | ||
package com.github.miachm.sods; | ||
|
||
class Column extends TableItem { | ||
private ColumnStyle style; | ||
|
||
@Override | ||
public Column clone() throws CloneNotSupportedException { | ||
return (Column) super.clone(); | ||
} | ||
|
||
@Override | ||
public boolean isBlank() { | ||
return style.isDefault(); | ||
} | ||
|
||
public ColumnStyle getStyle() { | ||
return style; | ||
} | ||
|
||
public void setStyle(ColumnStyle style) { | ||
this.style = style; | ||
} | ||
} |
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,28 @@ | ||
package com.github.miachm.sods; | ||
|
||
class ColumnCollection extends TableCollection<Column> { | ||
private RowCollection rows; | ||
public ColumnCollection(RowCollection rows) | ||
{ | ||
this.rows = rows; | ||
} | ||
|
||
@Override | ||
public void remove(int index, int howmany) | ||
{ | ||
super.remove(index, howmany); | ||
rows.deleteCells(index, howmany); | ||
} | ||
|
||
@Override | ||
public void addItems(int index, int howmany) | ||
{ | ||
super.addItems(index, howmany); | ||
rows.addCells(index, howmany); | ||
} | ||
|
||
@Override | ||
protected Column createItem() { | ||
return new Column(); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.github.miachm.sods; | ||
|
||
class Row extends TableItem { | ||
private RowStyle style; | ||
private CellCollection cells = new CellCollection(); | ||
|
||
public RowStyle getStyle() { | ||
return style; | ||
} | ||
|
||
public void setStyle(RowStyle style) { | ||
this.style = style; | ||
} | ||
|
||
public CellCollection getCells() { | ||
return cells; | ||
} | ||
|
||
@Override | ||
public Row clone() throws CloneNotSupportedException { | ||
return (Row) super.clone(); | ||
} | ||
|
||
@Override | ||
public boolean isBlank() { | ||
return style.isDefault() && cells.isEmpty(); | ||
} | ||
} |
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,52 @@ | ||
package com.github.miachm.sods; | ||
|
||
import java.util.Map; | ||
|
||
public class RowCollection extends TableCollection<Row> { | ||
private int numColumns = 0; | ||
|
||
@Override | ||
public void addItems(int index, int howmany) | ||
{ | ||
boolean isEmpty = items.isEmpty(); | ||
super.addItems(index, howmany); | ||
if (isEmpty) { | ||
addCells(0, numColumns); | ||
numColumns /= 2; // Remove useless sum | ||
} | ||
} | ||
|
||
public void deleteCells(int index, int howmany) | ||
{ | ||
for (Map.Entry<Integer, Row> rowEntry : items.entrySet()) { | ||
Row row = rowEntry.getValue(); | ||
CellCollection cells = row.getCells(); | ||
cells.remove(index, howmany); | ||
} | ||
} | ||
|
||
public void addCells(int index, int howmany) { | ||
for (Map.Entry<Integer, Row> rowEntry : items.entrySet()) { | ||
Row row = rowEntry.getValue(); | ||
CellCollection cells = row.getCells(); | ||
cells.addItems(index, howmany); | ||
} | ||
numColumns += howmany; | ||
} | ||
|
||
@Override | ||
public Row getItemForEdit(int index) | ||
{ | ||
Row row = super.getItemForEdit(index); | ||
CellCollection cells = row.getCells(); | ||
if (cells.isEmpty()) | ||
cells.addItems(0, numColumns); | ||
|
||
return row; | ||
} | ||
|
||
@Override | ||
protected Row createItem() { | ||
return new Row(); | ||
} | ||
} |
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
Oops, something went wrong.