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.site;
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 SiteObject implements
17: IIdentifiable {
18:
19: private static final long serialVersionUID = 1L;
20: protected String id;
21:
22: public String getId() {
23: return id;
24: }
25:
26: protected void parse(Node node) {
27: super .parse(node);
28: id = getNodeAttribute(node, "id"); //$NON-NLS-1$
29: }
30:
31: public boolean isValid() {
32: return id != null;
33: }
34:
35: public void setId(String id) throws CoreException {
36: ensureModelEditable();
37: Object oldValue = this .id;
38: this .id = id;
39: firePropertyChanged(this , P_ID, oldValue, id);
40: }
41:
42: public void restoreProperty(String name, Object oldValue,
43: Object newValue) throws CoreException {
44: if (name.equals(P_ID)) {
45: setId(newValue != null ? newValue.toString() : null);
46: } else
47: super .restoreProperty(name, oldValue, newValue);
48: }
49:
50: protected void reset() {
51: super.reset();
52: id = null;
53: }
54: }
|