Exemple #1
0
  private JPanel createWorkspacePanel() {

    JPanel workspacePanel = new JPanel(new GridLayout(1, 2));
    workspacePanel.setBackground(new java.awt.Color(255, 255, 255));

    JPanel leftPanel = new JPanel(new BorderLayout());

    JPanel scorePanel = new JPanel(new BorderLayout());
    scorePanel.setBorder(
        new TitledBorder(BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_TotalScore)));
    scorePanel.setBackground(new java.awt.Color(255, 255, 255));

    scorePanel.add(this.createLeftPanel());

    leftPanel.add(BorderLayout.CENTER, scorePanel);

    workspacePanel.add(leftPanel);

    JPanel subitemPanel = new JPanel(new GridLayout(4, 1));
    subitemPanel.setBackground(new java.awt.Color(255, 255, 255));

    JPanel dPanel = new JPanel(new BorderLayout());
    dPanel.setBorder(new TitledBorder(BundleUtil.getString(BundleUtil.Metrics_D)));
    dPanel.setBackground(new java.awt.Color(255, 255, 255));
    dPanel.add(this.createItem(AnalysisResult.Metrics_D, result.getDistance()));

    subitemPanel.add(dPanel);

    JPanel balancePanel = new JPanel(new BorderLayout());
    balancePanel.setBorder(new TitledBorder(BundleUtil.getString(BundleUtil.Metrics_Balance)));
    balancePanel.setBackground(new java.awt.Color(255, 255, 255));
    balancePanel.add(this.createItem(AnalysisResult.Metrics_Balance, result.getBalance()));

    subitemPanel.add(balancePanel);

    JPanel encapsulationPanel = new JPanel(new BorderLayout());
    encapsulationPanel.setBorder(
        new TitledBorder(BundleUtil.getString(BundleUtil.Metrics_Encapsulation)));
    encapsulationPanel.setBackground(new java.awt.Color(255, 255, 255));
    encapsulationPanel.add(
        this.createItem(AnalysisResult.Metrics_Encapsulation, result.getEncapsulation()));

    subitemPanel.add(encapsulationPanel);

    JPanel relationRationalityPanel = new JPanel(new BorderLayout());
    relationRationalityPanel.setBorder(
        new TitledBorder(BundleUtil.getString(BundleUtil.Metrics_RelationRationality)));
    relationRationalityPanel.setBackground(new java.awt.Color(255, 255, 255));
    relationRationalityPanel.add(
        this.createItem(
            AnalysisResult.Metrics_RelationRationality, result.getRelationRationality()));

    subitemPanel.add(relationRationalityPanel);

    workspacePanel.add(subitemPanel);

    return workspacePanel;
  }
  @Override
  protected JPopupMenu getPopupMenu() {
    JPopupMenu popupMenu = super.getPopupMenu();

    popupMenu.addSeparator();

    JMenuItem uploadItem = new JMenuItem(BundleUtil.getString(BundleUtil.Command_Upload));
    uploadItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              upload();
              JOptionPane.showMessageDialog(frame, "上传成功", "alert", JOptionPane.ERROR_MESSAGE);
            } catch (Exception e1) {
              e1.printStackTrace();
              JOptionPane.showMessageDialog(
                  frame, e1.getMessage(), "alert", JOptionPane.ERROR_MESSAGE);
            }
          }
        });
    popupMenu.add(uploadItem);

    JMenuItem downloadItem = new JMenuItem(BundleUtil.getString(BundleUtil.Command_Download));
    downloadItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              download();
            } catch (Exception e1) {
              e1.printStackTrace();
              JOptionPane.showMessageDialog(
                  frame, e1.getMessage(), "alert", JOptionPane.ERROR_MESSAGE);
            }
          }
        });
    popupMenu.add(downloadItem);

    JMenuItem deleteItem = new JMenuItem(BundleUtil.getString(BundleUtil.Command_Delete));
    deleteItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              if (JOptionPane.showConfirmDialog(frame, "您是否确认删除?", "提示", JOptionPane.YES_NO_OPTION)
                  == 0) {
                delete();
              }
            } catch (Exception e1) {
              e1.printStackTrace();
              JOptionPane.showMessageDialog(
                  frame, e1.getMessage(), "alert", JOptionPane.ERROR_MESSAGE);
            }
          }
        });
    popupMenu.add(deleteItem);

    return popupMenu;
  }
Exemple #3
0
  private JTable initSessionList() {

    final JPopupMenu popupMenu = new JPopupMenu();
    JMenuItem removeItem = new JMenuItem(BundleUtil.getString(BundleUtil.Command_Delete));
    removeItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            remove();
          }
        });
    popupMenu.add(removeItem);

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

    TableSorter sorter = new TableSorter(sessionListModel);

    JTable sessionsTable = new JTable(sorter);

    sessionsTable.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            JTable table = (JTable) e.getSource();
            int currentRow = table.rowAtPoint(e.getPoint());
            if (currentRow >= 0) {
              table.setRowSelectionInterval(currentRow, currentRow);
            }
          }

          @Override
          public void mousePressed(MouseEvent e) {
            JTable table = (JTable) e.getSource();
            int currentRow = table.rowAtPoint(e.getPoint());
            if (currentRow >= 0) {
              table.setRowSelectionInterval(currentRow, currentRow);
            }
            currentSession = (Long) table.getValueAt(table.rowAtPoint(e.getPoint()), 0);
            if (e.getButton() == 3) {
              popupMenu.show(table, e.getX(), e.getY());
            }
          }
        });

    sorter.setTableHeader(sessionsTable.getTableHeader());

    sessionListModel.addColumn("会话ID");
    sessionListModel.addColumn("用户名");
    sessionListModel.addColumn("IP地址");
    sessionListModel.addColumn("创建时间");
    sessionListModel.addColumn("操作");
    sessionListModel.addColumn("注销时间");

    return sessionsTable;
  }
Exemple #4
0
  public ResultTab(JDependCooper frame) {
    super(frame, true, true, CooperTabbedPane.Workspace);

    this.popupMenu = new JPopupMenu();
    JMenuItem closeItem = new JMenuItem(BundleUtil.getString(BundleUtil.Command_Close));
    closeItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            closeSelf(e);
          }
        });
    popupMenu.add(closeItem);

    JMenuItem closeOthersItem = new JMenuItem("关闭其它");
    closeOthersItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            closeOthers();
          }
        });
    popupMenu.add(closeOthersItem);

    JMenuItem closeAllItem = new JMenuItem("关闭所有");
    closeAllItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            closeAll();
          }
        });
    popupMenu.add(closeAllItem);
  }
  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);
  }
Exemple #6
0
  private JPanel createScope(
      final Float lScore, final String lScoreId, final Float hScore, final String hScoreId) {
    JPanel scoreScope = new JPanel();
    FlowLayout flowLayout = new FlowLayout();
    flowLayout.setAlignment(FlowLayout.RIGHT);
    scoreScope.setLayout(flowLayout);
    scoreScope.setBackground(new java.awt.Color(255, 255, 255));
    JLabel scopeTitle =
        new JLabel(BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_ExistingScoreScope) + ":");
    scopeTitle.setForeground(new java.awt.Color(204, 204, 204));
    scoreScope.add(scopeTitle);
    JLabel lScoreJLablel = new JLabel(String.valueOf(lScore));
    lScoreJLablel.setForeground(new java.awt.Color(204, 204, 204));
    lScoreJLablel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    scoreScope.add(lScoreJLablel);
    lScoreJLablel.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(java.awt.event.MouseEvent evt) {
            try {
              scoreScopeMouseClicked(lScoreId);
            } catch (JDependException e) {
              frame.getResultPanel().showError(e);
            }
          }
        });
    JLabel interval = new JLabel("~");
    interval.setForeground(new java.awt.Color(204, 204, 204));
    scoreScope.add(interval);
    JLabel hScoreJLablel = new JLabel(String.valueOf(hScore));
    hScoreJLablel.setForeground(new java.awt.Color(204, 204, 204));
    hScoreJLablel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    hScoreJLablel.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(java.awt.event.MouseEvent evt) {
            try {
              scoreScopeMouseClicked(hScoreId);
            } catch (JDependException e) {
              frame.getResultPanel().showError(e);
            }
          }
        });
    scoreScope.add(hScoreJLablel);

    return scoreScope;
  }
  @Override
  protected JPopupMenu getPopupMenu1() {
    JPopupMenu popupMenu1 = super.getPopupMenu1();
    JMenuItem downloadItem1 = new JMenuItem(BundleUtil.getString(BundleUtil.Command_Download));
    downloadItem1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              download();
            } catch (Exception e1) {
              e1.printStackTrace();
              JOptionPane.showMessageDialog(
                  frame, e1.getMessage(), "alert", JOptionPane.ERROR_MESSAGE);
            }
          }
        });
    popupMenu1.add(downloadItem1);

    return popupMenu1;
  }
Exemple #8
0
  private JComponent createTitleInfo() {

    JPanel content = new JPanel(new BorderLayout());
    content.setBackground(new java.awt.Color(255, 255, 255));

    JLabel executeInfo = new JLabel();

    executeInfo.setFont(new java.awt.Font("宋体", 0, 10));
    executeInfo.setForeground(new java.awt.Color(204, 204, 204));
    executeInfo.setText(
        BundleUtil.getString(BundleUtil.Analysis_Time)
            + ":"
            + this.result.getRunningContext().getAnalyseDate()
            + " V"
            + VersionUtil.getVersion()
            + " BuildDate:"
            + VersionUtil.getBuildDate()
            + " Group:"
            + this.result.getRunningContext().getGroup()
            + " Command:"
            + this.result.getRunningContext().getCommand());

    content.add(BorderLayout.WEST, executeInfo);

    JPanel buttons = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 0));
    buttons.setBackground(new java.awt.Color(255, 255, 255));

    JLabel addResultButton = new JLabel();
    addResultButton.setIcon(new ImageIcon(JDependUIUtil.getImage("cart/add.png")));
    addResultButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    addResultButton.setToolTipText("将当前结果加入到购物车");
    addResultButton.addMouseListener(
        new java.awt.event.MouseAdapter() {
          @Override
          public void mouseClicked(java.awt.event.MouseEvent evt) {
            try {
              ShoppingCart.getInstance().addProduct(result);
              frame.getStatusField().refresh();
            } catch (JDependException e) {
              JOptionPane.showMessageDialog(
                  ScorePanel.this, e.getMessage(), "alert", JOptionPane.ERROR_MESSAGE);
            }
          }
        });

    buttons.add(addResultButton);

    JLabel exportResultButton = new JLabel();
    exportResultButton.setIcon(new ImageIcon(JDependUIUtil.getImage("export.png")));
    exportResultButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    exportResultButton.setToolTipText("将当前结果导出");
    exportResultButton.addMouseListener(
        new java.awt.event.MouseAdapter() {
          @Override
          public void mouseClicked(java.awt.event.MouseEvent evt) {
            try {
              AnalysisResultExportUtil.exportResult(frame, result);
            } catch (Exception e) {
              e.printStackTrace();
              JOptionPane.showMessageDialog(frame, "导出失败!", "alert", JOptionPane.ERROR_MESSAGE);
            }
          }
        });

    buttons.add(exportResultButton);

    content.add(BorderLayout.EAST, buttons);

    return content;
  }
Exemple #9
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;
  }
Exemple #10
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;
  }
Exemple #11
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;
  }
Exemple #12
0
  private JPanel createItem(String itemName, final Float scoreValue) {

    JPanel itemPanel = new JPanel(new BorderLayout());
    itemPanel.setBackground(new java.awt.Color(255, 255, 255));
    itemPanel.setBorder(new EmptyBorder(2, 2, 2, 2));

    JPanel scorePanel = new JPanel(new GridLayout(2, 1));
    scorePanel.setBackground(new java.awt.Color(255, 255, 255));

    JPanel scoreItemPanel = new JPanel(new GridLayout(1, 4, 4, 0));
    scoreItemPanel.setBackground(new java.awt.Color(255, 255, 255));
    JLabel scoreTitle = new JLabel();
    scoreTitle.setFont(new java.awt.Font("宋体", 1, 18));
    String title = BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_Score) + ":";
    scoreTitle.setText(title);
    scoreItemPanel.add(scoreTitle);

    JLabel score = new JLabel();
    score.setFont(new java.awt.Font("宋体", 1, 18));

    if (scoreValue != null) {
      score.setText(MetricsFormat.toFormattedMetrics(scoreValue).toString());
    } else {
      score.setText(Scored.NoValue);
    }

    scoreItemPanel.add(score);
    JLabel scoreCompareLabel = this.getComparedLabel(scoreValue, itemName);
    if (scoreCompareLabel != null) {
      scoreItemPanel.add(scoreCompareLabel);
    }
    if (itemName.equals(AnalysisResult.Metrics_TotalScore)) {

      score.addMouseListener(
          new java.awt.event.MouseAdapter() {
            @Override
            public void mouseClicked(java.awt.event.MouseEvent evt) {
              ScoreSummaryDialog d = new ScoreSummaryDialog(frame);
              d.setVisible(true);
            }
          });
      JDependUIUtil.addClickTipEffect(score);

      JLabel mm = new JLabel("MM");
      mm.addMouseListener(
          new java.awt.event.MouseAdapter() {
            @Override
            public void mouseClicked(java.awt.event.MouseEvent evt) {
              MMDialog motive = new MMDialog();
              motive.setModal(true);
              motive.setVisible(true);
            }
          });
      JDependUIUtil.addClickTipEffect(mm);

      scoreItemPanel.add(mm);
    }
    scorePanel.add(scoreItemPanel);

    JLabel fullScore = new JLabel();
    fullScore.setBackground(new java.awt.Color(153, 153, 153));
    fullScore.setFont(new java.awt.Font("宋体", 0, 10));
    fullScore.setForeground(new java.awt.Color(204, 204, 204));
    if (itemName.equals(AnalysisResult.Metrics_TotalScore)) {
      fullScore.setText(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_FullScore)
              + ":"
              + result.getFullScore());
    } else if (itemName.equals(AnalysisResult.Metrics_RelationRationality)) {
      fullScore.setText(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_FullScore)
              + ":"
              + result.getRelationRationalityScale());
    } else if (itemName.equals(AnalysisResult.Metrics_D)) {
      fullScore.setText(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_FullScore)
              + ":"
              + result.getDistanceScale());
    } else if (itemName.equals(AnalysisResult.Metrics_Balance)) {
      fullScore.setText(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_FullScore)
              + ":"
              + result.getBalanceScale());
    } else if (itemName.equals(AnalysisResult.Metrics_Encapsulation)) {
      fullScore.setText(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_FullScore)
              + ":"
              + result.getEncapsulationScale());
    }

    scorePanel.add(fullScore);

    itemPanel.add(BorderLayout.WEST, scorePanel);

    JPanel scoreScope = new JPanel();
    if (scorelist.size() > 0) {
      ScoreFacade.sort(scorelist, itemName);
      final ScoreInfo lScore = scorelist.get(0);
      final ScoreInfo hScore = scorelist.get(scorelist.size() - 1);

      scoreScope = this.createScope(lScore, hScore, itemName);
    }

    itemPanel.add(BorderLayout.EAST, scoreScope);

    itemPanel.add(BorderLayout.SOUTH, this.createAdvisePanel(itemName));

    return itemPanel;
  }