Ejemplo n.º 1
0
 /** {@inheritDoc} */
 @Override
 public void dockingComplete(DockingEvent evt) {
   super.dockingComplete(evt);
   changeToolBar();
 }
Ejemplo n.º 2
0
 /** {@inheritDoc} */
 @Override
 public void undockingComplete(DockingEvent evt) {
   super.undockingComplete(evt);
   addToolBar(null);
 }
Ejemplo n.º 3
0
  /**
   * Handling docking complete events
   *
   * @param e the event
   * @see
   *     org.flexdock.docking.event.DockingListener#dockingCanceled(org.flexdock.docking.event.DockingEvent)
   */
  public void dockingComplete(DockingEvent e) {
    debug("dockingComplete");
    String newId = null;

    DockingListener[] newListeners = e.getNewDockingPort().getDockingListeners();
    SwingScilabTab dockedTab = (SwingScilabTab) e.getDockable();
    if (newListeners.length == 2) {
      /* This docking port has been created when the parent window were created */
      /* So this docking port has a sciDockingListener */
      newId = ((SciDockingListener) newListeners[1]).getAssociatedWindowId();
    } else {
        /* Docking port created by Flexdock itself */
      /* Retrieve the ID of the parent window */
      Set<Dockable> allDockables = e.getNewDockingPort().getDockables();
      /* Have to find an other dockable than the one we just docked */
      Iterator<Dockable> it = allDockables.iterator();
      Dockable dock = it.next();

      if (it.hasNext()) {
          /** More than one dockable --> already existing docking port */
        while (e.getDockable() == dock) {
          dock = it.next();
        }
        newId = ((SwingScilabTab) dock).getParentWindowId();
      } else {
          /** Create a new Window to display the tab inside it */

        DefaultDockingPort dockingPort = ((DefaultDockingPort) e.getOldDockingPort());
        JPanel parentPanel = (JPanel) dockingPort.getParent();
        JLayeredPane parentLayeredPane = (JLayeredPane) parentPanel.getParent();
        JRootPane parentRootPane = (JRootPane) parentLayeredPane.getParent();

        /* Computes new position for the created Window */
        int offsetX =
            dockingPort.getX()
                + parentPanel.getX()
                + parentLayeredPane.getX()
                + parentRootPane.getX();
        int offsetY =
            dockingPort.getY()
                + parentPanel.getY()
                + parentLayeredPane.getY()
                + parentRootPane.getY();
        int newX = -offsetX;
        int newY = -offsetY;
        if (e.getNewDockingPort() instanceof FloatingDockingPort) {
          newX +=
              ((FloatingDockingPort) e.getNewDockingPort())
                  .getParent()
                  .getParent()
                  .getParent()
                  .getX();
          newY +=
              ((FloatingDockingPort) e.getNewDockingPort())
                  .getParent()
                  .getParent()
                  .getParent()
                  .getY();
        } else {
          newX +=
              ((DefaultDockingPort) e.getNewDockingPort())
                  .getParent()
                  .getParent()
                  .getParent()
                  .getX();
          newY +=
              ((DefaultDockingPort) e.getNewDockingPort())
                  .getParent()
                  .getParent()
                  .getParent()
                  .getY();
        }

        SwingScilabWindow newWindow = new SwingScilabWindow();
        newWindow.setPosition(new Position(newX, newY));
        newWindow.setDims(
            SwingScilabWindow.allScilabWindows.get(associatedScilabWindowId).getDims());
        DockingManager.dock(dockedTab, newWindow.getDockingPort());
        newWindow.setVisible(true);
        newId = newWindow.getId();
      }
    }
    dockedTab.setParentWindowId(newId);
    dockedTab.requestFocus();
  }