Changeset 21934


Ignore:
Timestamp:
04/22/10 10:05:01 (11 years ago)
Author:
sjm84
Message:

Added a filter box to the GAI log pane

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/admin/gui/LogPane.java

    r21922 r21934  
    9393    private JPanel control_pane = null;
    9494
    95     private File log_file = null;
     95    private ArrayList logFiles = new ArrayList();
     96    private File currentlySelectedFile = null;
    9697     
    9798    /** The various sizes for the screen layout*/
     
    102103    //Constructor
    103104    public LogPane() {
    104    
     105
     106    logFiles.add(new File (GAI.tomcat_home+File.separatorChar+"logs"+File.separatorChar+"catalina.out"));
     107    logFiles.add(new File (GAI.getGSDL3ExtensionHome() + File.separatorChar + "logs" + File.separatorChar + "ext.log"));
     108
    105109    // create all the necessary panes
    106110    control_pane = new JPanel();
     
    210214    logContent_pane.add(control_pane, BorderLayout.SOUTH);
    211215   
     216    JPanel filterPanel = new JPanel();
     217    filterPanel.setLayout(new BorderLayout());
     218
     219    JTextField filterField = new JTextField();
     220    filterPanel.add(filterField, BorderLayout.CENTER);
     221   
     222    JButton filterButton = new JButton("Filter");
     223    filterButton.addActionListener(new FilterButtonListener(filterField));
     224    filterPanel.add(filterButton, BorderLayout.EAST);
     225
     226    JPanel contentFilterPanel = new JPanel();
     227    contentFilterPanel.setLayout(new BorderLayout());
     228    contentFilterPanel.add(logContent_pane, BorderLayout.CENTER);
     229    contentFilterPanel.add(filterPanel, BorderLayout.NORTH);
     230
    212231    main_log_pane.add(logList_pane, JSplitPane.LEFT);
    213     main_log_pane.add(logContent_pane, JSplitPane.RIGHT);
     232    main_log_pane.add(contentFilterPanel, JSplitPane.RIGHT);
    214233    main_log_pane.setDividerLocation(LIST_SIZE.width - 10);
    215234   
     
    217236    this.add(main_log_pane, BorderLayout.CENTER);
    218237    //this.add(control_pane, BorderLayout.SOUTH);
     238    }
     239
     240    public class FilterButtonListener implements ActionListener
     241    {
     242    JTextField _filterField = null;
     243
     244    public FilterButtonListener(JTextField filterField)
     245    {
     246        _filterField = filterField;
     247    }
     248   
     249    public void actionPerformed(ActionEvent e)
     250    {
     251        readFile(currentlySelectedFile.getPath(), _filterField.getText());
     252    }
    219253    }
    220254
     
    300334        reload_button.setEnabled(true);
    301335        clear_button.setEnabled(true);
    302         updateLogsContent(log_file.getPath());
     336        updateLogsContent(currentlySelectedFile.getPath());
    303337    }
    304338    }
     
    307341    implements ActionListener {
    308342    public void actionPerformed(ActionEvent event) {
    309         if (!log_file.exists()){
    310         JOptionPane.showMessageDialog((Component) null,log_file.getPath() + " log file does not exist");
     343        if (!currentlySelectedFile.exists()){
     344        JOptionPane.showMessageDialog((Component) null,currentlySelectedFile.getPath() + " log file does not exist");
    311345        return;
    312346        } else {
    313347        ClearLogFilePrompt cfp  = new ClearLogFilePrompt();
    314         boolean file_cleared = cfp.display(log_file);
     348        boolean file_cleared = cfp.display(currentlySelectedFile);
    315349        if (file_cleared) {
    316350            log_textarea.setText("");
     
    322356   
    323357    public void updateLogsContent(String filename){
    324     if (!log_file.exists()){
     358    if (!currentlySelectedFile.exists()){
    325359        log_textarea.setText("");
    326360        JOptionPane.showMessageDialog((Component) null, filename+" log file does not exist"); 
    327361        clear_button.setEnabled(false);
    328362    } else {
    329         readFile(filename);
    330     }
    331     }
    332 
    333     public void readFile (String filename) {
     363        readFile(filename, "");
     364    }
     365    }
     366
     367    public void readFile (String filename, String filter) {
    334368    log_textarea.setText("");
    335369    String fileLine;
     
    337371        BufferedReader in = new BufferedReader(new FileReader(filename));
    338372        while ((fileLine = in.readLine()) != null) {
    339         log_textarea.append(fileLine);
    340         log_textarea.append("\n");
     373        if(fileLine.contains(filter)){
     374            log_textarea.append(fileLine);
     375            log_textarea.append("\n");
     376        }
    341377        }
    342378    } catch (Exception e) {
     
    351387            //no selection
    352388        } else if (log_list.getSelectedIndex () == 0 ) {
    353             log_file = new File (GAI.tomcat_home+File.separatorChar+"logs"+File.separatorChar+"catalina.out");
     389            File log_file = (File)logFiles.get(0);
     390            currentlySelectedFile = log_file;
    354391            String filename = log_file.getPath();
    355392            updateLogsContent(filename);
     
    357394            clear_button.setEnabled(true);
    358395        } else if (log_list.getSelectedIndex () == 1) {
    359             log_file = new File (GAI.getGSDL3ExtensionHome() + File.separatorChar + "logs" + File.separatorChar + "ext.log");
     396            File log_file = (File)logFiles.get(1);
     397            currentlySelectedFile = log_file;
    360398            String filename = log_file.getPath();
    361399            updateLogsContent(filename);
Note: See TracChangeset for help on using the changeset viewer.