Ejemplo n.º 1
0
  /**
   * 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()));
        });
  }
Ejemplo n.º 2
0
 @Handler
 public void doDeleteWindow(final SwingWindowDeletedEvent event) {
   final TextFrame window = event.getChildWindow();
   UIUtilities.invokeAndWait(
       () -> {
         if (nodes.get(window) == null) {
           return;
         }
         final DefaultMutableTreeNode node = nodes.get(window);
         if (node.getLevel() == 0) {
           LOG.warn(
               LogUtils.USER_ERROR,
               "delServer triggered for root node {}",
               node,
               new IllegalArgumentException());
         } else {
           model.removeNodeFromParent(nodes.get(window));
         }
         synchronized (nodes) {
           eventBus.unsubscribe(nodes.get(window).getLabel());
           nodes.remove(window);
         }
       });
 }