KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > plugin > PluginExtensionPoint


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.plugin;
12
13 import java.io.PrintWriter JavaDoc;
14
15 import org.eclipse.core.runtime.CoreException;
16 import org.eclipse.pde.core.plugin.IFragment;
17 import org.eclipse.pde.core.plugin.IPluginBase;
18 import org.eclipse.pde.core.plugin.IPluginExtensionPoint;
19 import org.eclipse.pde.core.plugin.IPluginModelBase;
20 import org.w3c.dom.Node JavaDoc;
21
22 public class PluginExtensionPoint extends IdentifiablePluginObject
23     implements IPluginExtensionPoint {
24
25     private static final long serialVersionUID = 1L;
26     
27     protected String JavaDoc fSchema;
28     
29     public boolean isValid() {
30         return fID != null && fName != null;
31     }
32
33     public String JavaDoc getFullId() {
34         String JavaDoc pointId = getId();
35         IPluginModelBase modelBase = getPluginModel();
36         IPluginBase pluginBase = modelBase.getPluginBase();
37         if ("3.2".equals(pluginBase.getSchemaVersion())) { //$NON-NLS-1$
38
if (pointId.indexOf('.') > 0)
39                 return pointId;
40         }
41         
42         if (pluginBase instanceof IFragment)
43             return ((IFragment) pluginBase).getPluginId() + '.' + pointId;
44         return pluginBase.getId() + '.' + pointId;
45     }
46     
47     public String JavaDoc getSchema() {
48         return fSchema;
49     }
50     
51     void load(Node JavaDoc node) {
52         this.fID = getNodeAttribute(node, "id"); //$NON-NLS-1$
53
fName = getNodeAttribute(node, "name"); //$NON-NLS-1$
54
fSchema = getNodeAttribute(node, "schema"); //$NON-NLS-1$
55
fStartLine = Integer.parseInt(getNodeAttribute(node, "line")); //$NON-NLS-1$
56
}
57     
58     public boolean equals(Object JavaDoc obj) {
59         if (obj == this)
60             return true;
61         if (obj instanceof IPluginExtensionPoint) {
62             IPluginExtensionPoint target = (IPluginExtensionPoint) obj;
63             // Objects from the same model must be
64
// binary equal
65
if (target.getModel().equals(getModel()))
66                 return false;
67             if (stringEqualWithNull(target.getId(), getId())
68                 && stringEqualWithNull(target.getName(), getName())
69                 && stringEqualWithNull(target.getSchema(), getSchema()))
70                 return true;
71         }
72         return false;
73     }
74
75     public void setSchema(String JavaDoc newSchema) throws CoreException {
76         ensureModelEditable();
77         String JavaDoc oldValue = fSchema;
78         fSchema = newSchema;
79         firePropertyChanged(P_SCHEMA, oldValue, fSchema);
80     }
81
82     public void restoreProperty(String JavaDoc name, Object JavaDoc oldValue, Object JavaDoc newValue)
83         throws CoreException {
84         if (name.equals(P_SCHEMA)) {
85             setSchema(newValue != null ? newValue.toString() : null);
86             return;
87         }
88         super.restoreProperty(name, oldValue, newValue);
89     }
90
91     public void write(String JavaDoc indent, PrintWriter JavaDoc writer) {
92         writer.print(indent);
93         writer.print("<extension-point"); //$NON-NLS-1$
94
if (getId() != null)
95             writer.print(" id=\"" + getWritableString(getId()) + "\""); //$NON-NLS-1$ //$NON-NLS-2$
96
if (getName() != null)
97             writer.print(" name=\"" + getWritableString(getName()) + "\""); //$NON-NLS-1$ //$NON-NLS-2$
98
if (getSchema() != null)
99             writer.print(" schema=\"" + getSchema() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
100
writer.println("/>"); //$NON-NLS-1$
101
}
102 }
103
Popular Tags