/** * Adds a window to the frame container. * * @param parent Parent node * @param window Window to add */ public void addWindow(final MutableTreeNode parent, final TextFrame window) { UIUtilities.invokeAndWait( () -> { final NodeLabel label = new NodeLabel(window, iconManager); eventBus.subscribe(label); swingEventBus.subscribe(label); final TreeViewNode node = new TreeViewNode(label, window); synchronized (nodes) { nodes.put(window, node); } if (parent == null) { model.insertNodeInto(node, model.getRootNode()); } else { model.insertNodeInto(node, parent); } tree.expandPath(new TreePath(node.getPath()).getParentPath()); final Rectangle view = tree.getRowBounds(tree.getRowForPath(new TreePath(node.getPath()))); if (view != null) { tree.scrollRectToVisible(new Rectangle(0, (int) view.getY(), 0, 0)); } node.getLabel() .unreadStatusChanged( new UnreadStatusChangedEvent( window.getContainer(), window.getContainer().getUnreadStatusManager(), window.getContainer().getUnreadStatusManager().getNotificationColour(), window.getContainer().getUnreadStatusManager().getUnreadLines())); node.getLabel() .iconChanged( new FrameIconChangedEvent( window.getContainer(), window.getContainer().getIcon())); }); }
@Handler(invocation = EdtHandlerInvocation.class, delivery = Invoke.Asynchronously) public void unreadStatusChanged(final UnreadStatusChangedEvent event) { synchronized (nodes) { final TreeViewNode node = nodes.get(windowFactory.getSwingWindow(event.getSource())); if (node != null) { final NodeLabel label = node.getLabel(); if (label != null) { label.unreadStatusChanged(event); tree.repaint(); } } } }
/** * Checks for and sets a rollover node. * * @param event event to check */ protected void checkRollover(final MouseEvent event) { NodeLabel node = null; if (event != null && tree.getNodeForLocation(event.getX(), event.getY()) != null) { node = tree.getNodeForLocation(event.getX(), event.getY()).getLabel(); } synchronized (nodes) { for (TreeViewNode treeNode : nodes.values()) { final NodeLabel label = treeNode.getLabel(); label.setRollover(label == node); } } tree.repaint(); }