예제 #1
0
  /**
   * Closes the view that shows <code>note</code>. Stores the location of the view in order to open
   * the view again at the same location.
   *
   * @param note the <code>Note</code> whose view should be closed
   */
  public void hide(Note note) {
    NoteView view = noteViews.remove(note);
    if (view != null) {
      DockStation root = DockUtilities.getRoot(view);
      DockableProperty location = DockUtilities.getPropertyChain(root, view);
      locations.put(note, new Tuple<DockStation, DockableProperty>(root, location));

      DockStation parent = view.getDockParent();
      parent.drag(view);
      view.setNote(null);
      focusedViews.remove(view);
    }
  }
예제 #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);
              }
            }
          });
    }
  }