01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.runtime.logview;
11:
12: import org.eclipse.core.filesystem.EFS;
13: import org.eclipse.core.filesystem.IFileStore;
14: import org.eclipse.core.runtime.IPath;
15: import org.eclipse.core.runtime.Path;
16: import org.eclipse.jface.action.Action;
17: import org.eclipse.pde.internal.runtime.PDERuntimePlugin;
18: import org.eclipse.ui.IWorkbenchPage;
19: import org.eclipse.ui.IWorkbenchWindow;
20: import org.eclipse.ui.PartInitException;
21: import org.eclipse.ui.ide.IDE;
22:
23: /*
24: * This action is used to Open the Log File from the LogView if both org.eclipse.ui.ide and
25: * org.eclipse.core.filesystem are available. If both plugins are resolved, we will open
26: * the log file through the IDE's file association preferences. Otherwise,
27: * LogView.getOpenLogJob() is called to open the file.
28: */
29: public class OpenIDELogFileAction extends Action {
30:
31: private LogView fView;
32:
33: public OpenIDELogFileAction(LogView logView) {
34: fView = logView;
35: }
36:
37: public void run() {
38: IPath logPath = new Path(fView.getLogFile().getAbsolutePath());
39: IFileStore fileStore = EFS.getLocalFileSystem().getStore(
40: logPath);
41: if (!fileStore.fetchInfo().isDirectory()
42: && fileStore.fetchInfo().exists()) {
43: IWorkbenchWindow ww = PDERuntimePlugin
44: .getActiveWorkbenchWindow();
45: IWorkbenchPage page = ww.getActivePage();
46: try {
47: IDE.openEditorOnFileStore(page, fileStore);
48: } catch (PartInitException e) {
49: }
50: }
51: }
52:
53: }
|