01: /*******************************************************************************
02: * Copyright (c) 2005, 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.product;
11:
12: import org.eclipse.core.runtime.PlatformObject;
13: import org.eclipse.pde.core.IModelChangeProvider;
14: import org.eclipse.pde.core.ModelChangedEvent;
15: import org.eclipse.pde.internal.core.iproduct.IProduct;
16: import org.eclipse.pde.internal.core.iproduct.IProductModel;
17: import org.eclipse.pde.internal.core.iproduct.IProductObject;
18: import org.eclipse.pde.internal.core.util.PDEXMLHelper;
19:
20: public abstract class ProductObject extends PlatformObject implements
21: IProductObject {
22:
23: private transient IProductModel fModel;
24:
25: public ProductObject(IProductModel model) {
26: fModel = model;
27: }
28:
29: /* (non-Javadoc)
30: * @see org.eclipse.pde.internal.core.iproduct.IProductObject#getModel()
31: */
32: public IProductModel getModel() {
33: return fModel;
34: }
35:
36: public void setModel(IProductModel model) {
37: fModel = model;
38: }
39:
40: /* (non-Javadoc)
41: * @see org.eclipse.pde.internal.core.iproduct.IProductObject#getProduct()
42: */
43: public IProduct getProduct() {
44: return getModel().getProduct();
45: }
46:
47: protected void firePropertyChanged(String property,
48: Object oldValue, Object newValue) {
49: firePropertyChanged(this , property, oldValue, newValue);
50: }
51:
52: protected void firePropertyChanged(IProductObject object,
53: String property, Object oldValue, Object newValue) {
54: if (fModel.isEditable()) {
55: IModelChangeProvider provider = fModel;
56: provider.fireModelObjectChanged(object, property, oldValue,
57: newValue);
58: }
59: }
60:
61: protected void fireStructureChanged(IProductObject child,
62: int changeType) {
63: fireStructureChanged(new IProductObject[] { child }, changeType);
64: }
65:
66: protected void fireStructureChanged(IProductObject[] children,
67: int changeType) {
68: if (fModel.isEditable()) {
69: IModelChangeProvider provider = fModel;
70: provider.fireModelChanged(new ModelChangedEvent(provider,
71: changeType, children, null));
72: }
73: }
74:
75: protected boolean isEditable() {
76: return getModel().isEditable();
77: }
78:
79: public String getWritableString(String source) {
80: return PDEXMLHelper.getWritableString(source);
81: }
82:
83: }
|