public void testBlocking() { final Composite parentComposite = ReflectionUtils.invokeHidden(subModuleNodeView, "getParentComposite"); final Composite contentComposite = ReflectionUtils.invokeHidden(subModuleNodeView, "getContentComposite"); final Cursor oldCursor = parentComposite.getCursor(); final Cursor waitCursor = parentComposite.getDisplay().getSystemCursor(SWT.CURSOR_WAIT); node.setBlocked(true); assertFalse(contentComposite.isEnabled()); assertSame(waitCursor, parentComposite.getCursor()); node.setBlocked(false); assertTrue(contentComposite.isEnabled()); assertSame(oldCursor, parentComposite.getCursor()); // blocking several times should still have the same cursor outcome node.setBlocked(true); node.setBlocked(true); assertFalse(contentComposite.isEnabled()); assertSame(waitCursor, parentComposite.getCursor()); node.setBlocked(false); assertTrue(contentComposite.isEnabled()); assertSame(oldCursor, parentComposite.getCursor()); }
@Override public void bind(final SubModuleNode node) { if (node.getNavigationNodeController() == null) { node.setNavigationNodeController(createController(node)); } ReflectionUtils.setHidden(this, "currentController", node.getNavigationNodeController()); nodesBoundToSharedView.add(node); }
public void testBlockOnBind() throws Exception { node.setBlocked(true); TestView2 view2 = new TestView2(); view2.bind(node); assertNotNull(view2.blockViewCalled[0]); assertTrue(view2.blockViewCalled[0]); node.setBlocked(false); view2 = new TestView2(); view2.bind(node); assertNotNull(view2.blockViewCalled[0]); assertFalse(view2.blockViewCalled[0]); }
public void testBindOnActivate() throws Exception { nodesBoundToView.clear(); anotherNode.activate(); assertTrue(nodesBoundToView.isEmpty()); anotherNodeSameView.activate(); assertTrue(nodesBoundToView.isEmpty()); node.activate(); assertEquals(1, nodesBoundToView.size()); assertSame(node, nodesBoundToView.get(0)); }
@Override protected void tearDown() throws Exception { node.deactivate(null); removeExtension("sub.module.view.test"); shell.dispose(); super.tearDown(); }
@Override protected void setUp() throws Exception { super.setUp(); shell = new Shell(); parentComposite = new Composite(shell, SWT.NONE); addPluginXml(SubModuleViewTest.class, "SubModuleViewTest.xml"); appNode = new ApplicationNode(); final SubApplicationNode subAppNode = new SubApplicationNode(); appNode.addChild(subAppNode); final ModuleGroupNode mgNode = new ModuleGroupNode(null); subAppNode.addChild(mgNode); moduleNode = new ModuleNode(null, "TestModuleLabel"); mgNode.addChild(moduleNode); anotherNode = new SubModuleNode(new NavigationNodeId("testId2", "2"), "TestSubModuleLabel2"); moduleNode.addChild(anotherNode); anotherNodeSameView = new SubModuleNode(new NavigationNodeId("testId", "1"), "TestSubModuleLabel3"); moduleNode.addChild(anotherNodeSameView); nodesBoundToView = new ArrayList<SubModuleNode>(); nodesBoundToSharedView = new ArrayList<SubModuleNode>(); subModuleNodeView = new TestView(); node = new SubModuleNode(new NavigationNodeId("testId", "0"), "TestSubModuleLabel"); moduleNode.setNavigationNodeController(new ModuleController(moduleNode)); moduleNode.addChild(node); subModuleNodeView.createPartControl(new Shell()); node.activate(); }
public void testShared() { subModuleNodeView.dispose(); final SubModuleNode s1 = new SubModuleNode(new NavigationNodeId("s", "1")); final SubModuleNode s2 = new SubModuleNode(new NavigationNodeId("s", "2")); moduleNode.addChild(s1); moduleNode.addChild(s2); final TestSharedView subModuleNodeSharedView = new TestSharedView(); subModuleNodeSharedView.s1 = s1; subModuleNodeSharedView.s2 = s2; subModuleNodeSharedView.createPartControl(new Shell()); assertNotNull(s1.getNavigationNodeController()); s1.activate(); final SubModuleController s1c = (SubModuleController) s1.getNavigationNodeController(); assertNotNull(s1c.getRidget("button")); assertEquals(nodesBoundToSharedView.get(0), s1); s2.activate(); assertEquals(nodesBoundToSharedView.get(2), s2); s1.dispose(); assertFalse(subModuleNodeSharedView.unbindActiveCalled); s2.dispose(); assertTrue(subModuleNodeSharedView.unbindActiveCalled); }
@Override public SubModuleNode getNavigationNode() { return s1.isActivated() ? s1 : s2.isActivated() ? s2 : s1; }