Ejemplo n.º 1
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();
 }
Ejemplo n.º 2
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();
    }
    protected Component buildContent() {
      SimpleForm form = new SimpleForm();

      form.addSpace(5);
      Interface[] ifaces = getInterfaces(project);
      DefaultComboBoxModel sourceStepComboModel = new DefaultComboBoxModel();
      sourceStepCombo = form.appendComboBox("Interfaces", sourceStepComboModel, "Target Interface");
      sourceStepCombo.setRenderer(new ModelItemListCellRenderer());
      for (Interface element : ifaces) {
        sourceStepComboModel.addElement(element);
      }

      propertiesCombo =
          form.appendComboBox(
              operationType,
              ((Interface) sourceStepCombo.getSelectedItem()).getOperationList().toArray(),
              "Target " + operationType);
      propertiesCombo.setRenderer(new ModelItemListCellRenderer());

      sourceStepCombo.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              Interface iface =
                  project.getInterfaceByName(
                      ((Interface) sourceStepCombo.getSelectedItem()).getName());
              propertiesCombo.removeAllItems();
              if (iface != null) {
                propertiesCombo.setEnabled(true);
                for (Operation op : iface.getOperationList()) {
                  propertiesCombo.addItem(op);
                }
              } else {
                propertiesCombo.setEnabled(false);
              }
            }
          });

      form.addSpace(5);
      return form.getPanel();
    }
Ejemplo n.º 4
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());
  }