Examples of AbstractTableModel


Examples of javax.swing.table.AbstractTableModel

        this.controller = controller;
    }

    public void initTableModel() {

        this.tableModel = new AbstractTableModel() {

            private static final long serialVersionUID = 1639834079696538876L;

            @Override
            public boolean isCellEditable(int row, int column) {
View Full Code Here

Examples of javax.swing.table.AbstractTableModel

        this.controller = controller;
    }

    public void initTableModel() {

        this.tableModel = new AbstractTableModel() {

            private static final long serialVersionUID = 1639834079696538876L;

            @Override
            public boolean isCellEditable(int row, int column) {
View Full Code Here

Examples of javax.swing.table.AbstractTableModel

        {"Checking if the database exists", ""},
        {"Checking the database schema", ""},
         {"Checking whether the database needs conversion", ""}
    };

    TableModel dataModel = new AbstractTableModel() {
        private String[] columnNames = names;
        private Object[][] data = datas;
        public int getColumnCount() { return columnNames.length; }
        public int getRowCount() { return data.length; }
        public String getColumnName(int col) { return columnNames[col]; }
View Full Code Here

Examples of javax.swing.table.AbstractTableModel

   * @return the java component
   */
  public JComponent createWorldTable(){
   
    // Create a model of the data.
    dataModelW = new AbstractTableModel() {

      public int getColumnCount() {
        return 6;
      }

View Full Code Here

Examples of javax.swing.table.AbstractTableModel

   * @return the java component
   */
  public JComponent createEntityTable(){
 
    // Create a model of the data.
    dataModelE = new AbstractTableModel() {
      public int getColumnCount() {
        if (selUnit != null) {
          return 15;// hide some information //selUnit.list.size();
        } else
          return 0;
View Full Code Here

Examples of javax.swing.table.AbstractTableModel

    columnNames.add("Time");
    columnNames.add("From");
    columnNames.add("To");
    columnNames.add("Data");

    final AbstractTableModel model = new AbstractTableModel() {
      public String getColumnName(int col) {
        return columnNames.get(col).toString();
      }

      public int getRowCount() {
        return rowData.size();
      }

      public int getColumnCount() {
        return columnNames.size();
      }

      public Object getValueAt(int row, int col) {
        if (col == COLUMN_TIME) {
          return rowData.get(row)[DATAPOS_TIME];
        } else if (col == COLUMN_FROM) {
          return ((RadioConnection)rowData.get(row)[DATAPOS_CONNECTION]).getSource().getMote();
        } else if (col == COLUMN_TO) {
          return "[" + ((RadioConnection)rowData.get(row)[DATAPOS_CONNECTION]).getDestinations().length + " motes]";
        } else if (col == COLUMN_DATA) {
          return transformDataToString((byte[]) rowData.get(row)[DATAPOS_DATA]);
        } else {
          logger.fatal("Bad row/col: " + row + "/" + col);
        }
        return null;
      }

      public boolean isCellEditable(int row, int col) {
        if (col == COLUMN_FROM) {
          // Try to highligt selected mote
          gui.signalMoteHighlight(
              ((RadioConnection)rowData.get(row)[DATAPOS_CONNECTION]).getSource().getMote()
          );
        }

        if (col == COLUMN_TO) {
          return true;
        }
        return false;
      }

      public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
      }
    };

    final JComboBox comboBox = new JComboBox();

    comboBox.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent e) {
        if (e.getStateChange() == ItemEvent.SELECTED) {
          if (e.getItem() instanceof Mote) {
            gui.signalMoteHighlight((Mote) e.getItem());
          }
        }
      }
    });

    dataTable = new JTable(model) {
      public TableCellEditor getCellEditor(int row, int column) {
        // Populate combo box
        comboBox.removeAllItems();
        if (row < 0 || row >= rowData.size()) {
          return super.getCellEditor(row, column);
        }

        RadioConnection conn = (RadioConnection) rowData.get(row)[DATAPOS_CONNECTION];
        if (conn == null) {
          return super.getCellEditor(row, column);
        }

        for (Radio destRadio: conn.getDestinations()) {
          if (destRadio.getMote() != null) {
            comboBox.addItem(destRadio.getMote());
          } else {
            comboBox.addItem("[standalone radio]");
          }
        }

        return super.getCellEditor(row, column);
      }

      public String getToolTipText(MouseEvent e) {
        java.awt.Point p = e.getPoint();
        int rowIndex = rowAtPoint(p);
        int colIndex = columnAtPoint(p);
        int realColumnIndex = convertColumnIndexToModel(colIndex);

        String tip = "";
        if (realColumnIndex == COLUMN_DATA) {
          byte[] data = (byte[]) rowData.get(rowIndex)[DATAPOS_DATA];

          Packet packet = analyzePacket(data);
          if (packet != null) {
            tip = packet.getToolTip();
          }
        } else {
          tip = super.getToolTipText(e);
        }
        return tip;
      }
    };

    // Set data column width greedy
    dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    dataTable.getColumnModel().getColumn(COLUMN_TIME).setPreferredWidth(55);
    dataTable.getColumnModel().getColumn(COLUMN_FROM).setPreferredWidth(130);
    dataTable.getColumnModel().getColumn(COLUMN_TO).setPreferredWidth(100);

    dataTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    dataTable.getSelectionModel().addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            int selectedRowIndex = dataTable.getSelectedRow();
            if (selectedRowIndex < 0) {
              return;
            }

            Object[] row = rowData.get(selectedRowIndex);
            if (row == null) {
              return;
            }

            RadioConnection conn = (RadioConnection) row[DATAPOS_CONNECTION];
            if (conn == null) {
              return;
            }

            Mote mote = conn.getSource().getMote();
            if (mote == null) {
              return;
            }

            gui.signalMoteHighlight(mote);
          }
        });

    TableColumn destColumn = dataTable.getColumnModel().getColumn(COLUMN_TO);
    destColumn.setCellEditor(new DefaultCellEditor(comboBox));

    final JScrollPane scrollPane = new JScrollPane(dataTable);
//    dataTable.setFillsViewportHeight(true);

    add(scrollPane);

    simulation.getRadioMedium().addRadioMediumObserver(radioMediumObserver = new Observer() {
      public void update(Observable obs, Object obj) {
        RadioConnection[] newConnections = radioMedium.getLastTickConnections();
        if (newConnections == null) {
          return;
        }

        for (RadioConnection newConnection: newConnections) {
          Object[] data = new Object[3];
          data[DATAPOS_TIME] = new Integer(simulation.getSimulationTime());
          data[DATAPOS_CONNECTION] = newConnection;

          if (newConnection.getSource() instanceof PacketRadio) {
            data[DATAPOS_DATA] = ((PacketRadio) newConnection.getSource()).getLastPacketTransmitted();
          } else {
            data[DATAPOS_DATA] = null;
          }

          rowData.add(data);
        }
        model.fireTableRowsInserted(rowData.size() - newConnections.length + 1, rowData.size());
        setTitle("Radio Logger: " + rowData.size() + " packets");
      }
    });

    try {
View Full Code Here

Examples of javax.swing.table.AbstractTableModel

      DAOFactory daoFactory = new DAOFactory();
      RegisterDAO registerDao = (RegisterDAO)daoFactory.getDAO("register");
      transactionList = registerDao.loadTransactionsForAccount(currentAccount.getAccountID());
    }
   
    TableModel dataModel = new AbstractTableModel() {
      private static final long serialVersionUID = 1;
     
      public int getColumnCount() { return 5; }
     
      public String getColumnName(int columnIndex) {
View Full Code Here

Examples of javax.swing.table.AbstractTableModel

   */
 
  private static String[] columnNames = {"Del", "Account", "Deposit", "Withdraw"};
  private void updateSplitTableData() {
   
    TableModel dataModel = new AbstractTableModel() {
      private static final long serialVersionUID = 1;
     
      private TransSplit transSplit = null;
     
      public int getColumnCount() { return 4; }
View Full Code Here

Examples of javax.swing.table.AbstractTableModel

     
      RegisterDAO registerDAO = (RegisterDAO)daoFactory.getDAO("register");
      balanceList = registerDAO.loadBalancesForAccount(this.currentAccount.getAccountID());
    }

    TableModel dataModel = new AbstractTableModel() {
      private static final long serialVersionUID = 1;
     
      public int getColumnCount() { return 5; }
     
      public String getColumnName(int columnIndex) {
View Full Code Here

Examples of javax.swing.table.AbstractTableModel

      DAOFactory daoFactory = new DAOFactory();
      RegisterDAO registerDao = (RegisterDAO)daoFactory.getDAO("register");
      transactionList = registerDao.loadTransactionsForPayee(currentPayee.getPayeeID());
    }
   
    TableModel dataModel = new AbstractTableModel() {
      private static final long serialVersionUID = 1;
     
      public int getColumnCount() { return 4; }
     
      public String getColumnName(int columnIndex) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.