Commit b8443ae5 authored by Simon Barner's avatar Simon Barner
Browse files

- Add setRedraw() and getDraw() to control update of tree viewer

parent 233116a3
......@@ -40,13 +40,16 @@ import org.fortiss.tooling.kernel.ui.extension.base.EditorBase;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: B41A78E1C4B5CE289ABE9708C75C3BE2
* @ConQAT.Rating YELLOW Hash: C9AE2970436C1B319E0CDB08EA9A0428
*/
public abstract class TreeViewerEditorBase<T extends EObject> extends EditorBase<T> {
/** Stores the {@link TreeViewer}. */
private TreeViewer treeViewer;
/** Flag if redraw of the underlying {@link #treeViewer} is enabled. */
boolean redraw;
/** The adapter used for dealing with changes of the content. */
private final Adapter editedObjectChanged = new EContentAdapter() {
@Override
......@@ -54,7 +57,7 @@ public abstract class TreeViewerEditorBase<T extends EObject> extends EditorBase
super.notifyChanged(notification);
if(notification.getEventType() != Notification.REMOVING_ADAPTER) {
Display.getDefault().asyncExec(() -> {
if(!treeViewer.getTree().isDisposed()) {
if(!treeViewer.getTree().isDisposed() && getRedraw()) {
treeViewer.refresh(true);
}
});
......@@ -66,6 +69,7 @@ public abstract class TreeViewerEditorBase<T extends EObject> extends EditorBase
@Override
public void createPartControl(Composite parent) {
treeViewer = new TreeViewer(parent);
redraw = true;
setupTreeViewer(treeViewer);
......@@ -110,8 +114,22 @@ public abstract class TreeViewerEditorBase<T extends EObject> extends EditorBase
treeViewer.getTree().setFocus();
}
/** Returns treeViewer. */
/** Returns {@link #treeViewer}. */
public TreeViewer getTreeViewer() {
return treeViewer;
}
/** Sets {@link #redraw}. */
public void setRedraw(boolean redraw) {
this.redraw = redraw;
treeViewer.getTree().setRedraw(redraw);
if(redraw) {
treeViewer.refresh();
}
}
/** Returns {@link #redraw}. */
boolean getRedraw() {
return redraw;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment