KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > visualcontent > repository > remoterep > Model3JackrabbitRepositoryPlugin


1 /**
2  * VC Browser - Visualizes the content of a JSR 170 compatible repository
3  * Copyright (C) 2006 Sandro Böhme
4  *
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.visualcontent.repository.remoterep;
19
20 import org.eclipse.ui.PlatformUI;
21 import org.eclipse.ui.plugin.*;
22 import org.eclipse.core.runtime.IStatus;
23 import org.eclipse.core.runtime.Status;
24 import org.eclipse.jface.dialogs.ErrorDialog;
25 import org.eclipse.jface.resource.ImageDescriptor;
26 import org.osgi.framework.BundleContext;
27
28 /**
29  * The main plugin class to be used in the desktop.
30  */

31 public class Model3JackrabbitRepositoryPlugin extends AbstractUIPlugin {
32
33     //The shared instance.
34
private static Model3JackrabbitRepositoryPlugin plugin;
35     
36     /**
37      * The constructor.
38      */

39     public Model3JackrabbitRepositoryPlugin() {
40         plugin = this;
41     }
42
43     public void log(String JavaDoc message, Throwable JavaDoc t){
44
45         IStatus status = getErrorStatus(message, t);
46         this.getLog().log(status);
47     }
48
49     private IStatus getErrorStatus(String JavaDoc message, Throwable JavaDoc t) {
50         IStatus status = new Status(
51                 Status.ERROR,
52                 this.getBundle().getSymbolicName(),
53                 Status.OK,
54                 message,
55                 t);
56         return status;
57     }
58
59     public void showError(String JavaDoc message, Throwable JavaDoc t){
60         this.log(message,t);
61         IStatus status = getErrorStatus(message, t);
62         //Display.getDefault().getActiveShell();
63
ErrorDialog.openError(
64                         PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
65                         null,
66                         null,
67                         status);
68     }
69     /**
70      * This method is called upon plug-in activation
71      */

72     public void start(BundleContext context) throws Exception JavaDoc {
73         super.start(context);
74     }
75
76     /**
77      * This method is called when the plug-in is stopped
78      */

79     public void stop(BundleContext context) throws Exception JavaDoc {
80         super.stop(context);
81         plugin = null;
82     }
83
84     /**
85      * Returns the shared instance.
86      */

87     public static Model3JackrabbitRepositoryPlugin getDefault() {
88         return plugin;
89     }
90
91     /**
92      * Returns an image descriptor for the image file at the given
93      * plug-in relative path.
94      *
95      * @param path the path
96      * @return the image descriptor
97      */

98     public static ImageDescriptor getImageDescriptor(String JavaDoc path) {
99         return AbstractUIPlugin.imageDescriptorFromPlugin("org.visualcontent.repository.remoterep", path);
100     }
101 }
102
Popular Tags