private JPanel createDynamicCenterPanel(PrimitiveForm primitiveForm, DOTProperty property) {
    final JTable theTable = new JTable();
    PrimitiveFormPropertyPair pfpPair =
        new PrimitiveFormPropertyPair(primitiveForm.getName(), property);
    _dynamicTables.put(pfpPair, theTable);
    DOTPoint dotPoint = (DOTPoint) _dotDefinitionDialogFrame.getScratchDisplayObjectType();
    final DynamicDOTItemManager tableModel =
        (DynamicDOTItemManager) dotPoint.getTableModel(primitiveForm, property);
    theTable.setModel(tableModel);

    class NumberComparator implements Comparator<Number> {

      public int compare(Number o1, Number o2) {
        final double d1 = o1.doubleValue();
        final double d2 = o2.doubleValue();
        if (d1 < d2) {
          return -1;
        }
        if (d1 == d2) {
          return 0;
        }
        return 1;
      }
    }
    TableRowSorter<DynamicDOTItemManager> tableRowSorter =
        new TableRowSorter<DynamicDOTItemManager>();
    tableRowSorter.setModel(tableModel);
    tableRowSorter.setComparator(4, new NumberComparator());
    tableRowSorter.setComparator(5, new NumberComparator());
    theTable.setRowSorter(tableRowSorter);

    JButton newDOTItemButton = new JButton("Neue Zeile");
    newDOTItemButton.setEnabled(_dotDefinitionDialogFrame.isEditable());
    JButton deleteDOTItemButton = new JButton("Zeile löschen");
    deleteDOTItemButton.setEnabled(false);
    JButton showConflictsButton = new JButton("Zeige Konflikte");

    addButtonListeners(
        primitiveForm, property, newDOTItemButton, deleteDOTItemButton, showConflictsButton);
    addListSelectionListener(theTable, deleteDOTItemButton);

    JPanel dotButtonsPanel = new JPanel();
    dotButtonsPanel.setLayout(new SpringLayout());

    dotButtonsPanel.add(newDOTItemButton);
    dotButtonsPanel.add(deleteDOTItemButton);
    dotButtonsPanel.add(showConflictsButton);

    dotButtonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
    SpringUtilities.makeCompactGrid(dotButtonsPanel, 1, 5, 20);

    JPanel thePanel = new JPanel();
    thePanel.setLayout(new SpringLayout());
    thePanel.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.BLACK));
    thePanel.add(new JScrollPane(theTable));
    thePanel.add(dotButtonsPanel);
    SpringUtilities.makeCompactGrid(thePanel, 2, 20, 5);

    return thePanel;
  }
Esempio n. 2
0
  private void createUIComponents() {
    portFreightTableModel = new FreightTableModel(Game.getInstance().getFreightMarket());
    portFreightTable = new JTable(portFreightTableModel);
    TableRowSorter<FreightTableModel> portTableSorter =
        new TableRowSorter<FreightTableModel>(portFreightTableModel);
    portTableSorter.setRowFilter(new FreightTableModel.PortRowFilter(portProxy));
    portFreightTable.setRowSorter(portTableSorter);

    Company playerCompany = Game.getInstance().getPlayerCompany();
    List<ShipModel> shipsInPortList = playerCompany.findShipsInPort(portProxy);

    shipsInPortListBox = new JList(shipsInPortList.toArray());

    // TODO this is fugly-hacked at the moment.
    FreightTableModel shipFreightTableModel = null;

    if (shipsInPortList.size() > 0) {
      shipFreightTableModel = new FreightTableModel(shipsInPortList.get(0));
    } else {
      shipFreightTableModel = new FreightTableModel(null);
    }

    shipFreightTable = new JTable(shipFreightTableModel);
    TableRowSorter<FreightTableModel> shipTableSorter =
        new TableRowSorter<FreightTableModel>(shipFreightTableModel);
    shipFreightTable.setRowSorter(shipTableSorter);

    nameOfPort = new JLabel();
    nameOfPort.setText(portProxy.getName());
  }
Esempio n. 3
0
 private void filterUsers(final String fragment) {
   table.clearSelection();
   userCertificatePanel.setUserCertificateModel(null);
   if (StringUtils.isEmpty(fragment)) {
     table.setRowSorter(defaultSorter);
     return;
   }
   RowFilter<UserCertificateTableModel, Object> containsFilter =
       new RowFilter<UserCertificateTableModel, Object>() {
         @Override
         public boolean include(
             Entry<? extends UserCertificateTableModel, ? extends Object> entry) {
           for (int i = entry.getValueCount() - 1; i >= 0; i--) {
             if (entry.getStringValue(i).toLowerCase().contains(fragment.toLowerCase())) {
               return true;
             }
           }
           return false;
         }
       };
   TableRowSorter<UserCertificateTableModel> sorter =
       new TableRowSorter<UserCertificateTableModel>(tableModel);
   sorter.setRowFilter(containsFilter);
   table.setRowSorter(sorter);
 }
  public void setValue(Map values, JTable receiveAddrTable) {

    clearValue();
    System.out.println("values.size():" + values.size());
    Set set = values.keySet();
    Iterator iterator = set.iterator();
    int i = 0;
    data = new Object[values.size()][];
    while (iterator.hasNext()) {
      String key = (String) iterator.next();
      String[] row = (String[]) values.get(key);
      data[i] = row;
      i++;
    }

    RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(this);
    receiveAddrTable.setRowSorter(sorter);

    /*TableColumnModel tcm = receiveAddrTable.getColumnModel();
    System.out.println("receivedTable.getColumn()"+tcm.getColumnCount());
    if(tcm.getColumnCount()==6){
      receiveAddrTable.removeColumn(tcm.getColumn(5));
    }*/

    fireTableDataChanged();
  }
  /**
   * Fügt einem Container eine JTable mit den Daten, der Beschriftung und dem Titel hinzu.
   *
   * @param tabs JTabbedPane
   * @param daten Daten
   * @param kopfZeile Beschriftung
   * @param s Titel
   */
  protected static void fuegeJTabelleHinzu(
      Container tabs, Object[][] daten, Object[] kopfZeile, String s) {

    TableModel model =
        new DefaultTableModel(daten, kopfZeile) {
          private static final long serialVersionUID = 1L;

          @SuppressWarnings({"rawtypes", "unchecked"})
          @Override
          public Class getColumnClass(int column) {
            return getValueAt(0, column).getClass();
          }
        };

    JTable jTabelle = new JTable(model);
    jTabelle.getTableHeader().setFont(DiagrammeErsteller.STANDARD2);
    jTabelle.setFont(DiagrammeErsteller.STANDARD3);
    jTabelle.setEnabled(false);
    jTabelle.getTableHeader().setReorderingAllowed(false);
    RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model);
    jTabelle.setRowSorter(sorter);
    if (tabs.getClass() == JTabbedPane.class) {
      JTabbedPane t = (JTabbedPane) tabs;
      t.addTab(
          s,
          new JScrollPane(
              jTabelle,
              JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
              JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED));
    } else {
      tabs.add(new JScrollPane(jTabelle));
    }
  }
Esempio n. 6
0
  private void init(final EncodeTableModel model) {
    setModal(true);
    setTitle("Encode Production Data");

    table.setAutoCreateRowSorter(true);
    table.setModel(model);
    table.setRowSorter(model.getSorter());
    try {
      rowCountLabel.setText(numberFormatter.valueToString(table.getRowCount()) + " rows");
    } catch (ParseException e) {

    }

    table.setRowSelectionAllowed(false);
    table.setColumnSelectionAllowed(false);

    filterTextField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              public void changedUpdate(DocumentEvent e) {
                updateFilter();
              }

              public void insertUpdate(DocumentEvent e) {
                updateFilter();
              }

              public void removeUpdate(DocumentEvent e) {
                updateFilter();
              }
            });
  }
  /**
   * Create the {@link #projectsTableModel}, {@link #projectsTable} and {@link
   * #projectsTableRowSorter}
   */
  private void createProjectsTable() {
    projectsTableModel =
        Utils.createUneditableTableModel(
            "Project",
            "Skipped?",
            "<html>Comp<br>Warn</html>",
            "<html>Comp<br>Err</html>",
            "<html>Link<br>Warn</html>",
            "<html>Link<br>Err</html>",
            "Includes?");
    projectsTable = new JTable(projectsTableModel);
    projectsTable.getTableHeader().setReorderingAllowed(false);

    projectsTableRowSorter = new TableRowSorter<DefaultTableModel>(projectsTableModel);
    projectsTable.setRowSorter(projectsTableRowSorter);

    projectsTable.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
              int viewRow = projectsTable.rowAtPoint(e.getPoint());
              int modelRow = projectsTable.convertRowIndexToModel(viewRow);
              openBuildOutputFrame(buildOutputs.get(modelRow));
            }
          }
        });

    projectsTable.setToolTipText("Double-click to open");
  }
Esempio n. 8
0
  /**
   * @see org.tramper.gui.viewer.Body#displayDocument(org.tramper.doc.SimpleDocument,
   *     org.tramper.doc.Target, int)
   */
  public void displayDocument(SimpleDocument doc, Target target, int documentPart) {
    if (!(doc instanceof Feed)) {
      throw new RuntimeException(doc.getTitle() + " is not a Feed");
    }
    document = (Feed) doc;
    this.target = target;

    feedTable.setModel(document);
    TableRowSorter<TableModel> tableSorter = new TableRowSorter<TableModel>(document);
    feedTable.setRowSorter(tableSorter);

    long indexModel = document.getIndex();
    int indexView = feedTable.convertColumnIndexToView((int) indexModel);
    feedTable.changeSelection(indexView, 0, false, false);
    TableColumnModel model = feedTable.getColumnModel();

    ListTableCellRenderer linkCellRenderer = new ListTableCellRenderer();
    ListTableCellEditor linkCellEditor = new ListTableCellEditor();
    TableColumn descColumn = model.getColumn(2);
    descColumn.setCellRenderer(linkCellRenderer);
    descColumn.setCellEditor(linkCellEditor);

    DateTableCellRenderer dateCellRenderer = new DateTableCellRenderer();
    descColumn = model.getColumn(3);
    descColumn.setCellRenderer(dateCellRenderer);
    descColumn = model.getColumn(4);
    descColumn.setCellRenderer(dateCellRenderer);

    this.initColumnSizes(feedTable);
  }
 public ReceiveAddressDialog(JDialog parent) {
   super(parent, "Receive Addresses", Dialog.ModalityType.DOCUMENT_MODAL);
   setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
   tableModel = new AddressTableModel(columnNames, columnClasses);
   table = new AddressTable(tableModel, columnTypes);
   table.setRowSorter(new TableRowSorter<>(tableModel));
   table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   scrollPane = new JScrollPane(table);
   JPanel tablePane = new JPanel();
   tablePane.setBackground(Color.WHITE);
   tablePane.add(Box.createGlue());
   tablePane.add(scrollPane);
   tablePane.add(Box.createGlue());
   JPanel buttonPane =
       new ButtonPane(
           this,
           10,
           new String[] {"New", "new"},
           new String[] {"Copy", "copy"},
           new String[] {"Edit", "edit"},
           new String[] {"Done", "done"});
   buttonPane.setBackground(Color.white);
   JPanel contentPane = new JPanel();
   contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
   contentPane.setOpaque(true);
   contentPane.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
   contentPane.setBackground(Color.WHITE);
   contentPane.add(tablePane);
   contentPane.add(buttonPane);
   setContentPane(contentPane);
 }
Esempio n. 10
0
  public TabularViewer(final Debugger debugger, final DebuggerListener listener) {
    this.debugger = debugger;
    this.listener = listener;

    frame = new JFrame();

    pauseButton = new JButton("Pause");
    pauseButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (paused) {
              paused = false;
              debugger.play();
              pauseButton.setText("Pause");
            } else {
              paused = true;
              debugger.pause();
              pauseButton.setText("Play");

              data = listener.getData();
              tableModel.setDataVector(data, listener.getHeader());
            }
          }
        });
    frame.add(pauseButton, BorderLayout.NORTH);

    tableModel = new DefaultTableModel();
    tableModel.setColumnIdentifiers(listener.getHeader());
    final JTable table = new JTable(tableModel);
    final TableRowSorter<DefaultTableModel> sorter =
        new TableRowSorter<DefaultTableModel>(tableModel) {
          @Override
          public Comparator<?> getComparator(int column) {
            return new Comparator<String>() {
              @Override
              public int compare(String o1, String o2) {
                if (o1.matches("\\d+") && o2.matches("\\d+")) {
                  return new Integer(Integer.parseInt(o1)).compareTo(Integer.parseInt(o2));
                } else return o1.compareTo(o2);
              }
            };
          }
        };
    table.setRowSorter(sorter);
    frame.add(new JScrollPane(table));
    frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    frame.setSize(400, 600);
    frame.setVisible(true);

    table.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            int row = table.rowAtPoint(e.getPoint());
            listener.debugCallback(
                data, sorter.convertRowIndexToModel(row), table.columnAtPoint(e.getPoint()));
          }
        });
  }
Esempio n. 11
0
  @SuppressWarnings("unchecked")
  public JPanel view(String src_n, String dst_n) {
    List<JPanel> panels = new LinkedList<>();
    LinkedList<String> sorted = new LinkedList<>(data.keySet());
    sorted.sort(String::compareTo);
    for (String k : sorted) {
      Set<Pair<Object, Object>> xxx = data.get(k);
      List<Pair<Object, Object>> table = new LinkedList<>(xxx);

      Object[][] arr = new Object[table.size()][2];
      int i = 0;
      for (Pair<Object, Object> p : table) {
        arr[i][0] = p.first;
        arr[i][1] = p.second;
        i++;
      }
      @SuppressWarnings("serial")
      JTable t =
          new JTable(arr, new Object[] {src_n, dst_n}) {
            @Override
            public Dimension getPreferredScrollableViewportSize() {
              Dimension d = getPreferredSize();
              return new Dimension(d.width, d.height);
            }
          };
      // //t.setRowSelectionAllowed(false);
      // t.setColumnSelectionAllowed(false);
      // MouseListener[] listeners = t.getMouseListeners();
      // for (MouseListener l : listeners) {
      // t.removeMouseListener(l);
      // }
      TableRowSorter<?> sorter = new MyTableRowSorter(t.getModel());

      t.setRowSorter(sorter);
      sorter.allRowsChanged();
      sorter.toggleSortOrder(0);
      t.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
      JPanel p = new JPanel(new GridLayout(1, 1));
      p.add(new JScrollPane(t));
      p.setBorder(
          BorderFactory.createTitledBorder(
              BorderFactory.createEmptyBorder(2, 2, 2, 2), k + "  (" + xxx.size() + " rows)"));
      panels.add(p);
      //	p.setPreferredSize(new Dimension(60, 60));
    }

    /*int x = (int) Math.ceil(Math.sqrt(panels.size()));
    if (x == 0) {
    	return new JPanel();
    }
    JPanel panel = new JPanel(new GridLayout(x, x));
    for (JPanel p : panels) {
    	panel.add(p);
    }
    panel.setBorder(BorderFactory.createEtchedBorder()); */
    return FqlUtil.makeGrid(((List<JComponent>) ((Object) panels)));
  }
Esempio n. 12
0
  private JPanel createTablePanel(boolean away) {
    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    JLabel headerLabel = new JLabel();
    if (away) {
      headerLabel.setText(
          HOVerwaltung.instance().getLanguageString("ifa.statisticsTable.header.away"));
    } else {
      headerLabel.setText(
          HOVerwaltung.instance().getLanguageString("ifa.statisticsTable.header.home"));
    }
    Font boldFont = headerLabel.getFont().deriveFont(headerLabel.getFont().getStyle() ^ Font.BOLD);
    headerLabel.setFont(boldFont);
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.insets = new Insets(10, 10, 3, 10);
    panel.add(headerLabel, gbc);

    final IfaTableModel tblModel = new IfaTableModel();
    tblModel.setData(this.model, away);
    JTable table = new JTable(tblModel);
    IfaTableCellRenderer renderer = new IfaTableCellRenderer();
    table.getColumnModel().getColumn(0).setCellRenderer(renderer);
    table.getColumnModel().getColumn(1).setCellRenderer(renderer);
    table.getColumnModel().getColumn(2).setCellRenderer(renderer);
    table.getColumnModel().getColumn(3).setCellRenderer(renderer);
    table.getColumnModel().getColumn(4).setCellRenderer(renderer);
    table.getColumnModel().getColumn(5).setCellRenderer(renderer);
    table.getColumnModel().getColumn(6).setCellRenderer(renderer);

    TableRowSorter<TableModel> sorter = new SummaryTableSorter<TableModel>(table.getModel());
    table.setRowSorter(sorter);
    sorter.setComparator(
        0,
        new Comparator<Country>() {

          @Override
          public int compare(Country o1, Country o2) {
            return o1.getName().compareTo(o2.getName());
          }
        });
    List<SortKey> list = new ArrayList<SortKey>();
    list.add(new SortKey(5, SortOrder.DESCENDING));
    sorter.setSortKeys(list);

    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridy = 1;
    gbc.weightx = 1;
    gbc.weighty = 1;
    gbc.insets = new Insets(3, 10, 10, 10);
    panel.add(new JScrollPane(table), gbc);

    return panel;
  }
  public synchronized void setModel(StockTable model) {
    // we pass the model to the JTable
    this.table.setModel(model);
    // we set the first column to be larger (it contains the stock_name)
    TableColumn col = table.getColumnModel().getColumn(0);
    col.setPreferredWidth(250);

    // we add a sorter to the JTable (and we listen for sort changes, see below)
    TableRowSorter<StockTable> trs = new TableRowSorter<StockTable>(model);
    trs.addRowSorterListener(new SortListener());

    table.setRowSorter(trs);
  }
Esempio n. 14
0
 protected void do_this_windowActivated(WindowEvent e) {
   DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
   tableModel.setRowCount(0);
   tableModel.setColumnIdentifiers(new Object[] {"书名", "出版社", "出版时间", "丛书类别", "定价"});
   tableModel.addRow(
       new Object[] {"Java从入门到精通(第2版)", "清华大学出版社", "2010-07-01", "软件工程师入门丛书", "59.8元"});
   tableModel.addRow(
       new Object[] {"PHP从入门到精通(第2版)", "清华大学出版社", "2010-07-01", "软件工程师入门丛书", "69.8元"});
   tableModel.addRow(
       new Object[] {"Visual Basic从入门到精通(第2版)", "清华大学出版社", "2010-07-01", "软件工程师入门丛书", "69.8元"});
   tableModel.addRow(
       new Object[] {"Visual C++从入门到精通(第2版)", "清华大学出版社", "2010-07-01", "软件工程师入门丛书", "69.8元"});
   sorter.setModel(tableModel);
   table.setRowSorter(sorter);
 }
Esempio n. 15
0
  public PaymentPanel(List<PaymentVO> vos) {
    paymentVOs = vos;
    tableModel = new PaymentTableModel(vos);
    tableSorter = new TableRowSorter<TableModel>(tableModel);
    paymentTable = new JTable(tableModel);
    paymentTable.setSize(650, 160);

    paymentScrollPane = new JScrollPane(paymentTable);
    paymentScrollPane.setBounds(0, 0, 650, 160);
    paymentTable.setRowSorter(tableSorter);
    PresentationUtil.fitTableColumns(paymentTable);
    this.setBounds(0, 0, 650, 160);
    this.setLayout(null);
    this.add(paymentScrollPane);
  }
Esempio n. 16
0
 private void initView() {
   pageView = new PageView<TOrder>();
   orderOnlineModel = new OrderHistoryModel();
   table = uiFactory.createJTable(orderOnlineModel, this, this, 30, JLabel.CENTER);
   //		table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
   tableJsp = new JScrollPane(table);
   pagingComponent = new PagingComponent();
   pagingComponent.setPageDelegale(this);
   this.add(topPanel(), BorderLayout.NORTH);
   this.add(tableJsp, BorderLayout.CENTER);
   this.add(pagingComponent, BorderLayout.SOUTH);
   // 排序
   TableRowSorter<OrderHistoryModel> tableRowSorter =
       new TableRowSorter<OrderHistoryModel>(orderOnlineModel);
   table.setRowSorter(tableRowSorter);
 }
Esempio n. 17
0
  /**
   * Create and configure a new table using the given model and row sorter.
   *
   * @param name the name of the table
   * @param model the data model for the table
   * @param sorter the row sorter for the table; if null, the table will not be sortable
   * @return the table
   * @throws NullPointerException if name or model are null
   */
  public JTable makeJTable(
      @Nonnull String name,
      @Nonnull TableModel model,
      @Nullable RowSorter<? extends TableModel> sorter) {
    Objects.requireNonNull(name, "the table name must be nonnull");
    Objects.requireNonNull(model, "the table model must be nonnull");
    JTable table = new JTable(model);
    table.setName(name);
    table.setRowSorter(sorter);
    table.getTableHeader().setReorderingAllowed(true);
    table.setColumnModel(new XTableColumnModel());
    table.createDefaultColumnsFromModel();

    addMouseListenerToHeader(table);
    return table;
  }
Esempio n. 18
0
  private void initPrintTable() {

    printTable = new JTable(tableModel);
    printSorter = new TableRowSorter<TableModel>(tableModel);
    printTable.setRowSorter(printSorter);
    TableColumnModel cm = printTable.getColumnModel();
    cm.getColumn(0).setPreferredWidth(40);
    cm.getColumn(1).setPreferredWidth(10);
    cm.getColumn(2).setPreferredWidth(10);
    cm.getColumn(3).setPreferredWidth(100);
    cm.getColumn(4).setPreferredWidth(80);
    cm.getColumn(5).setPreferredWidth(100);
    cm.getColumn(6).setPreferredWidth(140);
    cm.getColumn(7).setPreferredWidth(110);
    printTable.setRowHeight(30);
  }
Esempio n. 19
0
  public test() {
    jTable.setRowSorter(rowSorter);

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(new JLabel("Specify a word to match:"), BorderLayout.WEST);
    panel.add(jtfFilter, BorderLayout.CENTER);

    setLayout(new BorderLayout());
    add(panel, BorderLayout.SOUTH);
    add(new JScrollPane(jTable), BorderLayout.CENTER);

    jtfFilter
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {

              @Override
              public void insertUpdate(DocumentEvent e) {
                String text = jtfFilter.getText();

                if (text.trim().length() == 0) {
                  rowSorter.setRowFilter(null);
                } else {
                  rowSorter.setRowFilter(RowFilter.regexFilter("(?i)" + text));
                }
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                String text = jtfFilter.getText();

                if (text.trim().length() == 0) {
                  rowSorter.setRowFilter(null);
                } else {
                  rowSorter.setRowFilter(RowFilter.regexFilter("(?i)" + text));
                }
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                throw new UnsupportedOperationException(
                    "Not supported yet."); // To change body of generated methods, choose Tools |
                                           // Templates.
              }
            });
  }
Esempio n. 20
0
  /** Creates an instance <tt>PropertiesEditorPanel</tt>. */
  public PropertiesEditorPanel() {
    super(new BorderLayout());

    /**
     * Instantiates the properties table and adds selection model and listener and adds a row sorter
     * to the table model
     */
    ResourceManagementService r = PropertiesEditorActivator.getResourceManagementService();
    String[] columnNames =
        new String[] {r.getI18NString("service.gui.NAME"), r.getI18NString("service.gui.VALUE")};

    propsTable = new JTable(new PropsTableModel(initTableModel(), columnNames));
    propsTable.setRowSorter(new TableRowSorter<TableModel>(propsTable.getModel()));
    propsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    PropsListSelectionListener selectionListener = new PropsListSelectionListener();

    propsTable.getSelectionModel().addListSelectionListener(selectionListener);
    propsTable.getColumnModel().getSelectionModel().addListSelectionListener(selectionListener);

    JScrollPane scrollPane = new JScrollPane(propsTable);
    SearchField searchField = new SearchField("", propsTable);

    buttonsPanel = new ButtonsPanel(propsTable, searchField);

    centerPanel = new TransparentPanel(new BorderLayout());
    centerPanel.add(scrollPane, BorderLayout.CENTER);
    centerPanel.add(buttonsPanel, BorderLayout.EAST);

    JLabel needRestart = new JLabel(r.getI18NString("plugin.propertieseditor.NEED_RESTART"));

    needRestart.setForeground(Color.RED);

    TransparentPanel searchPanel = new TransparentPanel(new BorderLayout(5, 0));

    searchPanel.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
    searchPanel.add(searchField, BorderLayout.CENTER);

    setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
    add(searchPanel, BorderLayout.NORTH);
    add(centerPanel, BorderLayout.CENTER);
    add(needRestart, BorderLayout.SOUTH);
  }
  @Test
  public void testFilteredTable() {
    JTable jTable = new JTable(10, 1);
    TableRowSorter rowSorter = new TableRowSorter(jTable.getModel());
    jTable.setRowSorter(rowSorter);
    RowFilter<TableModel, Integer> rowFilter =
        new RowFilter<TableModel, Integer>() {

          public boolean include(Entry<? extends TableModel, ? extends Integer> entry) {
            return entry.getIdentifier().intValue() % 2 == 0;
          }
        };

    rowSorter.setRowFilter(rowFilter);
    NextRowProvider nextRowProvider = NextRowProviderFactory.getNextFilteredTableRow(jTable);
    for (int i = 0; i < 5; i++) {
      int nextRow = nextRowProvider.getNextRow();
      assertEquals(i * 2, nextRow);
    }
    assertEquals(-1, nextRowProvider.getNextRow());
  }
Esempio n. 22
0
  private void init() {
    // TODO Auto-generated method stub
    pageView = new PageView<TShopCharge>();
    memberQueryShopChargeModel = new MemberQueryShopChargeModel();
    table = uiFactory.createRPJTable(memberQueryShopChargeModel, null, this, 30, JLabel.CENTER);
    // table设置列宽度 AUTO_RESIZE_SUBSEQUENT_COLUMNS 填满父容器  JTable.AUTO_RESIZE_OFF 自适应
    table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
    tableJsp = uiFactory.createJScrollPane(table);
    pagingComponent = new PagingComponent();
    pagingComponent.setPageDelegale(this);

    this.add(this.topPanel(), BorderLayout.NORTH);
    this.add(tableJsp, BorderLayout.CENTER);
    this.add(pagingComponent, BorderLayout.SOUTH);
    this.add(this.initTail(), BorderLayout.SOUTH);

    this.termQuery(1);
    // 排序
    TableRowSorter<MemberQueryShopChargeModel> tableRowSorter =
        new TableRowSorter<MemberQueryShopChargeModel>(memberQueryShopChargeModel);
    table.setRowSorter(tableRowSorter);
  }
Esempio n. 23
0
  private JComponent getPersonnelTable() {
    personnelTable = new JTable(personnelModel);
    personnelTable.setCellSelectionEnabled(false);
    personnelTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

    for (int i = PersonnelTableModel.N_COL - 1; i >= 0; --i) {
      TableColumn column = personnelTable.getColumnModel().getColumn(i);
      if (personnelColumns.contains(Integer.valueOf(i))) {
        column.setPreferredWidth(personnelModel.getColumnWidth(i));
        column.setCellRenderer(new CellRenderer());
      } else {
        personnelTable.removeColumn(column);
      }
    }
    personnelTable.setIntercellSpacing(new Dimension(1, 0));
    personnelTable.setShowGrid(false);
    personnelTable.setRowSorter(personnelSorter);

    JScrollPane pane = new JScrollPane(personnelTable);
    pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    return pane;
  }
  @Override
  public void setModel(ParrotModel model) {
    if (model == null) {
      return;
    }

    model.addParrotModelListener(new TableViewModelListener());

    TableModel tableModel = ((TableParrotModel) model.asListModel()).asTableModel();
    table.setModel(tableModel);
    rowSorter = new TableRowSorter<TableParrotModel>((TableParrotModel) tableModel);

    List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>();
    sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
    sortKeys.add(new RowSorter.SortKey(1, SortOrder.ASCENDING));
    rowSorter.setSortKeys(sortKeys);
    table.setRowSorter(rowSorter);

    popup = new NodeWrapperPopupMenu(SwingUtilities.getRoot(this), model);

    TableCellRenderer cellRenderer = new NodeWrapperRenderer(model);
    table.setDefaultRenderer(NodeWrapper.class, cellRenderer);
  }
Esempio n. 25
0
  protected void initFilters(JTable table) {
    TableRowSorter sorter = new TableRowSorter(table.getModel());
    table.setRowSorter(sorter);

    if (visualsFilter == null) {
      visualsFilter =
          new RowFilter<UIDefaultsTableModel, Integer>() {
            public boolean include(Entry<? extends UIDefaultsTableModel, ? extends Integer> entry) {
              UIDefaultsTableModel model = entry.getModel();
              Object defaultsValue =
                  model.getValueAt(
                      entry.getIdentifier().intValue(), UIDefaultsTableModel.VALUE_COLUMN);

              return defaultsValue instanceof Color
                  || defaultsValue instanceof Font
                  || defaultsValue instanceof Icon;
            }
          };
    }

    if (onlyVisualsCheckBox.isSelected()) {
      sorter.setRowFilter(visualsFilter);
    }
  }
  /**
   * Update the display after filtering
   *
   * @see org.scilab.modules.ui_data.variablebrowser.SimpleVariableBrowser#updateRowFiltering()
   */
  public void updateRowFiltering() {
    if (isSetData == false) {
        /* If the pull of the data has not been done, do it (please) */
      try {
        ScilabInterpreterManagement.synchronousScilabExec("browsevar");
        isSetData = true;
      } catch (InterpreterException e) {
        System.err.println(e);
      }
    }
    VariableBrowserRowTypeFilter rowTypeFilter =
        new VariableBrowserRowTypeFilter(getFilteredTypeValues());
    VariableBrowserRowDataFilter rowDataFilter =
        new VariableBrowserRowDataFilter(getFilteredDataValues());

    List<RowFilter<Object, Object>> filters = new ArrayList<RowFilter<Object, Object>>();
    RowFilter<Object, Object> compoundRowFilter = null;
    filters.add(rowTypeFilter);
    filters.add(rowDataFilter);
    compoundRowFilter = RowFilter.andFilter(filters);

    rowSorter.setRowFilter(compoundRowFilter);
    table.setRowSorter(rowSorter);
  }
Esempio n. 27
0
  public RevenuePendingDialog(RevenuePendingTableModel tm, int modelRow, boolean isEditable) {
    revenueblService = BusinessLogicService.getRevenueblService();

    this.revenuePendingTableModel = tm;

    JLabel[] labels = new JLabel[6];
    for (int i = 0; i < labels.length; i++) {
      labels[i] = new JLabel("", JLabel.CENTER);
      labels[i].setText(LABEL_NAMES[i]);
      labels[i].setBounds(0, 10 + 35 * i, 100, 25);
      this.add(labels[i]);
    }
    textFields = new JTextField[2];
    for (int i = 0; i < textFields.length; i++) {
      textFields[i] = new JTextField();
      textFields[i].setBounds(100, 10 + 35 * i, 150, 25);
      textFields[i].setEnabled(false);
      this.add(textFields[i]);
    }

    JComboBox<String> organizationComboBox = new JComboBox<String>();
    organizationComboBox.addItem("南京市栖霞区中转中心");
    organizationComboBox.addItem("上海市浦东新区中转中心");
    organizationComboBox.setBounds(100, 10 + 35 * 2, 180, 25);
    organizationComboBox.setEnabled(false);
    this.add(organizationComboBox);

    JTextField accountIdTextField = new JTextField();
    accountIdTextField.setBounds(100, 10 + 35 * 3, 180, 25);
    this.add(accountIdTextField);

    RecentDatePickPanel datePickPanel = new RecentDatePickPanel();
    datePickPanel.setBounds(100, 10 + 35 * 3, 200, 25);
    datePickPanel.setEnabled(false);
    this.add(datePickPanel);

    RevenueVO vo = revenuePendingTableModel.getRevenueVO(modelRow);
    textFields[0].setText(vo.getId());
    textFields[1].setText(vo.getCourierId());
    organizationComboBox.setSelectedItem(vo.getOrganization());
    accountIdTextField.setText(vo.getAccountId());
    datePickPanel.setDate(vo.getRevenueDate());

    tableModel = new OrderTableModel(revenueblService, vo.getOrderId());
    TableRowSorter<TableModel> tableSorter = new TableRowSorter<TableModel>(tableModel);
    JTable orderTable = new JTable(tableModel);
    PresentationUtil.fitTableColumns(orderTable);
    orderTable.getTableHeader().setPreferredSize(new Dimension(180, 25));
    orderTable.setSize(250, 125);
    orderTable.setRowSorter(tableSorter);

    JScrollPane OrderScrollPane = new JScrollPane(orderTable);
    OrderScrollPane.setBounds(100, 10 + 35 * 4, 200, 125);
    this.add(OrderScrollPane);

    JLabel costLabel = new JLabel("", JLabel.CENTER);
    costLabel.setText("收款金额");
    costLabel.setBounds(0, 25 + 35 * 7, 100, 25);
    this.add(costLabel);

    JTextField costTextField = new JTextField();
    costTextField.setBounds(100, 25 + 35 * 7, 60, 25);
    costTextField.setEnabled(false);
    this.add(costTextField);

    costTextField.setText("" + vo.getRevenue());

    JButton confirmButton = new JButton("确认");
    confirmButton.setBounds(230, 320, 80, 30);
    confirmButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (!isEditable) {
              RevenuePendingDialog.this.dispose();
              return;
            }

            vo.setAccountId(accountIdTextField.getText());
            revenuePendingTableModel.modify(modelRow, vo);
            RevenuePendingDialog.this.dispose();
            ScreenMessage.putOnScreen(ScreenMessage.SAVE_SUCCESS);
          }
        });
    this.add(confirmButton);
    if (isEditable) {
      JButton cancleButton = new JButton("取消");
      cancleButton.setBounds(140, 320, 80, 30);
      cancleButton.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
              RevenuePendingDialog.this.dispose();
            }
          });
      this.add(cancleButton);
    }
    if (!isEditable) {
      accountIdTextField.setEnabled(false);
    }

    this.setSize(340, 400);
    this.setLayout(new DialogLayoutManager());
    this.setLocationRelativeTo(MainFrame.getMainFrame());
    this.setTitle("收款单");
    this.setModalityType(ModalityType.APPLICATION_MODAL);
    this.setVisible(true);
  }
Esempio n. 28
0
  public ArrivalPendingPanel() {

    tableModel = new ArrivalPendingTableModel();
    tableSorter = new TableRowSorter<TableModel>(tableModel);
    arrivalPendingTable = new JTable(tableModel);
    arrivalPendingTable.setSize(800, 500);
    arrivalPendingTable.setRowSorter(tableSorter);

    arrivalPendingScrollPane = new JScrollPane(arrivalPendingTable);
    arrivalPendingScrollPane.setBounds(0, 0, 650, 390);

    toggleButton = new JToggleButton("批量审批");
    approveButton = new JButton("审批");
    modifyButton = new JButton("修改");
    queryButton = new JButton("详情");

    toggleButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            indexes.clear();
            arrivalPendingTable.clearSelection();
          }
        });
    approveButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            int row = arrivalPendingTable.getSelectedRow();
            if (row == -1) {
              ScreenMessage.putOnScreen(ScreenMessage.NO_CHOOSE_IN_TABLE);
              return;
            }
            int indexesNum = arrivalPendingTable.getSelectedRowCount();
            int[] selectedRows = arrivalPendingTable.getSelectedRows();
            for (int i = 0; i < indexesNum; i++) {
              for (int j = i + 1; j < indexesNum; j++) {
                selectedRows[j] -= 1;
              }
              int firstSelectedRow = selectedRows[i];
              int modelRow = arrivalPendingTable.convertRowIndexToModel(firstSelectedRow);
              tableModel.approve(modelRow);
            }
            ScreenMessage.putOnScreen(ScreenMessage.SAVE_SUCCESS);
            indexes.clear();
            arrivalPendingTable.clearSelection();
          }
        });

    modifyButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            int row = arrivalPendingTable.getSelectedRow();
            if (row == -1) {
              ScreenMessage.putOnScreen(ScreenMessage.NO_CHOOSE_IN_TABLE);
              return;
            }
            int modelRow = arrivalPendingTable.convertRowIndexToModel(row);
            new ArrivalPendingDialog(tableModel, modelRow, true);
          }
        });
    queryButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            int row = arrivalPendingTable.getSelectedRow();
            if (row == -1) {
              ScreenMessage.putOnScreen(ScreenMessage.NO_CHOOSE_IN_TABLE);
              return;
            }
            int modelRow = arrivalPendingTable.convertRowIndexToModel(row);
            new ArrivalPendingDialog(tableModel, modelRow, false);
          }
        });

    arrivalPendingTable.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseReleased(MouseEvent e) {
            if (!toggleButton.isSelected()) return;
            int clicked = arrivalPendingTable.getSelectedRow();
            if (indexes.contains(clicked)) {
              indexes.remove(new Integer(clicked));
            } else {
              indexes.add(clicked);
            }
            arrivalPendingTable.clearSelection();
            for (int i : indexes) {
              arrivalPendingTable.addRowSelectionInterval(i, i);
            }
          }

          @Override
          public void mousePressed(MouseEvent e) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseExited(MouseEvent e) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseEntered(MouseEvent e) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseClicked(MouseEvent e) {}
        });

    toggleButton.setBounds(320, 400, 70, 30);
    approveButton.setBounds(405, 400, 70, 30);
    modifyButton.setBounds(490, 400, 70, 30);
    queryButton.setBounds(575, 400, 70, 30);

    // set panel
    this.setBounds(0, 0, 650, 470);
    this.setLayout(null);
    this.add(arrivalPendingScrollPane);
    this.add(toggleButton);
    this.add(approveButton);
    this.add(modifyButton);
    this.add(queryButton);
  }
  public NetworkTable(Properties display) {
    this.display = display;

    model =
        new GenericTableModel(
            new String[] {" ", "Address", "Label", "Description", "Pivot"}, "Address", 256);
    table = new ATable(model);
    TableRowSorter sorter = new TableRowSorter(model);
    sorter.toggleSortOrder(1);

    Comparator hostCompare =
        new Comparator() {
          public int compare(Object a, Object b) {
            long aa = Route.ipToLong(a + "");
            long bb = Route.ipToLong(b + "");

            if (aa > bb) {
              return 1;
            } else if (aa < bb) {
              return -1;
            } else {
              return 0;
            }
          }

          public boolean equals(Object a, Object b) {
            return (a + "").equals(b + "");
          }
        };

    sorter.setComparator(1, hostCompare);
    sorter.setComparator(4, hostCompare);

    table.setRowSorter(sorter);
    table.setColumnSelectionAllowed(false);

    table.getColumn("Address").setPreferredWidth(125);
    table.getColumn("Label").setPreferredWidth(125);
    table.getColumn("Pivot").setPreferredWidth(125);
    table.getColumn(" ").setPreferredWidth(32);
    table.getColumn(" ").setMaxWidth(32);
    table.getColumn("Description").setPreferredWidth(500);

    final TableCellRenderer parent = table.getDefaultRenderer(Object.class);
    table.setDefaultRenderer(
        Object.class,
        new TableCellRenderer() {
          public Component getTableCellRendererComponent(
              JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
            JLabel component =
                (JLabel)
                    parent.getTableCellRendererComponent(table, value, isSelected, false, row, col);

            if (col == 4 && Boolean.TRUE.equals(model.getValueAt(table, row, "Active"))) {
              component.setFont(component.getFont().deriveFont(Font.BOLD));
            } else if (col == 1 && !"".equals(model.getValueAt(table, row, "Description"))) {
              component.setFont(component.getFont().deriveFont(Font.BOLD));
            } else {
              component.setFont(component.getFont().deriveFont(Font.PLAIN));
            }

            String tip = model.getValueAt(table, row, "Tooltip") + "";

            if (tip.length() > 0) {
              component.setToolTipText(tip);
            }
            return component;
          }
        });

    table
        .getColumn(" ")
        .setCellRenderer(
            new TableCellRenderer() {
              public Component getTableCellRendererComponent(
                  JTable table,
                  Object value,
                  boolean isSelected,
                  boolean hasFocus,
                  int row,
                  int col) {
                JLabel component =
                    (JLabel)
                        parent.getTableCellRendererComponent(
                            table, value, isSelected, false, row, col);
                component.setIcon(new ImageIcon((Image) model.getValueAt(table, row, "Image")));
                component.setText("");

                String tip = model.getValueAt(table, row, "Tooltip") + "";

                if (tip.length() > 0) {
                  component.setToolTipText(tip);
                }

                return component;
              }
            });

    table.addMouseListener(
        new MouseAdapter() {
          public void all(MouseEvent ev) {
            if (ev.isPopupTrigger()) {
              popup.showGraphPopup(getSelectedHosts(), ev);
              ev.consume();
            }
          }

          public void mouseClicked(MouseEvent ev) {
            all(ev);
          }

          public void mousePressed(MouseEvent ev) {
            all(ev);
          }

          public void mouseReleased(MouseEvent ev) {
            all(ev);
          }
        });

    setLayout(new BorderLayout());
    scroller = new JScrollPane(table);
    add(scroller, BorderLayout.CENTER);
  }
  public pnl_wheels_view(int width, int height) {
    setBackground(Color.WHITE);

    setSize(width, height - 30);

    window_width = this.getWidth();
    window_height = this.getHeight();

    setLayout(null);

    tbl_service_details =
        new JTable() {

          private static final long serialVersionUID = 1L;

          protected JTableHeader createDefaultTableHeader() {
            return new JTableHeader(columnModel) {

              private static final long serialVersionUID = 1L;

              public String getToolTipText(MouseEvent e) {
                String tip = null;
                java.awt.Point p = e.getPoint();
                int index = columnModel.getColumnIndexAtX(p.x);

                if (index == 8) {
                  tip = "Enable checkbox if Free checkup is Completed";
                }

                return tip;
              }
            };
          }

          @Override
          public Component prepareRenderer(TableCellRenderer renderer, int row, int col) {
            Component comp = super.prepareRenderer(renderer, row, col);
            int index = (int) getModel().getValueAt(row, 0);
            int due_date = fcd_completed_due_date.get(index - 1);
            if (col == 8) {
              if (due_date == 0) {
                comp.setBackground(Color.LIGHT_GRAY);
              }
            }
            return comp;
          }
        };

    tbl_service_details.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    tbl_service_details.setRowSelectionAllowed(false);
    mdl_service_details =
        new DefaultTableModel() {

          private static final long serialVersionUID = 1L;

          public boolean isCellEditable(int row, int col) {

            if (col == 9) return true;
            else if (col == 8 && fcd_completed_due_date.get((int) getValueAt(row, 0) - 1) != 0)
              return true;
            else return false;
          }

          public Class<?> getColumnClass(int c) {

            if (this.getRowCount() >= 1) {
              return getValueAt(0, c).getClass();
            } else {
              return new String().getClass();
            }
          }
        };

    String[] columns = {
      "S.NO",
      "Customer Name",
      "Mobile No",
      "Vehicle No",
      "Bill Date",
      "Remarks",
      "Particulars",
      "Total",
      "FCD",
      "Info"
    };

    mdl_service_details.setColumnIdentifiers(columns);

    load_all_sbd();

    tbl_service_details.setModel(mdl_service_details);
    tbl_service_details.setFont(new Font("Arial", Font.PLAIN, 14));
    tbl_service_details.setForeground(Color.DARK_GRAY);
    tbl_service_details.setGridColor(Color.BLUE);
    tbl_service_details.setBackground(Color.WHITE);
    tbl_service_details.setRowMargin(5);
    tbl_service_details.setRowHeight(50);

    tbl_service_details.getColumn("Particulars").setCellRenderer(new SubTableRenderer());
    tbl_service_details.getColumn("Customer Name").setCellRenderer(new WrapCellRenderer());
    tbl_service_details.getColumn("Mobile No").setCellRenderer(new WrapCellRenderer());
    tbl_service_details.getColumn("Vehicle No").setCellRenderer(new WrapCellRenderer());
    tbl_service_details.getColumn("Bill Date").setCellRenderer(new WrapCellRenderer());
    tbl_service_details.getColumn("Remarks").setCellRenderer(new WrapCellRenderer());

    Action update_fcd =
        new AbstractAction() {

          private static final long serialVersionUID = 1L;

          @Override
          public void actionPerformed(ActionEvent e) {

            int row = Integer.valueOf(e.getActionCommand());

            int completed_date = fcd_completed_date.get(row);

            int due_date = fcd_completed_due_date.get(row);

            if (due_date > 0) {
              String msg = "";
              if (completed_date > 0) {
                msg =
                    "<html><Table>"
                        + "<tr>"
                        + "<td><font color='green'> FreeCheckup Status </font></td>"
                        + "<td> : </td>"
                        + "<td><font color='green'> Completed </font></td>"
                        + "</tr>"
                        + "<tr>"
                        + "<td><font color='green'> Completed Date </font></td>"
                        + "<td> : </td>"
                        + "<td><font color='green'>"
                        + Time.get_date(completed_date, "dd/MM/yyyy hh:mm:ss a")
                        + " </font></td>"
                        + "</tr>"
                        + "</Table></html>";

              } else if (completed_date == 0) {
                msg =
                    "<html><Table>"
                        + "<tr>"
                        + "<td><font color='red'> FreeCheckup Status </font></td>"
                        + "<td> : </td>"
                        + "<td><font color='red'> Not Completed </font></td>"
                        + "</tr>"
                        + "<tr>"
                        + "<td><font color='red'> Due Date </font></td>"
                        + "<td> : </td>"
                        + "<td><font color='red'>"
                        + Time.get_date(due_date)
                        + " </font></td>"
                        + "</tr>"
                        + "</Table></html>";
              }
              JOptionPane.showMessageDialog(tbl_service_details, msg);
            } else {
              JOptionPane.showMessageDialog(
                  tbl_service_details, " This bill don't have any service which has Free Checkup");
            }
          }
        };

    @SuppressWarnings("unused")
    ButtonColumn buttonColumn = new ButtonColumn(tbl_service_details, update_fcd, 9);

    tbl_service_details.addMouseListener(
        new java.awt.event.MouseAdapter() {
          @Override
          public void mouseClicked(java.awt.event.MouseEvent evt) {

            int col = tbl_service_details.columnAtPoint(evt.getPoint());
            int row = tbl_service_details.rowAtPoint(evt.getPoint());

            ServiceBill obj_service_bill = null;

            int index = (int) tbl_service_details.getValueAt(row, 0) - 1;

            boolean is_fcd_update =
                (col == 8 && fcd_completed_due_date.get(index) > 0) ? true : false;

            if (col == 0 || is_fcd_update) {
              String date_str = tbl_service_details.getValueAt(row, 4).toString();

              obj_service_bill = dbh.get_service_bill(vehicle_id.get(index), date_str);
            }

            if ((col == 0 || is_fcd_update) && obj_service_bill == null) {

              JOptionPane.showMessageDialog(
                  tbl_service_details, "Error while getting service bill object");
              Logger.log.severe(
                  "Error while getting service bill object for service bill id " + index);

            } else if (col == 0) {

              wheel_bill_print obj_wbp = new wheel_bill_print(obj_service_bill.getId());

              obj_wbp.setVisible(true);

            } else if (is_fcd_update) {

              int epoch = (boolean) tbl_service_details.getValueAt(row, col) ? Time.now() : 0;

              fcd_completed_date.set(index, epoch);

              obj_service_bill.setFree_checkup_completed(epoch);
              dbh.update(obj_service_bill);
            }
          }
        });

    JTableHeader obj_jtable_header = tbl_service_details.getTableHeader();
    obj_jtable_header.setBackground(Color.BLUE);
    obj_jtable_header.setForeground(Color.WHITE);
    obj_jtable_header.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 12));

    JScrollPane jsp_service_details = new JScrollPane(tbl_service_details);
    jsp_service_details.setForeground(new Color(102, 153, 255));
    jsp_service_details.setBorder(new MatteBorder(3, 3, 3, 3, (Color) new Color(204, 51, 102)));
    jsp_service_details.setBackground(new Color(204, 102, 153));
    jsp_service_details.setBounds(20, 120, window_width - 40, window_height - 220);
    add(jsp_service_details);

    int tbl_width = jsp_service_details.getWidth();

    tbl_service_details.getColumn("S.NO").setMaxWidth((tbl_width / 100) * 4);
    tbl_service_details.getColumn("Customer Name").setPreferredWidth((tbl_width / 100) * 9);
    tbl_service_details.getColumn("Mobile No").setWidth((tbl_width / 100) * 9);
    tbl_service_details.getColumn("Vehicle No").setWidth((tbl_width / 100) * 7);
    tbl_service_details.getColumn("Bill Date").setWidth((tbl_width / 100) * 10);
    tbl_service_details.getColumn("Remarks").setPreferredWidth((tbl_width / 100) * 8);
    tbl_service_details.getColumn("Total").setMaxWidth((tbl_width / 100) * 8);
    tbl_service_details.getColumn("FCD").setMaxWidth((tbl_width / 100) * 10);
    tbl_service_details.getColumn("Info").setMaxWidth((tbl_width / 100) * 8);
    tbl_service_details.getColumn("Particulars").setPreferredWidth((tbl_width / 100) * 28);

    rowSorter = new TableRowSorter<>(tbl_service_details.getModel());
    tbl_service_details.setRowSorter(rowSorter);

    JPanel pnl_search = new JPanel();
    pnl_search.setBackground(new Color(204, 51, 153));
    pnl_search.setBorder(new MatteBorder(3, 3, 3, 3, (Color) new Color(204, 51, 153)));
    pnl_search.setBounds(20, 95, tbl_width, 30);
    add(pnl_search);
    pnl_search.setLayout(new BoxLayout(pnl_search, BoxLayout.X_AXIS));

    JLabel lbl_search_word = new JLabel("Search Text        ");
    lbl_search_word.setBackground(new Color(204, 153, 0));
    lbl_search_word.setAlignmentX(Component.CENTER_ALIGNMENT);
    pnl_search.add(lbl_search_word);
    lbl_search_word.setForeground(new Color(255, 255, 153));
    lbl_search_word.setFont(new Font("Bitstream Charter", Font.BOLD | Font.ITALIC, 18));

    txt_search_word = new JTextField();
    txt_search_word.setBackground(new Color(255, 255, 255));
    pnl_search.add(txt_search_word);
    txt_search_word.setColumns(10);
    txt_search_word
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void insertUpdate(DocumentEvent e) {

                String text = txt_search_word.getText();

                if (text.trim().length() == 0) {
                  rowSorter.setRowFilter(null);
                } else {
                  rowSorter.setRowFilter(RowFilter.regexFilter("(?i)" + text));
                }
                calculate_total();
              }

              @Override
              public void removeUpdate(DocumentEvent e) {

                String text = txt_search_word.getText();

                if (text.trim().length() == 0) {
                  rowSorter.setRowFilter(null);
                } else {
                  rowSorter.setRowFilter(RowFilter.regexFilter("(?i)" + text));
                }
                calculate_total();
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                throw new UnsupportedOperationException(
                    "Not supported yet."); // To change body of generated methods, choose Tools |
                                           // Templates.
              }
            });

    JPanel pnl_total = new JPanel();
    pnl_total.setBackground(Color.WHITE);
    pnl_total.setBorder(new MatteBorder(3, 3, 3, 3, (Color) new Color(204, 51, 153)));
    pnl_total.setBounds(20, window_height - 105, tbl_width, 40);
    add(pnl_total);
    pnl_total.setLayout(new BoxLayout(pnl_total, BoxLayout.X_AXIS));

    pnl_total.add(Box.createHorizontalGlue());

    lbl_total = new JLabel("Total        ");
    lbl_total.setBackground(new Color(204, 153, 0));
    lbl_total.setAlignmentX(Component.CENTER_ALIGNMENT);
    pnl_total.add(lbl_total);
    lbl_total.setForeground(Color.BLUE);
    lbl_total.setVisible(false);
    lbl_total.setFont(new Font("Bitstream Charter", Font.BOLD | Font.ITALIC, 18));

    btn_toggle_total = new JButton("Show Total");
    btn_toggle_total.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String btn_text = btn_toggle_total.getText();

            if (btn_text.equals("Show Total")) {
              lbl_total.setVisible(true);
              btn_toggle_total.setText("Hide Total");
            } else {
              lbl_total.setVisible(false);
              btn_toggle_total.setText("Show Total");
            }
          }
        });
    pnl_total.add(btn_toggle_total);

    cmb_search_catagory = new JComboBox<String>();
    cmb_search_catagory.setBounds((window_width / 2) - 245, 45, 225, 24);
    cmb_search_catagory.addItem("Vehicle Number");
    cmb_search_catagory.addItem("Customer Name");
    cmb_search_catagory.addItem("Date Period");
    cmb_search_catagory.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (cmb_search_catagory.getSelectedIndex() != 2) {
              load_all_sbd();
              calculate_total();
              jdp_from.setVisible(false);
              jdp_to.setVisible(false);
              txt_search_text.setVisible(true);
            } else {
              jdp_from.setVisible(true);
              jdp_to.setVisible(true);
              txt_search_text.setVisible(false);
            }
          }
        });
    add(cmb_search_catagory);

    jdp_from = new JXDatePicker();
    jdp_from.setDate(Calendar.getInstance().getTime());
    jdp_from.setFormats(new SimpleDateFormat("dd.MM.yyyy"));
    jdp_from.setBounds((window_width / 2), 28, 225, 24);
    jdp_from.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            load_sbd_bw_date_range();
          }
        });
    add(jdp_from);
    jdp_from.setVisible(false);

    jdp_to = new JXDatePicker();
    jdp_to.setDate(Calendar.getInstance().getTime());
    jdp_to.setFormats(new SimpleDateFormat("dd.MM.yyyy"));
    jdp_to.setBounds((window_width / 2), 58, 225, 24);
    jdp_to.setVisible(false);
    jdp_to.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jdp_from.getMonthView().setUpperBound(jdp_to.getDate());
            load_sbd_bw_date_range();
          }
        });
    add(jdp_to);

    txt_search_text = new JTextField();
    txt_search_text.setBorder(new LineBorder(new Color(0, 0, 0)));
    txt_search_text.setBounds((window_width / 2), 45, 225, 24);
    add(txt_search_text);
    txt_search_text
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void insertUpdate(DocumentEvent e) {
                update_filter();
                calculate_total();
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                update_filter();
                calculate_total();
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                update_filter();
                calculate_total();
              }
            });

    calculate_total();

    txt_search_word.setText(Time.get_current_date_time());
  }