Esempio n. 1
0
  /** Sets treeview colours. */
  private void setColours() {
    tree.setBackground(
        UIUtilities.convertColour(
            colourManager.getColourFromString(
                config.getOptionString("treeview", "backgroundcolour", "ui", "backgroundcolour"),
                null)));
    tree.setForeground(
        UIUtilities.convertColour(
            colourManager.getColourFromString(
                config.getOptionString("treeview", "foregroundcolour", "ui", "foregroundcolour"),
                null)));

    tree.repaint();
  }
Esempio n. 2
0
  /** Starts the tree from scratch taking into account new sort orders. */
  private void redoTreeView() {
    UIUtilities.invokeLater(
        () -> {
          ((DefaultTreeModel) tree.getModel()).setRoot(null);
          ((DefaultTreeModel) tree.getModel()).setRoot(new TreeViewNode(null, null));
          if (scroller != null) {
            scroller.unregister();
          }
          scroller = new TreeTreeScroller(swingEventBus, tree);

          for (WindowModel window : windowManager.getRootWindows()) {
            addWindow(null, windowFactory.getSwingWindow(window));
            final Collection<WindowModel> childWindows = windowManager.getChildren(window);
            for (WindowModel childWindow : childWindows) {
              addWindow(
                  nodes.get(windowFactory.getSwingWindow(window)),
                  windowFactory.getSwingWindow(childWindow));
            }
          }

          if (activeFrameManager.getActiveFrame() != null) {
            selectionChanged(new SwingWindowSelectedEvent(activeFrameManager.getActiveFrame()));
          }
        });
  }
Esempio n. 3
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()));
        });
  }
Esempio n. 4
0
  @Inject
  public TreeFrameManager(
      final WindowManager windowManager,
      @GlobalConfig final AggregateConfigProvider globalConfig,
      @GlobalConfig final ColourManager colourManager,
      final ActiveFrameManager activeFrameManager,
      final SwingWindowFactory windowFactory,
      @PluginDomain(SwingController.class) final String domain,
      final EventBus eventBus,
      final SwingEventBus swingEventBus,
      final IconManager iconManager) {
    this.windowFactory = windowFactory;
    this.windowManager = windowManager;
    this.nodes = new HashMap<>();
    this.config = globalConfig;
    this.colourManager = colourManager;
    this.activeFrameManager = activeFrameManager;
    this.eventBus = eventBus;
    this.swingEventBus = swingEventBus;
    this.iconManager = iconManager;

    UIUtilities.invokeLater(
        () -> {
          model = new TreeViewModel(config, new TreeViewNode(null, null));
          tree = new Tree(this, model, swingEventBus, globalConfig, domain);
          tree.setCellRenderer(new TreeViewTreeCellRenderer(config, colourManager, this));
          tree.setVisible(true);

          config.addChangeListener("treeview", this);
          config.addChangeListener("ui", "sortrootwindows", this);
          config.addChangeListener("ui", "sortchildwindows", this);
          config.addChangeListener("ui", "backgroundcolour", this);
          config.addChangeListener("ui", "foregroundcolour", this);
        });
  }
Esempio n. 5
0
 @Handler(invocation = EdtHandlerInvocation.class)
 public void selectionChanged(final SwingWindowSelectedEvent event) {
   if (event.getWindow().isPresent()) {
     UIUtilities.invokeLater(
         () -> {
           final TreeNode[] treePath =
               ((DefaultTreeModel) tree.getModel())
                   .getPathToRoot(nodes.get(event.getWindow().get()));
           if (treePath != null && treePath.length > 0) {
             final TreePath path = new TreePath(treePath);
             tree.setTreePath(path);
             tree.scrollPathToVisible(path);
             tree.repaint();
           }
         });
   }
 }
Esempio n. 6
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);
         }
       });
 }