Example usage for javax.swing.table DefaultTableModel getValueAt

List of usage examples for javax.swing.table DefaultTableModel getValueAt

Introduction

In this page you can find the example usage for javax.swing.table DefaultTableModel getValueAt.

Prototype

public Object getValueAt(int row, int column) 

Source Link

Document

Returns an attribute value for the cell at row and column.

Usage

From source file:grupob.TipoProceso.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

    DefaultTableModel modelo = (DefaultTableModel) jTableDistritos.getModel();
    ArrayList<Distrito> listaDistritosPas = listaDistritos;
    for (int i = 0; i < listaDistritosPas.size(); i++) {
        String a = modelo.getValueAt(i, 1).toString();
        String n = modelo.getValueAt(i, 0).toString();
        int num = -1;
        try {//from w  w w . j ava2s .  co  m
            num = Integer.parseInt(a);
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(null,
                    "Error: Ingreso un valor distinto de un numero en la fila: " + (i + 1) + " columna: 2");
            return;
        }
        if (num < 0) {
            JOptionPane.showMessageDialog(null,
                    "Error: Ingreso un numero negativo en la fila: " + (i + 1) + " columna: 2");
            return;
        }
        Distrito s = listaDistritosPas.get(i);
        String co = modelo.getValueAt(i, 2).toString();
        ArrayList<Region> reg = Manager.queryByNameRegion(co);
        Distrito r = new Distrito(s.getId(), reg.get(0).getId(), n, num);
        listaDistritosPas.set(i, r);

    }
    for (int i = 0; i < listaDistritosPas.size(); i++) {
        Distrito rd = listaDistritosPas.get(i);
        if (rd.getId() != 0) {
            Manager.updateDistrito(rd);
        }
    }
    JOptionPane.showMessageDialog(null, "Se Completo de actualizar los distritos");
}

From source file:dataviewer.DataViewer.java

private void transpose(DefaultTableModel model) {
    try {/*w w  w  .j  a v  a2s. c  om*/
        if (model.getColumnCount() == 0) {
            return;
        }
        DefaultTableModel new_model = new DefaultTableModel();

        // if not transposed
        if (!model.getColumnName(0).equals("_field_") && transpose == true) {
            new_model.addColumn("_field_");
            for (int r = 1; r <= model.getRowCount(); ++r) {
                new_model.addColumn("_col_" + r);
            }

            long n = 1;
            for (int c = 0; c < model.getColumnCount(); ++c) {
                Object[] s = new Object[new_model.getColumnCount()];
                String colname = model.getColumnName(c);
                int l = 0;
                s[l++] = colname;
                for (int r = 0; r < model.getRowCount(); ++r) {
                    s[r + l] = model.getValueAt(r, c);
                }
                new_model.addRow(s);
            }
        }
        if (model.getColumnName(0).equals("_field_") && transpose == false) {
            // if transposed
            for (int r = 0; r < model.getRowCount(); ++r) {
                new_model.addColumn(model.getValueAt(r, 0));
            }

            List<Integer> colIdx = new ArrayList();
            for (int c = 0; c < model.getColumnCount(); ++c) {
                if (!model.getColumnName(c).equals("_field_")) {
                    colIdx.add(c);
                }
            }

            for (int c = 0; c < colIdx.size(); ++c) {
                Object[] s = new Object[new_model.getColumnCount()];
                for (int r = 0; r < model.getRowCount(); ++r) {
                    s[r] = model.getValueAt(r, colIdx.get(c));
                }
                new_model.addRow(s);
            }
        }

        renderData(new_model);
    } catch (Exception e) {
        txt_count.setText(e.getMessage());
    }
}

From source file:gdt.jgui.entity.fields.JFieldsEditor.java

private void copy(boolean cut) {
    try {/*from  ww w.ja  v a2 s . c  o  m*/
        JTable table = (JTable) scrollPane.getViewport().getView();
        DefaultTableModel model = (DefaultTableModel) table.getModel();
        ListSelectionModel listModel = table.getSelectionModel();
        int rCnt = table.getRowCount();
        ArrayList<Integer> srl = new ArrayList<Integer>();
        for (int i = 0; i < rCnt; i++)
            if (listModel.isSelectedIndex(i)) {
                srl.add(new Integer(i));
            }
        Integer[] sra = srl.toArray(new Integer[0]);
        ArrayList<String> sl = new ArrayList<String>();
        Properties locator = new Properties();
        locator.setProperty(Locator.LOCATOR_TYPE, LOCATOR_TYPE_FIELD);
        if (cut)
            locator.setProperty(JRequester.REQUESTER_ACTION, ACTION_CUT_FIELDS);
        else
            locator.setProperty(JRequester.REQUESTER_ACTION, ACTION_COPY_FIELDS);
        locator.setProperty(Entigrator.ENTIHOME, entihome$);
        locator.setProperty(EntityHandler.ENTITY_KEY, entityKey$);
        String locator$;
        console.clipboard.clear();
        for (int i = 0; i < rCnt; i++) {
            for (int aSra : sra) {
                if (i == aSra) {
                    locator.setProperty(CELL_FIELD_NAME, (String) model.getValueAt(i, 0));
                    locator.setProperty(Locator.LOCATOR_TITLE, (String) model.getValueAt(i, 0));
                    locator.setProperty(CELL_FIELD_VALUE, (String) model.getValueAt(i, 1));
                    locator$ = Locator.toString(locator);
                    //                System.out.println("FieldsEditor:copy:locator="+locator$);
                    console.clipboard.putString(locator$);
                }
            }
        }
    } catch (Exception e) {
        LOGGER.severe(e.toString());
    }
}

From source file:gtu._work.etc.EnglishTester.java

private void initGUI() {
    try {//w w w  . j  av  a 2  s. c om
        JCommonUtil.defaultToolTipDelay();
        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            jTabbedPane1.setPreferredSize(new java.awt.Dimension(462, 259));

            jTabbedPane1.addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent evt) {
                    // XXX
                    // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
                    jTabbedPane1.requestFocus();// FOCUS TODO
                    // XXX
                    // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
                }
            });
            jTabbedPane1.addKeyListener(new KeyAdapter() {
                public void keyPressed(KeyEvent evt) {
                    System.out.println("2===" + evt.getKeyCode());
                    if (evt.getKeyCode() == 49) {// 0
                        jTabbedPane1.setSelectedIndex(0);
                    }
                    if (evt.getKeyCode() == 50) {// 1
                        jTabbedPane1.setSelectedIndex(1);
                    }
                    if (evt.getKeyCode() == 10) {// enter
                        skipBtnAction();
                    }
                    if (evt.getKeyCode() == 32) {// 
                        removeBtnAction();
                    }
                }
            });
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("english", null, jPanel1, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(420, 141));
                    {
                        englishArea = new JTextArea();
                        jScrollPane1.setViewportView(englishArea);
                        englishArea.setFont(new java.awt.Font("Microsoft JhengHei", 0, 22));
                    }
                }
                {
                    jPanel5 = new JPanel();
                    jPanel1.add(jPanel5, BorderLayout.SOUTH);
                    jPanel5.setPreferredSize(new java.awt.Dimension(402, 65));
                    {
                        skipBtn = new JButton();
                        jPanel5.add(skipBtn);
                        skipBtn.setText("skip");
                        skipBtn.setPreferredSize(new java.awt.Dimension(187, 24));
                        skipBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                skipBtnAction();
                            }
                        });
                    }
                    {
                        removeBtn = new JButton();
                        jPanel5.add(removeBtn);
                        removeBtn.setText("remove");
                        removeBtn.setPreferredSize(new java.awt.Dimension(180, 24));
                        removeBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                removeBtnAction();
                            }
                        });
                    }
                    {
                        questionCountLabel = new JLabel();
                        jPanel5.add(questionCountLabel);
                        questionCountLabel.setPreferredSize(new java.awt.Dimension(47, 21));
                        questionCountLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
                        questionCountLabel.setToolTipText("");
                    }
                    {
                        propCountLabel = new JLabel();
                        jPanel5.add(propCountLabel);
                        propCountLabel.setPreferredSize(new java.awt.Dimension(45, 21));
                        propCountLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
                        propCountLabel.setToolTipText("");
                    }
                    {
                        googleSearchBtn = new JButton();
                        jPanel5.add(googleSearchBtn);
                        googleSearchBtn.setText("<html>GPic</html>");
                        googleSearchBtn.setPreferredSize(new java.awt.Dimension(58, 24));
                        googleSearchBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                try {
                                    String word = currentWordIndex.trim();
                                    ClipboardUtil.getInstance().setContents(word);
                                    word = word.replace(" ", "%20");
                                    URI uri = new URI(
                                            "https://www.google.com.tw/search?num=10&hl=zh-TW&site=imghp&tbm=isch&source=hp&biw=1280&bih=696&q="
                                                    + word);
                                    //URI uri = new URI("http://image.baidu.com/search/index?tn=baiduimage&ps=1&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&word=" + word);
                                    Desktop.getDesktop().browse(uri);
                                } catch (Exception ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        });
                    }
                    {
                        yahooDicBtn = new JButton();
                        jPanel5.add(yahooDicBtn);
                        yahooDicBtn.setText("<html>Dict</html>");
                        yahooDicBtn.setPreferredSize(new java.awt.Dimension(57, 24));
                        yahooDicBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                try {
                                    // URI uri = new
                                    // URI("http://tw.dictionary.yahoo.com/dictionary?p="
                                    // + currentWord.trim());
                                    URI uri = new URI("http://www.dreye.com/axis/ddict.jsp?ver=big5&dod=0102&w="
                                            + currentWordIndex.trim() + "&x=0&y=0");
                                    Desktop.getDesktop().browse(uri);
                                } catch (Exception ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        });
                    }
                    {
                        pickBtn = new JButton();
                        jPanel5.add(pickBtn);
                        pickBtn.setText("<html>+Pick</html>");
                        pickBtn.setPreferredSize(new java.awt.Dimension(60, 24));
                        pickBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                try {
                                    String key = currentWordIndex;
                                    String value = englishProp.getProperty(currentWordIndex);
                                    if (StringUtils.isEmpty(value)) {
                                        JCommonUtil._jOptionPane_showMessageDialog_error(
                                                "add pick failed : no such word => " + key);
                                    } else {
                                        pickProp.setProperty(key, value);
                                        JCommonUtil._jOptionPane_showMessageDialog_info(
                                                "key=" + key + "\nvalue=" + value + "\nsize=" + pickProp.size(),
                                                "??");
                                    }
                                } catch (Exception ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        });
                    }
                    {
                        scanPicBtn = new JButton();
                        scanPicBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                            }
                        });
                        jPanel5.add(scanPicBtn);
                        scanPicBtn.setPreferredSize(new java.awt.Dimension(46, 24));
                        scanPicBtn.addMouseListener(new MouseAdapter() {

                            public void mouseClicked(MouseEvent evt) {
                                if (picDir == null) {
                                    JCommonUtil._jOptionPane_showMessageDialog_error("picDir is null");
                                    return;
                                }

                                if (picSet != null && picSet.size() > 0) {
                                    try {
                                        Desktop.getDesktop().open(picSet.iterator().next());
                                    } catch (IOException e) {
                                        JCommonUtil.handleException(e);
                                    }
                                    return;
                                }

                                try {
                                    String text = currentWordIndex.trim().toLowerCase();
                                    ClipboardUtil.getInstance().setContents(text);
                                    text = text.replace(" ", "%20");
                                    URI uri = new URI(
                                            "https://www.google.com.tw/search?num=10&hl=zh-TW&site=imghp&tbm=isch&source=hp&biw=1280&bih=696&q="
                                                    + text);
                                    //URI uri = new URI("http://image.baidu.com/search/index?tn=baiduimage&ps=1&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&word=" + text);
                                    Desktop.getDesktop().browse(uri);
                                } catch (Exception ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        });
                    }
                    {
                        showChineseOption = new JCheckBox();
                        showChineseOption.setSelected(true);
                        jPanel5.add(showChineseOption);
                    }
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("chinese", null, jPanel2, null);
                jPanel2.setPreferredSize(new java.awt.Dimension(420, 211));
                {
                    showEnglishText = new JTextField();
                    jPanel2.add(showEnglishText, BorderLayout.NORTH);
                    showEnglishText.setEditable(false);
                }
                {
                    jPanel10 = new JPanel();
                    jPanel2.add(jPanel10, BorderLayout.CENTER);
                }
                {
                    answerBtn[0] = new JButton();
                    jPanel10.add(answerBtn[0]);
                    answerBtn[0].setPreferredSize(new java.awt.Dimension(190, 110));
                    answerBtn[0].addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            answerBtnClick(answerBtn[0]);
                        }
                    });
                }
                {
                    answerBtn[1] = new JButton();
                    jPanel10.add(answerBtn[1]);
                    answerBtn[1].setPreferredSize(new java.awt.Dimension(190, 110));
                    answerBtn[1].addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            answerBtnClick(answerBtn[1]);
                        }
                    });
                }
                {
                    answerBtn[2] = new JButton();
                    jPanel10.add(answerBtn[2]);
                    answerBtn[2].setPreferredSize(new java.awt.Dimension(190, 110));
                    answerBtn[2].addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            answerBtnClick(answerBtn[2]);
                        }
                    });
                }
                {
                    answerBtn[3] = new JButton();
                    jPanel10.add(answerBtn[3]);
                    answerBtn[3].setPreferredSize(new java.awt.Dimension(190, 110));
                    answerBtn[3].addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            answerBtnClick(answerBtn[3]);
                        }
                    });
                }
                {
                    for (int ii = 0; ii < 4; ii++) {
                        answerBtn[ii].setFont(new java.awt.Font("", 0, 14));
                    }
                }
            }
            {
                jPanel3 = new JPanel();
                BorderLayout jPanel3Layout = new BorderLayout();
                jPanel3.setLayout(jPanel3Layout);
                jTabbedPane1.addTab("word", null, jPanel3, null);
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel3.add(jScrollPane3, BorderLayout.CENTER);
                    jScrollPane3.setPreferredSize(new java.awt.Dimension(420, 187));
                    {
                        propTable = new JTable();
                        jScrollPane3.setViewportView(propTable);
                        JTableUtil.defaultSetting(propTable);
                        propTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                JPopupMenuUtil.newInstance(propTable)
                                        .addJMenuItem(JTableUtil.newInstance(propTable).getDefaultJMenuItems())
                                        .applyEvent(evt).show();
                            }
                        });
                    }
                }
                {
                    saveBtn = new JButton();
                    jPanel3.add(saveBtn, BorderLayout.SOUTH);
                    saveBtn.setText("save table");
                    saveBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            DefaultTableModel model = JTableUtil.newInstance(propTable).getModel();
                            for (int ii = 0; ii < model.getRowCount(); ii++) {
                                String key = (String) model.getValueAt(ii, 0);
                                String value = (String) model.getValueAt(ii, 1);
                                if (!englishProp.containsKey(key)) {
                                    englishProp.setProperty(key, value);
                                }
                            }
                            try {
                                englishProp.store(new FileOutputStream(englishFile), "comment");
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            JCommonUtil._jOptionPane_showMessageDialog_info("save file ok!  \n" + englishFile);
                        }
                    });
                }
                {
                    queryText = new JTextField();
                    jPanel3.add(queryText, BorderLayout.NORTH);
                    queryText.getDocument()
                            .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() {
                                @Override
                                public void process(DocumentEvent event) {
                                    String text = JCommonUtil.getDocumentText(event);
                                    Pattern pattern = Pattern.compile(text);
                                    Matcher matcher = null;
                                    DefaultTableModel propTableModel = JTableUtil.createModel(false, "english",
                                            "chinese");
                                    for (Enumeration<?> enu = englishProp.propertyNames(); enu
                                            .hasMoreElements();) {
                                        String key = (String) enu.nextElement();
                                        String value = englishProp.getProperty(key);
                                        if (key.contains(text)) {
                                            propTableModel.addRow(new Object[] { key, value });
                                            continue;
                                        }
                                        matcher = pattern.matcher(key);
                                        if (matcher.find()) {
                                            propTableModel.addRow(new Object[] { key, value });
                                            continue;
                                        }
                                    }
                                    propTable.setModel(propTableModel);
                                }
                            }));
                }
            }
            {
                jPanel4 = new JPanel();
                jTabbedPane1.addTab("config", null, jPanel4, null);
                {
                    savePickBtn = new JButton();
                    jPanel4.add(savePickBtn);
                    savePickBtn.setText("save pick");
                    savePickBtn.setPreferredSize(new java.awt.Dimension(116, 40));
                    savePickBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            if (englishFile == null) {
                                File file = new File(//
                                        PropertiesUtil.getJarCurrentPath(EnglishTester.class),
                                        "temp.properties");
                                englishFile = file;
                            }
                            if (pickProp.isEmpty()) {
                                JCommonUtil._jOptionPane_showMessageDialog_error("?!");
                                return;
                            }
                            String fileName = englishFile.getName().replaceAll("\\.properties",
                                    "_bak.properties");
                            File jarWhereFile = PropertiesUtil.getJarCurrentPath(EnglishTester.class);
                            fileName = JCommonUtil._jOptionPane_showInputDialog("save target properties",
                                    fileName);
                            if (StringUtils.isEmpty(fileName)) {
                                JCommonUtil._jOptionPane_showMessageDialog_error("can't save!");
                                return;
                            }
                            if (fileName.equalsIgnoreCase(englishFile.getName())) {
                                JCommonUtil._jOptionPane_showMessageDialog_error(
                                        "??englishFile???");
                                return;
                            }
                            if (!fileName.endsWith(".properties")) {
                                fileName += ".properties";
                            }
                            File newFile = new File(jarWhereFile, fileName);
                            Properties oldProp = new Properties();
                            if (newFile.exists()) {
                                try {
                                    oldProp.load(new FileInputStream(newFile));
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                            oldProp.putAll(pickProp);
                            try {
                                oldProp.store(new FileOutputStream(newFile), "comment");
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            JCommonUtil._jOptionPane_showMessageDialog_info("save file ok!  \n" + newFile);
                        }
                    });
                }
                {
                    saveConfigBtn2 = new JButton();
                    jPanel4.add(saveConfigBtn2);
                    saveConfigBtn2.setText("save config");
                    saveConfigBtn2.setPreferredSize(new java.awt.Dimension(108, 40));
                    saveConfigBtn2.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            saveConfigBtnAction();
                        }
                    });
                }
                {
                    startAllBtn = new JButton();
                    jPanel4.add(startAllBtn);
                    startAllBtn.setText("start all");
                    startAllBtn.setPreferredSize(new java.awt.Dimension(101, 40));
                    startAllBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            Object[] files = fileList.getSelectedValues();
                            if (files == null || files.length == 0) {
                                JCommonUtil
                                        ._jOptionPane_showMessageDialog_error("?properties");
                                return;
                            }
                            Properties allProp = new Properties();
                            Properties prop = new Properties();
                            for (Object ff : files) {
                                try {
                                    prop.load(new FileInputStream((File) ff));
                                } catch (Exception e) {
                                    JCommonUtil.handleException(e);
                                }
                                allProp.putAll(prop);
                            }
                            englishProp = allProp;
                            System.out.println("englishProp = " + englishProp.size());
                            startNow();
                        }
                    });
                }
                {
                    startNow = new JButton();
                    jPanel4.add(startNow);
                    startNow.setText("start now");
                    startNow.setPreferredSize(new java.awt.Dimension(101, 40));

                    startNow.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            startNow();
                        }
                    });
                }
                {
                    picOnly = new JCheckBox();
                    jPanel4.add(picOnly);
                    picOnly.setText("picOnly");
                }
                {
                    sortChkBox = new JCheckBox();
                    jPanel4.add(sortChkBox);
                    sortChkBox.setText("sort");
                }
                {
                    showPicChkBox = new JCheckBox();
                    showPicChkBox.setSelected(true);
                    jPanel4.add(showPicChkBox);
                    showPicChkBox.setText("showPic");
                }
                {
                    JCommonUtil.defaultToolTipDelay();
                    fontSizeSliber = new JSlider(JSlider.HORIZONTAL);
                    jPanel4.add(fontSizeSliber);
                    fontSizeSliber.setPreferredSize(new java.awt.Dimension(419, 35));
                    fontSizeSliber.setValue(22);
                    fontSizeSliber.setMinimum(22);
                    fontSizeSliber.setMaximum(300);
                    fontSizeSliber.setMajorTickSpacing(30);
                    fontSizeSliber.setMinorTickSpacing(5);
                    fontSizeSliber.setCursor(new Cursor(Cursor.HAND_CURSOR));
                    fontSizeSliber.setPaintTicks(false);
                    fontSizeSliber.setPaintLabels(true);
                    {
                        picFolderDirText = new JTextField();
                        JCommonUtil.jTextFieldSetFilePathMouseEvent(picFolderDirText, true);
                        jPanel4.add(picFolderDirText);
                        picFolderDirText.setColumns(20);
                    }
                    fontSizeSliber.addChangeListener(new ChangeListener() {
                        @Override
                        public void stateChanged(ChangeEvent e) {
                            int size = fontSizeSliber.getValue();
                            fontSizeSliber.setToolTipText("" + size);
                            englishArea.setFont(new java.awt.Font("Microsoft JhengHei", 0, size));
                        }
                    });

                }
            }
            {
                jPanel6 = new JPanel();
                jTabbedPane1.addTab("files", null, jPanel6, null);
                BorderLayout jPanel6Layout = new BorderLayout();
                jPanel6.setLayout(jPanel6Layout);
                {
                    jScrollPane4 = new JScrollPane();
                    jPanel6.add(jScrollPane4, BorderLayout.CENTER);
                    jScrollPane4.setPreferredSize(new java.awt.Dimension(420, 211));
                    {
                        fileList = new JList();
                        reloadFileList();
                        jScrollPane4.setViewportView(fileList);
                        fileList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                final File file = JListUtil.getLeadSelectionObject(fileList);
                                if (JMouseEventUtil.buttonRightClick(1, evt)) {
                                    JPopupMenuUtil.newInstance(EnglishTester.this.fileList).applyEvent(evt)//
                                            .addJMenuItem("reload", new ActionListener() {
                                                @Override
                                                public void actionPerformed(ActionEvent e) {
                                                    reloadFileList();
                                                }
                                            })//
                                            .addJMenuItem("delete : " + file.getName(), new ActionListener() {
                                                @Override
                                                public void actionPerformed(ActionEvent e) {
                                                    boolean result = JCommonUtil
                                                            ._JOptionPane_showConfirmDialog_yesNoOption(
                                                                    "delete : " + file.getName() + " ?",
                                                                    "confirm");
                                                    if (result) {
                                                        file.delete();
                                                        reloadFileList();
                                                    }
                                                }//
                                            }).show();
                                    return;
                                }
                                if (evt.getClickCount() == 1) {
                                    return;
                                }
                                if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption(
                                        "?,?\n" + file.getName(),
                                        "")) {
                                    loadEnglishFile(file);
                                }
                            }
                        });
                        fileList.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                JListUtil.newInstance(fileList).defaultJListKeyPressed(evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel9 = new JPanel();
                jTabbedPane1.addTab("pic", null, jPanel9, null);
                {
                    picCheckText = new JTextField();
                    jPanel9.add(picCheckText);
                    picCheckText.setPreferredSize(new java.awt.Dimension(177, 39));
                }
                {
                    picCheckBtn = new JButton();
                    jPanel9.add(picCheckBtn);
                    picCheckBtn.setText("check");
                    picCheckBtn.setPreferredSize(new java.awt.Dimension(98, 43));
                    {
                        jPanel11 = new JPanel();
                        jTabbedPane1.addTab("", null, jPanel11, null);
                        jPanel11.setLayout(new BorderLayout(0, 0));
                        {
                            inputTestArea2 = new JTextArea();
                            inputTestArea2.setFont(new Font("", Font.PLAIN, 12));
                            inputTestArea2.addKeyListener(new KeyAdapter() {
                                @Override
                                public void keyReleased(KeyEvent e) {
                                    inputTestTrainer.keyin(e);
                                }
                            });
                            jPanel11.add(inputTestArea2, BorderLayout.SOUTH);
                        }
                        {
                            inputTestArea1 = new JTextArea();
                            JTextAreaUtil.setWrapTextArea(inputTestArea1);
                            inputTestArea1.setFont(new Font("", Font.PLAIN, 22));
                            jPanel11.add(inputTestArea1, BorderLayout.CENTER);
                        }
                        {
                            panel = new JPanel();
                            jPanel11.add(panel, BorderLayout.NORTH);
                            {
                                inputTestLabel = new JLabel("");
                                panel.add(inputTestLabel);
                            }
                            {
                                inputTestChk = new JCheckBox("");
                                inputTestChk.addActionListener(new ActionListener() {
                                    public void actionPerformed(ActionEvent e) {
                                        inputTestTrainer.initQuestion();
                                    }
                                });
                                panel.add(inputTestChk);
                            }
                        }
                    }
                    picCheckBtn.addActionListener(new ActionListener() {
                        void scanPic(String searchWord, File file, Set<File> findFile) {
                            if (file.isDirectory()) {
                                File[] list = null;
                                if ((list = file.listFiles()) != null) {
                                    for (File f : list) {
                                        scanPic(searchWord, f, findFile);
                                    }
                                }
                            } else {
                                String text = searchWord;
                                String name = file.getName().toLowerCase();
                                if (isMatch(name, text)) {
                                    findFile.add(file);
                                }
                            }
                        }

                        public void actionPerformed(ActionEvent evt) {
                            picDir = new File(picFolderDirText.getText());
                            if (picDir == null) {
                                JCommonUtil._jOptionPane_showMessageDialog_error("picDir is null");
                                return;
                            }
                            if (!picDir.exists() || !picDir.isDirectory()) {
                                JCommonUtil._jOptionPane_showMessageDialog_error("picDir ");
                                return;
                            }

                            picCheckBtn.setText("search..");

                            String searchWord = picCheckText.getText().toLowerCase().trim();

                            Set<File> picSet2 = new HashSet<File>();
                            scanPic(searchWord, picDir, picSet2);

                            if (picSet2 != null && picSet2.size() > 0) {
                                picCheckBtn.setText("" + picSet2.size());

                                try {
                                    Desktop.getDesktop().open(picSet2.iterator().next());
                                } catch (IOException e) {
                                    JCommonUtil.handleException(e);
                                }
                            } else {
                                picCheckBtn.setText("0");
                            }
                        }
                    });
                }
            }
        }

        JCommonUtil.setJFrameIcon(this, "resource/images/ico/english_tester.ico");

        pack();
        this.setSize(423, 314);

        configHelper.init();
    } catch (Exception e) {
        // add your error handling code here
        e.printStackTrace();
    }
}

From source file:front.TestTable.java

public TestTable(Controller cont, int[][] response, float[] vec, float rango, int cantIntervalos) {

    controller = cont;/* w w w. ja  v  a  2s  .  c  om*/
    contador = response.length;
    initComponents();

    DecimalFormat in = new DecimalFormat("0.00");
    DecimalFormat aleat = new DecimalFormat("0.0000");
    DecimalFormat c = new DecimalFormat("0.000");
    int contador = 0;
    int frecEsp = (int) vec.length / cantIntervalos;
    double rangoM;
    float[][] matrizIntervalos = new float[cantIntervalos][2];
    double[] estadisticoParcial = new double[cantIntervalos];
    DefaultTableModel tm = (DefaultTableModel) table.getModel();

    for (int i = 0; i < response.length; i++) {
        if (i == 0) {
            rangoM = rango;
            tm.addRow(new Object[] { "0.00 - " + in.format(rangoM), i, response[i][1], frecEsp,
                    c.format(estadisticoPrueba(response, frecEsp, i)) });
            contador++;
            matrizIntervalos[0][0] = 0;
            matrizIntervalos[0][1] = (float) rangoM;

        } else {
            if (contador == 1) {
                tm.addRow(new Object[] { in.format(rango) + " - " + in.format(rango + rango), i, response[i][1],
                        frecEsp, c.format(estadisticoPrueba(response, frecEsp, i)) });

                matrizIntervalos[i][0] = rango;
                matrizIntervalos[i][1] = (float) rango + rango;
                contador++;

            } else {
                tm.addRow(new Object[] {
                        in.format(rango * contador) + " - " + in.format((rango * contador) + rango), i,
                        response[i][1], frecEsp, c.format(estadisticoPrueba(response, frecEsp, i)) });
                matrizIntervalos[i][0] = rango * contador;
                matrizIntervalos[i][1] = (rango * contador) + rango;
                contador++;
            }

        }
    }

    if (frecEsp < 5) {
        DefaultTableModel tm2 = (DefaultTableModel) tablaFe.getModel();
        double estadisticoTotal = 0;
        int frecEspAcumulada = 0;
        int frecObsAcumulada = 0;
        int inicio = 0;
        float a = 0;

        for (int i = 0; i < tm.getRowCount(); i++) {
            frecEspAcumulada += (int) tm.getValueAt(i, 2);
            frecObsAcumulada += (int) tm.getValueAt(i, 1);

            if (frecEspAcumulada >= 5) {
                estadisticoParcial[i] += estadisticoPrueba2(frecObsAcumulada, (int) frecEspAcumulada);
                tm2.addRow(new Object[] {
                        in.format(matrizIntervalos[inicio][0]) + " - " + in.format(matrizIntervalos[i][1]),
                        (int) frecObsAcumulada, frecEspAcumulada, c.format(estadisticoParcial[i]) });
                a = matrizIntervalos[inicio][0];
                inicio = i + 1;

                frecEspAcumulada = 0;
                frecObsAcumulada = 0;
            } else {
                if (i == tm.getRowCount() - 1) {
                    int filaAUnir = tm2.getRowCount() - 1;
                    //actualizo intervalo
                    tm2.setValueAt(in.format(a) + " - " + in.format(matrizIntervalos[i][1]), filaAUnir, 0);
                    //frec observada
                    tm2.setValueAt(frecObsAcumulada + (int) tm2.getValueAt(filaAUnir, 1), filaAUnir, 1);
                    //frec esperada
                    tm2.setValueAt(frecEspAcumulada + (int) tm2.getValueAt(filaAUnir, 2), filaAUnir, 2);

                    int frecObsUltima = (int) tm2.getValueAt(filaAUnir, 1);
                    int frecEspUltima = (int) tm2.getValueAt(filaAUnir, 2);

                    estadisticoParcial[i - 1] = estadisticoPrueba2(frecObsUltima, frecEspUltima);
                    tm2.setValueAt(estadisticoParcial[i - 1], filaAUnir, 3);
                    break;
                }
            }
        }

        for (int i = 0; i < estadisticoParcial.length; i++) {
            estadisticoTotal += estadisticoParcial[i];
        }
        txt_gradosNuevo.setText("" + gradosLibertad(tm2.getRowCount()));
        txt_estadisticoNuevo.setText("" + c.format(estadisticoTotal));
    }
    //para mostrar los valores generados
    String acum = "";
    for (int i = 0; i < vec.length; i++) {
        acum += "Valor " + (i + 1) + ": " + aleat.format(vec[i]) + ".\n";
    }
    txt_valoresGenerados.setText(acum);

    //para el calculo de mi estadistico de prueba total
    txt_estadistico.setText("" + c.format(estadisticoPruebaTotal(response, frecEsp)));
    txt_grados.setText("" + gradosLibertad(cantIntervalos));

    valoresGenerados = vec;
    this.cantIntervalos = cantIntervalos;
    agregarHistograma();

}

From source file:org.agmip.ui.afsirs.frames.SWFrame.java

private void soilNameComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_soilNameComboActionPerformed

    // TODO add your handling code here:
    if (isInitializing)
        return;/*from  w ww. ja v a  2 s.c om*/

    int index = soilNameCombo.getSelectedIndex();
    if (index == -1)
        return;
    //index = index ==-1? 0 : index;
    SoilData soilData = utils.getSoilData();
    String key = (String) soilFileListCombo.getSelectedItem();
    key = key.trim();
    ArrayList<Soil> soilList = soilData.getSoilsFromFile(key);

    if (soilList.size() > 0) {

        if (index == -1) {

            // TODO add your handling code here:
            DefaultTableModel model = (DefaultTableModel) soilTable.getModel();
            int row = model.getRowCount();
            for (int i = 0; i < row; i++) {
                model.removeRow(0);
            }
            index = 0;
            Soil soil = soilList.get(index);
            for (int i = 0; i < soil.getNL(); i++) {
                Object[] vec = new Object[4];
                vec[0] = i + 1;
                vec[1] = soil.getDU()[i];
                vec[2] = soil.getWC()[i];
                vec[3] = soil.getWCU()[i] - soil.getWCL()[i];
                model.addRow(vec);

            }
        } else {

            // This is to take the backup of the data so that I can 

            //Soil soil = soilList.get(selectedSoilIndex);
            DefaultTableModel model = (DefaultTableModel) soilTable.getModel();

            if (prevSoil != null) {
                for (int i = 0; i < model.getRowCount(); i++) {
                    prevSoil.getDU()[i] = (Double) model.getValueAt(i, 1);
                    prevSoil.getWC()[i] = (Double) model.getValueAt(i, 2);
                }
            }

            int row = model.getRowCount();
            for (int i = 0; i < row; i++) {
                model.removeRow(0);
            }

            Soil soil = soilList.get(index);

            DU = soil.getDU();
            WCL = soil.getWCL();
            WCU = soil.getWCU();
            WC = soil.getWC();
            NL = soil.getNL();
            SNAME = soil.getName();
            utils.setDefaultSoil(soil);

            for (int i = 0; i < soil.getNL(); i++) {
                Object[] vec = new Object[4];
                vec[0] = i + 1;
                vec[1] = soil.getDU()[i];
                vec[2] = soil.getWC()[i];
                vec[3] = (WCU[i] - WCL[i]);
                model.addRow(vec);

            }

            prevSoil = soil;
        }

    }
    //selectedSoilIndex = index;
}

From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowserAdvancedFilter.java

public void saveSelections() {
    DefaultTableModel contentSearchModel = ((DefaultTableModel) contentSearchTable.getModel());
    DefaultTableModel metaDataSearchModel = ((DefaultTableModel) metaDataSearchTable.getModel());
    ItemSelectionTableModel<Integer, String> connectorModel = ((ItemSelectionTableModel<Integer, String>) connectorTable
            .getModel());//from   w  w w  . jav a  2s .  c om

    cachedSettings.clear();

    cachedSettings.put("messageIdLowerField", messageIdLowerField.getText());
    cachedSettings.put("messageIdUpperField", messageIdUpperField.getText());
    cachedSettings.put("originalIdLowerField", originalIdLowerField.getText());
    cachedSettings.put("originalIdUpperField", originalIdUpperField.getText());
    cachedSettings.put("importIdLowerField", importIdLowerField.getText());
    cachedSettings.put("importIdUpperField", importIdUpperField.getText());
    cachedSettings.put("serverIdField", serverIdField.getText());
    cachedSettings.put("sendAttemptsLower", sendAttemptsLower.getValue());
    cachedSettings.put("sendAttemptsUpper", sendAttemptsUpper.getValue());
    cachedSettings.put("attachment", attachmentCheckBox.isSelected());
    cachedSettings.put("error", errorCheckBox.isSelected());

    Object[][] contentSearchData = new Object[contentSearchModel.getRowCount()][contentSearchModel
            .getColumnCount()];
    for (int row = 0; row < contentSearchModel.getRowCount(); row++) {
        for (int column = 0; column < contentSearchModel.getColumnCount(); column++) {
            contentSearchData[row][column] = contentSearchModel.getValueAt(row, column);
        }
    }
    cachedSettings.put("contentSearchTable", contentSearchData);

    Object[][] metaDataSearchData = new Object[metaDataSearchModel.getRowCount()][metaDataSearchModel
            .getColumnCount()];
    for (int row = 0; row < metaDataSearchModel.getRowCount(); row++) {
        for (int column = 0; column < metaDataSearchModel.getColumnCount(); column++) {
            metaDataSearchData[row][column] = metaDataSearchModel.getValueAt(row, column);
        }
    }
    cachedSettings.put("metaDataSearchTable", metaDataSearchData);

    Boolean[] connectorData = new Boolean[connectorModel.getRowCount()];
    for (int row = 0; row < connectorModel.getRowCount(); row++) {
        connectorData[row] = (Boolean) connectorModel.getValueAt(row, ItemSelectionTableModel.CHECKBOX_COLUMN);
    }

    cachedSettings.put("connectorTable", connectorData);
}

From source file:org.agmip.ui.afsirs.frames.SWFrame.java

private void nextButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextButtonActionPerformed
    if (soilTable.isEditing()) {
        soilTable.getCellEditor().stopCellEditing();
    }//from  ww w .j ava  2  s  .com

    wcErrorLabel.setVisible(false);
    errorLabel.setVisible(false);
    soilNameLabel.setForeground(Color.black);
    soilTextureLabel.setForeground(Color.black);
    dwtLabel.setForeground(Color.black);

    boolean isFailed = false;
    int ISOIL = soilListBox.getSelectedIndex();
    if (jRadioKeyboard.isSelected()) {

        if (soilNameText.getText().length() < 1) {
            //if (soilNameCombo.getItemAt(0).length() < 1) {
            isFailed = true;
            soilNameLabel.setForeground(Color.red);
        }

        if (soilTextureText.getText().length() < 1) {
            isFailed = true;
            soilTextureLabel.setForeground(Color.red);
        }

        DefaultTableModel model = (DefaultTableModel) soilTable.getModel();
        int nl = NLComboBox.getSelectedIndex() + 1;
        if (nl != model.getRowCount()) {
            isFailed = true;
        }
    }

    if (dwtText.isEnabled()) {
        try {
            DWT = Double.parseDouble(dwtText.getText());
        } catch (NumberFormatException e) {
            dwtLabel.setForeground(Color.red);
            isFailed = true;
        }
        if (DWT < 0.01) {
            dwtLabel.setForeground(Color.red);
            isFailed = true;
        }
    }

    //@rohit_note: Data needs to be taken based on the selection from UI Map/File/Keyboard. For eg. If this is file/Keyboard
    // Then Take the data from the controls/ else if it is Map then take the data from the json File. 
    SNAME = soilNameText.getText();
    TXT[0] = soilTextureText.getText();
    DefaultTableModel model = (DefaultTableModel) soilTable.getModel();
    SoilData soilData = utils.getSoilData();

    if (soilData == null) {
        soilData = new SoilData();
        utils.setSoilData(soilData);
    }

    try {

        for (int i = 0; i < NL; i++) {
            DU[i] = (Double) model.getValueAt(i, 1);
            WC[i] = (Double) model.getValueAt(i, 2);

            if (jRadioButtonSavedLocation.isSelected()) {
                ArrayList<Soil> soilList = soilData
                        .getSoilsFromFile((String) soilFileListCombo.getSelectedItem());
                soilData.setKey((String) soilFileListCombo.getSelectedItem());
                if (soilList != null) {
                    Soil soil = soilList.get(soilNameCombo.getSelectedIndex());
                    soil.getDU()[i] = DU[i];
                    soil.getWC()[i] = WC[i];
                    utils.setDefaultSoil(soil);
                }
            } else if (WC[i] < 0.01 || WC[i] > 0.9) {
                isFailed = true;
                wcErrorLabel.setVisible(true);
            }
        }
    } catch (Exception e) {
        isFailed = true;
        errorLabel.setVisible(true);
    }

    if (isFailed) {
        return;
    }

    if (jRadioKeyboard.isSelected() || jRadioFile.isSelected()) {
        // The Soil name will be Empty
        Soil soil = new Soil(ISOIL, SNAME, "", "", SNAME, NL);
        soil.setValues(WC, WCL, WCU, DU, TXT);
        soilData.addSoil(jRadioKeyboard.isSelected() ? Messages.KEYBOARD_KEY : Messages.FILE_KEY, soil);
        utils.setSoilData(soilData);
        utils.setDefaultSoil(soil);

    }

    //Define Lower Soil Layer Dimensions
    utils.setDWT(DWT);

    setVisible(false);
    if (soilDataNext != null) {
        soilDataNext.setVisible(true);
    } else {
        if (utils.getPerennial()) {
            DCOEFPerennialFrame nextFrame = new DCOEFPerennialFrame(this);
            nextFrame.setVisible(true);
            soilDataNext = nextFrame;
        } else {
            DCOEFAnnualFrame nextFrame = new DCOEFAnnualFrame(this);
            nextFrame.setVisible(true);
            soilDataNext = nextFrame;
        }
    }

    //finish.setVisible(true);
}

From source file:gtu._work.etc.GoogleContactUI.java

void googleTableMouseClicked(MouseEvent evt) {
    try {/*from   w w  w .j  av  a  2  s .  co  m*/
        JPopupMenuUtil popupUtil = JPopupMenuUtil.newInstance(googleTable).applyEvent(evt);

        //CHANGE ENCODE
        popupUtil.addJMenuItem("set encode", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    String code = StringUtils.defaultString(JOptionPaneUtil.newInstance().iconPlainMessage()
                            .showInputDialog("input file encode", "ENCODE"), "UTF8");
                    encode = Charset.forName(code).displayName();
                } catch (Exception ex) {
                    JCommonUtil.handleException(ex);
                }
                System.err.println("encode : " + encode);
            }
        });

        //SIMPLE LOAD GOOGLE CSV FILE
        popupUtil.addJMenuItem("open Google CSV file", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                File file = JFileChooserUtil.newInstance().selectFileOnly().addAcceptFile("csv", ".csv")
                        .showOpenDialog().getApproveSelectedFile();
                if (file == null) {
                    errorMessage("file is not correct!");
                    return;
                }
                try {
                    if (file.getName().endsWith(".csv")) {
                        DefaultTableModel model = (DefaultTableModel) googleTable.getModel();
                        LineNumberReader reader = new LineNumberReader(
                                new InputStreamReader(new FileInputStream(file), GOOGLE_CVS_ENCODE));
                        for (String line = null; (line = reader.readLine()) != null;) {
                            if (reader.getLineNumber() == 1) {
                                continue;
                            }
                            model.addRow(line.split(","));
                        }
                        reader.close();
                        googleTable.setModel(model);
                        JTableUtil.newInstance(googleTable).hiddenAllEmptyColumn();
                    }
                } catch (Exception ex) {
                    JCommonUtil.handleException(ex);
                }
            }
        });

        //SAVE CSV FILE FOR GOOGLE
        popupUtil.addJMenuItem("save to Google CVS file", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                File file = JFileChooserUtil.newInstance().selectFileOnly().addAcceptFile(".csv", ".csv")
                        .showSaveDialog().getApproveSelectedFile();
                if (file == null) {
                    errorMessage("file is not correct!");
                    return;
                }
                file = FileUtil.getIndicateFileExtension(file, ".csv");
                try {
                    BufferedWriter writer = new BufferedWriter(
                            new OutputStreamWriter(new FileOutputStream(file), GOOGLE_CVS_ENCODE));
                    StringBuilder sb = new StringBuilder();
                    for (Object title : googleColumns) {
                        sb.append(title + ",");
                    }
                    sb.deleteCharAt(sb.length() - 1);
                    System.out.println(sb);
                    writer.write(sb.toString());
                    writer.newLine();
                    DefaultTableModel model = (DefaultTableModel) googleTable.getModel();
                    for (int row = 0; row < model.getRowCount(); row++) {
                        sb = new StringBuilder();
                        for (int col = 0; col < model.getColumnCount(); col++) {
                            String colVal = StringUtils.defaultString((String) model.getValueAt(row, col), "");
                            if (colVal.equalsIgnoreCase("null")) {
                                colVal = "";
                            }
                            sb.append(colVal + ",");
                        }
                        sb.deleteCharAt(sb.length() - 1);
                        System.out.println(sb);
                        writer.write(sb.toString());
                        writer.newLine();
                    }
                    writer.flush();
                    writer.close();
                } catch (Exception ex) {
                    JCommonUtil.handleException(ex);
                }
            }
        });

        //PASTE CLIPBOARD
        popupUtil.addJMenuItem("paste clipboard", new ActionListener() {
            public void actionPerformed(ActionEvent paramActionEvent) {
                JTableUtil.newInstance(googleTable).pasteFromClipboard_multiRowData(true);
            }
        });

        popupUtil.addJMenuItem("paste clipboard to selected cell", new ActionListener() {
            public void actionPerformed(ActionEvent paramActionEvent) {
                JTableUtil.newInstance(googleTable).pasteFromClipboard_singleValueToSelectedCell();
            }
        });

        JMenuItem addEmptyRowItem = JTableUtil.newInstance(googleTable).jMenuItem_addRow(false,
                "add row count?");
        addEmptyRowItem.setText("add row");
        JMenuItem removeColumnItem = JTableUtil.newInstance(googleTable).jMenuItem_removeColumn(null);
        removeColumnItem.setText("remove column");
        JMenuItem removeRowItem = JTableUtil.newInstance(googleTable).jMenuItem_removeRow(null);
        removeRowItem.setText("remove row");
        JMenuItem removeAllRowItem = JTableUtil.newInstance(googleTable)
                .jMenuItem_removeAllRow("remove all row?");
        removeAllRowItem.setText("remove all row");
        JMenuItem clearSelectedCellItem = JTableUtil.newInstance(googleTable)
                .jMenuItem_clearSelectedCell("are you sure clear selected area?");
        clearSelectedCellItem.setText("clear selected area");
        popupUtil.addJMenuItem(addEmptyRowItem, removeColumnItem, removeRowItem, removeAllRowItem,
                clearSelectedCellItem);
        popupUtil.show();
    } catch (Exception ex) {
        JCommonUtil.handleException(ex);
    }
}

From source file:edu.ku.brc.specify.conversion.SpecifyDBConverter.java

/**
 * /*w  w  w. j a  v a  2 s  .  com*/
 */
protected void createTableSummaryPage() {
    TableWriter tblWriter = convLogger.getWriter("TableSummary.html", "Table Summary");
    tblWriter.startTable();
    tblWriter.println("<tr><th>Table</th><th>Count</th></tr>");
    int total = 0;
    for (DBTableInfo ti : DBTableIdMgr.getInstance().getTables()) {
        Integer count = BasicSQLUtils.getCount("select count(*) from " + ti.getName());
        if (count != null && count > 0) {
            tblWriter.log(ti.getName(), count.toString());
        }
        total += count;
    }
    tblWriter.println("<tr><td>Total Records</td><td>" + total + "</td></tr>");
    tblWriter.endTable();

    String sql;

    //----------------------------------------------------------------------------------
    tblWriter.println("<H3>Col Obj Counts By Discipline/Collection</H3>");
    sql = " SELECT cct.CollectionObjectTypeName, cs.SeriesName, Count(cc.CollectionObjectCatalogID) FROM catalogseries AS cs "
            + "Inner Join collectionobjectcatalog AS cc ON cs.CatalogSeriesID = cc.CatalogSeriesID "
            + "Inner Join collectionobjecttype AS cct ON cc.CollectionObjectTypeID = cct.CollectionObjectTypeID "
            + "Inner Join collectionobject AS co ON cc.CollectionObjectCatalogID = co.CollectionObjectID "
            + " WHERE co.DerivedFromID IS NULL " + "GROUP BY cct.CollectionObjectTypeName, cs.SeriesName";

    showTable(tblWriter, "Specify 5", false, sql, "Discipline", "Collection", "Count");

    sql = "SELECT d.Name, c.CollectionName, Count(co.CollectionObjectID) AS `Count` FROM discipline AS d "
            + "Inner Join collection AS c ON d.UserGroupScopeId = c.DisciplineID "
            + "Inner Join collectionobject AS co ON co.CollectionID = c.UserGroupScopeId "
            + "GROUP BY d.Name, c.CollectionName";
    tblWriter.println("<BR>");
    showTable(tblWriter, "Specify 6", true, sql, "Discipline", "Collection", "Count");

    //----------------------------------------------------------------------------------
    /*tblWriter.println("<H3>Collecting Events Counts By Discipline</H3>");
    sql = " SELECT ct.CollectionObjectTypeName, Count(ce.CollectingEventID) FROM collectionobjecttype AS ct " +
    "Inner Join collectingevent AS ce ON ct.CollectionObjectTypeID = ce.BiologicalObjectTypeCollectedID " +
    "GROUP BY ct.CollectionObjectTypeName";
    showTable(tblWriter, "Specify 5", false, sql, "Discipline", "Count");
            
    sql = " SELECT d.Name, Count(ce.CollectingEventID) FROM discipline AS d " +
    "Inner Join collectingevent AS ce ON d.UserGroupScopeId = ce.DisciplineID " +
    "GROUP BY d.Name";
    tblWriter.println("<BR>");
    showTable(tblWriter, "Specify 6", true, sql, "Discipline", "Count");
    */
    //----------------------------------------------------------------------------------
    tblWriter.println("<H3>Col Obj Counts By Collection</H3>");
    sql = " SELECT cs.SeriesName, Count(cc.CollectionObjectCatalogID) FROM catalogseries AS cs "
            + "Inner Join collectionobjectcatalog AS cc ON cs.CatalogSeriesID = cc.CatalogSeriesID "
            + "Inner Join collectionobject AS co ON cc.CollectionObjectCatalogID = co.CollectionObjectID "
            + " WHERE co.DerivedFromID IS NULL " + "GROUP BY cs.SeriesName";

    showTable(tblWriter, "Specify 5", false, sql, "Collection", "Count");

    sql = " SELECT c.CollectionName, Count(co.CollectionObjectID) FROM collection AS c "
            + "Inner Join collectionobject AS co ON c.UserGroupScopeId = co.CollectionID "
            + "GROUP BY c.CollectionName";
    tblWriter.println("<BR>");
    showTable(tblWriter, "Specify 6", true, sql, "Collection", "Count");

    //----------------------------------------------------------------------------------
    tblWriter.println("<H3>Locality Counts</H3>");
    sql = " SELECT Count(LocalityID) FROM locality";
    showTable(tblWriter, "Specify 5", false, sql, "Count");

    sql = " SELECT Count(LocalityID) FROM locality";
    tblWriter.println("<BR>");
    showTable(tblWriter, "Specify 6", true, sql, "Count");

    //----------------------------------------------------------------------------------
    tblWriter.println("<H3>Locality Counts By Discipline</H3>");
    sql = " SELECT ct.CollectionObjectTypeName, Count(locid) FROM collectionobjecttype AS ct "
            + "Inner Join (SELECT ce.CollectingEventID as ceid, ce.BiologicalObjectTypeCollectedID as botid, locality.LocalityID as locid FROM collectingevent ce Inner Join locality ON ce.LocalityID = locality.LocalityID GROUP BY locality.LocalityID) T1 ON ct.CollectionObjectTypeID = T1.botid "
            + "GROUP BY ct.CollectionObjectTypeName";

    showTable(tblWriter, "Specify 5", false, sql, "Discipline", "Count");

    sql = " SELECT d.Name, Count(l.LocalityID) FROM discipline AS d "
            + "Inner Join locality AS l ON d.UserGroupScopeId = l.DisciplineID " + "GROUP BY d.Name";
    tblWriter.println("<BR>");
    showTable(tblWriter, "Specify 6", true, sql, "Discipline", "Count");

    //----------------------------------------------------------------------------------
    tblWriter.startTable();
    tblWriter.logHdr(CollectionInfoModel.getHeaders());

    DefaultTableModel model = CollectionInfo.getCollectionInfoTableModel(true);
    Object[] row = new Object[model.getColumnCount()];
    for (int r = 0; r < model.getRowCount(); r++) {
        for (int i = 0; i < model.getColumnCount(); i++) {
            row[i] = model.getValueAt(r, i);
        }
        tblWriter.logObjRow(row);
    }
    tblWriter.endTable();
    tblWriter.close();

    /*
    tblWriter.startTable();
    tblWriter.logHdr("&nbsp;", "Specify 5", "Specify 6");
    for (Triple<String, String, String> qry : getSummaryQueries())
    {
            
    }
    tblWriter.endTable();
    */
}