final WritableList input = tableView.getInput();
final Runnable addAction = new Runnable() {
@Override
public void run() {
final SetHeaderDefinition sh = new SetHeaderDefinition("myHeaderName", new LanguageExpressionBean(CamelModelHelper.getDefaultLanguageName(), ""));
final TableViewer viewer = tableView.getViewer();
Refreshable refreshable = new Refreshable() {
@Override
public void refresh() {
input.add(sh);
viewer.setSelection(new StructuredSelection(sh));
Viewers.refresh(viewer);
layoutForm();
panel.layout(true, true);
fireNodePropertyChangedEvent(id);
}
};
SetHeaderDialog.showDialog(sh, refreshable);
}
};
final Runnable editAction = new Runnable() {
@Override
public void run() {
Activator.getLogger().debug("Starting the edit...");
final TableViewer viewer = tableView.getViewer();
if (!viewer.getSelection().isEmpty()) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
Iterator iter = selection.iterator();
while (iter.hasNext()) {
SetHeaderDefinition sh = toSetHeaderDefinition(iter.next());
if (sh != null) {
Refreshable refreshable = new Refreshable() {
@Override
public void refresh() {
Viewers.refresh(viewer);
fireNodePropertyChangedEvent(id);
}
};
SetHeaderDialog.showDialog(sh, refreshable);
break;
}
}
}
}
};
final Runnable deleteAction = new Runnable() {
@Override
public void run() {
TableViewer viewer = tableView.getViewer();
if (!viewer.getSelection().isEmpty()) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
Iterator iter = selection.iterator();
while (iter.hasNext()) {
SetHeaderDefinition sh = toSetHeaderDefinition(iter.next());
if (sh != null) {
input.remove(sh);
}
}
fireNodePropertyChangedEvent(id);