01: /*******************************************************************************
02: * Copyright (c) 2005, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.core.product;
11:
12: import java.io.PrintWriter;
13:
14: import org.eclipse.pde.core.plugin.IFragmentModel;
15: import org.eclipse.pde.core.plugin.PluginRegistry;
16: import org.eclipse.pde.internal.core.iproduct.IProductModel;
17: import org.eclipse.pde.internal.core.iproduct.IProductPlugin;
18: import org.w3c.dom.Element;
19: import org.w3c.dom.Node;
20:
21: public class ProductPlugin extends ProductObject implements
22: IProductPlugin {
23:
24: private static final long serialVersionUID = 1L;
25: private String fId;
26:
27: public ProductPlugin(IProductModel model) {
28: super (model);
29: }
30:
31: /* (non-Javadoc)
32: * @see org.eclipse.pde.internal.core.iproduct.IProductPlugin#getId()
33: */
34: public String getId() {
35: return fId.trim();
36: }
37:
38: /* (non-Javadoc)
39: * @see org.eclipse.pde.internal.core.iproduct.IProductPlugin#setId(java.lang.String)
40: */
41: public void setId(String id) {
42: fId = id;
43: }
44:
45: /* (non-Javadoc)
46: * @see org.eclipse.pde.internal.core.iproduct.IProductObject#parse(org.w3c.dom.Node)
47: */
48: public void parse(Node node) {
49: if (node.getNodeType() == Node.ELEMENT_NODE)
50: fId = ((Element) node).getAttribute("id"); //$NON-NLS-1$
51: }
52:
53: /* (non-Javadoc)
54: * @see org.eclipse.pde.internal.core.product.ProductObject#write(java.lang.String, java.io.PrintWriter)
55: */
56: public void write(String indent, PrintWriter writer) {
57: writer.print(indent + "<plugin id=\"" + fId + "\""); //$NON-NLS-1$ //$NON-NLS-2$
58: if (PluginRegistry.findModel(fId) instanceof IFragmentModel)
59: writer.print(" fragment=\"true\""); //$NON-NLS-1$
60: writer.println("/>"); //$NON-NLS-1$
61: }
62:
63: }
|