KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > core > manipulation > JavaManipulationPlugin


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.jdt.internal.core.manipulation;
12
13 import org.eclipse.core.runtime.IStatus;
14 import org.eclipse.core.runtime.MultiStatus;
15 import org.eclipse.core.runtime.Plugin;
16 import org.eclipse.core.runtime.Status;
17
18 import org.eclipse.jdt.core.manipulation.JavaManipulation;
19
20 import org.osgi.framework.BundleContext;
21
22 /**
23  * The main plug-in class to be used in the workbench.
24  */

25 public class JavaManipulationPlugin extends Plugin {
26
27     //The shared instance.
28
private static JavaManipulationPlugin fgDefault;
29     
30     /**
31      * The constructor.
32      */

33     public JavaManipulationPlugin() {
34         fgDefault = this;
35     }
36
37     /**
38      * This method is called upon plug-in activation
39      */

40     public void start(BundleContext context) throws Exception JavaDoc {
41         super.start(context);
42     }
43
44     /**
45      * This method is called when the plug-in is stopped
46      */

47     public void stop(BundleContext context) throws Exception JavaDoc {
48         super.stop(context);
49         fgDefault = null;
50     }
51
52     /**
53      * Returns the shared instance.
54      *
55      * @return the shared instance.
56      */

57     public static JavaManipulationPlugin getDefault() {
58         return fgDefault;
59     }
60     
61     public static String JavaDoc getPluginId() {
62         return JavaManipulation.ID_PLUGIN;
63     }
64
65     public static void log(IStatus status) {
66         getDefault().getLog().log(status);
67     }
68     
69     public static void logErrorMessage(String JavaDoc message) {
70         log(new Status(IStatus.ERROR, getPluginId(), IStatusConstants.INTERNAL_ERROR, message, null));
71     }
72
73     public static void logErrorStatus(String JavaDoc message, IStatus status) {
74         if (status == null) {
75             logErrorMessage(message);
76             return;
77         }
78         MultiStatus multi= new MultiStatus(getPluginId(), IStatusConstants.INTERNAL_ERROR, message, null);
79         multi.add(status);
80         log(multi);
81     }
82     
83     public static void log(Throwable JavaDoc e) {
84         log(new Status(IStatus.ERROR, getPluginId(), IStatusConstants.INTERNAL_ERROR, JavaManipulationMessages.JavaManipulationMessages_internalError, e));
85     }
86 }
87
Popular Tags