Package gov.nasa.arc.mct.table.model

Examples of gov.nasa.arc.mct.table.model.TableStructure$TableRow


  @Test
  public void testZeroDimensional() {
    when(policyManager.execute(isA(String.class), isA(PolicyContext.class))).thenReturn(success);

    AbstractComponent c;
    TableStructure structure;
   
    c = new MockLeafComponent();
    structure = TableViewPolicy.getTableStructure(c);
    assertEquals(structure.getType(), TableType.ZERO_DIMENSIONAL);
    assertEquals(structure.getRowCount(), 1);
    assertEquals(structure.getColumnCount(), 1);
    assertSame(structure.getValue(0, 0), c);
   
    c = new MockFeedComponent();
    structure = TableViewPolicy.getTableStructure(c);
    assertEquals(structure.getType(), TableType.ZERO_DIMENSIONAL);
    assertEquals(structure.getRowCount(), 1);
    assertEquals(structure.getColumnCount(), 1);
    assertSame(structure.getValue(0, 0), c);
   
    c = new MockEvaluator(new MockFeedComponent());
    structure = TableViewPolicy.getTableStructure(c);
    assertEquals(structure.getType(), TableType.ZERO_DIMENSIONAL);
    assertEquals(structure.getRowCount(), 1);
    assertEquals(structure.getColumnCount(), 1);
    assertSame(structure.getValue(0, 0), c);
  }
View Full Code Here


    AbstractComponent c3 = new MockCollection();
    AbstractComponent c4 = new MockEvaluator(c1,c2);
   
    AbstractComponent parent = new MockCollection(c1, c2, c3,c4);
   
    TableStructure structure = TableViewPolicy.getTableStructure(parent);
    assertEquals(structure.getType(), TableType.ONE_DIMENSIONAL);
    assertEquals(structure.getRowCount(), 4);
    assertEquals(structure.getColumnCount(), 1);
    assertSame(structure.getValue(0, 0), c1);
    assertSame(structure.getValue(1, 0), c2);
    assertSame(structure.getValue(2, 0), c3);
    assertSame(structure.getValue(3, 0), c4);
  }
View Full Code Here

    AbstractComponent parent3 = new MockCollection(e1, e2);

    AbstractComponent grandParent = new MockCollection(parent1, parent2, parent3);
   
    TableStructure structure = TableViewPolicy.getTableStructure(grandParent);
    assertEquals(structure.getType(), TableType.TWO_DIMENSIONAL);
    assertEquals(structure.getRowCount(), 3);
    assertEquals(structure.getColumnCount(), 3);
    assertSame(structure.getValue(0, 0), c1);
    assertSame(structure.getValue(0, 1), c2);
    assertSame(structure.getValue(0, 2), c3);
    assertSame(structure.getValue(1, 0), d1);
    assertSame(structure.getValue(1, 1), d2);
    assertNull(structure.getValue(1, 2));
    assertSame(structure.getValue(2, 0), e1);
    assertSame(structure.getValue(2, 1), e2);
    assertNull(structure.getValue(2, 2));
  }
View Full Code Here

   */
  public static TableStructure getTableStructure(AbstractComponent targetComponent) {

    if (targetComponent.isLeaf() || hasFeed(targetComponent) || isEvaluatorComponent(targetComponent)) {
      // 0-dimensional table
      return new TableStructure(TableType.ZERO_DIMENSIONAL, targetComponent);
    }

    // Try to create a 2-dimensional structure.
    // Each child of the component is an object to display as a row
    // or column. The child must have children of its own in order
    // to have 2 dimensions to the table. Each of those grandchildren
    // must have a data feed.
    boolean isTwoDimensional = true;
    childLoop: for (AbstractComponent component : targetComponent.getComponents()) {
      if ((component.isLeaf() || hasEvaluator(component)) && canEmbedInTable(component)) {
        isTwoDimensional = false;
        break childLoop;
      } else {
        for (AbstractComponent gcComponent : component.getComponents()) {
          if (!gcComponent.isLeaf() && !hasFeed(gcComponent) && !isViewableEvaluator(gcComponent)) {
            // We found a nonleaf that doesn't have a value, so we aren't two-dimensional.
            isTwoDimensional = false;
            break childLoop;
          }
        }
      }
    }
    if (isTwoDimensional) {
      return new TableStructure(TableType.TWO_DIMENSIONAL, targetComponent);
    }

    // The default case: a 1-dimensional structure.
    return new TableStructure(TableType.ONE_DIMENSIONAL, targetComponent);
  }
View Full Code Here

  public TableViewManifestation(AbstractComponent component, ViewInfo vi) {
    super(component,vi);

    labelingAlgorithm = new AbbreviatingTableLabelingAlgorithm();
    setLabelingContext(labelingAlgorithm, getNamingContext());
    TableStructure structure = TableViewPolicy
        .getTableStructure(getManifestedComponent());
    model = new ComponentTableModel(structure, labelingAlgorithm, this);
    model.updateLabels();

    TableViewCellRenderer renderer = new TableViewCellRenderer();
   
    table = new LabeledTable(model);
    table.getTable().setShowGrid(false);
    table.getTable().getColumnModel().setColumnMargin(0);
    table.getTable().setRowMargin(0);
   
    table.getTable().setDefaultRenderer(Object.class,
        renderer);
    table.getTable().setTransferHandler(
        new TableTransferHandler(this, table));
    table.getTable().setDragEnabled(true);
    table.getTable().setFillsViewportHeight(true);
    if (structure.getType() == TableType.TWO_DIMENSIONAL) {
      table.getTable().setDropMode(DropMode.ON_OR_INSERT);
    } else {
      table.getTable().setDropMode(DropMode.ON_OR_INSERT_ROWS);
    }
   
View Full Code Here

    }
    return rv;
  }

  private void updateFeedProviders() {
    TableStructure structure = TableViewPolicy
        .getTableStructure(getManifestedComponent());
    updateFeedProviders(structure);
    updateEvalutors();
    loadHeaderSettings();
    loadCellSettings();
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.table.model.TableStructure$TableRow

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.