List of usage examples for javax.swing JList JList
public JList()
JList
with an empty, read-only, model. From source file:gtu._work.ui.RegexCatchReplacer_Ebao.java
private void initGUI() { try {//from www . ja v a 2s. 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); { replaceArea = new JTextArea(); jScrollPane1.setViewportView(replaceArea); replaceArea.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { JPopupMenuUtil.newInstance(replaceArea).applyEvent(evt) .addJMenuItem("load from file", true, new ActionListener() { Thread newThread; public void actionPerformed(ActionEvent arg0) { if (newThread != null && newThread.getState() != Thread.State.TERMINATED) { JCommonUtil._jOptionPane_showMessageDialog_error( "file is loading!"); return; } final File file = JCommonUtil._jFileChooser_selectFileOnly(); if (file == null) { JCommonUtil._jOptionPane_showMessageDialog_error( "file is not correct!"); return; } String defaultCharset = Charset.defaultCharset().displayName(); String chst = (String) JCommonUtil._jOptionPane_showInputDialog( "input your charset!", defaultCharset); final Charset charset2 = Charset.forName( StringUtils.defaultIfEmpty(chst, defaultCharset)); newThread = new Thread(Thread.currentThread().getThreadGroup(), new Runnable() { public void run() { try { loadFromFileSb = new StringBuilder(); BufferedReader reader = new BufferedReader( new InputStreamReader( new FileInputStream(file), charset2)); for (String line = null; (line = reader .readLine()) != null;) { loadFromFileSb.append(line + "\n"); } reader.close(); replaceArea .setText(loadFromFileSb.toString()); JCommonUtil ._jOptionPane_showMessageDialog_info( "load completed!"); } catch (Exception e) { JCommonUtil.handleException(e); } } }, "" + System.currentTimeMillis()); newThread.setDaemon(true); newThread.start(); } }).show(); } }); } } } { 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); jScrollPane2.setPreferredSize(new java.awt.Dimension(491, 283)); { DefaultTableModel resultAreaModel = JTableUtil.createModel(true, "match", "count"); resultArea = new JTable(); jScrollPane2.setViewportView(resultArea); JTableUtil.defaultSetting(resultArea); resultArea.setModel(resultAreaModel); } } } { 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(); jScrollPane3.setViewportView(templateList); reloadTemplateList(); } 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); } }); } } { jPanel6 = new JPanel(); FlowLayout jPanel6Layout = new FlowLayout(); jPanel6.setLayout(jPanel6Layout); jTabbedPane1.addTab("result1", null, jPanel6, null); { resultBtn1 = new JButton(); jPanel6.add(resultBtn1); resultBtn1.setText("to String[]"); resultBtn1.setPreferredSize(new java.awt.Dimension(105, 32)); resultBtn1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { JTableUtil tableUtil = JTableUtil.newInstance(resultArea); int[] rowPoss = tableUtil.getSelectedRows(); DefaultTableModel model = tableUtil.getModel(); List<Object> valueList = new ArrayList<Object>(); for (int ii = 0; ii < rowPoss.length; ii++) { valueList.add(model.getValueAt(rowPoss[ii], 0)); } String reult = valueList.toString().replaceAll("[\\s]", "") .replaceAll("[\\,]", "\",\"").replaceAll("[\\[\\]]", "\""); ClipboardUtil.getInstance().setContents(reult); } }); } { resultBtn2 = new JButton(); jPanel6.add(resultBtn2); resultBtn2.setText("TODO"); resultBtn2.setPreferredSize(new java.awt.Dimension(105, 32)); resultBtn2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out.println("resultBtn1.actionPerformed, event=" + evt); // TODO add your code for // resultBtn1.actionPerformed JCommonUtil._jOptionPane_showMessageDialog_info("TODO"); } }); } } } this.setSize(512, 350); JCommonUtil.setFont(repToText, repFromText, replaceArea, templateList); { panel = new JPanel(); jTabbedPane1.addTab("eBao", null, panel, null); panel.setLayout(new BorderLayout(0, 0)); { scrollPane = new JScrollPane(); panel.add(scrollPane, BorderLayout.CENTER); { ebaoTable = new JTable(); scrollPane.setViewportView(ebaoTable); // TODO DefaultTableModel ebaoModel = JTableUtil.createModel(true, "match", "label"); JTableUtil.defaultSetting(ebaoTable); ebaoTable.setModel(ebaoModel); } } { exactEbaoSearchChk = new JCheckBox(""); panel.add(exactEbaoSearchChk, BorderLayout.NORTH); } } 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.ExecuteOpener.java
private void initGUI() { final SwingActionUtil swingUtil = SwingActionUtil.newInstance(this); ToolTipManager.sharedInstance().setInitialDelay(0); try {/*from ww w. ja va 2 s .co 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:AppSpringLayout.java
/** * Initialize the contents of the frame. *///w ww . j a v a 2s. c om private void initialize() { frame = new JFrame(); frame.setBounds(0, 0, 850, 750); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); springLayout = new SpringLayout(); frame.getContentPane().setLayout(springLayout); frame.setLocationRelativeTo(null); FileNameExtensionFilter filter = new FileNameExtensionFilter("Image files", "jpg", "jpeg", "png"); fc = new JFileChooser(); fc.setFileFilter(filter); // frame.getContentPane().add(fc); btnTurnCameraOn = new JButton("Turn camera on"); springLayout.putConstraint(SpringLayout.WEST, btnTurnCameraOn, 51, SpringLayout.WEST, frame.getContentPane()); springLayout.putConstraint(SpringLayout.EAST, btnTurnCameraOn, -581, SpringLayout.EAST, frame.getContentPane()); frame.getContentPane().add(btnTurnCameraOn); urlTextField = new JTextField(); springLayout.putConstraint(SpringLayout.SOUTH, btnTurnCameraOn, -6, SpringLayout.NORTH, urlTextField); springLayout.putConstraint(SpringLayout.WEST, urlTextField, 0, SpringLayout.WEST, btnTurnCameraOn); springLayout.putConstraint(SpringLayout.EAST, urlTextField, 274, SpringLayout.WEST, frame.getContentPane()); frame.getContentPane().add(urlTextField); urlTextField.setColumns(10); originalImageLabel = new JLabel(""); springLayout.putConstraint(SpringLayout.NORTH, originalImageLabel, 102, SpringLayout.NORTH, frame.getContentPane()); springLayout.putConstraint(SpringLayout.WEST, originalImageLabel, 34, SpringLayout.WEST, frame.getContentPane()); springLayout.putConstraint(SpringLayout.SOUTH, originalImageLabel, -326, SpringLayout.SOUTH, frame.getContentPane()); springLayout.putConstraint(SpringLayout.EAST, originalImageLabel, -566, SpringLayout.EAST, frame.getContentPane()); springLayout.putConstraint(SpringLayout.SOUTH, urlTextField, -6, SpringLayout.NORTH, originalImageLabel); frame.getContentPane().add(originalImageLabel); btnAnalyseImage = new JButton("Analyse image"); springLayout.putConstraint(SpringLayout.NORTH, btnAnalyseImage, 6, SpringLayout.SOUTH, originalImageLabel); springLayout.putConstraint(SpringLayout.WEST, btnAnalyseImage, 58, SpringLayout.WEST, frame.getContentPane()); springLayout.putConstraint(SpringLayout.EAST, btnAnalyseImage, 252, SpringLayout.WEST, frame.getContentPane()); frame.getContentPane().add(btnAnalyseImage); lblTags = new JLabel("Tags:"); frame.getContentPane().add(lblTags); lblDescription = new JLabel("Description:"); springLayout.putConstraint(SpringLayout.WEST, lblDescription, 84, SpringLayout.EAST, lblTags); springLayout.putConstraint(SpringLayout.NORTH, lblTags, 0, SpringLayout.NORTH, lblDescription); springLayout.putConstraint(SpringLayout.NORTH, lblDescription, 6, SpringLayout.SOUTH, btnAnalyseImage); springLayout.putConstraint(SpringLayout.SOUTH, lblDescription, -269, SpringLayout.SOUTH, frame.getContentPane()); frame.getContentPane().add(lblDescription); tagsTextArea = new JTextArea(); springLayout.putConstraint(SpringLayout.NORTH, tagsTextArea, 459, SpringLayout.NORTH, frame.getContentPane()); springLayout.putConstraint(SpringLayout.WEST, tagsTextArea, 10, SpringLayout.WEST, frame.getContentPane()); springLayout.putConstraint(SpringLayout.EAST, tagsTextArea, -727, SpringLayout.EAST, frame.getContentPane()); frame.getContentPane().add(tagsTextArea); descriptionTextArea = new JTextArea(); springLayout.putConstraint(SpringLayout.NORTH, descriptionTextArea, 0, SpringLayout.SOUTH, lblDescription); springLayout.putConstraint(SpringLayout.WEST, descriptionTextArea, 18, SpringLayout.EAST, tagsTextArea); descriptionTextArea.setLineWrap(true); descriptionTextArea.setWrapStyleWord(true); frame.getContentPane().add(descriptionTextArea); lblImageType = new JLabel("Image type"); springLayout.putConstraint(SpringLayout.WEST, lblTags, 0, SpringLayout.WEST, lblImageType); springLayout.putConstraint(SpringLayout.NORTH, lblImageType, 10, SpringLayout.SOUTH, tagsTextArea); springLayout.putConstraint(SpringLayout.WEST, lblImageType, 20, SpringLayout.WEST, frame.getContentPane()); frame.getContentPane().add(lblImageType); lblSize = new JLabel("Size"); springLayout.putConstraint(SpringLayout.NORTH, lblSize, 21, SpringLayout.SOUTH, lblImageType); springLayout.putConstraint(SpringLayout.WEST, lblSize, 20, SpringLayout.WEST, frame.getContentPane()); frame.getContentPane().add(lblSize); lblLicense = new JLabel("License"); springLayout.putConstraint(SpringLayout.WEST, lblLicense, 20, SpringLayout.WEST, frame.getContentPane()); frame.getContentPane().add(lblLicense); lblSafeSearch = new JLabel("Safe search"); springLayout.putConstraint(SpringLayout.WEST, lblSafeSearch, 10, SpringLayout.WEST, frame.getContentPane()); springLayout.putConstraint(SpringLayout.SOUTH, lblSafeSearch, 139, SpringLayout.SOUTH, frame.getContentPane()); frame.getContentPane().add(lblSafeSearch); String[] licenseTypes = { "unspecified", "Public", "Share", "ShareCommercially", "Modify" }; licenseBox = new JComboBox(licenseTypes); springLayout.putConstraint(SpringLayout.WEST, licenseBox, 28, SpringLayout.EAST, lblLicense); frame.getContentPane().add(licenseBox); String[] sizeTypes = { "unspecified", "Small", "Medium", "Large", "Wallpaper" }; sizeBox = new JComboBox(sizeTypes); springLayout.putConstraint(SpringLayout.WEST, sizeBox, 50, SpringLayout.EAST, lblSize); springLayout.putConstraint(SpringLayout.EAST, sizeBox, -556, SpringLayout.EAST, frame.getContentPane()); springLayout.putConstraint(SpringLayout.EAST, licenseBox, 0, SpringLayout.EAST, sizeBox); frame.getContentPane().add(sizeBox); String[] imageTypes = { "unspecified", "AnimategGif", "Clipart", "Line", "Photo" }; imageTypeBox = new JComboBox(imageTypes); springLayout.putConstraint(SpringLayout.SOUTH, descriptionTextArea, -6, SpringLayout.NORTH, imageTypeBox); springLayout.putConstraint(SpringLayout.NORTH, imageTypeBox, 547, SpringLayout.NORTH, frame.getContentPane()); springLayout.putConstraint(SpringLayout.SOUTH, tagsTextArea, -6, SpringLayout.NORTH, imageTypeBox); springLayout.putConstraint(SpringLayout.WEST, imageTypeBox, 6, SpringLayout.EAST, lblImageType); springLayout.putConstraint(SpringLayout.EAST, imageTypeBox, -556, SpringLayout.EAST, frame.getContentPane()); springLayout.putConstraint(SpringLayout.NORTH, sizeBox, 10, SpringLayout.SOUTH, imageTypeBox); frame.getContentPane().add(imageTypeBox); btnBrowse = new JButton("Browse"); springLayout.putConstraint(SpringLayout.WEST, btnBrowse, 0, SpringLayout.WEST, btnTurnCameraOn); springLayout.putConstraint(SpringLayout.EAST, btnBrowse, -583, SpringLayout.EAST, frame.getContentPane()); frame.getContentPane().add(btnBrowse); lblSafeSearch_1 = new JLabel("Safe search"); springLayout.putConstraint(SpringLayout.WEST, lblSafeSearch_1, 20, SpringLayout.WEST, frame.getContentPane()); springLayout.putConstraint(SpringLayout.SOUTH, lblLicense, -17, SpringLayout.NORTH, lblSafeSearch_1); frame.getContentPane().add(lblSafeSearch_1); String[] safeSearchTypes = { "Strict", "Moderate", "Off" }; safeSearchBox = new JComboBox(safeSearchTypes); springLayout.putConstraint(SpringLayout.SOUTH, licenseBox, -6, SpringLayout.NORTH, safeSearchBox); springLayout.putConstraint(SpringLayout.WEST, safeSearchBox, 4, SpringLayout.EAST, lblSafeSearch_1); springLayout.putConstraint(SpringLayout.EAST, safeSearchBox, 0, SpringLayout.EAST, licenseBox); frame.getContentPane().add(safeSearchBox); btnSearchForSimilar = new JButton("Search for similar images"); springLayout.putConstraint(SpringLayout.SOUTH, lblSafeSearch_1, -13, SpringLayout.NORTH, btnSearchForSimilar); springLayout.putConstraint(SpringLayout.SOUTH, safeSearchBox, -6, SpringLayout.NORTH, btnSearchForSimilar); springLayout.putConstraint(SpringLayout.NORTH, btnSearchForSimilar, 689, SpringLayout.NORTH, frame.getContentPane()); springLayout.putConstraint(SpringLayout.WEST, btnSearchForSimilar, 36, SpringLayout.WEST, frame.getContentPane()); frame.getContentPane().add(btnSearchForSimilar); btnCancel = new JButton("Cancel"); springLayout.putConstraint(SpringLayout.NORTH, btnCancel, 0, SpringLayout.NORTH, btnBrowse); btnCancel.setVisible(false); frame.getContentPane().add(btnCancel); btnSave = new JButton("Save"); springLayout.putConstraint(SpringLayout.WEST, btnCancel, 6, SpringLayout.EAST, btnSave); springLayout.putConstraint(SpringLayout.NORTH, btnSave, 0, SpringLayout.NORTH, btnBrowse); btnSave.setVisible(false); frame.getContentPane().add(btnSave); btnTakeAPicture = new JButton("Take a picture"); springLayout.putConstraint(SpringLayout.WEST, btnTakeAPicture, 114, SpringLayout.EAST, btnBrowse); springLayout.putConstraint(SpringLayout.WEST, btnSave, 6, SpringLayout.EAST, btnTakeAPicture); springLayout.putConstraint(SpringLayout.NORTH, btnTakeAPicture, 0, SpringLayout.NORTH, btnBrowse); btnTakeAPicture.setVisible(false); frame.getContentPane().add(btnTakeAPicture); //// JScrollPane scroll = new JScrollPane(list); // Constraints c = springLayout.getConstraints(list); // frame.getContentPane().add(scroll, c); list = new JList(); JScrollPane scroll = new JScrollPane(list); springLayout.putConstraint(SpringLayout.EAST, descriptionTextArea, -89, SpringLayout.WEST, list); springLayout.putConstraint(SpringLayout.EAST, list, -128, SpringLayout.EAST, frame.getContentPane()); springLayout.putConstraint(SpringLayout.WEST, list, 64, SpringLayout.EAST, licenseBox); springLayout.putConstraint(SpringLayout.NORTH, list, 0, SpringLayout.NORTH, btnTurnCameraOn); springLayout.putConstraint(SpringLayout.SOUTH, list, -35, SpringLayout.SOUTH, lblSafeSearch_1); Constraints c = springLayout.getConstraints(list); frame.getContentPane().add(scroll, c); // frame.getContentPane().add(list); progressBar = new JProgressBar(); springLayout.putConstraint(SpringLayout.NORTH, progressBar, 15, SpringLayout.SOUTH, list); springLayout.putConstraint(SpringLayout.WEST, progressBar, 24, SpringLayout.EAST, safeSearchBox); springLayout.putConstraint(SpringLayout.EAST, progressBar, 389, SpringLayout.WEST, btnTakeAPicture); progressBar.setIndeterminate(true); progressBar.setStringPainted(true); progressBar.setVisible(false); Border border = BorderFactory .createTitledBorder("We are checking every image, pixel by pixel, it may take a while..."); progressBar.setBorder(border); frame.getContentPane().add(progressBar); labelTryLinks = new JLabel(); labelTryLinks.setVisible(false); springLayout.putConstraint(SpringLayout.NORTH, labelTryLinks, -16, SpringLayout.SOUTH, btnSearchForSimilar); springLayout.putConstraint(SpringLayout.WEST, labelTryLinks, -61, SpringLayout.EAST, licenseBox); springLayout.putConstraint(SpringLayout.SOUTH, labelTryLinks, 0, SpringLayout.SOUTH, btnSearchForSimilar); springLayout.putConstraint(SpringLayout.EAST, labelTryLinks, 0, SpringLayout.EAST, licenseBox); frame.getContentPane().add(labelTryLinks); lblFoundLinks = new JLabel(""); springLayout.putConstraint(SpringLayout.NORTH, lblFoundLinks, -29, SpringLayout.NORTH, progressBar); springLayout.putConstraint(SpringLayout.WEST, lblFoundLinks, 6, SpringLayout.EAST, scroll); springLayout.putConstraint(SpringLayout.SOUTH, lblFoundLinks, -13, SpringLayout.NORTH, progressBar); springLayout.putConstraint(SpringLayout.EAST, lblFoundLinks, -10, SpringLayout.EAST, frame.getContentPane()); frame.getContentPane().add(lblFoundLinks); numberOfImagesToSearchFor = new JTextField(); springLayout.putConstraint(SpringLayout.NORTH, numberOfImagesToSearchFor, 0, SpringLayout.NORTH, tagsTextArea); springLayout.putConstraint(SpringLayout.WEST, numberOfImagesToSearchFor, 6, SpringLayout.EAST, descriptionTextArea); springLayout.putConstraint(SpringLayout.EAST, numberOfImagesToSearchFor, -36, SpringLayout.WEST, scroll); frame.getContentPane().add(numberOfImagesToSearchFor); numberOfImagesToSearchFor.setColumns(10); JLabel lblNumberOfImages = new JLabel("Number"); springLayout.putConstraint(SpringLayout.NORTH, lblNumberOfImages, 0, SpringLayout.NORTH, lblTags); springLayout.putConstraint(SpringLayout.WEST, lblNumberOfImages, 31, SpringLayout.EAST, btnAnalyseImage); springLayout.putConstraint(SpringLayout.EAST, lblNumberOfImages, -6, SpringLayout.WEST, scroll); frame.getContentPane().add(lblNumberOfImages); // label to get coordinates for web camera panel // lblNewLabel_1 = new JLabel("New label"); // springLayout.putConstraint(SpringLayout.NORTH, lblNewLabel_1, 0, // SpringLayout.NORTH, btnTurnCameraOn); // springLayout.putConstraint(SpringLayout.WEST, lblNewLabel_1, 98, // SpringLayout.EAST, originalImagesLabel); // springLayout.putConstraint(SpringLayout.SOUTH, lblNewLabel_1, -430, // SpringLayout.SOUTH, lblSafeSearch_1); // springLayout.putConstraint(SpringLayout.EAST, lblNewLabel_1, 0, // SpringLayout.EAST, btnCancel); // frame.getContentPane().add(lblNewLabel_1); btnBrowse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (fc.showOpenDialog(frame) == JFileChooser.APPROVE_OPTION) { openFilechooser(); } } }); btnTurnCameraOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("turn camera on"); turnCameraOn(); btnCancel.setVisible(true); btnTakeAPicture.setVisible(true); } }); btnTakeAPicture.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btnSave.setVisible(true); imageWebcam = webcam.getImage(); originalImage = imageWebcam; // to mirror the image we create a temporary file, flip it // horizontally and then delete // get user's name to store file in the user directory String user = System.getProperty("user.home"); String fileName = user + "/webCamPhoto.jpg"; File newFile = new File(fileName); try { ImageIO.write(originalImage, "jpg", newFile); } catch (IOException e1) { e1.printStackTrace(); } try { originalImage = (BufferedImage) ImageIO.read(newFile); } catch (IOException e1) { e1.printStackTrace(); } newFile.delete(); originalImage = mirrorImage(originalImage); icon = scaleBufferedImage(originalImage, originalImageLabel); originalImageLabel.setIcon(icon); } }); btnSave.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (fc.showSaveDialog(frame) == JFileChooser.APPROVE_OPTION) { try { file = fc.getSelectedFile(); File output = new File(file.toString()); // check if image already exists if (output.exists()) { int response = JOptionPane.showConfirmDialog(null, // "Do you want to replace the existing file?", // "Confirm", JOptionPane.YES_NO_OPTION, // JOptionPane.QUESTION_MESSAGE); if (response != JOptionPane.YES_OPTION) { return; } } ImageIO.write(toBufferedImage(originalImage), "jpg", output); System.out.println("Your image has been saved in the folder " + file.getPath()); } catch (IOException e1) { e1.printStackTrace(); } } } }); btnCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btnTakeAPicture.setVisible(false); btnCancel.setVisible(false); btnSave.setVisible(false); webcam.close(); panel.setVisible(false); } }); urlTextField.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (urlTextField.getText().length() > 0) { String linkNew = urlTextField.getText(); displayImage(linkNew, originalImageLabel); originalImage = imageResponses; } } }); btnAnalyseImage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Token computerVisionToken = new Token(); String computerVisionTokenFileName = "APIToken.txt"; try { computerVisionImageToken = computerVisionToken.getApiToken(computerVisionTokenFileName); try { analyse(); } catch (NullPointerException e1) { // if user clicks on "analyze" button without uploading // image or posts a broken link JOptionPane.showMessageDialog(null, "Please choose an image"); e1.printStackTrace(); } } catch (NullPointerException e1) { e1.printStackTrace(); } } }); btnSearchForSimilar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { listModel.clear(); Token bingImageToken = new Token(); String bingImageTokenFileName = "SearchApiToken.txt"; bingToken = bingImageToken.getApiToken(bingImageTokenFileName); // in case user edited description or tags, update it and // replace new line character, spaces and breaks with %20 text = descriptionTextArea.getText().replace(" ", "%20").replace("\r", "%20").replace("\n", "%20"); String tagsString = tagsTextArea.getText().replace(" ", "%20").replace("\r", "%20").replace("\n", "%20"); String numberOfImages = numberOfImagesToSearchFor.getText(); try { int numberOfImagesTry = Integer.parseInt(numberOfImages); System.out.println(numberOfImagesTry); imageTypeString = imageTypeBox.getSelectedItem().toString(); sizeTypeString = sizeBox.getSelectedItem().toString(); licenseTypeString = licenseBox.getSelectedItem().toString(); safeSearchTypeString = safeSearchBox.getSelectedItem().toString(); searchParameters = tagsString + text; System.out.println("search parameters: " + searchParameters); if (searchParameters.length() != 0) { // add new thread for searching, so that progress bar // and searching could run simultaneously Thread t1 = new Thread(new Runnable() { @Override public void run() { progressBar.setVisible(true); workingUrls = searchToDisplayOnJList(searchParameters, imageTypeString, sizeTypeString, licenseTypeString, safeSearchTypeString, numberOfImages); } }); // start searching in a separate thread t1.start(); } else { JOptionPane.showMessageDialog(null, "Please choose first an image to analyse or insert search parameters"); } } catch (NumberFormatException e1) { JOptionPane.showMessageDialog(null, "Please insert a valid number of images to search for"); e1.printStackTrace(); } } }); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int i = list.getSelectedIndex(); if (fc.showSaveDialog(frame) == JFileChooser.APPROVE_OPTION) { try { file = fc.getSelectedFile(); File output = new File(file.toString()); // check if file already exists, ask user if they // wish to overwrite it if (output.exists()) { int response = JOptionPane.showConfirmDialog(null, // "Do you want to replace the existing file?", // "Confirm", JOptionPane.YES_NO_OPTION, // JOptionPane.QUESTION_MESSAGE); if (response != JOptionPane.YES_OPTION) { return; } } try { URL fileNameAsUrl = new URL(linksResponse[i]); originalImage = ImageIO.read(fileNameAsUrl); ImageIO.write(toBufferedImage(originalImage), "jpeg", output); System.out.println("image saved, in the folder: " + output.getAbsolutePath()); } catch (MalformedURLException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } } catch (NullPointerException e2) { e2.getMessage(); } } } }); }
From source file:eu.europa.ec.markt.dss.applet.util.ComponentFactory.java
/** * /* w w w.j a va2 s .c o m*/ * @param name * @param model * @param cellRenderer * @return */ public static JList list(final String name, final ListModel model, final ListCellRenderer cellRenderer) { final JList list = new JList(); list.setName(name); list.setModel(model); if (cellRenderer != null) { list.setCellRenderer(cellRenderer); } return list; }
From source file:com._17od.upm.gui.MainWindow.java
private void addComponentsToPane() { // Ensure the layout manager is a BorderLayout if (!(getContentPane().getLayout() instanceof GridBagLayout)) { getContentPane().setLayout(new GridBagLayout()); }/*from w w w . j av a 2 s .c o m*/ // Create the menubar setJMenuBar(createMenuBar()); GridBagConstraints c = new GridBagConstraints(); // The toolbar Row c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.FIRST_LINE_START; c.insets = new Insets(0, 0, 0, 0); c.weightx = 0; c.weighty = 0; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; Component toolbar = createToolBar(); getContentPane().add(toolbar, c); // Keep the frame background color consistent getContentPane().setBackground(toolbar.getBackground()); // The seperator Row c.gridx = 0; c.gridy = 1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 0); c.weightx = 1; c.weighty = 0; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; getContentPane().add(new JSeparator(), c); // The search field row searchIcon = new JLabel(Util.loadImage("search.gif")); searchIcon.setDisabledIcon(Util.loadImage("search_d.gif")); searchIcon.setEnabled(false); c.gridx = 0; c.gridy = 2; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(5, 1, 5, 1); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; getContentPane().add(searchIcon, c); searchField = new JTextField(15); searchField.setEnabled(false); searchField.setMinimumSize(searchField.getPreferredSize()); searchField.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { // This method never seems to be called } public void insertUpdate(DocumentEvent e) { dbActions.filter(); } public void removeUpdate(DocumentEvent e) { dbActions.filter(); } }); searchField.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { dbActions.resetSearch(); } else if (e.getKeyCode() == KeyEvent.VK_ENTER) { // If the user hits the enter key in the search field and // there's only one item // in the listview then open that item (this code assumes // that the one item in // the listview has already been selected. this is done // automatically in the // DatabaseActions.filter() method) if (accountsListview.getModel().getSize() == 1) { viewAccountMenuItem.doClick(); } } } }); c.gridx = 1; c.gridy = 2; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(5, 1, 5, 1); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; getContentPane().add(searchField, c); resetSearchButton = new JButton(Util.loadImage("stop.gif")); resetSearchButton.setDisabledIcon(Util.loadImage("stop_d.gif")); resetSearchButton.setEnabled(false); resetSearchButton.setToolTipText(Translator.translate(RESET_SEARCH_TXT)); resetSearchButton.setActionCommand(RESET_SEARCH_TXT); resetSearchButton.addActionListener(this); resetSearchButton.setBorder(BorderFactory.createEmptyBorder()); resetSearchButton.setFocusable(false); c.gridx = 2; c.gridy = 2; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(5, 1, 5, 1); c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; getContentPane().add(resetSearchButton, c); // The accounts listview row accountsListview = new JList(); accountsListview.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); accountsListview.setSelectedIndex(0); accountsListview.setVisibleRowCount(10); accountsListview.setModel(new SortedListModel()); JScrollPane accountsScrollList = new JScrollPane(accountsListview, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); accountsListview.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { // If the listview gets focus, there is one ore more items in // the listview and there is nothing // already selected, then select the first item in the list if (accountsListview.getModel().getSize() > 0 && accountsListview.getSelectedIndex() == -1) { accountsListview.setSelectionInterval(0, 0); } } }); accountsListview.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { dbActions.setButtonState(); } }); accountsListview.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { viewAccountMenuItem.doClick(); } } }); accountsListview.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { viewAccountMenuItem.doClick(); } } }); // Create a shortcut to delete account functionality with DEL(delete) // key accountsListview.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { try { dbActions.reloadDatabaseBefore(new DeleteAccountAction()); } catch (InvalidPasswordException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (ProblemReadingDatabaseFile e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } }); c.gridx = 0; c.gridy = 3; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 1, 1, 1); c.weightx = 1; c.weighty = 1; c.gridwidth = 3; c.fill = GridBagConstraints.BOTH; getContentPane().add(accountsScrollList, c); // The "File Changed" panel c.gridx = 0; c.gridy = 4; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 1, 0, 1); c.ipadx = 3; c.ipady = 3; c.weightx = 0; c.weighty = 0; c.gridwidth = 3; c.fill = GridBagConstraints.BOTH; databaseFileChangedPanel = new JPanel(); databaseFileChangedPanel.setLayout(new BoxLayout(databaseFileChangedPanel, BoxLayout.X_AXIS)); databaseFileChangedPanel.setBackground(new Color(249, 172, 60)); databaseFileChangedPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); JLabel fileChangedLabel = new JLabel("Database file changed"); fileChangedLabel.setAlignmentX(LEFT_ALIGNMENT); databaseFileChangedPanel.add(fileChangedLabel); databaseFileChangedPanel.add(Box.createHorizontalGlue()); JButton reloadButton = new JButton("Reload"); reloadButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { dbActions.reloadDatabaseFromDisk(); } catch (Exception ex) { dbActions.errorHandler(ex); } } }); databaseFileChangedPanel.add(reloadButton); databaseFileChangedPanel.setVisible(false); getContentPane().add(databaseFileChangedPanel, c); // Add the statusbar c.gridx = 0; c.gridy = 5; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 1, 1, 1); c.weightx = 1; c.weighty = 0; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; getContentPane().add(statusBar, c); }
From source file:br.com.jinsync.view.FrmJInSync.java
/** * Initialize the contents of the frame. *//*ww w . j a va2 s . c o m*/ private void initialize() { Language.loadParameters(); setBounds(100, 100, 1136, 665); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] { 0, 0 }; gridBagLayout.rowHeights = new int[] { 600, 53, 0, 0 }; gridBagLayout.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gridBagLayout.rowWeights = new double[] { 1.0, 0.0, 0.0, Double.MIN_VALUE }; getContentPane().setLayout(gridBagLayout); grpFontes = new JTabbedPane(SwingConstants.TOP); GridBagConstraints gbc_grpFontes = new GridBagConstraints(); gbc_grpFontes.insets = new Insets(0, 0, 5, 0); gbc_grpFontes.fill = GridBagConstraints.BOTH; gbc_grpFontes.gridx = 0; gbc_grpFontes.gridy = 0; getContentPane().add(grpFontes, gbc_grpFontes); tabCopybook = new JPanel(); tabCopybook.setBackground(Color.WHITE); grpFontes.addTab(Language.tabCopy, null, tabCopybook, null); GridBagLayout gbl_tabCopybook = new GridBagLayout(); gbl_tabCopybook.columnWidths = new int[] { 10, 1, 0, 349, 0, 0, 62, 28, 71, 0, 0, 0 }; gbl_tabCopybook.rowHeights = new int[] { 1, 0, 0, 0 }; gbl_tabCopybook.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; gbl_tabCopybook.rowWeights = new double[] { 0.0, 0.0, 1.0, Double.MIN_VALUE }; tabCopybook.setLayout(gbl_tabCopybook); JLabel lblCopybook = new JLabel(Language.txtFilePds); GridBagConstraints gbc_lblCopybook = new GridBagConstraints(); gbc_lblCopybook.anchor = GridBagConstraints.EAST; gbc_lblCopybook.insets = new Insets(0, 0, 5, 5); gbc_lblCopybook.gridx = 1; gbc_lblCopybook.gridy = 1; tabCopybook.add(lblCopybook, gbc_lblCopybook); txtPath = new JTextField(); GridBagConstraints gbc_txtPath = new GridBagConstraints(); gbc_txtPath.gridwidth = 4; gbc_txtPath.insets = new Insets(0, 0, 5, 5); gbc_txtPath.fill = GridBagConstraints.HORIZONTAL; gbc_txtPath.gridx = 2; gbc_txtPath.gridy = 1; tabCopybook.add(txtPath, gbc_txtPath); txtPath.setColumns(10); JButton btnDiretorio = new JButton(""); btnDiretorio.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/folder.png"))); btnDiretorio.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { openDirectory(); } }); GridBagConstraints gbc_btnDiretorio = new GridBagConstraints(); gbc_btnDiretorio.insets = new Insets(0, 0, 5, 5); gbc_btnDiretorio.gridx = 6; gbc_btnDiretorio.gridy = 1; tabCopybook.add(btnDiretorio, gbc_btnDiretorio); btnClearCopy = new JButton(""); btnClearCopy.setEnabled(false); btnClearCopy.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { tableCopy = new JTable(); scrCopy.setViewportView(tableCopy); tableString = new JTable(); scrTableString.setViewportView(tableString); btnExcelString.setEnabled(false); btnClearString.setEnabled(false); textAreaString.setText(""); console.removeAllElements(); btnExcel.setEnabled(false); btnClearCopy.setEnabled(false); grpFontes.setEnabledAt(1, false); tableFile = new JTable(); scrFile.setViewportView(tableFile); btnExcelFile.setEnabled(false); btnClearFile.setEnabled(false); grpFontes.setEnabledAt(2, false); } }); btnClearCopy.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/cancel.png"))); GridBagConstraints gbc_btnLimpar = new GridBagConstraints(); gbc_btnLimpar.fill = GridBagConstraints.BOTH; gbc_btnLimpar.insets = new Insets(0, 0, 5, 5); gbc_btnLimpar.gridx = 9; gbc_btnLimpar.gridy = 1; tabCopybook.add(btnClearCopy, gbc_btnLimpar); JButton btnProcessarBook = new JButton(""); btnProcessarBook.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { loadData(); btnClearCopy.setEnabled(true); grpFontes.setEnabledAt(1, true); grpFontes.setEnabledAt(2, true); } }); btnProcessarBook.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/engine.png"))); GridBagConstraints gbc_btnProcessarBook = new GridBagConstraints(); gbc_btnProcessarBook.fill = GridBagConstraints.VERTICAL; gbc_btnProcessarBook.insets = new Insets(0, 0, 5, 5); gbc_btnProcessarBook.gridx = 7; gbc_btnProcessarBook.gridy = 1; tabCopybook.add(btnProcessarBook, gbc_btnProcessarBook); btnExcel = new JButton(""); btnExcel.setEnabled(false); btnExcel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { expExcelBook(); // exportarExcelBook(tableCopy, txtPath.getText(), // "Horizontal"); } }); btnExcel.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/excel.png"))); GridBagConstraints gbc_btnExcel = new GridBagConstraints(); gbc_btnExcel.insets = new Insets(0, 0, 5, 5); gbc_btnExcel.gridx = 8; gbc_btnExcel.gridy = 1; tabCopybook.add(btnExcel, gbc_btnExcel); // JScrollPane scrCopy = new JScrollPane(); gbc_scrCopy = new GridBagConstraints(); gbc_scrCopy.gridwidth = 9; gbc_scrCopy.insets = new Insets(0, 0, 0, 5); gbc_scrCopy.fill = GridBagConstraints.BOTH; gbc_scrCopy.gridx = 1; gbc_scrCopy.gridy = 2; // tabCopybook.add(scrCopy, gbc_scrCopy); panelConsole = new Panel(); GridBagConstraints gbc_panelConsole = new GridBagConstraints(); gbc_panelConsole.insets = new Insets(0, 0, 5, 0); gbc_panelConsole.fill = GridBagConstraints.BOTH; gbc_panelConsole.gridx = 0; gbc_panelConsole.gridy = 1; getContentPane().add(panelConsole, gbc_panelConsole); panelConsole.setLayout(new BorderLayout(0, 0)); listTerminal = new JList<String>(); listTerminal.setFont(new Font("Courier New", Font.PLAIN, 11)); listTerminal.setModel(console); scrConsole = new JScrollPane(listTerminal); panelConsole.add(scrConsole); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu mnNewMenu = new JMenu(Language.menuParam); menuBar.add(mnNewMenu); JMenuItem mnItemUsuario = new JMenuItem(Language.menuParamUser); mnItemUsuario.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { FrmUser frmUsuar = new FrmUser(); frmUsuar.setLocationRelativeTo(null); frmUsuar.setVisible(true); setUser(); } }); mnNewMenu.add(mnItemUsuario); JMenuItem mnItemFtp = new JMenuItem(Language.menuParamFtp); mnItemFtp.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { FrmFtp frmFtp = new FrmFtp(); frmFtp.setLocationRelativeTo(null); frmFtp.setVisible(true); setFtp(); } }); mnNewMenu.add(mnItemFtp); JMenu mnAjuda = new JMenu(Language.menuHelp); menuBar.add(mnAjuda); JMenuItem mntmNewMenuItem = new JMenuItem(Language.menuHelpAbout); mntmNewMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { FrmAbout frmSobre = new FrmAbout(); frmSobre.setLocationRelativeTo(null); frmSobre.setVisible(true); } }); mnAjuda.add(mntmNewMenuItem); tabCopybook.setFont(new Font("Arial", Font.PLAIN, 12)); tabCopybook.add(scrCopy, gbc_scrCopy); tabString = new JPanel(); tabString.setFont(new Font("Arial", Font.PLAIN, 12)); tabString.setBackground(Color.WHITE); grpFontes.addTab(Language.tabString, null, tabString, null); grpFontes.setEnabledAt(1, false); GridBagLayout gbl_tabString = new GridBagLayout(); gbl_tabString.columnWidths = new int[] { 10, 1, 346, 349, 0, 0, 62, 28, 71, 0, 0, 0 }; gbl_tabString.rowHeights = new int[] { 1, 0, 0, 17, 22, 0, 259, 0 }; gbl_tabString.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; gbl_tabString.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE }; tabString.setLayout(gbl_tabString); JLabel lblString = new JLabel("String:"); GridBagConstraints gbc_lblString = new GridBagConstraints(); gbc_lblString.anchor = GridBagConstraints.WEST; gbc_lblString.insets = new Insets(0, 0, 5, 5); gbc_lblString.gridx = 1; gbc_lblString.gridy = 1; tabString.add(lblString, gbc_lblString); textAreaString = new JTextArea(); JScrollPane scrStringData = new JScrollPane(textAreaString); GridBagConstraints gbc_scrString = new GridBagConstraints(); gbc_scrString.gridheight = 3; gbc_scrString.gridwidth = 8; gbc_scrString.insets = new Insets(0, 0, 5, 5); gbc_scrString.fill = GridBagConstraints.BOTH; gbc_scrString.gridx = 1; gbc_scrString.gridy = 2; tabString.add(scrStringData, gbc_scrString); btnClearString = new JButton(""); btnClearString.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { scrTableString.setViewportView(tableString); btnExcelString.setEnabled(false); btnClearString.setEnabled(false); textAreaString.setText(""); tableString = new JTable(); scrTableString.setViewportView(tableString); } }); btnExcelString = new JButton(""); btnExcelString.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { expExcelString(); } }); JButton btnProcessarArq = new JButton(""); btnProcessarArq.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { processString(); } }); btnProcessarArq.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/engine.png"))); GridBagConstraints gbc_btnProcessarArq = new GridBagConstraints(); gbc_btnProcessarArq.fill = GridBagConstraints.VERTICAL; gbc_btnProcessarArq.insets = new Insets(0, 0, 5, 5); gbc_btnProcessarArq.gridx = 9; gbc_btnProcessarArq.gridy = 2; tabString.add(btnProcessarArq, gbc_btnProcessarArq); btnExcelString.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/excel.png"))); btnExcelString.setEnabled(false); GridBagConstraints gbc_btnExcelString = new GridBagConstraints(); gbc_btnExcelString.fill = GridBagConstraints.VERTICAL; gbc_btnExcelString.insets = new Insets(0, 0, 5, 5); gbc_btnExcelString.gridx = 9; gbc_btnExcelString.gridy = 3; tabString.add(btnExcelString, gbc_btnExcelString); btnClearString.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/cancel.png"))); btnClearString.setEnabled(false); GridBagConstraints gbc_btnClearString = new GridBagConstraints(); gbc_btnClearString.fill = GridBagConstraints.VERTICAL; gbc_btnClearString.insets = new Insets(0, 0, 5, 5); gbc_btnClearString.gridx = 9; gbc_btnClearString.gridy = 4; tabString.add(btnClearString, gbc_btnClearString); JLabel lblSaida = new JLabel(Language.txtOutput); GridBagConstraints gbc_lblSaida = new GridBagConstraints(); gbc_lblSaida.insets = new Insets(0, 0, 5, 5); gbc_lblSaida.gridx = 1; gbc_lblSaida.gridy = 5; tabString.add(lblSaida, gbc_lblSaida); GridBagConstraints gbc_scrArquivo = new GridBagConstraints(); gbc_scrArquivo.fill = GridBagConstraints.BOTH; gbc_scrArquivo.gridwidth = 9; gbc_scrArquivo.insets = new Insets(0, 0, 0, 5); gbc_scrArquivo.gridx = 1; gbc_scrArquivo.gridy = 6; tabString.add(scrTableString, gbc_scrArquivo); tabFile = new JPanel(); tabFile.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent e) { // TODO Auto-generated method stub if (isProcessStarted) { int key = e.getKeyCode(); if (key == KeyEvent.VK_ESCAPE) { int opc = JOptionPane.showConfirmDialog(null, Language.msgCancelProcess, Language.msgInf, JOptionPane.OK_CANCEL_OPTION); if (opc == JOptionPane.OK_OPTION) { escProcessFile(); } } } } @Override public void keyReleased(KeyEvent arg0) { // TODO Auto-generated method stub } @Override public void keyTyped(KeyEvent arg0) { // TODO Auto-generated method stub } }); tabFile.setFont(new Font("Arial", Font.PLAIN, 12)); tabFile.setBackground(Color.WHITE); grpFontes.addTab(Language.tabFile, null, tabFile, null); grpFontes.setEnabledAt(2, false); GridBagLayout gbl_tabFile = new GridBagLayout(); gbl_tabFile.columnWidths = new int[] { 10, 1, 49, 459, 0, 0, 62, 28, 0, 71, 0, 0, 0, 0 }; gbl_tabFile.rowHeights = new int[] { 1, 0, 0, 17, 22, 0, 259, 0, 0 }; gbl_tabFile.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; gbl_tabFile.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE }; tabFile.setLayout(gbl_tabFile); JLabel lblFile = new JLabel(Language.txtFilePds); GridBagConstraints gbc_lblFile = new GridBagConstraints(); gbc_lblFile.anchor = GridBagConstraints.EAST; gbc_lblFile.insets = new Insets(0, 0, 5, 5); gbc_lblFile.gridx = 1; gbc_lblFile.gridy = 1; tabFile.add(lblFile, gbc_lblFile); txtFile = new JTextField(); txtFile.setColumns(10); GridBagConstraints gbc_txtFile = new GridBagConstraints(); gbc_txtFile.gridwidth = 5; gbc_txtFile.insets = new Insets(0, 0, 5, 5); gbc_txtFile.fill = GridBagConstraints.HORIZONTAL; gbc_txtFile.gridx = 2; gbc_txtFile.gridy = 1; tabFile.add(txtFile, gbc_txtFile); btnClearFile = new JButton(""); btnClearFile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { tableFile = new JTable(); scrFile.setViewportView(tableFile); btnExcelFile.setEnabled(false); btnClearFile.setEnabled(false); progressBar.setStringPainted(true); progressBar.setValue(0); progressBar.setString(""); } }); btnExcelFile = new JButton(""); btnExcelFile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { expExcelFile(); } }); btnProcFile = new JButton(""); btnProcFile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { loadFile(); } }); btnDirFile = new JButton(""); btnDirFile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openDirFile(); } }); btnDirFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/folder.png"))); GridBagConstraints gbc_btnDirFile = new GridBagConstraints(); gbc_btnDirFile.fill = GridBagConstraints.VERTICAL; gbc_btnDirFile.insets = new Insets(0, 0, 5, 5); gbc_btnDirFile.gridx = 7; gbc_btnDirFile.gridy = 1; tabFile.add(btnDirFile, gbc_btnDirFile); btnProcFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/engine.png"))); GridBagConstraints gbc_btnProcFile = new GridBagConstraints(); gbc_btnProcFile.fill = GridBagConstraints.VERTICAL; gbc_btnProcFile.insets = new Insets(0, 0, 5, 5); gbc_btnProcFile.gridx = 8; gbc_btnProcFile.gridy = 1; tabFile.add(btnProcFile, gbc_btnProcFile); btnExcelFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/excel.png"))); btnExcelFile.setEnabled(false); GridBagConstraints gbc_btnExcelFile = new GridBagConstraints(); gbc_btnExcelFile.insets = new Insets(0, 0, 5, 5); gbc_btnExcelFile.gridx = 9; gbc_btnExcelFile.gridy = 1; tabFile.add(btnExcelFile, gbc_btnExcelFile); btnClearFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/cancel.png"))); btnClearFile.setEnabled(false); GridBagConstraints gbc_btnLimparFile = new GridBagConstraints(); gbc_btnLimparFile.fill = GridBagConstraints.VERTICAL; gbc_btnLimparFile.insets = new Insets(0, 0, 5, 5); gbc_btnLimparFile.gridx = 10; gbc_btnLimparFile.gridy = 1; tabFile.add(btnClearFile, gbc_btnLimparFile); JLabel lblTamanho = new JLabel(Language.txtFileLength); GridBagConstraints gbc_lblTamanho = new GridBagConstraints(); gbc_lblTamanho.anchor = GridBagConstraints.WEST; gbc_lblTamanho.insets = new Insets(0, 0, 5, 5); gbc_lblTamanho.gridx = 1; gbc_lblTamanho.gridy = 2; tabFile.add(lblTamanho, gbc_lblTamanho); txtLength = new JTextField(); GridBagConstraints gbc_txtTamanho = new GridBagConstraints(); gbc_txtTamanho.fill = GridBagConstraints.HORIZONTAL; gbc_txtTamanho.insets = new Insets(0, 0, 5, 5); gbc_txtTamanho.gridx = 2; gbc_txtTamanho.gridy = 2; tabFile.add(txtLength, gbc_txtTamanho); txtLength.setColumns(10); JLabel label_1 = new JLabel(Language.txtOutput); GridBagConstraints gbc_label_1 = new GridBagConstraints(); gbc_label_1.anchor = GridBagConstraints.WEST; gbc_label_1.insets = new Insets(0, 0, 5, 5); gbc_label_1.gridx = 1; gbc_label_1.gridy = 3; tabFile.add(label_1, gbc_label_1); GridBagConstraints gbc_scrFile = new GridBagConstraints(); gbc_scrFile.gridheight = 3; gbc_scrFile.fill = GridBagConstraints.BOTH; gbc_scrFile.gridwidth = 10; gbc_scrFile.insets = new Insets(0, 0, 5, 5); gbc_scrFile.gridx = 1; gbc_scrFile.gridy = 4; tabFile.add(scrFile, gbc_scrFile); progressBar = new JProgressBar(); GridBagConstraints gbc_progressBar = new GridBagConstraints(); gbc_progressBar.fill = GridBagConstraints.HORIZONTAL; gbc_progressBar.gridwidth = 10; gbc_progressBar.insets = new Insets(0, 0, 0, 5); gbc_progressBar.gridx = 1; gbc_progressBar.gridy = 7; tabFile.add(progressBar, gbc_progressBar); JLabel lblNewLabel = new JLabel(Language.txtDeveloped + " Rodrigo Augusto Silva dos Santos - 2016"); GridBagConstraints gbc_lblNewLabel = new GridBagConstraints(); gbc_lblNewLabel.gridx = 0; gbc_lblNewLabel.gridy = 2; getContentPane().add(lblNewLabel, gbc_lblNewLabel); loadParameters(); }
From source file:SuitaDetails.java
public void showSuiteLib() { JScrollPane jScrollPane1 = new JScrollPane(); JList jList1 = new JList(); JPanel libraries = new JPanel(); jScrollPane1.setViewportView(jList1); GroupLayout layout = new GroupLayout(libraries); libraries.setLayout(layout);/* ww w .j a v a2 s.co m*/ layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)); try { Object[] s = (Object[]) RunnerRepository.getRPCClient().execute("getLibrariesList", new Object[] { RunnerRepository.user }); String[] libs = new String[s.length]; for (int i = 0; i < s.length; i++) { libs[i] = s[i].toString(); } ArrayList<Integer> ind = new ArrayList<Integer>(); jList1.setModel(new DefaultComboBoxModel(libs)); if (parent.getLibs() != null) { for (String st : parent.getLibs()) { for (int i = 0; i < libs.length; i++) { if (libs[i].equals(st)) { ind.add(new Integer(i)); } } } int[] indices = new int[ind.size()]; for (int i = 0; i < ind.size(); i++) { indices[i] = ind.get(i); } jList1.setSelectedIndices(indices); } } catch (Exception e) { System.out.println("There was an error on calling getLibrariesList on CE"); e.printStackTrace(); } int resp = (Integer) CustomDialog.showDialog(libraries, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, RunnerRepository.window, "Libraries", null); if (resp == JOptionPane.OK_OPTION) { Object[] val = jList1.getSelectedValues(); String[] libs = new String[val.length]; for (int s = 0; s < val.length; s++) { libs[s] = val[s].toString(); } parent.setLibs(libs); } }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
private void transitionListInitializations() { listTransition = new JList(); listTransition.setCellRenderer(new coloredMRMListRenderer()); listTransition.setModel(new DefaultListModel()); listTransition.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); _tlsl = new transitionListSelectionListener(); listTransition.addListSelectionListener(_tlsl); listTransition.addMouseWheelListener(new MouseWheelListener() { public void mouseWheelMoved(MouseWheelEvent event) { int move = event.getWheelRotation(); int curIndex = listTransition.getSelectedIndex(); int newIndex = curIndex; if (move > 0) { newIndex = Math.min(curIndex + move, listTransition.getModel().getSize()); listTransition.setSelectedIndex(newIndex); }/*from w w w . j a va 2 s . c o m*/ if (move < 0) { newIndex = Math.max(curIndex + move, 0); listTransition.setSelectedIndex(newIndex); } listTransition.ensureIndexIsVisible(newIndex); } }); for (MRMTransition curTran : _mrmTransitions) ((DefaultListModel) listTransition.getModel()).addElement(curTran); listTransition.setVisible(true); listScrollPane.getViewport().setView(listTransition); listScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); listScrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent ae) { if (!ae.getValueIsAdjusting()) { listTransition.repaint(); } } }); }
From source file:SuitaDetails.java
private void showLib() { JScrollPane jScrollPane1 = new JScrollPane(); JList jList1 = new JList(); JPanel libraries = new JPanel(); jScrollPane1.setViewportView(jList1); GroupLayout layout = new GroupLayout(libraries); libraries.setLayout(layout);//ww w .j av a2s . com layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)); try { Object[] s = (Object[]) RunnerRepository.getRPCClient().execute("getLibrariesList", new Object[] { RunnerRepository.user }); String[] libs = new String[s.length]; for (int i = 0; i < s.length; i++) { libs[i] = s[i].toString(); } ArrayList<Integer> ind = new ArrayList<Integer>(); jList1.setModel(new DefaultComboBoxModel(libs)); for (String st : globallib) { for (int i = 0; i < libs.length; i++) { if (libs[i].equals(st)) { ind.add(new Integer(i)); } } } int[] indices = new int[ind.size()]; for (int i = 0; i < ind.size(); i++) { indices[i] = ind.get(i); } jList1.setSelectedIndices(indices); } catch (Exception e) { System.out.println("There was an error on calling getLibrariesList on CE"); e.printStackTrace(); } int resp = (Integer) CustomDialog.showDialog(libraries, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, RunnerRepository.window, "Libraries", null); if (resp == JOptionPane.OK_OPTION) { Object[] val = jList1.getSelectedValues(); globallib = new String[val.length]; for (int s = 0; s < val.length; s++) { globallib[s] = val[s].toString(); } } }
From source file:ca.uhn.hl7v2.testpanel.ui.TestPanelWindow.java
/** * Initialize the contents of the frame. *///from w w w . j a v a 2s .com private void initialize() { myframe = new JFrame(); myframe.setVisible(false); List<Image> l = new ArrayList<Image>(); l.add(Toolkit.getDefaultToolkit() .getImage(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_16.png"))); l.add(Toolkit.getDefaultToolkit() .getImage(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_64.png"))); myframe.setIconImages(l); myframe.setTitle("HAPI TestPanel"); myframe.setBounds(100, 100, 796, 603); myframe.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); myframe.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent theE) { myController.close(); } }); JMenuBar menuBar = new JMenuBar(); myframe.setJMenuBar(menuBar); JMenu mnFile = new JMenu("File"); mnFile.setMnemonic('f'); menuBar.add(mnFile); JMenuItem mntmExit = new JMenuItem("Exit"); mntmExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { myController.close(); } }); JMenuItem mntmNewMessage = new JMenuItem("New Message..."); mntmNewMessage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.addMessage(); } }); mntmNewMessage.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/message_hl7.png"))); mnFile.add(mntmNewMessage); mySaveMenuItem = new JMenuItem("Save"); mySaveMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mySaveMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSaveMessages(); } }); mnFile.add(mySaveMenuItem); mySaveAsMenuItem = new JMenuItem("Save As..."); mySaveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSaveMessagesAs(); } }); mnFile.add(mySaveAsMenuItem); mymenuItem_3 = new JMenuItem("Open"); mymenuItem_3.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mymenuItem_3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.openMessages(); } }); myRevertToSavedMenuItem = new JMenuItem("Revert to Saved"); myRevertToSavedMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.revertMessage((Hl7V2MessageCollection) myController.getLeftSelectedItem()); } }); mnFile.add(myRevertToSavedMenuItem); mnFile.add(mymenuItem_3); myRecentFilesMenu = new JMenu("Open Recent"); mnFile.add(myRecentFilesMenu); JSeparator separator = new JSeparator(); mnFile.add(separator); mnFile.add(mntmExit); JMenu mnNewMenu = new JMenu("View"); mnNewMenu.setMnemonic('v'); menuBar.add(mnNewMenu); myShowLogConsoleMenuItem = new JMenuItem("Show Log Console"); myShowLogConsoleMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Prefs.getInstance().setShowLogConsole(!Prefs.getInstance().getShowLogConsole()); updateLogScrollPaneVisibility(); myframe.validate(); } }); mnNewMenu.add(myShowLogConsoleMenuItem); mymenu_1 = new JMenu("Test"); menuBar.add(mymenu_1); mymenuItem_1 = new JMenuItem("Populate TestPanel with Sample Message and Connections..."); mymenuItem_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.populateWithSampleMessageAndConnections(); } }); mymenu_1.add(mymenuItem_1); mymenu_3 = new JMenu("Tools"); menuBar.add(mymenu_3); mnHl7V2FileDiff = new JMenuItem("HL7 v2 File Diff..."); mnHl7V2FileDiff.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myHl7V2FileDiff == null) { myHl7V2FileDiff = new Hl7V2FileDiffController(myController); } myHl7V2FileDiff.show(); } }); mymenu_3.add(mnHl7V2FileDiff); mymenuItem_5 = new JMenuItem("HL7 v2 File Sort..."); mymenuItem_5.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myHl7V2FileSort == null) { myHl7V2FileSort = new Hl7V2FileSortController(myController); } myHl7V2FileSort.show(); } }); mymenu_3.add(mymenuItem_5); mymenu_2 = new JMenu("Conformance"); menuBar.add(mymenu_2); mymenuItem_2 = new JMenuItem("Profiles and Tables..."); mymenuItem_2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.showProfilesAndTablesEditor(); } }); mymenu_2.add(mymenuItem_2); mymenu = new JMenu("Help"); mymenu.setMnemonic('H'); menuBar.add(mymenu); mymenuItem = new JMenuItem("About HAPI TestPanel..."); mymenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showAboutDialog(); } }); mymenuItem.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_16.png"))); mymenu.add(mymenuItem); mymenuItem_4 = new JMenuItem("Licenses..."); mymenuItem_4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new LicensesDialog().setVisible(true); } }); mymenu.add(mymenuItem_4); myframe.getContentPane().setLayout(new BorderLayout(0, 0)); JSplitPane outerSplitPane = new JSplitPane(); outerSplitPane.setBorder(null); myframe.getContentPane().add(outerSplitPane); JSplitPane leftSplitPane = new JSplitPane(); leftSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); outerSplitPane.setLeftComponent(leftSplitPane); JPanel messagesPanel = new JPanel(); leftSplitPane.setLeftComponent(messagesPanel); GridBagLayout gbl_messagesPanel = new GridBagLayout(); gbl_messagesPanel.columnWidths = new int[] { 110, 0 }; gbl_messagesPanel.rowHeights = new int[] { 20, 30, 118, 0, 0 }; gbl_messagesPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_messagesPanel.rowWeights = new double[] { 0.0, 0.0, 100.0, 1.0, Double.MIN_VALUE }; messagesPanel.setLayout(gbl_messagesPanel); JLabel lblMessages = new JLabel("Messages"); GridBagConstraints gbc_lblMessages = new GridBagConstraints(); gbc_lblMessages.insets = new Insets(0, 0, 5, 0); gbc_lblMessages.gridx = 0; gbc_lblMessages.gridy = 0; messagesPanel.add(lblMessages, gbc_lblMessages); JToolBar messagesToolBar = new JToolBar(); messagesToolBar.setFloatable(false); messagesToolBar.setRollover(true); messagesToolBar.setAlignmentX(Component.LEFT_ALIGNMENT); GridBagConstraints gbc_messagesToolBar = new GridBagConstraints(); gbc_messagesToolBar.insets = new Insets(0, 0, 5, 0); gbc_messagesToolBar.weightx = 1.0; gbc_messagesToolBar.anchor = GridBagConstraints.NORTHWEST; gbc_messagesToolBar.gridx = 0; gbc_messagesToolBar.gridy = 1; messagesPanel.add(messagesToolBar, gbc_messagesToolBar); JButton msgOpenButton = new JButton(""); msgOpenButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.openMessages(); } }); myAddMessageButton = new JButton(""); myAddMessageButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.addMessage(); } }); myAddMessageButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/add.png"))); myAddMessageButton.setToolTipText("New Message"); myAddMessageButton.setBorderPainted(false); myAddMessageButton.addMouseListener(new HoverButtonMouseAdapter(myAddMessageButton)); messagesToolBar.add(myAddMessageButton); myDeleteMessageButton = new JButton(""); myDeleteMessageButton.setToolTipText("Close Selected Message"); myDeleteMessageButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.closeMessage((Hl7V2MessageCollection) myController.getLeftSelectedItem()); } }); myDeleteMessageButton.setBorderPainted(false); myDeleteMessageButton.addMouseListener(new HoverButtonMouseAdapter(myDeleteMessageButton)); myDeleteMessageButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/close.png"))); messagesToolBar.add(myDeleteMessageButton); msgOpenButton.setBorderPainted(false); msgOpenButton.setToolTipText("Open Messages from File"); msgOpenButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/open.png"))); msgOpenButton.addMouseListener(new HoverButtonMouseAdapter(msgOpenButton)); messagesToolBar.add(msgOpenButton); myMsgSaveButton = new JButton(""); myMsgSaveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSaveMessages(); } }); myMsgSaveButton.setBorderPainted(false); myMsgSaveButton.setToolTipText("Save Selected Messages to File"); myMsgSaveButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/save.png"))); myMsgSaveButton.addMouseListener(new HoverButtonMouseAdapter(myMsgSaveButton)); messagesToolBar.add(myMsgSaveButton); myMessagesList = new JList(); myMessagesList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (myMessagesList.getSelectedIndex() >= 0) { ourLog.debug("New messages selection " + myMessagesList.getSelectedIndex()); myController.setLeftSelectedItem(myMessagesList.getSelectedValue()); myOutboundConnectionsList.clearSelection(); myOutboundConnectionsList.repaint(); myInboundConnectionsList.clearSelection(); myInboundConnectionsList.repaint(); } updateLeftToolbarButtons(); } }); GridBagConstraints gbc_MessagesList = new GridBagConstraints(); gbc_MessagesList.gridheight = 2; gbc_MessagesList.weightx = 1.0; gbc_MessagesList.weighty = 1.0; gbc_MessagesList.fill = GridBagConstraints.BOTH; gbc_MessagesList.gridx = 0; gbc_MessagesList.gridy = 2; messagesPanel.add(myMessagesList, gbc_MessagesList); JPanel connectionsPanel = new JPanel(); leftSplitPane.setRightComponent(connectionsPanel); GridBagLayout gbl_connectionsPanel = new GridBagLayout(); gbl_connectionsPanel.columnWidths = new int[] { 194, 0 }; gbl_connectionsPanel.rowHeights = new int[] { 0, 30, 0, 0, 0, 0, 0 }; gbl_connectionsPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_connectionsPanel.rowWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, Double.MIN_VALUE }; connectionsPanel.setLayout(gbl_connectionsPanel); JLabel lblConnections = new JLabel("Sending Connections"); lblConnections.setHorizontalAlignment(SwingConstants.CENTER); GridBagConstraints gbc_lblConnections = new GridBagConstraints(); gbc_lblConnections.insets = new Insets(0, 0, 5, 0); gbc_lblConnections.anchor = GridBagConstraints.NORTH; gbc_lblConnections.fill = GridBagConstraints.HORIZONTAL; gbc_lblConnections.gridx = 0; gbc_lblConnections.gridy = 0; connectionsPanel.add(lblConnections, gbc_lblConnections); JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); GridBagConstraints gbc_toolBar = new GridBagConstraints(); gbc_toolBar.insets = new Insets(0, 0, 5, 0); gbc_toolBar.anchor = GridBagConstraints.NORTH; gbc_toolBar.fill = GridBagConstraints.HORIZONTAL; gbc_toolBar.gridx = 0; gbc_toolBar.gridy = 1; connectionsPanel.add(toolBar, gbc_toolBar); myAddConnectionButton = new JButton(""); myAddConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.addOutboundConnection(); } }); myAddConnectionButton.setBorderPainted(false); myAddConnectionButton.addMouseListener(new HoverButtonMouseAdapter(myAddConnectionButton)); myAddConnectionButton.setBorder(null); myAddConnectionButton.setToolTipText("New Connection"); myAddConnectionButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/add.png"))); toolBar.add(myAddConnectionButton); myDeleteOutboundConnectionButton = new JButton(""); myDeleteOutboundConnectionButton.setToolTipText("Delete Selected Connection"); myDeleteOutboundConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myController.getLeftSelectedItem() instanceof OutboundConnection) { myController.removeOutboundConnection((OutboundConnection) myController.getLeftSelectedItem()); } } }); myDeleteOutboundConnectionButton.setBorderPainted(false); myDeleteOutboundConnectionButton .addMouseListener(new HoverButtonMouseAdapter(myDeleteOutboundConnectionButton)); myDeleteOutboundConnectionButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/delete.png"))); toolBar.add(myDeleteOutboundConnectionButton); myStartOneOutboundButton = new JButton(""); myStartOneOutboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myController.getLeftSelectedItem() instanceof OutboundConnection) { myController.startOutboundConnection((OutboundConnection) myController.getLeftSelectedItem()); } } }); myStartOneOutboundButton.setBorderPainted(false); myStartOneOutboundButton.setToolTipText("Start selected connection"); myStartOneOutboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_one.png"))); myStartOneOutboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartOneOutboundButton)); toolBar.add(myStartOneOutboundButton); myStartAllOutboundButton = new JButton(""); myStartAllOutboundButton.setBorderPainted(false); myStartAllOutboundButton.setToolTipText("Start all sending connections"); myStartAllOutboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_all.png"))); myStartAllOutboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartAllOutboundButton)); myStartAllOutboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent theE) { myController.startAllOutboundConnections(); } }); toolBar.add(myStartAllOutboundButton); myStopAllOutboundButton = new JButton(""); myStopAllOutboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.stopAllOutboundConnections(); } }); myStopAllOutboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/stop_all.png"))); myStopAllOutboundButton.setToolTipText("Stop all sending connections"); myStopAllOutboundButton.setBorderPainted(false); myStopAllOutboundButton.addMouseListener(new HoverButtonMouseAdapter(myStopAllOutboundButton)); toolBar.add(myStopAllOutboundButton); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBorder(null); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.insets = new Insets(0, 0, 5, 0); gbc_scrollPane.gridx = 0; gbc_scrollPane.gridy = 2; connectionsPanel.add(scrollPane, gbc_scrollPane); myOutboundConnectionsList = new JList(); myOutboundConnectionsList.setBorder(null); myOutboundConnectionsList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (myOutboundConnectionsList.getSelectedIndex() >= 0) { ourLog.debug( "New outbound connection selection " + myOutboundConnectionsList.getSelectedIndex()); myController.setLeftSelectedItem(myOutboundConnectionsList.getSelectedValue()); myMessagesList.clearSelection(); myMessagesList.repaint(); myInboundConnectionsList.clearSelection(); myInboundConnectionsList.repaint(); } updateLeftToolbarButtons(); } }); scrollPane.setViewportView(myOutboundConnectionsList); JLabel lblReceivingConnections = new JLabel("Receiving Connections"); lblReceivingConnections.setHorizontalAlignment(SwingConstants.CENTER); GridBagConstraints gbc_lblReceivingConnections = new GridBagConstraints(); gbc_lblReceivingConnections.insets = new Insets(0, 0, 5, 0); gbc_lblReceivingConnections.gridx = 0; gbc_lblReceivingConnections.gridy = 3; connectionsPanel.add(lblReceivingConnections, gbc_lblReceivingConnections); JToolBar toolBar_1 = new JToolBar(); toolBar_1.setFloatable(false); GridBagConstraints gbc_toolBar_1 = new GridBagConstraints(); gbc_toolBar_1.anchor = GridBagConstraints.WEST; gbc_toolBar_1.insets = new Insets(0, 0, 5, 0); gbc_toolBar_1.gridx = 0; gbc_toolBar_1.gridy = 4; connectionsPanel.add(toolBar_1, gbc_toolBar_1); myAddInboundConnectionButton = new JButton(""); myAddInboundConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.addInboundConnection(); } }); myAddInboundConnectionButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/add.png"))); myAddInboundConnectionButton.setToolTipText("New Connection"); myAddInboundConnectionButton.setBorderPainted(false); myAddInboundConnectionButton.addMouseListener(new HoverButtonMouseAdapter(myAddInboundConnectionButton)); toolBar_1.add(myAddInboundConnectionButton); myDeleteInboundConnectionButton = new JButton(""); myDeleteInboundConnectionButton.setToolTipText("Delete Selected Connection"); myDeleteInboundConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myController.getLeftSelectedItem() instanceof InboundConnection) { myController.removeInboundConnection((InboundConnection) myController.getLeftSelectedItem()); } } }); myDeleteInboundConnectionButton.setBorderPainted(false); myDeleteInboundConnectionButton .addMouseListener(new HoverButtonMouseAdapter(myDeleteInboundConnectionButton)); myDeleteInboundConnectionButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/delete.png"))); toolBar_1.add(myDeleteInboundConnectionButton); myStartOneInboundButton = new JButton(""); myStartOneInboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myController.getLeftSelectedItem() instanceof InboundConnection) { myController.startInboundConnection((InboundConnection) myController.getLeftSelectedItem()); } } }); myStartOneInboundButton.setBorderPainted(false); myStartOneInboundButton.setToolTipText("Start selected connection"); myStartOneInboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_one.png"))); myStartOneInboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartOneInboundButton)); toolBar_1.add(myStartOneInboundButton); myStartAllInboundButton = new JButton(""); myStartAllInboundButton.setBorderPainted(false); myStartAllInboundButton.setToolTipText("Start all receiving connections"); myStartAllInboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_all.png"))); myStartAllInboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartAllInboundButton)); myStartAllInboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent theE) { myController.startAllInboundConnections(); } }); toolBar_1.add(myStartAllInboundButton); myStopAllInboundButton = new JButton(""); myStopAllInboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.stopAllInboundConnections(); } }); myStopAllInboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/stop_all.png"))); myStopAllInboundButton.setToolTipText("Stop all receiving connections"); myStopAllInboundButton.setBorderPainted(false); myStopAllInboundButton.addMouseListener(new HoverButtonMouseAdapter(myStopAllInboundButton)); toolBar_1.add(myStopAllInboundButton); JScrollPane scrollPane_1 = new JScrollPane(); scrollPane_1.setBorder(null); GridBagConstraints gbc_scrollPane_1 = new GridBagConstraints(); gbc_scrollPane_1.fill = GridBagConstraints.BOTH; gbc_scrollPane_1.gridx = 0; gbc_scrollPane_1.gridy = 5; connectionsPanel.add(scrollPane_1, gbc_scrollPane_1); myInboundConnectionsList = new JList(); myInboundConnectionsList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (myInboundConnectionsList.getSelectedIndex() >= 0) { ourLog.debug("New inbound connection selection " + myInboundConnectionsList.getSelectedIndex()); myController.setLeftSelectedItem(myInboundConnectionsList.getSelectedValue()); myMessagesList.clearSelection(); myMessagesList.repaint(); myOutboundConnectionsList.clearSelection(); myOutboundConnectionsList.repaint(); myInboundConnectionsList.repaint(); } updateLeftToolbarButtons(); } }); scrollPane_1.setViewportView(myInboundConnectionsList); leftSplitPane.setDividerLocation(200); myWorkspacePanel = new JPanel(); myWorkspacePanel.setBorder(null); outerSplitPane.setRightComponent(myWorkspacePanel); myWorkspacePanel.setLayout(new BorderLayout(0, 0)); outerSplitPane.setDividerLocation(200); myLogScrollPane = new LogTable(); myLogScrollPane.setPreferredSize(new Dimension(454, 120)); myLogScrollPane.setMaximumSize(new Dimension(32767, 120)); myframe.getContentPane().add(myLogScrollPane, BorderLayout.SOUTH); updateLogScrollPaneVisibility(); updateLeftToolbarButtons(); }