List of usage examples for javax.swing JMenuItem JMenuItem
public JMenuItem()
JMenuItem
with no set text or icon. From source file:gtu._work.ui.PropertyEditUI.java
private void initGUI() { try {/*from ww w. j a va2s. c o m*/ setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); BorderLayout thisLayout = new BorderLayout(); this.setTitle("PropertyEditUI"); getContentPane().setLayout(thisLayout); { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu1 = new JMenu(); jMenuBar1.add(jMenu1); jMenu1.setText("File"); { jMenuItem1 = new JMenuItem(); jMenu1.add(jMenuItem1); jMenuItem1.setText("open directory"); jMenuItem1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JCommonUtil._jFileChooser_selectDirectoryOnly(); loadCurrentFile(file); } }); } { openDirectoryAndChildren = new JMenuItem(); jMenu1.add(openDirectoryAndChildren); openDirectoryAndChildren.setText("open directory and children"); openDirectoryAndChildren.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out.println("openDirectoryAndChildren.actionPerformed, event=" + evt); File file = JCommonUtil._jFileChooser_selectDirectoryOnly(); if (file == null) { // file = // PropertiesUtil.getJarCurrentPath(getClass());//XXX file = new File("D:\\my_tool\\english"); JCommonUtil._jOptionPane_showMessageDialog_info("load C:\\L-CONFIG !"); } DefaultListModel model = new DefaultListModel(); List<File> list = new ArrayList<File>(); FileUtil.searchFileMatchs(file, ".*\\.properties", list); for (File f : list) { File_ ff = new File_(); ff.file = f; model.addElement(ff); } backupFileList = list; fileList.setModel(model); } }); } { jMenuItem2 = new JMenuItem(); jMenu1.add(jMenuItem2); jMenuItem2.setText("save"); jMenuItem2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out.println("jMenu3.actionPerformed, event=" + evt); if (currentFile == null) { return; } if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption( "save to " + currentFile.getName(), "SAVE")) { try { Properties prop = new Properties(); // try { // prop.load(new // FileInputStream(currentFile)); // } catch (Exception e) { // e.printStackTrace(); // JCommonUtil.handleException(e); // return; // } loadModelToProperties(prop); prop.store(new FileOutputStream(currentFile), getTitle()); } catch (Exception e) { e.printStackTrace(); JCommonUtil.handleException(e); } } } }); } { jMenuItem3 = new JMenuItem(); jMenu1.add(jMenuItem3); jMenuItem3.setText("save to target"); jMenuItem3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JFileChooserUtil.newInstance().selectFileOnly().showSaveDialog() .getApproveSelectedFile(); if (file == null) { JCommonUtil._jOptionPane_showMessageDialog_error("file name is not correct!"); return; } if (!file.getName().contains(".properties")) { file = new File(file.getParent(), file.getName() + ".properties"); } try { Properties prop = new Properties(); // try { // prop.load(new // FileInputStream(currentFile)); // } catch (Exception e) { // e.printStackTrace(); // JCommonUtil.handleException(e); // return; // } loadModelToProperties(prop); prop.store(new FileOutputStream(file), getTitle()); } catch (Exception e) { e.printStackTrace(); JCommonUtil.handleException(e); } } }); } { jMenuItem4 = new JMenuItem(); jMenu1.add(jMenuItem4); jMenuItem4.setText("save file(sorted)"); jMenuItem4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (currentFile == null) { return; } try { BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(currentFile))); List<String> sortList = new ArrayList<String>(); for (String line = null; (line = reader.readLine()) != null;) { sortList.add(line); } reader.close(); Collections.sort(sortList); StringBuilder sb = new StringBuilder(); for (String line : sortList) { sb.append(line + "\n"); } FileUtil.saveToFile(currentFile, sb.toString(), "UTF8"); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }); } { jMenuItem5 = new JMenuItem(); jMenu1.add(jMenuItem5); jMenuItem5.setText(""); jMenuItem5.addActionListener(new ActionListener() { private void setMeaning(String meaning, int rowPos) { propTable.getRowSorter().getModel().setValueAt(meaning, rowPos, 2); } private void setMeaningEn1(String english, int rowPos, List<String> errSb) { EnglishTester_Diectory eng = new EnglishTester_Diectory(); try { WordInfo wordInfo = eng.parseToWordInfo(english); String meaning = getChs2Big5(wordInfo.getMeaning()); if (hasChinese(meaning)) { setMeaning(meaning, rowPos); } else { setMeaningEn2(english, rowPos, errSb); } } catch (Exception e) { errSb.add(english); e.printStackTrace(); } } private void setMeaningEn2(String english, int rowPos, List<String> errSb) { EnglishTester_Diectory2 eng2 = new EnglishTester_Diectory2(); try { WordInfo2 wordInfo = eng2.parseToWordInfo(english); String meaning = getChs2Big5(StringUtils.join(wordInfo.getMeaningList(), ";")); setMeaning(meaning, rowPos); } catch (Exception e) { errSb.add(english); e.printStackTrace(); } } private boolean hasChinese(String val) { return new StringUtil_().getChineseWord(val, true).length() > 0; } private Properties loadFromMemoryBank() { try { Properties prop = new Properties(); File f1 = new File( "D:/gtu001_dropbox/Dropbox/Apps/gtu001_test/etc_config/EnglishSearchUI_MemoryBank.properties"); File f2 = new File( "e:/gtu001_dropbox/Dropbox/Apps/gtu001_test/etc_config/EnglishSearchUI_MemoryBank.properties"); for (File f : new File[] { f1, f2 }) { if (f.exists()) { HermannEbbinghaus_Memory memory = new HermannEbbinghaus_Memory(); memory.init(f); List<MemData> memLst = memory.getAllMemData(true); for (MemData d : memLst) { prop.setProperty(d.getKey(), getChs2Big5(d.getRemark())); } break; } } return prop; } catch (Exception ex) { throw new RuntimeException(ex); } } public void actionPerformed(ActionEvent evt) { if (currentFile == null) { return; } // Properties memoryProp = loadFromMemoryBank(); Properties memoryProp = new Properties(); List<String> errSb = new ArrayList<String>(); for (int row = 0; row < propTable.getModel().getRowCount(); row++) { int rowPos = propTable.getRowSorter().convertRowIndexToModel(row); String english = StringUtils.trimToEmpty( (String) propTable.getRowSorter().getModel().getValueAt(rowPos, 1)) .toLowerCase(); String desc = (String) propTable.getRowSorter().getModel().getValueAt(rowPos, 2); if (memoryProp.containsKey(english) && StringUtils.isNotBlank(memoryProp.getProperty(english))) { setMeaning(memoryProp.getProperty(english), rowPos); } else { if (StringUtils.isBlank(desc) || !hasChinese(desc)) { if (!english.contains(" ")) { setMeaningEn1(english, rowPos, errSb); } else { setMeaningEn2(english, rowPos, errSb); } } } if (StringUtils.trimToEmpty(desc).contains("?")) { setMeaning("", rowPos); } } if (!errSb.isEmpty()) { JCommonUtil._jOptionPane_showMessageDialog_error(":\n" + errSb); } } }); } { JMenuItem jMenuItem6 = new JMenuItem(); jMenu1.add(jMenuItem6); jMenuItem6.setText(""); jMenuItem6.addActionListener(new ActionListener() { private void setMeaning(String meaning, int rowPos) { propTable.getRowSorter().getModel().setValueAt(meaning, rowPos, 2); } public void actionPerformed(ActionEvent evt) { for (int row = 0; row < propTable.getModel().getRowCount(); row++) { int rowPos = propTable.getRowSorter().convertRowIndexToModel(row); String english = StringUtils.trimToEmpty( (String) propTable.getRowSorter().getModel().getValueAt(rowPos, 1)) .toLowerCase(); String desc = (String) propTable.getRowSorter().getModel().getValueAt(rowPos, 2); if (StringUtils.trimToEmpty(desc).contains("?")) { setMeaning("", rowPos); } } } }); } } } { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("editor", null, jPanel2, null); { jScrollPane1 = new JScrollPane(); jPanel2.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(550, 314)); { TableModel propTableModel = new DefaultTableModel( new String[][] { { "", "", "" }, { "", "", "" } }, new String[] { "index", "Key", "value" }); propTable = new JTable(); JTableUtil.defaultSetting_AutoResize(propTable); jScrollPane1.setViewportView(propTable); propTable.setModel(propTableModel); propTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { JTableUtil xxxxxx = JTableUtil.newInstance(propTable); int[] rows = xxxxxx.getSelectedRows(); for (int ii : rows) { System.out.println(xxxxxx.getModel().getValueAt(ii, 1)); } JPopupMenuUtil.newInstance(propTable).applyEvent(evt) .addJMenuItem(JTableUtil.newInstance(propTable).getDefaultJMenuItems()) .show(); } }); } } { queryText = new JTextField(); jPanel2.add(queryText, BorderLayout.NORTH); queryText.getDocument() .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() { @Override public void process(DocumentEvent event) { if (currentFile == null) { return; } Properties prop = new Properties(); try { prop.load(new FileInputStream(currentFile)); } catch (Exception e) { e.printStackTrace(); JCommonUtil.handleException(e); return; } loadPropertiesToModel(prop); String text = JCommonUtil.getDocumentText(event); Pattern pattern = null; try { pattern = Pattern.compile(text); } catch (Exception ex) { } DefaultTableModel model = JTableUtil.newInstance(propTable).getModel(); for (int ii = 0; ii < model.getRowCount(); ii++) { String key = (String) model.getValueAt(ii, 1); String value = (String) model.getValueAt(ii, 2); if (key.contains(text)) { continue; } if (value.contains(text)) { continue; } if (pattern != null) { if (pattern.matcher(key).find()) { continue; } if (pattern.matcher(value).find()) { continue; } } model.removeRow(propTable.convertRowIndexToModel(ii)); ii--; } } })); } } { jPanel3 = new JPanel(); BorderLayout jPanel3Layout = new BorderLayout(); jPanel3.setLayout(jPanel3Layout); jTabbedPane1.addTab("folder", null, jPanel3, null); { jScrollPane2 = new JScrollPane(); jPanel3.add(jScrollPane2, BorderLayout.CENTER); jScrollPane2.setPreferredSize(new java.awt.Dimension(550, 314)); { fileList = new JList(); jScrollPane2.setViewportView(fileList); fileList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(fileList).defaultJListKeyPressed(evt); } }); fileList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { final File_ file = JListUtil.getLeadSelectionObject(fileList); if (evt.getButton() == MouseEvent.BUTTON1) { Properties prop = new Properties(); currentFile = file.file; setTitle(currentFile.getName()); try { prop.load(new FileInputStream(file.file)); } catch (Exception e) { e.printStackTrace(); } loadPropertiesToModel(prop); } if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 2) { try { Runtime.getRuntime().exec(String.format("cmd /c \"%s\"", file.file)); } catch (IOException e1) { e1.printStackTrace(); } } final File parent = file.file.getParentFile(); JMenuItem openTargetDir = new JMenuItem(); openTargetDir.setText("open : " + parent); openTargetDir.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Desktop.getDesktop().open(parent); } catch (IOException e1) { JCommonUtil.handleException(e1); } } }); JPopupMenuUtil.newInstance(fileList).addJMenuItem(openTargetDir).applyEvent(evt) .show(); } }); } } { fileQueryText = new JTextField(); jPanel3.add(fileQueryText, BorderLayout.NORTH); fileQueryText.getDocument() .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() { @Override public void process(DocumentEvent event) { String text = JCommonUtil.getDocumentText(event); DefaultListModel model = new DefaultListModel(); for (File f : backupFileList) { if (f.getName().contains(text)) { File_ ff = new File_(); ff.file = f; model.addElement(ff); } } fileList.setModel(model); } })); } { contentQueryText = new JTextField(); jPanel3.add(contentQueryText, BorderLayout.SOUTH); contentQueryText.addActionListener(new ActionListener() { void addModel(File f, DefaultListModel model) { File_ ff = new File_(); ff.file = f; model.addElement(ff); } public void actionPerformed(ActionEvent evt) { DefaultListModel model = new DefaultListModel(); String text = contentQueryText.getText(); if (StringUtils.isEmpty(contentQueryText.getText())) { return; } Pattern pattern = Pattern.compile(text); Properties pp = null; for (File f : backupFileList) { pp = new Properties(); try { pp.load(new FileInputStream(f)); for (String key : pp.stringPropertyNames()) { if (key.isEmpty()) { continue; } if (pp.getProperty(key) == null || pp.getProperty(key).isEmpty()) { continue; } if (key.contains(text)) { addModel(f, model); break; } if (pp.getProperty(key).contains(text)) { addModel(f, model); break; } if (pattern.matcher(key).find()) { addModel(f, model); break; } if (pattern.matcher(pp.getProperty(key)).find()) { addModel(f, model); break; } } } catch (Exception e) { e.printStackTrace(); } } fileList.setModel(model); } }); } } } JCommonUtil.setJFrameIcon(this, "resource/images/ico/english.ico"); JCommonUtil.setJFrameCenter(this); pack(); this.setSize(571, 408); loadCurrentFile(null); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.sec.ose.osi.ui.frm.main.JMenuMain.java
private JMenuItem getJMenuItemStopIdentificationThread() { if (jMenuItemStopSendingIdentificationThread == null) { jMenuItemStopSendingIdentificationThread = new JMenuItem(); jMenuItemStopSendingIdentificationThread.setText("Stop Sending Identification Thread"); jMenuItemStopSendingIdentificationThread.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { log.debug("jMenuItemStopSendingIdentificationThread actionPerformed()"); mEventHandler.handle(EventHandler.MAN_TOOL_STOP_IDENTIFICATION_THREAD); }//from ww w . j ava 2 s . co m }); } return jMenuItemStopSendingIdentificationThread; }
From source file:com.jidesoft.spring.richclient.docking.JideApplicationLifecycleAdvisor.java
@Override public void onPostStartup() { initializeRepaintManager();// ww w. ja v a2s . c o m if (devOption == false) { JMenuBar menuBar = Application.instance().getActiveWindow().getControl().getJMenuBar(); for (int i = 0; i < menuBar.getMenuCount(); i++) { //TODO:I18N if (menuBar.getMenu(i).getText().equals("Admin")) { menuBar.getMenu(i).setVisible(false); } } } JMenuBar menuBar = Application.instance().getActiveWindow().getControl().getJMenuBar(); for (int i = 0; i < menuBar.getMenuCount(); i++) { // recent games //TODO: I18N if (menuBar.getMenu(i).getText().equals("Game")) { for (int j = 0; j < menuBar.getMenu(i).getItemCount(); j++) { if (menuBar.getMenu(i).getItem(j) != null && menuBar.getMenu(i).getItem(j).getText() != null && menuBar.getMenu(i).getItem(j).getText().equals("Recent Games")) { JMenu menu = (JMenu) menuBar.getMenu(i).getItem(j); RecentGames rg = new RecentGames(); ArrayList<RecentGames.RecentGameInfo> rgis = rg.getRecentGameInfo(); for (RecentGameInfo rgi : rgis) { final RecentGameInfo frgi = rgi; JMenuItem mu = new JMenuItem(); mu.setText("Game " + String.valueOf(rgi.getNumber())); mu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { LoadGame loadGame = new LoadGame(frgi.getFile()); loadGame.execute(); } }); menu.add(mu); } } } } // user guide //TODO:I18N if (menuBar.getMenu(i).getText().equals("Help")) { try { final File f = new File("JOverseerUserGuide.pdf"); if (f.exists()) { //TODO:I18N JMenuItem mi = new JMenuItem("User's Guide"); mi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Runtime.getRuntime() .exec("rundll32 url.dll,FileProtocolHandler " + f.getAbsolutePath()); } catch (Exception exc) { // do nothing } } }); menuBar.getMenu(i).add(new JSeparator()); menuBar.getMenu(i).add(mi); } } catch (Exception exc) { // do nothing } } } if (JOverseerJIDEClient.cmdLineArgs != null && JOverseerJIDEClient.cmdLineArgs.length == 1 && JOverseerJIDEClient.cmdLineArgs[0].endsWith(".jov")) { String fname = JOverseerJIDEClient.cmdLineArgs[0]; File f = new File(fname); if (f.exists()) { LoadGame lg = new LoadGame(fname); lg.loadGame(); } } }
From source file:fedroot.dacs.swingdemo.DacsSingleFrameApplication.java
private JMenu createMenu(String menuName, String[] actionNames) { JMenu menu = new JMenu(); menu.setName(menuName);/*from w w w . jav a 2s. c om*/ for (String actionName : actionNames) { JMenuItem menuItem = new JMenuItem(); menuItem.setAction(actionMap().get(actionName)); menu.add(menuItem); } return menu; }
From source file:com.sec.ose.osi.ui.frm.main.JMenuMain.java
private JMenuItem getJMenuItemProxyServer() { if (jMenuItemProxyServer == null) { jMenuItemProxyServer = new JMenuItem(); jMenuItemProxyServer.setText("Proxy"); jMenuItemProxyServer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { log.debug("jMenuItemProxyServer actionPerformed()"); mEventHandler.handle(EventHandler.MAN_SETTING_PROXY_SERVER); }//from w w w . j a va2s. c o m }); } return jMenuItemProxyServer; }
From source file:gtu._work.ui.SvnLastestCommitInfoUI.java
private void initGUI() { try {/*from w w w . j a v a 2 s .c o m*/ BorderLayout thisLayout = new BorderLayout(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(thisLayout); this.setFocusable(false); this.setTitle("SVN lastest commit wather"); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("svn dir", null, jPanel1, null); { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); { TableModel svnTableModel = new DefaultTableModel(); svnTable = new JTable(); jScrollPane1.setViewportView(svnTable); svnTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { try { if (evt.getButton() == 3) { final List<File> list = new ArrayList<File>(); SvnFile svnFile = null; final StringBuilder sb = new StringBuilder(); for (int row : svnTable.getSelectedRows()) { svnFile = (SvnFile) svnTable.getModel().getValueAt( svnTable.getRowSorter().convertRowIndexToModel(row), SvnTableColumn.SVN_FILE.pos); list.add(svnFile.file); sb.append(svnFile.file.getName() + ","); } if (sb.length() > 200) { sb.delete(200, sb.length() - 1); } JMenuItem copySelectedMeun = new JMenuItem(); copySelectedMeun.setText("copy selected file : " + list.size()); copySelectedMeun.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION != JOptionPaneUtil .newInstance().iconPlainMessage().confirmButtonYesNo() .showConfirmDialog( "are you sure copy files :\n" + sb + "\n???", "COPY SELECTED FILE : " + list.size())) { return; } final File copyToDir = JFileChooserUtil.newInstance() .selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); if (copyToDir == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("dir folder is not correct!", "ERROR"); return; } new Thread(Thread.currentThread().getThreadGroup(), new Runnable() { public void run() { StringBuilder errMsg = new StringBuilder(); int errCount = 0; for (File f : list) { try { FileUtil.copyFile(f, new File(copyToDir, f.getName())); } catch (IOException e) { e.printStackTrace(); errCount++; errMsg.append(f + "\n"); } } JOptionPaneUtil.newInstance().iconPlainMessage() .showMessageDialog( "copy completed!\nerror : " + errCount + "\nerror list : \n" + errMsg, "COMPLETED"); } }, "copySelectedFiles_" + hashCode()).start(); } }); JMenuItem copySelectedOringTreeMeun = new JMenuItem(); copySelectedOringTreeMeun .setText("copy selected file (orign tree): " + list.size()); copySelectedOringTreeMeun.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION != JOptionPaneUtil .newInstance().iconPlainMessage().confirmButtonYesNo() .showConfirmDialog( "are you sure copy files :\n" + sb + "\n???", "COPY SELECTED FILE : " + list.size())) { return; } final File copyToDir = JFileChooserUtil.newInstance() .selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); if (copyToDir == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("dir folder is not correct!", "ERROR"); return; } new Thread(Thread.currentThread().getThreadGroup(), new Runnable() { public void run() { File srcBaseDir = FileUtil .exportReceiveBaseDir(list); int cutLength = 0; if (srcBaseDir != null) { cutLength = srcBaseDir.getAbsolutePath() .length(); } StringBuilder errMsg = new StringBuilder(); int errCount = 0; File newFile = null; for (File f : list) { try { newFile = new File(copyToDir + "/" + f.getAbsolutePath() .substring(cutLength), f.getName()); newFile.getParentFile().mkdirs(); FileUtil.copyFile(f, newFile); } catch (IOException e) { e.printStackTrace(); errCount++; errMsg.append(f + "\n"); } } JOptionPaneUtil.newInstance().iconPlainMessage() .showMessageDialog( "copy completed!\nerror : " + errCount + "\nerror list : \n" + errMsg, "COMPLETED"); } }, "copySelectedFiles_orignTree_" + hashCode()).start(); } }); JPopupMenuUtil.newInstance(svnTable).applyEvent(evt) .addJMenuItem(copySelectedMeun, copySelectedOringTreeMeun) .show(); } if (!JMouseEventUtil.buttonLeftClick(2, evt)) { return; } int row = JTableUtil.newInstance(svnTable).getSelectedRow(); SvnFile svnFile = (SvnFile) svnTable.getModel().getValueAt(row, SvnTableColumn.SVN_FILE.pos); String command = String.format("cmd /c call \"%s\"", svnFile.file); System.out.println(command); try { Runtime.getRuntime().exec(command); } catch (IOException e) { e.printStackTrace(); } } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); svnTable.setModel(svnTableModel); JTableUtil.defaultSetting(svnTable); } } { jPanel3 = new JPanel(); jPanel1.add(jPanel3, BorderLayout.NORTH); jPanel3.setPreferredSize(new java.awt.Dimension(379, 35)); { filterText = new JTextField(); jPanel3.add(filterText); filterText.setPreferredSize(new java.awt.Dimension(258, 24)); filterText.getDocument() .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() { public void process(DocumentEvent event) { try { String scanText = JCommonUtil.getDocumentText(event); reloadSvnTable(scanText, _defaultScanProcess); } catch (Exception ex) { JCommonUtil.handleException(ex); } } })); } { choiceSvnDir = new JButton(); jPanel3.add(choiceSvnDir); choiceSvnDir.setText("choice svn dir"); choiceSvnDir.setPreferredSize(new java.awt.Dimension(154, 24)); choiceSvnDir.addActionListener(new ActionListener() { Pattern svnOutputPattern = Pattern .compile("\\s*(\\d*)\\s+(\\d+)\\s+(\\w+)\\s+([\\S]+)"); public void actionPerformed(ActionEvent evt) { try { System.out.println("choiceSvnDir.actionPerformed, event=" + evt); final File svnDir = JFileChooserUtil.newInstance().selectDirectoryOnly() .showOpenDialog().getApproveSelectedFile(); if (svnDir == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("dir is not correct!", "ERROR"); return; } Thread thread = new Thread(Thread.currentThread().getThreadGroup(), new Runnable() { public void run() { long startTime = System.currentTimeMillis(); String command = String .format("cmd /c svn status -v \"%s\"", svnDir); Matcher matcher = null; try { long projectLastestVersion = 0; SvnFile svnFile = null; Process process = Runtime.getRuntime().exec(command); BufferedReader reader = new BufferedReader( new InputStreamReader(process.getInputStream(), "BIG5")); for (String line = null; (line = reader .readLine()) != null;) { matcher = svnOutputPattern.matcher(line); if (matcher.find()) { try { if (StringUtils .isNotBlank(matcher.group(1))) { projectLastestVersion = Math.max( projectLastestVersion, Long.parseLong( matcher.group(1))); } svnFile = new SvnFile(); svnFile.lastestVersion = Long .parseLong(matcher.group(2)); svnFile.author = matcher.group(3); svnFile.filePath = matcher.group(4); svnFile.file = new File(svnFile.filePath); svnFile.fileName = svnFile.file.getName(); svnFileSet.add(svnFile); authorSet.add(svnFile.author); String extension = null; if (svnFile.file.isFile() && (extension = getExtension( svnFile.fileName)) != null) { fileExtenstionSet.add(extension); } } catch (Exception ex) { ex.printStackTrace(); } } else { System.out.println("ignore : " + line); } } reader.close(); lastestVersion = projectLastestVersion; projectName = svnDir.getName(); resetUiAndShowMessage(startTime, projectName, projectLastestVersion); } catch (IOException e) { JCommonUtil.handleException(e); } } }, "loadSvnLastest_" + this.hashCode()); thread.setDaemon(true); thread.start(); setTitle("sweeping..."); } catch (Exception ex) { JCommonUtil.handleException(ex); } } String getExtension(String name) { int pos = -1; if ((pos = name.lastIndexOf(".")) != -1) { return name.substring(pos).toLowerCase(); } return null; } }); } { jLabel1 = new JLabel(); jPanel3.add(jLabel1); jLabel1.setText("match :"); jLabel1.setPreferredSize(new java.awt.Dimension(56, 22)); } { matchCount = new JLabel(); jPanel3.add(matchCount); matchCount.setPreferredSize(new java.awt.Dimension(82, 22)); } } } { jPanel2 = new JPanel(); FlowLayout jPanel2Layout = new FlowLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("config", null, jPanel2, null); { DefaultComboBoxModel authorComboBoxModel = new DefaultComboBoxModel(); authorComboBox = new JComboBox(); jPanel2.add(authorComboBox); authorComboBox.setModel(authorComboBoxModel); authorComboBox.setPreferredSize(new java.awt.Dimension(260, 24)); authorComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { Object author = authorComboBox.getSelectedItem(); if (author instanceof Map.Entry) { Map.Entry<?, ?> entry = (Map.Entry<?, ?>) author; reloadSvnTable((String) entry.getKey(), _authorScanProcess); } else { reloadSvnTable((String) author, _authorScanProcess); } } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(); fileExtensionComboBox = new JComboBox(); jPanel2.add(fileExtensionComboBox); fileExtensionComboBox.setModel(jComboBox1Model); fileExtensionComboBox.setPreferredSize(new java.awt.Dimension(186, 24)); fileExtensionComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { String extension = (String) fileExtensionComboBox.getSelectedItem(); reloadSvnTable(extension, _fileExtensionScanProcess); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { jScrollPane2 = new JScrollPane(); jScrollPane2.setPreferredSize(new java.awt.Dimension(130, 200)); jPanel2.add(jScrollPane2); { DefaultListModel model = new DefaultListModel(); fileExtensionFilter = new JList(); jScrollPane2.setViewportView(fileExtensionFilter); fileExtensionFilter.setModel(model); fileExtensionFilter.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { try { System.out .println(Arrays.toString(fileExtensionFilter.getSelectedValues())); String extensionStr = ""; StringBuilder sb = new StringBuilder(); for (Object val : fileExtensionFilter.getSelectedValues()) { sb.append(val + ","); } extensionStr = (sb.length() > 0 ? sb.deleteCharAt(sb.length() - 1) : sb) .toString(); System.out.format("extensionStr = [%s]\n", extensionStr); multiExtendsionFilter.setName(extensionStr); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } } { multiExtendsionFilter = new JButton(); jPanel2.add(multiExtendsionFilter); multiExtendsionFilter.setText("multi extension filter"); multiExtendsionFilter.setPreferredSize(new java.awt.Dimension(166, 34)); multiExtendsionFilter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { reloadSvnTable(multiExtendsionFilter.getName(), _fileExtensionMultiScanProcess); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { loadAuthorReference = new JButton(); jPanel2.add(loadAuthorReference); loadAuthorReference.setText("load author reference"); loadAuthorReference.setPreferredSize(new java.awt.Dimension(188, 35)); loadAuthorReference.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { File file = JFileChooserUtil.newInstance().selectFileOnly().showOpenDialog() .getApproveSelectedFile(); if (file == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("file is not correct!", "ERROR"); return; } authorProps.load(new FileInputStream(file)); reloadAuthorComboBox(); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { saveCurrentData = new JButton(); jPanel2.add(saveCurrentData); saveCurrentData.setText("save current data"); saveCurrentData.setPreferredSize(new java.awt.Dimension(166, 34)); saveCurrentData.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { File saveDataConfig = new File(jarExistLocation, getSaveCurrentDataFileName()); ObjectOutputStream writer = new ObjectOutputStream( new FileOutputStream(saveDataConfig)); writer.writeObject(projectName); writer.writeObject(authorSet); writer.writeObject(fileExtenstionSet); writer.writeObject(svnFileSet); writer.writeObject(authorProps); writer.writeObject(lastestVersion); writer.flush(); writer.close(); JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog("current project : " + projectName + " save completed! \n" + saveDataConfig, "SUCCESS"); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { loadDataFromFile = new JButton(); jPanel2.add(loadDataFromFile); loadDataFromFile.setText("load data cfg"); loadDataFromFile.setPreferredSize(new java.awt.Dimension(165, 35)); loadDataFromFile.addActionListener(new ActionListener() { @SuppressWarnings("unchecked") public void actionPerformed(ActionEvent evt) { try { File file = JFileChooserUtil.newInstance().selectFileOnly() .addAcceptFile(".cfg", ".cfg").showOpenDialog() .getApproveSelectedFile(); if (file == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("file is not correct!", "ERROR"); return; } long startTime = System.currentTimeMillis(); ObjectInputStream input = new ObjectInputStream(new FileInputStream(file)); projectName = (String) input.readObject(); authorSet = (Set<String>) input.readObject(); fileExtenstionSet = (Set<String>) input.readObject(); svnFileSet = (Set<SvnFile>) input.readObject(); authorProps = (Properties) input.readObject(); lastestVersion = (Long) input.readObject(); input.close(); resetUiAndShowMessage(startTime, projectName, lastestVersion); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } } } pack(); this.setSize(726, 459); } catch (Exception e) { e.printStackTrace(); } }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.doctype.ferramentaDoctype.java
/** * Mtodo chamado pelos construtores/* ww w. j a v a 2 s. co m*/ * * @param conteudo */ private void initComponents(String conteudo) { textAreaSourceCode = new G_TextAreaSourceCode(); tabelaDoctypes = new TabelaDescricao(); aplicar = new JButton(); abrir = new JButton(); cancelar = new JButton(); JPanel regraFonteBtn = new JPanel(); regraFonteBtn.setLayout(new BorderLayout()); textAreaSourceCode.setTipoHTML(); new OnChange(textAreaSourceCode, this); tabelaDoctypes = new TabelaDescricao(); salvar = new JButton(); abrir = new JButton(); cancelar = new JButton(); strConteudoalt = new String(); pnRegra = new JPanel(); lbRegras1 = new JLabel(); pnSetaDescricao = new JPanel(); pnListaErros = new JPanel(); scrollPanetabLinCod = new JScrollPane(); pnBotoes = new JPanel(); buscar = new JButton(); salvar.setEnabled(false); salvaAlteracoes = TxtBuffer.getInstanciaSalvaAlteracoes(textAreaSourceCode.getTextPane(), salvar, new JMenuItem(), parentFrame); textAreaSourceCode.getTextPane().setEditable(true); aplicar.setEnabled(false); setBackground(CoresDefault.getCorPaineis()); Container contentPane = this;// ?? contentPane.setLayout(new GridLayout(2, 1)); // ======== pnRegra ======== { // pnRegra.setBorder(criaBorda("")); pnRegra.setBorder(criaBorda(LabelPanel.TITULO_REGRA)); pnRegra.setLayout(new GridLayout(2, 1)); pnRegra.add(lbRegras1); lbRegras1.setText(TradFerramentaDocType.UTILIZAR_ELEMENTOS_CABECALHO); lbRegras1.setHorizontalAlignment(SwingConstants.CENTER); pnRegra.add(lbRegras1); pnRegra.setPreferredSize(new Dimension(700, 60)); } // ======== pnDescricao ======== aplicar.setText(GERAL.APLICAR); aplicar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { aplicarActionPerformed(e); } }); aplicar.setToolTipText(TradFerramentaDocType.DICA_APLICA_DTD); aplicar.getAccessibleContext().setAccessibleDescription(TradFerramentaDocType.DICA_APLICA_DTD); aplicar.getAccessibleContext().setAccessibleName(TradFerramentaDocType.DICA_APLICA_DTD); aplicar.setBounds(10, 0, 150, 25); salvar.setText(GERAL.BTN_SALVAR); salvar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { salvarActionPerformed(e); } }); salvar.setToolTipText(GERAL.DICA_SALVAR); salvar.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SALVAR); salvar.getAccessibleContext().setAccessibleName(GERAL.DICA_SALVAR); salvar.setBounds(10, 0, 150, 25); abrir.setText(GERAL.BTN_ABRIR); abrir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { abrirActionPerformed(e); } }); abrir.setToolTipText(Ferramenta_Scripts.DICA_ABRIR); abrir.getAccessibleContext().setAccessibleDescription(Ferramenta_Scripts.DICA_ABRIR_HTML); abrir.getAccessibleContext().setAccessibleName(Ferramenta_Scripts.DICA_ABRIR_HTML); abrir.setBounds(165, 0, 150, 25); cancelar.setText(Ferramenta_Imagens.TELA_ANTERIOR); cancelar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { cancelarActionPerformed(e); } }); cancelar.setToolTipText(Ferramenta_Imagens.DICA_TELA_ANTERIOR); cancelar.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_TELA_ANTERIOR); cancelar.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.DICA_BTN_CANCELAR); cancelar.setBounds(320, 0, 150, 25); // ======== pnParticRotulo ======== // pnSetaDescricao.setBorder(criaBorda("")); GridBagConstraints cons = new GridBagConstraints(); GridBagLayout layout = new GridBagLayout(); cons.fill = GridBagConstraints.BOTH; cons.weighty = 1; cons.weightx = 0.80; pnSetaDescricao.setLayout(layout); cons.anchor = GridBagConstraints.SOUTHEAST; cons.insets = new Insets(0, 0, 0, 10); // ======== spParticRotulo ======== cons.weightx = 0.20; pnSetaDescricao.setPreferredSize(new Dimension(400, 60)); // ======== pnListaErros ======== { pnListaErros.setBorder(criaBorda(TradFerramentaDocType.ESCOLHA_DTD_CORRETO)); pnListaErros.setLayout(new BorderLayout()); // ======== scrollPanetabLinCod ======== { scrollPanetabLinCod.setViewportView(tabelaDoctypes); } pnListaErros.add(scrollPanetabLinCod, BorderLayout.CENTER); } // ======== pnBotoes ======== { // pnBotoes.setBorder(criaBorda("")); pnBotoes.setLayout(null); // ---- adicionar ---- // ---- aplicarRotulo ---- buscar.setText(TradSimuladorNavegacao.BUSCAR_PROXIMA); buscar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { aplicarActionPerformed(e); } }); buscar.setToolTipText(TradSimuladorNavegacao.BUSCAR_TEXTO); buscar.getAccessibleContext().setAccessibleDescription(TradSimuladorNavegacao.BUSCAR_TEXTO); buscar.getAccessibleContext().setAccessibleName(TradSimuladorNavegacao.BUSCAR_TEXTO); buscar.setBounds(10, 5, 150, 25); // pnBotoes.add(buscar); } /* * Colocar os controles */ pnRegra.setBackground(CoresDefault.getCorPaineis()); regraFonteBtn.add(pnRegra, BorderLayout.NORTH); textAreaSourceCode.setBorder(criaBorda(TradFerramentaDocType.CODIGO_FONTE)); textAreaSourceCode.setBackground(CoresDefault.getCorPaineis()); regraFonteBtn.add(textAreaSourceCode, BorderLayout.CENTER); pnBotoes.setPreferredSize(new Dimension(600, 35)); pnBotoes.setBackground(CoresDefault.getCorPaineis()); regraFonteBtn.setBackground(CoresDefault.getCorPaineis()); contentPane.add(regraFonteBtn); JPanel textoErrosBtn = new JPanel(); textoErrosBtn.setLayout(new BorderLayout()); pnSetaDescricao.setBackground(CoresDefault.getCorPaineis()); pnSetaDescricao.add(pnBotoes, cons); textoErrosBtn.add(pnSetaDescricao, BorderLayout.NORTH); textoErrosBtn.add(pnListaErros, BorderLayout.CENTER); pnSalvarCancelar.setLayout(null); pnSalvarCancelar.setPreferredSize(new Dimension(600, 35)); pnSalvarCancelar.add(abrir); pnSalvarCancelar.add(salvar); pnSalvarCancelar.add(cancelar); if (!original) { reverter = new JButton("Reverter"); reverter.setText(TradPainelRelatorio.REVERTER); reverter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); TxtBuffer.setContent(TxtBuffer.getContentOriginal()); parentFrame.showPainelFerramentaDoctypePArq(TxtBuffer.getContentOriginal()); setVisible(true); } }); reverter.setToolTipText(TradPainelRelatorio.DICA_REVERTER); reverter.getAccessibleContext().setAccessibleDescription(TradPainelRelatorio.DICA_REVERTER); reverter.getAccessibleContext().setAccessibleName(TradPainelRelatorio.DICA_REVERTER); reverter.setBounds(485, 0, 150, 25); pnSalvarCancelar.add(reverter); } pnSalvarCancelar.setBackground(CoresDefault.getCorPaineis()); textoErrosBtn.add(pnSalvarCancelar, BorderLayout.SOUTH); pnListaErros.setBackground(CoresDefault.getCorPaineis()); contentPane.setBackground(CoresDefault.getCorPaineis()); contentPane.add(textoErrosBtn); controla(conteudo); this.setVisible(true); }
From source file:search2go.UIFrame.java
public UIFrame() throws IOException, ParseException { topLevels = new TopLevelGTermSet[] { CCs, MFs, BPs }; this.addWindowListener(new WindowAdapter() { @Override// w ww . j a va 2 s . co m public void windowClosing(WindowEvent et) { try { if (os.isWindows()) { Runtime.getRuntime().exec("cmd /C TaskKill -IM blastx.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM blastn.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM blastp.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM python.exe -F"); } else { Runtime.getRuntime().exec("killAll -KILL blastx"); Runtime.getRuntime().exec("killAll -KILL blastn"); Runtime.getRuntime().exec("killAll -KILL blastp"); Runtime.getRuntime().exec("killAll -KILL python"); } } catch (IOException ex) { System.out.println("Error closing child processes"); } } }); initComponents(); txtBlastOutput.getDocument().addDocumentListener(new BufferEnforcer(txtBlastOutput)); txtFullOutput.getDocument().addDocumentListener(new BufferEnforcer(txtFullOutput)); txtMapOutput.getDocument().addDocumentListener(new BufferEnforcer(txtMapOutput)); ((DefaultCaret) txtBlastOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); ((DefaultCaret) txtMapOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); ((DefaultCaret) txtFullOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); webSaveMenu = new JPopupMenu(); JMenuItem saveWeb = new JMenuItem(); saveWeb.setText("Save"); saveWeb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { webSaveDialogue.showSaveDialog(pnlChartHolder); File saveFile = webSaveDialogue.getSelectedFile(); if (!saveFile.getPath().contains(".png")) saveFile = new File(saveFile.getPath() + ".png"); try { BufferedImage webChartImage = new BufferedImage(pnlChartHolder.getWidth(), pnlChartHolder.getHeight(), BufferedImage.TYPE_INT_RGB); pnlChartHolder.print(webChartImage.getGraphics()); ImageIO.write(webChartImage, "png", saveFile); } catch (Exception ex) { javax.swing.JOptionPane.showMessageDialog(pnlChartHolder, "Error saving chart. Please try again."); } } }); webSaveMenu.add(saveWeb); pnlChartHolder.add(webSaveMenu); pnlChartHolder.setLayout(new java.awt.BorderLayout()); try { currentProj = Workspace.open(new Path("Search2GO_Data")); chkDoCCs.setState(currentProj.willDoCC()); chkDoBPs.setState(currentProj.willDoBP()); chkDoMFs.setState(currentProj.willDoMF()); txtQuery.setText(currentProj.getQueryPath()); txtQueryFP.setText(currentProj.getQueryPath()); txtDatabase.setText(currentProj.getPathToDB()); txtDatabaseFP.setText(currentProj.getPathToDB()); txtThreads.setValue(currentProj.getThreadNo()); txtThreadsFP.setValue(currentProj.getThreadNo()); cbxNXP.setSelectedIndex(currentProj.getBlastTypeIndex()); cbxNXPFP.setSelectedIndex(currentProj.getBlastTypeIndex()); cbxDBID.setSelectedIndex(currentProj.getSelectedDBIndex()); cbxDBIDFP.setSelectedIndex(currentProj.getSelectedDBIndex()); txtBitScore.setValue(currentProj.getBitScoreThreshold()); txtBitScoreFP.setValue(currentProj.getBitScoreThreshold()); txtBlastE.setValue(currentProj.getEThreshold()); txtMapE.setValue(currentProj.getEThreshold()); txtEFP.setValue(currentProj.getEThreshold()); } catch (FileNotFoundException e) { currentProj = Workspace.create(new Path("Search2GO_Data")); chkDoCCs.setState(currentProj.willDoCC()); chkDoBPs.setState(currentProj.willDoBP()); chkDoMFs.setState(currentProj.willDoMF()); } this.setTitle("Search2GO " + currentProj.getPath().toString()); GTermTableModel = new DefaultTableModel(); GTermTableModel.setColumnCount(2); GTermTableModel.setColumnIdentifiers(new String[] { "GO ID", "Frequency" }); ListSelectionModel GTermSelector = tblGOFreq.getSelectionModel(); GTermSelector.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (tblGOFreq.getSelectedRow() > -1) { DefaultListModel emptyModel = new DefaultListModel(); lstQueries.setModel(emptyModel); txtTermInfo.setText(""); String selectedID = (String) tblGOFreq.getValueAt(tblGOFreq.getSelectedRow(), 0); JTextArea tempHolderInfo = new JTextArea(); JTextArea tempHolderQueries = new JTextArea(); if (tblGOFreq.getSelectedRow() != -1) { ResetGTermInfoGetter(tempHolderInfo, tempHolderQueries); gTermInfoGetter.getProcess(0).addParameter("id", selectedID.substring(0, selectedID.indexOf("["))); gTermInfoGetter.getProcess(1).addParameter("id", selectedID.substring(0, selectedID.indexOf("["))); GTerm currentGTerm = gTerms.getGTerm(selectedID.substring(0, selectedID.indexOf("["))); gTermInfoGetter.getProcess(1).addParameter("db", currentGTerm.getTopLevel().getCode()); gTermInfoGetter.setTail(new ProcessSequenceEnd() { @Override public void run() { tempHolderInfo.setText("id: " + selectedID + "\n" + tempHolderInfo.getText()); txtTermInfo.setText(tempHolderInfo.getText()); DefaultListModel queryList = new DefaultListModel(); for (String str : tempHolderQueries.getText().split(";")) { queryList.addElement(str.replaceAll("Query: ", "")); } lstQueries.setModel(queryList); prgIdentification.setIndeterminate(false); } }); try { gTermInfoGetter.start(); prgIdentification.setIndeterminate(true); } catch (IOException ex) { Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex); } } } } } }); lstQueries.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting() && !e.toString().contains("invalid") && lstQueries.getSelectedValue() != null) { JTextArea tempHolder = new JTextArea(); ProcessSequence fetchLocusSequence = new ProcessSequence(new ProcessSequenceEnd() { @Override public void run() { if (txtTermInfo.getText().contains("Score")) { txtTermInfo.setText( txtTermInfo.getText().substring(0, txtTermInfo.getText().indexOf("Score"))); } txtTermInfo.append(tempHolder.getText()); prgIdentification.setIndeterminate(false); } }); Path fetchLocusPath = new Path("Processes"); fetchLocusPath.append("fetchLocus.py"); Process fetchLocus = new Process(tempHolder); fetchLocus.setScriptCommand(fetchLocusPath.toEscString()); fetchLocus.addParameter("dir", currentProj.getPath().toEscString()); fetchLocus.addParameter("q", new ParameterString(lstQueries.getSelectedValue().replace("\n", "")).toString()); String selectedID = (String) tblGOFreq.getValueAt(tblGOFreq.getSelectedRow(), 0); GTerm currentGTerm = gTerms.getGTerm(selectedID.substring(0, selectedID.indexOf("["))); fetchLocus.addParameter("db", currentGTerm.getTopLevel().getCode()); fetchLocus.addParameter("id", currentGTerm.getID()); fetchLocusSequence.addProcess(fetchLocus); try { fetchLocusSequence.start(); prgIdentification.setIndeterminate(true); } catch (IOException ex) { Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex); } } } }); DocumentListener filterListener = new DocumentListener() { private void anyUpdate() { gTerms.getFilter().setFilterString(txtSearchTerms.getText()); if (!txtMinFreqFilter.getText().equals("")) gTerms.getFilter().setMinFreq(Integer.parseInt(txtMinFreqFilter.getText())); else gTerms.getFilter().setMinFreq(0); if (!txtMaxFreqFilter.getText().equals("")) gTerms.getFilter().setMaxFreq(Integer.parseInt(txtMaxFreqFilter.getText())); else gTerms.getFilter().setMaxFreq(-1); fillIdentTable(gTerms.stringFilter(), false); } @Override public void insertUpdate(DocumentEvent e) { anyUpdate(); } @Override public void removeUpdate(DocumentEvent e) { anyUpdate(); } @Override public void changedUpdate(DocumentEvent e) { anyUpdate(); } }; txtSearchTerms.getDocument().addDocumentListener(filterListener); txtMinFreqFilter.getDocument().addDocumentListener(filterListener); txtMaxFreqFilter.getDocument().addDocumentListener(filterListener); NumberFormat numberMask = NumberFormat.getIntegerInstance(); numberMask.setGroupingUsed(false); NumberFormatter numberMasker = new NumberFormatter(numberMask); NumberFormatter numberMaskerAndBlank = new NumberFormatter(numberMask) { @Override public Object stringToValue(String s) throws ParseException { if (s == null || s.length() == 0) return null; return super.stringToValue(s); } }; DefaultFormatterFactory numberMaskFactory = new DefaultFormatterFactory(numberMasker); DefaultFormatterFactory numberMaskAndBlankFactory = new DefaultFormatterFactory(numberMaskerAndBlank); txtThreads.setFormatterFactory(numberMaskFactory); txtThreadsFP.setFormatterFactory(numberMaskFactory); txtBitScore.setFormatterFactory(numberMaskAndBlankFactory); txtBitScoreFP.setFormatterFactory(numberMaskAndBlankFactory); txtMinFreqFilter.setFormatterFactory(numberMaskFactory); txtMaxFreqFilter.setFormatterFactory(numberMaskFactory); txtBlastE.setFormatterFactory(numberMaskAndBlankFactory); txtMapE.setFormatterFactory(numberMaskAndBlankFactory); txtEFP.setFormatterFactory(numberMaskAndBlankFactory); blastButton = new StopButton(btnBlast); mapButton = new StopButton(btnMapIDs); identButton = new StopButton(btnGTermIdent); fullButton = new StopButton(btnProcessFP); if (currentProj.getStage() >= 2) identify(false); }
From source file:biz.wolschon.finance.jgnucash.JGnucash.java
/** * @return a menu-item to show a report on plugin-loading *//*from w w w. ja va 2s. c o m*/ private JMenuItem getHelpPluginReportMenu() { if (helpPluginReport == null) { helpPluginReport = new JMenuItem(); helpPluginReport.setText("Plugin Report"); helpPluginReport.addActionListener(new ActionListener() { @SuppressWarnings("unchecked") @Override public void actionPerformed(final ActionEvent e) { PluginManager manager = getPluginManager(); IntegrityCheckReport report = manager.getRegistry().getRegistrationReport(); StringBuilder message = new StringBuilder(); Collection<IntegrityCheckReport.ReportItem> items = report.getItems(); for (IntegrityCheckReport.ReportItem reportItem : items) { String severity = ""; /*unknown: "; if (reportItem.getSeverity() == IntegrityCheckReport.ReportItem.SEVERITY_ERROR) { severity = "Error: "; } else if (reportItem.getSeverity() == IntegrityCheckReport.ReportItem.SEVERITY_WARNING) { severity = "Warning: "; } else if (reportItem.getSeverity() == IntegrityCheckReport.ReportItem.SEVERITY_INFO) { severity = "Info: "; };*/ message.append(severity) /*.append('(') .append(reportItem.getCode()) .append(')')*/ .append(reportItem.getMessage()).append('\n'); } JOptionPane.showMessageDialog(JGnucash.this, message.toString(), "Plugins-Report", JOptionPane.INFORMATION_MESSAGE); } }); } return helpPluginReport; }
From source file:com.sec.ose.osi.ui.frm.main.JMenuMain.java
/** * This method initializes jMenuItemAnalysis * // w w w . j a v a 2s. c o m * @return javax.swing.JMenuItem */ private JMenuItem getJMenuItemAnalysis() { if (jMenuItemFileManage == null) { jMenuItemFileManage = new JMenuItem(); jMenuItemFileManage.setText("Manage"); jMenuItemFileManage.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { mEventHandler.handle(EventHandler.MAN_FILE_MANAGE); } }); } return jMenuItemFileManage; }