Example usage for javax.swing DefaultListModel getSize

List of usage examples for javax.swing DefaultListModel getSize

Introduction

In this page you can find the example usage for javax.swing DefaultListModel getSize.

Prototype

public int getSize() 

Source Link

Document

Returns the number of components in this list.

Usage

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

private void exeucteActionPerformed(ActionEvent evt) {
    try {//  w w  w.  java 2  s. c  o m
        String fromPattern = null;
        String toFormat = repToText.getText();
        Validate.notEmpty((fromPattern = repFromText.getText()), "replace regex can't empty");

        DefaultListModel model = (DefaultListModel) srcList.getModel();
        DefaultListModel rmodel = new DefaultListModel();

        errMsg = new StringBuilder();
        successMsg = new StringBuilder();

        String replaceText = null;
        String bakupReplaceText = null;

        File newFile = null;
        File oldFile = null;
        OldNewFile oldNewFile = null;

        for (int ii = 0; ii < model.getSize(); ii++) {
            oldFile = (File) model.getElementAt(ii);
            replaceText = FileUtil.loadFromFile(oldFile, getCharset());
            bakupReplaceText = replaceText.toString();
            replaceText = replacer(fromPattern, toFormat, replaceText, oldFile);

            if (!bakupReplaceText.equals(replaceText)) {

                if (replaceOldFileChkbox.isSelected()) {
                    oldFile.renameTo(new File(oldFile.getParentFile(), oldFile.getName() + ".bak"));
                }

                newFile = oldFile;

                FileUtil.saveToFile(newFile, replaceText, getCharset());
                successMsg.append(newFile.getName() + "\n");
                oldNewFile = new OldNewFile();
                oldNewFile.oldFile = oldFile;
                oldNewFile.newFile = newFile;
                rmodel.addElement(oldNewFile);

                successMsg.append(oldFile.getName() + "\n");
            }
        }

        newRepList.setModel(rmodel);
        JOptionPaneUtil.newInstance().iconInformationMessage()
                .showMessageDialog(String.format(MESSAGE, successMsg, errMsg), getTitle());
    } catch (Exception ex) {
        JCommonUtil.handleException(ex);
    }
}

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

private void scheduleExecuteActionPerformed(ActionEvent evt) {
    try {//from  w w w . j a va 2  s.c om
        DefaultListModel model = (DefaultListModel) srcList.getModel();
        DefaultListModel rmodel = new DefaultListModel();
        DefaultListModel pmodel = (DefaultListModel) templateList.getModel();

        errMsg = new StringBuilder();
        successMsg = new StringBuilder();

        String replaceText = null;
        String bakupReplaceText = null;

        File newFile = null;
        File oldFile = null;
        OldNewFile oldNewFile = null;
        for (int ii = 0; ii < model.getSize(); ii++) {
            oldFile = (File) model.getElementAt(ii);
            replaceText = FileUtil.loadFromFile(oldFile, getCharset());
            bakupReplaceText = replaceText.toString();

            for (int jj = 0; jj < pmodel.getSize(); jj++) {
                Entry<Object, Object> entry = (Entry<Object, Object>) pmodel.getElementAt(jj);
                replaceText = replacer((String) entry.getKey(), (String) entry.getValue(), replaceText,
                        oldFile);
            }

            if (!bakupReplaceText.equals(replaceText)) {
                newFile = new File(oldFile.getParent(), oldFile.getName() + ".replace");
                FileUtil.saveToFile(newFile, replaceText, getCharset());
                successMsg.append(newFile.getName() + "\n");
                oldNewFile = new OldNewFile();
                oldNewFile.oldFile = oldFile;
                oldNewFile.newFile = newFile;
                rmodel.addElement(oldNewFile);
            }
        }

        newRepList.setModel(rmodel);
        JOptionPaneUtil.newInstance().iconInformationMessage()
                .showMessageDialog(String.format(MESSAGE, successMsg, errMsg), getTitle());
    } catch (Exception ex) {
        JCommonUtil.handleException(ex);
    }
}

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

void loadSrcTextarea() throws IOException {
    String srcText = null;/*from www  . j  av a2 s.  co m*/
    Validate.notEmpty((srcText = srcArea.getText()), "src textarea can't empty");
    Validate.notNull(manualBaseDir, "src base directory not set!");
    BufferedReader reader = new BufferedReader(new StringReader(srcText));
    ParseMode mode = null;
    LineParser lineParser = null;
    Set<LineParser> set = new HashSet<LineParser>();
    DefaultListModel errorLogModel = new DefaultListModel();
    for (String line = null; (line = reader.readLine()) != null;) {
        mode = ((ParseMode) exportModeCombo.getSelectedItem());
        if (mode == null) {
            continue;
        }
        lineParser = mode.parse(line, errorLogModel);
        System.out.println("lineParser = " + lineParser);
        if (lineParser != null) {
            set.add(lineParser);
        }
    }
    errorLogList.setModel(errorLogModel);
    if (errorLogModel.getSize() != 0) {
        JOptionPaneUtil.newInstance().iconErrorMessage()
                .showMessageDialog("same error occor!,\n check out error log panel", "ERROR");
    }

    DefaultListModel srcModel = new DefaultListModel();
    for (LineParser line : set) {
        srcModel.addElement(line);
    }
    srcList.setModel(srcModel);
    copySrcListForQuerySet = Collections.unmodifiableSet(set);
}

From source file:net.sf.xmm.moviemanager.gui.DialogIMDbMultiAdd.java

/**
 * Checks if the movie list should be retrived from IMDB or the local movie Database
 *///from w w  w  .  j  a  v  a 2 s . c o  m
void executeSearchMultipleMovies() {

    if (addInfoToExistingMovie) {
        executeEditExistingMovie(getSearchField().getText());
    } else {
        final DefaultListModel listModel = new DefaultListModel();

        int setSelectedIndex = 0;

        try {

            IMDb imdb = IMDbLib.newIMDb(MovieManager.getConfig().getHttpSettings());
            ArrayList<ModelIMDbSearchHit> hits = imdb.getSimpleMatches(getSearchField().getText());

            // Error
            if (hits == null) {
                HTTPResult res = imdb.getLastHTTPResult();

                if (res.getStatusCode() == HttpStatus.SC_REQUEST_TIMEOUT) {
                    listModel.addElement(new ModelIMDbSearchHit("Connection timed out...")); //$NON-NLS-1$
                }
            }

            for (int i = 0; i < hits.size(); i++) {
                listModel.addElement(hits.get(i));
            }

        } catch (Exception e) {
            executeErrorMessage(e);

            e.printStackTrace();
            dispose();
        }

        if (listModel.getSize() == 0)
            listModel.addElement(
                    new ModelIMDbSearchHit(Localizer.get("DialogIMDB.list-element.messsage.no-hits-found"))); //$NON-NLS-1$

        getMoviesList().setModel(listModel);
        getMoviesList().setSelectedIndex(setSelectedIndex);

        // This delays the execution of requestFocusInWindow.
        // The reason is to avoid that the actionlistener for the choose button 
        // is invoked, which is would be if invokelater isn't used. (Experienced on Ubuntu).
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                getMoviesList().requestFocusInWindow();
            }
        });
    }
}

From source file:imageuploader.ImgWindow.java

private void generatedImages(String code, File[] files)
        throws IOException, IllegalStateException, FTPIllegalReplyException, FTPException, FtpException {

    int ubicacion;
    File directory = new File(code);
    ArrayList<File> imageList = new ArrayList();
    DefaultListModel mod = (DefaultListModel) jL_Info.getModel();
    if (!directory.exists()) {
        boolean result = directory.mkdir();
        if (!result) {
            JOptionPane.showMessageDialog(rootPane, "Directory -- Error");
        } else {/*from w  w w  .  ja v  a 2s  . c o  m*/
            File dir, img;
            boolean rst;
            FileChannel source = null;
            FileChannel dest = null;
            FtpCredentials.getInstancia().connect();
            for (int i = 0; i < files.length; i++) {

                int val = 1 + i;
                //Create the Angle directory
                dir = new File(directory, "Angle" + val);
                rst = dir.mkdir();

                //Copy Images
                //DefaultListModel mod = (DefaultListModel)jL_Info.getModel();

                for (int j = 0; j < mod.getSize(); j++) {
                    img = new File(dir, code + "~" + mod.getElementAt(j).toString() + ".jpg");
                    rst = img.createNewFile();
                    imageList.add(img);
                    source = new RandomAccessFile(files[i], "rw").getChannel();
                    dest = new RandomAccessFile(img, "rw").getChannel();

                    long position = 0;
                    long count = source.size();
                    source.transferTo(position, count, dest);

                    if (source != null) {
                        source.close();
                    }
                    if (dest != null) {
                        dest.close();
                    }

                }
                ubicacion = i + 1;
                /*Using the private library  */
                if (jCHBox_MY.isSelected()) {
                    FtpCredentials.getInstancia().getClient().setDir("/Myron/angle" + ubicacion + "Flash");
                    FtpCredentials.getInstancia().copyImage(imageList);
                }
                if (jCHB_CA.isSelected()) {
                    FtpCredentials.getInstancia().getClient().setDir("/canada/angle" + ubicacion + "Flash");
                    FtpCredentials.getInstancia().copyImage(imageList);
                }
                if (jCHB_AZ.isSelected()) {
                    FtpCredentials.getInstancia().getClient().setDir("/australia/angle" + ubicacion + "Flash");
                    FtpCredentials.getInstancia().copyImage(imageList);
                }
                imageList.clear();

            }

            mod.removeAllElements();
            jTF_StyleCode.setText("");
            //jL_Info.removeAll();
            //list.removeAllElements();
            JOptionPane.showMessageDialog(rootPane, "Images uploaded");
        }
    } else {
        JOptionPane.showMessageDialog(rootPane, "There is a folder with the same name in the same location");
    }

}

From source file:gtu._work.mvn.MavenRepositoryUI.java

private void initGUI() {
    try {//w ww .j av  a 2  s.c o  m
        {
        }
        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                scanList = new JList();
                jTabbedPane1.addTab("repository", null, jPanel1, null);
                {
                    scanText = new JTextField();
                    jPanel1.add(scanText, BorderLayout.NORTH);
                }
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    {
                        ListModel scanListModel = new DefaultListModel();
                        jScrollPane1.setViewportView(scanList);
                        scanList.setModel(scanListModel);
                        scanList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                defaultJListClick(scanList, evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel4 = new JPanel();
                BorderLayout jPanel4Layout = new BorderLayout();
                jPanel4.setLayout(jPanel4Layout);
                jTabbedPane1.addTab("repository only jar", null, jPanel4, null);
                jPanel4.setPreferredSize(new java.awt.Dimension(520, 298));
                {
                    scanText2 = new JTextField();
                    jPanel4.add(scanText2, BorderLayout.NORTH);
                }
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel4.add(jScrollPane3, BorderLayout.CENTER);
                    {
                        scanList2 = new JList();
                        jScrollPane3.setViewportView(scanList2);
                        ListModel scanList2Model = new DefaultListModel();
                        scanList2.setModel(scanList2Model);
                        scanList2.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                defaultJListClick(scanList2, evt);
                            }
                        });
                    }
                }
                {
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("jar find", null, jPanel2, null);
                {
                    jarFindText = new JTextField();
                    jPanel2.add(jarFindText, BorderLayout.NORTH);
                }
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel2.add(jScrollPane2, BorderLayout.CENTER);
                    {
                        ListModel jarFindListModel = new DefaultListModel();
                        jarFindList = new JList();
                        jScrollPane2.setViewportView(jarFindList);
                        jarFindList.setModel(jarFindListModel);
                        jarFindList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                defaultJListClick(jarFindList, evt);
                            }
                        });
                    }
                }
                {
                    jarFindExecute = new JButton();
                    jPanel2.add(jarFindExecute, BorderLayout.SOUTH);
                    jarFindExecute.setText("find");
                    jarFindExecute.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            String searchtext = jarFindText.getText();
                            if (StringUtils.isEmpty(searchtext) || searchtext.length() < 2) {
                                JOptionPaneUtil.newInstance().iconErrorMessage()
                                        .showMessageDialog("", "error");
                                return;
                            }
                            try {
                                DefaultListModel model = new DefaultListModel();
                                jarFindList.setModel(model);

                                searchtext = searchtext.trim();
                                searchtext = searchtext.replace('/', '.');
                                searchtext = searchtext.replace('\\', '.');

                                if (jarfinder == null) {
                                    jarfinder = JarFinder.newInstance();
                                } else {
                                    jarfinder.clear();
                                }

                                jarfinder.pattern(searchtext);

                                DefaultListModel scanModel = (DefaultListModel) scanList.getModel();
                                PomFile pomFile = null;
                                for (int ii = 0; ii < scanModel.getSize(); ii++) {
                                    pomFile = (PomFile) scanModel.getElementAt(ii);
                                    if (pomFile.jarFile == null) {
                                        continue;
                                    }
                                    jarfinder.setDir(pomFile.jarFile);
                                    if (!jarfinder.execute().isEmpty()) {
                                        model.addElement(pomFile);
                                    }
                                    jarfinder.getMap().clear();
                                }
                            } catch (Exception ex) {
                                JOptionPaneUtil.newInstance().iconErrorMessage()
                                        .showMessageDialog(ex.getMessage(), "error");
                                ex.printStackTrace();
                            }
                        }
                    });
                }
            }
            {
                jPanel5 = new JPanel();
                BorderLayout jPanel5Layout = new BorderLayout();
                jTabbedPane1.addTab("detail", null, jPanel5, null);
                jPanel5.setLayout(jPanel5Layout);
                {
                    jScrollPane4 = new JScrollPane();
                    jPanel5.add(jScrollPane4, BorderLayout.CENTER);
                    {
                        TableModel scanTableModel = new DefaultTableModel();
                        scanTable = new JTable();
                        BorderLayout scanTableLayout = new BorderLayout();
                        scanTable.setLayout(scanTableLayout);
                        jScrollPane4.setViewportView(scanTable);
                        scanTable.setModel(scanTableModel);
                        JTableUtil.defaultSetting(scanTable);

                        scanTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                tableMouseClicked(scanTable, 0, evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel3 = new JPanel();
                jTabbedPane1.addTab("config", null, jPanel3, null);
                GroupLayout jPanel3Layout = new GroupLayout((JComponent) jPanel3);
                jPanel3.setLayout(jPanel3Layout);
                {
                    copyToDir = new JButton();
                    copyToDir.setText("set copy to dir");
                    copyToDir.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                                    .getApproveSelectedFile();
                            if (file == null || !file.exists() || !file.isDirectory()) {
                                JOptionPaneUtil.newInstance().iconErrorMessage()
                                        .showMessageDialog("dir is not correct!, set default desktop", "error");
                                file = FileUtil.DESKTOP_DIR;
                            }
                            copyTo = file;
                            System.out.println("copyTo: " + copyTo);
                        }
                    });
                }
                {
                    resetM2Dir = new JButton();
                    resetM2Dir.setText("set .m2 dir");
                    resetM2Dir.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                                    .getApproveSelectedFile();
                            if (file == null || !file.exists() || !file.isDirectory()) {
                                showErrorMsg();
                                repositoryDir = DEFAULT_REPOSITORY_DIR;
                                reloadRepositoryDir();
                                return;
                            }
                            File newRepository = new File(file, "repository");
                            File settings = new File(file, "settings.xml");
                            if (settings.exists() && settings.isFile() && newRepository.exists()
                                    && newRepository.isDirectory()) {
                                repositoryDir = newRepository;
                                reloadRepositoryDir();
                            } else {
                                showErrorMsg();
                            }
                        }

                        void showErrorMsg() {
                            JOptionPaneUtil.newInstance().iconErrorMessage()
                                    .showMessageDialog("dir is not correct!, set default .m2 dir", "error");
                        }
                    });
                }
                {
                    saveCurrentDataBtn = new JButton();
                    saveCurrentDataBtn.setText("save current data");
                    saveCurrentDataBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File cfgFile = new File(PropertiesUtil.getJarCurrentPath(MavenRepositoryUI.class),
                                    MavenRepositoryUI.class.getSimpleName() + "_" + DateFormatUtil
                                            .format(System.currentTimeMillis(), "yyyyMMdd_HHmmss") + ".cfg");
                            try {
                                ObjectOutputStream writer = new ObjectOutputStream(
                                        new FileOutputStream(cfgFile));
                                writer.writeObject(pomFileList);
                                writer.writeObject(pomFileJarList);
                                writer.writeObject(pomFileMap);
                                writer.flush();
                                writer.close();
                                JOptionPaneUtil.newInstance().iconInformationMessage()
                                        .showMessageDialog("save completed!\n" + cfgFile, "SUCCESS");
                            } catch (Exception ex) {
                                JCommonUtil.handleException(ex);
                                ex.printStackTrace();
                            }
                        }
                    });
                }
                {
                    loadConfigDataBtn = new JButton();
                    loadConfigDataBtn.setText("load config data");
                    loadConfigDataBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File cfgFile = JFileChooserUtil.newInstance().selectFileOnly()
                                    .addAcceptFile("cfg", ".cfg").showOpenDialog().getApproveSelectedFile();
                            if (cfgFile == null) {
                                JOptionPaneUtil.newInstance().iconErrorMessage()
                                        .showMessageDialog("file is not correct!", "ERROR");
                                return;
                            }
                            try {
                                ObjectInputStream reader = new ObjectInputStream(new FileInputStream(cfgFile));
                                pomFileList = (Set<PomFile>) reader.readObject();
                                pomFileJarList = (Set<PomFile>) reader.readObject();
                                pomFileMap = (Map<DependencyKey, PomFile>) reader.readObject();
                                reader.close();
                                resetUIStatus();
                                JOptionPaneUtil.newInstance().iconInformationMessage()
                                        .showMessageDialog("load completed!\n" + cfgFile, "SUCCESS");
                            } catch (Exception ex) {
                                JCommonUtil.handleException(ex);
                                ex.printStackTrace();
                            }
                        }
                    });

                }
                jPanel3Layout.setHorizontalGroup(jPanel3Layout.createSequentialGroup().addContainerGap(24, 24)
                        .addGroup(jPanel3Layout.createParallelGroup()
                                .addGroup(jPanel3Layout.createSequentialGroup().addComponent(loadConfigDataBtn,
                                        GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel3Layout.createSequentialGroup().addComponent(saveCurrentDataBtn,
                                        GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel3Layout.createSequentialGroup().addComponent(copyToDir,
                                        GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel3Layout.createSequentialGroup().addComponent(resetM2Dir,
                                        GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel3Layout.createSequentialGroup().addComponent(getJButton1(),
                                        GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(281, Short.MAX_VALUE));
                jPanel3Layout.setVerticalGroup(jPanel3Layout.createSequentialGroup().addContainerGap(25, 25)
                        .addComponent(copyToDir, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
                        .addGap(22)
                        .addComponent(resetM2Dir, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
                        .addGap(24)
                        .addComponent(saveCurrentDataBtn, GroupLayout.PREFERRED_SIZE, 31,
                                GroupLayout.PREFERRED_SIZE)
                        .addGap(25)
                        .addComponent(loadConfigDataBtn, GroupLayout.PREFERRED_SIZE, 31,
                                GroupLayout.PREFERRED_SIZE)
                        .addGap(28)
                        .addComponent(getJButton1(), GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(34, Short.MAX_VALUE));
            }
            {
                jPanel6 = new JPanel();
                BorderLayout jPanel6Layout = new BorderLayout();
                jPanel6.setLayout(jPanel6Layout);
                jTabbedPane1.addTab("pom dency", null, jPanel6, null);
                {
                    openPom = new JButton();
                    jPanel6.add(openPom, BorderLayout.NORTH);
                    openPom.setText("open");
                    openPom.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File file = JFileChooserUtil.newInstance().selectFileAndDirectory()
                                    .showDialog("?pom,pom").getApproveSelectedFile();
                            if (file == null) {
                                JOptionPaneUtil.newInstance().iconErrorMessage()
                                        .showMessageDialog("file is not correct!!", "ERROR");
                                return;
                            }
                            List<File> pomList = new ArrayList<File>();
                            if (file.isFile()
                                    && (file.getName().endsWith(".xml") || file.getName().endsWith(".pom"))) {
                                pomList.add(file);
                            } else {
                                FileUtil.searchFileMatchs(file, "pom.xml", pomList);
                            }
                            Set<PomFile> poms = loadPomList(pomList);
                            resetUIStatus();

                            Map<DependencyKey, PomFile> map = new HashMap<DependencyKey, PomFile>();
                            Set<LoadPomListDependency.DependencyKey> errorSet = new HashSet<LoadPomListDependency.DependencyKey>();
                            for (PomFile p : poms) {
                                openPomFetchDependency(p.pom, map, errorSet);
                            }

                            PomFile pfile = null;
                            DefaultTableModel model = JTableUtil.createModel(true, "groupId", "artifactId",
                                    "jar", "pomFile");
                            for (DependencyKey key : map.keySet()) {
                                pfile = map.get(key);
                                model.addRow(new Object[] { pfile.pom.groupId, pfile.pom.artifactId,
                                        (pfile.jarFile == null ? "" : pfile.jarFile.getName()), pfile });
                            }
                            for (LoadPomListDependency.DependencyKey key : errorSet) {
                                model.addRow(new Object[] { key.groupId, key.artifactId, "ERROR" });
                            }
                            pomDenpendencyTable.setModel(model);
                        }
                    });
                }
                {
                    jScrollPane5 = new JScrollPane();
                    jPanel6.add(jScrollPane5, BorderLayout.CENTER);
                    {
                        TableModel pomDenpendencyTableModel = new DefaultTableModel();
                        pomDenpendencyTable = new JTable();
                        jScrollPane5.setViewportView(pomDenpendencyTable);
                        pomDenpendencyTable.setModel(pomDenpendencyTableModel);
                        pomDenpendencyTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                tableMouseClicked(pomDenpendencyTable, 3, evt);
                            }
                        });
                        JTableUtil.defaultSetting(pomDenpendencyTable);
                    }
                }
                {
                    jPanel7 = new JPanel();
                    FlowLayout jPanel7Layout = new FlowLayout();
                    jPanel7Layout.setAlignOnBaseline(true);
                    jPanel6.add(jPanel7, BorderLayout.SOUTH);
                    jPanel7.setLayout(jPanel7Layout);
                    jPanel7.setPreferredSize(new java.awt.Dimension(520, 36));
                    {
                        clipboardListJar = new JButton();
                        jPanel7.add(clipboardListJar);
                        clipboardListJar.setText("jar list to clipboard");
                        clipboardListJar.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                List<File> list = fetchPomDependencyTableJarList();
                                StringBuilder sb = new StringBuilder();
                                for (File f : list) {
                                    sb.append(f + "\n");
                                }
                                ClipboardUtil.getInstance().setContents(sb);
                                JOptionPaneUtil.newInstance().iconInformationMessage()
                                        .showMessageDialog("clipboard set ok!", "SUCCESS");
                            }
                        });
                    }
                    {
                        pomOutputJarDir = new JButton();
                        jPanel7.add(pomOutputJarDir);
                        pomOutputJarDir.setText("set output jar dir");
                        pomOutputJarDir.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                File file = JFileChooserUtil.newInstance().selectDirectoryOnly()
                                        .showDialog("?Jar").getApproveSelectedFile();
                                if (file == null) {
                                    JOptionPaneUtil.newInstance().iconErrorMessage()
                                            .showMessageDialog("dir is not correct!!", "ERROR");
                                    return;
                                }
                                pomOutputJarDir_ = file;
                            }
                        });
                    }
                    {
                        exportListJar = new JButton();
                        jPanel7.add(exportListJar);
                        exportListJar.setText("export list jar");
                        exportListJar.setPreferredSize(new java.awt.Dimension(113, 24));
                        exportListJar.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                List<File> list = fetchPomDependencyTableJarList();
                                if (pomOutputJarDir_ == null || !pomOutputJarDir_.exists()
                                        || !pomOutputJarDir_.isDirectory()) {
                                    JOptionPaneUtil.newInstance().iconErrorMessage()
                                            .showMessageDialog("output dir is not correct!!", "ERROR");
                                    return;
                                }
                                if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION == JOptionPaneUtil
                                        .newInstance().confirmButtonYesNo().iconWaringMessage()
                                        .showConfirmDialog("are you sure copy list jar count:(" + list.size()
                                                + ") to\n" + pomOutputJarDir_, "WARN")) {
                                    StringBuilder sb = new StringBuilder();
                                    StringBuilder fsb = new StringBuilder();
                                    sb.append("total : " + list.size() + "\n");
                                    int ok = 0;
                                    int noOk = 0;
                                    for (File f : list) {
                                        try {
                                            FileUtil.copyFile(f, new File(pomOutputJarDir_, f.getName()));
                                            ok++;
                                        } catch (IOException e) {
                                            e.printStackTrace();
                                            noOk++;
                                            fsb.append(f + "\n");
                                        }
                                    }
                                    sb.append("success : " + ok + "\n");
                                    sb.append("failed : " + noOk + "\n");
                                    sb.append("Failed jar :\n");
                                    sb.append(fsb);

                                    JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog(sb,
                                            "COPY RESULT");
                                }

                            }
                        });
                    }
                }
            }
        }
        this.setSize(541, 365);

        reloadRepositoryDir();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:edu.ku.brc.specify.plugins.TaxonLabelFormatting.java

/**
 * Formats the same String./*from ww w. ja va2  s .  c o m*/
 */
protected void doFormatting() {
    drawList.clear();

    Object fmtObj = formatCBX.getValue();
    if (fmtObj == null) {
        return;
    }

    String format = fmtObj.toString();
    //System.out.println("["+format+"]");
    if (StringUtils.isNotEmpty(format) && format.length() > 0) {
        DefaultListModel model = (DefaultListModel) authorsList.getModel();

        StringBuilder chars = new StringBuilder();
        StringBuilder exp = new StringBuilder();
        int len = format.length();
        StringBuilder pat = new StringBuilder();
        for (int i = 0; i < len; i++) {
            char ch = format.charAt(i);
            if (ch == '%') {
                if (chars.length() > 0) {
                    drawList.add(new TextDrawInfo(FormatType.Plain, chars.toString()));
                    chars.setLength(0);
                }
                ch = format.charAt(++i);
                pat.setLength(0);
                pat.append('%');
                do {
                    if (Character.isLetter(ch) || Character.isDigit(ch)) {
                        pat.append(ch);
                    } else {
                        i--;
                        break;
                    }
                    i++;
                    if (i < len) {
                        ch = format.charAt(i);
                    }
                } while (i < len);

                FormatType ft = FormatType.Plain;
                String val = "";
                String token = pat.toString();
                if (token.equals("%S")) {
                    val = getByRank(taxon, 220).getName();
                    ft = FormatType.Italic;

                } else if (token.equals("%G")) {
                    val = getByRank(taxon, 180).getName();
                    ft = FormatType.Italic;

                } else if (token.charAt(1) == 'A') {
                    int authNum = Integer.parseInt(token.substring(2)) - 1;
                    if (authNum < model.getSize()) {
                        val = ((Agent) model.get(authNum)).getLastName();
                    } else {
                        val = token;
                    }
                }
                exp.append(val);
                drawList.add(new TextDrawInfo(ft, val));
            } else {
                exp.append(ch);
                chars.append(ch);
            }
        }
        if (chars.length() > 0) {
            drawList.add(new TextDrawInfo(FormatType.Plain, chars.toString()));
            chars.setLength(0);
        }
        specialLabel.repaint();
    }
}

From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java

private String checkInfos(final boolean submodel) {
    final DefaultListModel listModel = (DefaultListModel) parameterList.getModel();
    for (int i = 0; i < listModel.getSize(); ++i) {
        final AvailableParameter param = (AvailableParameter) listModel.get(i);
        final String invalid = submodel ? checkSubmodelInfo(param.info) : checkFileInfo(param);
        if (invalid != null)
            return invalid;
    }//w  w w .  j  a  v  a 2s. co  m

    for (final ParameterCombinationGUI pGUI : parameterTreeBranches) {
        final DefaultMutableTreeNode root = pGUI.combinationRoot;
        @SuppressWarnings("rawtypes")
        final Enumeration nodes = root.breadthFirstEnumeration();
        nodes.nextElement(); // root
        while (nodes.hasMoreElements()) {
            final DefaultMutableTreeNode node = (DefaultMutableTreeNode) nodes.nextElement();
            final ParameterInATree userObj = (ParameterInATree) node.getUserObject();
            final String invalid = submodel ? checkSubmodelInfo(userObj.info) : checkFileInfo(userObj);
            if (invalid != null)
                return invalid;
        }
    }

    return null;
}

From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java

private ParameterTree createParameterTreeFromParamSweepGUI() throws ModelInformationException {
    final ParameterTree result = new ParameterTree();

    final DefaultListModel listModel = (DefaultListModel) parameterList.getModel();
    for (int i = 0; i < listModel.getSize(); ++i) {
        final AvailableParameter param = (AvailableParameter) listModel.get(i);
        final AbstractParameterInfo<?> batchParameter = InfoConverter.parameterInfo2ParameterInfo(param.info);
        ParameterTreeUtils.addConstantParameterToParameterTree(batchParameter, result, currentModelHandler);
    }/* w  w  w .ja  va2s  .  com*/

    for (final ParameterCombinationGUI pGUI : parameterTreeBranches) {
        final DefaultMutableTreeNode root = pGUI.combinationRoot;
        @SuppressWarnings("rawtypes")
        final Enumeration nodes = root.breadthFirstEnumeration();
        nodes.nextElement(); // root;
        while (nodes.hasMoreElements()) {
            final DefaultMutableTreeNode node = (DefaultMutableTreeNode) nodes.nextElement();
            final ParameterInATree userObj = (ParameterInATree) node.getUserObject();
            ParameterTreeUtils.filterConstants(userObj, result, currentModelHandler);
        }
    }

    for (final ParameterCombinationGUI pGUI : parameterTreeBranches) {
        final DefaultMutableTreeNode root = pGUI.combinationRoot;
        @SuppressWarnings("rawtypes")
        final Enumeration nodes = root.preorderEnumeration();
        nodes.nextElement(); // root
        ParameterNode parent = result.getRoot();
        while (nodes.hasMoreElements()) {
            final DefaultMutableTreeNode node = (DefaultMutableTreeNode) nodes.nextElement();
            final ParameterInATree userObj = (ParameterInATree) node.getUserObject();
            if (ParameterTreeUtils.isMutableParameter(userObj)) {
                final AbstractParameterInfo<?> batchParameter = InfoConverter
                        .parameterInfo2ParameterInfo(userObj.info);
                batchParameter.setRunNumber(1);
                final ParameterNode parameterNode = new ParameterNode(batchParameter);
                parent.add(parameterNode);
                parent = parameterNode;
            }
        }
    }

    return result;
}

From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java

private void savePSParameterList(final ObjectFactory factory, final Model model) {
    final DefaultListModel listModel = (DefaultListModel) parameterList.getModel();

    if (!listModel.isEmpty()) {
        for (int i = 0; i < listModel.getSize(); ++i) {
            final AvailableParameter availableParameter = (AvailableParameter) listModel.get(i);

            final DefaultParameter defaultParameter = factory.createDefaultParameter();
            defaultParameter.setName(availableParameter.info.getName());
            model.getDefaultParameterList().add(defaultParameter);
        }//  w  ww. ja v  a 2  s  . com
    }
}