KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > feature > FeatureInstallHandler


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.feature;
12
13 import java.io.PrintWriter JavaDoc;
14
15 import org.eclipse.core.runtime.CoreException;
16 import org.eclipse.pde.internal.core.ifeature.IFeatureInstallHandler;
17 import org.w3c.dom.Node JavaDoc;
18
19 public class FeatureInstallHandler
20     extends FeatureObject
21     implements IFeatureInstallHandler {
22     private static final long serialVersionUID = 1L;
23     private String JavaDoc fLibrary;
24     private String JavaDoc fHandlerName;
25
26     /*
27      * @see IFeatureInstallHandler#getLibrary()
28      */

29     public String JavaDoc getLibrary() {
30         return fLibrary;
31     }
32
33     /*
34      * @see IFeatureInstallHandler#getClassName()
35      */

36     public String JavaDoc getHandlerName() {
37         return fHandlerName;
38     }
39
40     /*
41      * @see IFeatureInstallHandler#setLibrary(String)
42      */

43     public void setLibrary(String JavaDoc library) throws CoreException {
44         ensureModelEditable();
45         Object JavaDoc oldValue = this.fLibrary;
46         this.fLibrary = library;
47         firePropertyChanged(P_LIBRARY, oldValue, library);
48     }
49
50     /*
51      * @see IFeatureInstallHandler#setClassName(String)
52      */

53     public void setHandlerName(String JavaDoc handlerName) throws CoreException {
54         ensureModelEditable();
55         Object JavaDoc oldValue = this.fHandlerName;
56         this.fHandlerName = handlerName;
57         firePropertyChanged(P_HANDLER_NAME, oldValue, handlerName);
58     }
59     public void restoreProperty(String JavaDoc name, Object JavaDoc oldValue, Object JavaDoc newValue)
60         throws CoreException {
61         if (name.equals(P_LIBRARY)) {
62             setLibrary((String JavaDoc) newValue);
63         } else if (name.equals(P_HANDLER_NAME)) {
64             setHandlerName((String JavaDoc) newValue);
65         } else
66             super.restoreProperty(name, oldValue, newValue);
67     }
68     protected void parse(Node JavaDoc node) {
69         fLibrary = getNodeAttribute(node, "library"); //$NON-NLS-1$
70
fHandlerName = getNodeAttribute(node, "handler"); //$NON-NLS-1$
71
}
72     public void write(String JavaDoc indent, PrintWriter JavaDoc writer) {
73         writer.print(indent + "<install-handler"); //$NON-NLS-1$
74
if (fLibrary != null) {
75             writer.print(" library=\"" + fLibrary + "\""); //$NON-NLS-1$ //$NON-NLS-2$
76
}
77         if (fHandlerName != null) {
78             writer.print(" handler=\"" + fHandlerName + "\""); //$NON-NLS-1$ //$NON-NLS-2$
79
}
80         writer.println("/>"); //$NON-NLS-1$
81
//writer.println(indent + "</install-handler>");
82
}
83 }
84
Popular Tags