public String getColumnText(Object o, int i) {
BeanProxy ruleProxy = (BeanProxy) o;
String returnValue = null;
if (i == COLUMN_SELECTOR) {
// Selectors
Proxy selectorsProxy =
ruleProxy.getPropertyProxy(Rule.SELECTORS);
Object model = selectorsProxy.getModelObject();
returnValue = selectorListToText((List) model);
} else if (i == COLUMN_ORDER) {
// Order
ListProxy rules = (ListProxy) getSelectedStyleSheetProxy().
getPropertyProxy(ThemeModel.RULES);
int index = rules.getItemProxyIndex(ruleProxy);
// Indices start at 0, but humans expect 1...
returnValue = String.valueOf(index + 1);
}
return returnValue;
}
public void addListener(ILabelProviderListener iLabelProviderListener) {
}
public void dispose() {
}
public boolean isLabelProperty(Object o, String s) {
return true;
}
public void removeListener(ILabelProviderListener iLabelProviderListener) {
}
};
ruleTable.setLabelProvider(labelProvider);
CellEditor editors [] = new CellEditor[2];
editors[0] = new TextCellEditor(table);
ruleTable.setCellEditors(editors);
ruleTable.setColumnProperties(new String[]{"selectors", "order"});
ruleTable.setCellModifier(new ICellModifier() {
public boolean canModify(Object o, String s) {
return "selectors".equals(s);
}
public Object getValue(Object o, String s) {
Object value = null;
// Only selectors are modifiable, so ignore all other settings
if ("selectors".equals(s)) {
List selectors = ruleProxyToSelectorList((BeanProxy) o);
value = selectorListToText(selectors);
}
return value;
}
public void modify(Object tableItem, String columnName, Object newValue) {
if ("selectors".equals(columnName)) {
TableItem item = (TableItem) tableItem;
BeanProxy ruleProxy = (BeanProxy) item.getData();
String oldValue = labelProvider.getColumnText(ruleProxy, COLUMN_SELECTOR);
if (!oldValue.equals(newValue)) {
List parsed =
CSS_PARSER.parseSelectorGroup((String) newValue);
ListProxy selectorsProxy = (ListProxy) ruleProxy.getPropertyProxy(Rule.SELECTORS);
Operation setList = selectorsProxy.prepareSetModelObjectOperation(parsed);
context.executeOperation(setList);
}
}
}
});