4,10 → 4,10 |
* Coded by: Group 5, software practice summer 2003 |
* University of Bielefeld, Germany |
* |
* @version $Revision: 1.63 $ |
* @version $Revision: 1.64 $ |
* |
* Last modification: $Date: 2003/07/26 11:39:29 $ |
* $Id: PluginManager.java,v 1.63 2003/07/26 11:39:29 swalkenh Exp $ |
* Last modification: $Date: 2003/07/26 11:51:45 $ |
* $Id: PluginManager.java,v 1.64 2003/07/26 11:51:45 swalkenh Exp $ |
*/ |
|
package src.plugins; |
67,7 → 67,7 |
* |
* @author Sascha Walkenhorst |
* |
* @version $Revision: 1.63 $ Last modification: $Date: 2003/07/26 11:39:29 $ |
* @version $Revision: 1.64 $ Last modification: $Date: 2003/07/26 11:51:45 $ |
*/ |
public class PluginManager implements TreeSelectionListener, |
PluginManagerInterface, |
124,9 → 124,7 |
/** needed for correct updating nodes */ |
private Node lastUpdatedNode; |
|
private Node retransformedNode = null; |
|
|
|
/** |
* Default constuctor, starts making list of plugins and the associations |
* with XML-elements. First it sets the internal variable for the |
146,7 → 144,7 |
* |
* author Sascha Walkenhorst |
* |
* Last Revision: 21-Jul-2003 by Sascha W. |
* Last Revision: 21-Jul-2003 by S. Walkenhorst |
*/ |
public PluginManager(String configFilePath, |
GuiInterface newGuiInterface, |
188,7 → 186,7 |
* |
* author Sascha Walkenhorst |
* |
* Last Revision: 21-Jul-2003 by Sascha W. |
* Last Revision: 21-Jul-2003 by S. Walkenhorst |
*/ |
public void reset(String configFilePath) { |
|
230,7 → 228,7 |
* |
* author Sascha Walkenhorst |
* |
* Last Revision: 05-Jul-2003 by Sascha W. |
* Last Revision: 05-Jul-2003 by S. Walkenhorst |
*/ |
private Document readConfigurationFile(File configFile) { |
Document tempDocument = null; |
280,7 → 278,7 |
* |
* author Sascha Walkenhorst |
* |
* Last Revision: 26-Jul-2003 by Sascha W. |
* Last Revision: 26-Jul-2003 by S. Walkenhorst |
*/ |
private String readPluginsPath(Document config) { |
String candidate = null; |
361,7 → 359,7 |
* |
* author Sascha Walkenhorst |
* |
* Last Revision: 15-Jul-2003 by Sascha W. |
* Last Revision: 15-Jul-2003 by S. Walkenhorst |
*/ |
private Hashtable lookupPlugins(String path) { |
Hashtable jars = new Hashtable(); |
497,7 → 495,7 |
* |
* author Sascha Walkenhorst |
* |
* Last Revision: 12-Jul-2003 by Sascha W. |
* Last Revision: 12-Jul-2003 by S. Walkenhorst |
*/ |
private String[] lookupManifest(JarFile archive) { |
/* get the Manifest of the archive */ |
545,7 → 543,7 |
* |
* author Sascha Walkenhorst |
* |
* Last Revision: 13-Jul-2003 by Sascha W. |
* Last Revision: 13-Jul-2003 by S. Walkenhorst |
*/ |
private Hashtable readPluginAssociations() { |
Hashtable hashtable = new Hashtable(); |
631,7 → 629,7 |
* |
* author Sascha Walkenhorst |
* |
* Last Revision: 15-Jul-2003 by Sascha W. |
* Last Revision: 15-Jul-2003 by S. Walkenhorst |
*/ |
private Hashtable readPluginAssociationsFromConfiguration() { |
Hashtable hashtable = new Hashtable(); |
695,7 → 693,7 |
* |
* author Sascha Walkenhorst |
* |
* Last Revision: 22-Jul-2003 by Sascha W. |
* Last Revision: 22-Jul-2003 by S. Walkenhorst |
*/ |
private String readDefaultPluginName(Document config) { |
String candidate = null; |
744,7 → 742,7 |
* |
* author Sascha Walkenhorst |
* |
* Last revision: 25-Jul-2003 by Sascha W. |
* Last revision: 25-Jul-2003 by S. Walkenhorst |
*/ |
private String chooseDefaultPluginName() { |
/* create the available plugins as options for dialog */ |
808,7 → 806,7 |
* |
* author Sascha Walkenhorst |
* |
* Last Revision: 25-Jul-2003 by Sascha W. |
* Last Revision: 25-Jul-2003 by S. Walkenhorst |
*/ |
public void valueChanged(TreeSelectionEvent tSE) { |
/* case: a new element has been selected */ |
954,7 → 952,7 |
* |
* author Sascha Walkenhorst |
* |
* Last Revision: 06-Jul-2003 by Sascha W. |
* Last Revision: 06-Jul-2003 by S. Walkenhorst |
*/ |
public String getAssociatedPlugin(String element) { |
String linkedTo = null; |
983,7 → 981,7 |
* |
* author Sascha Walkenhorst |
* |
* Last Revision: 13-Jul-2003 by Sascha W. |
* Last Revision: 13-Jul-2003 by S. Walkenhorst |
*/ |
public void documentClosed(String closedDocumentName) { |
LinkedList lL = (LinkedList) documents.get(closedDocumentName); |
1022,7 → 1020,7 |
* |
* author Sascha Walkenhorst |
* |
* Last Revision: 13-Jul-2003 by Sascha W. |
* Last Revision: 13-Jul-2003 by S. Walkenhorst |
*/ |
public TreeSelectionListener getTreeSelectionListener() { |
return this; |
1037,7 → 1035,7 |
* |
* author Sascha Walkenhorst |
* |
* Last Revision: 12-Jul-2003 by Sascha W. |
* Last Revision: 12-Jul-2003 by S. Walkenhorst |
*/ |
private void listVariables() { |
System.out.println("variables of PluginManager:"); |
1105,7 → 1103,7 |
* |
* author Sascha Walkenhorst |
* |
* Last revision: 12-Jul-2003 by Sascha W. |
* Last revision: 12-Jul-2003 by S. Walkenhorst |
*/ |
public void setDocumentManagerInterface(DocumentManagerInterface newDocumentManagerInterface) { |
documentManagerInterface = newDocumentManagerInterface; |
1120,7 → 1118,7 |
* |
* author Sascha Walkenhorst |
* |
* Last revision: 23-Jul-2003 by Sascha W. |
* Last revision: 23-Jul-2003 by S. Walkenhorst |
*/ |
public void setUpdateViewInterface(UpdateViewInterface newUpdateViewInterface) { |
updateViewInterface = newUpdateViewInterface; |
1146,7 → 1144,7 |
* |
* author Sascha Walkenhorst |
* |
* Last Revision: 19-Jul-2003 by Matthias D. |
* Last Revision: 28-Jul-2003 by S. Walkenhorst |
*/ |
public void firedOurEvent(OurEvent e) { |
Node retransformedNode = null; |
1154,32 → 1152,35 |
/* read out the event contents */ |
Object[] oldMessage = (Object[]) e.getSource(); |
|
/* only nodes of type "element" and "entity" can be transformed with stylesheet others, |
* for example "text" and "processing instruction" result in a node which is 'null' */ |
/* case: node has 'normal' type -> transform it */ |
if( ((Node) oldMessage[1]).getNodeType() == Node.ELEMENT_NODE |
|| ((Node) oldMessage[1]).getNodeType() == Node.ENTITY_NODE) |
{ |
/* case: new node (oldMessage[1]) is not "null" -> try to transform this node */ |
if (oldMessage[1] != null) { |
/* only nodes of type "element" and "entity" can be transformed with stylesheet others, |
* for example "text" and "processing instruction" result in a node which is 'null' */ |
/* case: node has 'normal' type -> transform it */ |
if( ((Node) oldMessage[1]).getNodeType() == Node.ELEMENT_NODE |
|| ((Node) oldMessage[1]).getNodeType() == Node.ENTITY_NODE) |
{ |
|
/* get transformer for back direction and transform new node */ |
String oldSelectedElementName = oldSelectedElement.getLastPathComponent().toString().split(" : ")[0]; |
String associatedPlugin = getAssociatedPlugin(oldSelectedElementName); |
//testing output |
System.out.println("oldSelectedElementName: " + oldSelectedElementName |
+ "; associated plugin: " + associatedPlugin); |
/* get transformer for back direction and transform new node */ |
String oldSelectedElementName = oldSelectedElement.getLastPathComponent().toString().split(" : ")[0]; |
String associatedPlugin = getAssociatedPlugin(oldSelectedElementName); |
//testing output |
System.out.println("oldSelectedElementName: " + oldSelectedElementName |
+ "; associated plugin: " + associatedPlugin); |
|
//OurTransformer transformer = (OurTransformer) ((Hashtable) plugins.get(associatedPlugin)).get("xslFro"); |
OurTransformer transformer = (OurTransformer) ((Hashtable) plugins.get((String) oldMessage[2])).get("xslFro"); |
retransformedNode = transformer.transformNode((Node) oldMessage[1]); |
} |
else { |
//testing output |
System.out.println("Node type old = " + ((Node) oldMessage[1]).getNodeType()); |
//OurTransformer transformer = (OurTransformer) ((Hashtable) plugins.get(associatedPlugin)).get("xslFro"); |
OurTransformer transformer = (OurTransformer) ((Hashtable) plugins.get((String) oldMessage[2])).get("xslFro"); |
retransformedNode = transformer.transformNode((Node) oldMessage[1]); |
} |
else { |
//testing output |
System.out.println("Node type old = " + ((Node) oldMessage[1]).getNodeType()); |
|
/* this node of 'unnormal' type must not be transformed */ |
retransformedNode = ((Node) oldMessage[1]).cloneNode(true); |
/* this node of 'unnormal' type must not be transformed */ |
retransformedNode = ((Node) oldMessage[1]).cloneNode(true); |
|
System.out.println("Retransformed NS-URI = " + retransformedNode.getNamespaceURI()); |
System.out.println("Retransformed NS-URI = " + retransformedNode.getNamespaceURI()); |
} |
} |
|
/* oldIndex is set to the indexposition of the node which should be updated */ |
1219,7 → 1220,7 |
* |
* author Sascha Walkenhorst |
* |
* Last revision: 25-Jul-2003 by Sascha W. |
* Last revision: 25-Jul-2003 by S. Walkenhorst |
*/ |
private void switchToAndFroDefaultPlugin() { |
//testing output |
1325,7 → 1326,7 |
* |
* author Sascha Walkenhorst |
* |
* Last revision: 25-Jul-2003 by Sascha W. |
* Last revision: 25-Jul-2003 by S. Walkenhorst |
*/ |
public void actionPerformed(ActionEvent e) { |
/* case: user wants to reset plugin settings */ |
1351,30 → 1352,6 |
|
|
/** |
* Transforms given node for specified plugin |
* |
* @param associatedPlugin name of associated plugin for the node |
* @param node the node |
* |
* @return the transformed node |
* |
* autor Y.Klassen, V.Zudova |
* |
* Last revision: 24-Jul-2003 |
*/ |
public Node transformsNode(String associatedPlugin, Node node) |
{ |
/* case: no default plugin has been selected -> break up*/ |
if (associatedPlugin == null) return null; |
|
/* get the transformer needed for transformation of node for the associated plugin */ |
OurTransformer transformer = (OurTransformer) ((Hashtable) plugins.get(associatedPlugin)).get("xslTo"); |
|
return transformer.transformNode(node); |
} |
|
|
/** |
* 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 |
1384,7 → 1361,7 |
* |
* author Sascha Walkenhorst |
* |
* Last revision: 26-Jul-2003 by Sascha W. |
* Last revision: 26-Jul-2003 by S. Walkenhorst |
*/ |
public void saveConfiguration() { |
/* open element "PLUGINS" */ |