KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > model > plugin > PluginExtensionNode


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.model.plugin;
12
13 import org.eclipse.core.runtime.*;
14 import org.eclipse.pde.core.plugin.*;
15 import org.eclipse.pde.internal.core.*;
16 import org.eclipse.pde.internal.core.ischema.*;
17 import org.eclipse.pde.internal.core.schema.*;
18 import org.eclipse.pde.internal.ui.model.*;
19
20 public class PluginExtensionNode extends PluginParentNode
21         implements
22             IPluginExtension {
23     private static final long serialVersionUID = 1L;
24     private transient ISchema fSchema;
25
26     /* (non-Javadoc)
27      * @see org.eclipse.pde.core.plugin.IPluginExtension#getPoint()
28      */

29     public String JavaDoc getPoint() {
30         return getXMLAttributeValue(P_POINT);
31     }
32     /* (non-Javadoc)
33      * @see org.eclipse.pde.core.plugin.IPluginExtension#setPoint(java.lang.String)
34      */

35     public void setPoint(String JavaDoc point) throws CoreException {
36         setXMLAttribute(P_POINT, point);
37     }
38     
39     /* (non-Javadoc)
40      * @see org.eclipse.pde.core.plugin.IPluginObject#setName(java.lang.String)
41      */

42     public void setName(String JavaDoc name) throws CoreException {
43         setXMLAttribute(P_NAME, name);
44     }
45     
46     /* (non-Javadoc)
47      * @see org.eclipse.pde.core.plugin.IPluginObject#getName()
48      */

49     public String JavaDoc getName() {
50         return getXMLAttributeValue(P_NAME);
51     }
52     
53     /* (non-Javadoc)
54      * @see org.eclipse.pde.core.plugin.IPluginObject#getTranslatedName()
55      */

56     public String JavaDoc getTranslatedName() {
57         String JavaDoc name = getName();
58         return (name == null || name.trim().length() == 0) ? getPoint() : getResourceString(name);
59     }
60     /* (non-Javadoc)
61      * @see org.eclipse.pde.core.IIdentifiable#getId()
62      */

63     public String JavaDoc getId() {
64         return getXMLAttributeValue(P_ID);
65     }
66     /* (non-Javadoc)
67      * @see org.eclipse.pde.core.IIdentifiable#setId(java.lang.String)
68      */

69     public void setId(String JavaDoc id) throws CoreException {
70         setXMLAttribute(P_ID, id);
71     }
72     
73     /* (non-Javadoc)
74      * @see org.eclipse.pde.internal.ui.model.plugin.PluginObjectNode#write()
75      */

76     public String JavaDoc write(boolean indent) {
77         String JavaDoc sep = getLineDelimiter();
78         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
79         if (indent)
80             buffer.append(getIndent());
81         buffer.append(writeShallow(false));
82         IDocumentNode[] children = getChildNodes();
83         for (int i = 0; i < children.length; i++) {
84             children[i].setLineIndent(getLineIndent() + 3);
85             buffer.append(sep + children[i].write(true));
86         }
87         buffer.append(sep + getIndent() + "</extension>"); //$NON-NLS-1$
88
return buffer.toString();
89     }
90     
91     /* (non-Javadoc)
92      * @see org.eclipse.pde.internal.ui.model.plugin.PluginObjectNode#writeShallow(boolean)
93      */

94     public String JavaDoc writeShallow(boolean terminate) {
95         String JavaDoc sep = getLineDelimiter();
96         String JavaDoc attrIndent = " "; //$NON-NLS-1$
97
StringBuffer JavaDoc buffer = new StringBuffer JavaDoc("<extension"); //$NON-NLS-1$
98
IDocumentAttribute attr = getDocumentAttribute(P_ID);
99         if (attr != null && attr.getAttributeValue().trim().length() > 0)
100             buffer.append(sep + getIndent() + attrIndent + attr.write());
101         attr = getDocumentAttribute(P_NAME);
102         if (attr != null && attr.getAttributeValue().trim().length() > 0)
103             buffer.append(sep + getIndent() + attrIndent + attr.write());
104         attr = getDocumentAttribute(P_POINT);
105         if (attr != null && attr.getAttributeValue().trim().length() > 0)
106             buffer.append(sep + getIndent() + attrIndent + attr.write());
107         if (terminate)
108             buffer.append("/"); //$NON-NLS-1$
109
buffer.append(">"); //$NON-NLS-1$
110
return buffer.toString();
111     }
112     
113     /* (non-Javadoc)
114      * @see org.eclipse.pde.core.plugin.IPluginExtension#getSchema()
115      */

116     public Object JavaDoc getSchema() {
117         if (fSchema == null) {
118             SchemaRegistry registry = PDECore.getDefault().getSchemaRegistry();
119             fSchema = registry.getSchema(getPoint());
120         } else if (fSchema.isDisposed()) {
121             fSchema = null;
122         }
123         return fSchema;
124     }
125 }
126
Popular Tags