Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 836 → Rev 837

/sun/xmleditor/trunk/src/plugins/PluginManagerInterface.java
4,10 → 4,10
* Coded by: Group 5, software practice summer 2003
* University of Bielefeld, Germany
*
* @version $Revision: 1.8 $
* @version $Revision: 1.9 $
*
* Last modification: $Date: 2003/07/24 22:18:06 $
* $Id: PluginManagerInterface.java,v 1.8 2003/07/24 22:18:06 ioklasse Exp $
* Last modification: $Date: 2003/07/25 18:18:27 $
* $Id: PluginManagerInterface.java,v 1.9 2003/07/25 18:18:27 swalkenh Exp $
*/
 
package src.plugins;
26,7 → 26,7
*
* @author Sascha Walkenhorst
*
* @version $Revision: 1.8 $ Last modification: $Date: 2003/07/24 22:18:06 $
* @version $Revision: 1.9 $ Last modification: $Date: 2003/07/25 18:18:27 $
*/
public interface PluginManagerInterface {
55,6 → 55,16
/**
* Saves the name of the default plugin in the configuration.
*
* author Sascha Walkenhorst
*
* Last revision: 26-Jul-2003 by Sascha W.
*/
public void saveConfiguration();
 
/**
* Delivers the name of the associated plugin to given element.
* If no plugin is explicitly associated with the given element
* the default plugin is returned.
/sun/xmleditor/trunk/src/plugins/PluginManager.java
4,10 → 4,10
* Coded by: Group 5, software practice summer 2003
* University of Bielefeld, Germany
*
* @version $Revision: 1.61 $
* @version $Revision: 1.62 $
*
* Last modification: $Date: 2003/07/25 18:17:50 $
* $Id: PluginManager.java,v 1.61 2003/07/25 18:17:50 swalkenh Exp $
* Last modification: $Date: 2003/07/25 18:18:27 $
* $Id: PluginManager.java,v 1.62 2003/07/25 18:18:27 swalkenh Exp $
*/
 
package src.plugins;
38,7 → 38,6
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
64,7 → 63,7
*
* @author Sascha Walkenhorst
*
* @version $Revision: 1.61 $ Last modification: $Date: 2003/07/25 18:17:50 $
* @version $Revision: 1.62 $ Last modification: $Date: 2003/07/25 18:18:27 $
*/
public class PluginManager implements TreeSelectionListener,
PluginManagerInterface,
277,7 → 276,7
*
* author Sascha Walkenhorst
*
* Last Revision: 22-Jul-2003 by Sascha W.
* Last Revision: 26-Jul-2003 by Sascha W.
*/
private String readPluginsPath(Document config) {
String candidate = null;
299,7 → 298,14
Node nodePlugins = nodes.item(0);
NamedNodeMap nodeMap = nodePlugins.getAttributes();
Node nodeDefaultPlugin = nodeMap.getNamedItem("path");
candidate = nodeDefaultPlugin.getNodeValue();
try {
candidate = nodeDefaultPlugin.getNodeValue();
}
/* case: attribute "path" doesn't exists */
catch (NullPointerException e) {
System.out.println("invalid configuration file: attribute \"path\" doesn't exists");
candidate = null;
}
}
 
/* used for information flow */
320,7 → 326,7
if (!candidateIsOK) {
candidate = JOptionPane.showInputDialog(
"Choose the directory the plugins are located." +
"\n(default: src/plugin)" +
"\n(default: src/plugins)" +
"\nold value:",
candidate);
1365,50 → 1371,43
/**
* Saves the name of the default plugin in the configuration. In the former parsed
* configuration file, saved in <code>configuration</code>, the attribute
* <em>defaultplugin</em> is set to the actual value of <code>defaultPluginName</code>.
* If the requiered element <em>PLUGINS</em> doesn't exist, or more than one exists
* a new one will be created or the first will be taken, others are deleted.
* Saves the name of the default plugin and the path of the plugins in the configuration.
* In the former parsed configuration file, saved in <code>configuration</code>, the
* attributes <em>defaultplugin</em> and <em>path</em> are set to the actual value of
* <code>defaultPluginName</code> and <code>pluginsPath</code>. If the requiered element
* <em>PLUGINS</em> doesn't exist, or more than one exists a new one will be created or
* the first will be taken.
*
* TODO use me
*
* author Sascha Walkenhorst
*
* Last revision: 25-Jul-2003 by Sascha W.
* Last revision: 26-Jul-2003 by Sascha W.
*/
public void saveConfiguration() {
/* open element "PLUGINS" */
NodeList nodes = configuration.getElementsByTagName("PLUGINS");
 
/* for the attribute "defaultplugin" */
Attr attribute = null;
 
/* check if there is one element with name "PLUGINS" */
if (nodes.getLength() == 0) {
/* create a "PLUGINS"-node, make needed attribute named "defaultplugin" */
Node nodePlugins = ((Document) configuration.cloneNode(true)).createElement("PLUGINS").getElementsByTagName("PLUGINS").item(0);
Element temp = (Element) nodePlugins;
Element temp = ((Document) configuration.cloneNode(false)).createElement("PLUGINS");
temp.setAttribute("defaultplugin", defaultPluginName);
attribute = temp.getAttributeNode("defaultplugin");
/* cause its a new entry for configuration also add attribute "path" */
temp.setAttribute("path", pluginsPath);
 
/* set new node "PLUGINS" in configuration */
configuration.appendChild(nodePlugins);
Node adoptedTemp = configuration.importNode(temp, true);
configuration.getElementsByTagName("XMLEDITORCONFIGURATION").item(0).appendChild(adoptedTemp);
}
else {
/* case: more than one element with name "PLUGINS"
* -> take first, delete other elements with name "PLUGINS" */
if (nodes.getLength() > 1) {
//
}
/* case: perhaps more than one element with name "PLUGINS" -> take first */
Node nodePlugins = nodes.item(0);
Element temp = (Element) nodePlugins;
attribute = temp.getAttributeNode("defaultplugin");
temp.setAttribute("defaultplugin", defaultPluginName);
temp.setAttribute("path", pluginsPath);
}
attribute.setNodeValue(defaultPluginName);
/* save the configuration-file to file with path of "configurationFilePath" */
/* create input and output for transformation of configuration */
DOMSource source = new DOMSource(configuration);