KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > runtime > logview > LogView


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.pde.internal.runtime.logview;
13
14 import java.io.BufferedReader JavaDoc;
15 import java.io.BufferedWriter JavaDoc;
16 import java.io.File JavaDoc;
17 import java.io.FileInputStream JavaDoc;
18 import java.io.FileOutputStream JavaDoc;
19 import java.io.IOException JavaDoc;
20 import java.io.InputStreamReader JavaDoc;
21 import java.io.OutputStreamWriter JavaDoc;
22 import java.io.PrintWriter JavaDoc;
23 import java.io.StringWriter JavaDoc;
24 import java.lang.reflect.InvocationTargetException JavaDoc;
25 import java.util.ArrayList JavaDoc;
26 import java.util.Comparator JavaDoc;
27
28 import org.eclipse.core.runtime.ILogListener;
29 import org.eclipse.core.runtime.IProgressMonitor;
30 import org.eclipse.core.runtime.IStatus;
31 import org.eclipse.core.runtime.Path;
32 import org.eclipse.core.runtime.Platform;
33 import org.eclipse.core.runtime.Preferences;
34 import org.eclipse.core.runtime.Status;
35 import org.eclipse.core.runtime.jobs.Job;
36 import org.eclipse.jface.action.Action;
37 import org.eclipse.jface.action.IMenuListener;
38 import org.eclipse.jface.action.IMenuManager;
39 import org.eclipse.jface.action.IStatusLineManager;
40 import org.eclipse.jface.action.IToolBarManager;
41 import org.eclipse.jface.action.MenuManager;
42 import org.eclipse.jface.action.Separator;
43 import org.eclipse.jface.dialogs.IDialogSettings;
44 import org.eclipse.jface.dialogs.MessageDialog;
45 import org.eclipse.jface.dialogs.ProgressMonitorDialog;
46 import org.eclipse.jface.operation.IRunnableWithProgress;
47 import org.eclipse.jface.util.Policy;
48 import org.eclipse.jface.viewers.DoubleClickEvent;
49 import org.eclipse.jface.viewers.IDoubleClickListener;
50 import org.eclipse.jface.viewers.ISelection;
51 import org.eclipse.jface.viewers.ISelectionChangedListener;
52 import org.eclipse.jface.viewers.IStructuredSelection;
53 import org.eclipse.jface.viewers.SelectionChangedEvent;
54 import org.eclipse.jface.viewers.TreeViewer;
55 import org.eclipse.jface.viewers.Viewer;
56 import org.eclipse.jface.viewers.ViewerComparator;
57 import org.eclipse.jface.window.Window;
58 import org.eclipse.osgi.util.NLS;
59 import org.eclipse.pde.internal.runtime.IHelpContextIds;
60 import org.eclipse.pde.internal.runtime.PDERuntimeMessages;
61 import org.eclipse.pde.internal.runtime.PDERuntimePlugin;
62 import org.eclipse.pde.internal.runtime.PDERuntimePluginImages;
63 import org.eclipse.swt.SWT;
64 import org.eclipse.swt.custom.BusyIndicator;
65 import org.eclipse.swt.dnd.Clipboard;
66 import org.eclipse.swt.dnd.TextTransfer;
67 import org.eclipse.swt.dnd.Transfer;
68 import org.eclipse.swt.events.DisposeEvent;
69 import org.eclipse.swt.events.DisposeListener;
70 import org.eclipse.swt.events.SelectionAdapter;
71 import org.eclipse.swt.events.SelectionEvent;
72 import org.eclipse.swt.graphics.Color;
73 import org.eclipse.swt.graphics.Image;
74 import org.eclipse.swt.graphics.Point;
75 import org.eclipse.swt.graphics.Rectangle;
76 import org.eclipse.swt.layout.GridData;
77 import org.eclipse.swt.layout.GridLayout;
78 import org.eclipse.swt.program.Program;
79 import org.eclipse.swt.widgets.Composite;
80 import org.eclipse.swt.widgets.Display;
81 import org.eclipse.swt.widgets.Event;
82 import org.eclipse.swt.widgets.FileDialog;
83 import org.eclipse.swt.widgets.Listener;
84 import org.eclipse.swt.widgets.Menu;
85 import org.eclipse.swt.widgets.Shell;
86 import org.eclipse.swt.widgets.Text;
87 import org.eclipse.swt.widgets.Tree;
88 import org.eclipse.swt.widgets.TreeColumn;
89 import org.eclipse.swt.widgets.TreeItem;
90 import org.eclipse.ui.IActionBars;
91 import org.eclipse.ui.IMemento;
92 import org.eclipse.ui.ISharedImages;
93 import org.eclipse.ui.IViewSite;
94 import org.eclipse.ui.IWorkbenchActionConstants;
95 import org.eclipse.ui.IWorkbenchPage;
96 import org.eclipse.ui.PartInitException;
97 import org.eclipse.ui.PlatformUI;
98 import org.eclipse.ui.XMLMemento;
99 import org.eclipse.ui.actions.ActionFactory;
100 import org.eclipse.ui.part.ViewPart;
101
102 public class LogView extends ViewPart implements ILogListener {
103     public static final String JavaDoc P_LOG_WARNING = "warning"; //$NON-NLS-1$
104
public static final String JavaDoc P_LOG_ERROR = "error"; //$NON-NLS-1$
105
public static final String JavaDoc P_LOG_INFO = "info"; //$NON-NLS-1$
106
public static final String JavaDoc P_LOG_LIMIT = "limit"; //$NON-NLS-1$
107
public static final String JavaDoc P_USE_LIMIT = "useLimit"; //$NON-NLS-1$
108
public static final String JavaDoc P_SHOW_ALL_SESSIONS = "allSessions"; //$NON-NLS-1$
109
private static final String JavaDoc P_COLUMN_1 = "column2"; //$NON-NLS-1$
110
private static final String JavaDoc P_COLUMN_2 = "column3"; //$NON-NLS-1$
111
private static final String JavaDoc P_COLUMN_3 = "column4"; //$NON-NLS-1$
112
public static final String JavaDoc P_ACTIVATE = "activate"; //$NON-NLS-1$
113
public static final String JavaDoc P_ORDER_TYPE = "orderType"; //$NON-NLS-1$
114
public static final String JavaDoc P_ORDER_VALUE = "orderValue"; //$NON-NLS-1$
115

116     private int MESSAGE_ORDER;
117     private int PLUGIN_ORDER;
118     private int DATE_ORDER;
119
120     public final static byte MESSAGE = 0x0;
121     public final static byte PLUGIN = 0x1;
122     public final static byte DATE = 0x2;
123     public static int ASCENDING = 1;
124     public static int DESCENDING = -1;
125
126     private ArrayList JavaDoc fLogs;
127
128     private Clipboard fClipboard;
129
130     private IMemento fMemento;
131     private File JavaDoc fInputFile;
132     private String JavaDoc fDirectory;
133
134     private Comparator JavaDoc fComparator;
135
136     // hover text
137
private boolean fCanOpenTextShell;
138     private Text fTextLabel;
139     private Shell fTextShell;
140
141     private boolean fFirstEvent = true;
142
143     private TreeColumn fColumn1;
144     private TreeColumn fColumn2;
145     private TreeColumn fColumn3;
146
147     private Tree fTree;
148     private TreeViewer fTreeViewer;
149     private LogViewLabelProvider fLabelProvider;
150
151     private Action fPropertiesAction;
152     private Action fDeleteLogAction;
153     private Action fReadLogAction;
154     private Action fCopyAction;
155     private Action fActivateViewAction;
156     private Action fOpenLogAction;
157     private Action fExportAction;
158
159     public LogView() {
160         fLogs = new ArrayList JavaDoc();
161         fInputFile = Platform.getLogFileLocation().toFile();
162     }
163
164     public void createPartControl(Composite parent) {
165         readLogFile();
166         createViewer(parent);
167         createActions();
168         fClipboard = new Clipboard(fTree.getDisplay());
169         fTree.setToolTipText(""); //$NON-NLS-1$
170
getSite().setSelectionProvider(fTreeViewer);
171         initializeViewerSorter();
172
173         makeHoverShell();
174
175         Platform.addLogListener(this);
176         PlatformUI.getWorkbench().getHelpSystem().setHelp(fTree, IHelpContextIds.LOG_VIEW);
177     }
178
179     private void createActions() {
180         IActionBars bars = getViewSite().getActionBars();
181
182         fCopyAction = createCopyAction();
183         bars.setGlobalActionHandler(ActionFactory.COPY.getId(), fCopyAction);
184
185         IToolBarManager toolBarManager = bars.getToolBarManager();
186
187         fExportAction = createExportAction();
188         toolBarManager.add(fExportAction);
189
190         final Action importLogAction = createImportLogAction();
191         toolBarManager.add(importLogAction);
192
193         toolBarManager.add(new Separator());
194
195         final Action clearAction = createClearAction();
196         toolBarManager.add(clearAction);
197
198         fDeleteLogAction = createDeleteLogAction();
199         toolBarManager.add(fDeleteLogAction);
200
201         fOpenLogAction = createOpenLogAction();
202         toolBarManager.add(fOpenLogAction);
203
204         fReadLogAction = createReadLogAction();
205         toolBarManager.add(fReadLogAction);
206
207         toolBarManager.add(new Separator());
208
209         IMenuManager mgr = bars.getMenuManager();
210         mgr.add(createFilterAction());
211         mgr.add(new Separator());
212
213         fActivateViewAction = createActivateViewAction();
214         mgr.add(fActivateViewAction);
215
216         createPropertiesAction();
217
218         MenuManager popupMenuManager = new MenuManager("#PopupMenu"); //$NON-NLS-1$
219
IMenuListener listener = new IMenuListener() {
220             public void menuAboutToShow(IMenuManager manager) {
221                 manager.add(fCopyAction);
222                 manager.add(new Separator());
223                 manager.add(clearAction);
224                 manager.add(fDeleteLogAction);
225                 manager.add(fOpenLogAction);
226                 manager.add(fReadLogAction);
227                 manager.add(new Separator());
228                 manager.add(fExportAction);
229                 manager.add(importLogAction);
230                 manager.add(new Separator());
231                 ((EventDetailsDialogAction) fPropertiesAction).setComparator(fComparator);
232                 manager.add(fPropertiesAction);
233                 manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
234             }
235         };
236         popupMenuManager.addMenuListener(listener);
237         popupMenuManager.setRemoveAllWhenShown(true);
238         getSite().registerContextMenu(popupMenuManager, getSite().getSelectionProvider());
239         Menu menu = popupMenuManager.createContextMenu(fTree);
240         fTree.setMenu(menu);
241     }
242
243     private Action createActivateViewAction() {
244         Action action = new Action(PDERuntimeMessages.LogView_activate) { //
245
public void run() {
246                 fMemento.putString(P_ACTIVATE, isChecked() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
247
}
248         };
249         action.setChecked(fMemento.getString(P_ACTIVATE).equals("true")); //$NON-NLS-1$
250
return action;
251     }
252
253     private Action createClearAction() {
254         Action action = new Action(PDERuntimeMessages.LogView_clear) {
255             public void run() {
256                 handleClear();
257             }
258         };
259         action.setImageDescriptor(PDERuntimePluginImages.DESC_CLEAR);
260         action.setDisabledImageDescriptor(PDERuntimePluginImages.DESC_CLEAR_DISABLED);
261         action.setToolTipText(PDERuntimeMessages.LogView_clear_tooltip);
262         action.setText(PDERuntimeMessages.LogView_clear);
263         return action;
264     }
265
266     private Action createCopyAction() {
267         Action action = new Action(PDERuntimeMessages.LogView_copy) {
268             public void run() {
269                 copyToClipboard(fTreeViewer.getSelection());
270             }
271         };
272         action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
273                 .getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
274         return action;
275     }
276
277     private Action createDeleteLogAction() {
278         Action action = new Action(PDERuntimeMessages.LogView_delete) {
279             public void run() {
280                 doDeleteLog();
281             }
282         };
283         action.setToolTipText(PDERuntimeMessages.LogView_delete_tooltip);
284         action.setImageDescriptor(PDERuntimePluginImages.DESC_REMOVE_LOG);
285         action.setDisabledImageDescriptor(PDERuntimePluginImages.DESC_REMOVE_LOG_DISABLED);
286         action.setEnabled(fInputFile.exists() && fInputFile.equals(Platform.getLogFileLocation().toFile()));
287         return action;
288     }
289
290     private Action createExportAction() {
291         Action action = new Action(PDERuntimeMessages.LogView_export) {
292             public void run() {
293                 handleExport();
294             }
295         };
296         action.setToolTipText(PDERuntimeMessages.LogView_export_tooltip);
297         action.setImageDescriptor(PDERuntimePluginImages.DESC_EXPORT);
298         action.setDisabledImageDescriptor(PDERuntimePluginImages.DESC_EXPORT_DISABLED);
299         action.setEnabled(fInputFile.exists());
300         return action;
301     }
302
303     private Action createFilterAction() {
304         Action action = new Action(PDERuntimeMessages.LogView_filter) {
305             public void run() {
306                 handleFilter();
307             }
308         };
309         action.setToolTipText(PDERuntimeMessages.LogView_filter);
310         action.setImageDescriptor(PDERuntimePluginImages.DESC_FILTER);
311         action.setDisabledImageDescriptor(PDERuntimePluginImages.DESC_FILTER_DISABLED);
312         return action;
313     }
314
315     private Action createImportLogAction() {
316         Action action = new Action(PDERuntimeMessages.LogView_import) {
317             public void run() {
318                 handleImport();
319             }
320         };
321         action.setToolTipText(PDERuntimeMessages.LogView_import_tooltip);
322         action.setImageDescriptor(PDERuntimePluginImages.DESC_IMPORT);
323         action.setDisabledImageDescriptor(PDERuntimePluginImages.DESC_IMPORT_DISABLED);
324         return action;
325     }
326
327     private Action createOpenLogAction() {
328         Action action = null;
329         try {
330             // check to see if org.eclipse.ui.ide is available
331
Class.forName("org.eclipse.ui.ide.IDE"); //$NON-NLS-1$
332
// check to see if org.eclipse.core.filesystem is available
333
Class.forName("org.eclipse.core.filesystem.IFileStore"); //$NON-NLS-1$
334
action = new OpenIDELogFileAction(this);
335         } catch (ClassNotFoundException JavaDoc e) {
336             action = new Action() {
337                 public void run() {
338                     if (fInputFile.exists()) {
339                         Job job = getOpenLogFileJob();
340                         job.setUser(false);
341                         job.setPriority(Job.SHORT);
342                         job.schedule();
343                     }
344                 }
345             };
346         }
347         action.setText(PDERuntimeMessages.LogView_view_currentLog);
348         action.setImageDescriptor(PDERuntimePluginImages.DESC_OPEN_LOG);
349         action.setDisabledImageDescriptor(PDERuntimePluginImages.DESC_OPEN_LOG_DISABLED);
350         action.setEnabled(fInputFile.exists());
351         action.setToolTipText(PDERuntimeMessages.LogView_view_currentLog_tooltip);
352         return action;
353     }
354
355     private void createPropertiesAction() {
356         fPropertiesAction = new EventDetailsDialogAction(fTree.getShell(), fTreeViewer);
357         fPropertiesAction.setImageDescriptor(PDERuntimePluginImages.DESC_PROPERTIES);
358         fPropertiesAction.setDisabledImageDescriptor(PDERuntimePluginImages.DESC_PROPERTIES_DISABLED);
359         fPropertiesAction.setToolTipText(PDERuntimeMessages.LogView_properties_tooltip);
360         fPropertiesAction.setEnabled(false);
361     }
362
363     private Action createReadLogAction() {
364         Action action = new Action(PDERuntimeMessages.LogView_readLog_restore) {
365             public void run() {
366                 fInputFile = Platform.getLogFileLocation().toFile();
367                 reloadLog();
368             }
369         };
370         action.setToolTipText(PDERuntimeMessages.LogView_readLog_restore_tooltip);
371         action.setImageDescriptor(PDERuntimePluginImages.DESC_READ_LOG);
372         action.setDisabledImageDescriptor(PDERuntimePluginImages.DESC_READ_LOG_DISABLED);
373         return action;
374     }
375
376     private void createViewer(Composite parent) {
377         fTreeViewer = new TreeViewer(parent, SWT.FULL_SELECTION);
378         fTree = fTreeViewer.getTree();
379         fTree.setLinesVisible(true);
380         createColumns(fTree);
381         fTreeViewer.setContentProvider(new LogViewContentProvider(this));
382         fTreeViewer.setLabelProvider(fLabelProvider = new LogViewLabelProvider());
383         fLabelProvider.connect(this);
384         fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
385             public void selectionChanged(SelectionChangedEvent e) {
386                 handleSelectionChanged(e.getSelection());
387                 if (fPropertiesAction.isEnabled())
388                     ((EventDetailsDialogAction) fPropertiesAction).resetSelection();
389             }
390         });
391         fTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
392             public void doubleClick(DoubleClickEvent event) {
393                 ((EventDetailsDialogAction) fPropertiesAction).setComparator(fComparator);
394                 fPropertiesAction.run();
395             }
396         });
397         fTreeViewer.setInput(this);
398         addMouseListeners();
399     }
400
401     private void createColumns(Tree tree) {
402         fColumn1 = new TreeColumn(tree, SWT.LEFT);
403         fColumn1.setText(PDERuntimeMessages.LogView_column_message);
404         fColumn1.setWidth(fMemento.getInteger(P_COLUMN_1).intValue());
405         fColumn1.addSelectionListener(new SelectionAdapter() {
406             public void widgetSelected(SelectionEvent e) {
407                 MESSAGE_ORDER *= -1;
408                 ViewerComparator comparator = getViewerComparator(MESSAGE);
409                 fTreeViewer.setComparator(comparator);
410                 boolean isComparatorSet =
411                     ((EventDetailsDialogAction) fPropertiesAction).resetSelection(MESSAGE, MESSAGE_ORDER);
412                 setComparator(MESSAGE);
413                 if (!isComparatorSet)
414                     ((EventDetailsDialogAction) fPropertiesAction).setComparator(fComparator);
415                 fMemento.putInteger(P_ORDER_VALUE, MESSAGE_ORDER);
416                 fMemento.putInteger(P_ORDER_TYPE, MESSAGE);
417                 setColumnSorting(fColumn1, MESSAGE_ORDER);
418             }
419         });
420
421         fColumn2 = new TreeColumn(tree, SWT.LEFT);
422         fColumn2.setText(PDERuntimeMessages.LogView_column_plugin);
423         fColumn2.setWidth(fMemento.getInteger(P_COLUMN_2).intValue());
424         fColumn2.addSelectionListener(new SelectionAdapter() {
425             public void widgetSelected(SelectionEvent e) {
426                 PLUGIN_ORDER *= -1;
427                 ViewerComparator comparator = getViewerComparator(PLUGIN);
428                 fTreeViewer.setComparator(comparator);
429                 boolean isComparatorSet =
430                     ((EventDetailsDialogAction) fPropertiesAction).resetSelection(PLUGIN, PLUGIN_ORDER);
431                 setComparator(PLUGIN);
432                 if (!isComparatorSet)
433                     ((EventDetailsDialogAction) fPropertiesAction).setComparator(fComparator);
434                 fMemento.putInteger(P_ORDER_VALUE, PLUGIN_ORDER);
435                 fMemento.putInteger(P_ORDER_TYPE, PLUGIN);
436                 setColumnSorting(fColumn2, PLUGIN_ORDER);
437             }
438         });
439
440         fColumn3 = new TreeColumn(tree, SWT.LEFT);
441         fColumn3.setText(PDERuntimeMessages.LogView_column_date);
442         fColumn3.setWidth(fMemento.getInteger(P_COLUMN_3).intValue());
443         fColumn3.addSelectionListener(new SelectionAdapter() {
444             public void widgetSelected(SelectionEvent e) {
445                 DATE_ORDER *= -1;
446                 ViewerComparator comparator = getViewerComparator(DATE);
447                 fTreeViewer.setComparator(comparator);
448                 setComparator(DATE);
449                 ((EventDetailsDialogAction) fPropertiesAction).setComparator(fComparator);
450                 fMemento.putInteger(P_ORDER_VALUE, DATE_ORDER);
451                 fMemento.putInteger(P_ORDER_TYPE, DATE);
452                 setColumnSorting(fColumn3, DATE_ORDER);
453             }
454         });
455
456         tree.setHeaderVisible(true);
457     }
458
459     private void initializeViewerSorter() {
460         byte orderType = fMemento.getInteger(P_ORDER_TYPE).byteValue();
461         ViewerComparator comparator = getViewerComparator(orderType);
462         fTreeViewer.setComparator(comparator);
463         if (orderType == MESSAGE )
464             setColumnSorting(fColumn1, MESSAGE_ORDER);
465         else if (orderType == PLUGIN)
466             setColumnSorting(fColumn2, PLUGIN_ORDER);
467         else if (orderType == DATE)
468             setColumnSorting(fColumn3, DATE_ORDER);
469     }
470
471     private void setColumnSorting(TreeColumn column, int order) {
472         fTree.setSortColumn(column);
473         fTree.setSortDirection(order == ASCENDING ? SWT.UP : SWT.DOWN);
474     }
475
476     public void dispose() {
477         writeSettings();
478         Platform.removeLogListener(this);
479         fClipboard.dispose();
480         if (fTextShell != null)
481             fTextShell.dispose();
482         LogReader.reset();
483         fLabelProvider.disconnect(this);
484         super.dispose();
485     }
486
487
488     private void handleImport() {
489         FileDialog dialog = new FileDialog(getViewSite().getShell());
490         dialog.setFilterExtensions(new String JavaDoc[] { "*.log" }); //$NON-NLS-1$
491
if (fDirectory != null)
492             dialog.setFilterPath(fDirectory);
493         handleImportPath(dialog.open());
494     }
495
496     public void handleImportPath(String JavaDoc path) {
497         if (path != null && new Path(path).toFile().exists()) {
498             fInputFile = new Path(path).toFile();
499             fDirectory = fInputFile.getParent();
500             IRunnableWithProgress op = new IRunnableWithProgress() {
501                 public void run(IProgressMonitor monitor)
502                 throws InvocationTargetException JavaDoc, InterruptedException JavaDoc {
503                     monitor.beginTask(PDERuntimeMessages.LogView_operation_importing, IProgressMonitor.UNKNOWN);
504                     readLogFile();
505                 }
506             };
507             ProgressMonitorDialog pmd = new ProgressMonitorDialog(getViewSite().getShell());
508             try {
509                 pmd.run(true, true, op);
510             } catch (InvocationTargetException JavaDoc e) {
511             } catch (InterruptedException JavaDoc e) {
512             } finally {
513                 fReadLogAction.setText(PDERuntimeMessages.LogView_readLog_reload);
514                 fReadLogAction.setToolTipText(PDERuntimeMessages.LogView_readLog_reload);
515                 asyncRefresh(false);
516                 resetDialogButtons();
517             }
518         }
519     }
520
521     private void handleExport() {
522         FileDialog dialog = new FileDialog(getViewSite().getShell(), SWT.SAVE);
523         dialog.setFilterExtensions(new String JavaDoc[] { "*.log" }); //$NON-NLS-1$
524
if (fDirectory != null)
525             dialog.setFilterPath(fDirectory);
526         String JavaDoc path = dialog.open();
527         if (path != null) {
528             if (path.indexOf('.') == -1 && !path.endsWith(".log")) //$NON-NLS-1$
529
path += ".log"; //$NON-NLS-1$
530
File JavaDoc outputFile = new Path(path).toFile();
531             fDirectory = outputFile.getParent();
532             if (outputFile.exists()) {
533                 String JavaDoc message = NLS.bind(PDERuntimeMessages.LogView_confirmOverwrite_message, outputFile.toString());
534                 if (!MessageDialog.openQuestion(getViewSite().getShell(), PDERuntimeMessages.LogView_exportLog, message))
535                     return;
536             }
537             copy(fInputFile, outputFile);
538         }
539     }
540
541     private void copy(File JavaDoc inputFile, File JavaDoc outputFile) {
542         BufferedReader JavaDoc reader = null;
543         BufferedWriter JavaDoc writer = null;
544         try {
545             reader = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(new FileInputStream JavaDoc(inputFile), "UTF-8")); //$NON-NLS-1$
546
writer = new BufferedWriter JavaDoc(new OutputStreamWriter JavaDoc(new FileOutputStream JavaDoc(outputFile), "UTF-8")); //$NON-NLS-1$
547
while (reader.ready()) {
548                 writer.write(reader.readLine());
549                 writer.write(System.getProperty("line.separator")); //$NON-NLS-1$
550
}
551         } catch (IOException JavaDoc e) {
552         } finally {
553             try {
554                 if (reader != null)
555                     reader.close();
556                 if (writer != null)
557                     writer.close();
558             } catch (IOException JavaDoc e1) {
559             }
560         }
561     }
562
563     private void handleFilter() {
564         FilterDialog dialog = new FilterDialog(PDERuntimePlugin.getActiveWorkbenchShell(), fMemento);
565         dialog.create();
566         dialog.getShell().setText(PDERuntimeMessages.LogView_FilterDialog_title);
567         if (dialog.open() == Window.OK)
568             reloadLog();
569     }
570
571     private void doDeleteLog() {
572         String JavaDoc title = PDERuntimeMessages.LogView_confirmDelete_title;
573         String JavaDoc message = PDERuntimeMessages.LogView_confirmDelete_message;
574         if (!MessageDialog.openConfirm(fTree.getShell(), title, message))
575             return;
576         if (fInputFile.delete() || fLogs.size() > 0) {
577             fLogs.clear();
578             asyncRefresh(false);
579             resetDialogButtons();
580         }
581     }
582
583     public void fillContextMenu(IMenuManager manager) {
584     }
585
586     public LogEntry[] getLogs() {
587         return (LogEntry[]) fLogs.toArray(new LogEntry[fLogs.size()]);
588     }
589
590     protected void handleClear() {
591         BusyIndicator.showWhile(fTree.getDisplay(),
592                 new Runnable JavaDoc() {
593             public void run() {
594                 fLogs.clear();
595                 asyncRefresh(false);
596                 resetDialogButtons();
597             }
598         });
599     }
600
601     protected void reloadLog() {
602         IRunnableWithProgress op = new IRunnableWithProgress() {
603             public void run(IProgressMonitor monitor) throws InvocationTargetException JavaDoc, InterruptedException JavaDoc {
604                 monitor.beginTask(PDERuntimeMessages.LogView_operation_reloading, IProgressMonitor.UNKNOWN);
605                 readLogFile();
606             }
607         };
608         ProgressMonitorDialog pmd = new ProgressMonitorDialog(getViewSite().getShell());
609         try {
610             pmd.run(true, true, op);
611         } catch (InvocationTargetException JavaDoc e) {
612         } catch (InterruptedException JavaDoc e) {
613         } finally {
614             fReadLogAction.setText(PDERuntimeMessages.LogView_readLog_restore);
615             fReadLogAction.setToolTipText(PDERuntimeMessages.LogView_readLog_restore);
616             asyncRefresh(false);
617             resetDialogButtons();
618         }
619     }
620
621     private void readLogFile() {
622         fLogs.clear();
623         if (!fInputFile.exists())
624             return;
625         LogReader.parseLogFile(fInputFile, fLogs, fMemento);
626     }
627
628     public void logging(IStatus status, String JavaDoc plugin) {
629         if (!fInputFile.equals(Platform.getLogFileLocation().toFile()))
630             return;
631         if (fFirstEvent) {
632             readLogFile();
633             asyncRefresh();
634             fFirstEvent = false;
635         } else {
636             pushStatus(status);
637         }
638     }
639
640     private void pushStatus(IStatus status) {
641         LogEntry entry = new LogEntry(status);
642         LogReader.addEntry(entry, fLogs, fMemento, true);
643         asyncRefresh();
644     }
645
646     private void asyncRefresh() {
647         asyncRefresh(true);
648     }
649
650     private void asyncRefresh(final boolean activate) {
651         if (fTree.isDisposed())
652             return;
653         Display display = fTree.getDisplay();
654         final ViewPart view = this;
655         if (display != null) {
656             display.asyncExec(new Runnable JavaDoc() {
657                 public void run() {
658                     if (!fTree.isDisposed()) {
659                         fTreeViewer.refresh();
660                         fDeleteLogAction.setEnabled(fInputFile.exists()
661                                 && fInputFile.equals(Platform.getLogFileLocation().toFile()));
662                         fOpenLogAction.setEnabled(fInputFile.exists());
663                         fExportAction.setEnabled(fInputFile.exists());
664                         if (activate && fActivateViewAction.isChecked()) {
665                             IWorkbenchPage page = PDERuntimePlugin.getActivePage();
666                             if (page != null)
667                                 page.bringToTop(view);
668                         }
669                     }
670                 }
671             });
672         }
673     }
674
675     public void setFocus() {
676         if (fTree != null && !fTree.isDisposed())
677             fTree.setFocus();
678     }
679
680     private void handleSelectionChanged(ISelection selection) {
681         updateStatus(selection);
682         fCopyAction.setEnabled(!selection.isEmpty());
683         fPropertiesAction.setEnabled(!selection.isEmpty());
684     }
685
686     private void updateStatus(ISelection selection) {
687         IStatusLineManager status = getViewSite().getActionBars().getStatusLineManager();
688         if (selection.isEmpty())
689             status.setMessage(null);
690         else {
691             LogEntry entry = (LogEntry) ((IStructuredSelection) selection).getFirstElement();
692             status.setMessage(((LogViewLabelProvider) fTreeViewer.getLabelProvider()).getColumnText(entry, 0));
693         }
694     }
695
696     private void copyToClipboard(ISelection selection) {
697         StringWriter JavaDoc writer = new StringWriter JavaDoc();
698         PrintWriter JavaDoc pwriter = new PrintWriter JavaDoc(writer);
699         if (selection.isEmpty())
700             return;
701         LogEntry entry = (LogEntry) ((IStructuredSelection) selection).getFirstElement();
702         entry.write(pwriter);
703         pwriter.flush();
704         String JavaDoc textVersion = writer.toString();
705         try {
706             pwriter.close();
707             writer.close();
708         } catch (IOException JavaDoc e) {
709         }
710         if (textVersion.trim().length() > 0) {
711             // set the clipboard contents
712
fClipboard.setContents(
713                     new Object JavaDoc[] { textVersion },
714                     new Transfer[] { TextTransfer.getInstance() });
715         }
716     }
717
718     public void init(IViewSite site, IMemento memento) throws PartInitException {
719         super.init(site, memento);
720         if (memento == null)
721             this.fMemento = XMLMemento.createWriteRoot("LOGVIEW"); //$NON-NLS-1$
722
else
723             this.fMemento = memento;
724         readSettings();
725
726         // initialize column ordering
727
final byte type = this.fMemento.getInteger(P_ORDER_TYPE).byteValue();
728         switch (type){
729         case DATE:
730             DATE_ORDER = this.fMemento.getInteger(P_ORDER_VALUE).intValue();
731             MESSAGE_ORDER = DESCENDING;
732             PLUGIN_ORDER = DESCENDING;
733             break;
734         case MESSAGE:
735             MESSAGE_ORDER = this.fMemento.getInteger(P_ORDER_VALUE).intValue();
736             DATE_ORDER = DESCENDING;
737             PLUGIN_ORDER = DESCENDING;
738             break;
739         case PLUGIN:
740             PLUGIN_ORDER = this.fMemento.getInteger(P_ORDER_VALUE).intValue();
741             MESSAGE_ORDER = DESCENDING;
742             DATE_ORDER = DESCENDING;
743             break;
744         default:
745             DATE_ORDER = DESCENDING;
746         MESSAGE_ORDER = DESCENDING;
747         PLUGIN_ORDER = DESCENDING;
748         }
749         setComparator(fMemento.getInteger(P_ORDER_TYPE).byteValue());
750     }
751
752     private void initializeMemento() {
753         if (fMemento.getString(P_USE_LIMIT) == null)
754             fMemento.putString(P_USE_LIMIT, "true"); //$NON-NLS-1$
755
if (fMemento.getInteger(P_LOG_LIMIT) == null)
756             fMemento.putInteger(P_LOG_LIMIT, 50);
757         if (fMemento.getString(P_LOG_INFO) == null)
758             fMemento.putString(P_LOG_INFO, "true"); //$NON-NLS-1$
759
if (fMemento.getString(P_LOG_WARNING) == null)
760             fMemento.putString(P_LOG_WARNING, "true"); //$NON-NLS-1$
761
if (fMemento.getString(P_LOG_ERROR) == null)
762             fMemento.putString(P_LOG_ERROR, "true"); //$NON-NLS-1$
763
if (fMemento.getString(P_SHOW_ALL_SESSIONS) == null)
764             fMemento.putString(P_SHOW_ALL_SESSIONS, "true"); //$NON-NLS-1$
765
Integer JavaDoc width = fMemento.getInteger(P_COLUMN_1);
766         if (width == null || width.intValue() == 0)
767             fMemento.putInteger(P_COLUMN_1, 300);
768         width = fMemento.getInteger(P_COLUMN_2);
769         if (width == null || width.intValue() == 0)
770             fMemento.putInteger(P_COLUMN_2, 150);
771         width = fMemento.getInteger(P_COLUMN_3);
772         if (width == null || width.intValue() == 0)
773             fMemento.putInteger(P_COLUMN_3, 150);
774         if (fMemento.getString(P_ACTIVATE) == null)
775             fMemento.putString(P_ACTIVATE, "true"); //$NON-NLS-1$
776

777         fMemento.putInteger(P_ORDER_VALUE, DESCENDING);
778         fMemento.putInteger(P_ORDER_TYPE, DATE);
779     }
780
781     public void saveState(IMemento memento) {
782         if (this.fMemento == null || memento == null)
783             return;
784         this.fMemento.putInteger(P_COLUMN_1, fColumn1.getWidth());
785         this.fMemento.putInteger(P_COLUMN_2, fColumn2.getWidth());
786         this.fMemento.putInteger(P_COLUMN_3, fColumn3.getWidth());
787         this.fMemento.putString(P_ACTIVATE,
788                 fActivateViewAction.isChecked() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
789
memento.putMemento(this.fMemento);
790         writeSettings();
791     }
792
793     private void addMouseListeners() {
794         Listener tableListener = new Listener() {
795             public void handleEvent(Event e) {
796                 switch (e.type) {
797                 case SWT.MouseMove:
798                     onMouseMove(e);
799                     break;
800                 case SWT.MouseHover:
801                     onMouseHover(e);
802                     break;
803                 case SWT.MouseDown:
804                     onMouseDown(e);
805                     break;
806                 }
807             }
808         };
809         int[] tableEvents = new int[] { SWT.MouseDown, SWT.MouseMove, SWT.MouseHover };
810         for (int i = 0; i < tableEvents.length; i++) {
811             fTree.addListener(tableEvents[i], tableListener);
812         }
813     }
814
815     private void makeHoverShell() {
816         fTextShell = new Shell(fTree.getShell(), SWT.NO_FOCUS | SWT.ON_TOP | SWT.TOOL);
817         Display display = fTextShell.getDisplay();
818         fTextShell.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
819         GridLayout layout = new GridLayout(1, false);
820         int border = ((fTree.getShell().getStyle() & SWT.NO_TRIM) == 0) ? 0 : 1;
821         layout.marginHeight = border;
822         layout.marginWidth = border;
823         fTextShell.setLayout(layout);
824         fTextShell.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
825         Composite shellComposite = new Composite(fTextShell, SWT.NONE);
826         layout = new GridLayout();
827         layout.marginHeight = 0;
828         layout.marginWidth = 0;
829         shellComposite.setLayout(layout);
830         shellComposite.setLayoutData(
831                 new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_BEGINNING));
832         fTextLabel = new Text(shellComposite, SWT.WRAP | SWT.MULTI | SWT.READ_ONLY);
833         GridData gd = new GridData(GridData.FILL_BOTH);
834         gd.widthHint = 100;
835         gd.grabExcessHorizontalSpace = true;
836         fTextLabel.setLayoutData(gd);
837         Color c = fTree.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
838         fTextLabel.setBackground(c);
839         c = fTree.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND);
840         fTextLabel.setForeground(c);
841         fTextLabel.setEditable(false);
842         fTextShell.addDisposeListener(new DisposeListener() {
843             public void widgetDisposed(DisposeEvent e) {
844                 onTextShellDispose(e);
845             }
846         });
847     }
848
849     void onTextShellDispose(DisposeEvent e) {
850         fCanOpenTextShell = true;
851         setFocus();
852     }
853
854     void onMouseDown(Event e) {
855         if (fTextShell != null && !fTextShell.isDisposed() && !fTextShell.isFocusControl()) {
856             fTextShell.setVisible(false);
857             fCanOpenTextShell = true;
858         }
859     }
860
861     void onMouseHover(Event e) {
862         if (!fCanOpenTextShell)
863             return;
864         fCanOpenTextShell = false;
865         Point point = new Point(e.x, e.y);
866         TreeItem item = fTree.getItem(point);
867         if (item == null)
868             return;
869         String JavaDoc message = ((LogEntry) item.getData()).getStack();
870         if (message == null)
871             return;
872
873         fTextLabel.setText(message);
874         Rectangle bounds = fTree.getDisplay().getBounds();
875         Point cursorPoint = fTree.getDisplay().getCursorLocation();
876         int x = point.x;
877         int y = point.y + 25;
878         int width = fTree.getColumn(0).getWidth();
879         int height = 125;
880         if (cursorPoint.x + width > bounds.width)
881             x -= width;
882         if (cursorPoint.y + height + 25 > bounds.height)
883             y -= height + 27;
884
885         fTextShell.setLocation(fTree.toDisplay(x, y));
886         fTextShell.setSize(width, height);
887         fTextShell.setVisible(true);
888     }
889
890     void onMouseMove(Event e) {
891         if (fTextShell != null && !fTextShell.isDisposed() && fTextShell.isVisible())
892             fTextShell.setVisible(false);
893
894         Point point = new Point(e.x, e.y);
895         TreeItem item = fTree.getItem(point);
896         if (item == null)
897             return;
898         Image image= item.getImage();
899         LogEntry entry = (LogEntry)item.getData();
900         int parentCount = getNumberOfParents(entry);
901         int startRange = 20 + Math.max(image.getBounds().width + 2, 7 + 2)*parentCount;
902         int endRange = startRange + 16;
903         fCanOpenTextShell = e.x >= startRange && e.x <= endRange;
904     }
905
906     private int getNumberOfParents(LogEntry entry){
907         LogEntry parent = (LogEntry)entry.getParent(entry);
908         if (parent ==null)
909             return 0;
910         return 1 + getNumberOfParents(parent);
911     }
912
913     public Comparator JavaDoc getComparator() {
914         return fComparator;
915     }
916
917     private void setComparator(byte sortType) {
918         if (sortType == DATE) {
919             fComparator = new Comparator JavaDoc() {
920                 public int compare(Object JavaDoc e1, Object JavaDoc e2) {
921                     long date1 = ((LogEntry) e1).getDate().getTime();
922                     long date2 = ((LogEntry) e2).getDate().getTime();
923                     if (date1 == date2) {
924                         int result = fLogs.indexOf(e2) - fLogs.indexOf(e1);
925                         if (DATE_ORDER == DESCENDING)
926                             result *= DESCENDING;
927                         return result;
928                     }
929                     if (DATE_ORDER == DESCENDING)
930                         return date1 > date2 ? DESCENDING : ASCENDING;
931                         return date1 < date2 ? DESCENDING : ASCENDING;
932                 }
933             };
934         } else if (sortType == PLUGIN) {
935             fComparator = new Comparator JavaDoc() {
936                 public int compare(Object JavaDoc e1, Object JavaDoc e2) {
937                     LogEntry entry1 = (LogEntry) e1;
938                     LogEntry entry2 = (LogEntry) e2;
939                     return getDefaultComparator().compare(entry1.getPluginId(), entry2.getPluginId()) * PLUGIN_ORDER;
940                 }
941             };
942         } else {
943             fComparator = new Comparator JavaDoc() {
944                 public int compare(Object JavaDoc e1, Object JavaDoc e2) {
945                     LogEntry entry1 = (LogEntry) e1;
946                     LogEntry entry2 = (LogEntry) e2;
947                     return getDefaultComparator().compare(entry1.getMessage(), entry2.getMessage()) * MESSAGE_ORDER;
948                 }
949             };
950         }
951     }
952
953     private Comparator JavaDoc getDefaultComparator() {
954         return Policy.getComparator();
955     }
956
957     private ViewerComparator getViewerComparator(byte sortType) {
958         if (sortType == PLUGIN) {
959             return new ViewerComparator() {
960                 public int compare(Viewer viewer, Object JavaDoc e1, Object JavaDoc e2) {
961                     LogEntry entry1 = (LogEntry) e1;
962                     LogEntry entry2 = (LogEntry) e2;
963                     return getComparator().compare(entry1.getPluginId(), entry2.getPluginId()) * PLUGIN_ORDER;
964                 }
965             };
966         } else if (sortType == MESSAGE) {
967             return new ViewerComparator() {
968                 public int compare(Viewer viewer, Object JavaDoc e1, Object JavaDoc e2) {
969                     LogEntry entry1 = (LogEntry) e1;
970                     LogEntry entry2 = (LogEntry) e2;
971                     return getComparator().compare(entry1.getMessage(), entry2.getMessage()) * MESSAGE_ORDER;
972                 }
973             };
974         } else {
975             return new ViewerComparator() {
976                 public int compare(Viewer viewer, Object JavaDoc e1, Object JavaDoc e2) {
977                     long date1 = ((LogEntry) e1).getDate().getTime();
978                     long date2 = ((LogEntry) e2).getDate().getTime();
979                     if (date1 == date2) {
980                         int result = fLogs.indexOf(e2) - fLogs.indexOf(e1);
981                         if (DATE_ORDER == DESCENDING)
982                             result *= DESCENDING;
983                         return result;
984                     }
985                     if (DATE_ORDER == DESCENDING)
986                         return date1 > date2 ? DESCENDING : ASCENDING;
987                         return date1 < date2 ? DESCENDING : ASCENDING;
988                 }
989             };
990         }
991     }
992
993     private void resetDialogButtons() {
994         ((EventDetailsDialogAction) fPropertiesAction).resetDialogButtons();
995     }
996
997     /**
998      * Returns the filter dialog settings object used to maintain
999      * state between filter dialogs
1000     * @return the dialog settings to be used
1001     */

1002    private IDialogSettings getLogSettings() {
1003        IDialogSettings settings= PDERuntimePlugin.getDefault().getDialogSettings();
1004        return settings.getSection(getClass().getName());
1005    }
1006
1007    /**
1008     * Returns the plugin preferences used to maintain
1009     * state of log view
1010     * @return the plugin preferences
1011     */

1012    private Preferences getLogPreferences(){
1013        return PDERuntimePlugin.getDefault().getPluginPreferences();
1014    }
1015
1016    private void readSettings(){
1017        IDialogSettings s = getLogSettings();
1018        Preferences p = getLogPreferences();
1019        if (s == null || p == null){
1020            initializeMemento();
1021            return;
1022        }
1023        try {
1024            fMemento.putString(P_USE_LIMIT, s.getBoolean(P_USE_LIMIT) ? "true":"false"); //$NON-NLS-1$ //$NON-NLS-2$
1025
fMemento.putString(P_LOG_INFO, s.getBoolean(P_LOG_INFO) ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
1026
fMemento.putString(P_LOG_WARNING, s.getBoolean(P_LOG_WARNING) ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
1027
fMemento.putString(P_LOG_ERROR, s.getBoolean(P_LOG_ERROR) ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
1028
fMemento.putString(P_SHOW_ALL_SESSIONS, s.getBoolean(P_SHOW_ALL_SESSIONS) ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
1029
fMemento.putInteger(P_LOG_LIMIT, s.getInt(P_LOG_LIMIT));
1030            fMemento.putInteger(P_COLUMN_1, p.getInt(P_COLUMN_1) > 0 ? p.getInt(P_COLUMN_1) : 300);
1031            fMemento.putInteger(P_COLUMN_2, p.getInt(P_COLUMN_2) > 0 ? p.getInt(P_COLUMN_2) : 150);
1032            fMemento.putInteger(P_COLUMN_3, p.getInt(P_COLUMN_3) > 0 ? p.getInt(P_COLUMN_3) : 150);
1033            fMemento.putString(P_ACTIVATE, p.getBoolean(P_ACTIVATE) ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
1034
int order = p.getInt(P_ORDER_VALUE);
1035            fMemento.putInteger(P_ORDER_VALUE, order == 0 ? DESCENDING : order);
1036            fMemento.putInteger(P_ORDER_TYPE, p.getInt(P_ORDER_TYPE));
1037        } catch (NumberFormatException JavaDoc e) {
1038            fMemento.putInteger(P_LOG_LIMIT, 50);
1039            fMemento.putInteger(P_COLUMN_1, 300);
1040            fMemento.putInteger(P_COLUMN_2, 150);
1041            fMemento.putInteger(P_COLUMN_3, 150);
1042            fMemento.putInteger(P_ORDER_TYPE, DATE);
1043            fMemento.putInteger(P_ORDER_VALUE, DESCENDING);
1044        }
1045    }
1046
1047    private void writeSettings(){
1048        writeViewSettings();
1049        writeFilterSettings();
1050    }
1051
1052    private void writeFilterSettings(){
1053        IDialogSettings settings = getLogSettings();
1054        if (settings == null)
1055            settings = PDERuntimePlugin.getDefault().getDialogSettings().addNewSection(getClass().getName());
1056        settings.put(P_USE_LIMIT, fMemento.getString(P_USE_LIMIT).equals("true")); //$NON-NLS-1$
1057
settings.put(P_LOG_LIMIT, fMemento.getInteger(P_LOG_LIMIT).intValue());
1058        settings.put(P_LOG_INFO, fMemento.getString(P_LOG_INFO).equals("true")); //$NON-NLS-1$
1059
settings.put(P_LOG_WARNING, fMemento.getString(P_LOG_WARNING).equals("true")); //$NON-NLS-1$
1060
settings.put(P_LOG_ERROR, fMemento.getString(P_LOG_ERROR).equals("true")); //$NON-NLS-1$
1061
settings.put(P_SHOW_ALL_SESSIONS, fMemento.getString(P_SHOW_ALL_SESSIONS).equals("true")); //$NON-NLS-1$
1062
}
1063
1064    private void writeViewSettings(){
1065        Preferences preferences = getLogPreferences();
1066        preferences.setValue(P_COLUMN_1, fMemento.getInteger(P_COLUMN_1).intValue());
1067        preferences.setValue(P_COLUMN_2, fMemento.getInteger(P_COLUMN_2).intValue());
1068        preferences.setValue(P_COLUMN_3, fMemento.getInteger(P_COLUMN_3).intValue());
1069        preferences.setValue(P_ACTIVATE, fMemento.getString(P_ACTIVATE).equals("true")); //$NON-NLS-1$
1070
int order = fMemento.getInteger(P_ORDER_VALUE).intValue();
1071        preferences.setValue(P_ORDER_VALUE, order == 0 ? DESCENDING : order);
1072        preferences.setValue(P_ORDER_TYPE, fMemento.getInteger(P_ORDER_TYPE).intValue());
1073    }
1074
1075    public void sortByDateDescending() {
1076        setColumnSorting(fColumn3, DESCENDING);
1077    }
1078    
1079    protected Job getOpenLogFileJob() {
1080        final Shell shell = getViewSite().getShell();
1081        return new Job(PDERuntimeMessages.OpenLogDialog_message) {
1082            protected IStatus run(IProgressMonitor monitor) {
1083                boolean failed = false;
1084                if (fInputFile.length() <= LogReader.MAX_FILE_LENGTH) {
1085                    failed = !Program.launch(fInputFile.getAbsolutePath());
1086                    if (failed) {
1087                        Program p = Program.findProgram(".txt"); //$NON-NLS-1$
1088
if (p != null) {
1089                            p.execute(fInputFile.getAbsolutePath());
1090                            return Status.OK_STATUS;
1091                        }
1092                    }
1093                }
1094                if (failed) {
1095                    final OpenLogDialog openDialog = new OpenLogDialog(shell, fInputFile);
1096                    Display.getDefault().asyncExec(new Runnable JavaDoc() {
1097                        public void run() {
1098                            openDialog.create();
1099                            openDialog.open();
1100                        }
1101                    });
1102                }
1103                return Status.OK_STATUS;
1104            }
1105        };
1106    }
1107    
1108    protected File JavaDoc getLogFile() {
1109        return fInputFile;
1110    }
1111}
1112
Popular Tags