01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 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.feature;
11:
12: import org.eclipse.core.runtime.CoreException;
13: import org.eclipse.pde.core.IIdentifiable;
14: import org.w3c.dom.Node;
15:
16: public class IdentifiableObject extends FeatureObject implements
17: IIdentifiable {
18: private static final long serialVersionUID = 1L;
19: protected String id;
20:
21: public String getId() {
22: return id;
23: }
24:
25: protected void parse(Node node) {
26: super .parse(node);
27: id = getNodeAttribute(node, "id"); //$NON-NLS-1$
28: }
29:
30: public void setId(String id) throws CoreException {
31: ensureModelEditable();
32: Object oldValue = this .id;
33: this .id = id;
34: firePropertyChanged(this , P_ID, oldValue, id);
35: }
36:
37: public void restoreProperty(String name, Object oldValue,
38: Object newValue) throws CoreException {
39: if (name.equals(P_ID)) {
40: setId(newValue != null ? newValue.toString() : null);
41: } else
42: super .restoreProperty(name, oldValue, newValue);
43: }
44:
45: protected void reset() {
46: super.reset();
47: id = null;
48: }
49: }
|