Пример #1
0
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

      boldFont = getFont().deriveFont(Font.BOLD);

      AssertionListEntry entry = (AssertionListEntry) value;
      String type = TestAssertionRegistry.getInstance().getAssertionTypeForName(entry.getName());
      boolean canAssert = false;
      boolean disable = true;
      JLabel label;
      JTextArea descText;
      JLabel disabledInfo;
      if (type != null && assertable != null && assertable.getModelItem() != null) {
        canAssert =
            isAssertionApplicable(type, assertable.getModelItem(), getSelectedPropertyName());
        disable = !categoriesListTable.isEnabled() || !canAssert;
      }
      String str = entry.getName();
      label = new JLabel(str);
      label.setFont(boldFont);
      descText = new JTextArea(((AssertionListEntry) value).getDescription());
      descText.setSize(new Dimension(80, 20));
      descText.setLineWrap(true);
      descText.setWrapStyleWord(true);
      disabledInfo = new JLabel("Not applicable with selected Source and Property");
      descText.setFont(disabledInfo.getFont());
      if (disable) {
        label.setForeground(Color.LIGHT_GRAY);
        descText.setForeground(Color.LIGHT_GRAY);
        disabledInfo.setForeground(Color.LIGHT_GRAY);
      }
      SimpleForm form = new SimpleForm();
      form.addComponent(label);
      if (!isHideDescriptionSelected()) {
        form.addComponent(descText);
        //				if( disable )
        //				{
        //					form.addComponent( disabledInfo );
        //				}
        getAssertionsTable().setRowHeight(70);
      } else {
        if (disable) {
          form.addComponent(disabledInfo);
        }
        getAssertionsTable().setRowHeight(40);
      }
      if (isSelected) {
        descText.setBackground(Color.LIGHT_GRAY);
        form.getPanel().setBackground(Color.LIGHT_GRAY);
      } else {
        descText.setBackground(Color.WHITE);
        form.getPanel().setBackground(Color.WHITE);
      }
      return form.getPanel();
    }
Пример #2
0
 @Override
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   String categoryName = (String) value;
   boolean disabled = true;
   Font boldFont = getFont().deriveFont(Font.BOLD);
   SortedSet<AssertionListEntry> assertions = categoriesAssertionsMap.get(categoryName);
   for (AssertionListEntry assertionListEntry : assertions) {
     if (isAssertionApplicable(assertionListEntry.getTypeId())) {
       disabled = false;
       break;
     }
   }
   JLabel label = new JLabel(categoryName);
   SimpleForm form = new SimpleForm();
   form.addComponent(label);
   label.setFont(boldFont);
   if (disabled || !((CategoriesListTable) table).isSelectable(row)) {
     label.setForeground(Color.GRAY);
   }
   if (isSelected) {
     form.getPanel().setBackground(Color.LIGHT_GRAY);
   } else {
     form.getPanel().setBackground(Color.WHITE);
   }
   return form.getPanel();
 }
Пример #3
0
  protected Component buildAssertionsList() {
    assertionsForm = new SimpleForm();

    assertionsListTableModel = new AssertionsListTableModel();
    assertionsTable = new AssertionsListTable(assertionsListTableModel);
    int selectedRow = categoriesListTable.getSelectedRow();
    String category = (String) categoriesListTable.getModel().getValueAt(selectedRow, 0);
    if (category != null && categoriesAssertionsMap.containsKey(category)) {
      assertions = categoriesAssertionsMap.get(category);
      assertionsListTableModel.setListEntriesSet(assertions);
    }
    assertionsTable.setTableHeader(null);
    assertionsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    assertionsTable.getSelectionModel().addListSelectionListener(selectionListener);
    assertionsTable.setEditable(false);
    assertionsTable.setGridColor(Color.BLACK);
    assertionsTable.addMouseListener(mouseAdapter);

    assertionsTable.getColumnModel().getColumn(0).setCellRenderer(assertionEntryRenderer);
    assertionsForm.addComponent(assertionsTable);
    return new JScrollPane(assertionsForm.getPanel());
  }