Example #1
0
  @RequiresPermissions("admin:view")
  @RequestMapping(value = "/result/{id}/view", method = RequestMethod.GET)
  public String view(Model model, @PathVariable String id, HttpServletRequest request)
      throws JDependException {

    AnalysisResult result = AnalysisResultRepository.getInstance().getResult(id);

    WebAnalysisResult webResult = new WebAnalysisResult(result);
    model.addAttribute("result", webResult);
    request.getSession().setAttribute(WebConstants.SESSION_RESULT, webResult);

    TODOListIdentifyerFacade identify = new TODOListIdentifyerFacade();
    List<TODOItem> todoList = identify.identify(result);
    model.addAttribute("todoList", todoList);

    List<TableViewInfo> tableInfos = TableViewUtil.view(result);
    model.addAttribute("tableList", tableInfos);

    RelationGraphData relationGraphData = WebRelationGraphUtil.getGraphData(result.getRelations());
    model.addAttribute("relation_graph_data", relationGraphData);

    return "result";
  }
Example #2
0
  /**
   * 左侧分数面板
   *
   * @return
   */
  private JComponent createLeftPanel() {

    JPanel leftPanel = new JPanel(new BorderLayout());
    leftPanel.setBackground(new java.awt.Color(255, 255, 255));
    leftPanel.add(
        BorderLayout.NORTH, this.createItem(AnalysisResult.Metrics_TotalScore, result.getScore()));

    JPanel otherPanel = new JPanel(new BorderLayout());
    otherPanel.setBackground(new java.awt.Color(255, 255, 255));
    JPanel descPanel = new JPanel(new GridLayout(8, 1));
    descPanel.setBackground(new java.awt.Color(255, 255, 255));
    JPanel panel = null;
    JLabel valuePanel = null;
    JLabel itemCompareLabel = null;

    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel.setBackground(new java.awt.Color(255, 255, 255));
    JLabel ruleLabel = new JLabel("使用的规则");
    panel.add(ruleLabel);
    JDependUIUtil.addClickTipEffect(ruleLabel);
    ruleLabel.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(java.awt.event.MouseEvent evt) {
            CurrentProfileSettingDialog d = new CurrentProfileSettingDialog(frame);
            d.setModal(true);
            d.setVisible(true);
          }
        });
    descPanel.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel.setBackground(new java.awt.Color(255, 255, 255));
    panel.add(new JLabel(BundleUtil.getString(BundleUtil.Metrics_LC) + ":"));
    panel.add(new JLabel("" + result.getSummary().getLineCount()));
    itemCompareLabel =
        this.getComparedLabel(result.getSummary().getLineCount(), AnalysisResult.Metrics_LC);
    if (itemCompareLabel != null) {
      panel.add(itemCompareLabel);
    }
    descPanel.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel.setBackground(new java.awt.Color(255, 255, 255));
    panel.add(new JLabel(BundleUtil.getString(BundleUtil.Metrics_CN) + ":"));
    valuePanel = new JLabel("" + result.getSummary().getClassCount());
    JDependUIUtil.addClickTipEffect(valuePanel);
    valuePanel.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(java.awt.event.MouseEvent evt) {
            frame.getResultPanel().setTab(2, 0);
          }
        });
    panel.add(valuePanel);
    itemCompareLabel =
        this.getComparedLabel(result.getSummary().getClassCount(), AnalysisResult.Metrics_CN);
    if (itemCompareLabel != null) {
      panel.add(itemCompareLabel);
    }
    descPanel.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel.setBackground(new java.awt.Color(255, 255, 255));
    panel.add(new JLabel(BundleUtil.getString(BundleUtil.Metrics_ComponentCount) + ":"));
    valuePanel = new JLabel("" + result.getComponents().size());
    JDependUIUtil.addClickTipEffect(valuePanel);
    valuePanel.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(java.awt.event.MouseEvent evt) {
            frame.getResultPanel().setTab(1, 0);
          }
        });
    panel.add(valuePanel);
    itemCompareLabel =
        this.getComparedLabel(result.getComponents().size(), AnalysisResult.Metrics_ComponentCount);
    if (itemCompareLabel != null) {
      panel.add(itemCompareLabel);
    }
    descPanel.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel.setBackground(new java.awt.Color(255, 255, 255));
    panel.add(new JLabel(BundleUtil.getString(BundleUtil.Metrics_RelationCount) + ":"));
    valuePanel = new JLabel("" + result.getRelations().size());
    JDependUIUtil.addClickTipEffect(valuePanel);
    valuePanel.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(java.awt.event.MouseEvent evt) {
            frame.getResultPanel().setTab(1, 1);
          }
        });
    panel.add(valuePanel);
    itemCompareLabel =
        this.getComparedLabel(result.getRelations().size(), AnalysisResult.Metrics_RelationCount);
    if (itemCompareLabel != null) {
      panel.add(itemCompareLabel);
    }
    descPanel.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel.setBackground(new java.awt.Color(255, 255, 255));
    panel.add(new JLabel(BundleUtil.getString(BundleUtil.Metrics_RelationComponentScale) + ":"));
    panel.add(new JLabel("" + result.calRelationComponentScale()));
    itemCompareLabel =
        this.getComparedLabel(
            result.calRelationComponentScale(), AnalysisResult.Metrics_RelationComponentScale);
    if (itemCompareLabel != null) {
      panel.add(itemCompareLabel);
    }
    descPanel.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel.setBackground(new java.awt.Color(255, 255, 255));
    panel.add(new JLabel(BundleUtil.getString(BundleUtil.Metrics_Coupling) + ":"));
    valuePanel = new JLabel("" + result.getSummary().getCoupling());
    JDependUIUtil.addClickTipEffect(valuePanel);
    valuePanel.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(java.awt.event.MouseEvent evt) {
            CouplingDialog d = new CouplingDialog();
            d.setModal(true);
            d.setVisible(true);
          }
        });
    panel.add(valuePanel);
    itemCompareLabel =
        this.getComparedLabel(result.getSummary().getCoupling(), AnalysisResult.Metrics_Coupling);
    if (itemCompareLabel != null) {
      panel.add(itemCompareLabel);
    }
    descPanel.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel.setBackground(new java.awt.Color(255, 255, 255));
    panel.add(new JLabel(BundleUtil.getString(BundleUtil.Metrics_Cohesion) + ":"));
    valuePanel = new JLabel("" + result.getSummary().getCohesion());
    JDependUIUtil.addClickTipEffect(valuePanel);
    valuePanel.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(java.awt.event.MouseEvent evt) {
            CohesionDialog d = new CohesionDialog();
            d.setModal(true);
            d.setVisible(true);
          }
        });
    panel.add(valuePanel);
    itemCompareLabel =
        this.getComparedLabel(result.getSummary().getCohesion(), AnalysisResult.Metrics_Cohesion);
    if (itemCompareLabel != null) {
      panel.add(itemCompareLabel);
    }
    descPanel.add(panel);

    otherPanel.add(BorderLayout.SOUTH, descPanel);

    Map<String, String> diffElements = result.getDiffElements();
    if (diffElements != null && diffElements.size() > 0) {
      JPanel tipPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
      tipPanel.setBackground(new java.awt.Color(255, 255, 255));
      tipPanel.add(
          new JLabel(BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_ElementChangeTip)));
      JLabel tipClickLabel =
          new JLabel(BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_ElementChangeTip_This));
      JDependUIUtil.addClickTipEffect(tipClickLabel);
      tipClickLabel.addMouseListener(
          new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
              ChangedElementListDialog d = new ChangedElementListDialog(frame);
              d.setModal(true);
              d.setVisible(true);
            }
          });
      tipPanel.add(tipClickLabel);
      otherPanel.add(BorderLayout.NORTH, tipPanel);
    }

    JPanel contentpanel = new JPanel(new GridLayout(1, 2));
    contentpanel.add(otherPanel);
    contentpanel.add(this.createGraphScore());

    leftPanel.add(BorderLayout.CENTER, contentpanel);

    return leftPanel;
  }