Exemplo n.º 1
0
    /**
     * updateUI is overridden to set the colors of the Tree's renderer to match that of the table.
     */
    public void updateUI() {
      super.updateUI();

      // Make the tree's cell renderer use the table's cell selection
      // colors.
      TreeCellRenderer tcr = getCellRenderer();

      if (tcr instanceof DefaultTreeCellRenderer) {
        DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
        // For 1.1 uncomment this, 1.2 has a bug that will cause an
        // exception to be thrown if the border selection color is
        // null.
        // dtcr.setBorderSelectionColor(null);
        dtcr.setTextSelectionColor(UIManager.getColor("Table.selectionForeground"));
        dtcr.setBackgroundSelectionColor(UIManager.getColor("Table.selectionBackground"));
      }
    }
Exemplo n.º 2
0
  /**
   * The abstract function that descendant classes must be overridden to provide customsized
   * handling.
   *
   * @param e
   * @return true if the action is finished successfully; otherwise, return false.
   */
  protected boolean doAction(ActionEvent e) throws Exception {

    // System.out.println("Delete node clicked.......");
    if (treeNode == null) {
      // System.out.println("Tree node null returning.......");
      return false;
    }

    DefaultEdge[] linkEdge = null;
    DefaultEdge linkEdgeTemp = null;
    DefaultPort[] srcPort = null;
    DefaultPort srcPortTemp = null;
    DefaultPort[] tgtPort = null;
    DefaultPort tgtPortTemp = null;
    for (Object child : MainFrame.getMappingMainPanel().getMiddlePanel().getGraph().getRoots()) {
      if (child instanceof DefaultEdge) {
        linkEdge = new DefaultEdge[2];
        srcPort = new DefaultPort[1];
        tgtPort = new DefaultPort[1];
        linkEdgeTemp = (DefaultEdge) child;
        // linkEdge[0] = linkEdgeTemp;
        srcPortTemp = (DefaultPort) linkEdgeTemp.getSource();
        srcPort[0] = srcPortTemp;
        tgtPortTemp = (DefaultPort) linkEdgeTemp.getTarget();
        tgtPort[0] = tgtPortTemp;
        Iterator edges = srcPortTemp.getEdges().iterator();
        int i = 0;
        while (edges.hasNext()) {
          linkEdge[i] = (DefaultEdge) edges.next();
          i++;
        }

        Object sourceNode = srcPortTemp.getUserObject();
        if (sourceNode instanceof DefaultMutableTreeNode) {
          DefaultMutableTreeNode srcTreeNode = (DefaultMutableTreeNode) sourceNode;
          if (srcTreeNode.getParent().equals(treeNode)) {

            MainFrame.getMappingMainPanel()
                .getMiddlePanel()
                .getGraphController()
                .removeCells(linkEdge, true);
            // MainFrame.getMappingMainPanel().getMiddlePanel().getGraphController().removeCells(tgtPort,true);
            MainFrame.getMappingMainPanel().getTargetScrollPane().repaint();
          }
        }
      }
    }
    // System.out.println("Before Tree node removal.......");
    if (treeNode.getParent() != null) {
      treeNode.removeFromParent();
    } else {
      tree.removeAll();
    }
    // remove the resource from the list
    MainFrame.getMappingMainPanel().getPOJOClassList().remove(treeNode.toString());
    // System.out.println("TREENODE STR..."+treeNode.toString());
    //
    tree.updateUI();
    //
    if (MainFrame.getMappingMainPanel().getMappingTargetFile() != null) {
      Mapping mappingData =
          MainFrame.getMappingMainPanel()
              .getMiddlePanel()
              .getGraphController()
              .retrieveMappingData(true, "Temp");
      if (mappingData != null) {
        MainFrame.getMappingMainPanel()
            .getMiddlePanel()
            .getGraphController()
            .setMappingData(mappingData, true);
        MainFrame.getMappingMainPanel().getMiddlePanel().setMappingNamesforLinkInGraph(mappingData);
      }
    }
    return true;
  }