Example #1
0
  private JLabel getComparedLabel(Object value, String metrics) {
    try {
      final CompareInfo info =
          AdjustHistory.getInstance()
              .compare(
                  new CompareObject(value, null, metrics) {
                    @Override
                    public Object getOriginalityValue(AnalysisResult result) {
                      if (this.getMetrics().equals(AnalysisResult.Metrics_TotalScore)) {
                        return result.getScore();
                      } else if (this.getMetrics().equals(AnalysisResult.Metrics_D)) {
                        return result.getDistance();
                      } else if (this.getMetrics().equals(AnalysisResult.Metrics_Balance)) {
                        return result.getBalance();
                      } else if (this.getMetrics()
                          .equals(AnalysisResult.Metrics_RelationRationality)) {
                        return result.getRelationRationality();
                      } else if (this.getMetrics().equals(AnalysisResult.Metrics_Encapsulation)) {
                        return result.getEncapsulation();
                      } else if (this.getMetrics().equals(AnalysisResult.Metrics_LC)) {
                        return result.getSummary().getLineCount();
                      } else if (this.getMetrics().equals(AnalysisResult.Metrics_CN)) {
                        return result.getSummary().getClassCount();
                      } else if (this.getMetrics().equals(AnalysisResult.Metrics_ComponentCount)) {
                        return result.getComponents().size();
                      } else if (this.getMetrics().equals(AnalysisResult.Metrics_RelationCount)) {
                        return result.getRelations().size();
                      } else if (this.getMetrics()
                          .equals(AnalysisResult.Metrics_RelationComponentScale)) {
                        return result.calRelationComponentScale();
                      } else if (this.getMetrics().equals(AnalysisResult.Metrics_Coupling)) {
                        return result.getSummary().getCoupling();
                      } else if (this.getMetrics().equals(AnalysisResult.Metrics_Cohesion)) {
                        return result.getSummary().getCohesion();
                      }
                      return null;
                    }
                  });

      if (info != null && info.isDiff()) {
        JLabel labelDirection =
            new JLabel() {
              @Override
              public String getToolTipText(MouseEvent e) {
                return "Originality:" + info.getOriginality();
              }
            };
        ToolTipManager.sharedInstance().registerComponent(labelDirection);
        CompareInfoWebWarpper warpper = new CompareInfoWebWarpper(info);
        labelDirection.setText(warpper.getCompare());
        labelDirection.setForeground(warpper.getDirectionColor());
        return labelDirection;
      } else {
        return null;
      }
    } catch (JDependException e1) {
      e1.printStackTrace();
      return null;
    }
  }
 public void registRelationType(JavaClassRelationType type) {
   try {
     service.registRelationType(type);
   } catch (JDependException e) {
     e.printStackTrace();
   }
 }
 public void registMetrics(String key, Metrics metrics) {
   try {
     service.registMetrics(key, metrics);
   } catch (JDependException e) {
     e.printStackTrace();
   }
 }
Example #4
0
 @Override
 protected void init(AnalysisResult result) {
   try {
     scorelist = ScoreFacade.getScoreList();
   } catch (JDependException e) {
     e.printStackTrace();
   }
   initComponents();
 }
  public UserActionListDialog(String username) {
    super();
    this.setLayout(new BorderLayout());

    getContentPane().setLayout(new BorderLayout());

    DefaultTableModel actionListModel =
        new DefaultTableModel() {
          @Override
          public boolean isCellEditable(int row, int column) {
            return false;
          }
        };

    TableSorter sorter = new TableSorter(actionListModel);

    JTable actionListTable = new JTable(sorter);

    sorter.setTableHeader(actionListTable.getTableHeader());

    actionListModel.addColumn("操作");
    actionListModel.addColumn("IP");
    actionListModel.addColumn("创建时间");
    actionListModel.addColumn("收集时间");

    try {
      Object[] row;
      for (UserActionItem item : new UserDomainService().getTheUserActions(username)) {
        row = new Object[4];
        row[0] = item.operation;
        row[1] = item.ip;
        row[2] = item.getCreatedate();
        row[3] = item.getGartherdate();

        actionListModel.addRow(row);
      }
    } catch (JDependException e) {
      e.printStackTrace();
    }

    this.add(BorderLayout.CENTER, new JScrollPane(actionListTable));

    JPanel buttonBar = new JPanel();
    buttonBar.add(createButton(BundleUtil.getString(BundleUtil.Command_Close)));

    this.add(BorderLayout.SOUTH, buttonBar);
  }
Example #6
0
  @Override
  public String getToolTipText(MouseEvent e) {

    ListModel model = this.getModel();

    int index = this.locationToIndex(e.getPoint());
    if (index >= 0) {
      String currentCommand = (String) model.getElementAt(index);
      try {
        return CommandAdapterMgr.getInstance().getCommands(this.group).get(currentCommand).getTip();
      } catch (JDependException e1) {
        e1.printStackTrace();
        frame.showStatusError(e1.getMessage());
        return null;
      }
    }
    return null;
  }
Example #7
0
  private JPanel createAdvisePanel(String itemName) {

    JPanel advisePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    advisePanel.setBackground(new java.awt.Color(255, 255, 255));

    WisdomAnalysisResult wisdomAnalysisResult = new WisdomAnalysisResult(result);

    JLabel adviseLabel = null;
    JLabel descLabel = null;
    if (itemName.equals(AnalysisResult.Metrics_TotalScore)) {
      adviseLabel = new JLabel();
      try {
        AdviseInfo advise =
            wisdomAnalysisResult.getAdvise(StructureCategory.LowScoreItemIdentifier);
        if (advise != null) {
          adviseLabel.setText(
              advise.getDesc() + ReportConstant.toMetricsName(advise.getComponentNameInfo()));
          advisePanel.add(adviseLabel);
        }
      } catch (JDependException e) {
        e.printStackTrace();
      }
    } else if (itemName.equals(AnalysisResult.Metrics_D)) {
      try {
        AdviseInfo advise = wisdomAnalysisResult.getAdvise(StructureCategory.DDomainAnalysis);
        if (advise != null) {
          descLabel = new JLabel();
          descLabel.setText(advise.getDesc());
          adviseLabel = new JLabel();
          adviseLabel.setFont(new java.awt.Font("宋体", 1, 15)); // NOI18N
          adviseLabel.setText(advise.getComponentNameInfo());
          JDependUIUtil.addClickTipEffect(adviseLabel);
          adviseLabel.addMouseListener(
              new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                  jdepend.model.Component component =
                      result.getTheComponent(((JLabel) evt.getSource()).getText());
                  ComponentDetailDialog d = new ComponentDetailDialog(component);
                  d.setModal(true);
                  d.setVisible(true);
                }
              });
          advisePanel.add(adviseLabel);
          advisePanel.add(descLabel);
        }
      } catch (JDependException e) {
        e.printStackTrace();
      }
    } else if (itemName.equals(AnalysisResult.Metrics_Balance)) {
      try {
        AdviseInfo advise =
            wisdomAnalysisResult.getAdvise(StructureCategory.CohesionDomainAnalysis);
        if (advise != null) {
          descLabel = new JLabel();
          descLabel.setText(advise.getDesc());
          adviseLabel = new JLabel();
          adviseLabel.setFont(new java.awt.Font("宋体", 1, 15)); // NOI18N
          adviseLabel.setText(advise.getComponentNameInfo());
          JDependUIUtil.addClickTipEffect(adviseLabel);
          adviseLabel.addMouseListener(
              new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                  jdepend.model.Component component =
                      result.getTheComponent(((JLabel) evt.getSource()).getText());
                  BalanceComponentDialog d = new BalanceComponentDialog(frame, component);
                  d.setModal(true);
                  d.setVisible(true);
                }
              });
          advisePanel.add(descLabel);
          advisePanel.add(adviseLabel);
        }
      } catch (JDependException e) {
        e.printStackTrace();
      }
    } else if (itemName.equals(AnalysisResult.Metrics_Encapsulation)) {
      try {
        final AdviseInfo advise =
            wisdomAnalysisResult.getAdvise(StructureCategory.EncapsulationDomainAnalysis);
        if (advise != null) {
          descLabel = new JLabel();
          descLabel.setText(advise.getDesc());
          adviseLabel = new JLabel();
          adviseLabel.setFont(new java.awt.Font("宋体", 1, 15)); // NOI18N
          adviseLabel.setText(advise.getComponentNameInfo());
          JDependUIUtil.addClickTipEffect(adviseLabel);
          adviseLabel.addMouseListener(
              new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                  jdepend.model.Component component =
                      result.getTheComponent(advise.getComponentNameInfo());
                  ClassListDialog d = new ClassListDialog(frame, component);
                  d.setModal(true);
                  d.setVisible(true);
                }
              });
          advisePanel.add(descLabel);
          advisePanel.add(adviseLabel);
        }
      } catch (JDependException e) {
        e.printStackTrace();
      }
    } else if (itemName.equals(AnalysisResult.Metrics_RelationRationality)) {
      Float rs = result.getAttentionRelationScale();
      adviseLabel = new JLabel();
      if (MathUtil.isZero(rs)) {
        adviseLabel.setText(BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_RelationNormal));
      } else {
        adviseLabel.setText(
            BundleUtil.getString(BundleUtil.Metrics_AttentionRelationScale)
                + ":"
                + MetricsFormat.toFormattedPercent(rs));
        JDependUIUtil.addClickTipEffect(adviseLabel);
        adviseLabel.addMouseListener(
            new java.awt.event.MouseAdapter() {
              public void mouseClicked(java.awt.event.MouseEvent evt) {
                frame.getResultPanel().setTab(1, 1);
              }
            });
      }
      advisePanel.add(adviseLabel);
    }

    return advisePanel;
  }
Example #8
0
  private JComponent createGraphScore() {
    GraphData graph = new GraphData();
    graph.setAddJScrollPane(false);

    GraphDataItem item = null;
    Map<Object, Object> datas = null;

    if (this.result.getDistance() != null) {
      item = new GraphDataItem();
      item.setTitle(BundleUtil.getString(BundleUtil.Metrics_D));
      item.setType(GraphDataItem.PIE);
      datas = new HashMap<Object, Object>();
      datas.put(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_Score),
          this.result.getDistance() / result.getDistanceScale());
      datas.put(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_ScoreDifference),
          1F - this.result.getDistance() / result.getDistanceScale());
      item.setDatas(datas);
      graph.addItem(item);
    }

    if (this.result.getBalance() != null) {
      item = new GraphDataItem();
      item.setTitle(BundleUtil.getString(BundleUtil.Metrics_Balance));
      item.setType(GraphDataItem.PIE);
      datas = new HashMap<Object, Object>();
      datas.put(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_Score),
          this.result.getBalance() / result.getBalanceScale());
      datas.put(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_ScoreDifference),
          1F - this.result.getBalance() / result.getBalanceScale());
      item.setDatas(datas);
      graph.addItem(item);
    }

    if (this.result.getEncapsulation() != null) {
      item = new GraphDataItem();
      item.setTitle(BundleUtil.getString(BundleUtil.Metrics_Encapsulation));
      item.setType(GraphDataItem.PIE);
      datas = new HashMap<Object, Object>();
      datas.put(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_Score),
          this.result.getEncapsulation() / result.getEncapsulationScale());
      datas.put(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_ScoreDifference),
          1F - this.result.getEncapsulation() / result.getEncapsulationScale());
      item.setDatas(datas);
      graph.addItem(item);
    }

    if (this.result.getRelationRationality() != null) {
      item = new GraphDataItem();
      item.setTitle(BundleUtil.getString(BundleUtil.Metrics_RelationRationality));
      item.setType(GraphDataItem.PIE);
      datas = new HashMap<Object, Object>();
      datas.put(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_Score),
          this.result.getRelationRationality() / result.getRelationRationalityScale());
      datas.put(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_ScoreDifference),
          1F - this.result.getRelationRationality() / result.getRelationRationalityScale());
      item.setDatas(datas);
      graph.addItem(item);
    }

    JPanel contentPanel = new JPanel(new BorderLayout());
    contentPanel.setBackground(new java.awt.Color(255, 255, 255));
    try {
      contentPanel.add(GraphUtil.createGraph(graph));
    } catch (JDependException e) {
      e.printStackTrace();
    }

    return contentPanel;
  }