01: /*******************************************************************************
02: * Copyright (c) 2000, 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.plugin;
11:
12: import java.io.PrintWriter;
13: import java.io.Serializable;
14:
15: import org.eclipse.pde.core.ISourceObject;
16: import org.eclipse.pde.core.IWritable;
17: import org.eclipse.pde.core.plugin.IPlugin;
18: import org.eclipse.pde.core.plugin.IPluginBase;
19: import org.eclipse.pde.core.plugin.IPluginImport;
20: import org.eclipse.pde.core.plugin.IPluginModelBase;
21:
22: public class ImportObject extends PluginReference implements IWritable,
23: Serializable, IWritableDelimiter {
24:
25: private static final long serialVersionUID = 1L;
26: private IPluginImport iimport;
27:
28: public ImportObject() {
29: super ();
30: }
31:
32: public ImportObject(IPluginImport iimport) {
33: super (iimport.getId());
34: this .iimport = iimport;
35: }
36:
37: public ImportObject(IPluginImport iimport, IPlugin plugin) {
38: super (plugin);
39: this .iimport = iimport;
40: }
41:
42: public IPluginImport getImport() {
43: return iimport;
44: }
45:
46: public boolean equals(Object object) {
47: if (object instanceof ImportObject) {
48: ImportObject io = (ImportObject) object;
49: if (iimport.equals(io.getImport()))
50: return true;
51: }
52: return false;
53: }
54:
55: /* (non-Javadoc)
56: * @see org.eclipse.pde.core.IWritable#write(java.lang.String, java.io.PrintWriter)
57: */
58: public void write(String indent, PrintWriter writer) {
59: iimport.write(indent, writer);
60: }
61:
62: public Object getAdapter(Class key) {
63: if (key.equals(ISourceObject.class)) {
64: if (iimport instanceof ISourceObject)
65: return iimport;
66: }
67: return super .getAdapter(key);
68: }
69:
70: /* (non-Javadoc)
71: * @see org.eclipse.pde.internal.core.plugin.PluginReference#reconnect(org.eclipse.pde.core.plugin.IPlugin)
72: */
73: public void reconnect(IPluginModelBase model) {
74: super .reconnect(model);
75: // Field that has transient fields: Import
76: IPluginBase parent = model.getPluginBase();
77: // Note: Cannot make into a 'IDocument*' interface. The functionality
78: // is usually done by the '*Node' classes; but, it is the opposite here
79: if (iimport instanceof PluginImport) {
80: ((PluginImport) iimport).reconnect(model, parent);
81: }
82: }
83:
84: /* (non-Javadoc)
85: * @see org.eclipse.pde.internal.core.plugin.IWritableDelimeter#writeDelimeter(java.io.PrintWriter)
86: */
87: public void writeDelimeter(PrintWriter writer) {
88: // Note: Cannot make into a 'IDocument*' interface. The functionality
89: // is usually done by the '*Node' classes; but, it is the opposite here
90: if (iimport instanceof PluginImport) {
91: ((PluginImport) iimport).writeDelimeter(writer);
92: }
93: }
94:
95: }
|