1 package org.dbe.studio.tools.sdlCompiler2Java.plugin;
2
3 import java.io.BufferedInputStream;
4 import java.io.ByteArrayOutputStream;
5 import java.io.IOException;
6 import java.io.InputStream;
7 import java.net.URL;
8
9 import org.dbe.studio.tools.sdlCompiler2Java.Sdl2JavaException;
10 import org.dbe.studio.tools.sdlCompiler2Java.Sdl2JavaMessages;
11 import org.eclipse.ui.plugin.*;
12 import org.eclipse.jface.dialogs.MessageDialog;
13 import org.eclipse.jface.resource.ImageDescriptor;
14 import org.osgi.framework.BundleContext;
15
16 /***
17 * The main plugin class to be used in the desktop.
18 */
19 public class SdlCompiler2JavaPlugin extends AbstractUIPlugin {
20
21
22 private static SdlCompiler2JavaPlugin plugin;
23
24 /***
25 * The constructor.
26 */
27 public SdlCompiler2JavaPlugin() {
28 plugin = this;
29 }
30
31 /***
32 * This method is called upon plug-in activation
33 */
34 public void start(BundleContext context) throws Exception {
35 super.start(context);
36 }
37
38 /***
39 * This method is called when the plug-in is stopped
40 */
41 public void stop(BundleContext context) throws Exception {
42 super.stop(context);
43 plugin = null;
44 }
45
46 /***
47 * Returns the shared instance.
48 */
49 public static SdlCompiler2JavaPlugin getDefault() {
50 return plugin;
51 }
52
53 /***
54 * Returns an image descriptor for the image file at the given
55 * plug-in relative path.
56 *
57 * @param path the path
58 * @return the image descriptor
59 */
60 public static ImageDescriptor getImageDescriptor(String path) {
61 return AbstractUIPlugin.imageDescriptorFromPlugin("org.dbe.studio.tools.sdlCompiler2Java.plugin.SdlCompiler2JavaPlugin", path);
62 }
63
64 /***
65 *
66 * @param sFileName
67 * @return the URL where the file is located
68 */
69
70
71
72
73
74
75
76
77
78
79
80
81
82 /***
83 *
84 * @param fileName
85 * @return the context of a file as String
86 * @throws Exception
87 */
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122 public static String getXSLContent (String fileName) throws Exception {
123
124 ClassLoader loader = getDefault().getClass().getClassLoader();
125 InputStream is = loader.getResourceAsStream(fileName);
126
127 ByteArrayOutputStream baos = new ByteArrayOutputStream(10000);
128 byte[] b = new byte[4096];
129 int nb;
130 while ( (nb = is.read(b)) != -1 ) {
131 baos.write(b, 0, nb);
132 }
133
134 return baos.toString();
135 }
136
137
138
139
140
141
142
143
144
145
146
147
148 }