KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > wizards > site > NewSiteProjectCreationOperation


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 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.pde.internal.ui.wizards.site;
12
13 import java.io.ByteArrayInputStream JavaDoc;
14 import java.io.PrintWriter JavaDoc;
15 import java.io.StringWriter JavaDoc;
16 import java.lang.reflect.InvocationTargetException JavaDoc;
17
18 import org.eclipse.core.resources.IFile;
19 import org.eclipse.core.resources.IProject;
20 import org.eclipse.core.runtime.CoreException;
21 import org.eclipse.core.runtime.IPath;
22 import org.eclipse.core.runtime.IProgressMonitor;
23 import org.eclipse.jface.viewers.ISelection;
24 import org.eclipse.jface.viewers.StructuredSelection;
25 import org.eclipse.pde.internal.core.natures.PDE;
26 import org.eclipse.pde.internal.core.site.WorkspaceSiteModel;
27 import org.eclipse.pde.internal.core.util.CoreUtility;
28 import org.eclipse.pde.internal.ui.IPDEUIConstants;
29 import org.eclipse.pde.internal.ui.PDEPlugin;
30 import org.eclipse.pde.internal.ui.PDEUIMessages;
31 import org.eclipse.swt.widgets.Display;
32 import org.eclipse.ui.IWorkbenchPage;
33 import org.eclipse.ui.IWorkbenchPart;
34 import org.eclipse.ui.IWorkbenchWindow;
35 import org.eclipse.ui.PartInitException;
36 import org.eclipse.ui.actions.WorkspaceModifyOperation;
37 import org.eclipse.ui.ide.IDE;
38 import org.eclipse.ui.part.FileEditorInput;
39 import org.eclipse.ui.part.ISetSelectionTarget;
40
41
42 public class NewSiteProjectCreationOperation extends WorkspaceModifyOperation {
43     private Display fDisplay;
44     private IProject fProject;
45     private IPath fPath;
46     private String JavaDoc fWebLocation;
47     
48     public NewSiteProjectCreationOperation(Display display, IProject project, IPath path, String JavaDoc webLocation) {
49         fDisplay = display;
50         fProject = project;
51         fPath = path;
52         fWebLocation = webLocation;
53     }
54
55     /* (non-Javadoc)
56      * @see org.eclipse.ui.actions.WorkspaceModifyOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
57      */

58     protected void execute(IProgressMonitor monitor) throws CoreException,
59             InvocationTargetException JavaDoc, InterruptedException JavaDoc {
60         int numUnits = fWebLocation == null ? 3 : 4;
61         
62         monitor.beginTask(PDEUIMessages.NewSiteWizard_creatingProject, numUnits);
63
64         CoreUtility.createProject(fProject, fPath, monitor);
65         fProject.open(monitor);
66         CoreUtility.addNatureToProject(fProject, PDE.SITE_NATURE, monitor);
67         monitor.worked(1);
68         
69         if (fWebLocation != null){
70             CoreUtility.createFolder(fProject.getFolder(fWebLocation));
71             createXSLFile();
72             createCSSFile();
73             createHTMLFile();
74             monitor.worked(1);
75         }
76     
77         monitor.subTask(PDEUIMessages.NewSiteWizard_creatingManifest);
78         IFile file = createSiteManifest();
79         monitor.worked(1);
80         
81         openFile(file);
82         monitor.worked(1);
83         
84     }
85
86     private IFile createSiteManifest() throws CoreException {
87         IFile file = fProject.getFile("site.xml"); //$NON-NLS-1$
88
if (file.exists()) return file;
89         
90         WorkspaceSiteModel model = new WorkspaceSiteModel(file);
91         model.getSite();
92         // Save the model
93
model.save();
94         model.dispose();
95         // Set the default editor
96
IDE.setDefaultEditor(file, IPDEUIConstants.SITE_EDITOR_ID);
97         return file;
98     }
99     
100     private void openFile(final IFile file) {
101         fDisplay.asyncExec(new Runnable JavaDoc() {
102             public void run() {
103                 IWorkbenchWindow ww = PDEPlugin.getActiveWorkbenchWindow();
104                 if (ww == null) {
105                     return;
106                 }
107                 IWorkbenchPage page = ww.getActivePage();
108                 if (page == null || !file.exists())
109                     return;
110                 IWorkbenchPart focusPart = page.getActivePart();
111                 if (focusPart instanceof ISetSelectionTarget) {
112                     ISelection selection = new StructuredSelection(file);
113                     ((ISetSelectionTarget) focusPart).selectReveal(selection);
114                 }
115                 try {
116                     page.openEditor(new FileEditorInput(file),
117                             IPDEUIConstants.SITE_EDITOR_ID);
118                 } catch (PartInitException e) {
119                 }
120             }
121         });
122     }
123
124     private void createHTMLFile(){
125         StringWriter JavaDoc swriter = new StringWriter JavaDoc();
126         PrintWriter JavaDoc writer = new PrintWriter JavaDoc(swriter);
127         
128         writer.println("<html>"); //$NON-NLS-1$
129
writer.println("<head>"); //$NON-NLS-1$
130
writer.println("<title>"+fProject.getName()+"</title>"); //$NON-NLS-1$ //$NON-NLS-2$
131
writer.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">"); //$NON-NLS-1$
132
writer.println("<style>@import url(\""+fWebLocation+"/site.css\");</style>"); //$NON-NLS-1$ //$NON-NLS-2$
133
writer.println("<script type=\"text/javascript\">"); //$NON-NLS-1$
134
writer.println(" var returnval = 0;"); //$NON-NLS-1$
135
writer.println(" var stylesheet, xmlFile, cache, doc;"); //$NON-NLS-1$
136
writer.println(" function init(){"); //$NON-NLS-1$
137
writer.println(" // NSCP 7.1+ / Mozilla 1.4.1+ / Safari"); //$NON-NLS-1$
138
writer.println(" // Use the standard DOM Level 2 technique, if it is supported"); //$NON-NLS-1$
139
writer.println(" if (document.implementation && document.implementation.createDocument) {"); //$NON-NLS-1$
140
writer.println(" xmlFile = document.implementation.createDocument(\"\", \"\", null);"); //$NON-NLS-1$
141
writer.println(" stylesheet = document.implementation.createDocument(\"\", \"\", null);"); //$NON-NLS-1$
142
writer.println(" if (xmlFile.load){"); //$NON-NLS-1$
143
writer.println(" xmlFile.load(\"site.xml\");"); //$NON-NLS-1$
144
writer.println(" stylesheet.load(\""+fWebLocation+"/site.xsl\");"); //$NON-NLS-1$ //$NON-NLS-2$
145
writer.println(" } else {"); //$NON-NLS-1$
146
writer.println(" alert(\"" + PDEUIMessages.SiteHTML_loadError + "\");"); //$NON-NLS-1$ //$NON-NLS-2$
147
writer.println(" }"); //$NON-NLS-1$
148
writer.println(" xmlFile.addEventListener(\"load\", transform, false);"); //$NON-NLS-1$
149
writer.println(" stylesheet.addEventListener(\"load\", transform, false);"); //$NON-NLS-1$
150
writer.println(" }"); //$NON-NLS-1$
151
writer.println(" //IE 6.0+ solution"); //$NON-NLS-1$
152
writer.println(" else if (window.ActiveXObject) {"); //$NON-NLS-1$
153
writer.println(" xmlFile = new ActiveXObject(\"msxml2.DOMDocument.3.0\");"); //$NON-NLS-1$
154
writer.println(" xmlFile.async = false;"); //$NON-NLS-1$
155
writer.println(" xmlFile.load(\"site.xml\");"); //$NON-NLS-1$
156
writer.println(" stylesheet = new ActiveXObject(\"msxml2.FreeThreadedDOMDocument.3.0\");"); //$NON-NLS-1$
157
writer.println(" stylesheet.async = false;"); //$NON-NLS-1$
158
writer.println(" stylesheet.load(\""+fWebLocation+"/site.xsl\");"); //$NON-NLS-1$ //$NON-NLS-2$
159
writer.println(" cache = new ActiveXObject(\"msxml2.XSLTemplate.3.0\");"); //$NON-NLS-1$
160
writer.println(" cache.stylesheet = stylesheet;"); //$NON-NLS-1$
161
writer.println(" transformData();"); //$NON-NLS-1$
162
writer.println(" }"); //$NON-NLS-1$
163
writer.println(" }"); //$NON-NLS-1$
164
writer.println(" // separate transformation function for IE 6.0+"); //$NON-NLS-1$
165
writer.println(" function transformData(){"); //$NON-NLS-1$
166
writer.println(" var processor = cache.createProcessor();"); //$NON-NLS-1$
167
writer.println(" processor.input = xmlFile;"); //$NON-NLS-1$
168
writer.println(" processor.transform();"); //$NON-NLS-1$
169
writer.println(" data.innerHTML = processor.output;"); //$NON-NLS-1$
170
writer.println(" }"); //$NON-NLS-1$
171
writer.println(" // separate transformation function for NSCP 7.1+ and Mozilla 1.4.1+ "); //$NON-NLS-1$
172
writer.println(" function transform(){"); //$NON-NLS-1$
173
writer.println(" returnval+=1;"); //$NON-NLS-1$
174
writer.println(" if (returnval==2){"); //$NON-NLS-1$
175
writer.println(" var processor = new XSLTProcessor();"); //$NON-NLS-1$
176
writer.println(" processor.importStylesheet(stylesheet); "); //$NON-NLS-1$
177
writer.println(" doc = processor.transformToDocument(xmlFile);"); //$NON-NLS-1$
178
writer.println(" document.getElementById(\"data\").innerHTML = doc.documentElement.innerHTML;"); //$NON-NLS-1$
179
writer.println(" }"); //$NON-NLS-1$
180
writer.println(" }"); //$NON-NLS-1$
181
writer.println("</script>"); //$NON-NLS-1$
182
writer.println("</head>"); //$NON-NLS-1$
183
writer.println("<body onload=\"init();\">"); //$NON-NLS-1$
184
writer.println("<!--[insert static HTML here]-->"); //$NON-NLS-1$
185
writer.println("<div id=\"data\"><!-- this is where the transformed data goes --></div>"); //$NON-NLS-1$
186
writer.println("</body>"); //$NON-NLS-1$
187
writer.println("</html>"); //$NON-NLS-1$
188

189         writer.flush();
190         writeFile(fProject.getFile("index.html"), swriter); //$NON-NLS-1$
191
}
192         
193     private void createCSSFile(){
194         StringWriter JavaDoc swriter = new StringWriter JavaDoc();
195         PrintWriter JavaDoc writer = new PrintWriter JavaDoc(swriter);
196         writer.println("<STYLE type=\"text/css\">"); //$NON-NLS-1$
197
writer.println("td.spacer {padding-bottom: 10px; padding-top: 10px;}"); //$NON-NLS-1$
198
writer.println(".title { font-family: sans-serif; color: #99AACC;}"); //$NON-NLS-1$
199
writer.println(".bodyText { font-family: sans-serif; font-size: 9pt; color:#000000; }"); //$NON-NLS-1$
200
writer.println(".sub-header { font-family: sans-serif; font-style: normal; font-weight: bold; font-size: 9pt; color: white;}"); //$NON-NLS-1$
201
writer.println(".log-text {font-family: sans-serif; font-style: normal; font-weight: lighter; font-size: 8pt; color:black;}"); //$NON-NLS-1$
202
writer.println(".big-header { font-family: sans-serif; font-style: normal; font-weight: bold; font-size: 9pt; color: white; border-top:10px solid white;}"); //$NON-NLS-1$
203
writer.println(".light-row {background:#FFFFFF}"); //$NON-NLS-1$
204
writer.println(".dark-row {background:#EEEEFF}"); //$NON-NLS-1$
205
writer.println(".header {background:#99AADD}"); //$NON-NLS-1$
206
writer.println("#indent {word-wrap : break-word;width :300px;text-indent:10px;}"); //$NON-NLS-1$
207
writer.println("</STYLE>"); //$NON-NLS-1$
208

209         writer.flush();
210         writeFile(fProject.getFile(fWebLocation + "/site.css"), swriter); //$NON-NLS-1$
211
}
212
213     private void createXSLFile(){
214         StringWriter JavaDoc swriter = new StringWriter JavaDoc();
215         PrintWriter JavaDoc writer = new PrintWriter JavaDoc(swriter);
216         writer.println("<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\">"); //$NON-NLS-1$
217
writer.println("<xsl:output method=\"html\" encoding=\"UTF-8\"/>"); //$NON-NLS-1$
218
writer.println("<xsl:key name=\"cat\" match=\"category\" use=\"@name\"/>"); //$NON-NLS-1$
219
writer.println("<xsl:template match=\"/\">"); //$NON-NLS-1$
220
writer.println("<xsl:for-each select=\"site\">"); //$NON-NLS-1$
221
writer.println(" <html>"); //$NON-NLS-1$
222
writer.println(" <head>"); //$NON-NLS-1$
223
writer.println(" <title>"+fProject.getName()+"</title>"); //$NON-NLS-1$ //$NON-NLS-2$
224
writer.println(" <style>@import url(\"" + fWebLocation + "/site.css\");</style>"); //$NON-NLS-1$ //$NON-NLS-2$
225
writer.println(" </head>"); //$NON-NLS-1$
226
writer.println(" <body>"); //$NON-NLS-1$
227
writer.println(" <h1 class=\"title\">" + fProject.getName() +"</h1>"); //$NON-NLS-1$ //$NON-NLS-2$
228
writer.println(" <p class=\"bodyText\"><xsl:value-of select=\"description\"/></p>"); //$NON-NLS-1$
229
writer.println(" <table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"2\">"); //$NON-NLS-1$
230
writer.println(" <xsl:for-each select=\"category-def\">"); //$NON-NLS-1$
231
writer.println(" <xsl:sort select=\"@label\" order=\"ascending\" case-order=\"upper-first\"/>"); //$NON-NLS-1$
232
writer.println(" <xsl:sort select=\"@name\" order=\"ascending\" case-order=\"upper-first\"/>"); //$NON-NLS-1$
233
writer.println(" <xsl:if test=\"count(key('cat',@name)) != 0\">"); //$NON-NLS-1$
234
writer.println(" <tr class=\"header\">"); //$NON-NLS-1$
235
writer.println(" <td class=\"sub-header\" width=\"30%\">"); //$NON-NLS-1$
236
writer.println(" <xsl:value-of select=\"@name\"/>"); //$NON-NLS-1$
237
writer.println(" </td>"); //$NON-NLS-1$
238
writer.println(" <td class=\"sub-header\" width=\"70%\">"); //$NON-NLS-1$
239
writer.println(" <xsl:value-of select=\"@label\"/>"); //$NON-NLS-1$
240
writer.println(" </td>"); //$NON-NLS-1$
241
writer.println(" </tr>"); //$NON-NLS-1$
242
writer.println(" <xsl:for-each select=\"key('cat',@name)\">"); //$NON-NLS-1$
243
writer.println(" <xsl:sort select=\"ancestor::feature//@version\" order=\"ascending\"/>"); //$NON-NLS-1$
244
writer.println(" <xsl:sort select=\"ancestor::feature//@id\" order=\"ascending\" case-order=\"upper-first\"/>"); //$NON-NLS-1$
245
writer.println(" <tr>"); //$NON-NLS-1$
246
writer.println(" <xsl:choose>"); //$NON-NLS-1$
247
writer.println(" <xsl:when test=\"(position() mod 2 = 1)\">"); //$NON-NLS-1$
248
writer.println(" <xsl:attribute name=\"class\">dark-row</xsl:attribute>"); //$NON-NLS-1$
249
writer.println(" </xsl:when>"); //$NON-NLS-1$
250
writer.println(" <xsl:otherwise>"); //$NON-NLS-1$
251
writer.println(" <xsl:attribute name=\"class\">light-row</xsl:attribute>"); //$NON-NLS-1$
252
writer.println(" </xsl:otherwise>"); //$NON-NLS-1$
253
writer.println(" </xsl:choose>"); //$NON-NLS-1$
254
writer.println(" <td class=\"log-text\" id=\"indent\">"); //$NON-NLS-1$
255
writer.println(" <xsl:choose>"); //$NON-NLS-1$
256
writer.println(" <xsl:when test=\"ancestor::feature//@label\">"); //$NON-NLS-1$
257
writer.println(" <a HREF=\"{ancestor::feature//@url}\"><xsl:value-of select=\"ancestor::feature//@label\"/></a>"); //$NON-NLS-1$
258
writer.println(" <br/>"); //$NON-NLS-1$
259
writer.println(" <div id=\"indent\">"); //$NON-NLS-1$
260
writer.println(" (<xsl:value-of select=\"ancestor::feature//@id\"/> - <xsl:value-of select=\"ancestor::feature//@version\"/>)"); //$NON-NLS-1$
261
writer.println(" </div>"); //$NON-NLS-1$
262
writer.println(" </xsl:when>"); //$NON-NLS-1$
263
writer.println(" <xsl:otherwise>"); //$NON-NLS-1$
264
writer.println(" <a HREF=\"{ancestor::feature//@url}\"><xsl:value-of select=\"ancestor::feature//@id\"/> - <xsl:value-of select=\"ancestor::feature//@version\"/></a>"); //$NON-NLS-1$
265
writer.println(" </xsl:otherwise>"); //$NON-NLS-1$
266
writer.println(" </xsl:choose>"); //$NON-NLS-1$
267
writer.println(" <br />"); //$NON-NLS-1$
268
writer.println(" </td>"); //$NON-NLS-1$
269
writer.println(" <td>"); //$NON-NLS-1$
270
writer.println(" <table>"); //$NON-NLS-1$
271
writer.println(" <xsl:if test=\"ancestor::feature//@os\">"); //$NON-NLS-1$
272
writer.println(" <tr><td class=\"log-text\" id=\"indent\">Operating Systems:</td>"); //$NON-NLS-1$
273
writer.println(" <td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"ancestor::feature//@os\"/></td>"); //$NON-NLS-1$
274
writer.println(" </tr>"); //$NON-NLS-1$
275
writer.println(" </xsl:if>"); //$NON-NLS-1$
276
writer.println(" <xsl:if test=\"ancestor::feature//@ws\">"); //$NON-NLS-1$
277
writer.println(" <tr><td class=\"log-text\" id=\"indent\">Windows Systems:</td>"); //$NON-NLS-1$
278
writer.println(" <td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"ancestor::feature//@ws\"/></td>"); //$NON-NLS-1$
279
writer.println(" </tr>"); //$NON-NLS-1$
280
writer.println(" </xsl:if>"); //$NON-NLS-1$
281
writer.println(" <xsl:if test=\"ancestor::feature//@nl\">"); //$NON-NLS-1$
282
writer.println(" <tr><td class=\"log-text\" id=\"indent\">Languages:</td>"); //$NON-NLS-1$
283
writer.println(" <td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"ancestor::feature//@nl\"/></td>"); //$NON-NLS-1$
284
writer.println(" </tr>"); //$NON-NLS-1$
285
writer.println(" </xsl:if>"); //$NON-NLS-1$
286
writer.println(" <xsl:if test=\"ancestor::feature//@arch\">"); //$NON-NLS-1$
287
writer.println(" <tr><td class=\"log-text\" id=\"indent\">Architecture:</td>"); //$NON-NLS-1$
288
writer.println(" <td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"ancestor::feature//@arch\"/></td>"); //$NON-NLS-1$
289
writer.println(" </tr>"); //$NON-NLS-1$
290
writer.println(" </xsl:if>"); //$NON-NLS-1$
291
writer.println(" </table>"); //$NON-NLS-1$
292
writer.println(" </td>"); //$NON-NLS-1$
293
writer.println(" </tr>"); //$NON-NLS-1$
294
writer.println(" </xsl:for-each>"); //$NON-NLS-1$
295
writer.println(" <tr><td class=\"spacer\"><br/></td><td class=\"spacer\"><br/></td></tr>"); //$NON-NLS-1$
296
writer.println(" </xsl:if>"); //$NON-NLS-1$
297
writer.println(" </xsl:for-each>"); //$NON-NLS-1$
298
writer.println(" <xsl:if test=\"count(feature) &gt; count(feature/category)\">"); //$NON-NLS-1$
299
writer.println(" <tr class=\"header\">"); //$NON-NLS-1$
300
writer.println(" <td class=\"sub-header\" colspan=\"2\">"); //$NON-NLS-1$
301
writer.println(" Uncategorized"); //$NON-NLS-1$
302
writer.println(" </td>"); //$NON-NLS-1$
303
writer.println(" </tr>"); //$NON-NLS-1$
304
writer.println(" </xsl:if>"); //$NON-NLS-1$
305
writer.println(" <xsl:choose>"); //$NON-NLS-1$
306
writer.println(" <xsl:when test=\"function-available('msxsl:node-set')\">"); //$NON-NLS-1$
307
writer.println(" <xsl:variable name=\"rtf-nodes\">"); //$NON-NLS-1$
308
writer.println(" <xsl:for-each select=\"feature[not(category)]\">"); //$NON-NLS-1$
309
writer.println(" <xsl:sort select=\"@id\" order=\"ascending\" case-order=\"upper-first\"/>"); //$NON-NLS-1$
310
writer.println(" <xsl:sort select=\"@version\" order=\"ascending\" />"); //$NON-NLS-1$
311
writer.println(" <xsl:value-of select=\".\"/>"); //$NON-NLS-1$
312
writer.println(" <xsl:copy-of select=\".\" />"); //$NON-NLS-1$
313
writer.println(" </xsl:for-each>"); //$NON-NLS-1$
314
writer.println(" </xsl:variable>"); //$NON-NLS-1$
315
writer.println(" <xsl:variable name=\"myNodeSet\" select=\"msxsl:node-set($rtf-nodes)/*\"/>"); //$NON-NLS-1$
316
writer.println(" <xsl:for-each select=\"$myNodeSet\">"); //$NON-NLS-1$
317
writer.println(" <tr>"); //$NON-NLS-1$
318
writer.println(" <xsl:choose>"); //$NON-NLS-1$
319
writer.println(" <xsl:when test=\"position() mod 2 = 1\">"); //$NON-NLS-1$
320
writer.println(" <xsl:attribute name=\"class\">dark-row</xsl:attribute>"); //$NON-NLS-1$
321
writer.println(" </xsl:when>"); //$NON-NLS-1$
322
writer.println(" <xsl:otherwise>"); //$NON-NLS-1$
323
writer.println(" <xsl:attribute name=\"class\">light-row</xsl:attribute>"); //$NON-NLS-1$
324
writer.println(" </xsl:otherwise>"); //$NON-NLS-1$
325
writer.println(" </xsl:choose>"); //$NON-NLS-1$
326
writer.println(" <td class=\"log-text\" id=\"indent\">"); //$NON-NLS-1$
327
writer.println(" <xsl:choose>"); //$NON-NLS-1$
328
writer.println(" <xsl:when test=\"@label\">"); //$NON-NLS-1$
329
writer.println(" <a HREF=\"{@url}\"><xsl:value-of select=\"@label\"/></a>"); //$NON-NLS-1$
330
writer.println(" <br />"); //$NON-NLS-1$
331
writer.println(" <div id=\"indent\">"); //$NON-NLS-1$
332
writer.println(" (<xsl:value-of select=\"@id\"/> - <xsl:value-of select=\"@version\"/>)"); //$NON-NLS-1$
333
writer.println(" </div>"); //$NON-NLS-1$
334
writer.println(" </xsl:when>"); //$NON-NLS-1$
335
writer.println(" <xsl:otherwise>"); //$NON-NLS-1$
336
writer.println(" <a HREF=\"{@url}\"><xsl:value-of select=\"@id\"/> - <xsl:value-of select=\"@version\"/></a>"); //$NON-NLS-1$
337
writer.println(" </xsl:otherwise>"); //$NON-NLS-1$
338
writer.println(" </xsl:choose>"); //$NON-NLS-1$
339
writer.println(" <br /><br />"); //$NON-NLS-1$
340
writer.println(" </td>"); //$NON-NLS-1$
341
writer.println(" <td>"); //$NON-NLS-1$
342
writer.println(" <table>"); //$NON-NLS-1$
343
writer.println(" <xsl:if test=\"@os\">"); //$NON-NLS-1$
344
writer.println(" <tr><td class=\"log-text\" id=\"indent\">Operating Systems:</td>"); //$NON-NLS-1$
345
writer.println(" <td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"@os\"/></td>"); //$NON-NLS-1$
346
writer.println(" </tr>"); //$NON-NLS-1$
347
writer.println(" </xsl:if>"); //$NON-NLS-1$
348
writer.println(" <xsl:if test=\"@ws\">"); //$NON-NLS-1$
349
writer.println(" <tr><td class=\"log-text\" id=\"indent\">Windows Systems:</td>"); //$NON-NLS-1$
350
writer.println(" <td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"@ws\"/></td>"); //$NON-NLS-1$
351
writer.println(" </tr>"); //$NON-NLS-1$
352
writer.println(" </xsl:if>"); //$NON-NLS-1$
353
writer.println(" <xsl:if test=\"@nl\">"); //$NON-NLS-1$
354
writer.println(" <tr><td class=\"log-text\" id=\"indent\">Languages:</td>"); //$NON-NLS-1$
355
writer.println(" <td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"@nl\"/></td>"); //$NON-NLS-1$
356
writer.println(" </tr>"); //$NON-NLS-1$
357
writer.println(" </xsl:if>"); //$NON-NLS-1$
358
writer.println(" <xsl:if test=\"@arch\">"); //$NON-NLS-1$
359
writer.println(" <tr><td class=\"log-text\" id=\"indent\">Architecture:</td>"); //$NON-NLS-1$
360
writer.println(" <td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"@arch\"/></td>"); //$NON-NLS-1$
361
writer.println(" </tr>"); //$NON-NLS-1$
362
writer.println(" </xsl:if>"); //$NON-NLS-1$
363
writer.println(" </table>"); //$NON-NLS-1$
364
writer.println(" </td>"); //$NON-NLS-1$
365
writer.println(" </tr>"); //$NON-NLS-1$
366
writer.println(" </xsl:for-each>"); //$NON-NLS-1$
367
writer.println(" </xsl:when>"); //$NON-NLS-1$
368
writer.println(" <xsl:otherwise>"); //$NON-NLS-1$
369
writer.println(" <xsl:for-each select=\"feature[not(category)]\">"); //$NON-NLS-1$
370
writer.println(" <xsl:sort select=\"@id\" order=\"ascending\" case-order=\"upper-first\"/>"); //$NON-NLS-1$
371
writer.println(" <xsl:sort select=\"@version\" order=\"ascending\" />"); //$NON-NLS-1$
372
writer.println(" <tr>"); //$NON-NLS-1$
373
writer.println(" <xsl:choose>"); //$NON-NLS-1$
374
writer.println(" <xsl:when test=\"count(preceding-sibling::feature[not(category)]) mod 2 = 1\">"); //$NON-NLS-1$
375
writer.println(" <xsl:attribute name=\"class\">dark-row</xsl:attribute>"); //$NON-NLS-1$
376
writer.println(" </xsl:when>"); //$NON-NLS-1$
377
writer.println(" <xsl:otherwise>"); //$NON-NLS-1$
378
writer.println(" <xsl:attribute name=\"class\">light-row</xsl:attribute>"); //$NON-NLS-1$
379
writer.println(" </xsl:otherwise>"); //$NON-NLS-1$
380
writer.println(" </xsl:choose>"); //$NON-NLS-1$
381
writer.println(" <td class=\"log-text\" id=\"indent\">"); //$NON-NLS-1$
382
writer.println(" <xsl:choose>"); //$NON-NLS-1$
383
writer.println(" <xsl:when test=\"@label\">"); //$NON-NLS-1$
384
writer.println(" <a HREF=\"{@url}\"><xsl:value-of select=\"@label\"/></a>"); //$NON-NLS-1$
385
writer.println(" <br />"); //$NON-NLS-1$
386
writer.println(" <div id=\"indent\">"); //$NON-NLS-1$
387
writer.println(" (<xsl:value-of select=\"@id\"/> - <xsl:value-of select=\"@version\"/>)"); //$NON-NLS-1$
388
writer.println(" </div>"); //$NON-NLS-1$
389
writer.println(" </xsl:when>"); //$NON-NLS-1$
390
writer.println(" <xsl:otherwise>"); //$NON-NLS-1$
391
writer.println(" <a HREF=\"{@url}\"><xsl:value-of select=\"@id\"/> - <xsl:value-of select=\"@version\"/></a>"); //$NON-NLS-1$
392
writer.println(" </xsl:otherwise>"); //$NON-NLS-1$
393
writer.println(" </xsl:choose>"); //$NON-NLS-1$
394
writer.println(" <br /><br />"); //$NON-NLS-1$
395
writer.println(" </td>"); //$NON-NLS-1$
396
writer.println(" <td>"); //$NON-NLS-1$
397
writer.println(" <table>"); //$NON-NLS-1$
398
writer.println(" <xsl:if test=\"@os\">"); //$NON-NLS-1$
399
writer.println(" <tr><td class=\"log-text\" id=\"indent\">Operating Systems:</td>"); //$NON-NLS-1$
400
writer.println(" <td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"@os\"/></td>"); //$NON-NLS-1$
401
writer.println(" </tr>"); //$NON-NLS-1$
402
writer.println(" </xsl:if>"); //$NON-NLS-1$
403
writer.println(" <xsl:if test=\"@ws\">"); //$NON-NLS-1$
404
writer.println(" <tr><td class=\"log-text\" id=\"indent\">Windows Systems:</td>"); //$NON-NLS-1$
405
writer.println(" <td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"@ws\"/></td>"); //$NON-NLS-1$
406
writer.println(" </tr>"); //$NON-NLS-1$
407
writer.println(" </xsl:if>"); //$NON-NLS-1$
408
writer.println(" <xsl:if test=\"@nl\">"); //$NON-NLS-1$
409
writer.println(" <tr><td class=\"log-text\" id=\"indent\">Languages:</td>"); //$NON-NLS-1$
410
writer.println(" <td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"@nl\"/></td>"); //$NON-NLS-1$
411
writer.println(" </tr>"); //$NON-NLS-1$
412
writer.println(" </xsl:if>"); //$NON-NLS-1$
413
writer.println(" <xsl:if test=\"@arch\">"); //$NON-NLS-1$
414
writer.println(" <tr><td class=\"log-text\" id=\"indent\">Architecture:</td>"); //$NON-NLS-1$
415
writer.println(" <td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"@arch\"/></td>"); //$NON-NLS-1$
416
writer.println(" </tr>"); //$NON-NLS-1$
417
writer.println(" </xsl:if>"); //$NON-NLS-1$
418
writer.println(" </table>"); //$NON-NLS-1$
419
writer.println(" </td>"); //$NON-NLS-1$
420
writer.println(" </tr>"); //$NON-NLS-1$
421
writer.println(" </xsl:for-each>"); //$NON-NLS-1$
422
writer.println(" </xsl:otherwise>"); //$NON-NLS-1$
423
writer.println(" </xsl:choose>"); //$NON-NLS-1$
424
writer.println(" </table>"); //$NON-NLS-1$
425
writer.println(" </body>"); //$NON-NLS-1$
426
writer.println(" </html>"); //$NON-NLS-1$
427
writer.println("</xsl:for-each>"); //$NON-NLS-1$
428
writer.println("</xsl:template>"); //$NON-NLS-1$
429
writer.println("</xsl:stylesheet>"); //$NON-NLS-1$
430

431         writer.flush();
432         writeFile(fProject.getFile(fWebLocation + "/site.xsl"), swriter); //$NON-NLS-1$
433
}
434     
435     private void writeFile(IFile file, StringWriter JavaDoc swriter) {
436         try {
437             ByteArrayInputStream JavaDoc stream = new ByteArrayInputStream JavaDoc(swriter
438                     .toString().getBytes("UTF8")); //$NON-NLS-1$
439
if (file.exists()) {
440                 file.setContents(stream, false, false, null);
441             } else {
442                 file.create(stream, false, null);
443             }
444             stream.close();
445             swriter.close();
446         } catch (Exception JavaDoc e) {
447             PDEPlugin.logException(e);
448         }
449     }
450
451 }
452
Popular Tags