📄 eafmultiplefilesearchpanel.java
字号:
* @return DOCUMENT ME! */ public Dimension getPreferredSize() { return new Dimension(800, 480); } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public File[] getSelectedFiles() { return searchFiles; } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public List getSelectedNodes() { return new ArrayList(); } /** * DOCUMENT ME! */ public void executionStarted() { super.executionStarted(); if (((JComponent) resultViewer).getWidth() == 0) { removeAll(); makeSecondPanel(); validate(); } infoLabel.setText(""); } /** * DOCUMENT ME! */ public void executionStopped() { super.executionStopped(); infoLabel.setText("in " + searchFiles.length + " files (" + (searchEngine.getSearchDuration() / 1000.0) + " seconds)"); } /** * DOCUMENT ME! * * @param e DOCUMENT ME! */ public void handleException(Exception e) { //System.out.println(e.getClass().getName()); if (e instanceof PatternSyntaxException) { JOptionPane.showMessageDialog(this, e.getMessage(), SearchLocale.getString("Search.Exception.Formulation"), JOptionPane.ERROR_MESSAGE); searchEngine.stopExecution(); } else if (e instanceof SAXException || e instanceof IOException) { JOptionPane.showMessageDialog(this, e.getMessage(), SearchLocale.getString("Search.Exception.Parse"), JOptionPane.ERROR_MESSAGE); //don't stop execution! } else { super.handleException(e); } } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ protected Query getQuery() { AnchorConstraint ac = new AnchorConstraint("", googleField.getText(), regexCheckBox.isSelected(), caseSensitiveCheckBox.isSelected()); return new ContentQuery(ac, new EAFType(), searchFiles); } /** * DOCUMENT ME! */ protected void export() { String lastDir = (String) Preferences.get(LAST_DIR_KEY, null); JFileChooser fc = new JFileChooser(lastDir); int retValue = fc.showSaveDialog(this); if (retValue == JFileChooser.APPROVE_OPTION) { try { ContentResult result = (ContentResult) searchEngine.getResult(); //System.out.println(result.getQuery()); ContentMatch2TabDelimitedText.exportMatches(result.getMatches(), fc.getSelectedFile()); } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(this, e.getMessage(), "Error during export", JOptionPane.ERROR_MESSAGE); } } } private void setComponents() { setBackground(Color.white); googleLabel.setFont(new Font("Serif", 0, 36)); googleLabel.setBorder(new EmptyBorder(5, 5, 5, 5)); googleLabel.setForeground(Color.BLUE); googleField.setFont(googleField.getFont().deriveFont(16f)); regexCheckBox.setOpaque(false); regexCheckBox.setFont(regexCheckBox.getFont().deriveFont(10f)); regexCheckBox.setBackground(getBackground()); caseSensitiveCheckBox.setOpaque(false); caseSensitiveCheckBox.setFont(caseSensitiveCheckBox.getFont() .deriveFont(10f)); caseSensitiveCheckBox.setBackground(getBackground()); startStopPanel.setOpaque(false); exportButton.setFont(googleField.getFont().deriveFont(10f)); exportButton.setEnabled(false); progressViewer.setOpaque(false); progressViewer.setBorder(new CompoundBorder( new EmptyBorder(3, 3, 3, 3), progressViewer.getBorder())); searchCategoryBox.setOpaque(false); searchCategoryBox.setBorder(new EmptyBorder(3, 0, 3, 0)); copyrightLabel.setFont(copyrightLabel.getFont().deriveFont(9f)); copyrightLabel.setBorder(new EmptyBorder(10, 10, 10, 10)); } private void makeSecondPanel() { optionBox.add(exportButton); JPanel infoPanel = new JPanel(new FlowLayout()); infoPanel.setOpaque(false); infoPanel.add(matchCounter); infoPanel.add(infoLabel); JPanel statusPanel = new JPanel(new BorderLayout()); statusPanel.setOpaque(false); statusPanel.add(((EAFMultipleFileResultViewer) resultViewer).getControlPanel(), BorderLayout.WEST); statusPanel.add(infoPanel, BorderLayout.EAST); GridBagConstraints c = new GridBagConstraints(); c.gridx = GridBagConstraints.RELATIVE; c.anchor = GridBagConstraints.WEST; add(googleLabel, c); c.anchor = GridBagConstraints.CENTER; add(centralPanel, c); add(startStopPanel, c); add(optionBox, c); c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0; add(progressViewer, c); c.fill = GridBagConstraints.HORIZONTAL; add(new JSeparator(JSeparator.HORIZONTAL), c); c.insets = new java.awt.Insets(0, 0, 0, 0); add(statusPanel, c); c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; add((JComponent) resultViewer, c); ((EAFMultipleFileResultViewer) resultViewer).setColumnVisible(EAFResultViewerTableModel.TIMEPOINT, false); } private void makeStartPanel() { setLayout(new GridBagLayout()); LinkButton defineDomainButton = new LinkButton(defineDomainAction); defineDomainButton.setFont(googleField.getFont().deriveFont(10f)); optionBox.add(new LinkButton(defineDomainAction)); JPanel flagPanel = new JPanel(new GridLayout(1, 0)); flagPanel.setOpaque(false); flagPanel.add(regexCheckBox); flagPanel.add(caseSensitiveCheckBox); searchCategoryBox.add(new JLabel("Annotations", JLabel.LEFT)); centralPanel.setOpaque(false); centralPanel.add(searchCategoryBox, BorderLayout.NORTH); centralPanel.add(googleField, BorderLayout.CENTER); centralPanel.add(flagPanel, BorderLayout.SOUTH); //empty component for keeping the 'google field' in the horizontal // center JComponent counterWeight = new JComponent() { public Dimension getPreferredSize() { return optionBox.getPreferredSize(); } }; JPanel panel = new JPanel(new FlowLayout()); panel.setOpaque(false); panel.add(counterWeight); panel.add(centralPanel); panel.add(optionBox); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.CENTER; add(googleLabel, c); add(panel, c); add(startStopPanel, c); add(copyrightLabel, c); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -