コード例 #1
0
  private void updateNodePos() {

    for (int i = 0; i < nodeData.size(); i++) {

      int oldIndex = ((Integer) sorter.getValueAt(i, 0)).intValue();
      sorter.setValueAt(new Integer(i), i, 0);

      if (oldIndex <= nodeData.size()) {
        NodePosition np = ((NodePosition) nodeData.elementAt(oldIndex));
        if (np != null) {
          try {
            view.setNodePosition(np.getNode().getId(), new Point(np.getXPos(), (i + 1) * 10));
            np.setYPos((i + 1) * 10);
          } catch (Exception ex) {
            log.error("Error...", ex);
            log.info("Error: Unable to update position " + ex.getMessage()); // $NON-NLS-1$
          }
        }
      }
    }
  }
コード例 #2
0
  public void constructTableData() {

    Vector vtTemp = new Vector();
    nodeData.removeAllElements();

    for (Enumeration e = view.getPositions(); e.hasMoreElements(); ) {
      NodePosition nodePos = (NodePosition) e.nextElement();
      vtTemp.addElement(nodePos);
      nodeData.addElement(nodePos);
    }

    for (Enumeration e = vtTemp.elements(); e.hasMoreElements(); ) {
      NodePosition nodePos = (NodePosition) e.nextElement();
      NodeSummary node = nodePos.getNode();
      int index = nodePos.getYPos() / 10;
      index--;
      if (index < nodeData.size()) {
        nodeData.removeElementAt(index);
        nodeData.insertElementAt(nodePos, index);
      }
    }
  }
コード例 #3
0
  public void setValueAt(Object o, int row, int col) {

    String sAuthor = ProjectCompendium.APP.getModel().getUserProfile().getUserName();

    NodePosition np = (NodePosition) nodeData.elementAt(row);
    NodeSummary node = np.getNode();
    switch (col) {
      case ListTableModel.NUMBER_COLUMN:
        {
          if (o instanceof Integer) np.setYPos((((Integer) o).intValue() + 1) * 10);
          break;
        }
      case ListTableModel.LABEL_COLUMN:
        {
          String oldLabel = node.getLabel();
          String newLabel = (String) o;
          if (!oldLabel.equals(newLabel)) {
            try {
              node.setLabel(newLabel, sAuthor);
            } catch (Exception ex) {
              ProjectCompendium.APP.displayError(
                  "Error: (ListTableModel.setValueAt)\n\n"
                      + //$NON-NLS-1$
                      LanguageProperties.getString(
                          LanguageProperties.UI_GENERAL_BUNDLE, "ListTableModel.errorLabel")
                      + //$NON-NLS-1$
                      ": "
                      + oldLabel
                      + "\n\n"
                      + ex.getMessage()); // $NON-NLS-1$ //$NON-NLS-2$
            }
          }
          break;
        }
    }
  }
コード例 #4
0
  public Object getValueAt(int row, int col) {

    if (nodeData == null) {
      return null;
    }
    if (row >= nodeData.size()) {
      return null;
    }

    NodePosition np = (NodePosition) nodeData.elementAt(row);
    if (np != null) {
      NodeSummary node = np.getNode();
      if (node != null) {
        switch (col) {
          case ListTableModel.NUMBER_COLUMN:
            {
              return new Integer(row);
            }
          case ListTableModel.IMAGE_COLUMN:
            {
              if (node.getType() == ICoreConstants.REFERENCE) {
                return UINode.getReferenceImageSmall(node.getSource());
              } else {
                return UINode.getNodeImageSmall(node.getType());
              }
            }
          case ListTableModel.TAGS_COLUMN:
            {
              if (node.getCodeCount() > 0) {
                return "T"; //$NON-NLS-1$
              } else {
                return ""; //$NON-NLS-1$
              }
            }
          case ListTableModel.VIEWS_COLUMN:
            {
              int count = node.getViewCount();
              if (count == 0) {
                node.updateMultipleViews();
                count = node.getViewCount();
              }
              return new Integer(count);
            }
          case ListTableModel.DETAIL_COLUMN:
            {
              String sDetail = node.getDetail();
              sDetail = sDetail.trim();
              if (!sDetail.equals("")
                  && !sDetail.equals(ICoreConstants.NODETAIL_STRING)) { // $NON-NLS-1$
                return "*"; //$NON-NLS-1$
              } else {
                return ""; //$NON-NLS-1$
              }
            }
          case ListTableModel.WEIGHT_COLUMN:
            {
              if (node instanceof View) {
                View view = (View) node;
                int count = 0;
                try {
                  count = view.getNodeCount();
                } catch (Exception e) {
                }
                return new Integer(count);
              }
              return null;
            }
          case ListTableModel.LABEL_COLUMN:
            {
              return node.getLabel();
            }
          case ListTableModel.CREATION_DATE_COLUMN:
            {
              return node.getCreationDate();
            }
          case ListTableModel.MODIFICATION_DATE_COLUMN:
            {
              return node.getModificationDate();
            }
          case ListTableModel.ID_COLUMN:
            {
              return node.getId();
            }
          case ListTableModel.AUTHOR_COLUMN:
            {
              return node.getAuthor();
            }
          default:
            return null;
        }
      }
    }

    return null;
  }