01: package org.drools.eclipse.debug.actions;
02:
03: import org.drools.eclipse.DroolsEclipsePlugin;
04: import org.drools.eclipse.DroolsPluginImages;
05: import org.drools.eclipse.debug.AuditView;
06: import org.eclipse.jface.action.Action;
07: import org.eclipse.jface.action.IAction;
08: import org.eclipse.swt.custom.BusyIndicator;
09: import org.eclipse.swt.widgets.FileDialog;
10:
11: /**
12: * Action to open a log.
13: *
14: * @author <a href="mailto:kris_verlaenen@hotmail.com">kris verlaenen </a>
15: */
16: public class OpenLogAction extends Action {
17:
18: private AuditView view;
19:
20: public OpenLogAction(AuditView view) {
21: super (null, IAction.AS_PUSH_BUTTON);
22: this .view = view;
23: setToolTipText("Open Log");
24: setImageDescriptor(DroolsPluginImages
25: .getImageDescriptor(DroolsPluginImages.OPEN_LOG));
26: setId(DroolsEclipsePlugin.getUniqueIdentifier()
27: + ".OpenLogAction");
28: }
29:
30: public void run() {
31: if (!view.isAvailable()) {
32: return;
33: }
34: FileDialog dialog = new FileDialog(view.getSite().getShell());
35: dialog.setFilterExtensions(new String[] { "*.log" });
36: String fileName = dialog.open();
37: view.setLogFile(fileName);
38: BusyIndicator.showWhile(view.getViewer().getControl()
39: .getDisplay(), new Runnable() {
40: public void run() {
41: view.getViewer().refresh();
42: }
43: });
44: }
45: }
|