Example usage for javax.swing.table TableCellEditor getCellEditorValue

List of usage examples for javax.swing.table TableCellEditor getCellEditorValue

Introduction

In this page you can find the example usage for javax.swing.table TableCellEditor getCellEditorValue.

Prototype

public Object getCellEditorValue();

Source Link

Document

Returns the value contained in the editor.

Usage

From source file:me.paddingdun.gen.code.gui.view.dbtable.TableView.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.//from w  ww. ja v  a 2s  .co  m
 */
// <editor-fold defaultstate="collapsed" desc="Generated
// Code">//GEN-BEGIN:initComponents
private void initComponents() {

    setIconifiable(true);
    setMaximizable(true);
    setResizable(true);
    setTitle("?/");
    fileChooser = new javax.swing.JFileChooser();
    p = new javax.swing.JSplitPane();
    p0t = new javax.swing.JPanel();
    pt = new javax.swing.JSplitPane();
    ptt = new javax.swing.JScrollPane();
    ptb = new javax.swing.JScrollPane();
    ptba = new javax.swing.JPanel();
    pb = new javax.swing.JSplitPane();
    p0b = new javax.swing.JPanel();
    pbt = new javax.swing.JScrollPane();
    pbb = new javax.swing.JScrollPane();
    pbba = new javax.swing.JPanel();

    p.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    pt.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    pb.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

    p.setTopComponent(p0t);
    p.setBottomComponent(p0b);

    p0t.setLayout(new BorderLayout());
    p0t.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "?",
            TitledBorder.LEFT, TitledBorder.DEFAULT_POSITION, null, Color.BLACK));
    p0t.add(pt, BorderLayout.CENTER);
    p0t.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            p.setDividerLocation(p.getHeight() - 40);
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    pt.setDividerLocation(0.38);
                    EventQueue.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            pb.setDividerLocation(1.0d);
                        }
                    });
                }
            });
        }
    });

    p0b.setLayout(new BorderLayout());
    p0b.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "",
            TitledBorder.LEFT, TitledBorder.DEFAULT_POSITION, null, Color.BLACK));
    p0b.add(pb, BorderLayout.CENTER);
    p0b.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            p.setDividerLocation(30);
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    pt.setDividerLocation(1.0d);

                    EventQueue.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            pb.setDividerLocation(0.38);
                        }
                    });
                }
            });
        }
    });

    pt.setTopComponent(ptt);
    pt.setBottomComponent(ptb);

    ptb.setViewportView(ptba);
    ptb.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    pb.setTopComponent(pbt);
    pb.setBottomComponent(pbb);

    pbb.setViewportView(pbba);
    pbb.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    tableColumnTable = new javax.swing.JTable() {
        public void editingStopped(ChangeEvent e) {
            TableCellEditor editor = this.getCellEditor();
            if (editor != null) {
                Object value = editor.getCellEditorValue();
                setTableColumnValue(value);
            }
            // System.out.println(MessageFormat.format("c:{0}-r:{1}",
            // this.getSelectedColumn(), this.getSelectedRow()));
            super.editingStopped(e);
        }
    };
    // ColumnModel?false;
    // table.setAutoCreateColumnsFromModel(false);
    ptt.setViewportView(tableColumnTable);

    /**
     * add by 2016422 ;
     */
    listColumnTable = new javax.swing.JTable() {
        public void editingStopped(ChangeEvent e) {
            TableCellEditor editor = this.getCellEditor();
            if (editor != null) {
                Object value = editor.getCellEditorValue();
                setListColumnValue(value);
            }
            // System.out.println(MessageFormat.format("c:{0}-r:{1}",
            // this.getSelectedColumn(), this.getSelectedRow()));
            super.editingStopped(e);
        }
    };
    listColumnTable.getTableHeader().addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {

        }
    });
    pbt.setViewportView(listColumnTable);

    jLabel1 = new javax.swing.JLabel();
    basePackageName = new javax.swing.JTextField();
    btnGen = new javax.swing.JButton();
    btnListColumnOk = new javax.swing.JButton();
    btnTableColumnOk = new javax.swing.JButton();
    jLabel2 = new javax.swing.JLabel();
    jcombo_sqlMapMarkUse = new javax.swing.JComboBox<Option<Integer>>();
    jLabel3 = new javax.swing.JLabel();
    jLabel4 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    jLabel6 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    jLabel8 = new javax.swing.JLabel();
    jLabel9 = new javax.swing.JLabel();
    jLabel10 = new javax.swing.JLabel();
    jLabel11 = new javax.swing.JLabel();
    jLabel12 = new javax.swing.JLabel();
    jLabel13 = new javax.swing.JLabel();
    jLabel14 = new javax.swing.JLabel();
    jLabel15 = new javax.swing.JLabel();
    jLabel16 = new javax.swing.JLabel();
    columnTitle = new javax.swing.JTextField();
    listTitle = new javax.swing.JTextField();
    jcombo_showGsonAnnotation = new javax.swing.JComboBox<Option<Boolean>>();
    jcombo_queryRenderShow = new javax.swing.JComboBox<Option<Boolean>>();
    jcombo_listRenderShow = new javax.swing.JComboBox<Option<Boolean>>();
    jcombo_editRenderShow = new javax.swing.JComboBox<Option<Boolean>>();
    jcombo_queryRenderWay = new javax.swing.JComboBox<Option<Integer>>();
    jcombo_listRenderWay = new javax.swing.JComboBox<Option<Integer>>();
    jcombo_editRenderWay = new javax.swing.JComboBox<Option<Integer>>();
    saveMethodPrefix = new javax.swing.JTextField();
    updateMethodPrefix = new javax.swing.JTextField();
    getMethodPrefix = new javax.swing.JTextField();
    deleteMethodPrefix = new javax.swing.JTextField();
    queryMethodPrefix = new javax.swing.JTextField();
    queryPagingMethodPrefix = new javax.swing.JTextField();

    queryColumnJson = new javax.swing.JTextArea(1, 10);
    javax.swing.JScrollPane cqpc = new javax.swing.JScrollPane(queryColumnJson);
    // customQueryProperty.setAutoscrolls(true);

    editValueGenWayJson = new javax.swing.JTextArea(1, 10);
    javax.swing.JScrollPane cevfw = new javax.swing.JScrollPane(editValueGenWayJson);

    //      editValidateJson = new javax.swing.JTextArea(1, 10);
    //      javax.swing.JScrollPane evj = new javax.swing.JScrollPane(editValidateJson);

    editValidateEasyuiString = new javax.swing.JTextArea(1, 10);
    javax.swing.JScrollPane evj = new javax.swing.JScrollPane(editValidateEasyuiString);

    jLabel1.setText("??");

    btnGen.setText("?");
    btnTableColumnOk.setText("Ok");
    btnListColumnOk.setText("Ok");

    jLabel2.setText("SQL??");

    // sqlMapMarkUse.setModel(null);

    jLabel3.setText("??");

    jLabel4.setText("?");

    jLabel5.setText("??");

    jLabel6.setText("?");

    jLabel7.setText("?");

    jLabel8.setText("?");

    jLabel9.setText("?gosn");

    jLabel10.setText("?");
    jLabel11.setText("?");

    jLabel12.setText("?");
    jLabel13.setText("?");

    jLabel14.setText("?");
    jLabel15.setText("?");

    jLabel16.setText("");

    TableLayout tableLayout_ptba = new TableLayout();
    double border = 2; // 0 1 2 3 4 5 6
    tableLayout_ptba.setColumn(new double[] { border, 50, 50, 80, -1, 50, 70, border });
    tableLayout_ptba.setRow(new double[] { border, 30, 30, 30, 130, 130, 130, border });
    ptba.setLayout(tableLayout_ptba);

    queryRenderShow.addElement(CollectionHelper.option("", Boolean.TRUE));
    queryRenderShow.addElement(CollectionHelper.option("?", Boolean.FALSE));
    jcombo_queryRenderShow.setModel(queryRenderShow);

    listRenderShow.addElement(CollectionHelper.option("", Boolean.TRUE));
    listRenderShow.addElement(CollectionHelper.option("?", Boolean.FALSE));
    jcombo_listRenderShow.setModel(listRenderShow);

    editRenderShow.addElement(CollectionHelper.option("", Boolean.TRUE));
    editRenderShow.addElement(CollectionHelper.option("?", Boolean.FALSE));
    jcombo_editRenderShow.setModel(editRenderShow);

    CollectionHelper.renderWayOption(queryRenderWay, "query");
    jcombo_queryRenderWay.setModel(queryRenderWay);

    CollectionHelper.renderWayOption(listRenderWay, "list");
    jcombo_listRenderWay.setModel(listRenderWay);

    CollectionHelper.renderWayOption(editRenderWay, "edit");
    jcombo_editRenderWay.setModel(editRenderWay);
    jcombo_editRenderWay.addItemListener(new ItemListener() {

        @SuppressWarnings("unchecked")
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) { //??   
                Option<Integer> o = (Option<Integer>) e.getItem();
                String s = EditValueGenWayHelper.toEditValueShowWayJson(o.getValue());
                editRenderWayJson.setText(s);
            }
        }
    });

    int row = 1;
    ptba.add(new JLabel(""), MessageFormat.format("1,{0},2,{0}", row));
    ptba.add(columnTitle, MessageFormat.format("3,{0},4,{0}", row));
    ptba.add(btnTableColumnOk, MessageFormat.format("6,{0}", row));
    row++;
    ptba.add(jLabel14, MessageFormat.format("1,{0},2,{0}", row));
    ptba.add(jcombo_editRenderShow, MessageFormat.format("3,{0},4,{0}", row));
    ptba.add(btnListColumnOk, MessageFormat.format("6,{0}", row));
    row++;
    ptba.add(jLabel15, MessageFormat.format("1,{0},2,{0}", row));
    ptba.add(jcombo_editRenderWay, MessageFormat.format("3,{0},4,{0}", row));
    row++;
    ptba.add(new JLabel("?"), MessageFormat.format("1,{0},2,{0}", row));
    editRenderWayJson = new javax.swing.JTextArea(1, 10);
    editRenderWayJson.setLineWrap(true);
    editRenderWayJson.setWrapStyleWord(true);
    javax.swing.JScrollPane erwjj = new javax.swing.JScrollPane(editRenderWayJson);
    ptba.add(erwjj, MessageFormat.format("3,{0},6,{0}", row));
    row++;
    JLabel j1 = new JLabel("?");
    j1.setToolTipText("<html>\n" + "<table border=\"1\">\n" + "<tr>\n" + "   <th>?</th>\n"
            + "   <th>??</th>\n" + "</tr>\n" + "<tr>\n" + "   <td>new</td>\n"
            + "   <td>?,\"input\":, \"time\":??, \"nothing\":??</td>\n"
            + "</tr>\n" + "</table>\n" + "</html>");

    ptba.add(j1, MessageFormat.format("1,{0},2,{0}", row));
    ptba.add(cevfw, MessageFormat.format("3,{0},6,{0}", row));
    row++;
    ptba.add(new JLabel("JS?"), MessageFormat.format("1,{0},2,{0}", row));
    ptba.add(evj, MessageFormat.format("3,{0},6,{0}", row));

    // showGsonAnnotation.setModel(null);

    btnGen.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnGenActionPerformed(evt);
        }
    });

    btnListColumnOk.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnListColumnOkActionPerformed(evt);
        }
    });

    btnTableColumnOk.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnTableColumnOkActionPerformed(evt);
        }
    });

    TableLayout tableLayout_pbba = new TableLayout();
    // double border = 2; //0 1 2 3 4 5 6
    tableLayout_pbba.setColumn(new double[] { border, 50, 50, 80, -1, 50, 70, border });
    tableLayout_pbba.setRow(new double[] { border, 30, 30, 30, 30, 30, 130, border });
    pbba.setLayout(tableLayout_pbba);

    row = 1;
    pbba.add(jLabel16, MessageFormat.format("1,{0},2,{0}", row));
    pbba.add(listTitle, MessageFormat.format("3,{0},4,{0}", row));
    pbba.add(btnListColumnOk, MessageFormat.format("6,{0}", row));

    row++;
    pbba.add(jLabel12, MessageFormat.format("1,{0},2,{0}", row));
    pbba.add(jcombo_listRenderShow, MessageFormat.format("3,{0},4,{0}", row));
    row++;
    pbba.add(jLabel13, MessageFormat.format("1,{0},2,{0}", row));
    pbba.add(jcombo_listRenderWay, MessageFormat.format("3,{0},4,{0}", row));

    row++;
    pbba.add(jLabel10, MessageFormat.format("1,{0},2,{0}", row, row));
    pbba.add(jcombo_queryRenderShow, MessageFormat.format("3,{0},4,{0}", row));
    row++;
    pbba.add(jLabel11, MessageFormat.format("1,{0},2,{0}", row));
    pbba.add(jcombo_queryRenderWay, MessageFormat.format("3,{0},4,{0}", row));
    row++;
    pbba.add(new JLabel(""), MessageFormat.format("1,{0},2,{0}", row));
    pbba.add(cqpc, MessageFormat.format("3,{0},6,{0}", row));

    // TableLayout tableLayout_pba = new TableLayout();
    //// double border = 2; //0 1 2 3 4 5 6
    // tableLayout_pba.setColumn(new double[]{border, 50, 50, 80, -1, 50,
    // 70, border});
    // tableLayout_pba.setRow(new double[]{border,30, 30, 30, 30, 30, 30,
    // 30, 30, 30, 30, border});
    // pba.setLayout(tableLayout_pba);
    //
    // pba.add(jLabel1, "1,1,2,1");
    // pba.add(basePackageName, "3,1,5,1");
    // pba.add(btnGen, "6,1");
    //
    // pba.add(jLabel2, "1,2,2,2");
    // pba.add(jcombo_sqlMapMarkUse, "3,2,4,2");
    //
    // pba.add(jLabel9, "1,3,2,3");
    // pba.add(jcombo_showGsonAnnotation, "3,3,4,3");
    //
    // pba.add(jLabel3, "1,4,2,4");
    // pba.add(saveMethodPrefix, "3,4,4,4");
    //
    // pba.add(jLabel4, "1,5,2,5");
    // pba.add(updateMethodPrefix, "3,5,4,5");
    //
    // pba.add(jLabel5, "1,6,2,6");
    // pba.add(getMethodPrefix, "3,6,4,6");
    //
    // pba.add(jLabel6, "1,7,2,7");
    // pba.add(deleteMethodPrefix, "3,7,4,7");
    //
    // pba.add(jLabel7, "1,8,2,8");
    // pba.add(queryMethodPrefix, "3,8,4,8");
    //
    // pba.add(jLabel8, "1,9,2,9");
    // pba.add(queryPagingMethodPrefix, "3,9,4,9");

    sqlMapMarkUse.addElement(CollectionHelper.option("??", 1));
    sqlMapMarkUse.addElement(CollectionHelper.option("??", 2));
    jcombo_sqlMapMarkUse.setModel(sqlMapMarkUse);

    showGsonAnnotation.addElement(CollectionHelper.option("", Boolean.TRUE));
    showGsonAnnotation.addElement(CollectionHelper.option("?", Boolean.FALSE));
    jcombo_showGsonAnnotation.setModel(showGsonAnnotation);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(p, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE,
                    470, Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
            p, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 446,
            Short.MAX_VALUE));

    this.addComponentListener(new java.awt.event.ComponentAdapter() {
        public void componentShown(java.awt.event.ComponentEvent evt) {
            afterShow(evt);
        }
    });

    pack();
}

From source file:pipeline.GUI_utils.JXTablePerColumnFiltering.java

@Override
//Overridden to work around problem with editor returning null value and
//to allow parsing to right object type
public void editingStopped(ChangeEvent e) {
    // Take in the new value
    int editingRow = this.editingRow;
    int editingColumn = this.editingColumn;
    TableCellEditor editor = getCellEditor();
    if (editor != null) {
        if (editingRow > -1 && editingColumn > -1) {
            Object value = editor.getCellEditorValue();
            if (getValueAt(editingRow, editingColumn) instanceof Float && value != null) {
                try {
                    value = Float.parseFloat((String) value);
                    setValueAt(value, editingRow, editingColumn);
                } catch (NumberFormatException ex) {
                    Utils.log("Could not parse " + value + " to float", LogLevel.WARNING);
                }/*  w  ww  .  ja  va  2 s  .  c om*/
            } else if (getValueAt(editingRow, editingColumn) instanceof Double && value != null) {
                try {
                    value = Double.parseDouble((String) value);
                    setValueAt(value, editingRow, editingColumn);
                } catch (NumberFormatException ex) {
                    Utils.log("Could not parse " + value + " to float", LogLevel.WARNING);
                }
            } else if (getValueAt(editingRow, editingColumn) instanceof Integer && value != null) {
                try {
                    value = Integer.parseInt((String) value);
                    setValueAt(value, editingRow, editingColumn);
                } catch (NumberFormatException ex) {
                    Utils.log("Could not parse " + value + " to int", LogLevel.WARNING);
                }
            } else if (value != null) {
                setValueAt(value, editingRow, editingColumn);
            }
            //It might make more sense for update event to be fired by setValueAt,
            //but BeanTableModel does not currently do that
            model.fireTableCellUpdated(editingRow, editingColumn);
        }
        removeEditor();
    }
}