Added lockable tables

git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@174 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
Jared Gould 2006-07-25 15:43:50 +00:00
parent b130e47424
commit 44aa01cb62
4 changed files with 30 additions and 12 deletions

View File

@ -164,21 +164,22 @@ public class DataCell extends JLabel implements MouseListener, Serializable {
public void increment(double increment) {
double oldValue = Double.parseDouble(getText());
if (table.getScale().getCoarseIncrement() < 0) increment = 0 - increment;
setRealValue((calcDisplayValue(binValue,
scale.getExpression()) + increment) + "");
// make sure table is incremented if change isnt great enough
if (oldValue == Double.parseDouble(getText()) &&
table.getStorageType() != Table.STORAGE_TYPE_FLOAT) {
setBinValue(binValue + (increment / Math.abs(increment)));
}
table.colorize();
}
public void setTable(Table table) {

View File

@ -80,6 +80,7 @@ public abstract class Table extends JPanel implements Serializable {
protected int compareDisplay = 1;
protected int userLevel = 0;
protected Settings settings;
protected boolean locked = false;
public Table(Settings settings) {
this.setSettings(settings);
@ -284,7 +285,11 @@ public abstract class Table extends JPanel implements Serializable {
if (scales.isEmpty()) {
scales.add(new Scale());
}
// temporarily remove lock
boolean tempLock = locked;
locked = false;
if (!isStatic) {
if (!beforeRam) {
ramOffset = container.getRomID().getRamOffset();
@ -319,6 +324,9 @@ public abstract class Table extends JPanel implements Serializable {
}
}
}
// reset locked status
locked = tempLock;
}
public int getType() {
@ -598,7 +606,7 @@ public abstract class Table extends JPanel implements Serializable {
}
public void increment(double increment) {
if (!isStatic) {
if (!isStatic && !locked) {
for (DataCell cell : data) {
if (cell.isSelected()) {
cell.increment(increment);
@ -607,8 +615,8 @@ public abstract class Table extends JPanel implements Serializable {
}
}
public void setRealValue(String realValue) {
if (!isStatic) {
public void setRealValue(String realValue) {
if (!isStatic && !locked) {
for (DataCell cell : data) {
if (cell.isSelected()) {
cell.setRealValue(realValue);
@ -1064,4 +1072,12 @@ public abstract class Table extends JPanel implements Serializable {
public void setSettings(Settings settings) {
this.settings = settings;
}
public boolean isLocked() {
return locked;
}
public void setLocked(boolean locked) {
this.locked = locked;
}
}

View File

@ -324,7 +324,7 @@ public class Table3D extends Table {
}
public void increment(double increment) {
if (!isStatic) {
if (!isStatic && !locked) {
for (int x = 0; x < this.getSizeX(); x++) {
for (int y = 0; y < this.getSizeY(); y++) {
if (data[x][y].isSelected()) {
@ -452,7 +452,7 @@ public class Table3D extends Table {
}
public void setRealValue(String realValue) {
if (!isStatic) {
if (!isStatic && !locked) {
for (int x = 0; x < this.getSizeX(); x++) {
for (int y = 0; y < this.getSizeY(); y++) {
if (data[x][y].isSelected()) {

View File

@ -273,6 +273,7 @@ public class DOMRomUnmarshaller {
table.setDataSize(Integer.parseInt(unmarshallAttribute(tableNode, "sizey", unmarshallAttribute(tableNode, "sizex", table.getDataSize()))));
table.setFlip(Boolean.parseBoolean(unmarshallAttribute(tableNode, "flipy", unmarshallAttribute(tableNode, "flipx", table.getFlip()+""))));
table.setUserLevel(Integer.parseInt(unmarshallAttribute(tableNode, "userlevel", table.getUserLevel())));
table.setLocked(Boolean.parseBoolean(unmarshallAttribute(tableNode, "locked", table.isLocked()+"")));
if (table.getType() == Table.TABLE_3D) {
((Table3D)table).setFlipX(Boolean.parseBoolean(unmarshallAttribute(tableNode, "flipx", ((Table3D)table).getFlipX()+"")));