Changeset 21934
- Timestamp:
- 2010-04-22T10:05:01+12:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/admin/gui/LogPane.java
r21922 r21934 93 93 private JPanel control_pane = null; 94 94 95 private File log_file = null; 95 private ArrayList logFiles = new ArrayList(); 96 private File currentlySelectedFile = null; 96 97 97 98 /** The various sizes for the screen layout*/ … … 102 103 //Constructor 103 104 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 105 109 // create all the necessary panes 106 110 control_pane = new JPanel(); … … 210 214 logContent_pane.add(control_pane, BorderLayout.SOUTH); 211 215 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 212 231 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); 214 233 main_log_pane.setDividerLocation(LIST_SIZE.width - 10); 215 234 … … 217 236 this.add(main_log_pane, BorderLayout.CENTER); 218 237 //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 } 219 253 } 220 254 … … 300 334 reload_button.setEnabled(true); 301 335 clear_button.setEnabled(true); 302 updateLogsContent( log_file.getPath());336 updateLogsContent(currentlySelectedFile.getPath()); 303 337 } 304 338 } … … 307 341 implements ActionListener { 308 342 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"); 311 345 return; 312 346 } else { 313 347 ClearLogFilePrompt cfp = new ClearLogFilePrompt(); 314 boolean file_cleared = cfp.display( log_file);348 boolean file_cleared = cfp.display(currentlySelectedFile); 315 349 if (file_cleared) { 316 350 log_textarea.setText(""); … … 322 356 323 357 public void updateLogsContent(String filename){ 324 if (! log_file.exists()){358 if (!currentlySelectedFile.exists()){ 325 359 log_textarea.setText(""); 326 360 JOptionPane.showMessageDialog((Component) null, filename+" log file does not exist"); 327 361 clear_button.setEnabled(false); 328 362 } 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) { 334 368 log_textarea.setText(""); 335 369 String fileLine; … … 337 371 BufferedReader in = new BufferedReader(new FileReader(filename)); 338 372 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 } 341 377 } 342 378 } catch (Exception e) { … … 351 387 //no selection 352 388 } 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; 354 391 String filename = log_file.getPath(); 355 392 updateLogsContent(filename); … … 357 394 clear_button.setEnabled(true); 358 395 } 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; 360 398 String filename = log_file.getPath(); 361 399 updateLogsContent(filename);
Note:
See TracChangeset
for help on using the changeset viewer.