Exemple #1
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()));
          }
        });
  }
Exemple #2
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);
        });
  }
Exemple #3
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();
           }
         });
   }
 }