KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.io.Serializable JavaDoc;
15
16 import org.eclipse.pde.core.ISourceObject;
17 import org.eclipse.pde.core.IWritable;
18 import org.eclipse.pde.core.plugin.IPlugin;
19 import org.eclipse.pde.core.plugin.IPluginBase;
20 import org.eclipse.pde.core.plugin.IPluginImport;
21 import org.eclipse.pde.core.plugin.IPluginModelBase;
22
23 public class ImportObject extends PluginReference implements IWritable, Serializable JavaDoc, IWritableDelimiter {
24
25     private static final long serialVersionUID = 1L;
26     private IPluginImport iimport;
27     
28     public ImportObject() {
29         super();
30     }
31     public ImportObject(IPluginImport iimport) {
32         super(iimport.getId());
33         this.iimport = iimport;
34     }
35     public ImportObject(IPluginImport iimport, IPlugin plugin) {
36         super(plugin);
37         this.iimport = iimport;
38     }
39     public IPluginImport getImport() {
40         return iimport;
41     }
42     public boolean equals(Object JavaDoc object) {
43         if (object instanceof ImportObject) {
44             ImportObject io = (ImportObject)object;
45             if (iimport.equals(io.getImport()))
46                return true;
47         }
48         return false;
49     }
50     
51     /* (non-Javadoc)
52      * @see org.eclipse.pde.core.IWritable#write(java.lang.String, java.io.PrintWriter)
53      */

54     public void write(String JavaDoc indent, PrintWriter JavaDoc writer) {
55         iimport.write(indent, writer);
56     }
57     
58     public Object JavaDoc getAdapter(Class JavaDoc key) {
59         if (key.equals(ISourceObject.class)) {
60             if (iimport instanceof ISourceObject)
61                 return iimport;
62         }
63         return super.getAdapter(key);
64     }
65     
66     /* (non-Javadoc)
67      * @see org.eclipse.pde.internal.core.plugin.PluginReference#reconnect(org.eclipse.pde.core.plugin.IPlugin)
68      */

69     public void reconnect(IPluginModelBase model) {
70         super.reconnect(model);
71         // Field that has transient fields: Import
72
IPluginBase parent = model.getPluginBase();
73         // Note: Cannot make into a 'IDocument*' interface. The functionality
74
// is usually done by the '*Node' classes; but, it is the opposite here
75
if (iimport instanceof PluginImport) {
76             ((PluginImport)iimport).reconnect(model, parent);
77         }
78     }
79     
80     /* (non-Javadoc)
81      * @see org.eclipse.pde.internal.core.plugin.IWritableDelimeter#writeDelimeter(java.io.PrintWriter)
82      */

83     public void writeDelimeter(PrintWriter JavaDoc writer) {
84         // Note: Cannot make into a 'IDocument*' interface. The functionality
85
// is usually done by the '*Node' classes; but, it is the opposite here
86
if (iimport instanceof PluginImport) {
87             ((PluginImport)iimport).writeDelimeter(writer);
88         }
89     }
90     
91 }
92
Popular Tags