Source Code Cross Referenced for NewSiteProjectCreationOperation.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » wizards » site » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » Eclipse plug in development » org.eclipse.pde.internal.ui.wizards.site 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2005, 2006 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.pde.internal.ui.wizards.site;
011:
012:        import java.io.ByteArrayInputStream;
013:        import java.io.PrintWriter;
014:        import java.io.StringWriter;
015:        import java.lang.reflect.InvocationTargetException;
016:
017:        import org.eclipse.core.resources.IFile;
018:        import org.eclipse.core.resources.IProject;
019:        import org.eclipse.core.runtime.CoreException;
020:        import org.eclipse.core.runtime.IPath;
021:        import org.eclipse.core.runtime.IProgressMonitor;
022:        import org.eclipse.jface.viewers.ISelection;
023:        import org.eclipse.jface.viewers.StructuredSelection;
024:        import org.eclipse.pde.internal.core.natures.PDE;
025:        import org.eclipse.pde.internal.core.site.WorkspaceSiteModel;
026:        import org.eclipse.pde.internal.core.util.CoreUtility;
027:        import org.eclipse.pde.internal.ui.IPDEUIConstants;
028:        import org.eclipse.pde.internal.ui.PDEPlugin;
029:        import org.eclipse.pde.internal.ui.PDEUIMessages;
030:        import org.eclipse.swt.widgets.Display;
031:        import org.eclipse.ui.IWorkbenchPage;
032:        import org.eclipse.ui.IWorkbenchPart;
033:        import org.eclipse.ui.IWorkbenchWindow;
034:        import org.eclipse.ui.PartInitException;
035:        import org.eclipse.ui.actions.WorkspaceModifyOperation;
036:        import org.eclipse.ui.ide.IDE;
037:        import org.eclipse.ui.part.FileEditorInput;
038:        import org.eclipse.ui.part.ISetSelectionTarget;
039:
040:        public class NewSiteProjectCreationOperation extends
041:                WorkspaceModifyOperation {
042:            private Display fDisplay;
043:            private IProject fProject;
044:            private IPath fPath;
045:            private String fWebLocation;
046:
047:            public NewSiteProjectCreationOperation(Display display,
048:                    IProject project, IPath path, String webLocation) {
049:                fDisplay = display;
050:                fProject = project;
051:                fPath = path;
052:                fWebLocation = webLocation;
053:            }
054:
055:            /* (non-Javadoc)
056:             * @see org.eclipse.ui.actions.WorkspaceModifyOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
057:             */
058:            protected void execute(IProgressMonitor monitor)
059:                    throws CoreException, InvocationTargetException,
060:                    InterruptedException {
061:                int numUnits = fWebLocation == null ? 3 : 4;
062:
063:                monitor.beginTask(PDEUIMessages.NewSiteWizard_creatingProject,
064:                        numUnits);
065:
066:                CoreUtility.createProject(fProject, fPath, monitor);
067:                fProject.open(monitor);
068:                CoreUtility.addNatureToProject(fProject, PDE.SITE_NATURE,
069:                        monitor);
070:                monitor.worked(1);
071:
072:                if (fWebLocation != null) {
073:                    CoreUtility.createFolder(fProject.getFolder(fWebLocation));
074:                    createXSLFile();
075:                    createCSSFile();
076:                    createHTMLFile();
077:                    monitor.worked(1);
078:                }
079:
080:                monitor.subTask(PDEUIMessages.NewSiteWizard_creatingManifest);
081:                IFile file = createSiteManifest();
082:                monitor.worked(1);
083:
084:                openFile(file);
085:                monitor.worked(1);
086:
087:            }
088:
089:            private IFile createSiteManifest() throws CoreException {
090:                IFile file = fProject.getFile("site.xml"); //$NON-NLS-1$
091:                if (file.exists())
092:                    return file;
093:
094:                WorkspaceSiteModel model = new WorkspaceSiteModel(file);
095:                model.getSite();
096:                // Save the model
097:                model.save();
098:                model.dispose();
099:                // Set the default editor
100:                IDE.setDefaultEditor(file, IPDEUIConstants.SITE_EDITOR_ID);
101:                return file;
102:            }
103:
104:            private void openFile(final IFile file) {
105:                fDisplay.asyncExec(new Runnable() {
106:                    public void run() {
107:                        IWorkbenchWindow ww = PDEPlugin
108:                                .getActiveWorkbenchWindow();
109:                        if (ww == null) {
110:                            return;
111:                        }
112:                        IWorkbenchPage page = ww.getActivePage();
113:                        if (page == null || !file.exists())
114:                            return;
115:                        IWorkbenchPart focusPart = page.getActivePart();
116:                        if (focusPart instanceof  ISetSelectionTarget) {
117:                            ISelection selection = new StructuredSelection(file);
118:                            ((ISetSelectionTarget) focusPart)
119:                                    .selectReveal(selection);
120:                        }
121:                        try {
122:                            page.openEditor(new FileEditorInput(file),
123:                                    IPDEUIConstants.SITE_EDITOR_ID);
124:                        } catch (PartInitException e) {
125:                        }
126:                    }
127:                });
128:            }
129:
130:            private void createHTMLFile() {
131:                StringWriter swriter = new StringWriter();
132:                PrintWriter writer = new PrintWriter(swriter);
133:
134:                writer.println("<html>"); //$NON-NLS-1$
135:                writer.println("<head>"); //$NON-NLS-1$
136:                writer.println("<title>" + fProject.getName() + "</title>"); //$NON-NLS-1$ //$NON-NLS-2$
137:                writer
138:                        .println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">"); //$NON-NLS-1$
139:                writer
140:                        .println("<style>@import url(\"" + fWebLocation + "/site.css\");</style>"); //$NON-NLS-1$ //$NON-NLS-2$
141:                writer.println("<script type=\"text/javascript\">"); //$NON-NLS-1$
142:                writer.println("	var returnval = 0;"); //$NON-NLS-1$
143:                writer.println("	var stylesheet, xmlFile, cache, doc;"); //$NON-NLS-1$
144:                writer.println("	function init(){"); //$NON-NLS-1$
145:                writer.println("		// NSCP 7.1+ / Mozilla 1.4.1+ / Safari"); //$NON-NLS-1$
146:                writer
147:                        .println("		// Use the standard DOM Level 2 technique, if it is supported"); //$NON-NLS-1$
148:                writer
149:                        .println("		if (document.implementation && document.implementation.createDocument) {"); //$NON-NLS-1$
150:                writer
151:                        .println("			xmlFile = document.implementation.createDocument(\"\", \"\", null);"); //$NON-NLS-1$
152:                writer
153:                        .println("			stylesheet = document.implementation.createDocument(\"\", \"\", null);"); //$NON-NLS-1$
154:                writer.println("			if (xmlFile.load){"); //$NON-NLS-1$
155:                writer.println("				xmlFile.load(\"site.xml\");"); //$NON-NLS-1$
156:                writer
157:                        .println("				stylesheet.load(\"" + fWebLocation + "/site.xsl\");"); //$NON-NLS-1$ //$NON-NLS-2$
158:                writer.println("			} else {"); //$NON-NLS-1$
159:                writer
160:                        .println("				alert(\"" + PDEUIMessages.SiteHTML_loadError + "\");"); //$NON-NLS-1$ //$NON-NLS-2$ 
161:                writer.println("			}"); //$NON-NLS-1$
162:                writer
163:                        .println("			xmlFile.addEventListener(\"load\", transform, false);"); //$NON-NLS-1$
164:                writer
165:                        .println("			stylesheet.addEventListener(\"load\", transform, false);"); //$NON-NLS-1$
166:                writer.println("		}"); //$NON-NLS-1$
167:                writer.println("		//IE 6.0+ solution"); //$NON-NLS-1$
168:                writer.println("		else if (window.ActiveXObject) {"); //$NON-NLS-1$
169:                writer
170:                        .println("			xmlFile = new ActiveXObject(\"msxml2.DOMDocument.3.0\");"); //$NON-NLS-1$
171:                writer.println("			xmlFile.async = false;"); //$NON-NLS-1$
172:                writer.println("			xmlFile.load(\"site.xml\");"); //$NON-NLS-1$
173:                writer
174:                        .println("			stylesheet = new ActiveXObject(\"msxml2.FreeThreadedDOMDocument.3.0\");"); //$NON-NLS-1$
175:                writer.println("			stylesheet.async = false;"); //$NON-NLS-1$
176:                writer
177:                        .println("			stylesheet.load(\"" + fWebLocation + "/site.xsl\");"); //$NON-NLS-1$ //$NON-NLS-2$
178:                writer
179:                        .println("			cache = new ActiveXObject(\"msxml2.XSLTemplate.3.0\");"); //$NON-NLS-1$
180:                writer.println("			cache.stylesheet = stylesheet;"); //$NON-NLS-1$
181:                writer.println("			transformData();"); //$NON-NLS-1$
182:                writer.println("		}"); //$NON-NLS-1$
183:                writer.println("	}"); //$NON-NLS-1$
184:                writer
185:                        .println("	// separate transformation function for IE 6.0+"); //$NON-NLS-1$
186:                writer.println("	function transformData(){"); //$NON-NLS-1$
187:                writer.println("		var processor = cache.createProcessor();"); //$NON-NLS-1$
188:                writer.println("		processor.input = xmlFile;"); //$NON-NLS-1$
189:                writer.println("		processor.transform();"); //$NON-NLS-1$
190:                writer.println("		data.innerHTML = processor.output;"); //$NON-NLS-1$
191:                writer.println("	}"); //$NON-NLS-1$
192:                writer
193:                        .println("	// separate transformation function for NSCP 7.1+ and Mozilla 1.4.1+ "); //$NON-NLS-1$
194:                writer.println("	function transform(){"); //$NON-NLS-1$
195:                writer.println("		returnval+=1;"); //$NON-NLS-1$
196:                writer.println("		if (returnval==2){"); //$NON-NLS-1$
197:                writer.println("			var processor = new XSLTProcessor();"); //$NON-NLS-1$
198:                writer.println("			processor.importStylesheet(stylesheet); "); //$NON-NLS-1$
199:                writer
200:                        .println("			doc = processor.transformToDocument(xmlFile);"); //$NON-NLS-1$
201:                writer
202:                        .println("			document.getElementById(\"data\").innerHTML = doc.documentElement.innerHTML;"); //$NON-NLS-1$
203:                writer.println("		}"); //$NON-NLS-1$
204:                writer.println("	}"); //$NON-NLS-1$
205:                writer.println("</script>"); //$NON-NLS-1$
206:                writer.println("</head>"); //$NON-NLS-1$
207:                writer.println("<body onload=\"init();\">"); //$NON-NLS-1$
208:                writer.println("<!--[insert static HTML here]-->"); //$NON-NLS-1$
209:                writer
210:                        .println("<div id=\"data\"><!-- this is where the transformed data goes --></div>"); //$NON-NLS-1$
211:                writer.println("</body>"); //$NON-NLS-1$
212:                writer.println("</html>"); //$NON-NLS-1$
213:
214:                writer.flush();
215:                writeFile(fProject.getFile("index.html"), swriter); //$NON-NLS-1$
216:            }
217:
218:            private void createCSSFile() {
219:                StringWriter swriter = new StringWriter();
220:                PrintWriter writer = new PrintWriter(swriter);
221:                writer.println("<STYLE type=\"text/css\">"); //$NON-NLS-1$
222:                writer
223:                        .println("td.spacer {padding-bottom: 10px; padding-top: 10px;}"); //$NON-NLS-1$
224:                writer
225:                        .println(".title { font-family: sans-serif; color: #99AACC;}"); //$NON-NLS-1$
226:                writer
227:                        .println(".bodyText { font-family: sans-serif; font-size: 9pt; color:#000000;  }"); //$NON-NLS-1$
228:                writer
229:                        .println(".sub-header { font-family: sans-serif; font-style: normal; font-weight: bold; font-size: 9pt; color: white;}"); //$NON-NLS-1$
230:                writer
231:                        .println(".log-text {font-family: sans-serif; font-style: normal; font-weight: lighter; font-size: 8pt; color:black;}"); //$NON-NLS-1$
232:                writer
233:                        .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$
234:                writer.println(".light-row {background:#FFFFFF}"); //$NON-NLS-1$
235:                writer.println(".dark-row {background:#EEEEFF}"); //$NON-NLS-1$
236:                writer.println(".header {background:#99AADD}"); //$NON-NLS-1$
237:                writer
238:                        .println("#indent {word-wrap : break-word;width :300px;text-indent:10px;}"); //$NON-NLS-1$
239:                writer.println("</STYLE>"); //$NON-NLS-1$
240:
241:                writer.flush();
242:                writeFile(fProject.getFile(fWebLocation + "/site.css"), swriter); //$NON-NLS-1$
243:            }
244:
245:            private void createXSLFile() {
246:                StringWriter swriter = new StringWriter();
247:                PrintWriter writer = new PrintWriter(swriter);
248:                writer
249:                        .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$
250:                writer
251:                        .println("<xsl:output method=\"html\" encoding=\"UTF-8\"/>"); //$NON-NLS-1$
252:                writer
253:                        .println("<xsl:key name=\"cat\" match=\"category\" use=\"@name\"/>"); //$NON-NLS-1$
254:                writer.println("<xsl:template match=\"/\">"); //$NON-NLS-1$
255:                writer.println("<xsl:for-each select=\"site\">"); //$NON-NLS-1$
256:                writer.println("	<html>"); //$NON-NLS-1$
257:                writer.println("	<head>"); //$NON-NLS-1$
258:                writer.println("	<title>" + fProject.getName() + "</title>"); //$NON-NLS-1$ //$NON-NLS-2$
259:                writer
260:                        .println("	<style>@import url(\"" + fWebLocation + "/site.css\");</style>"); //$NON-NLS-1$ //$NON-NLS-2$
261:                writer.println("	</head>"); //$NON-NLS-1$
262:                writer.println("	<body>"); //$NON-NLS-1$
263:                writer
264:                        .println("	<h1 class=\"title\">" + fProject.getName() + "</h1>"); //$NON-NLS-1$ //$NON-NLS-2$
265:                writer
266:                        .println("	<p class=\"bodyText\"><xsl:value-of select=\"description\"/></p>"); //$NON-NLS-1$
267:                writer
268:                        .println("	<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"2\">"); //$NON-NLS-1$
269:                writer.println("	<xsl:for-each select=\"category-def\">"); //$NON-NLS-1$
270:                writer
271:                        .println("		<xsl:sort select=\"@label\" order=\"ascending\" case-order=\"upper-first\"/>"); //$NON-NLS-1$
272:                writer
273:                        .println("		<xsl:sort select=\"@name\" order=\"ascending\" case-order=\"upper-first\"/>"); //$NON-NLS-1$
274:                writer
275:                        .println("	<xsl:if test=\"count(key('cat',@name)) != 0\">"); //$NON-NLS-1$
276:                writer.println("			<tr class=\"header\">"); //$NON-NLS-1$
277:                writer.println("				<td class=\"sub-header\" width=\"30%\">"); //$NON-NLS-1$
278:                writer.println("					<xsl:value-of select=\"@name\"/>"); //$NON-NLS-1$
279:                writer.println("				</td>"); //$NON-NLS-1$
280:                writer.println("				<td class=\"sub-header\" width=\"70%\">"); //$NON-NLS-1$
281:                writer.println("					<xsl:value-of select=\"@label\"/>"); //$NON-NLS-1$
282:                writer.println("				</td>"); //$NON-NLS-1$
283:                writer.println("			</tr>"); //$NON-NLS-1$
284:                writer.println("			<xsl:for-each select=\"key('cat',@name)\">"); //$NON-NLS-1$
285:                writer
286:                        .println("			<xsl:sort select=\"ancestor::feature//@version\" order=\"ascending\"/>"); //$NON-NLS-1$
287:                writer
288:                        .println("			<xsl:sort select=\"ancestor::feature//@id\" order=\"ascending\" case-order=\"upper-first\"/>"); //$NON-NLS-1$
289:                writer.println("			<tr>"); //$NON-NLS-1$
290:                writer.println("				<xsl:choose>"); //$NON-NLS-1$
291:                writer
292:                        .println("				<xsl:when test=\"(position() mod 2 = 1)\">"); //$NON-NLS-1$
293:                writer
294:                        .println("					<xsl:attribute name=\"class\">dark-row</xsl:attribute>"); //$NON-NLS-1$
295:                writer.println("				</xsl:when>"); //$NON-NLS-1$
296:                writer.println("				<xsl:otherwise>"); //$NON-NLS-1$
297:                writer
298:                        .println("					<xsl:attribute name=\"class\">light-row</xsl:attribute>"); //$NON-NLS-1$
299:                writer.println("				</xsl:otherwise>"); //$NON-NLS-1$
300:                writer.println("				</xsl:choose>"); //$NON-NLS-1$
301:                writer.println("				<td class=\"log-text\" id=\"indent\">"); //$NON-NLS-1$
302:                writer.println("						<xsl:choose>"); //$NON-NLS-1$
303:                writer
304:                        .println("						<xsl:when test=\"ancestor::feature//@label\">"); //$NON-NLS-1$
305:                writer
306:                        .println("							<a href=\"{ancestor::feature//@url}\"><xsl:value-of select=\"ancestor::feature//@label\"/></a>"); //$NON-NLS-1$
307:                writer.println("							<br/>"); //$NON-NLS-1$
308:                writer.println("							<div id=\"indent\">"); //$NON-NLS-1$
309:                writer
310:                        .println("							(<xsl:value-of select=\"ancestor::feature//@id\"/> - <xsl:value-of select=\"ancestor::feature//@version\"/>)"); //$NON-NLS-1$
311:                writer.println("							</div>"); //$NON-NLS-1$
312:                writer.println("						</xsl:when>"); //$NON-NLS-1$
313:                writer.println("						<xsl:otherwise>"); //$NON-NLS-1$
314:                writer
315:                        .println("						<a href=\"{ancestor::feature//@url}\"><xsl:value-of select=\"ancestor::feature//@id\"/> - <xsl:value-of select=\"ancestor::feature//@version\"/></a>"); //$NON-NLS-1$
316:                writer.println("						</xsl:otherwise>"); //$NON-NLS-1$
317:                writer.println("						</xsl:choose>"); //$NON-NLS-1$
318:                writer.println("						<br />"); //$NON-NLS-1$
319:                writer.println("				</td>"); //$NON-NLS-1$
320:                writer.println("				<td>"); //$NON-NLS-1$
321:                writer.println("					<table>"); //$NON-NLS-1$
322:                writer
323:                        .println("						<xsl:if test=\"ancestor::feature//@os\">"); //$NON-NLS-1$
324:                writer
325:                        .println("							<tr><td class=\"log-text\" id=\"indent\">Operating Systems:</td>"); //$NON-NLS-1$
326:                writer
327:                        .println("							<td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"ancestor::feature//@os\"/></td>"); //$NON-NLS-1$
328:                writer.println("							</tr>"); //$NON-NLS-1$
329:                writer.println("						</xsl:if>"); //$NON-NLS-1$
330:                writer
331:                        .println("						<xsl:if test=\"ancestor::feature//@ws\">"); //$NON-NLS-1$
332:                writer
333:                        .println("							<tr><td class=\"log-text\" id=\"indent\">Windows Systems:</td>"); //$NON-NLS-1$
334:                writer
335:                        .println("							<td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"ancestor::feature//@ws\"/></td>"); //$NON-NLS-1$
336:                writer.println("							</tr>"); //$NON-NLS-1$
337:                writer.println("						</xsl:if>"); //$NON-NLS-1$
338:                writer
339:                        .println("						<xsl:if test=\"ancestor::feature//@nl\">"); //$NON-NLS-1$
340:                writer
341:                        .println("							<tr><td class=\"log-text\" id=\"indent\">Languages:</td>"); //$NON-NLS-1$
342:                writer
343:                        .println("							<td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"ancestor::feature//@nl\"/></td>"); //$NON-NLS-1$
344:                writer.println("							</tr>"); //$NON-NLS-1$
345:                writer.println("						</xsl:if>"); //$NON-NLS-1$
346:                writer
347:                        .println("						<xsl:if test=\"ancestor::feature//@arch\">"); //$NON-NLS-1$
348:                writer
349:                        .println("							<tr><td class=\"log-text\" id=\"indent\">Architecture:</td>"); //$NON-NLS-1$
350:                writer
351:                        .println("							<td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"ancestor::feature//@arch\"/></td>"); //$NON-NLS-1$
352:                writer.println("							</tr>"); //$NON-NLS-1$
353:                writer.println("						</xsl:if>"); //$NON-NLS-1$
354:                writer.println("					</table>"); //$NON-NLS-1$
355:                writer.println("				</td>"); //$NON-NLS-1$
356:                writer.println("			</tr>"); //$NON-NLS-1$
357:                writer.println("			</xsl:for-each>"); //$NON-NLS-1$
358:                writer
359:                        .println("			<tr><td class=\"spacer\"><br/></td><td class=\"spacer\"><br/></td></tr>"); //$NON-NLS-1$
360:                writer.println("		</xsl:if>"); //$NON-NLS-1$
361:                writer.println("	</xsl:for-each>"); //$NON-NLS-1$
362:                writer
363:                        .println("	<xsl:if test=\"count(feature)  &gt; count(feature/category)\">"); //$NON-NLS-1$
364:                writer.println("	<tr class=\"header\">"); //$NON-NLS-1$
365:                writer.println("		<td class=\"sub-header\" colspan=\"2\">"); //$NON-NLS-1$
366:                writer.println("		Uncategorized"); //$NON-NLS-1$
367:                writer.println("		</td>"); //$NON-NLS-1$
368:                writer.println("	</tr>"); //$NON-NLS-1$
369:                writer.println("	</xsl:if>"); //$NON-NLS-1$
370:                writer.println("	<xsl:choose>"); //$NON-NLS-1$
371:                writer
372:                        .println("	<xsl:when test=\"function-available('msxsl:node-set')\">"); //$NON-NLS-1$
373:                writer.println("	   <xsl:variable name=\"rtf-nodes\">"); //$NON-NLS-1$
374:                writer
375:                        .println("		<xsl:for-each select=\"feature[not(category)]\">"); //$NON-NLS-1$
376:                writer
377:                        .println("			<xsl:sort select=\"@id\" order=\"ascending\" case-order=\"upper-first\"/>"); //$NON-NLS-1$
378:                writer
379:                        .println("			<xsl:sort select=\"@version\" order=\"ascending\" />"); //$NON-NLS-1$
380:                writer.println("			<xsl:value-of select=\".\"/>"); //$NON-NLS-1$
381:                writer.println("			<xsl:copy-of select=\".\" />"); //$NON-NLS-1$
382:                writer.println("		</xsl:for-each>"); //$NON-NLS-1$
383:                writer.println("	   </xsl:variable>"); //$NON-NLS-1$
384:                writer
385:                        .println("	   <xsl:variable name=\"myNodeSet\" select=\"msxsl:node-set($rtf-nodes)/*\"/>"); //$NON-NLS-1$
386:                writer.println("	<xsl:for-each select=\"$myNodeSet\">"); //$NON-NLS-1$
387:                writer.println("	<tr>"); //$NON-NLS-1$
388:                writer.println("		<xsl:choose>"); //$NON-NLS-1$
389:                writer.println("		<xsl:when test=\"position() mod 2 = 1\">"); //$NON-NLS-1$
390:                writer
391:                        .println("		<xsl:attribute name=\"class\">dark-row</xsl:attribute>"); //$NON-NLS-1$
392:                writer.println("		</xsl:when>"); //$NON-NLS-1$
393:                writer.println("		<xsl:otherwise>"); //$NON-NLS-1$
394:                writer
395:                        .println("		<xsl:attribute name=\"class\">light-row</xsl:attribute>"); //$NON-NLS-1$
396:                writer.println("		</xsl:otherwise>"); //$NON-NLS-1$
397:                writer.println("		</xsl:choose>"); //$NON-NLS-1$
398:                writer.println("		<td class=\"log-text\" id=\"indent\">"); //$NON-NLS-1$
399:                writer.println("			<xsl:choose>"); //$NON-NLS-1$
400:                writer.println("			<xsl:when test=\"@label\">"); //$NON-NLS-1$
401:                writer
402:                        .println("				<a href=\"{@url}\"><xsl:value-of select=\"@label\"/></a>"); //$NON-NLS-1$
403:                writer.println("				<br />"); //$NON-NLS-1$
404:                writer.println("				<div id=\"indent\">"); //$NON-NLS-1$
405:                writer
406:                        .println("				(<xsl:value-of select=\"@id\"/> - <xsl:value-of select=\"@version\"/>)"); //$NON-NLS-1$
407:                writer.println("				</div>"); //$NON-NLS-1$
408:                writer.println("			</xsl:when>"); //$NON-NLS-1$
409:                writer.println("			<xsl:otherwise>"); //$NON-NLS-1$
410:                writer
411:                        .println("				<a href=\"{@url}\"><xsl:value-of select=\"@id\"/> - <xsl:value-of select=\"@version\"/></a>"); //$NON-NLS-1$
412:                writer.println("			</xsl:otherwise>"); //$NON-NLS-1$
413:                writer.println("			</xsl:choose>"); //$NON-NLS-1$
414:                writer.println("			<br /><br />"); //$NON-NLS-1$
415:                writer.println("		</td>"); //$NON-NLS-1$
416:                writer.println("		<td>"); //$NON-NLS-1$
417:                writer.println("			<table>"); //$NON-NLS-1$
418:                writer.println("				<xsl:if test=\"@os\">"); //$NON-NLS-1$
419:                writer
420:                        .println("					<tr><td class=\"log-text\" id=\"indent\">Operating Systems:</td>"); //$NON-NLS-1$
421:                writer
422:                        .println("					<td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"@os\"/></td>"); //$NON-NLS-1$
423:                writer.println("					</tr>"); //$NON-NLS-1$
424:                writer.println("				</xsl:if>"); //$NON-NLS-1$
425:                writer.println("				<xsl:if test=\"@ws\">"); //$NON-NLS-1$
426:                writer
427:                        .println("					<tr><td class=\"log-text\" id=\"indent\">Windows Systems:</td>"); //$NON-NLS-1$
428:                writer
429:                        .println("					<td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"@ws\"/></td>"); //$NON-NLS-1$
430:                writer.println("					</tr>"); //$NON-NLS-1$
431:                writer.println("				</xsl:if>"); //$NON-NLS-1$
432:                writer.println("				<xsl:if test=\"@nl\">"); //$NON-NLS-1$
433:                writer
434:                        .println("					<tr><td class=\"log-text\" id=\"indent\">Languages:</td>"); //$NON-NLS-1$
435:                writer
436:                        .println("					<td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"@nl\"/></td>"); //$NON-NLS-1$
437:                writer.println("					</tr>"); //$NON-NLS-1$
438:                writer.println("				</xsl:if>"); //$NON-NLS-1$
439:                writer.println("				<xsl:if test=\"@arch\">"); //$NON-NLS-1$
440:                writer
441:                        .println("					<tr><td class=\"log-text\" id=\"indent\">Architecture:</td>"); //$NON-NLS-1$
442:                writer
443:                        .println("					<td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"@arch\"/></td>"); //$NON-NLS-1$
444:                writer.println("					</tr>"); //$NON-NLS-1$
445:                writer.println("				</xsl:if>"); //$NON-NLS-1$
446:                writer.println("			</table>"); //$NON-NLS-1$
447:                writer.println("		</td>"); //$NON-NLS-1$
448:                writer.println("	</tr>"); //$NON-NLS-1$
449:                writer.println("	</xsl:for-each>"); //$NON-NLS-1$
450:                writer.println("	</xsl:when>"); //$NON-NLS-1$
451:                writer.println("	<xsl:otherwise>"); //$NON-NLS-1$
452:                writer
453:                        .println("	<xsl:for-each select=\"feature[not(category)]\">"); //$NON-NLS-1$
454:                writer
455:                        .println("	<xsl:sort select=\"@id\" order=\"ascending\" case-order=\"upper-first\"/>"); //$NON-NLS-1$
456:                writer
457:                        .println("	<xsl:sort select=\"@version\" order=\"ascending\" />"); //$NON-NLS-1$
458:                writer.println("	<tr>"); //$NON-NLS-1$
459:                writer.println("		<xsl:choose>"); //$NON-NLS-1$
460:                writer
461:                        .println("		<xsl:when test=\"count(preceding-sibling::feature[not(category)]) mod 2 = 1\">"); //$NON-NLS-1$
462:                writer
463:                        .println("		<xsl:attribute name=\"class\">dark-row</xsl:attribute>"); //$NON-NLS-1$
464:                writer.println("		</xsl:when>"); //$NON-NLS-1$
465:                writer.println("		<xsl:otherwise>"); //$NON-NLS-1$
466:                writer
467:                        .println("		<xsl:attribute name=\"class\">light-row</xsl:attribute>"); //$NON-NLS-1$
468:                writer.println("		</xsl:otherwise>"); //$NON-NLS-1$
469:                writer.println("		</xsl:choose>"); //$NON-NLS-1$
470:                writer.println("		<td class=\"log-text\" id=\"indent\">"); //$NON-NLS-1$
471:                writer.println("			<xsl:choose>"); //$NON-NLS-1$
472:                writer.println("			<xsl:when test=\"@label\">"); //$NON-NLS-1$
473:                writer
474:                        .println("				<a href=\"{@url}\"><xsl:value-of select=\"@label\"/></a>"); //$NON-NLS-1$
475:                writer.println("				<br />"); //$NON-NLS-1$
476:                writer.println("				<div id=\"indent\">"); //$NON-NLS-1$
477:                writer
478:                        .println("				(<xsl:value-of select=\"@id\"/> - <xsl:value-of select=\"@version\"/>)"); //$NON-NLS-1$
479:                writer.println("				</div>"); //$NON-NLS-1$
480:                writer.println("			</xsl:when>"); //$NON-NLS-1$
481:                writer.println("			<xsl:otherwise>"); //$NON-NLS-1$
482:                writer
483:                        .println("				<a href=\"{@url}\"><xsl:value-of select=\"@id\"/> - <xsl:value-of select=\"@version\"/></a>"); //$NON-NLS-1$
484:                writer.println("			</xsl:otherwise>"); //$NON-NLS-1$
485:                writer.println("			</xsl:choose>"); //$NON-NLS-1$
486:                writer.println("			<br /><br />"); //$NON-NLS-1$
487:                writer.println("		</td>"); //$NON-NLS-1$
488:                writer.println("		<td>"); //$NON-NLS-1$
489:                writer.println("			<table>"); //$NON-NLS-1$
490:                writer.println("				<xsl:if test=\"@os\">"); //$NON-NLS-1$
491:                writer
492:                        .println("					<tr><td class=\"log-text\" id=\"indent\">Operating Systems:</td>"); //$NON-NLS-1$
493:                writer
494:                        .println("					<td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"@os\"/></td>"); //$NON-NLS-1$
495:                writer.println("					</tr>"); //$NON-NLS-1$
496:                writer.println("				</xsl:if>"); //$NON-NLS-1$
497:                writer.println("				<xsl:if test=\"@ws\">"); //$NON-NLS-1$
498:                writer
499:                        .println("					<tr><td class=\"log-text\" id=\"indent\">Windows Systems:</td>"); //$NON-NLS-1$
500:                writer
501:                        .println("					<td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"@ws\"/></td>"); //$NON-NLS-1$
502:                writer.println("					</tr>"); //$NON-NLS-1$
503:                writer.println("				</xsl:if>"); //$NON-NLS-1$
504:                writer.println("				<xsl:if test=\"@nl\">"); //$NON-NLS-1$
505:                writer
506:                        .println("					<tr><td class=\"log-text\" id=\"indent\">Languages:</td>"); //$NON-NLS-1$
507:                writer
508:                        .println("					<td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"@nl\"/></td>"); //$NON-NLS-1$
509:                writer.println("					</tr>"); //$NON-NLS-1$
510:                writer.println("				</xsl:if>"); //$NON-NLS-1$
511:                writer.println("				<xsl:if test=\"@arch\">"); //$NON-NLS-1$
512:                writer
513:                        .println("					<tr><td class=\"log-text\" id=\"indent\">Architecture:</td>"); //$NON-NLS-1$
514:                writer
515:                        .println("					<td class=\"log-text\" id=\"indent\"><xsl:value-of select=\"@arch\"/></td>"); //$NON-NLS-1$
516:                writer.println("					</tr>"); //$NON-NLS-1$
517:                writer.println("				</xsl:if>"); //$NON-NLS-1$
518:                writer.println("			</table>"); //$NON-NLS-1$
519:                writer.println("		</td>"); //$NON-NLS-1$
520:                writer.println("	</tr>"); //$NON-NLS-1$
521:                writer.println("	</xsl:for-each>"); //$NON-NLS-1$
522:                writer.println("	</xsl:otherwise>"); //$NON-NLS-1$
523:                writer.println("	</xsl:choose>"); //$NON-NLS-1$
524:                writer.println("	</table>"); //$NON-NLS-1$
525:                writer.println("	</body>"); //$NON-NLS-1$
526:                writer.println("	</html>"); //$NON-NLS-1$
527:                writer.println("</xsl:for-each>"); //$NON-NLS-1$
528:                writer.println("</xsl:template>"); //$NON-NLS-1$
529:                writer.println("</xsl:stylesheet>"); //$NON-NLS-1$
530:
531:                writer.flush();
532:                writeFile(fProject.getFile(fWebLocation + "/site.xsl"), swriter); //$NON-NLS-1$
533:            }
534:
535:            private void writeFile(IFile file, StringWriter swriter) {
536:                try {
537:                    ByteArrayInputStream stream = new ByteArrayInputStream(
538:                            swriter.toString().getBytes("UTF8")); //$NON-NLS-1$
539:                    if (file.exists()) {
540:                        file.setContents(stream, false, false, null);
541:                    } else {
542:                        file.create(stream, false, null);
543:                    }
544:                    stream.close();
545:                    swriter.close();
546:                } catch (Exception e) {
547:                    PDEPlugin.logException(e);
548:                }
549:            }
550:
551:        }
w___w___w__.___j_a___v___a__2_s.__c__om | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.