]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - base/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/ui/ArgeoUiPlugin.java
2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.eclipse
.ui
;
18 import org
.apache
.commons
.logging
.Log
;
19 import org
.apache
.commons
.logging
.LogFactory
;
20 import org
.eclipse
.core
.runtime
.ILogListener
;
21 import org
.eclipse
.core
.runtime
.IStatus
;
22 import org
.eclipse
.core
.runtime
.Platform
;
23 import org
.eclipse
.ui
.plugin
.AbstractUIPlugin
;
24 import org
.osgi
.framework
.BundleContext
;
27 * The activator class controls the plug-in life cycle
29 public class ArgeoUiPlugin
extends AbstractUIPlugin
implements ILogListener
{
30 public static final String PLUGIN_ID
= "org.argeo.eclipse.ui";
31 private final static Log log
= LogFactory
.getLog(ArgeoUiPlugin
.class);
32 // The shared instance
33 private static ArgeoUiPlugin plugin
;
35 public void start(BundleContext context
) throws Exception
{
37 // weirdly, the start method is called twice...
40 Platform
.addLogListener(this);
41 log
.debug("Eclipse logging now directed to standard logging");
45 public void stop(BundleContext context
) throws Exception
{
47 // weirdly, the stop method is called twice...
49 Platform
.removeLogListener(this);
50 log
.debug("Eclipse logging not directed anymore to standard logging");
58 /** Returns the shared instance */
59 public static ArgeoUiPlugin
getDefault() {
63 public void logging(IStatus status
, String plugin
) {
64 Log pluginLog
= LogFactory
.getLog(plugin
);
65 Integer severity
= status
.getSeverity();
66 if (severity
== IStatus
.ERROR
)
67 pluginLog
.error(status
.getMessage(), status
.getException());
68 else if (severity
== IStatus
.WARNING
)
69 pluginLog
.warn(status
.getMessage(), status
.getException());
70 else if (severity
== IStatus
.INFO
)
71 pluginLog
.info(status
.getMessage(), status
.getException());
72 else if (severity
== IStatus
.CANCEL
)
73 if (pluginLog
.isDebugEnabled())
74 pluginLog
.debug(status
.getMessage(), status
.getException());