KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 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 package org.eclipse.pde.internal.runtime.logview;
12
13 import org.eclipse.core.filesystem.EFS;
14 import org.eclipse.core.filesystem.IFileStore;
15 import org.eclipse.core.runtime.IPath;
16 import org.eclipse.core.runtime.Path;
17 import org.eclipse.jface.action.Action;
18 import org.eclipse.pde.internal.runtime.PDERuntimePlugin;
19 import org.eclipse.ui.IWorkbenchPage;
20 import org.eclipse.ui.IWorkbenchWindow;
21 import org.eclipse.ui.PartInitException;
22 import org.eclipse.ui.ide.IDE;
23
24 /*
25  * This action is used to Open the Log File from the LogView if both org.eclipse.ui.ide and
26  * org.eclipse.core.filesystem are available. If both plugins are resolved, we will open
27  * the log file through the IDE's file association preferences. Otherwise,
28  * LogView.getOpenLogJob() is called to open the file.
29  */

30 public class OpenIDELogFileAction extends Action {
31     
32     private LogView fView;
33     
34     public OpenIDELogFileAction (LogView logView) {
35         fView = logView;
36     }
37
38     public void run() {
39         IPath logPath = new Path(fView.getLogFile().getAbsolutePath());
40         IFileStore fileStore= EFS.getLocalFileSystem().getStore(logPath);
41         if (!fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists()) {
42             IWorkbenchWindow ww = PDERuntimePlugin.getActiveWorkbenchWindow();
43             IWorkbenchPage page = ww.getActivePage();
44             try {
45                 IDE.openEditorOnFileStore(page, fileStore);
46             } catch (PartInitException e) {
47             }
48         }
49     }
50
51 }
52
Popular Tags