@Override
public void setInput(IWorkbenchPart part, ISelection selection) {
super.setInput(part, selection);
// remove property listener on old model
AbstractObject oldModel = getModel();
if (oldModel != null) {
oldModel.removePropertyChangeListener(this);
}
if (selection instanceof IStructuredSelection) {
Object object = ((IStructuredSelection) selection)
.getFirstElement();
if (object instanceof EditPart) {
Object editPartModel = ((EditPart) object).getModel();
if (editPartModel instanceof AbstractObject) {
AbstractObject model = (AbstractObject) editPartModel;
if (model.getParameter(parameterName) == null) {
tableViewer.getTable().setEnabled(false);
buttonAdd.setEnabled(false);
buttonRemove.setEnabled(false);
} else {
tableViewer.getTable().setEnabled(true);
buttonAdd.setEnabled(true);
buttonRemove.setEnabled(true);
model.addPropertyChangeListener(this);
tableViewer.setInput(model);
}
}
}
}