}
// javadoc inherited
public String getColumnText(Object element,
int columnIndex) {
DeviceHeaderPattern pattern =
(DeviceHeaderPattern) element;
final String columnName =
tableViewer.getTable().
getColumn(columnIndex).getText();
String value = null;
if (columnName == HEADER_NAME_HEADER) {
value = pattern.getName();
} else if (columnName == VALUE_HEADER) {
value = pattern.getRegularExpression();
} else if (columnName == DEVICE_NAME_HEADER) {
value = pattern.getBaseDevice();
if (value == null) {
value = "";
}
}
return value;
}
// javadoc inherited
public void addListener(ILabelProviderListener listener) {
}
// javadoc inherited
public void dispose() {
}
// javadoc inherited
public boolean isLabelProperty(Object element,
String property) {
return false;
}
// javadoc inherited
public void removeListener(ILabelProviderListener listener) {
}
};
}
// javadoc inherited
protected Object createNewItem() {
return new DeviceHeaderPattern("", "", "");
}
// javadoc inherited
protected ICellModifier createCellModifier() {
return new ICellModifier() {
// javadoc inherited
public boolean canModify(Object element, String property) {
return true;
}
// javadoc inherited
public Object getValue(Object element, String property) {
DeviceHeaderPattern pattern =
(DeviceHeaderPattern) element;
Object value = null;
if (property == HEADER_NAME_HEADER) {
value = pattern.getName();
} else if (property == VALUE_HEADER) {
value = pattern.getRegularExpression();
} else if (property == DEVICE_NAME_HEADER) {
value = pattern.getBaseDevice();
if (value == null) {
value = "";
}
}
return value;
}
// javadoc inherited
public void modify(Object element, String property,
Object value) {
TableItem item = (TableItem) element;
DeviceHeaderPattern pattern =
(DeviceHeaderPattern) item.getData();
String newValue = (String) value;
boolean changed = false;
if (property == HEADER_NAME_HEADER) {
// The name cannot be null.
changed = !pattern.getName().equals(newValue);
pattern.setName(newValue);
} else if (property == VALUE_HEADER) {
// The regular expression cannot be null.
changed = !pattern.getRegularExpression().
equals(newValue);
pattern.setRegularExpression(newValue);
} else if (property == DEVICE_NAME_HEADER) {
// The base device CAN be null.
String oldBase = pattern.getBaseDevice();
if (oldBase == null && newValue == null) {
changed = false;
} else {
if (oldBase != null) {
changed = !oldBase.equals(newValue);
} else {
changed = !newValue.equals(oldBase);
}
}
pattern.setBaseDevice(
(newValue.equals("")) ? null : newValue);
}
// Inform the model of a change only if the object was
// modified.
if (changed) {