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:de.tor.tribes.ui.windows.TribeTribeAttackFrame.java

private void fireAddVillagesEvent(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_fireAddVillagesEvent
    List<Village> villages = new ArrayList<Village>();
    if (evt.getSource() == jAllSources) {
        DefaultListModel model = (DefaultListModel) jSourceVillageList.getModel();
        for (int i = 0; i < model.getSize(); i++) {
            villages.add((Village) model.getElementAt(i));
        }/*w w w . j  a  v a 2s .  c o m*/
        fireAddSourcesEvent(villages);
    } else if (evt.getSource() == jSelectedSources) {
        Object[] selection = jSourceVillageList.getSelectedValues();
        if (selection == null || selection.length == 0) {
            showInfo("Keine Drfer gewhlt");
            return;
        }
        for (Object v : selection) {
            villages.add((Village) v);
        }
        fireAddSourcesEvent(villages);
    } else if (evt.getSource() == jAllTargets) {
        DefaultListModel model = (DefaultListModel) jTargetVillageList.getModel();
        for (int i = 0; i < model.getSize(); i++) {
            villages.add((Village) model.getElementAt(i));
        }
        fireAddTargetsEvent(villages);
    } else if (evt.getSource() == jSelectedTargets) {
        Object[] selection = jTargetVillageList.getSelectedValues();
        if (selection == null || selection.length == 0) {
            showInfo("Keine Drfer gewhlt");
            return;
        }
        for (Object v : selection) {
            villages.add((Village) v);
        }
        fireAddTargetsEvent(villages);
    }
    showInfo(villages.size() + ((villages.size() == 1) ? " Dorf " : " Drfer ") + "eingefgt");

}

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

private void initGUI() {
    try {//from w  ww  .j  a va 2 s .co m
        final SwingActionUtil swingUtil = (SwingActionUtil) SwingActionUtil.newInstance(this);

        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        this.setTitle("3DS Rename");
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("vid list", null, jPanel1, null);
                {
                    openDir = new JButton();
                    jPanel1.add(openDir, BorderLayout.NORTH);
                    openDir.setText("open dir");
                    openDir.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("openDir.actionPerformed", evt);
                        }
                    });
                }
                {
                    ListModel vidListModel = new DefaultListModel();
                    vidList = new JList();
                    jPanel1.add(vidList, BorderLayout.CENTER);
                    vidList.setModel(vidListModel);
                    vidList.addMouseListener(new MouseAdapter() {
                        public void mouseClicked(MouseEvent evt) {
                            swingUtil.invokeAction("vidList.mouseClicked", evt);
                        }
                    });
                    vidList.addKeyListener(new KeyAdapter() {
                        public void keyPressed(KeyEvent evt) {
                            swingUtil.invokeAction("vidList.keyPressed", evt);
                        }
                    });
                }
                {
                    jPanel3 = new JPanel();
                    jPanel1.add(jPanel3, BorderLayout.SOUTH);
                    jPanel3.setPreferredSize(new java.awt.Dimension(445, 34));
                    {
                        renameText = new JTextField();
                        jPanel3.add(renameText);
                        renameText.setPreferredSize(new java.awt.Dimension(187, 24));
                    }
                    {
                        renameBtn = new JButton();
                        jPanel3.add(renameBtn);
                        renameBtn.setText("rename");
                        renameBtn.setPreferredSize(new java.awt.Dimension(106, 24));
                        renameBtn.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                swingUtil.invokeAction("renameBtn.mouseClicked", evt);
                            }
                        });
                    }
                    {
                        forceChange = new JCheckBox();
                        jPanel3.add(forceChange);
                        forceChange.setText("force");
                        forceChange.setPreferredSize(new java.awt.Dimension(64, 21));
                    }
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("copy", null, jPanel2, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel2.add(jScrollPane1, BorderLayout.CENTER);
                    {
                        ListModel copyToListModel = new DefaultListModel();
                        copyToList = new JList();
                        jScrollPane1.setViewportView(copyToList);
                        copyToList.setModel(copyToListModel);
                        copyToList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                swingUtil.invokeAction("copyToList.mouseClicked", evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel4 = new JPanel();
                BorderLayout jPanel4Layout = new BorderLayout();
                jPanel4.setLayout(jPanel4Layout);
                jTabbedPane1.addTab("BT Movie", null, jPanel4, null);
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel4.add(jScrollPane2, BorderLayout.WEST);
                    jScrollPane2.setPreferredSize(new java.awt.Dimension(254, 355));
                    {
                        btDirTree = new JTree();
                        jScrollPane2.setViewportView(btDirTree);
                        btDirTree.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                swingUtil.invokeAction(evt);
                            }
                        });
                        btDirTree.addPropertyChangeListener(new PropertyChangeListener() {
                            public void propertyChange(PropertyChangeEvent evt) {
                                swingUtil.invokeAction(evt);
                            }
                        });
                        JTreeUtil.newInstance(btDirTree).fileSystem(DEFAULT_BT_DIR);
                    }
                }
                {
                    jPanel5 = new JPanel();
                    BorderLayout jPanel5Layout = new BorderLayout();
                    jPanel5.setLayout(jPanel5Layout);
                    jPanel4.add(jPanel5, BorderLayout.CENTER);
                    {
                        jScrollPane3 = new JScrollPane();
                        jPanel5.add(jScrollPane3, BorderLayout.CENTER);
                        jScrollPane3.setPreferredSize(new java.awt.Dimension(427, 355));
                        {
                            DefaultListModel btMovListModel = new DefaultListModel();
                            btMovList = new JList();
                            jScrollPane3.setViewportView(btMovList);
                            btMovList.setModel(btMovListModel);
                            btMovList.addMouseListener(new MouseAdapter() {
                                public void mouseClicked(MouseEvent evt) {
                                    swingUtil.invokeAction(evt);
                                }
                            });
                            btMovList.addKeyListener(new KeyAdapter() {
                                public void keyPressed(KeyEvent evt) {
                                    JListUtil.newInstance(btMovList).defaultJListKeyPressed(evt);
                                }
                            });
                        }
                    }
                }
            }
            {
                jPanel6 = new JPanel();
                FlowLayout jPanel6Layout = new FlowLayout();
                jTabbedPane1.addTab("common", null, jPanel6, null);
                jPanel6.setLayout(jPanel6Layout);
                {
                    execute3dsVidTransfer = new JButton();
                    jPanel6.add(execute3dsVidTransfer);
                    execute3dsVidTransfer.setText("execute 3ds video transfer");
                    execute3dsVidTransfer.setPreferredSize(new java.awt.Dimension(207, 42));
                    execute3dsVidTransfer.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            String bat = "C:/apps/_movie/3DSVideov1.00/3DS Video.exe";
                            try {
                                Runtime.getRuntime().exec(String.format("cmd /c call \"%s\"", bat));
                            } catch (IOException e) {
                                JCommonUtil.handleException(e);
                            }
                        }
                    });
                }
                {
                    openMovieAppDir = new JButton();
                    jPanel6.add(openMovieAppDir);
                    openMovieAppDir.setText("open movie app dir");
                    openMovieAppDir.setPreferredSize(new java.awt.Dimension(207, 42));
                    openMovieAppDir.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            try {
                                Desktop.getDesktop().open(new File("C:/apps/_movie"));
                            } catch (IOException e) {
                                JCommonUtil.handleException(e);
                            }
                        }
                    });
                }
            }
            {
                jPanel7 = new JPanel();
                BorderLayout jPanel7Layout = new BorderLayout();
                jTabbedPane1.addTab("fake rename", null, jPanel7, null);
                jPanel7.setLayout(jPanel7Layout);
                {
                    openFakeRenameDir = new JButton();
                    jPanel7.add(openFakeRenameDir, BorderLayout.NORTH);
                    openFakeRenameDir.setText("open dir");
                    openFakeRenameDir.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File file = JCommonUtil._jFileChooser_selectDirectoryOnly();
                            if (file != null) {
                                DefaultListModel model = new DefaultListModel();
                                for (File f : file.listFiles()) {
                                    model.addElement(f);
                                }
                                openFakeRenameDirList.setModel(model);
                            }
                        }
                    });
                }
                {
                    DefaultListModel openFakeRenameDirListModel = new DefaultListModel();
                    openFakeRenameDirList = new JList();
                    jPanel7.add(openFakeRenameDirList, BorderLayout.CENTER);
                    openFakeRenameDirList.setModel(openFakeRenameDirListModel);
                    openFakeRenameDirList.addMouseListener(new MouseAdapter() {
                        public void mouseClicked(MouseEvent evt) {
                            File file = (File) JListUtil.getLeadSelectionObject(openFakeRenameDirList);
                            try {
                                Process process = Runtime.getRuntime()
                                        .exec(String.format("cmd /c call \"%s\"", file));
                                InputStream ins = process.getInputStream();
                                while (ins.read() != -1) {
                                    //TODO
                                }
                                ins.close();
                                System.out.println("done...");
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                        }
                    });
                    openFakeRenameDirList.addKeyListener(new KeyAdapter() {
                        public void keyPressed(KeyEvent evt) {
                            JListUtil.newInstance(openFakeRenameDirList).defaultJListKeyPressed(evt);
                        }
                    });
                }
                {
                    jPanel8 = new JPanel();
                    jPanel7.add(jPanel8, BorderLayout.SOUTH);
                    jPanel8.setPreferredSize(new java.awt.Dimension(681, 43));
                    {
                        openFakeRenameDir_newName = new JTextField();
                        jPanel8.add(openFakeRenameDir_newName);
                        openFakeRenameDir_newName.setPreferredSize(new java.awt.Dimension(287, 27));
                    }
                    {
                        fakeRenameExecute = new JButton();
                        jPanel8.add(fakeRenameExecute);
                        fakeRenameExecute.setText("execute");
                        fakeRenameExecute.setPreferredSize(new java.awt.Dimension(95, 27));
                        fakeRenameExecute.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                DefaultListModel model = (DefaultListModel) openFakeRenameDirList.getModel();
                                //TODO
                            }
                        });
                    }
                }
            }

            swingUtil.addAction("copyToList.mouseClicked", new Action() {
                public void action(EventObject evt) throws Exception {
                    try {
                        if (((MouseEvent) evt).getButton() == 3) {
                            JMenuItem reloadMenu = new JMenuItem();
                            reloadMenu.setText("reload SD card directory");
                            reloadMenu.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    DefaultListModel copyToListModel = new DefaultListModel();
                                    for (final File f : load3DSDir.listFiles(new FilenameFilter() {
                                        public boolean accept(File paramFile, String paramString) {
                                            if (paramFile.isDirectory()
                                                    && paramString.matches(CUSTOM_3DS_DIR_PATTERN)) {
                                                return true;
                                            }
                                            return false;
                                        }
                                    })) {
                                        copyToListModel.addElement(f);
                                    }
                                    copyToList.setModel(copyToListModel);
                                }
                            });
                            JMenuItem copyAllToMenu = new JMenuItem();
                            {
                                copyAllToMenu.setText(
                                        String.format("move %d vids to...", vidList.getModel().getSize()));
                                final File toDir = (File) JListUtil.getLeadSelectionObject(copyToList);
                                if (toDir == null || !toDir.exists() || !toDir.isDirectory()) {
                                    copyAllToMenu.setEnabled(false);
                                }
                                if (vidList.getModel().getSize() == 0) {
                                    copyAllToMenu.setText("copy no file...");
                                    copyAllToMenu.setEnabled(false);
                                }
                                copyAllToMenu.addActionListener(new ActionListener() {
                                    public void actionPerformed(ActionEvent e) {
                                        DefaultListModel model = JListUtil.newInstance(vidList).getModel();
                                        if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION != JOptionPaneUtil
                                                .newInstance().iconWaringMessage().confirmButtonYesNo()
                                                .showConfirmDialog("are you sure copy files : "
                                                        + model.getSize() + "\n to dir : " + toDir,
                                                        "COPY VIDS")) {
                                            return;
                                        }
                                        for (int ii = 0; ii < model.getSize(); ii++) {
                                            File src = (File) model.getElementAt(ii);
                                            src.renameTo(new File(toDir, src.getName()));
                                        }
                                        JOptionPaneUtil.newInstance().iconInformationMessage()
                                                .showMessageDialog("copy completed!", "SUCCESS");
                                        loadDirVids();
                                    }
                                });
                            }

                            JPopupMenuUtil.newInstance(copyToList).applyEvent((MouseEvent) evt)
                                    .addJMenuItem(reloadMenu, copyAllToMenu).show();
                        }
                    } catch (Exception ex) {
                        JCommonUtil.handleException(ex);
                    }
                }
            });
            swingUtil.addAction("openDir.actionPerformed", new Action() {
                public void action(EventObject evt) throws Exception {
                    File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                            .getApproveSelectedFile();
                    if (file == null) {
                        JOptionPaneUtil.newInstance().iconErrorMessage()
                                .showMessageDialog("dir not corrent!, set desktop", getTitle());
                        loadDir = FileUtil.DESKTOP_DIR;
                    } else {
                        loadDir = file;
                    }
                    loadDirVids();
                }
            });
            swingUtil.addAction("vidList.mouseClicked", new Action() {
                //                    final String player = "C:/Program Files (x86)/GRETECH/GomPlayer/GOM.EXE";

                public void action(EventObject evt) throws Exception {
                    int pos = -1;
                    if ((pos = vidList.getLeadSelectionIndex()) == -1) {
                        return;
                    }
                    MouseEvent mevt = (MouseEvent) evt;

                    final File selectItem = (File) vidList.getModel().getElementAt(pos);

                    List<JMenuItem> menuList = new ArrayList<JMenuItem>();
                    JMenuItem simpleRenamer = new JMenuItem();
                    final String simpleRenamePrefix = RandomUtil.upperCase(3);
                    simpleRenamer.setText("Rename : " + simpleRenamePrefix);
                    simpleRenamer.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent paramActionEvent) {
                            String value = StringUtils.defaultString(JOptionPaneUtil.newInstance()
                                    .showInputDialog("3 char prefix?", "AVI PREFIX"), simpleRenamePrefix);
                            if (value != null && value.matches("[a-zA-Z]{3}")) {
                                selectItem.renameTo(getNewFile(selectItem.getParentFile(), value));
                                loadDirVids();
                            } else {
                                JOptionPaneUtil.newInstance().iconErrorMessage()
                                        .showMessageDialog("prefix is not correct!", "ERROR");
                            }
                        }
                    });
                    menuList.add(simpleRenamer);
                    if (load3DSDir == null) {
                        reload3DSDir();
                        if (load3DSDir == null) {
                            JMenuItem disable = new JMenuItem();
                            disable.setText("MOVE : SD card is not set!");
                            disable.setEnabled(false);
                            menuList.add(disable);
                        }
                    } else {
                        for (final File f : load3DSDir.listFiles(new FilenameFilter() {
                            public boolean accept(File paramFile, String paramString) {
                                if (paramFile.isDirectory() && paramString.matches(CUSTOM_3DS_DIR_PATTERN)) {
                                    return true;
                                }
                                return false;
                            }
                        })) {
                            JMenuItem copyTo = new JMenuItem();
                            copyTo.setText("MOVE : " + f.getName());
                            copyTo.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent paramActionEvent) {
                                    if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION == JOptionPaneUtil
                                            .newInstance().iconQuestionMessage().confirmButtonYesNo()
                                            .showConfirmDialog(//
                                                    "are you sure move file\n" + //
                                    selectItem + "\n" + //
                                    "to\n" + //
                                    "dir : " + f + "  ??"//
                                    , "COPY FILE")) {

                                        File copyToNewDirFile = new File(f, selectItem.getName());
                                        if (copyToNewDirFile.exists()) {
                                            JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog(
                                                    "target dir file already exist!, need rename!",
                                                    "FILE ALREADY EXIST");
                                            return;
                                        }
                                        selectItem.renameTo(copyToNewDirFile);
                                        loadDirVids();

                                        JOptionPaneUtil.newInstance().iconErrorMessage()
                                                .showMessageDialog("move completed!", "MOVE FILE");
                                    }
                                }
                            });
                            menuList.add(copyTo);
                        }
                    }
                    JPopupMenuUtil.newInstance(vidList).applyEvent(mevt)
                            .addJMenuItem(menuList.toArray(new JMenuItem[menuList.size()])).show();

                    if (mevt.getClickCount() != 2) {
                        return;
                    }
                    String clkItemPath = selectItem.getAbsolutePath();
                    String command = "cmd /c call \"" + clkItemPath + "\"";
                    System.out.println(command);
                    Runtime.getRuntime().exec(command);
                }
            });
            swingUtil.addAction("vidList.keyPressed", new Action() {
                public void action(EventObject evt) throws Exception {
                    JListUtil.newInstance(vidList).defaultJListKeyPressed(evt);
                }
            });
            swingUtil.addAction("renameBtn.mouseClicked", new Action() {

                Pattern aviNamePattern = Pattern.compile("^([a-zA-Z]{3})_\\d{4}\\.[aA][vV][iI]$");

                public void action(EventObject evt) throws Exception {
                    String name = StringUtils.defaultIfEmpty(renameText.getText(), RandomUtil.upperCase(3));
                    System.out.println("name = " + name + ", force : " + forceChange.isSelected());
                    if (!name.matches("[a-zA-Z]{3}")) {
                        renameText.setText("");
                        JOptionPaneUtil.newInstance().iconErrorMessage()
                                .showMessageDialog("rename must eng 3 char!", "ERROR");
                        return;
                    }
                    DefaultListModel model = (DefaultListModel) vidList.getModel();
                    boolean matchOk = false;
                    if (model.size() != 0) {
                        File oldFile = null;
                        Matcher matcher = null;
                        for (int ii = 0; ii < model.getSize(); ii++) {
                            oldFile = (File) model.getElementAt(ii);

                            if (!oldFile.exists()) {
                                JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog(
                                        "file not exeist : \n" + oldFile.getAbsolutePath(), getTitle());
                                return;
                            }
                            matcher = aviNamePattern.matcher(oldFile.getName());
                            matchOk = matcher.find();
                            System.out.println("matchOk = " + matchOk);
                            if (matchOk && !forceChange.isSelected()) {
                                oldFile.renameTo(getNewFile(oldFile.getParentFile(), matcher.group(1)));
                            } else {
                                oldFile.renameTo(getNewFile(oldFile.getParentFile(), name));
                            }
                        }
                        JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog("success!",
                                getTitle());
                    }
                    loadDirVids();
                }
            });

            ToolTipManager.sharedInstance().setInitialDelay(0);
            swingUtil.addAction(btMovList, MouseEvent.class, new Action() {
                public void action(EventObject evt) throws Exception {
                    final File file = (File) JListUtil.getLeadSelectionObject(btMovList);
                    if (JMouseEventUtil.buttonLeftClick(1, evt)) {
                        btMovList.setToolTipText(
                                DateFormatUtils.format(file.lastModified(), "yyyy/MM/dd HH:mm:ss") + " length:"
                                        + (file.length() / 1024) + "k");
                    }

                    final Object[] objects = btMovList.getSelectedValues();
                    JPopupMenuUtil.newInstance(btMovList).applyEvent(evt)//
                            .addJMenuItem("move out", (objects != null && objects.length > 0),
                                    new ActionListener() {
                                        public void actionPerformed(ActionEvent paramActionEvent) {
                                            List<File> list = new ArrayList<File>();
                                            for (Object val : objects) {
                                                list.add((File) val);
                                            }
                                            if (!JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption(
                                                    "sure move file from\n" + list.toString().replace(',', '\n')
                                                            + "\nto\n" + DEFAULT_BT_DIR,
                                                    "MOVE")) {
                                                return;
                                            }
                                            StringBuilder sb = new StringBuilder();
                                            File moveTo = null;
                                            for (File file : list) {
                                                sb.append((file.renameTo(
                                                        moveTo = new File(DEFAULT_BT_DIR, file.getName()))
                                                        && moveTo.exists()) ? "" : file + "\n");
                                            }
                                            JCommonUtil._jOptionPane_showMessageDialog_info(
                                                    sb.length() == 0 ? "move success!" : "move failed!\n" + sb);
                                        }
                                    })
                            .addJMenuItem("delete this", file.exists(), new ActionListener() {
                                public void actionPerformed(ActionEvent paramActionEvent) {
                                    if (!JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption(
                                            "sure delete file \n" + file, "DELETE")) {
                                        return;
                                    }
                                    boolean result = file.delete();
                                    System.out.println("!!!!!" + result + "..." + file.exists());
                                    JCommonUtil._jOptionPane_showMessageDialog_info(
                                            result ? "delete success!" : "delete failed!");
                                }
                            }).show();

                    if (JMouseEventUtil.buttonLeftClick(2, evt)) {
                        Runtime.getRuntime().exec(String.format("cmd /c call \"%s\"", file));
                    }
                }
            });
            swingUtil.addAction(btDirTree, MouseEvent.class, new Action() {

                File getSingleFile() {
                    return ((JFile) JTreeUtil.newInstance(btDirTree).getSelectItem().getUserObject()).getFile();
                }

                public void action(EventObject evt) throws Exception {
                    int selectCount = btDirTree.getSelectionModel().getSelectionCount();
                    if (selectCount == 1) {
                        final File file = getSingleFile();
                        JPopupMenuUtil.newInstance(btDirTree).applyEvent(evt).addJMenuItem("delete this",
                                selectCount == 1 && file.exists(), new ActionListener() {
                                    public void actionPerformed(ActionEvent paramActionEvent) {
                                        if (file.isFile()) {
                                            if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption(
                                                    "sure delete FILE : \n" + file, "WARNING")) {
                                                file.delete();
                                                JCommonUtil._jOptionPane_showMessageDialog_info(
                                                        (file.exists() ? "delete failed!" : "delete success!"));
                                            }
                                        }
                                        if (file.isDirectory()) {
                                            StringBuilder sb = new StringBuilder();
                                            if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption(
                                                    "sure delete DIR : \n" + file, "WARNING")) {
                                                List<Boolean> delL = new ArrayList<Boolean>();
                                                for (File f : file.listFiles()) {
                                                    if (fileExtensionPattern.matcher(f.getName()).find()
                                                            || f.length() > 1000000L) {
                                                        if (!JCommonUtil
                                                                ._JOptionPane_showConfirmDialog_yesNoOption(
                                                                        "delete this : \n" + f,
                                                                        "CHECK AGAIN")) {
                                                            continue;
                                                        }
                                                        delL.add(f.delete());
                                                    }
                                                    delL.add(f.delete());
                                                }
                                                for (File f : file.listFiles()) {
                                                    if (f.exists()) {
                                                        sb.append(f + "\n");
                                                    }
                                                }
                                                System.out.println("delL.contains(false)==================>"
                                                        + delL.contains(false));
                                            }
                                            if (!file.delete()) {
                                                sb.append(file + "\n");
                                            }
                                            JCommonUtil._jOptionPane_showMessageDialog_info(
                                                    sb.length() > 0 ? "delete failed!\nlist:\n" + sb
                                                            : "delete success!");
                                            if (sb.length() == 0) {
                                                DefaultMutableTreeNode node = JTreeUtil.newInstance(btDirTree)
                                                        .getSelectItem();
                                                System.out.println(
                                                        JTreeUtil.newInstance(btDirTree).removeNode(node));
                                            }
                                        }
                                    }
                                }).addJMenuItem("open dir", new ActionListener() {
                                    public void actionPerformed(ActionEvent paramActionEvent) {
                                        File openTarget = file;
                                        if (file.isFile()) {
                                            openTarget = file.getParentFile();
                                        }
                                        try {
                                            Desktop.getDesktop().open(openTarget);
                                        } catch (IOException e) {
                                            JCommonUtil.handleException(e);
                                        }
                                    }
                                }).show();
                    }
                }
            });
            swingUtil.addAction(btDirTree, PropertyChangeEvent.class, new Action() {
                public void action(EventObject evt) throws Exception {
                    List<File> list = new ArrayList<File>();
                    for (DefaultMutableTreeNode node : JTreeUtil.newInstance(btDirTree).getSelectItems()) {
                        JFile jfile = (JFile) node.getUserObject();
                        if (jfile.getFile().isDirectory()) {
                            for (File f : jfile.getFile().listFiles(new FilenameFilter() {
                                public boolean accept(File paramFile, String paramString) {
                                    return fileExtensionPattern.matcher(paramString).find();
                                }
                            })) {
                                System.out.println(f.getName() + "...." + f.length());
                                list.add(f);
                            }
                        }
                    }
                    Collections.sort(list, new Comparator<File>() {
                        public int compare(File paramT1, File paramT2) {
                            return paramT1.lastModified() > paramT2.lastModified() ? -1 : 1;
                        }
                    });
                    btMovList.setModel(JListUtil.createModel(list.iterator()));
                }
            });
        }
        this.setSize(702, 422);

        loadDirVids();
        reload3DSDir();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

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

private void initGUI() {
    try {//from   w  w w .  j a  va 2  s  . c om
        {
        }
        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);
                jTabbedPane1.addTab("source", null, jPanel1, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    {
                        ListModel srcListModel = new DefaultListModel();
                        srcList = new JList();
                        jScrollPane1.setViewportView(srcList);
                        srcList.setModel(srcListModel);
                        {
                            panel = new JPanel();
                            jScrollPane1.setRowHeaderView(panel);
                            panel.setLayout(new FormLayout(
                                    new ColumnSpec[] { ColumnSpec.decode("default:grow"), },
                                    new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                                            FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
                                            FormFactory.DEFAULT_ROWSPEC, }));
                            {
                                childrenDirChkbox = new JCheckBox("??");
                                childrenDirChkbox.setSelected(true);
                                panel.add(childrenDirChkbox, "1, 1");
                            }
                            {
                                subFileNameText = new JTextField();
                                panel.add(subFileNameText, "1, 2, fill, default");
                                subFileNameText.setColumns(10);
                                subFileNameText.setText("(txt|java)");
                            }
                            {
                                replaceOldFileChkbox = new JCheckBox("");
                                replaceOldFileChkbox.setSelected(true);
                                panel.add(replaceOldFileChkbox, "1, 3");
                            }
                            {
                                charsetText = new JTextField();
                                panel.add(charsetText, "1, 5, fill, default");
                                charsetText.setColumns(10);
                                charsetText.setText("UTF8");
                            }
                        }
                        srcList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                JListUtil.newInstance(srcList).defaultMouseClickOpenFile(evt);

                                JPopupMenuUtil.newInstance(srcList).applyEvent(evt)//
                                        .addJMenuItem("load files from clipboard", new ActionListener() {
                                            public void actionPerformed(ActionEvent arg0) {
                                                String content = ClipboardUtil.getInstance().getContents();
                                                DefaultListModel model = (DefaultListModel) srcList.getModel();
                                                StringTokenizer tok = new StringTokenizer(content, "\t\n\r\f",
                                                        false);
                                                for (; tok.hasMoreElements();) {
                                                    String val = ((String) tok.nextElement()).trim();
                                                    model.addElement(new File(val));
                                                }
                                            }
                                        }).show();
                            }
                        });
                        srcList.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                JListUtil.newInstance(srcList).defaultJListKeyPressed(evt);
                            }
                        });
                    }
                }
                {
                    addDirFiles = new JButton();
                    jPanel1.add(addDirFiles, BorderLayout.NORTH);
                    addDirFiles.setText("add dir files");
                    addDirFiles.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent evt) {
                            File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                                    .getApproveSelectedFile();
                            if (file == null || !file.isDirectory()) {
                                return;
                            }

                            List<File> fileLst = new ArrayList<File>();

                            String subName = StringUtils.trimToEmpty(subFileNameText.getText());
                            if (StringUtils.isBlank(subName)) {
                                subName = ".*";
                            }
                            String patternStr = ".*\\." + subName;

                            if (childrenDirChkbox.isSelected()) {
                                FileUtil.searchFileMatchs(file, patternStr, fileLst);
                            } else {
                                for (File f : file.listFiles()) {
                                    if (f.isFile() && f.getName().matches(patternStr)) {
                                        fileLst.add(f);
                                    }
                                }
                            }

                            DefaultListModel model = new DefaultListModel();
                            for (File f : fileLst) {
                                model.addElement(f);
                            }
                            srcList.setModel(model);
                        }
                    });
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("param", null, jPanel2, null);
                {
                    exeucte = new JButton();
                    jPanel2.add(exeucte, BorderLayout.SOUTH);
                    exeucte.setText("exeucte");
                    exeucte.setPreferredSize(new java.awt.Dimension(491, 125));
                    exeucte.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            exeucteActionPerformed(evt);
                        }
                    });
                }
                {
                    jPanel3 = new JPanel();
                    GroupLayout jPanel3Layout = new GroupLayout((JComponent) jPanel3);
                    jPanel3.setLayout(jPanel3Layout);
                    jPanel2.add(jPanel3, BorderLayout.CENTER);
                    {
                        repFromText = new JTextField();
                    }
                    {
                        repToText = new JTextField();
                    }
                    jPanel3Layout.setHorizontalGroup(jPanel3Layout.createSequentialGroup()
                            .addContainerGap(25, 25)
                            .addGroup(jPanel3Layout.createParallelGroup()
                                    .addGroup(jPanel3Layout.createSequentialGroup().addComponent(repFromText,
                                            GroupLayout.PREFERRED_SIZE, 446, GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel3Layout.createSequentialGroup().addComponent(repToText,
                                            GroupLayout.PREFERRED_SIZE, 446, GroupLayout.PREFERRED_SIZE)))
                            .addContainerGap(20, Short.MAX_VALUE));
                    jPanel3Layout.setVerticalGroup(jPanel3Layout.createSequentialGroup().addContainerGap()
                            .addComponent(repFromText, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(repToText, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
                }
                {
                    addToTemplate = new JButton();
                    jPanel2.add(addToTemplate, BorderLayout.NORTH);
                    addToTemplate.setText("add to template");
                    addToTemplate.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            prop.put(repFromText.getText(), repToText.getText());
                            reloadTemplateList();
                        }
                    });
                }
            }
            {
                jPanel4 = new JPanel();
                BorderLayout jPanel4Layout = new BorderLayout();
                jPanel4.setLayout(jPanel4Layout);
                jTabbedPane1.addTab("result", null, jPanel4, null);
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel4.add(jScrollPane2, BorderLayout.CENTER);
                    {

                        ListModel newRepListModel = new DefaultListModel();
                        newRepList = new JList();
                        jScrollPane2.setViewportView(newRepList);
                        newRepList.setModel(newRepListModel);
                        newRepList.addMouseListener(new MouseAdapter() {
                            static final String tortoiseMergeExe = "TortoiseMerge.exe";
                            static final String commandFormat = "cmd /c call \"%s\" /base:\"%s\" /theirs:\"%s\"";

                            public void mouseClicked(MouseEvent evt) {
                                if (!JListUtil.newInstance(newRepList).isCorrectMouseClick(evt)) {
                                    return;
                                }

                                OldNewFile oldNewFile = (OldNewFile) JListUtil
                                        .getLeadSelectionObject(newRepList);

                                String base = oldNewFile.newFile.getAbsolutePath();
                                String theirs = oldNewFile.oldFile.getAbsolutePath();

                                String command = String.format(commandFormat, tortoiseMergeExe, base, theirs);

                                System.out.println(command);

                                try {
                                    Runtime.getRuntime().exec(command);
                                } catch (IOException e) {
                                    JCommonUtil.handleException(e);
                                }
                            }
                        });
                        newRepList.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                Object[] objects = (Object[]) newRepList.getSelectedValues();
                                if (objects == null || objects.length == 0) {
                                    return;
                                }
                                DefaultListModel model = (DefaultListModel) newRepList.getModel();
                                int lastIndex = model.getSize() - 1;
                                Object swap = null;

                                StringBuilder dsb = new StringBuilder();
                                for (Object current : objects) {
                                    int index = model.indexOf(current);
                                    switch (evt.getKeyCode()) {
                                    case 38:// up
                                        if (index != 0) {
                                            swap = model.getElementAt(index - 1);
                                            model.setElementAt(swap, index);
                                            model.setElementAt(current, index - 1);
                                        }
                                        break;
                                    case 40:// down
                                        if (index != lastIndex) {
                                            swap = model.getElementAt(index + 1);
                                            model.setElementAt(swap, index);
                                            model.setElementAt(current, index + 1);
                                        }
                                        break;
                                    case 127:// del
                                        OldNewFile current_ = (OldNewFile) current;
                                        dsb.append(current_.newFile.getName() + "\t"
                                                + (current_.newFile.delete() ? "T" : "F") + "\n");
                                        current_.newFile.delete();
                                        model.removeElement(current);
                                    }
                                }

                                if (dsb.length() > 0) {
                                    JOptionPaneUtil.newInstance().iconInformationMessage()
                                            .showMessageDialog("del result!\n" + dsb, "DELETE");
                                }
                            }
                        });

                    }
                }
                {
                    replaceOrignFile = new JButton();
                    jPanel4.add(replaceOrignFile, BorderLayout.SOUTH);
                    replaceOrignFile.setText("replace orign file");
                    replaceOrignFile.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            DefaultListModel model = (DefaultListModel) newRepList.getModel();
                            StringBuilder sb = new StringBuilder();
                            for (int ii = 0; ii < model.size(); ii++) {
                                OldNewFile file = (OldNewFile) model.getElementAt(ii);
                                boolean delSuccess = false;
                                boolean renameSuccess = false;
                                if (delSuccess = file.oldFile.delete()) {
                                    renameSuccess = file.newFile.renameTo(file.oldFile);
                                }
                                sb.append(file.oldFile.getName() + " del:" + (delSuccess ? "T" : "F")
                                        + " rename:" + (renameSuccess ? "T" : "F") + "\n");
                            }
                            JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog(sb,
                                    getTitle());
                        }
                    });
                }
            }
            {
                jPanel5 = new JPanel();
                BorderLayout jPanel5Layout = new BorderLayout();
                jPanel5.setLayout(jPanel5Layout);
                jTabbedPane1.addTab("template", null, jPanel5, null);
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel5.add(jScrollPane3, BorderLayout.CENTER);
                    {
                        templateList = new JList();
                        reloadTemplateList();
                        jScrollPane3.setViewportView(templateList);
                        templateList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                if (templateList.getLeadSelectionIndex() == -1) {
                                    return;
                                }
                                Entry<Object, Object> entry = (Entry<Object, Object>) JListUtil
                                        .getLeadSelectionObject(templateList);
                                repFromText.setText((String) entry.getKey());
                                repToText.setText((String) entry.getValue());
                            }
                        });
                        templateList.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                JListUtil.newInstance(templateList).defaultJListKeyPressed(evt);
                            }
                        });
                    }
                }
                {
                    scheduleExecute = new JButton();
                    jPanel5.add(scheduleExecute, BorderLayout.SOUTH);
                    scheduleExecute.setText("schedule execute");
                    scheduleExecute.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            scheduleExecuteActionPerformed(evt);
                        }
                    });
                }
            }
        }
        this.setSize(512, 350);

        JCommonUtil.setFontAll(this.getRootPane());

        JCommonUtil.frameCloseDo(this, new WindowAdapter() {
            public void windowClosing(WindowEvent paramWindowEvent) {
                if (StringUtils.isNotBlank(repFromText.getText())) {
                    prop.put(repFromText.getText(), repToText.getText());
                }
                try {
                    prop.store(new FileOutputStream(propFile), "regexText");
                } catch (Exception e) {
                    JCommonUtil.handleException("properties store error!", e);
                }
                setVisible(false);
                dispose();
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}

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

private void initGUI() {
    try {//from   w  ww  .j  a v a2 s .c om
        final SwingActionUtil swingUtil = SwingActionUtil.newInstance(this);

        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        this.setTitle("SVN BACKUP");
        this.setPreferredSize(new java.awt.Dimension(734, 442));
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            jTabbedPane1.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent evt) {
                    swingUtil.invokeAction("jTabbedPane1_changeEvent", evt);
                }
            });
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("src text", null, jPanel1, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    {
                        srcArea = new JTextArea();
                        jScrollPane1.setViewportView(srcArea);
                    }
                }
                {
                    loadSrcTextarea = new JButton();
                    jPanel1.add(loadSrcTextarea, BorderLayout.SOUTH);
                    loadSrcTextarea.setText("load src textarea");
                    loadSrcTextarea.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("loadSrcTextarea.actionPerformed", evt);
                        }
                    });
                }
                {
                    srcBaseDir = new JButton();
                    jPanel1.add(srcBaseDir, BorderLayout.NORTH);
                    srcBaseDir.setText("set src base dir");
                    srcBaseDir.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("srcBaseDir.actionPerformed", evt);
                        }
                    });
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("src list", null, jPanel2, null);
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel2.add(jScrollPane2, BorderLayout.CENTER);
                    jScrollPane2.setPreferredSize(new java.awt.Dimension(531, 317));
                    {
                        ListModel srcListModel = new DefaultListModel();
                        srcList = new JList();
                        jScrollPane2.setViewportView(srcList);
                        srcList.setModel(srcListModel);
                        srcList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                swingUtil.invokeAction("srcList.mouseClicked", evt);
                            }
                        });
                        srcList.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                swingUtil.invokeAction("srcList.keyPressed", evt);
                            }
                        });
                    }
                }
                {
                    srcListQuery = new JTextField();
                    srcListQuery.getDocument()
                            .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() {
                                public void process(DocumentEvent event) {
                                    String scan = JCommonUtil.getDocumentText(event);
                                    DefaultListModel model = new DefaultListModel();
                                    Pattern pat = Pattern.compile(scan);
                                    for (LineParser line : copySrcListForQuerySet) {
                                        if (!line.file.exists()) {
                                            continue;
                                        }
                                        if (line.file.getAbsolutePath().contains(scan)) {
                                            model.addElement(line);
                                            continue;
                                        }
                                        try {
                                            if (pat.matcher(line.file.getAbsolutePath()).find()) {
                                                model.addElement(line);
                                                continue;
                                            }
                                        } catch (Exception ex) {
                                        }
                                    }
                                    srcList.setModel(model);
                                }
                            }));
                    jPanel2.add(srcListQuery, BorderLayout.NORTH);
                }
            }
            {
                jPanel3 = new JPanel();
                BorderLayout jPanel3Layout = new BorderLayout();
                jPanel3.setLayout(jPanel3Layout);
                jTabbedPane1.addTab("out list", null, jPanel3, null);
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel3.add(jScrollPane3, BorderLayout.CENTER);
                    {
                        ListModel outPutListModel = new DefaultListModel();
                        outPutList = new JList();
                        jScrollPane3.setViewportView(outPutList);
                        outPutList.setModel(outPutListModel);
                        outPutList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                swingUtil.invokeAction("outPutList.mouseClicked", evt);
                            }
                        });
                        outPutList.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                swingUtil.invokeAction("outPutList.keyPressed", evt);
                            }
                        });
                    }
                }
                {
                    outPutDir = new JButton();
                    jPanel3.add(outPutDir, BorderLayout.NORTH);
                    outPutDir.setText("set output dir");
                    outPutDir.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("outPutDir.actionPerformed", evt);
                        }
                    });
                }
                {
                    execute = new JButton();
                    jPanel3.add(execute, BorderLayout.SOUTH);
                    execute.setText("execute backup");
                    execute.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("execute.actionPerformed", evt);
                        }
                    });
                }
            }
            {
                jPanel4 = new JPanel();
                BorderLayout jPanel4Layout = new BorderLayout();
                jPanel4.setLayout(jPanel4Layout);
                jTabbedPane1.addTab("compre", null, jPanel4, null);
                {
                    jScrollPane4 = new JScrollPane();
                    jPanel4.add(jScrollPane4, BorderLayout.CENTER);
                    jScrollPane4.setPreferredSize(new java.awt.Dimension(713, 339));
                    {
                        TableModel compareTableModel = new DefaultTableModel();
                        compareTable = new JTable();
                        jScrollPane4.setViewportView(compareTable);
                        compareTable.setModel(compareTableModel);
                        JTableUtil.defaultSetting(compareTable);
                        compareTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                swingUtil.invokeAction("compareTable.mouseClicked", evt);
                            }
                        });
                    }
                }
                {
                    jPanel5 = new JPanel();
                    jPanel4.add(jPanel5, BorderLayout.NORTH);
                    jPanel5.setPreferredSize(new java.awt.Dimension(713, 42));
                    {
                        openExternalSrcFolder = new JButton();
                        jPanel5.add(openExternalSrcFolder);
                        openExternalSrcFolder.setText("open external src folder");
                        openExternalSrcFolder.setPreferredSize(new java.awt.Dimension(280, 29));
                        openExternalSrcFolder.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                swingUtil.invokeAction("openExternalSrcFolder.actionPerformed", evt);
                            }
                        });
                    }
                    {
                        startCompareMatch = new JButton();
                        jPanel5.add(startCompareMatch);
                        startCompareMatch.setText("start compare source");
                        startCompareMatch.setPreferredSize(new java.awt.Dimension(280, 29));
                        startCompareMatch.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                swingUtil.invokeAction("startCompareMatch.actionPerformed", evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel6 = new JPanel();
                GroupLayout jPanel6Layout = new GroupLayout((JComponent) jPanel6);
                jPanel6.setLayout(jPanel6Layout);
                jTabbedPane1.addTab("configuration", null, jPanel6, null);
                {
                    DefaultComboBoxModel exportModeComboModel = new DefaultComboBoxModel();
                    for (ParseMode mode : ParseMode.values()) {
                        exportModeComboModel.addElement(mode);
                    }
                    exportModeCombo = new JComboBox();
                    exportModeCombo.setModel(exportModeComboModel);
                }
                jPanel6Layout.setHorizontalGroup(jPanel6Layout
                        .createSequentialGroup().addContainerGap(41, 41).addComponent(exportModeCombo,
                                GroupLayout.PREFERRED_SIZE, 167, GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(505, Short.MAX_VALUE));
                jPanel6Layout
                        .setVerticalGroup(jPanel6Layout.createSequentialGroup().addContainerGap(30, 30)
                                .addComponent(exportModeCombo, GroupLayout.PREFERRED_SIZE,
                                        GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addContainerGap(321, Short.MAX_VALUE));
            }
            {
                jPanel7 = new JPanel();
                BorderLayout jPanel7Layout = new BorderLayout();
                jPanel7.setLayout(jPanel7Layout);
                jTabbedPane1.addTab("error log", null, jPanel7, null);
                {
                    jScrollPane5 = new JScrollPane();
                    jPanel7.add(jScrollPane5, BorderLayout.CENTER);
                    {
                        DefaultListModel errorLogListModel = new DefaultListModel();
                        errorLogList = new JList();
                        jScrollPane5.setViewportView(errorLogList);
                        errorLogList.setModel(errorLogListModel);
                    }
                }
            }
        }
        this.setSize(734, 442);

        swingUtil.addAction("openExternalSrcFolder.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                File dir = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                        .getApproveSelectedFile();
                if (dir == null) {
                    JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog("file is not correct!",
                            "ERROR");
                    return;
                }
                externalDir = dir;
            }
        });
        swingUtil.addAction("startCompareMatch.actionPerformed", new Action() {

            public void action(EventObject evt) throws Exception {
                Validate.notNull(manualBaseDir, "source folder not set!!");
                Validate.notNull(externalDir, "external folder not set!!");
                Validate.isTrue(!manualBaseDir.equals(externalDir), "source dir : " + manualBaseDir
                        + "\nexternal dir : " + externalDir + "\n cant be the same!!");

                List<File> externalSrcFolderList = new ArrayList<File>();
                FileUtil.searchFileMatchs(externalDir, ".*", externalSrcFolderList);
                System.out.println("externalSrcFolderList = " + externalSrcFolderList.size());

                List<File> manualBaseSourceList = new ArrayList<File>();
                FileUtil.searchFileMatchs(manualBaseDir, ".*", manualBaseSourceList);
                System.out.println("manualBaseSourceList = " + manualBaseSourceList.size());

                String cutExternalPath = FileUtil.exportReceiveBaseDir(externalSrcFolderList).getAbsolutePath();
                System.out.println("cutExternalPath = " + cutExternalPath);
                int cutExternalLength = cutExternalPath.length();

                List<CompareFile> _compareList = new ArrayList<CompareFile>();
                CompareFile compare = null;
                File mostCloseFile = null;
                List<File> searchMatchSrcList = new ArrayList<File>();
                for (File external : externalSrcFolderList) {
                    compare = new CompareFile();
                    compare.external = external;

                    searchMatchSrcList.clear();
                    mostCloseFile = new File(manualBaseDir,
                            external.getAbsolutePath().substring(cutExternalLength));
                    System.out.println(mostCloseFile.exists() + " == close file : " + mostCloseFile);
                    if (mostCloseFile.exists()) {
                        searchMatchSrcList.add(mostCloseFile);
                    } else {
                        for (File src : manualBaseSourceList) {
                            if (src.getName().equalsIgnoreCase(external.getName())) {
                                searchMatchSrcList.add(src);
                            }
                        }
                    }

                    System.out.println(external.getName() + " => match source : " + searchMatchSrcList.size());
                    compare.srcSet = new HashSet<File>(searchMatchSrcList);
                    _compareList.add(compare);
                }
                compareList = _compareList;
                reloadCompareTable();
            }
        });
        swingUtil.addAction("compareTable.mouseClicked", new Action() {
            String tortoiseMergeFormat = "cmd /c call TortoiseMerge /base:\"%s\" /theirs:\"%s\"";
            String openFileFormat = "cmd /c call \"%s\"";

            void openFile(File file) {
                String command = String.format(openFileFormat, file);
                System.out.println(command);
                try {
                    ProcessWatcher.newInstance(Runtime.getRuntime().exec(command)).getStreamSync();
                    System.out.println("do reload...");
                    reloadCompareTable();
                } catch (IOException e1) {
                    JCommonUtil.handleException(e1);
                }
            }

            public void action(EventObject evt) throws Exception {
                MouseEvent event = (MouseEvent) evt;

                int rowPos = JTableUtil.newInstance(compareTable).getSelectedRow();
                final File external = (File) JTableUtil.newInstance(compareTable).getModel().getValueAt(rowPos,
                        CompareTableIndex.EXTERNAL_FILE.pos);
                final File srcFile = (File) JTableUtil.newInstance(compareTable).getModel().getValueAt(rowPos,
                        CompareTableIndex.SOURCE_FILE.pos);

                System.out.println("external : " + external);
                System.out.println("srcFile : " + srcFile);

                if (JMouseEventUtil.buttonLeftClick(2, event)) {
                    String command = String.format(tortoiseMergeFormat, external, srcFile);
                    System.out.println(command);
                    Runtime.getRuntime().exec(command);
                }
                if (JMouseEventUtil.buttonRightClick(1, event)) {
                    JMenuItem showInfoMenu = new JMenuItem();
                    showInfoMenu.setText("information");
                    showInfoMenu.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog(//
                                    "source file : \n" + srcFile + "\n"
                                            + DateFormatUtils.format(srcFile.lastModified(),
                                                    "yyyy/MM/dd HH:mm:ss")
                                            + "\n" + "size : " + srcFile.length() / 1024 + "\n\n"
                                            + "external file : \n" + external + "\n"
                                            + DateFormatUtils.format(external.lastModified(),
                                                    "yyyy/MM/dd HH:mm:ss")
                                            + "\n" + "size : " + external.length() / 1024,
                                    "INFORMATION");
                        }
                    });
                    JMenuItem openFileMenu = new JMenuItem();
                    openFileMenu.setText("OPEN : source");
                    openFileMenu.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            openFile(srcFile);
                        }
                    });
                    JMenuItem openExternalMenu = new JMenuItem();
                    openExternalMenu.setText("OPEN : external");
                    openExternalMenu.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            openFile(external);
                        }
                    });
                    JMenuItem openPairlMenu = new JMenuItem();
                    openPairlMenu.setText("OPEN : all");
                    openPairlMenu.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            openFile(srcFile);
                            openFile(external);
                        }
                    });

                    JPopupMenuUtil.newInstance(compareTable).applyEvent(event)
                            .addJMenuItem(showInfoMenu, openFileMenu, openExternalMenu, openPairlMenu).show();
                }
            }
        });
        swingUtil.addAction("loadSrcTextarea.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                loadSrcTextarea();
            }
        });
        swingUtil.addAction("srcList.mouseClicked", new Action() {
            public void action(EventObject evt) throws Exception {
                if (JMouseEventUtil.buttonRightClick(1, evt)) {
                    JPopupMenuUtil.newInstance(srcList).applyEvent(evt)
                            .addJMenuItem("mark svn delete", new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION != JOptionPaneUtil
                                            .newInstance().confirmButtonYesNo().showConfirmDialog(
                                                    "are you sure, mark delete file : "
                                                            + srcList.getSelectedValues().length,
                                                    "SVN DELETE")) {
                                        return;
                                    }
                                    StringBuilder sb = new StringBuilder();
                                    Process process = null;
                                    InputStream in = null;
                                    for (Object obj : srcList.getSelectedValues()) {
                                        LineParser l = (LineParser) obj;
                                        String command = String.format("svn delete \"%s\"", l.file);
                                        System.out.println(command);
                                        try {
                                            process = Runtime.getRuntime().exec(command);
                                            in = process.getInputStream();
                                            for (; in.read() != -1;)
                                                ;
                                            if (l.file.exists()) {
                                                sb.append(l.file.getName() + "\n");
                                            }
                                        } catch (IOException e1) {
                                            e1.printStackTrace();
                                            sb.append(l.file.getName() + "\n");
                                        }
                                    }
                                    if (sb.length() > 0) {
                                        JOptionPaneUtil.newInstance().iconErrorMessage()
                                                .showMessageDialog("error : \n" + sb, "ERROR");
                                    } else {
                                        JOptionPaneUtil.newInstance().iconInformationMessage()
                                                .showMessageDialog("mark delete completed!!", "SUCCESS");
                                    }
                                    DefaultListModel model = (DefaultListModel) srcList.getModel();
                                    for (int ii = 0; ii < model.getSize(); ii++) {
                                        LineParser l = (LineParser) model.getElementAt(ii);
                                        if (!l.file.exists()) {
                                            model.remove(ii);
                                            ii--;
                                        }
                                    }
                                }
                            }).show();
                }

                if (!JListUtil.newInstance(srcList).isCorrectMouseClick(evt)) {
                    return;
                }
                LineParser lineParser = (LineParser) JListUtil.getLeadSelectionObject(srcList);
                if (lineParser == null) {
                    return;
                }
                Runtime.getRuntime().exec("cmd /c call \"" + lineParser.file + "\"");
            }
        });
        swingUtil.addAction("srcList.keyPressed", new Action() {
            public void action(EventObject evt) throws Exception {
                JListUtil.newInstance(srcList).defaultJListKeyPressed(evt);
            }
        });
        swingUtil.addAction("outPutList.mouseClicked", new Action() {
            public void action(EventObject evt) throws Exception {
                if (!JListUtil.newInstance(outPutList).isCorrectMouseClick(evt)) {
                    return;
                }
            }
        });
        swingUtil.addAction("outPutList.keyPressed", new Action() {
            public void action(EventObject evt) throws Exception {
                JListUtil.newInstance(outPutList).defaultJListKeyPressed(evt);
            }
        });
        swingUtil.addAction("outPutDir.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                File dir = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                        .getApproveSelectedFile();
                if (dir == null) {
                    outputDir = DEFAULT_OUTPUT_DIR;
                } else {
                    outputDir = dir;
                }
                reflushOutputList();
            }
        });
        swingUtil.addAction("srcBaseDir.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                File dir = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                        .getApproveSelectedFile();
                Validate.notNull(dir, "src base directory is not correct!");
                manualBaseDir = dir;
            }
        });
        swingUtil.addAction("execute.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                DefaultListModel model = (DefaultListModel) outPutList.getModel();
                for (int ii = 0; ii < model.size(); ii++) {
                    OutputFile file = (OutputFile) model.getElementAt(ii);
                    if (!file.destFile.getParentFile().exists()) {
                        file.destFile.getParentFile().mkdirs();
                    }
                    FileUtil.copyFile(file.srcFile, file.destFile);
                }
                JOptionPaneUtil.newInstance().iconInformationMessage()
                        .showMessageDialog("copy success!!\nsize = " + model.getSize(), getTitle());
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}

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

private void initGUI() {
    final SwingActionUtil swingUtil = SwingActionUtil.newInstance(this);
    ToolTipManager.sharedInstance().setInitialDelay(0);
    try {//from   www .  j a v a 2  s  . c  o  m
        {
            this.setTitle("execute browser");
            this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            this.setPreferredSize(new java.awt.Dimension(870, 551));
            this.addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent evt) {
                    swingUtil.invokeAction("frame.mouseClicked", evt);
                }
            });
        }
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1);
            jTabbedPane1.setPreferredSize(new java.awt.Dimension(384, 265));
            jTabbedPane1.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent evt) {
                    swingUtil.invokeAction("jTabbedPane1.stateChanged", evt);
                }
            });
            jTabbedPane1.addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent evt) {
                    swingUtil.invokeAction("jTabbedPane1.mouseClicked", evt);
                }
            });
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("file list", null, jPanel1, null);
                {
                    jPanel4 = new JPanel();
                    BorderLayout jPanel4Layout = new BorderLayout();
                    jPanel4.setLayout(jPanel4Layout);
                    jPanel1.add(jPanel4, BorderLayout.NORTH);
                    jPanel4.setPreferredSize(new java.awt.Dimension(508, 81));
                    {
                        jScrollPane1 = new JScrollPane();
                        jPanel4.add(jScrollPane1, BorderLayout.CENTER);
                        {
                            exeArea = new JTextArea();
                            jScrollPane1.setViewportView(exeArea);
                        }
                    }
                    {
                        jPanel5 = new JPanel();
                        BorderLayout jPanel5Layout = new BorderLayout();
                        jPanel5.setLayout(jPanel5Layout);
                        jPanel4.add(jPanel5, BorderLayout.EAST);
                        jPanel5.setPreferredSize(new java.awt.Dimension(202, 81));
                        {
                            addArea = new JButton();
                            jPanel5.add(addArea, BorderLayout.CENTER);
                            addArea.setText("addArea");
                            addArea.setPreferredSize(new java.awt.Dimension(58, 30));
                            addArea.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent evt) {
                                    swingUtil.invokeAction("addArea.actionPerformed", evt);
                                }
                            });
                        }
                    }
                    {
                        queryText = new JTextField();
                        jPanel4.add(queryText, BorderLayout.NORTH);
                        queryText.getDocument()
                                .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() {
                                    public void process(DocumentEvent event) {
                                        try {
                                            String query = JCommonUtil.getDocumentText(event);
                                            Pattern ptn = Pattern.compile(query);
                                            DefaultListModel model = new DefaultListModel();
                                            for (Object key : prop.keySet()) {
                                                String val = key.toString();
                                                if (val.contains(query)) {
                                                    model.addElement(key);
                                                    continue;
                                                }
                                                if (ptn.matcher(val).find()) {
                                                    model.addElement(key);
                                                    continue;
                                                }
                                            }
                                            execList.setModel(model);
                                        } catch (Exception ex) {
                                        }
                                    }
                                }));
                    }
                }
                {
                    jPanel3 = new JPanel();
                    jPanel1.add(jPanel3, BorderLayout.CENTER);
                    BorderLayout jPanel3Layout = new BorderLayout();
                    jPanel3.setLayout(jPanel3Layout);
                    jPanel3.setPreferredSize(new java.awt.Dimension(480, 220));
                    {
                        jScrollPane2 = new JScrollPane();
                        jPanel3.add(jScrollPane2, BorderLayout.CENTER);
                        {
                            DefaultListModel execListModel = new DefaultListModel();
                            for (Object obj : prop.keySet()) {
                                execListModel.addElement((String) obj);
                            }
                            execList = new JList();
                            jScrollPane2.setViewportView(execList);
                            execList.setModel(execListModel);
                            execList.addKeyListener(new KeyAdapter() {
                                public void keyPressed(KeyEvent evt) {
                                    swingUtil.invokeAction("execList.keyPressed", evt);
                                }
                            });
                            execList.addListSelectionListener(new ListSelectionListener() {
                                public void valueChanged(ListSelectionEvent evt) {
                                    swingUtil.invokeAction("execList.valueChanged", evt);
                                }
                            });
                            execList.addMouseListener(new MouseAdapter() {
                                public void mouseClicked(MouseEvent evt) {
                                    swingUtil.invokeAction("execList.mouseClicked", evt);
                                }
                            });
                        }
                    }
                }
                {
                    jPanel6 = new JPanel();
                    jPanel1.add(jPanel6, BorderLayout.SOUTH);
                    jPanel6.setPreferredSize(new java.awt.Dimension(741, 47));
                    {
                        saveList = new JButton();
                        jPanel6.add(saveList);
                        saveList.setText("save list to default properties");
                        saveList.setPreferredSize(new java.awt.Dimension(227, 28));
                        saveList.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                swingUtil.invokeAction("saveList.actionPerformed", evt);
                            }
                        });
                    }
                    {
                        clearExecList = new JButton();
                        jPanel6.add(clearExecList);
                        clearExecList.setText("clear properties");
                        clearExecList.setPreferredSize(new java.awt.Dimension(170, 28));
                        clearExecList.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                swingUtil.invokeAction("clearExecList.actionPerformed", evt);
                            }
                        });
                    }
                    {
                        reloadList = new JButton();
                        jPanel6.add(reloadList);
                        reloadList.setText("reload list");
                        reloadList.setPreferredSize(new java.awt.Dimension(156, 28));
                        reloadList.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                swingUtil.invokeAction("reloadList.actionPerformed", evt);
                            }
                        });
                    }
                    {
                        contentFilterBtn = new JButton();
                        jPanel6.add(contentFilterBtn);
                        contentFilterBtn.setText("content filter");
                        contentFilterBtn.setPreferredSize(new java.awt.Dimension(176, 27));
                        contentFilterBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                swingUtil.invokeAction("contentFilterBtn.actionPerformed", evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel2 = new JPanel();
                FlowLayout jPanel2Layout = new FlowLayout();
                jTabbedPane1.addTab("config", null, jPanel2, null);
                jPanel2.setPreferredSize(new java.awt.Dimension(573, 300));
                jPanel2.setLayout(jPanel2Layout);
                {
                    executeAll = new JButton();
                    jPanel2.add(executeAll);
                    executeAll.setText("execute all files");
                    executeAll.setPreferredSize(new java.awt.Dimension(137, 27));
                    executeAll.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("execute.actionPerformed", evt);
                        }
                    });
                }
                {
                    browser = new JButton();
                    jPanel2.add(browser);
                    browser.setText("add file");
                    browser.setPreferredSize(new java.awt.Dimension(140, 28));
                    browser.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("browser.actionPerformed", evt);
                        }
                    });
                }
                {
                    loadProp = new JButton();
                    jPanel2.add(loadProp);
                    loadProp.setText("load properties");
                    loadProp.setPreferredSize(new java.awt.Dimension(158, 32));
                    loadProp.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("loadProp.actionPerformed", evt);
                        }
                    });
                }
                {
                    executeExport = new JButton();
                    jPanel2.add(executeExport);
                    executeExport.setText("export list");
                    executeExport.setPreferredSize(new java.awt.Dimension(145, 31));
                    executeExport.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("executeExport.actionPerformed", evt);
                        }
                    });
                }
                {
                    exportListHasOrignTree = new JButton();
                    jPanel2.add(exportListHasOrignTree);
                    exportListHasOrignTree.setText("export list has orign tree");
                    exportListHasOrignTree.setPreferredSize(new java.awt.Dimension(204, 32));
                    exportListHasOrignTree.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("exportListHasOrignTree.actionPerformed", evt);
                        }
                    });
                }
                {
                    moveFiles = new JButton();
                    jPanel2.add(moveFiles);
                    moveFiles.setText("move selected");
                    moveFiles.setPreferredSize(new java.awt.Dimension(161, 31));
                    moveFiles.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("moveFiles.actionPerformed", evt);
                        }
                    });
                }
                {
                    deleteSelected = new JButton();
                    jPanel2.add(deleteSelected);
                    deleteSelected.setText("delete selected");
                    deleteSelected.setPreferredSize(new java.awt.Dimension(165, 31));
                    deleteSelected.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("deleteSelected.actionPerformed", evt);
                        }
                    });
                }
                {
                    loadClipboardPath = new JButton();
                    jPanel2.add(loadClipboardPath);
                    loadClipboardPath.setText("load clipboard path");
                    loadClipboardPath.setPreferredSize(new java.awt.Dimension(222, 31));
                    loadClipboardPath.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("loadClipboardPath.actionPerformed", evt);
                        }
                    });
                }
                {
                    deleteEmptyDir = new JButton();
                    jPanel2.add(deleteEmptyDir);
                    deleteEmptyDir.setText("delete empty dir");
                    deleteEmptyDir.setPreferredSize(new java.awt.Dimension(222, 31));
                    deleteEmptyDir.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("deleteEmptyDir.actionPerformed", evt);
                        }
                    });
                }
                {
                    openSvnUpdate = new JButton();
                    jPanel2.add(openSvnUpdate);
                    openSvnUpdate.setText("list svn new or modify file");
                    openSvnUpdate.setPreferredSize(new java.awt.Dimension(210, 34));
                    openSvnUpdate.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("openSvnUpdate.actionPerformed", evt);
                        }
                    });
                }
            }
            {
                jPanel7 = new JPanel();
                BorderLayout jPanel7Layout = new BorderLayout();
                jPanel7.setLayout(jPanel7Layout);
                jTabbedPane1.addTab("properties", null, jPanel7, null);
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel7.add(jScrollPane3, BorderLayout.CENTER);
                    jScrollPane3.setPreferredSize(new java.awt.Dimension(741, 415));
                    {
                        DefaultListModel propertiesListModel = new DefaultListModel();
                        propertiesList = new JList();
                        reloadCurrentDirPropertiesList();
                        jScrollPane3.setViewportView(propertiesList);
                        propertiesList.setModel(propertiesListModel);
                        propertiesList.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                swingUtil.invokeAction("propertiesList.keyPressed", evt);
                            }
                        });
                        propertiesList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                swingUtil.invokeAction("propertiesList.mouseClicked", evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel8 = new JPanel();
                BorderLayout jPanel8Layout = new BorderLayout();
                jTabbedPane1.addTab("scanner", null, jPanel8, null);
                jPanel8.setLayout(jPanel8Layout);
                {
                    jPanel9 = new JPanel();
                    jPanel8.add(jPanel9, BorderLayout.NORTH);
                    jPanel9.setPreferredSize(new java.awt.Dimension(741, 187));
                    {
                        scanDirText = new JTextField();
                        scanDirText.setToolTipText("scan dir");
                        jPanel9.add(scanDirText);
                        scanDirText.setPreferredSize(new java.awt.Dimension(225, 24));
                        scanDirText.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                swingUtil.invokeAction("scanDirText.mouseClicked", evt);
                            }
                        });
                    }
                    {
                        jScrollPane6 = new JScrollPane();
                        jPanel9.add(jScrollPane6);
                        jScrollPane6.setPreferredSize(new java.awt.Dimension(168, 69));
                        {
                            scannerText = new JTextArea();
                            scannerText.setToolTipText("query condition");
                            jScrollPane6.setViewportView(scannerText);
                        }
                    }
                    {
                        fileScan = new JButton();
                        jPanel9.add(fileScan);
                        fileScan.setText("start / stop");
                        fileScan.setPreferredSize(new java.awt.Dimension(113, 24));
                        fileScan.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                swingUtil.invokeAction("fileScan.actionPerformed", evt);
                            }
                        });
                    }
                    {
                        useRegexOnly = new JCheckBox();
                        jPanel9.add(useRegexOnly);
                        useRegexOnly.setText("regex only");
                    }
                    {
                        DefaultComboBoxModel scanTypeModel = new DefaultComboBoxModel();
                        for (ScanType s : ScanType.values()) {
                            scanTypeModel.addElement(s);
                        }
                        scanType = new JComboBox();
                        scanType.setToolTipText("scan type");
                        jPanel9.add(scanType);
                        scanType.setModel(scanTypeModel);
                        scanType.setPreferredSize(new java.awt.Dimension(147, 24));
                    }
                    {
                        DefaultComboBoxModel jComboBox1Model = new DefaultComboBoxModel();
                        for (FileOrDirType f : FileOrDirType.values()) {
                            jComboBox1Model.addElement(f);
                        }
                        fileOrDirTypeCombo = new JComboBox();
                        jPanel9.add(fileOrDirTypeCombo);
                        fileOrDirTypeCombo.setModel(jComboBox1Model);
                        fileOrDirTypeCombo.setToolTipText("scan file or directory!");
                    }
                    {
                        addListToExecList = new JButton();
                        jPanel9.add(addListToExecList);
                        addListToExecList.setText("add list to file list");
                        addListToExecList.setPreferredSize(new java.awt.Dimension(158, 24));
                        addListToExecList.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                swingUtil.invokeAction("addListToExecList.actionPerformed", evt);
                            }
                        });
                    }
                    {
                        ignoreScanText = new JTextField();
                        ignoreScanText.setToolTipText("ignore scan condition");
                        ignoreScanText.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                if (!JMouseEventUtil.buttonLeftClick(2, evt)) {
                                    return;
                                }
                                String ignore = null;
                                if (StringUtils.isBlank(ignore = ignoreScanText.getText())) {
                                    return;
                                }
                                DefaultListModel model = (DefaultListModel) ignoreScanList.getModel();
                                model.addElement(ignore);
                            }
                        });
                        jPanel9.add(ignoreScanText);
                        ignoreScanText.setPreferredSize(new java.awt.Dimension(153, 24));
                    }
                    {
                        jScrollPane5 = new JScrollPane();
                        jPanel9.add(jScrollPane5);
                        jScrollPane5.setPreferredSize(new java.awt.Dimension(125, 73));
                        jScrollPane5.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
                        jScrollPane5.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
                        {
                            DefaultListModel ignoreScanListModel = new DefaultListModel();
                            ignoreScanList = new JList();
                            ignoreScanList.setToolTipText("ignore scan condition list");
                            jScrollPane5.setViewportView(ignoreScanList);
                            ignoreScanList.setModel(ignoreScanListModel);
                            ignoreScanList.setPreferredSize(new java.awt.Dimension(125, 73));
                            ignoreScanList.addKeyListener(new KeyAdapter() {
                                public void keyPressed(KeyEvent evt) {
                                    JListUtil.newInstance(ignoreScanList).defaultJListKeyPressed(evt);
                                }
                            });
                        }
                    }
                    {
                        innerScannerText = new JTextField();
                        innerScannerText.setToolTipText("inner scan query condition");
                        jPanel9.add(innerScannerText);
                        innerScannerText.setPreferredSize(new java.awt.Dimension(164, 24));
                        innerScannerText.addMouseListener(new MouseAdapter() {

                            Thread innerScanThread = null;
                            boolean innerScanStop = false;

                            public void mouseClicked(MouseEvent evt) {
                                if (!JMouseEventUtil.buttonLeftClick(2, evt)) {
                                    return;
                                }
                                final String innerText = innerScannerText.getText();
                                if (arrayBackupForInnerScan == null) {
                                    return;
                                }

                                innerScanStop = true;

                                if (innerScanThread == null
                                        || innerScanThread.getState() == Thread.State.TERMINATED) {
                                    innerScanThread = new Thread(Thread.currentThread().getThreadGroup(),
                                            new Runnable() {
                                                public void run() {
                                                    innerScanStop = false;
                                                    System.out.println(
                                                            toString() + " ... start!! ==> " + innerScanStop);
                                                    DefaultListModel model = new DefaultListModel();
                                                    scanList.setModel(model);
                                                    for (int ii = 0; ii < arrayBackupForInnerScan.length; ii++) {
                                                        if (arrayBackupForInnerScan[ii].toString()
                                                                .contains(innerText)) {
                                                            model.addElement(arrayBackupForInnerScan[ii]);
                                                        }
                                                        if (innerScanStop) {
                                                            System.out.println(toString() + " ... over!! ==> "
                                                                    + innerScanStop);
                                                            break;
                                                        }
                                                    }
                                                    System.out.println(toString() + " ... run over!! ==> "
                                                            + innerScanStop);
                                                }
                                            }, "innerScanner_" + System.currentTimeMillis());
                                    innerScanThread.setDaemon(true);
                                    innerScanThread.start();
                                }
                            }
                        });
                    }
                }
                {
                    jScrollPane4 = new JScrollPane();
                    jPanel8.add(jScrollPane4, BorderLayout.CENTER);
                    {
                        DefaultListModel scanListModel = new DefaultListModel();
                        scanList = new JList();
                        jScrollPane4.setViewportView(scanList);
                        scanList.setModel(scanListModel);
                        scanList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                swingUtil.invokeAction("scanList.mouseClicked", evt);
                            }
                        });
                        scanList.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                swingUtil.invokeAction("scanList.keyPressed", evt);
                            }
                        });
                    }
                }
                {
                    scannerStatus = new JLabel();
                    jPanel8.add(scannerStatus, BorderLayout.SOUTH);
                    scannerStatus.setPreferredSize(new java.awt.Dimension(741, 27));
                }
            }
        }

        swingUtil.addAction("moveFiles.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                DefaultListModel model = (DefaultListModel) execList.getModel();
                if (model.getSize() == 0 || execList.getSelectedValues().length == 0) {
                    JOptionPaneUtil.newInstance().iconErrorMessage()
                            .showMessageDialog("no selected file can move!", "ERROR");
                    return;
                }
                File exportListTo = FileUtil.getDefaultExportDir(ExecuteOpener.class, true);
                File file = null;
                List<File> list = new ArrayList<File>();
                for (Object obj : execList.getSelectedValues()) {
                    file = new File((String) obj);
                    if (file.exists() && file.isFile()) {
                        list.add(file);
                    }
                }
                File fromBaseDir = FileUtil.exportReceiveBaseDir(list);
                System.out.println("fromBaseDir = " + fromBaseDir);
                int cutLen = 0;
                if (fromBaseDir != null) {
                    cutLen = fromBaseDir.getAbsolutePath().length();
                }
                StringBuilder err = new StringBuilder();
                File newFile = null;
                for (Object obj : execList.getSelectedValues()) {
                    file = new File((String) obj);
                    if (file.exists() && file.isFile()) {
                        newFile = new File(exportListTo + "/" + file.getParent().substring(cutLen),
                                file.getName());
                        newFile.getParentFile().mkdirs();
                        System.out.println("move to : " + newFile);
                        file.renameTo(newFile);
                        if (!newFile.exists()) {
                            err.append(file + "\n");
                        }
                    }
                }
                if (err.length() > 0) {
                    JOptionPaneUtil.newInstance().iconErrorMessage()
                            .showMessageDialog("move file error : \n" + err, "ERROR");
                } else {
                    JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog(
                            "move file success : " + execList.getSelectedValues().length, "SUCCESS");
                }
            }
        });
        swingUtil.addAction("deleteSelected.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                StringBuilder sb = new StringBuilder();
                for (Object obj : execList.getSelectedValues()) {
                    sb.append(new File((String) obj).getName() + "\n");
                }
                if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION != JOptionPaneUtil.newInstance()
                        .confirmButtonYesNo().iconWaringMessage()
                        .showConfirmDialog("are you sure delete file : \n" + sb, "DELETE")) {
                    return;
                }
                File file = null;
                sb = new StringBuilder();
                for (Object obj : execList.getSelectedValues()) {
                    file = new File((String) obj);
                    if (!file.exists()) {
                        continue;
                    }
                    if (file.isDirectory() && file.list().length == 0) {
                        if (!file.delete()) {
                            sb.append(file.getName() + "\n");
                        }
                        continue;
                    }
                    if (!file.delete()) {
                        sb.append(file.getName() + "\n");
                    }
                }
                if (sb.length() != 0) {
                    JOptionPaneUtil.newInstance().iconErrorMessage()
                            .showMessageDialog("delete error list :\n" + sb, "ERROR");
                } else {
                    JOptionPaneUtil.newInstance().iconPlainMessage().showMessageDialog("delete completed!",
                            "SUCCESS");
                }
            }
        });
        swingUtil.addAction("loadClipboardPath.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                File file = new File(ClipboardUtil.getInstance().getContents());
                if (!file.exists()) {
                    return;
                }
                List<File> list = new ArrayList<File>();
                FileUtil.searchFileMatchs(file, ".*", list);
                prop.clear();
                for (File f : list) {
                    if (f.isFile()) {
                        prop.setProperty(f.getAbsolutePath(), "");
                    }
                }
                DefaultListModel model = new DefaultListModel();
                for (Object key : prop.keySet()) {
                    model.addElement(key);
                }
                execList.setModel(model);
            }
        });
        swingUtil.addAction("deleteEmptyDir.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                        .getApproveSelectedFile();
                if (file == null) {
                    JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog("file is not correct!",
                            "ERROR");
                    return;
                }
                if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION != JOptionPaneUtil.newInstance()
                        .iconWaringMessage().confirmButtonYesNo()
                        .showConfirmDialog("are you sure delete empty dir in \n" + file, "WARRNING")) {
                    return;
                }
                List<File> delDir = new ArrayList<File>();
                FileUtil.deleteEmptyDir(file, delDir);
                JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog(
                        "delete dir list : \n" + delDir.toString().replace(',', '\n'), "DELETE");
            }
        });
        swingUtil.addAction("browser.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                File file = JFileChooserUtil.newInstance().selectFileAndDirectory().showOpenDialog()
                        .getApproveSelectedFile();
                if (file != null) {
                    DefaultListModel model = (DefaultListModel) execList.getModel();
                    model.addElement(file.getAbsolutePath());
                }
            }
        });
        swingUtil.addAction("addArea.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                if (StringUtils.isBlank(exeArea.getText())) {
                    return;
                }
                DefaultListModel model = (DefaultListModel) execList.getModel();
                StringTokenizer token = new StringTokenizer(exeArea.getText(), "\t\n\r\f");
                while (token.hasMoreElements()) {
                    String val = ((String) token.nextElement()).trim();
                    model.addElement(val);
                    prop.put(val, "");
                }
            }
        });
        swingUtil.addAction("execute.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                DefaultListModel model = (DefaultListModel) execList.getModel();
                for (Enumeration<?> enu = model.elements(); enu.hasMoreElements();) {
                    String val = (String) enu.nextElement();
                    exec(val);
                }
            }
        });
        swingUtil.addAction("execList.keyPressed", new Action() {
            public void action(EventObject evt) throws Exception {
                JListUtil.newInstance(execList).defaultJListKeyPressed(evt);
            }
        });
        //DEFAULT PROP SAVE
        swingUtil.addAction("saveList.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                String orignName = JOptionPaneUtil.newInstance().iconPlainMessage()
                        .showInputDialog("input properties file name", "SAVE");
                File saveFile = null;
                if (StringUtils.isNotBlank(orignName)) {
                    String fileName = orignName;
                    if (!fileName.toLowerCase().endsWith(".properties")) {
                        fileName += ".properties";
                    }
                    fileName = ExecuteOpener.class.getSimpleName() + "_" + fileName;
                    prop.clear();
                    DefaultListModel model = (DefaultListModel) execList.getModel();
                    for (Enumeration<?> enu = model.elements(); enu.hasMoreElements();) {
                        String val = (String) enu.nextElement();
                        prop.put(val, "");
                    }
                    saveFile = new File(jarPositionDir, fileName);
                } else {
                    saveFile = currentPropFile;
                }
                prop.store(new FileOutputStream(saveFile), orignName);
                JOptionPaneUtil.newInstance().iconPlainMessage().showMessageDialog(saveFile,
                        "PROPERTIES CREATE");
            }
        });
        swingUtil.addAction("clearExecList.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                //                    prop.clear();
                //                    reloadExecListProperties(prop);
                execList.setModel(new DefaultListModel());
            }
        });
        swingUtil.addAction("execList.mouseClicked", new Action() {
            public void action(EventObject evt) throws Exception {
                // right button single click event
                if (JMouseEventUtil.buttonRightClick(1, evt)) {
                    JPopupMenuUtil popupUtil = JPopupMenuUtil.newInstance(execList).applyEvent(evt);

                    if (execList.getSelectedValues().length == 1) {
                        popupUtil.addJMenuItem(
                                JFileExecuteUtil.newInstance(new File((String) execList.getSelectedValues()[0]))
                                        .createDefaultJMenuItems());
                        popupUtil.addJMenuItem("----------------", false);
                    }

                    popupUtil.addJMenuItem("eclipse home", new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            DefaultListModel model = (DefaultListModel) execList.getModel();
                            Object[] arry = model.toArray();
                            for (Object obj : arry) {
                                try {
                                    Runtime.getRuntime().exec(String.format("cmd /c call \"%s\" \"%s\"",
                                            "C:/?/eclipse_jee/eclipse.exe", obj));
                                } catch (IOException ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        }
                    });
                    popupUtil.addJMenuItem("eclipse company", new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            DefaultListModel model = (DefaultListModel) execList.getModel();
                            Object[] arry = model.toArray();
                            for (Object obj : arry) {
                                try {
                                    Runtime.getRuntime().exec(String.format("cmd /c call \"%s\" \"%s\"",
                                            "C:/?/iisi_eclipse/eclipse.exe", obj));
                                } catch (IOException ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        }
                    });

                    popupUtil.addJMenuItem("----------------", false);

                    popupUtil//
                            .addJMenuItem("sort list", new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    DefaultListModel model = (DefaultListModel) execList.getModel();
                                    Object[] arry = model.toArray();
                                    Arrays.sort(arry);
                                    DefaultListModel model2 = new DefaultListModel();
                                    for (Object obj : arry) {
                                        model2.addElement(obj);
                                    }
                                    execList.setModel(model2);
                                }
                            }).addJMenuItem("keep exists", new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    DefaultListModel model = (DefaultListModel) execList.getModel();
                                    DefaultListModel model2 = new DefaultListModel();
                                    for (Object obj : model.toArray()) {
                                        if (new File((String) obj).exists()) {
                                            model2.addElement(obj);
                                        }
                                    }
                                    execList.setModel(model2);
                                }
                            }).addJMenuItem("remove duplicate", new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    DefaultListModel model = (DefaultListModel) execList.getModel();
                                    DefaultListModel model2 = new DefaultListModel();
                                    Set<String> set = new HashSet<String>();
                                    for (Object obj : model.toArray()) {
                                        set.add((String) obj);
                                    }
                                    for (String val : set) {
                                        model2.addElement(val);
                                    }
                                    execList.setModel(model2);
                                }
                            }).addJMenuItem("remove folder", new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    DefaultListModel model = (DefaultListModel) execList.getModel();
                                    for (int ii = 0; ii < model.getSize(); ii++) {
                                        if (new File((String) model.getElementAt(ii)).isDirectory()) {
                                            model.removeElementAt(ii);
                                            ii--;
                                        }
                                    }
                                }
                            }).addJMenuItem("remove empty folder", new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    DefaultListModel model = (DefaultListModel) execList.getModel();
                                    File dir = null;
                                    for (int ii = 0; ii < model.getSize(); ii++) {
                                        dir = new File((String) model.getElementAt(ii));
                                        if (dir.isDirectory() && dir.list().length == 0) {
                                            model.removeElementAt(ii);
                                            ii--;
                                        }
                                    }
                                }
                            }).addJMenuItem("----------------", false)
                            .addJMenuItem("diff left : " + (diffLeft != null ? diffLeft.getName() : ""), true,
                                    new ActionListener() {
                                        public void actionPerformed(ActionEvent arg0) {
                                            File value = new File(
                                                    (String) JListUtil.getLeadSelectionObject(execList));
                                            if (value != null && value.isFile() && value.exists()) {
                                                diffLeft = value;
                                            }
                                        }
                                    })
                            .addJMenuItem("diff right : " + (diffRight != null ? diffRight.getName() : ""),
                                    true, new ActionListener() {
                                        public void actionPerformed(ActionEvent arg0) {
                                            File value = new File(
                                                    (String) JListUtil.getLeadSelectionObject(execList));
                                            if (value != null && value.isFile() && value.exists()) {
                                                diffRight = value;
                                            }
                                        }
                                    })
                            .addJMenuItem((diffLeft != null && diffRight != null) ? "diff compare" : "",
                                    (diffLeft != null && diffRight != null), new ActionListener() {
                                        public void actionPerformed(ActionEvent arg0) {
                                            try {
                                                Runtime.getRuntime().exec(String.format(
                                                        "cmd /c call TortoiseMerge.exe /base:\"%s\" /theirs:\"%s\"",
                                                        diffLeft, diffRight));
                                            } catch (IOException ex) {
                                                JCommonUtil.handleException(ex);
                                            }
                                        }
                                    })
                            .addJMenuItem((execList.getSelectedValues().length == 2) ? "diff compare" : "",
                                    (execList.getSelectedValues().length == 2), new ActionListener() {
                                        public void actionPerformed(ActionEvent arg0) {
                                            try {
                                                Runtime.getRuntime().exec(String.format(
                                                        "cmd /c call TortoiseMerge.exe /base:\"%s\" /theirs:\"%s\"",
                                                        execList.getSelectedValues()[0],
                                                        execList.getSelectedValues()[1]));
                                            } catch (IOException ex) {
                                                JCommonUtil.handleException(ex);
                                            }
                                        }
                                    })
                            .addJMenuItem("----------------", false)//
                            .show();//
                }

                // left button double click event 
                int pos = execList.getLeadSelectionIndex();
                if (pos == -1) {
                    return;
                }
                if (((MouseEvent) evt).getClickCount() < 2) {
                    return;
                }
                DefaultListModel model = (DefaultListModel) execList.getModel();
                String val = (String) model.getElementAt(pos);
                exec(val);
            }
        });
        swingUtil.addAction("loadProp.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                File file = JFileChooserUtil.newInstance().selectFileOnly().showOpenDialog()
                        .getApproveSelectedFile();
                if (file == null) {
                    JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog("file not correct!",
                            "ERROR");
                    return;
                }
                reloadExecListProperties(file);
                setTitle("load prop : " + file.getName());
            }
        });
        swingUtil.addAction("reloadList.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                reloadExecListProperties(prop);
            }
        });
        swingUtil.addAction("exportListHasOrignTree.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                DefaultListModel model = (DefaultListModel) execList.getModel();
                if (model.isEmpty()) {
                    JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog("no file can export!",
                            "ERROR");
                    return;
                }
                List<File> allList = new ArrayList<File>();
                for (int ii = 0; ii < model.getSize(); ii++) {
                    allList.add(new File((String) model.getElementAt(ii)));
                }
                File baseDir = FileUtil.exportReceiveBaseDir(allList);
                System.out.println("common base dir : " + baseDir);
                boolean dynamicBaseDir = baseDir == null;

                File tmp = null;
                File copyTo = null;
                int realCopyCount = 0;

                File exportListTo = FileUtil.getDefaultExportDir(ExecuteOpener.class, true);
                for (int ii = 0; ii < model.getSize(); ii++) {
                    String val = (String) model.getElementAt(ii);
                    if (StringUtils.isBlank(val)) {
                        continue;
                    }
                    tmp = new File(val);
                    if (tmp.isDirectory()) {
                        continue;
                    }
                    File copyFrom = getCorrectFile(tmp);
                    if (dynamicBaseDir) {
                        baseDir = FileUtil.getRoot(copyFrom);
                    }
                    copyTo = FileUtil.exportFileToTargetPath(copyFrom, baseDir, exportListTo);
                    if (!copyTo.getParentFile().exists()) {
                        copyTo.getParentFile().mkdirs();
                    }
                    System.out.println("## file : " + tmp + " -- > " + copyFrom);
                    System.out.println("\t copy to : " + copyTo);
                    FileUtil.copyFile(copyFrom, copyTo);
                    realCopyCount++;
                }
                JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog(
                        "copy completed!\ntotal : " + model.getSize() + "\ncopy : " + realCopyCount, "SUCCESS");
            }
        });
        swingUtil.addAction("executeExport.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                DefaultListModel model = (DefaultListModel) execList.getModel();
                if (model.isEmpty()) {
                    JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog("no file can export!",
                            "ERROR");
                    return;
                }
                File tmp = null;
                File copyTo = null;
                int realCopyCount = 0;
                File exportListTo = FileUtil.getDefaultExportDir(ExecuteOpener.class, true);
                BufferedWriter writer = new BufferedWriter(
                        new OutputStreamWriter(new FileOutputStream(exportListTo + "/output_log.txt"), "BIG5"));
                for (int ii = 0; ii < model.getSize(); ii++) {
                    String val = (String) model.getElementAt(ii);
                    if (StringUtils.isBlank(val)) {
                        continue;
                    }
                    tmp = new File(val);
                    if (tmp.isDirectory()) {
                        continue;
                    }
                    if (isNeedToCopy(exportListTo, tmp)) {
                        File copyFrom = getCorrectFile(tmp);
                        System.out.println("## file : " + tmp + " -- > " + copyFrom);
                        copyTo = new File(exportListTo, copyFrom.getName());
                        for (int jj = 0; copyTo.exists(); jj++) {
                            String name = copyFrom.getName();
                            int pos = name.lastIndexOf(".");
                            String prefix = name.substring(0, pos);
                            String rearfix = name.substring(pos);
                            copyTo = new File(exportListTo, prefix + "_R" + jj + rearfix);
                        }
                        FileUtil.copyFile(copyFrom, copyTo);
                        writer.write(tmp.getAbsolutePath()
                                + (!tmp.getName().equals(copyTo.getName()) ? "\t [rename] : " + copyTo.getName()
                                        : ""));
                        realCopyCount++;
                    } else {
                        writer.write(tmp.getAbsolutePath() + "\t [has same file, ommit!]");
                    }
                    writer.newLine();
                }
                writer.flush();
                writer.close();
                JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog(
                        "copy completed!\ntotal : " + model.getSize() + "\ncopy : " + realCopyCount, "SUCCESS");
            }
        });
        swingUtil.addAction("jTabbedPane1.mouseClicked", new Action() {
            public void action(EventObject evt) throws Exception {
                if (!JMouseEventUtil.buttonLeftClick(2, evt)) {
                    return;
                }
                File file = new File(getTitle());
                if (file.exists()) {
                    JOptionPaneUtil.newInstance().iconPlainMessage().showMessageDialog(file,
                            "current properties");
                }
                ClipboardUtil.getInstance().setContents(file);
            }
        });
        swingUtil.addAction("propertiesList.mouseClicked", new Action() {
            public void action(EventObject evt) throws Exception {
                File file = (File) propertiesList.getSelectedValue();
                JPopupMenuUtil.newInstance(propertiesList).applyEvent(evt)
                        .addJMenuItem("reload list", new ActionListener() {
                            public void actionPerformed(ActionEvent paramActionEvent) {
                                reloadCurrentDirPropertiesList();
                            }
                        }).addJMenuItem(JFileExecuteUtil.newInstance(file).createDefaultJMenuItems()).show();
                if (file == null) {
                    return;
                }
                if (!JMouseEventUtil.buttonLeftClick(2, evt)) {
                    return;
                }
                prop.clear();
                prop.load(new FileInputStream(file));
                currentPropFile = file;
                reloadExecListProperties(prop);
                setTitle("properties : " + file.getName());
            }
        });
        swingUtil.addAction("propertiesList.keyPressed", new Action() {
            public void action(EventObject evt) throws Exception {
                if (!JMouseEventUtil.buttonLeftClick(2, evt)) {
                    return;
                }
                JListUtil.newInstance(propertiesList).defaultJListKeyPressed(evt);
            }
        });
        swingUtil.addAction("jTabbedPane1.stateChanged", new Action() {
            public void action(EventObject evt) throws Exception {
                if (jTabbedPane1.getSelectedIndex() == 2) {
                    reloadCurrentDirPropertiesList();
                }
            }
        });
        swingUtil.addAction("scanList.keyPressed", new Action() {
            public void action(EventObject evt) throws Exception {
                JListUtil.newInstance(scanList).defaultJListKeyPressed(evt);
            }
        });
        swingUtil.addAction("scanList.mouseClicked", new Action() {
            public void action(EventObject evt) throws Exception {
                System.out.println("index = " + scanList.getLeadSelectionIndex());
                final Object[] vals = scanList.getSelectedValues();
                if (vals == null || vals.length == 0) {
                    return;
                }
                JPopupMenuUtil.newInstance(scanList).applyEvent(evt)
                        .addJMenuItem("add to file list : " + vals.length, new ActionListener() {
                            public void actionPerformed(ActionEvent arg0) {
                                File file = null;
                                DefaultListModel model = (DefaultListModel) execList.getModel();
                                for (Object v : vals) {
                                    file = (File) v;
                                    model.addElement(file.getAbsolutePath());
                                }
                            }
                        }).show();
            }
        });
        swingUtil.addAction("fileScan.actionPerformed", new Action() {

            Thread scanMainThread = null;

            public void action(EventObject evt) throws Exception {
                String scanText_ = scannerText.getText();
                final boolean anyFileMatch = StringUtils.isEmpty(scanText_);
                final String scanText = anyFileMatch ? UUID.randomUUID().toString() : scanText_;
                final FileOrDirType fileOrDirType = (FileOrDirType) fileOrDirTypeCombo.getSelectedItem();

                String scanDir_ = scanDirText.getText();
                final File scanDir = new File(scanDir_);
                if (StringUtils.isEmpty(scanDir_)) {
                    JOptionPaneUtil.newInstance().iconErrorMessage()
                            .showMessageDialog("scan dir text can't empty!", "ERROR");
                    return;
                }
                if (!scanDir.exists()) {
                    JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog("directory is't exists!",
                            "ERROR");
                    return;
                }

                Object[] igArry_ = ((DefaultListModel) ignoreScanList.getModel()).toArray();
                final String[] igArry = new String[igArry_.length];
                for (int ii = 0; ii < igArry.length; ii++) {
                    igArry[ii] = (String) igArry_[ii];
                }
                final boolean ignoreCheck = igArry.length > 0;

                final DefaultListModel model = new DefaultListModel();

                final StringTokenizer tok = new StringTokenizer(scanText);

                if (scanMainThread == null || scanMainThread.getState() == Thread.State.TERMINATED) {
                    scanMainThread = new Thread(Thread.currentThread().getThreadGroup(), new Runnable() {

                        ScanType scanTp;

                        public void run() {
                            currentScannerThreadStop = false;
                            final long startTime = System.currentTimeMillis();
                            scanTp = (ScanType) scanType.getSelectedItem();

                            List<Thread> threadList = new ArrayList<Thread>();
                            final Map<String, Integer> matchCountMap = new HashMap<String, Integer>();
                            for (; tok.hasMoreElements();) {
                                final String scanVal = (String) tok.nextElement();
                                System.out.println("add scan condition = " + scanVal);

                                Pattern ppp = null;
                                try {
                                    ppp = Pattern.compile(scanVal);
                                } catch (Exception ex) {
                                    System.out.println(ex);
                                }

                                final Pattern scanTextPattern = ppp;

                                Thread currentScannerThread = new Thread(
                                        Thread.currentThread().getThreadGroup(), new Runnable() {

                                            int matchCount = 0;

                                            void addElement(File file) {
                                                if (scanTp.filter(anyFileMatch, scanVal, scanTextPattern, file,
                                                        ignoreCheck, igArry)) {
                                                    for (int ii = 0;; ii++) {
                                                        try {
                                                            model.addElement(file);
                                                            matchCount++;
                                                            break;
                                                        } catch (Exception ex) {
                                                            System.err.println(
                                                                    file + ", error occor !!! ==> " + ex);
                                                            if (ii > 10) {
                                                                break;
                                                            }
                                                        }
                                                    }
                                                }
                                            }

                                            void find(File file) {
                                                if (currentScannerThreadStop) {
                                                    return;
                                                }
                                                if (file == null || !file.exists()) {
                                                    System.out
                                                            .println("file == null || !file.exists()\t" + file);
                                                    return;
                                                }
                                                scannerStatus.setText(
                                                        model.getSize() + " : " + file.getAbsolutePath());
                                                if (file.isDirectory()) {
                                                    if (file.listFiles() != null) {
                                                        for (File f : file.listFiles()) {
                                                            find(f);
                                                        }
                                                    } else {
                                                        System.out
                                                                .println("file.listFiles() == null!!\t" + file);
                                                    }
                                                    switch (fileOrDirType) {
                                                    case DIRECTORY_ONLY:
                                                        addElement(file);
                                                        break;
                                                    case ALL:
                                                        addElement(file);
                                                        break;
                                                    }
                                                }
                                                if (file.isFile()) {
                                                    switch (fileOrDirType) {
                                                    case FILE_ONLY:
                                                        addElement(file);
                                                        break;
                                                    case ALL:
                                                        addElement(file);
                                                        break;
                                                    }
                                                }
                                            }

                                            public void run() {
                                                find(scanDir);
                                                matchCountMap.put(scanVal, matchCount);
                                            }
                                        }, "file_scann_" + System.currentTimeMillis());
                                currentScannerThread.setDaemon(true);
                                currentScannerThread.start();
                                threadList.add(currentScannerThread);
                            }

                            for (;;) {
                                try {
                                    Thread.sleep(1000);
                                    boolean allTerminated = true;
                                    for (int ii = 0; ii < threadList.size(); ii++) {
                                        if (threadList.get(ii).getState() != Thread.State.TERMINATED) {
                                            allTerminated = false;
                                            break;
                                        }
                                    }
                                    if (allTerminated) {
                                        System.out.println("all done...");
                                        break;
                                    }
                                } catch (InterruptedException e) {
                                    JCommonUtil.handleException(e);
                                }
                            }

                            long endTime = System.currentTimeMillis() - startTime;

                            String status = "scan completed \n during :" + endTime + "\n file : "
                                    + model.getSize() + "\n \tResult : \n " + matchCountMap;
                            JOptionPaneUtil.newInstance().iconPlainMessage().showMessageDialog(status,
                                    "COMPLETED");
                            scannerStatus.setText(status);
                            scanList.setModel(model);

                            arrayBackupForInnerScan = ((DefaultListModel) scanList.getModel()).toArray();

                            currentScannerThreadStop = false;
                        }
                    }, "file_scann_main_" + System.currentTimeMillis());
                    scanMainThread.setDaemon(true);
                    scanMainThread.start();
                } else {
                    if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption(
                            "scanner is running \n want to stop??", "WARNING")) {
                        currentScannerThreadStop = true;
                    }
                }
            }
        });
        swingUtil.addAction("scanDirText.mouseClicked", new Action() {
            public void action(EventObject evt) throws Exception {
                if (!JMouseEventUtil.buttonLeftClick(2, evt)) {
                    return;
                }
                File dir = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                        .getApproveSelectedFile();
                if (dir == null) {
                    return;
                }
                scanDirText.setText(dir.getAbsolutePath());
            }
        });
        swingUtil.addAction("addListToExecList.actionPerformed", new Action() {

            Thread moveThread = null;

            public void action(EventObject evt) throws Exception {
                if (moveThread != null && moveThread.getState() != Thread.State.TERMINATED) {
                    JCommonUtil._jOptionPane_showMessageDialog_error("add list process already running!");
                    return;
                }
                moveThread = new Thread(Thread.currentThread().getThreadGroup(), new Runnable() {
                    public void run() {
                        DefaultListModel model = (DefaultListModel) scanList.getModel();
                        DefaultListModel model2 = (DefaultListModel) execList.getModel();
                        for (int ii = 0; ii < model.getSize(); ii++) {
                            File f = (File) model.getElementAt(ii);
                            model2.addElement(f.getAbsolutePath());
                        }
                        if (model.getSize() > 1000) {
                            JCommonUtil._jOptionPane_showMessageDialog_info(
                                    "add list completed!\n" + model.getSize());
                        }
                    }
                }, "addListToExecList.actionPerformed_" + System.currentTimeMillis());
                moveThread.setDaemon(true);
                moveThread.start();
            }
        });
        swingUtil.addAction("openSvnUpdate.actionPerformed", new Action() {

            Pattern svnPattern = Pattern.compile("^(?:[M|\\?])\\s+\\d*\\s+(.+)$");

            Thread svnThread = null;

            public void action(EventObject evt) throws Exception {
                if (svnThread != null && svnThread.getState() != Thread.State.TERMINATED) {
                    JCommonUtil._jOptionPane_showMessageDialog_error("svn scan process already running!");
                    return;
                }
                final File svnDir = JCommonUtil._jFileChooser_selectDirectoryOnly();
                if (svnDir == null) {
                    JCommonUtil._jOptionPane_showMessageDialog_error("dir is not correct!");
                    return;
                }

                svnThread = new Thread(Thread.currentThread().getThreadGroup(), new Runnable() {
                    public void run() {
                        try {
                            Process process = Runtime.getRuntime()
                                    .exec(String.format("svn status -u \"%s\"", svnDir));
                            BufferedReader reader = new BufferedReader(
                                    new InputStreamReader(process.getInputStream()));
                            Matcher matcher = null;
                            File file = null;
                            DefaultListModel model = new DefaultListModel();
                            List<File> scanList = new ArrayList<File>();
                            for (String line = null; (line = reader.readLine()) != null;) {
                                matcher = svnPattern.matcher(line);
                                if (matcher.find()) {
                                    file = new File(matcher.group(1));
                                    if (file.isFile()) {
                                        model.addElement(file.getAbsolutePath());
                                    }
                                    if (file.isDirectory()) {
                                        scanList.clear();
                                        FileUtil.searchFileMatchs(file, ".*", scanList);
                                        for (File f : scanList) {
                                            model.addElement(f.getAbsolutePath());
                                        }
                                    }
                                } else {
                                    System.out.println("ignore : [" + line + "]");
                                }
                            }
                            reader.close();
                            execList.setModel(model);
                            setTitle("svn : " + svnDir);

                            JCommonUtil._jOptionPane_showMessageDialog_info("svn scan completed!");
                        } catch (IOException e) {
                            JCommonUtil.handleException(e);
                        }
                    }
                }, "svn_scan" + System.currentTimeMillis());
                svnThread.setDaemon(true);
                svnThread.start();
            }
        });
        swingUtil.addAction("contentFilterBtn.actionPerformed", new Action() {
            Thread thread = null;
            String encode = Charset.defaultCharset().displayName();

            public void action(EventObject evt) throws Exception {
                if (thread != null && thread.getState() != Thread.State.TERMINATED) {
                    JCommonUtil._jOptionPane_showMessageDialog_error("scan process already running!");
                    return;
                }

                final String filter = JCommonUtil._jOptionPane_showInputDialog("input filter content?");
                if (StringUtils.isEmpty(filter)) {
                    JCommonUtil._jOptionPane_showMessageDialog_error("filter is empty!");
                    return;
                }

                Pattern tmpPattern = null;
                try {
                    tmpPattern = Pattern.compile(filter);
                } catch (Exception ex) {
                }
                final Pattern filterPattern = tmpPattern;

                try {
                    encode = JCommonUtil._jOptionPane_showInputDialog("input encode?", encode);
                } catch (Exception ex) {
                    JCommonUtil._jOptionPane_showMessageDialog_error("error encode!");
                    return;
                }

                thread = new Thread(Thread.currentThread().getThreadGroup(), new Runnable() {
                    public void run() {
                        DefaultListModel model = (DefaultListModel) execList.getModel();
                        DefaultListModel model_ = new DefaultListModel();
                        File file = null;
                        BufferedReader reader = null;
                        for (int ii = 0; ii < model.getSize(); ii++) {
                            file = new File((String) model.getElementAt(ii));
                            if (!file.exists()) {
                                continue;
                            }
                            try {
                                reader = new BufferedReader(
                                        new InputStreamReader(new FileInputStream(file), encode));
                                for (String line = null; (line = reader.readLine()) != null;) {
                                    if (line.contains(filter)) {
                                        model_.addElement(file.getAbsolutePath());
                                        break;
                                    }
                                    if (filterPattern != null && filterPattern.matcher(line).find()) {
                                        model_.addElement(file.getAbsolutePath());
                                        break;
                                    }
                                }
                                reader.close();
                            } catch (Exception e) {
                                JCommonUtil.handleException(e);
                            }
                        }
                        execList.setModel(model_);
                        JCommonUtil._jOptionPane_showMessageDialog_info("completed!");
                    }
                }, UUID.randomUUID().toString());
                thread.setDaemon(true);
                thread.start();
            }
        });
        swingUtil.addAction("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", new Action() {
            public void action(EventObject evt) throws Exception {
            }
        });

        this.setSize(870, 551);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.dialogs.ApplicationProperties.java

private void saveAndClose() {
    personalSettings.clearFavourites();//from w  w  w .  java  2s  .c o m
    DefaultListModel model = (DefaultListModel) lstFavourites.getModel();
    int size = model.getSize();
    for (int i = 0; i < size; i++) {
        final String favourite = (String) model.get(i);
        personalSettings.addFavourite(favourite);
    }
    personalSettings.clearFilesToIgnore();
    model = (DefaultListModel) lstFilesToIgnore.getModel();
    size = model.getSize();
    for (int i = 0; i < size; i++) {
        final PersonalSettings.FileDescriptions fileToIgnore = (PersonalSettings.FileDescriptions) model.get(i);
        personalSettings.addFileToIgnore(fileToIgnore);
    }
    personalSettings.setStandardFont(theStandardFont);
    personalSettings.setSortRunningAscending(chkSortRunning.isSelected());
    personalSettings.setSortPendingAscending(chkSortPending.isSelected());
    personalSettings.setSortFailedAscending(chkSortFailed.isSelected());
    personalSettings.setSortDepositedAscending(chkSortDeposited.isSelected());
    personalSettings.setSortCompleteAscending(chkSortComplete.isSelected());
    try {
        personalSettings.setNoOfRetries(Integer.parseInt(txtNoOfRetries.getText()));
    } catch (Exception ex) {
        LOG.error("Error setting no of retries", ex);
    }

    theParent.setFormFont(theStandardFont);
    closeForm();
}

From source file:nz.govt.natlib.ndha.manualdeposit.metadata.MetaDataConfiguratorPresenter.java

public void addSipStatus() {
    if (theSipList == null) {
        return;/*w  ww.ja v a2 s . co  m*/
    }
    DefaultListModel model = (DefaultListModel) theSipList.getModel();
    SIPStatus status = SIPStatus.create("New SIP Status", "", false, false, false);
    model.addElement(status);
    theSipList.setSelectedIndex(model.getSize() - 1);
    if (sipStatusCollection == null) {
        sipStatusCollection = SIPStatusCollection.create();
    }
    sipStatusCollection.add(status);
    configuratorFrame.showSipStatus(status);
}

From source file:nz.govt.natlib.ndha.manualdeposit.metadata.MetaDataConfiguratorPresenter.java

public void addUser() throws Exception {
    if (theUserList == null) {
        return;//from   w w  w .  ja va 2  s .c om
    }
    DefaultListModel model = (DefaultListModel) theUserList.getModel();
    IndigoUser user = IndigoUser.create("New User", "");
    model.addElement(user);
    theUserList.setSelectedIndex(model.getSize() - 1);
    if (userData == null) {
        userData = UserData.create("");
    }
    userData.addUser(user);
    configuratorFrame.showUser(user);
}

From source file:nz.govt.natlib.ndha.manualdeposit.MetaDataTest.java

@Test
public final void testLoadData() {
    loadConfigFile();/*ww  w  .ja  va  2 s. com*/
    assertTrue(metaDataPresenter.getIsDirty() == false);
    DefaultListModel model = (DefaultListModel) theFrame.lstDataList.getModel();
    assertTrue(model.getSize() == 9);
    theFrame.lstDataList.setSelectedIndex(0);
    assertTrue(theFrame.getTheData().equals(theFrame.lstDataList.getSelectedValue()));
    if (theFrame.lstDNX.getSelectedIndex() == 0) {
        theFrame.lstDNX.setSelectedIndex(1);
    } else {
        theFrame.lstDNX.setSelectedIndex(0);
    }
    assertTrue(theFrame.lstDNXDetail.getSelectedValue() == null);
    // assertTrue(_presenter.getIsDirty() == true);
    assertTrue(theFrame.getTheData().getDnxType().equals(theFrame.lstDNX.getSelectedValue()));
    theFrame.lstDNXDetail.setSelectedIndex(0);
    assertTrue(theFrame.getTheData().getDnxSubType().equals(theFrame.lstDNXDetail.getSelectedValue()));
    theFrame.tabDnxDc.setSelectedIndex(1);
    // Ajusted by Ben 2.12.2013
    assertTrue(theFrame.getTheData().isDNX());
    assertFalse(theFrame.getTheData().isDNXState());
    theFrame.lstDC.setSelectedIndex(0);
    assertTrue(theFrame.getTheData().getDcType().equals(theFrame.lstDC.getSelectedValue()));
    theFrame.cmbDataType.setSelectedItem(EDataType.Boolean);
    assertTrue(theFrame.getTheData().getDataType().equals(EDataType.Boolean));
    assertFalse(theFrame.pnlListItems.isVisible());
    theFrame.cmbDataType.setSelectedItem(EDataType.MultiSelect);
    assertTrue(theFrame.getTheData().getDataType().equals(EDataType.MultiSelect));
    assertTrue(theFrame.pnlListItems.isVisible());
    model = (DefaultListModel) theFrame.lstListItems.getModel();
    assertTrue(model.size() == 0);
    // MetaDataListValues value = MetaDataListValues.create("Stuff",
    // "Stuff");
    metaDataPresenter.addDataLookupItem("Stuff", "Stuff");
    // MetaDataListValues value2 = MetaDataListValues.create("Stuff2",
    // "Stuff2");
    metaDataPresenter.addDataLookupItem("Stuff2", "Stuff2");
    assertTrue(model.size() == 2);
    theFrame.editingLookupValue = false;
    theFrame.lstListItems.setSelectedIndex(0);
    assertTrue(theFrame.getIsEditingLookupValue());
    loadConfigFile();
    model = (DefaultListModel) theFrame.lstDataList.getModel();
    metaDataPresenter.addNewItem();
    assertTrue(model.getSize() == 10);
    assertTrue(theFrame.lstDataList.getSelectedIndex() == 9);
    metaDataPresenter.deleteItem();
    model = (DefaultListModel) theFrame.lstDataList.getModel();
    assertTrue(model.getSize() == 9);
    assertTrue(theFrame.lstDataList.getSelectedValue() == null);
}

From source file:nz.govt.natlib.ndha.manualdeposit.MetaDataTest.java

@Test
public final void testLookupData() {
    loadConfigFile();/*  w w w . j a  v  a 2s .c  o  m*/
    theFrame.lstDataList.setSelectedIndex(0);
    theFrame.cmbDataType.setSelectedItem(EDataType.MultiSelect);
    assertTrue(theFrame.getTheData().getDataType().equals(EDataType.MultiSelect));
    assertTrue(theFrame.pnlListItems.isVisible());
    DefaultListModel model = (DefaultListModel) theFrame.lstListItems.getModel();
    assertTrue(model.size() == 0);
    assertFalse(metaDataPresenter.canSaveLookupData(null));
    assertFalse(metaDataPresenter.canSaveLookupData(""));
    assertTrue(metaDataPresenter.canSaveLookupData("Test"));
    assertFalse(metaDataPresenter.canDeleteLookupData());
    boolean failed = false;
    try {
        // Can't save unless something is selected - should add instead
        // MetaDataListValues value = MetaDataListValues.create("Stuff",
        // "Stuff", 0);
        metaDataPresenter.saveDataLookupItem("Stuff", "Stuff");
    } catch (Exception ex) {
        failed = true;
    }
    // assertTrue(failed);
    MetaDataListValues value1 = MetaDataListValues.create("Value 1", "Value 1", 0);
    metaDataPresenter.addDataLookupItem(value1.getValue(), value1.getDisplay());
    MetaDataListValues value2 = MetaDataListValues.create("Value 2", "Value 2", 1);
    metaDataPresenter.addDataLookupItem(value2.getValue(), value2.getDisplay());
    MetaDataListValues value3 = MetaDataListValues.create("Value 3", "Value 3", 2);
    metaDataPresenter.addDataLookupItem(value3.getValue(), value3.getDisplay());
    assertTrue(model.getSize() == 3);
    theFrame.lstListItems.setSelectedIndex(0);
    MetaDataListValues newValue = MetaDataListValues.create("New Value", "New Value", 3);
    metaDataPresenter.saveDataLookupItem(newValue.getValue(), newValue.getDisplay());
    MetaDataListValues testValue = (MetaDataListValues) theFrame.lstListItems.getSelectedValue();
    assertTrue(testValue.getDisplay().equals(newValue.getDisplay()));
    assertTrue(testValue.getValue().equals(newValue.getValue()));
    assertTrue(metaDataPresenter.canMoveLookupItem(false));
    assertFalse(metaDataPresenter.canMoveLookupItem(true));
    metaDataPresenter.moveLookupItem(false);
    assertTrue(metaDataPresenter.canMoveLookupItem(false));
    assertTrue(metaDataPresenter.canMoveLookupItem(true));
    assertTrue(theFrame.lstListItems.getSelectedIndex() == 1);
    metaDataPresenter.moveLookupItem(true);
    assertTrue(metaDataPresenter.canMoveLookupItem(false));
    assertFalse(metaDataPresenter.canMoveLookupItem(true));
    assertTrue(theFrame.lstListItems.getSelectedIndex() == 0);
    theFrame.lstListItems.setSelectedIndex(2);
    assertFalse(metaDataPresenter.canMoveLookupItem(false));
    assertTrue(metaDataPresenter.canMoveLookupItem(true));
    assertTrue(metaDataPresenter.canDeleteLookupData());
    metaDataPresenter.deleteLookupItem();
    assertTrue(model.size() == 2);
    testValue = (MetaDataListValues) model.get(0);
    assertTrue(testValue.getDisplay().equals(newValue.getDisplay()));
    assertTrue(testValue.getValue().equals(newValue.getValue()));
    testValue = (MetaDataListValues) model.get(1);
    assertTrue(testValue.getDisplay().equals(value2.getDisplay()));
    assertTrue(testValue.getValue().equals(value2.getValue()));
}