/////////////////////////////////////////////////////////
 // Tablegroups
 private void onSelectAllTables() {
   for (JInternalFrame f : _desktopPane.getAllFrames()) {
     if (f instanceof TableFrame) {
       _desktopPane.addGroupFrame((TableFrame) f);
     }
   }
 }
 private void onEdgesGraphComponentChanged(EdgesGraphComponent edgesGraphComponent, boolean put) {
   if (put) {
     _desktopPane.putGraphComponents(new GraphComponent[] {edgesGraphComponent});
   } else {
     _desktopPane.removeGraphComponents(new GraphComponent[] {edgesGraphComponent});
   }
   _desktopPane.repaint();
 }
  public void removeConstraintViews(ConstraintView[] constraintViews, boolean keepFoldingPoints) {
    _desktopPane.removeGraphComponents(constraintViews);

    if (false == keepFoldingPoints) {
      for (int i = 0; i < constraintViews.length; i++) {
        constraintViews[i].removeAllFoldingPoints();
      }
    }
  }
  private void onSelectTablesByName() {
    String namePattern =
        JOptionPane.showInputDialog(
            _desktopPane,
            s_stringMgr.getString("graph.selectTablesByName.message"),
            s_stringMgr.getString("graph.selectTablesByName.title"),
            JOptionPane.QUESTION_MESSAGE);

    if (null == namePattern || 0 == namePattern.trim().length()) {
      return;
    }

    _desktopPane.clearGroupFrames();
    for (JInternalFrame f : _desktopPane.getAllFrames()) {
      if (f instanceof TableFrame) {
        TableFrame tf = (TableFrame) f;
        if (tf.getTitle().matches(namePattern.replace('?', '.').replace("*", ".*"))) {
          _desktopPane.addGroupFrame(tf);
        }
      }
    }
  }
  private ConstraintHitData findHit(MouseEvent e) {
    Vector<GraphComponent> graphComponents = _desktopPane.getGraphComponents();

    for (int i = 0; i < graphComponents.size(); i++) {
      GraphComponent graphComponent = graphComponents.elementAt(i);

      if (graphComponent instanceof ConstraintView) {
        ConstraintView constraintView = (ConstraintView) graphComponents.elementAt(i);
        ConstraintHit constraintHit = constraintView.hitMe(e);
        if (ConstraintHit.NONE != constraintHit) {
          return new ConstraintHitData(constraintView, constraintHit);
        }
      }
    }
    return new ConstraintHitData(null, ConstraintHit.NONE);
  }
  private void refreshSelection(ConstraintView hitOne, boolean allowDeselect) {
    if (allowDeselect) {
      hitOne.setSelected(!hitOne.isSelected());
    } else if (false == hitOne.isSelected()) {
      hitOne.setSelected(true);
    }

    Vector<GraphComponent> graphComponents = _desktopPane.getGraphComponents();

    for (int i = 0; i < graphComponents.size(); i++) {
      if (false == graphComponents.elementAt(i) instanceof ConstraintView) {
        continue;
      }

      ConstraintView constraintView = (ConstraintView) graphComponents.elementAt(i);
      if (false == constraintView.equals(hitOne)) {
        constraintView.setSelected(false);
      }
    }
  }
 public void addFrame(JInternalFrame frame) {
   _desktopPane.hideStartupImage();
   _desktopPane.add(frame);
 }
 public void repaint() {
   _desktopPane.repaint();
 }
  public GraphDesktopController(
      GraphDesktopListener listener,
      ISession session,
      GraphPlugin plugin,
      ModeManager modeManager,
      boolean showDndDesktopImageAtStartup) {
    _listener = listener;
    _session = session;
    _plugin = plugin;
    _graphPluginResources = new GraphPluginResources(_plugin);

    ImageIcon startUpImage = null;

    if (showDndDesktopImageAtStartup) {
      startUpImage = _graphPluginResources.getIcon(GraphPluginResources.IKeys.DND);
    }

    _desktopPane = new GraphDesktopPane(_session.getApplication(), startUpImage);
    _desktopPane.setBackground(Color.white);

    _modeManager = modeManager;

    DropTarget dt = new DropTarget();

    try {
      dt.addDropTargetListener(
          new DropTargetAdapter() {
            public void drop(DropTargetDropEvent dtde) {
              onTablesDroped(dtde);
            }
          });
    } catch (TooManyListenersException e) {
      throw new RuntimeException(e);
    }

    _desktopPane.setDropTarget(dt);

    _desktopPane.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            onMouseClicked(e);
          }

          public void mousePressed(MouseEvent e) {
            onMousePressed(e);
          }

          public void mouseReleased(MouseEvent e) {
            onMouseReleased(e);
          }
        });

    _desktopPane.addMouseMotionListener(
        new MouseMotionAdapter() {
          public void mouseDragged(MouseEvent e) {
            onMouseDragged(e);
          }
        });

    createPopUp();
  }
 /** It's called put because it adds unique, like a Hashtable. */
 public void putConstraintViews(ConstraintView[] constraintViews) {
   _desktopPane.putGraphComponents(constraintViews);
 }