|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2007 IBM Corporation and others. |
2 |
* Copyright (c) 2008 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 11-29
Link Here
|
| 11 |
*******************************************************************************/ |
11 |
*******************************************************************************/ |
| 12 |
package org.eclipse.ui.internal.views.log; |
12 |
package org.eclipse.ui.internal.views.log; |
| 13 |
|
13 |
|
|
|
14 |
import org.eclipse.core.runtime.*; |
| 14 |
import org.eclipse.jface.resource.ImageDescriptor; |
15 |
import org.eclipse.jface.resource.ImageDescriptor; |
| 15 |
import org.eclipse.jface.resource.ImageRegistry; |
16 |
import org.eclipse.jface.resource.ImageRegistry; |
|
|
17 |
import org.eclipse.ui.*; |
| 16 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
18 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
| 17 |
import org.osgi.framework.BundleContext; |
19 |
import org.osgi.framework.BundleContext; |
| 18 |
|
20 |
|
| 19 |
/** |
21 |
/** |
| 20 |
* The activator class controls the plug-in life cycle |
22 |
* The activator class controls the plug-in life cycle |
| 21 |
*/ |
23 |
*/ |
| 22 |
public class Activator extends AbstractUIPlugin { |
24 |
public class Activator extends AbstractUIPlugin implements ILogListener { |
| 23 |
|
25 |
|
| 24 |
// The plug-in ID |
26 |
// The plug-in ID |
| 25 |
public static final String PLUGIN_ID = "org.eclipse.ui.views.log"; //$NON-NLS-1$ |
27 |
public static final String PLUGIN_ID = "org.eclipse.ui.views.log"; //$NON-NLS-1$ |
| 26 |
|
28 |
|
|
|
29 |
public static final String EARLY_START_ENABLED = "earlyStartEnabled"; //$NON-NLS-1$ |
| 30 |
|
| 31 |
public static class Startup implements IStartup { |
| 32 |
|
| 33 |
public void earlyStartup() { |
| 34 |
// empty - all initialization is in Activator.start(BundleContext) |
| 35 |
} |
| 36 |
|
| 37 |
} |
| 38 |
|
| 27 |
// The shared instance |
39 |
// The shared instance |
| 28 |
private static Activator plugin; |
40 |
private static Activator plugin; |
| 29 |
|
41 |
|
|
Lines 40-45
Link Here
|
| 40 |
public void start(BundleContext context) throws Exception { |
52 |
public void start(BundleContext context) throws Exception { |
| 41 |
super.start(context); |
53 |
super.start(context); |
| 42 |
plugin = this; |
54 |
plugin = this; |
|
|
55 |
Platform.addLogListener(this); |
| 43 |
} |
56 |
} |
| 44 |
|
57 |
|
| 45 |
/* |
58 |
/* |
|
Lines 49-54
Link Here
|
| 49 |
public void stop(BundleContext context) throws Exception { |
62 |
public void stop(BundleContext context) throws Exception { |
| 50 |
plugin = null; |
63 |
plugin = null; |
| 51 |
super.stop(context); |
64 |
super.stop(context); |
|
|
65 |
Platform.removeLogListener(this); |
| 52 |
} |
66 |
} |
| 53 |
|
67 |
|
| 54 |
public static Activator getDefault() { |
68 |
public static Activator getDefault() { |
|
Lines 88-91
Link Here
|
| 88 |
return imageDescriptorFromPlugin(PLUGIN_ID, id); |
102 |
return imageDescriptorFromPlugin(PLUGIN_ID, id); |
| 89 |
} |
103 |
} |
| 90 |
|
104 |
|
|
|
105 |
public void logging(IStatus status, String plugin) { |
| 106 |
if (!getPluginPreferences().getBoolean(EARLY_START_ENABLED)) { |
| 107 |
return; |
| 108 |
} |
| 109 |
|
| 110 |
// initializes logview on first comming log entry |
| 111 |
final IWorkbench workbench = PlatformUI.getWorkbench(); |
| 112 |
workbench.getDisplay().asyncExec(new Runnable() { |
| 113 |
public void run() { |
| 114 |
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); |
| 115 |
if (window != null) { |
| 116 |
try { |
| 117 |
window.getActivePage().showView("org.eclipse.pde.runtime.LogView"); //$NON-NLS-1$ |
| 118 |
} catch (PartInitException e) { // empty |
| 119 |
} |
| 120 |
} |
| 121 |
} |
| 122 |
}); |
| 123 |
} |
| 91 |
} |
124 |
} |