KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > product > ProductPlugin


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 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.core.product;
12
13 import java.io.PrintWriter JavaDoc;
14
15 import org.eclipse.pde.core.plugin.IFragmentModel;
16 import org.eclipse.pde.core.plugin.PluginRegistry;
17 import org.eclipse.pde.internal.core.iproduct.IProductModel;
18 import org.eclipse.pde.internal.core.iproduct.IProductPlugin;
19 import org.w3c.dom.Element JavaDoc;
20 import org.w3c.dom.Node JavaDoc;
21
22
23 public class ProductPlugin extends ProductObject implements IProductPlugin {
24
25     private static final long serialVersionUID = 1L;
26     private String JavaDoc fId;
27
28     public ProductPlugin(IProductModel model) {
29         super(model);
30     }
31
32     /* (non-Javadoc)
33      * @see org.eclipse.pde.internal.core.iproduct.IProductPlugin#getId()
34      */

35     public String JavaDoc getId() {
36         return fId.trim();
37     }
38
39     /* (non-Javadoc)
40      * @see org.eclipse.pde.internal.core.iproduct.IProductPlugin#setId(java.lang.String)
41      */

42     public void setId(String JavaDoc id) {
43         fId = id;
44     }
45
46     /* (non-Javadoc)
47      * @see org.eclipse.pde.internal.core.iproduct.IProductObject#parse(org.w3c.dom.Node)
48      */

49     public void parse(Node JavaDoc node) {
50         if (node.getNodeType() == Node.ELEMENT_NODE)
51             fId = ((Element JavaDoc)node).getAttribute("id"); //$NON-NLS-1$
52
}
53     
54     /* (non-Javadoc)
55      * @see org.eclipse.pde.internal.core.product.ProductObject#write(java.lang.String, java.io.PrintWriter)
56      */

57     public void write(String JavaDoc indent, PrintWriter JavaDoc writer) {
58         writer.print(indent + "<plugin id=\"" + fId + "\""); //$NON-NLS-1$ //$NON-NLS-2$
59
if (PluginRegistry.findModel(fId) instanceof IFragmentModel)
60             writer.print(" fragment=\"true\""); //$NON-NLS-1$
61
writer.println("/>"); //$NON-NLS-1$
62
}
63     
64 }
65
Popular Tags