KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > target > TargetObject


1 /*******************************************************************************
2  * Copyright (c) 2005, 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.target;
12
13 import org.eclipse.core.runtime.PlatformObject;
14 import org.eclipse.pde.core.IModelChangeProvider;
15 import org.eclipse.pde.core.ModelChangedEvent;
16 import org.eclipse.pde.internal.core.itarget.ITarget;
17 import org.eclipse.pde.internal.core.itarget.ITargetModel;
18 import org.eclipse.pde.internal.core.itarget.ITargetObject;
19 import org.eclipse.pde.internal.core.util.PDEXMLHelper;
20
21 public abstract class TargetObject extends PlatformObject implements ITargetObject {
22
23     private transient ITargetModel fModel;
24     
25     public TargetObject(ITargetModel model) {
26         fModel = model;
27     }
28
29     public ITargetModel getModel() {
30         return fModel;
31     }
32
33     public void setModel(ITargetModel model) {
34         fModel = model;
35     }
36
37     public ITarget getTarget() {
38         return getModel().getTarget();
39     }
40
41     protected void firePropertyChanged(String JavaDoc property, Object JavaDoc oldValue, Object JavaDoc newValue) {
42         firePropertyChanged(this, property, oldValue, newValue);
43     }
44
45     protected void firePropertyChanged(ITargetObject object, String JavaDoc property,
46             Object JavaDoc oldValue, Object JavaDoc newValue) {
47         if (fModel.isEditable()) {
48             IModelChangeProvider provider = fModel;
49             provider.fireModelObjectChanged(object, property, oldValue, newValue);
50         }
51     }
52
53     protected void fireStructureChanged(ITargetObject child, int changeType) {
54         fireStructureChanged(new ITargetObject[] { child }, changeType);
55     }
56
57     protected void fireStructureChanged(ITargetObject[] children, int changeType) {
58         if (fModel.isEditable()) {
59             IModelChangeProvider provider = fModel;
60             provider.fireModelChanged(new ModelChangedEvent(provider, changeType,
61                     children, null));
62         }
63     }
64
65     protected boolean isEditable() {
66         return getModel().isEditable();
67     }
68
69     public String JavaDoc getWritableString(String JavaDoc source) {
70         return PDEXMLHelper.getWritableString(source);
71     }
72
73 }
74
Popular Tags