Skip to content

Commit

Permalink
Decrease memory footprint for AbstractTreeNode
Browse files Browse the repository at this point in the history
Remove extension and contributions
Lazy create child nodes
  • Loading branch information
csk-bsi committed Mar 29, 2023
1 parent 10a1906 commit 4e90f1b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.eclipse.scout.rt.platform.util.CollectionUtility;
import org.eclipse.scout.rt.shared.data.basic.FontSpec;
import org.eclipse.scout.rt.testing.platform.runner.PlatformTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -43,7 +42,6 @@ public class AbstractTreeTest {

@Before
public void setup() {
//BEANS.get(IExtensionRegistry.class).register(TreeNodeExtension.class);
m_tree = new P_Tree();
m_node1 = new P_TreeNode("node1");
m_node2 = new P_TreeNode("node2");
Expand All @@ -60,11 +58,6 @@ public void setup() {
m_tree.addTreeListener(m_treeListener);
}

@After
public void tearDown() {
//BEANS.get(IExtensionRegistry.class).deregister(TreeNodeExtension.class);
}

@Test
public void testNodeChangedSingleEvents() {

Expand Down Expand Up @@ -253,7 +246,7 @@ protected boolean containsEvent(List<TreeEvent> events, int eventType, ITreeNode

private static void assertDisposed(ITestDisposable... disposables) {
for (ITestDisposable disposable : disposables) {
assertTrue("should be desposed, but is not: " + disposable.getName(), disposable.isDisposed());
assertTrue("should be disposed, but is not: " + disposable.getName(), disposable.isDisposed());
}
}

Expand Down Expand Up @@ -522,13 +515,11 @@ private interface ITestDisposable {
boolean isDisposed();

String getName();

}

public static class P_TreeNode extends AbstractTreeNode implements ITestDisposable {
boolean m_disposeInternalCalled = false;
boolean m_execDisposeCalled = false;
boolean m_additionalDisposeCalled = false;

private String m_name;

Expand All @@ -543,7 +534,7 @@ public String getName() {

@Override
public boolean isDisposed() {
return m_disposeInternalCalled && m_execDisposeCalled && m_additionalDisposeCalled;
return m_disposeInternalCalled && m_execDisposeCalled;
}

@Override
Expand All @@ -556,10 +547,6 @@ public void disposeInternal() {
super.disposeInternal();
m_disposeInternalCalled = true;
}

public void additionalDispose() {
m_additionalDisposeCalled = true;
}
}

public static class P_TestMenu extends AbstractMenu implements ITestDisposable {
Expand All @@ -586,5 +573,4 @@ public void disposeActionInternal() {
m_disposed = true;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,7 @@ public void setFilterAccepted(boolean b) {

@Override
public void resetFilterCache() {
synchronized (this) {
m_filteredChildNodes = null;
}
m_filteredChildNodes = null;
}

@Override
Expand Down Expand Up @@ -1015,6 +1013,12 @@ public final void dispose() {
catch (RuntimeException e) {
LOG.warn("Exception while disposing node.", e);
}
try {
execDispose();
}
catch (RuntimeException e) {
LOG.warn("Exception while disposing node.", e);
}
finally {
setDisposing(false);
}
Expand Down

0 comments on commit 4e90f1b

Please sign in to comment.