/**
   * Gets the text which should be used in the title.
   *
   * @return the text, might be <code>null</code>
   */
  protected String getTitleText() {
    if (titleText != null) return titleText;

    Dockable dockable = getDockable();
    if (dockable == null) return null;

    return dockable.getTitleText();
  }
  /**
   * Gets the icon which should be used in the title.
   *
   * @return the icon
   */
  protected Icon getTitleIcon() {
    if (titleIcon != null) return titleIcon;

    Dockable dockable = getDockable();
    if (dockable == null) return null;

    return dockable.getTitleIcon();
  }
 /**
  * Tells which children to show and which not. This method is called with all children (direct and
  * indirect) of the station. The default behavior is to return <code>true</code> for any direct
  * child or <code>true</code> if the monitored dockable is no station at all.
  *
  * @param dockable the child to check
  * @return <code>true</code> if there should be a button, <code>false</code> otherwise
  */
 protected boolean shouldShow(Dockable dockable) {
   if (dockable.getDockParent() == getDockable().asDockStation()) {
     return true;
   }
   if (dockable == getDockable() && dockable.asDockStation() == null) {
     return true;
   }
   return false;
 }
  /**
   * 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()]);
  }
  @Override
  public void setDockable(Dockable dockable) {
    Dockable old = getDockable();
    if (old != null) {
      old.removeDockableListener(listener);
    }

    super.setDockable(dockable);

    if (dockable != null) {
      dockable.addDockableListener(listener);
    }

    updateTitleIcon();
    updateTitleText();
  }
  /**
   * Unregisters <code>dockable</code>, the associated controller will no longer support drag and
   * drop for <code>dockable</code>.<br>
   * Clients and subclasses should not call this method.
   *
   * @param dockable the element to remove
   */
  protected void unregister(Dockable dockable) {
    if (dockables.remove(dockable)) {
      dockable.setController(null);

      fireDockableUnregistered(dockable);
    }
  }
 public void titleTextChanged(Dockable dockable, String oldTitle, String newTitle) {
   setText(newTitle);
   String tooltip = dockable.getTitleToolTip();
   if (tooltip == null || tooltip.length() == 0) {
     setTooltip(newTitle);
   }
 }
    @Override
    public void dockableRemoved(DockStation station, Dockable dockable) {
      if (dockable.getDockParent() != null && dockable.getDockParent() != station) {
        throw new IllegalStateException(
            "the parent of dockable is wrong: it is neither null nor '" + station + "'");
      }
      dockable.setDockParent(null);

      DockStation asStation = dockable.asDockStation();
      if (asStation != null) {
        asStation.removeDockStationListener(StationListener.this);
      }

      if (stalled == 0) {
        removeDockable(dockable);
      }
    }
    /**
     * Adds a Dockable either as station or as pure Dockable to this controller.
     *
     * @param dockable the Dockable to register
     * @param requiresListener whether the listener of this {@link DockRegister} has to be added to
     *     the {@link DockStation} <code>dockable</code> or not
     */
    private void addDockable(Dockable dockable, boolean requiresListener) {
      DockStation asStation = dockable.asDockStation();

      if (asStation != null) {
        add(asStation, requiresListener);
      } else {
        register(dockable);
      }
    }
 public void remove(Dockable dockable) {
   DockStation station = dockable.asDockStation();
   if (station != null) {
     station.removeDockStationListener(this);
     for (int i = 0, n = station.getDockableCount(); i < n; i++) {
       remove(station.getDockable(i));
     }
   }
 }
Beispiel #11
0
  /**
   * Registers <code>dockable</code>, the associated controller will know the titles of <code>
   * dockable</code> to allow drag and drop operations.<br>
   * Clients and subclasses should not call this method.
   *
   * @param dockable a new Dockable
   */
  protected void register(Dockable dockable) {
    if (!dockables.contains(dockable)) {
      fireDockableRegistering(dockable);

      dockables.add(dockable);
      dockable.setController(controller);

      fireDockableRegistered(dockable);
    }
  }
 private void fill(Dockable dockable, List<Dockable> list) {
   if (shouldShow(dockable)) {
     list.add(dockable);
   }
   DockStation station = dockable.asDockStation();
   if (station != null) {
     for (int i = 0, n = station.getDockableCount(); i < n; i++) {
       fill(station.getDockable(i), list);
     }
   }
 }
Beispiel #13
0
    /**
     * Removes a Dockable either as station or as pure Dockable from this controller.
     *
     * @param dockable the Dockable to unregister
     */
    private void removeDockable(Dockable dockable) {
      DockStation asStation = dockable.asDockStation();

      if (asStation != null) {
        if (!isProtected(asStation)) {
          remove(asStation);
        }
      } else {
        unregister(dockable);
      }
    }
 public void hierarchyChanged(DockHierarchyEvent event) {
   if (bound > 0) {
     if (parent != null) {
       parent.removeDockStationListener(adapter);
     }
     parent = dockable.getDockParent();
     if (parent != null) {
       parent.addDockStationListener(adapter);
     }
     checkState();
   }
 }
  @Override
  public void action(Dockable dockable) {
    super.action(dockable);

    String title =
        JOptionPane.showInputDialog(
            dockable.getComponent(),
            "Please enter new title of note",
            "Change title",
            JOptionPane.PLAIN_MESSAGE);

    if (title != null) TitleAction.this.note.setTitle(title);
  }
Beispiel #16
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);
              }
            }
          });
    }
  }
    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;
        }
      }
    }
    private void checkState() {
      if (!onChange) {
        try {
          onChange = true;

          DockStation parent = dockable.getDockParent();
          boolean select = false;

          if (parent != null) {
            select = parent.isChildShowing(dockable) && parent.getFrontDockable() == dockable;
          }

          setSelected(select);
        } finally {
          onChange = false;
        }
      }
    }
 public boolean react(Dockable dockable) {
   return dockable.asDockStation() != null;
 }
 public void titleToolTipChanged(Dockable dockable, String oldToolTip, String newToolTip) {
   setTooltip(newToolTip);
   if (newToolTip == null || newToolTip.length() == 0) {
     setTooltip(dockable.getTitleText());
   }
 }