コード例 #1
0
  /**
   * Gets a list of stations which have no parent and are therefore the roots of the dock-trees.
   *
   * @return the roots
   */
  public DockStation[] listRoots() {
    List<DockStation> list = new LinkedList<DockStation>();
    for (DockStation station : stations) {
      Dockable dockable = station.asDockable();
      if (dockable == null || dockable.getDockParent() == null) list.add(station);
    }

    return list.toArray(new DockStation[list.size()]);
  }
コード例 #2
0
  /**
   * Removes a station which was managed by this register.
   *
   * @param station the station to remove
   */
  public void remove(DockStation station) {
    if (stations.contains(station)) {
      setProtected(station, false);
      Dockable dock = station.asDockable();
      if (dock != null) {
        DockStation parent = dock.getDockParent();
        if (parent != null) parent.drag(dock);
      }

      DockUtilities.visit(
          station,
          new DockUtilities.DockVisitor() {
            private Set<DockStation> ignored = new HashSet<DockStation>();

            @Override
            public void handleDockable(Dockable dockable) {
              DockStation station = dockable.asDockStation();
              if (station == null || !isProtected(station)) {
                for (DockStation parent : ignored) {
                  if (DockUtilities.isAncestor(parent, dockable)) {
                    return;
                  }
                }
                unregister(dockable);
              }
            }

            @Override
            public void handleDockStation(DockStation station) {
              if (isProtected(station)) {
                ignored.add(station);
              } else {
                unregister(station);
              }
            }
          });
    }
  }
コード例 #3
0
    private void checkDockable() {
      if (!onChange) {
        try {
          onChange = true;

          if (isSelected()) {
            DockController controller = dockable.getController();
            if (controller != null) {
              controller.setFocusedDockable(dockable, null, true, true, true);
            }
          } else {
            DockStation parent = this.parent;
            Dockable dockable = this.dockable;

            DockStation finalParent = StationChildrenActionSource.this.dockable.getDockParent();

            while (parent != null) {
              if (parent.getFrontDockable() == dockable) {
                parent.setFrontDockable(null);
              }
              if (parent == finalParent) {
                parent = null;
              } else {
                dockable = parent.asDockable();
                if (dockable != null) {
                  parent = dockable.getDockParent();
                } else {
                  parent = null;
                }
              }
            }
          }
        } finally {
          onChange = false;
        }
      }
    }
コード例 #4
0
 public void replace(DockStation old, Dockable next) {
   replace(old.asDockable(), next);
 }