예제 #1
0
  public MenuItemExplorer() {
    tableModel = new BeanTableModel<MenuItem>(MenuItem.class);
    tableModel.addColumn(POSConstants.ID.toUpperCase(), "id"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.NAME.toUpperCase(), "name"); // $NON-NLS-1$
    tableModel.addColumn(
        POSConstants.TRANSLATED_NAME.toUpperCase(), "translatedName"); // $NON-NLS-1$
    tableModel.addColumn(
        POSConstants.PRICE.toUpperCase() + " (" + Application.getCurrencySymbol() + ")",
        "price"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    tableModel.addColumn(POSConstants.VISIBLE.toUpperCase(), "visible"); // $NON-NLS-1$
    tableModel.addColumn(
        POSConstants.DISCOUNT.toUpperCase() + "(%)", "discountRate"); // $NON-NLS-1$ //$NON-NLS-2$
    tableModel.addColumn(POSConstants.FOOD_GROUP.toUpperCase(), "parent"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.TAX.toUpperCase(), "tax"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.SORT_ORDER.toUpperCase(), "sortOrder"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.BUTTON_COLOR.toUpperCase(), "buttonColor"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.TEXT_COLOR.toUpperCase(), "textColor"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.IMAGE.toUpperCase(), "imageData"); // $NON-NLS-1$

    tableModel.addRows(MenuItemDAO.getInstance().findAll());

    table = new JXTable(tableModel);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setRowHeight(30);

    table.setDefaultRenderer(Object.class, new CustomCellRenderer());
    table
        .getColumnModel()
        .getColumn(10)
        .setCellRenderer(
            new DefaultTableCellRenderer() {
              @Override
              public Component getTableCellRendererComponent(
                  JTable table,
                  Object value,
                  boolean isSelected,
                  boolean hasFocus,
                  int row,
                  int column) {
                if (value instanceof Color) {
                  JLabel lblColor = new JLabel("TEXT COLOR", JLabel.CENTER);
                  lblColor.setForeground((Color) value);
                  return lblColor;
                }
                return super.getTableCellRendererComponent(
                    table, value, isSelected, hasFocus, row, column);
              }
            });

    setLayout(new BorderLayout(5, 5));
    add(new JScrollPane(table));

    add(createButtonPanel(), BorderLayout.SOUTH);
    add(buildSearchForm(), BorderLayout.NORTH);
  }
예제 #2
0
  public JXTable createConfigureDecadeDetailsTable(LinkTableModel model) {
    JXTable table = new JXTable();
    table.setCellSelectionEnabled(true);
    table.setFont(monthView.getFont());
    table.setShowGrid(false, false);
    table.setTableHeader(null);

    table.setDefaultRenderer(
        Date.class, createDateRenderer(model.selectAction, monthPaddingBorder, JLabel.CENTER));
    table.setHighlighters(createCurrentDateHighlighters());
    table.setModel(model);
    Component comp = table.prepareRenderer(table.getCellRenderer(1, 1), 1, 1);
    table.setRowHeight(comp.getPreferredSize().height);

    return table;
  }
예제 #3
0
  public JXTable createConfigureMonthDetailsTable(LinkTableModel dateTableModel) {

    JXTable table = new JXTable();
    table.setCellSelectionEnabled(true);
    table.setVisibleRowCount(6);
    table.setFont(monthView.getFont());
    table.setShowGrid(false, false);

    configureDayOfWeeksHeader(table);
    table.setDefaultRenderer(
        Date.class,
        createDateRenderer(dateTableModel.selectAction, paddingBoxBorder, JLabel.TRAILING));

    table.setHighlighters(createCurrentDateHighlighters());
    table.setModel(dateTableModel);
    table.packAll();
    Component comp = table.prepareRenderer(table.getCellRenderer(1, 1), 1, 1);
    table.setRowHeight(comp.getPreferredSize().height);

    return table;
  }