Example usage for javax.swing.table DefaultTableModel getRowCount

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

Introduction

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

Prototype

public int getRowCount() 

Source Link

Document

Returns the number of rows in this data table.

Usage

From source file:gtu._work.ui.DirectoryCompareUI.java

private void initComponents() {
    DefaultTableModel dirCompareModel = getDefaultTableModel();
    DefaultComboBoxModel extensionModel = new DefaultComboBoxModel();
    extensionModel.addElement(EXTENSION_ALL);

    while (extensionNameComboBox.getModel().getSize() != extensionModel.getSize()) {
        extensionNameComboBox.setModel(extensionModel);
        System.out.println("reset extensionNameComboBox");
    }// ww w  .  j  a v a 2 s .c o m
    while (dirCompareTable.getModel().getRowCount() != dirCompareModel.getRowCount()) {
        dirCompareTable.setModel(dirCompareModel);
        System.out.println("reset dirCompareTable");
    }

    searchText.setText("");
    setTitle("");
    compareStyleComboBox.setSelectedItem(EXTENSION_ALL);
    if (diffMergeChkBox != null) {
        for (JCheckBox chk : diffMergeChkBox) {
            chk.setSelected(true);
        }
    }
}

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

private void initGUI() {
    try {/*from   w  w  w. java  2s .  co  m*/
        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;/*from  w  w  w  .ja va  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:br.com.atmatech.sac.view.ViewPessoa.java

private void buscaPessoa(String coluna, String parametro) {
        DefaultTableModel tabelapessoa = (DefaultTableModel) jTtempresa.getModel();
        tabelapessoa.setNumRows(0);/*from  ww  w. ja va2  s . c  o  m*/
        lpb = new PessoaDao().getPessoa(coluna, parametro, coluna);
        for (PessoaBeans pb : lpb) {
            tabelapessoa.addRow(new Object[] { pb.getIdpessoa(), pb.getRazao(), pb.getFantasia(), pb.getCnpj(),
                    pb.getEndereco() });
        }
        if (tabelapessoa.getRowCount() == 0) {
            tabelapessoa.addRow(new Object[] {});
        }
    }

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());/*ww  w. j  a v  a2 s  .c o m*/

    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:gtu._work.etc.GoogleContactUI.java

void googleTableMouseClicked(MouseEvent evt) {
    try {/*  w ww.  j  av  a  2 s  . c o  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:gtu._work.ui.DirectoryCompareUI.java

/**
 * TODO/*from   ww w . j a v a2 s .co  m*/
 */
private void compareStart() {
    try {
        String leftStr = leftDirText.getText();
        String rightStr = rightDirText.getText();
        Validate.notBlank(leftStr, "??");
        Validate.notBlank(rightStr, "???");

        initComponents();

        File leftFile = new File(StringUtils.trim(leftStr));
        File rightFile = new File(StringUtils.trim(rightStr));
        if (!leftFile.exists()) {
            leftFile = File.createTempFile("left_", ".txt");
            if (leftFile.exists()) {
                leftFile.delete();
            }
            FileUtils.write(leftFile, leftStr, "utf8");
        }
        if (!rightFile.exists()) {
            rightFile = File.createTempFile("right_", ".txt");
            if (rightFile.exists()) {
                rightFile.delete();
            }
            FileUtils.write(rightFile, rightStr, "utf8");
        }

        File mainFile = leftFile;
        File compareFile = rightFile;

        modelOrignList.clear();
        compareSearch = new MainCompareSearch(mainFile, compareFile) {
            @Override
            void compareFileNotExists(FileZ mainFile, FileZ compareToFile, boolean mainFileIsLeft) {
                modelOrignList
                        .add(getCreateRow(mainFile, compareToFile, mainFileIsLeft, DiffMergeStatus.NOT_EXISTS));
            }

            @Override
            void sameFile(FileZ mainFile, FileZ compareToFile, boolean mainFileIsLeft) {
                modelOrignList.add(getCreateRow(mainFile, compareToFile, mainFileIsLeft, DiffMergeStatus.SAME));
            }

            @Override
            void differentFile(FileZ mainFile, FileZ compareToFile, boolean mainFileIsLeft) {
                modelOrignList
                        .add(getCreateRow(mainFile, compareToFile, mainFileIsLeft, DiffMergeStatus.DIFFERENT));
            }

            @Override
            void complete() {
                DefaultTableModel dirCompareModel = getDefaultTableModel();
                DefaultComboBoxModel extensionModel = new DefaultComboBoxModel();
                Set<String> extensionSet = new TreeSet<String>();

                for (Object[] rows : modelOrignList) {
                    dirCompareModel.addRow(rows);
                    InfoObj infoObj = (InfoObj) rows[0];
                    // ???
                    checkExtensionName(infoObj, extensionSet);
                }
                extensionModel.addElement(EXTENSION_ALL);
                extensionModel.addElement(EXTENSION_CUSTOM);
                for (String name : extensionSet) {
                    extensionModel.addElement(name);
                }

                while (extensionNameComboBox.getModel().getSize() != extensionModel.getSize()) {
                    extensionNameComboBox.setModel(extensionModel);
                    System.out.println("reset extensionNameComboBox");
                }
                while (dirCompareTable.getModel().getRowCount() != dirCompareModel.getRowCount()) {
                    dirCompareTable.setModel(dirCompareModel);
                    System.out.println("reset dirCompareTable");
                }

                System.out.println(
                        "extensionNameComboBox = " + (extensionNameComboBox.getModel() == extensionModel));
                System.out.println("dirCompareTable = " + (dirCompareTable.getModel() == dirCompareModel));
                System.out.println("extensionNameComboBox = " + extensionNameComboBox.getModel().getSize());
                System.out.println("dirCompareTable = " + dirCompareTable.getModel().getRowCount());

                setTitle(":" + mainFileCount + "/?:" + compareToFileCount
                        + ",  :" + completeTime);

                JCommonUtil._jOptionPane_showMessageDialog_info(//
                        "???" + //
                "\n?:" + this.countSameFile + //
                "\n??:" + this.countDifferentFile + //
                "\n?:" + this.countNotExists + //
                "\n:" + completeTime + //
                "\n?merge:" + modelOrignList.size());
            }
        };

        if (leftFile.isDirectory() && rightFile.isDirectory()) {
            if (StringUtils.equals(FINDFUNCTION_ABS, String.valueOf(compareStyleComboBox.getSelectedItem()))) {
                compareSearch.executeSameDirectory();
            } else if (StringUtils.equals(FINDFUNCTION_REL,
                    String.valueOf(compareStyleComboBox.getSelectedItem()))) {
                List<File> mainFileList = new ArrayList<File>();
                List<File> compareFileList = new ArrayList<File>();
                FileUtil.searchFilefind(mainFile, ".*", mainFileList);
                FileUtil.searchFilefind(compareFile, ".*", compareFileList);
                compareSearch.executeTwoDirectoryButNotSame(mainFileList, compareFileList);
            } else {
                Validate.isTrue(false, "??!");
            }
        } else if (leftFile.isFile() && rightFile.isFile()) {
            compareSearch.executeTwoFile();
        } else if (leftFile.isDirectory() && rightFile.isFile()) {
            List<File> mainFileList = new ArrayList<File>();
            List<File> compareFileList = new ArrayList<File>();
            FileUtil.searchFilefind(mainFile, ".*", mainFileList);
            compareFileList.add(compareFile);
            compareSearch.executeTwoDirectoryButNotSame(mainFileList, compareFileList);
            compareStyleComboBox.setSelectedItem(FINDFUNCTION_REL);
        } else if (leftFile.isFile() && rightFile.isDirectory()) {
            List<File> mainFileList = new ArrayList<File>();
            List<File> compareFileList = new ArrayList<File>();
            mainFileList.add(mainFile);
            FileUtil.searchFilefind(compareFile, ".*", compareFileList);
            compareSearch.executeTwoDirectoryButNotSame(mainFileList, compareFileList);
            compareStyleComboBox.setSelectedItem(FINDFUNCTION_REL);
        } else {
            Validate.isTrue(false, "???!");
        }
    } catch (Exception ex) {
        JCommonUtil.handleException(ex, false);
    }
}

From source file:com.peterbochs.instrument.InstrumentPanel.java

private void updateHotestTable(long address, long blockSize) {
    DefaultTableModel jHotestAddressTableModel = (DefaultTableModel) jHotestAddressTable.getModel();
    while (jHotestAddressTableModel.getRowCount() > 0) {
        jHotestAddressTableModel.removeRow(0);
    }//from   w w  w  .  j  a v a 2 s  .c o m
    HashMap<String, Integer> map = Data.getHotestAddressCount(address, blockSize);
    Iterator it = map.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry entry = (Map.Entry) it.next();
        jHotestAddressTableModel
                .addRow(new String[] { entry.getKey().toString(), entry.getValue().toString() });
    }
}

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

/**
 * // w ww  .  ja  v a2s  .  c  om
 */
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();
    */
}

From source file:de.tor.tribes.ui.windows.DSWorkbenchMainFrame.java

public void doExport() {
    //build attack table
    DefaultTableModel model = (DefaultTableModel) jAttackExportTable.getModel();
    int rows = model.getRowCount();
    for (int i = 0; i < rows; i++) {
        model.removeRow(0);/*w w  w  .j  a  v  a2s . com*/
    }
    Iterator<String> plans = AttackManager.getSingleton().getGroupIterator();
    while (plans.hasNext()) {
        String next = plans.next();
        model.addRow(new Object[] { next, Boolean.FALSE });
    }

    //build marker set table
    String[] sets = MarkerManager.getSingleton().getGroups();
    model = (DefaultTableModel) jMarkerSetExportTable.getModel();
    rows = model.getRowCount();
    for (int i = 0; i < rows; i++) {
        model.removeRow(0);
    }

    for (String set : sets) {
        model.addRow(new Object[] { set, Boolean.FALSE });
    }

    //build report set table
    String[] reportSets = ReportManager.getSingleton().getGroups();

    model = (DefaultTableModel) jReportSetExportTable.getModel();
    rows = model.getRowCount();
    for (int i = 0; i < rows; i++) {
        model.removeRow(0);
    }

    for (String set : reportSets) {
        model.addRow(new Object[] { set, Boolean.FALSE });
    }

    //build troop table 
    String[] troopSets = TroopsManager.getSingleton().getGroups();

    model = (DefaultTableModel) jTroopSetExportTable.getModel();
    rows = model.getRowCount();
    for (int i = 0; i < rows; i++) {
        model.removeRow(0);
    }

    for (String set : troopSets) {
        model.addRow(new Object[] { set, Boolean.FALSE });
    }
    //build note table 
    String[] noteSets = NoteManager.getSingleton().getGroups();

    model = (DefaultTableModel) jNoteSetExportTable.getModel();
    rows = model.getRowCount();
    for (int i = 0; i < rows; i++) {
        model.removeRow(0);
    }

    for (String set : noteSets) {
        model.addRow(new Object[] { set, Boolean.FALSE });
    }
    jExportDialog.setAlwaysOnTop(true);
    jExportDialog.setVisible(true);
}