Package javax.swing.table

Examples of javax.swing.table.TableModel


        public void dispatch()
        {
            try
            {
                BridgePeer peer = (BridgePeer) getSource();
                TableModel model = _table.getModel();
                int rows = model.getRowCount();
                int cols = model.getColumnCount();
                for (int i = 0; i < rows; i++)
                {
                    //handle cell events
                    for (int j = 0; j < cols; j++)
                    {
                        boolean edit = model.isCellEditable(i, j);
                        if (edit)
                        {
                            TableCellEditor editor = _table.getCellEditor(i, j);
                            Component com = _table.prepareEditor(editor, i, j);
                            BridgePeer childPeer = _context.getContext().getPeer(com);
View Full Code Here


    assertNotNull(viewHandler.getCancelButton(null));
  }

  @Test
  public void testGetCustomerTableModel() {
    TableModel tableModel = viewHandler.getTableModel(null);
    assertNotNull(tableModel);
    assertEquals(3, tableModel.getColumnCount());
  }
View Full Code Here

            EventList<Entry> entries = GlazedListsSwing.swingThreadProxyList(sourceEntries);

            SortedList<Entry> sortedEntries = new SortedList<Entry>(entries, null);

            TreeList<Entry> treeList = new TreeList<Entry>(sortedEntries, treeFormat, TreeList.NODES_START_EXPANDED);
            TableModel model = new EventTableModel<Entry>(treeList, tableFormat);
            JTable table = new JTable(model);
            TreeTableSupport.install(table, treeList, 0);
            TableComparatorChooser.install(table, sortedEntries, TableComparatorChooser.SINGLE_COLUMN);

            JFrame frame = new JFrame(fileBrowserModel.getRoot().getName());
View Full Code Here

  public void actionPerformed(ActionEvent e) {
    JGeneratorFrame generatorGui = (JGeneratorFrame) ui;
   
    try {
      MetadataTable metadataTable = generatorGui.getMetadataTable();
      TableModel metadataTableModel = metadataTable.getModel();
     
      final ModelMetadata modelMetadata = new ModelMetadata();
      final List<FieldMetadata> fieldMetadatas = new ArrayList<FieldMetadata>();
      modelMetadata.setFieldMetadatas(fieldMetadatas);
     
      /*
       * 获取表格数据
       */
      int rowCount = metadataTableModel.getRowCount();
      for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
        final FieldMetadata oneFieldMetadata = new FieldMetadata();
       
        final Object columnName = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.COLUMN_NAME_INDEX);
        final Object propertyNameObj = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.PROPERTY_NAME_INDEX);
        final Object displayName = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.DISPLAY_NAME_INDEX);
        final Object comments = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.COMMENTS_INDEX);
        final Object sqlDataTypeObj = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.SQL_DATA_TYPE_INDEX);
        final Object dataLengthObj = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.DATA_LENGTH_INDEX);
        final Object dataPrecisionObj = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.DATA_PRECISION_INDEX);
        final Object dataScaleObj = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.DATA_SCALE_INDEX);
        final Object propertyTypeObj = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.PROPERTY_TYPE_INDEX);
        final Object nullable = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.NULLABLE_INDEX);
        final Object dataDefault = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.DATA_DEFAULT_INDEX);
        final Object keyField = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.IS_KEY_FIELD_INDEX);
        final Object constraintType = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.CONSTRAINT_TYPE_INDEX);
        final Object referencingTable = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.REFERENCING_TABLE_INDEX);
        final Object referencingColumn = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.REFERENCING_COLUMN_INDEX);
        final Object deleteRule = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.DELETE_RULE_INDEX);
        final Object queryField = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.IS_QUERY_FIELD_INDEX);
        final Object queryMode = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.QUERY_MODE_INDEX);
        final Object componentType = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.COMPONENT_TYPE_INDEX);
       
        oneFieldMetadata.setColumnName(StringUtils.toString(columnName));
        String propertyName = StringUtils.toString(propertyNameObj);
        oneFieldMetadata.setPropertyName(propertyName);
        oneFieldMetadata.setPropertyNameLowerCamelCase((NotationUtils.smallFirst(propertyName)));
View Full Code Here

        Schema schema = dc.getDefaultSchema();
        Table table = schema.getTableByName("projects_project");
        Query q = new Query().select(table.getColumns()).from(table, "p");
        assertEquals("SELECT p.id, p.project, p.name FROM xml_input_eobjects.xml.projects_project p", q.toString());
        DataSet data = dc.executeQuery(q);
        TableModel tableModel = new DataSetTableModel(data);
        assertEquals(3, tableModel.getColumnCount());
        assertEquals(2, tableModel.getRowCount());

        // ID
        assertEquals(1, tableModel.getValueAt(0, 0));
        assertEquals(2, tableModel.getValueAt(1, 0));

        // Project (text content)
        assertEquals("Some description", tableModel.getValueAt(0, 1));
        assertNull(tableModel.getValueAt(1, 1));

        // Name
        assertEquals("datacleaner", tableModel.getValueAt(0, 2));
        assertEquals("MetaModel", tableModel.getValueAt(1, 2));

        // Make a new query that joins the normalized tables together
        table = schema.getTableByName("contributors_person_address");
        Relationship relationShip = table.getRelationships()[0];
        q = new Query().select(relationShip.getPrimaryTable().getColumns())
                .select(relationShip.getForeignTable().getColumns()).from(new FromItem(JoinType.INNER, relationShip));

        assertEquals(
                "SELECT contributors_person.id, contributors_person_address.id, "
                        + "contributors_person_address.contributors_person_id, contributors_person_address.address "
                        + "FROM xml_input_eobjects.xml.contributors_person INNER JOIN xml_input_eobjects.xml.contributors_person_address "
                        + "ON contributors_person.id = contributors_person_address.contributors_person_id",
                q.toString());

        data = dc.executeQuery(q);
        tableModel = new DataSetTableModel(data);
        assertEquals(4, tableModel.getColumnCount());
        assertEquals(4, tableModel.getRowCount());

        assertEquals("1", tableModel.getValueAt(0, 0).toString());
        assertEquals("1", tableModel.getValueAt(0, 1).toString());
        assertEquals("1", tableModel.getValueAt(0, 2).toString());
        assertEquals("My address", tableModel.getValueAt(0, 3).toString());

        assertEquals("1", tableModel.getValueAt(1, 0).toString());
        assertEquals("2", tableModel.getValueAt(1, 1).toString());
        assertEquals("1", tableModel.getValueAt(1, 2).toString());
        assertEquals("Another address", tableModel.getValueAt(1, 3).toString());

        assertEquals("1", tableModel.getValueAt(2, 0).toString());
        assertEquals("3", tableModel.getValueAt(2, 1).toString());
        assertEquals("1", tableModel.getValueAt(2, 2).toString());
        assertEquals("A third address", tableModel.getValueAt(2, 3).toString());

        assertEquals("2", tableModel.getValueAt(3, 0).toString());
        assertEquals("4", tableModel.getValueAt(3, 1).toString());
        assertEquals("2", tableModel.getValueAt(3, 2).toString());
        assertEquals("Asbjorns address", tableModel.getValueAt(3, 3).toString());
    }
View Full Code Here

        CsvDataContext dc = new CsvDataContext(file, semicolonConfiguration);
        Table table = dc.getDefaultSchema().getTables()[0];
        Query query = new Query().from(table).select(table.getColumns()).setMaxRows(5);
        DataSet dataSet = dc.executeQuery(query);

        TableModel tableModel = new DataSetTableModel(dataSet);
        assertEquals(5, tableModel.getRowCount());
    }
View Full Code Here

  }

  public JXTable getTableOrders(ProductAreaGroup productAreaGroup) {
    updateTransportableList();
    tableOrdersList = new JXTable();
    TableModel transportOrderTableModel = new TransportOrderTableModel(
        transportableSelectionList, transportableList, Util
            .getGavlChecker(), Util
            .getTakstolChecker(managerRepository), Util
            .getSteinChecker(), Util.getGulvsponChecker(),
        TransportOrderTableModel.TransportColumn.ForExcel.TABLE);
View Full Code Here

    CellStyle cellStyle = new CellStyle(wb);

    Set<Transport> transports = tableModels.keySet();
    List<Transport> sortedTransport = new ArrayList<Transport>(transports);
    Collections.sort(sortedTransport, new TransportComparator());
    TableModel tableModel;
    String dateString = "";

    for (Transport transport : sortedTransport) {
      tableModel = tableModels.get(transport);

      String transportFirm = getTransportFirmInfo(transport);
      dateString = getDateString(dateString, transport);

      // Overskrift
      row = sheet.createRow((short) currentRow++);

      createCell(row, cellStyle.getStyle12(), (short) 0, transport
          .getTransportName()
          + " - lasting: " + dateString);

      row = sheet.createRow((short) currentRow++);
      createCell(row, cellStyle.getStyle12(), (short) 0, "firma:"
          + transportFirm);

      String comment = transport.getTransportComment();
      if (comment != null && comment.length() > 0) {
        row = sheet.createRow((short) currentRow++);
        createCell(row, cellStyle.getStyle12(), (short) 0, "kommentar:"
            + comment);
      }

      row = sheet.createRow((short) currentRow++);

      int columnCount = tableModel.getColumnCount();
      int rowCount = tableModel.getRowCount();

      createColumnHeadings(row, cellStyle.getStyle12BorderBottomThick(),
          tableModel, (short) 0, columnCount - 1, 0, null);

      // Data
      int j;
      int k;
      for (j = currentRow; j < rowCount + currentRow; j++) {
        setLabelInfo(labelInfo, infoString, j);
        row = sheet.createRow((short) j);

        for (k = 0; k < columnCount; k++) {
          // kommentar
          if (k == 11) {
            // har kommentar
            if (tableModel.getValueAt(j - currentRow, k) != null) {
              // lager egen linje for kommentar
              row = sheet.createRow((short) j + 1);
              createCell(row, null, (short) 0, String
                  .valueOf(tableModel.getValueAt(j
                      - currentRow++, k)));

              j++;
            }
          } else {
            if (tableModel.getValueAt(j - currentRow, k) != null) {
              Class<?> clazz = tableModel.getColumnClass(k);

              if (clazz.equals(Integer.class)
                  || clazz.equals(BigDecimal.class)) {
                createCell(
                    row,
                    cellStyle
                        .getStyle10BorderBottomDashedBorderTopMedium(true),
                    (short) k,
                    String
                        .valueOf(Double
                            .valueOf(
                                String
                                    .valueOf(tableModel
                                        .getValueAt(
                                            j
                                                - currentRow,
                                            k)))
                            .doubleValue()));
              } else {
                createCell(
                    row,
                    cellStyle
                        .getStyle10BorderBottomDashedBorderTopMedium(true),
                    (short) k, String.valueOf(tableModel
                        .getValueAt(j - currentRow, k)));
              }
            } else {
              createCell(
                  row,
View Full Code Here

      final Map<Transport, TransportOverviewTableModel> models,
      final Transport transport, final Map<Integer, HSSFRow> rader) {
    HSSFRow row;
    int currentRow = rowNumber;

    TableModel tableModel = models.get(transport);

    row = rader.get(currentRow);
    if (row == null) {
      row = sheet.createRow((short) currentRow);
      rader.put(currentRow, row);
    }
    currentRow++;
    createCell(row, cellStyle.getStyle12Bold(), weekAdd, transport
        .getTransportName());

    row = rader.get(currentRow);
    if (row == null) {
      row = sheet.createRow((short) currentRow);
      rader.put(currentRow, row);
    }
    currentRow++;
    int columnCount = tableModel.getColumnCount();
    int rowCount = tableModel.getRowCount();

    createColumnHeadings(row, cellStyle.getStyle12BoldBorderBottomThick(),
        tableModel, weekAdd, columnCount, 0, null);

    int j;
View Full Code Here

public class TableModelWrapper implements ICodeGen {
 
  public String getJavaCode(Object value, ImportRewrite imports) {
    if (value == null)
      return "null";
    TableModel model = (TableModel) value;
    String str = imports.addImport("javax.swing.table.DefaultTableModel");
    StringBuilder builder = new StringBuilder();
    builder.append("new " + str + "(\n");
    builder.append("new Object[][]{\n");
    int rowcount = model.getRowCount();
    int columncount = model.getColumnCount();
    for (int i = 0; i < rowcount; i++) {
      builder.append("{");
      for (int j = 0; j < columncount; j++) {
        Object object = model.getValueAt(i, j);
        if (object == null)
          builder.append("null");
        else {
          TypeAdapter adapter = ExtensionRegistry.getTypeAdapter(object.getClass());
          if (adapter != null) {
            ICodeGen codeGen = adapter.getCodegen();
            if (codeGen != null) {
              builder.append(codeGen.getJavaCode(object, imports));
            } else {
              builder.append(object.toString());
            }
          } else {
            builder.append(object.toString());
          }
        }
        builder.append(",");
      }
      builder.append("},\n");
    }
    builder.append("},\n");
    builder.append("new String [] {\n");
    for (int i = 0; i < columncount; i++) {
      builder.append("\"" + model.getColumnName(i) + "\",");
    }
    builder.append("}\n");
    builder.append("){\n");
    builder.append("private static final long serialVersionUID = 1L;\n");
    builder.append("Class<?>[] types = new Class<?> [] {\n");
    for (int i = 0; i < columncount; i++) {
      Class<?> cc = model.getColumnClass(i);
      String className = "java.lang.String";
      if (cc != null)
        className = cc.getName();
      String cn = imports.addImport(className);
      builder.append(cn + ".class,");
View Full Code Here

TOP

Related Classes of javax.swing.table.TableModel

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.