KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > bundle > BundleObject


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.bundle;
12
13 import java.io.PrintWriter JavaDoc;
14 import java.io.Serializable JavaDoc;
15
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.core.runtime.IStatus;
18 import org.eclipse.core.runtime.Status;
19 import org.eclipse.pde.core.IModelChangeProvider;
20 import org.eclipse.pde.core.IModelChangedEvent;
21 import org.eclipse.pde.core.IWritable;
22 import org.eclipse.pde.core.ModelChangedEvent;
23 import org.eclipse.pde.internal.core.PDECore;
24 import org.eclipse.pde.internal.core.ibundle.IBundleModel;
25 import org.eclipse.pde.internal.core.plugin.IWritableDelimiter;
26
27 public class BundleObject implements Serializable JavaDoc, IWritable, IWritableDelimiter {
28     private static final long serialVersionUID = 1L;
29     
30     private transient IBundleModel model;
31
32     public BundleObject() {
33     }
34
35     public IBundleModel getModel() {
36         return model;
37     }
38     public void setModel(IBundleModel newModel) {
39         model = newModel;
40     }
41     protected void throwCoreException(String JavaDoc message) throws CoreException {
42         Status status =
43             new Status(
44                 IStatus.ERROR,
45                 PDECore.PLUGIN_ID,
46                 IStatus.OK,
47                 message,
48                 null);
49         throw new CoreException(status);
50     }
51
52     protected void fireStructureChanged(BundleObject[] children, int changeType) {
53         IModelChangedEvent e = new ModelChangedEvent(
54                 model,
55                 changeType,
56                 children,
57                 null);
58         fireModelChanged(e);
59  }
60
61     protected void fireStructureChanged(BundleObject child, int changeType) {
62             IModelChangedEvent e = new ModelChangedEvent(
63                     model,
64                     changeType,
65                     new Object JavaDoc[]{child},
66                     null);
67             fireModelChanged(e);
68      }
69
70     protected void fireModelChanged(IModelChangedEvent e) {
71         IModelChangeProvider provider = model;
72         provider.fireModelChanged(e);
73     }
74     
75     protected void firePropertyChanged(BundleObject object, String JavaDoc property,
76             Object JavaDoc oldValue, Object JavaDoc newValue) {
77         IModelChangeProvider provider = model;
78         provider.fireModelObjectChanged(object, property, oldValue, newValue);
79     }
80
81     public void write(String JavaDoc indent, PrintWriter JavaDoc writer) {
82         writer.print(indent);
83         writer.print(toString());
84     }
85
86     /**
87      * @param model
88      */

89     public void reconnect(IBundleModel model) {
90         // Transient Field: Model
91
this.model = model;
92     }
93
94     /* (non-Javadoc)
95      * @see org.eclipse.pde.internal.core.plugin.IWritableDelimeter#writeDelimeter(java.io.PrintWriter)
96      */

97     public void writeDelimeter(PrintWriter JavaDoc writer) {
98         writer.println(',');
99         writer.print(' ');
100     }
101     
102 }
103
Popular Tags