List of usage examples for javax.swing DefaultListModel remove
public E remove(int index)
From source file:ListCutPaste.java
/** * When the export is complete, remove the old list entry if the action was a * move.//from w ww . ja va2s .c om */ protected void exportDone(JComponent c, Transferable data, int action) { if (action != MOVE) { return; } JList list = (JList) c; DefaultListModel model = (DefaultListModel) list.getModel(); int index = list.getSelectedIndex(); model.remove(index); }
From source file:de.pavloff.spark4knime.jsnippet.ui.JarListPanel.java
private void onJarRemove() { DefaultListModel model = (DefaultListModel) m_addJarList.getModel(); int[] sels = m_addJarList.getSelectedIndices(); int last = Integer.MAX_VALUE; // traverse backwards (editing list in loop body) for (int i = sels.length - 1; i >= 0; i--) { assert sels[i] < last : "Selection list not ordered"; model.remove(sels[i]); }//from w w w .j av a 2s . c o m }
From source file:edu.ku.brc.specify.plugins.TaxonLabelFormatting.java
@Override public void initialize(Properties propertiesArg, boolean isViewModeArg) { super.initialize(propertiesArg, isViewModeArg); String plName = "TaxonLabelFormatter"; PickListDBAdapterIFace adapter = PickListDBAdapterFactory.getInstance().create(plName, false); if (adapter == null || adapter.getPickList() == null) { throw new RuntimeException("PickList Adapter [" + plName + "] cannot be null!"); }/*www . j a va2 s . c o m*/ formatCBX = new ValComboBox(adapter); formatCBX.getComboBox().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doFormatting(); } }); formatCBX.getComboBox().addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { doFormatting(); } }); newAgentBtn = createButton(""); // Label set when new Resource Bundle is installed (below) searchPanel = new DBObjSearchPanel("Search", "AgentNameSearch", "AgentNameSearch", "edu.ku.brc.specify.datamodel.Agent", "agentId", SwingConstants.BOTTOM); searchPanel.getScrollPane().setMinimumSize(new Dimension(100, 200)); searchPanel.getScrollPane().setPreferredSize(new Dimension(100, 150)); ((FormViewObj) searchPanel.getForm()).getPanel().setBorder(null); try { UIRegistry.loadAndPushResourceBundle("specify_plugins"); newAgentBtn.setText(getResourceString("NewAgent")); authorsList = new JList(new DefaultListModel()); authorsList.setVisibleRowCount(10); authorsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { Object selObj = authorsList.getSelectedValue(); if (selObj != null) { } updateEnabledState(); } } }); JScrollPane scrollPane = new JScrollPane(authorsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); mapToBtn = createIconBtn("Map", "ADD_AUTHOR_NAME_TT", new ActionListener() { public void actionPerformed(ActionEvent ae) { Object agent = searchPanel.getSelectedObject(); ((DefaultListModel) authorsList.getModel()).addElement(agent); doFormatting(); } }); unmapBtn = createIconBtn("Unmap", "REMOVE_AUTHOR_NAME_TT", new ActionListener() { public void actionPerformed(ActionEvent ae) { int index = authorsList.getSelectedIndex(); if (index > -1) { DefaultListModel model = (DefaultListModel) authorsList.getModel(); model.remove(index); updateEnabledState(); doFormatting(); } } }); upBtn = createIconBtn("ReorderUp", "MOVE_AUTHOR_NAME_UP", new ActionListener() { public void actionPerformed(ActionEvent ae) { DefaultListModel model = (DefaultListModel) authorsList.getModel(); int index = authorsList.getSelectedIndex(); Object item = authorsList.getSelectedValue(); model.remove(index); model.insertElementAt(item, index - 1); authorsList.setSelectedIndex(index - 1); updateEnabledState(); } }); downBtn = createIconBtn("ReorderDown", "MOVE_AUTHOR_NAME_DOWN", new ActionListener() { public void actionPerformed(ActionEvent ae) { DefaultListModel model = (DefaultListModel) authorsList.getModel(); int index = authorsList.getSelectedIndex(); Object item = authorsList.getSelectedValue(); model.remove(index); model.insertElementAt(item, index + 1); authorsList.setSelectedIndex(index + 1); updateEnabledState(); } }); PanelBuilder bldr = new PanelBuilder(new FormLayout("p, 5px, p, 5px, f:p:g, 2px, p", "p, 4px, p, 2px, f:p:g, 4px, p, 4px, p, 2px, p, 2px, p, 2px, p"), this); CellConstraints cc = new CellConstraints(); PanelBuilder upDownPanel = new PanelBuilder(new FormLayout("p", "p, 2px, p, f:p:g")); upDownPanel.add(upBtn, cc.xy(1, 1)); upDownPanel.add(downBtn, cc.xy(1, 3)); PanelBuilder middlePanel = new PanelBuilder(new FormLayout("c:p:g", "f:p:g, p, 2px, p, f:p:g")); middlePanel.add(mapToBtn, cc.xy(1, 2)); middlePanel.add(unmapBtn, cc.xy(1, 4)); PanelBuilder rwPanel = new PanelBuilder(new FormLayout("p, 2px, f:p:g", "p")); refWorkLabel = createLabel(getResourceString("NONE")); rwPanel.add(createI18NFormLabel("REFERENCEWORK"), cc.xy(1, 1)); rwPanel.add(refWorkLabel, cc.xy(3, 1)); int y = 1; bldr.add(rwPanel.getPanel(), cc.xywh(1, y, 7, 1)); y += 2; bldr.add(searchPanel, cc.xywh(1, y, 1, 3)); bldr.addSeparator(getResourceString("Authors"), cc.xy(5, y)); y += 2; bldr.add(middlePanel.getPanel(), cc.xy(3, y)); bldr.add(scrollPane, cc.xywh(5, y, 1, 3)); bldr.add(upDownPanel.getPanel(), cc.xy(7, y)); y += 2; PanelBuilder newAgentPanel = new PanelBuilder(new FormLayout("f:p:g,p", "p")); newAgentPanel.add(newAgentBtn, cc.xy(2, 1)); bldr.add(newAgentPanel.getPanel(), cc.xy(1, y)); y += 2; JLabel fmtLabel = createLabel(getResourceString("LABELFORMAT")); bldr.add(fmtLabel, cc.xy(1, y)); y += 2; bldr.add(formatCBX, cc.xywh(1, y, 7, 1)); y += 2; Font plain = fmtLabel.getFont(); specialLabel = new SpecialLabel(plain, new Font(plain.getName(), Font.ITALIC, plain.getSize())); specialLabel.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY)); bldr.add(createLabel(getResourceString("SAMPLEOUTPUT") + ":"), cc.xywh(1, y, 7, 1)); y += 2; bldr.add(specialLabel, cc.xywh(1, y, 7, 1)); searchPanel.setOKBtn(mapToBtn); } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(TaxonLabelFormatting.class, ex); log.error(ex); ex.printStackTrace(); } UIRegistry.popResourceBundle(); }
From source file:DropDemo.java
protected void cleanup(JComponent c, boolean remove) { if (remove && indices != null) { JList source = (JList) c; DefaultListModel model = (DefaultListModel) source.getModel(); // If we are moving items around in the same list, we // need to adjust the indices accordingly, since those // after the insertion point have moved. if (addCount > 0) { for (int i = 0; i < indices.length; i++) { if (indices[i] > addIndex) { indices[i] += addCount; }/* w w w. j av a 2s . com*/ } } for (int i = indices.length - 1; i >= 0; i--) { model.remove(indices[i]); } } indices = null; addCount = 0; addIndex = -1; }
From source file:br.upe.ecomp.dosa.view.wizard.WizardAction.java
private void pickListUpAction(final JList list) { final DefaultListModel selectedListModel = (DefaultListModel) list.getModel(); final int selectedIndex = list.getSelectedIndex(); Object element;/*from ww w . ja v a 2s. c o m*/ if (selectedIndex > 0) { element = list.getSelectedValue(); selectedListModel.remove(selectedIndex); selectedListModel.add(selectedIndex - 1, element); } }
From source file:DragListDemo.java
protected void exportDone(JComponent c, Transferable data, int action) { if ((action == MOVE) && (indices != null)) { DefaultListModel model = (DefaultListModel) source.getModel(); //If we are moving items around in the same list, we //need to adjust the indices accordingly since those //after the insertion point have moved. if (addCount > 0) { for (int i = 0; i < indices.length; i++) { if (indices[i] > addIndex) { indices[i] += addCount; }/*from w ww . j av a 2 s . c o m*/ } } for (int i = indices.length - 1; i >= 0; i--) model.remove(indices[i]); } indices = null; addIndex = -1; addCount = 0; }
From source file:br.upe.ecomp.dosa.view.wizard.WizardAction.java
private void pickListDownAction(final JList list) { final DefaultListModel selectedListModel = (DefaultListModel) list.getModel(); final int selectedIndex = list.getSelectedIndex(); final int listSize = selectedListModel.getSize(); Object element;//from www . j ava 2 s . c o m if (selectedIndex < listSize - 1) { element = list.getSelectedValue(); selectedListModel.remove(selectedIndex); selectedListModel.add(selectedIndex + 1, element); } }
From source file:ExtendedDnDDemo.java
protected void cleanup(JComponent c, boolean remove) { if (remove && indices != null) { JList source = (JList) c; DefaultListModel model = (DefaultListModel) source.getModel(); //If we are moving items around in the same list, we //need to adjust the indices accordingly, since those //after the insertion point have moved. if (addCount > 0) { for (int i = 0; i < indices.length; i++) { if (indices[i] > addIndex) { indices[i] += addCount; }/*from w w w .j a v a 2 s.c o m*/ } } for (int i = indices.length - 1; i >= 0; i--) { model.remove(indices[i]); } } indices = null; addCount = 0; addIndex = -1; }
From source file:de.dakror.virtualhub.client.dialog.ChooseCatalogDialog.java
public static void show(ClientFrame frame, final JSONArray data) { final JDialog dialog = new JDialog(frame, "Katalog whlen", true); dialog.setSize(400, 300);/*from www . j a va 2 s . co m*/ dialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); dialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { Client.currentClient.disconnect(); System.exit(0); } }); JPanel contentPane = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0)); dialog.setContentPane(contentPane); DefaultListModel dlm = new DefaultListModel(); for (int i = 0; i < data.length(); i++) { try { dlm.addElement(data.getJSONObject(i).getString("name")); } catch (JSONException e) { e.printStackTrace(); } } final JList catalogs = new JList(dlm); catalogs.setDragEnabled(false); catalogs.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane jsp = new JScrollPane(catalogs, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); jsp.setPreferredSize(new Dimension(396, 200)); contentPane.add(jsp); JPanel mods = new JPanel(new GridLayout(1, 2)); mods.setPreferredSize(new Dimension(50, 22)); mods.add(new JButton(new AbstractAction("+") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { String name = JOptionPane.showInputDialog(dialog, "Bitte geben Sie den Namen des neuen Katalogs ein.", "Katalog hinzufgen", JOptionPane.PLAIN_MESSAGE); if (name != null && name.length() > 0) { DefaultListModel dlm = (DefaultListModel) catalogs.getModel(); for (int i = 0; i < dlm.getSize(); i++) { if (dlm.get(i).toString().equals(name)) { JOptionPane.showMessageDialog(dialog, "Es existert bereits ein Katalog mit diesem Namen!", "Katalog bereits vorhanden!", JOptionPane.ERROR_MESSAGE); actionPerformed(e); return; } } try { dlm.addElement(name); JSONObject o = new JSONObject(); o.put("name", name); o.put("sources", new JSONArray()); o.put("tags", new JSONArray()); data.put(o); Client.currentClient.sendPacket(new Packet0Catalogs(data)); } catch (Exception e1) { e1.printStackTrace(); } } } })); mods.add(new JButton(new AbstractAction("-") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { if (catalogs.getSelectedIndex() != -1) { if (JOptionPane.showConfirmDialog(dialog, "Sind Sie sicher, dass Sie diesen\r\nKatalog unwiderruflich lschen wollen?", "Katalog lschen", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { DefaultListModel dlm = (DefaultListModel) catalogs.getModel(); data.remove(catalogs.getSelectedIndex()); dlm.remove(catalogs.getSelectedIndex()); try { Client.currentClient.sendPacket(new Packet0Catalogs(data)); } catch (IOException e1) { e1.printStackTrace(); } } } } })); contentPane.add(mods); JLabel l = new JLabel(""); l.setPreferredSize(new Dimension(396, 14)); contentPane.add(l); JSeparator sep = new JSeparator(JSeparator.HORIZONTAL); sep.setPreferredSize(new Dimension(396, 10)); contentPane.add(sep); JPanel buttons = new JPanel(new GridLayout(1, 2)); buttons.setPreferredSize(new Dimension(396, 22)); buttons.add(new JButton(new AbstractAction("Abbrechen") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { Client.currentClient.disconnect(); System.exit(0); } })); buttons.add(new JButton(new AbstractAction("Katalog whlen") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { if (catalogs.getSelectedIndex() != -1) { try { Client.currentClient .setCatalog(new Catalog(data.getJSONObject(catalogs.getSelectedIndex()))); Client.currentClient.frame.setTitle("- " + Client.currentClient.getCatalog().getName()); dialog.dispose(); } catch (JSONException e1) { e1.printStackTrace(); } } } })); dialog.add(buttons); dialog.setLocationRelativeTo(frame); dialog.setResizable(false); dialog.setVisible(true); }
From source file:gtu._work.ui.ExportSVNModificationFilesUI.java
private void initGUI() { try {/*from w w w .ja v a2s. c o m*/ 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(); } }