});
} else {
String data = graph.getRelatedValue2(table, DN.TechType_TechTypeTable_HasData);
});
} else {
String data = graph.getRelatedValue2(table, DN.TechType_TechTypeTable_HasData);
- int[] enabled = graph.getPossibleRelatedValue2(table, DN.TechType_TechTypeTable_HasEnabledItems);
TechTypeTableView.table.getDisplay().asyncExec(() -> {
TechTypeTableView.table.setComponentType(null);
TechTypeTableView.table.getDisplay().asyncExec(() -> {
TechTypeTableView.table.setComponentType(null);
- TechTypeTableView.table.setTechTypeData(data, enabled);
+ TechTypeTableView.table.setTechTypeData(data, null);
bodyDataLayer.setConfigLabelAccumulator(new IConfigLabelAccumulator() {
@Override
public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
bodyDataLayer.setConfigLabelAccumulator(new IConfigLabelAccumulator() {
@Override
public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
- if (columnPosition == 0) {
+ if (bodyDataProvider.isCheckBoxColumn(columnPosition)) {
configLabels.addLabel(CHECK_BOX_LABEL);
} else if (validationResult != null && keyName != null) {
int keyColumn = bodyDataProvider.getVariableIndex(keyName);
configLabels.addLabel(CHECK_BOX_LABEL);
} else if (validationResult != null && keyName != null) {
int keyColumn = bodyDataProvider.getVariableIndex(keyName);
new EditableRule() {
@Override
public boolean isEditable(int columnIndex, int rowIndex) {
new EditableRule() {
@Override
public boolean isEditable(int columnIndex, int rowIndex) {
- return columnIndex == 0;
+ return bodyDataProvider.isEditable(columnIndex, rowIndex);
private ListenerList<EnableListener> enableListeners = new ListenerList<EnableListener>();
private int[] sortedRows;
private ListenerList<EnableListener> enableListeners = new ListenerList<EnableListener>();
private int[] sortedRows;
+
+ private boolean showEnabled = true;
private static final Comparator<? super String> VALUE_COMPARATOR = (a, b) -> {
try {
private static final Comparator<? super String> VALUE_COMPARATOR = (a, b) -> {
try {
public TechTypeTableDataProvider(String data, int[] enabledList) {
setData(data);
setEnabledFlags(enabledList);
public TechTypeTableDataProvider(String data, int[] enabledList) {
setData(data);
setEnabledFlags(enabledList);
+ showEnabled = enabledList != null;
}
public TechTypeTableDataProvider(String data) {
}
public TechTypeTableDataProvider(String data) {
}
public void setEnabledFlags(int[] enabledList) {
}
public void setEnabledFlags(int[] enabledList) {
+
+ showEnabled = enabledList != null;
+ }
+
+ public boolean isCheckBoxColumn(int columnIndex) {
+ return isEnabledColumn(columnIndex);
}
public String getVariableName(int columnIndex) {
}
public String getVariableName(int columnIndex) {
- return variables != null && columnIndex > 0 && columnIndex <= variables.size() ? variables.get(columnIndex - 1) : null;
+ return variables != null && columnIndex > 0 && columnIndex <= variables.size()
+ ? variables.get(columnIndex - columnOffset())
+ : null;
+ private int columnOffset() {
+ return showEnabled ? 1 : 0;
+ }
+
public int getVariableIndex(String variableName) {
public int getVariableIndex(String variableName) {
- return variables != null ? variables.indexOf(variableName) + 1 : -1;
+ return variables != null ? variables.indexOf(variableName) + columnOffset() : -1;
}
public CSVRecord getRecord(int rowIndex) {
}
public CSVRecord getRecord(int rowIndex) {
public String getHeaderValue(int columnIndex) {
if (headers == null) {
return "<empty>";
public String getHeaderValue(int columnIndex) {
if (headers == null) {
return "<empty>";
- } else if (columnIndex == 0) {
+ } else if (isEnabledColumn(columnIndex)) {
return "Enabled";
} else {
return "Enabled";
} else {
- return headers.get(columnIndex - 1);
+ return headers.get(columnIndex - columnOffset());
}
}
@Override
public Object getDataValue(int columnIndex, int rowIndex) {
}
}
@Override
public Object getDataValue(int columnIndex, int rowIndex) {
- if (columnIndex == 0) {
+ if (isEnabledColumn(columnIndex)) {
return isEnabled(rowIndex);
}
return isEnabled(rowIndex);
}
- return getRecord(rowIndex).get(columnIndex - 1);
+ return getRecord(rowIndex).get(columnIndex - columnOffset());
}
@Override
public void setDataValue(int columnIndex, int rowIndex, Object newValue) {
}
@Override
public void setDataValue(int columnIndex, int rowIndex, Object newValue) {
- if (columnIndex == 0) {
+ if (isEnabledColumn(columnIndex)) {
boolean value = Boolean.parseBoolean((String) newValue);
enabled[recordIndex(rowIndex)] = value;
fireEnableEvent(rowIndex, value);
boolean value = Boolean.parseBoolean((String) newValue);
enabled[recordIndex(rowIndex)] = value;
fireEnableEvent(rowIndex, value);
if (records.isEmpty()) {
return 0;
}
if (records.isEmpty()) {
return 0;
}
- return records.get(0).size() + 1;
+ return records.get(0).size() + columnOffset();
}
public boolean isEditable(int columnIndex, int rowIndex) {
}
public boolean isEditable(int columnIndex, int rowIndex) {
- return columnIndex == 0;
+ return isEnabledColumn(columnIndex);
+ private boolean isEnabledColumn(int columnIndex) {
+ return showEnabled && columnIndex == 0;
+ }
+
public void setFilter(String text) {
this.filter = text != null ? text.toLowerCase() : null;
public void setFilter(String text) {
this.filter = text != null ? text.toLowerCase() : null;
public void sortBy(int columnIndex, SortDirectionEnum sortDirection) {
if (columnIndex >= 0 && !sortDirection.equals(SortDirectionEnum.NONE)) {
public void sortBy(int columnIndex, SortDirectionEnum sortDirection) {
if (columnIndex >= 0 && !sortDirection.equals(SortDirectionEnum.NONE)) {
- Comparator<Integer> comparator = columnIndex == 0 ?
+ int offset = columnOffset();
+ Comparator<Integer> comparator = isEnabledColumn(columnIndex) ?
Comparator.comparing(k -> enabled[sortedRows[(int) k]]) :
Comparator.comparing(k -> enabled[sortedRows[(int) k]]) :
- Comparator.comparing(k -> records.get(sortedRows[(int) k]).get(columnIndex-1), VALUE_COMPARATOR);
+ Comparator.comparing(k -> records.get(sortedRows[(int) k]).get(columnIndex-offset), VALUE_COMPARATOR);
if (sortDirection.equals(SortDirectionEnum.DESC))
comparator = comparator.reversed();
if (sortDirection.equals(SortDirectionEnum.DESC))
comparator = comparator.reversed();