Package javax.swing.table

Examples of javax.swing.table.TableModel


            controller.removeSelectionListener(controllerSelectionListener);
            int [] selectedRows = getSelectedRows();
            // Build the list of selected furniture
            List<CatalogPieceOfFurniture> selectedFurniture =
                new ArrayList<CatalogPieceOfFurniture>(selectedRows.length);
            TableModel tableModel = getModel();
            for (int index : selectedRows) {
              // Add to selectedFurniture table model value that stores piece
              selectedFurniture.add((CatalogPieceOfFurniture)tableModel.getValueAt(index, 0));
            }
            // Set the new selection in controller
            controller.setSelectedFurniture(selectedFurniture);
            controller.addSelectionListener(controllerSelectionListener);
          }
View Full Code Here


   * Updates table columns width from the content of its cells.
   */
  private void updateTableColumnsWidth() {
    int intercellWidth = getIntercellSpacing().width;
    TableColumnModel columnModel = getColumnModel();
    TableModel tableModel = getModel();
    for (int columnIndex = 0, n = columnModel.getColumnCount(); columnIndex < n; columnIndex++) {
      TableColumn column = columnModel.getColumn(columnIndex);
      int modelColumnIndex = convertColumnIndexToModel(columnIndex);
      int preferredWidth = column.getPreferredWidth();
      preferredWidth = Math.max(preferredWidth, column.getHeaderRenderer().getTableCellRendererComponent(
          this, column.getHeaderValue(), false, false, -1, columnIndex).getPreferredSize().width);
      for (int rowIndex = 0, m = tableModel.getRowCount(); rowIndex < m; rowIndex++) {
        preferredWidth = Math.max(preferredWidth,
            column.getCellRenderer().getTableCellRendererComponent(
                this, tableModel.getValueAt(rowIndex, modelColumnIndex), false, false, -1, columnIndex).
                    getPreferredSize().width);
      }
      column.setPreferredWidth(preferredWidth + intercellWidth);
      column.setWidth(preferredWidth + intercellWidth);
    }
View Full Code Here

   
    m_InstSummaryPanel.setInstances(m_Instances);
    m_AttPanel.setInstances(m_Instances);
   
    if (first) {
      TableModel model = m_AttPanel.getTableModel();
      model.addTableModelListener(new TableModelListener() {
        public void tableChanged(TableModelEvent e) {
          if (m_AttPanel.getSelectedAttributes() != null &&
              m_AttPanel.getSelectedAttributes().length > 0) {
            m_RemoveButton.setEnabled(true);
          } else {
View Full Code Here

    }

    public int compareRowsByColumn(int row1, int row2, int column)
    {
        Class type = model.getColumnClass(column);
        TableModel data = model;

        // Check for nulls

        Object o1 = data.getValueAt(row1, column);
        Object o2 = data.getValueAt(row2, column);

        // If both values are null return 0
        if (o1 == null && o2 == null) {
            return 0;
        }
        else if (o1 == null) { // Define null less than everything.
            return -1;
        }
        else if (o2 == null) {
            return 1;
        }

/* We copy all returned values from the getValue call in case
an optimised model is reusing one object to return many values.
The Number subclasses in the JDK are immutable and so will not be used in
this way but other subclasses of Number might want to do this to save
space and avoid unnecessary heap allocation.
*/
        if (type.getSuperclass() == java.lang.Number.class)
            {
                Number n1 = (Number)data.getValueAt(row1, column);
                double d1 = n1.doubleValue();
                Number n2 = (Number)data.getValueAt(row2, column);
                double d2 = n2.doubleValue();

                if (d1 < d2)
                    return -1;
                else if (d1 > d2)
                    return 1;
                else
                    return 0;
            }
        else if (type == java.util.Date.class)
            {
                Date d1 = (Date)data.getValueAt(row1, column);
                long n1 = d1.getTime();
                Date d2 = (Date)data.getValueAt(row2, column);
                long n2 = d2.getTime();

                if (n1 < n2)
                    return -1;
                else if (n1 > n2)
                    return 1;
                else return 0;
            }
        else if (type == String.class)
            {
                String s1 = (String)data.getValueAt(row1, column);
                String s2    = (String)data.getValueAt(row2, column);
                int result = s1.compareTo(s2);

                if (result < 0)
                    return -1;
                else if (result > 0)
                    return 1;
                else return 0;
            }
        else if (type == Boolean.class)
            {
                Boolean bool1 = (Boolean)data.getValueAt(row1, column);
                boolean b1 = bool1.booleanValue();
                Boolean bool2 = (Boolean)data.getValueAt(row2, column);
                boolean b2 = bool2.booleanValue();

                if (b1 == b2)
                    return 0;
                else if (b1) // Define false < true
                    return 1;
                else
                    return -1;
            }
        else
            {
                Object v1 = data.getValueAt(row1, column);
                String s1 = v1.toString();
                Object v2 = data.getValueAt(row2, column);
                String s2 = v2.toString();
                int result = s1.compareTo(s2);

                if (result < 0)
                    return -1;
View Full Code Here

    Object[] names = new Object[]{
            "Capacity", "Cost", "Group", "Location", "Type", "Container", "Date Acquired" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
    };

    ClassicEngineBoot.getInstance().start();
    final TableModel dataModel = new DefaultTableModel(data, names);
    MasterReport report = parseReport(getReportDefinitionSource());
    report.setDataFactory(new TableDataFactory
        ("default", dataModel)); //$NON-NLS-1$
    PdfReportUtil.createPDF(report, "PagebreakItemband.pdf"); //$NON-NLS-1$
    assertTrue(true);
View Full Code Here

    {
      parameterContext.close();
    }

    // definition: Single mail or multi-mail
    final TableModel burstingData;
    final DataFactory dataFactory = definition.getDataFactory();
    if (definition.getBurstQuery() != null &&
        dataFactory.isQueryExecutable(definition.getBurstQuery(), parameterValues))
    {
      burstingData = wrapWithParameters(dataFactory.queryData(definition.getBurstQuery(), parameterValues), parameterValues);
    }
    else
    {
      burstingData = wrapWithParameters(new DefaultTableModel(1, 0), parameterValues);
    }


    if (burstingData.getRowCount() > 0)
    {
//      final Transport transport = session.getTransport();
//      transport.connect();
      for (int i = 0; i < burstingData.getRowCount(); i++)
      {
        final DataRow parameterDataRow = createReportParameterDataRow(burstingData, i);
        final MimeMessage message = createReport(definition, session, parameterDataRow);

        parameterContext.setParameterValues(parameterDataRow);
View Full Code Here

      throws ReportDataFactoryException, MessagingException
  {
    if (definition.getRecipientsQuery() != null &&
        dataFactory.isQueryExecutable(definition.getRecipientsQuery(), parameterDataRow))
    {
      final TableModel model = wrapWithParameters
          (dataFactory.queryData(definition.getRecipientsQuery(), parameterDataRow), parameterDataRow);

      for (int r = 0; r < model.getRowCount(); r++)
      {
        String address = null;
        String name = null;
        String type = "TO";
        if (model.getColumnCount() >= 3)
        {
          type = (String) model.getValueAt(0, 2);
        }
        if (model.getColumnCount() >= 2)
        {
          name = (String) model.getValueAt(0, 1);
        }
        if (model.getColumnCount() >= 1)
        {
          address = (String) model.getValueAt(0, 0);
        }
        if (address == null)
        {
          continue;
        }
View Full Code Here

      final String[] tables = tableDataFactory.getQueryNames();
      for (int i = 0; i < tables.length; i++)
      {
        final String tableName = tables[i];
        final TableModel tableModel = tableDataFactory.queryData(tableName, null);

        xmlWriter.writeTag(InlineDataFactoryModule.NAMESPACE, "inline-table", "name", tableName, XmlWriterSupport.OPEN);
        xmlWriter.writeTag(InlineDataFactoryModule.NAMESPACE, "definition", XmlWriterSupport.OPEN);

        final Class[] colTypes = new Class[tableModel.getColumnCount()];
        for (int col = 0; col < tableModel.getColumnCount(); col += 1)
        {
          final AttributeList colAttrs = new AttributeList();
          colAttrs.setAttribute(InlineDataFactoryModule.NAMESPACE, "name", tableModel.getColumnName(col));

          final Class columnClass = tableModel.getColumnClass(col);
          if (columnClass == null)
          {
            colAttrs.setAttribute(InlineDataFactoryModule.NAMESPACE, "type", Object.class.getName());
            colTypes[col] = Object.class;
          }
          else
          {
            colAttrs.setAttribute(InlineDataFactoryModule.NAMESPACE, "type", columnClass.getName());
            colTypes[col] = columnClass;
          }

          xmlWriter.writeTag(InlineDataFactoryModule.NAMESPACE, "data", colAttrs, XmlWriterSupport.CLOSE);
        }
        xmlWriter.writeCloseTag(); // definition

        for (int row = 0; row < tableModel.getRowCount(); row += 1)
        {
          xmlWriter.writeTag(InlineDataFactoryModule.NAMESPACE, "row", XmlWriterSupport.OPEN);
          for (int col = 0; col < tableModel.getColumnCount(); col += 1)
          {
            final AttributeList colAttrs = new AttributeList();
            final Object value = tableModel.getValueAt(row, col);
            if (value == null)
            {
              colAttrs.setAttribute(InlineDataFactoryModule.NAMESPACE, "null", "true");
              xmlWriter.writeTag(InlineDataFactoryModule.NAMESPACE, "data", colAttrs, XmlWriterSupport.CLOSE);
            }
View Full Code Here

  {
    if (GraphicsEnvironment.isHeadless())
    {
      return;
    }
    final TableModel mdataModel = new ExpressionGroupBugDataSet();
    ExpressionGroupBug bug = new ExpressionGroupBug();
    MasterReport report = TestSystem.loadReport
        ("org/pentaho/reporting/engine/classic/extensions/junit/bugs/resource/ExpressionGroupBug.xml", mdataModel);
    if (report == null)
    {
View Full Code Here

    Object[] names = new Object[]{
            "Capacity", "Cost", "Group", "Location", "Type", "Container", "Date Acquired" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-7
    };

    final TableModel dataModel = new DefaultTableModel(data, names);
    MasterReport report = parseReport(getReportDefinitionSource());
    report.setDataFactory(new TableDataFactory
        ("default", dataModel)); //$NON-NLS-1$
    assertTrue(FunctionalityTestLib.execGraphics2D(report)); }
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.