From 9d0a8214035afa2f3dfdd052e0efebea4fc2dc1d Mon Sep 17 00:00:00 2001
From: Phillipus
Date: Thu, 21 Sep 2023 18:59:17 +0100
Subject: [PATCH] Add new Eclipse Incremental TreeViewer feature
- Requires Eclipse 4.29 or greater
- See https://github.com/eclipse-platform/eclipse.platform.ui/issues/818
- See https://github.com/eclipse-platform/eclipse.platform.ui/commit/ee92e3de6f124b554ceca47135babea27831d04b
- See https://github.com/eclipse-platform/eclipse.platform.ui/pull/810
---
.../editor/views/tree/TreeModelView.java | 6 ++++++
.../editor/views/tree/TreeModelViewer.java | 21 +++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/TreeModelView.java b/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/TreeModelView.java
index 14a7ea59b..29978a060 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/TreeModelView.java
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/TreeModelView.java
@@ -460,6 +460,12 @@ public void menuAboutToShow(IMenuManager manager) {
private void fillContextMenu(IMenuManager manager) {
IStructuredSelection selection = ((IStructuredSelection)getViewer().getSelection());
Object selected = selection.getFirstElement();
+
+ // Expandable node
+ if(getViewer().isExandableNode(selected)) {
+ return;
+ }
+
boolean isEmpty = selected == null;
if(isEmpty && fTreeViewer.getInput() instanceof IEditorModelManager) {
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/TreeModelViewer.java b/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/TreeModelViewer.java
index cfc81289a..6fc5ce8f4 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/TreeModelViewer.java
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/TreeModelViewer.java
@@ -41,6 +41,7 @@
import com.archimatetool.editor.preferences.IPreferenceConstants;
import com.archimatetool.editor.ui.ArchiLabelProvider;
import com.archimatetool.editor.ui.FontFactory;
+import com.archimatetool.editor.ui.IArchiImages;
import com.archimatetool.editor.ui.UIUtils;
import com.archimatetool.editor.ui.components.TreeTextCellEditor;
import com.archimatetool.editor.ui.textrender.TextRenderer;
@@ -106,6 +107,8 @@ public TreeModelViewer(Composite parent, int style) {
setUseHashlookup(true);
+ setDisplayIncrementally(5000);
+
// Sort
setComparator(new ViewerComparator(Collator.getInstance()) {
@Override
@@ -313,6 +316,13 @@ private String getAncestorFolderRenderText(IArchimateModelObject object) {
return null;
}
+ /**
+ * Make this public
+ */
+ public boolean isExandableNode(Object element) {
+ return super.isExpandableNode(element);
+ }
+
// ========================= Model Providers =====================================
/**
@@ -394,6 +404,10 @@ private void resetFonts() {
}
private String getText(Object element) {
+ if(isExpandableNode(element)) {
+ return null;
+ }
+
// If a Concept or a View's parent or ancestor parent folder has a text expression, evaluate it
String text = getAncestorFolderRenderText((IArchimateModelObject)element);
if(text != null) {
@@ -423,10 +437,17 @@ private String getText(Object element) {
}
private Image getImage(Object element) {
+ if(isExpandableNode(element)) {
+ return IArchiImages.ImageFactory.getImage(IArchiImages.ZOOM_IN);
+ }
return ArchiLabelProvider.INSTANCE.getImage(element);
}
private Font getFont(Object element) {
+ if(isExpandableNode(element)) {
+ return null;
+ }
+
boolean isFiltering = false;
boolean unusedConcept = false;