Subversion Repositories general

Compare Revisions

No changes between revisions

Ignore whitespace Rev 793 → Rev 794

/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.55 $
* @version $Revision: 1.56 $
*
* Last modification: $Date: 2003/07/24 19:19:27 $
* $Id: PluginManager.java,v 1.55 2003/07/24 19:19:27 smcsporr Exp $
* Last modification: $Date: 2003/07/24 22:18:06 $
* $Id: PluginManager.java,v 1.56 2003/07/24 22:18:06 ioklasse Exp $
*/
 
package src.plugins;
56,7 → 56,7
*
* @author Sascha Walkenhorst
*
* @version $Revision: 1.55 $ Last modification: $Date: 2003/07/24 19:19:27 $
* @version $Revision: 1.56 $ Last modification: $Date: 2003/07/24 22:18:06 $
*/
public class PluginManager implements TreeSelectionListener,
PluginManagerInterface,
192,7 → 192,7
plugins = lookupPlugins(pluginsPath);
/* get associations of elements with plugins */
//associations = readPluginAssociationsFromConfiguration();
// associations = readPluginAssociationsFromConfiguration();
associations = readPluginAssociations();
/* get name of default plugin out of configuration */
311,8 → 311,8
/* case: user must choose a path */
if (!candidateIsOK) {
candidate = JOptionPane.showInputDialog(
+ "Choose the directory the plugins are located." +
+ "\n(default: src/plugin)" +
"\nold value:",
candidate);
@@ -750,14 +750,17 @@
* selected element in a tree (especially in <code>PopUpJTree</code>) is
* extracted from the <code>TreePath</code> provided by the
* <code>TreeSelectionEvent</code>. Then it calls the transformation
- * method to transform the document into the form, the plugin likes.
- * Finally this method gives the transformed document to the plugin and
- * put its name to the list <code>documents</code> as the active plugin,
- * and saves the path of the selected element to tell <code>UpdateView</code>
- * in method <code>firedOurEvent</code> the path of the old element if this
- * class gets an <code>OurEvent</code> from an plugin.<p>
+ * method to transform the document and the selected into the form, the plugin
+ * likes. The transformed document as the environment and the transformed
+ * selected element are given to the plugin. Additionally is the
+ * <code>TreePath</code> given to the plugin, so the plugin knows the context
+ * of the selected node. Finally this method puts the plugins name to the list
+ * <code>documents</code> as the active plugin,and saves the path of the
+ * selected element to tell <code>UpdateView</code> in method
+ * <code>firedOurEvent</code> the path of the old element if this class gets
+ * an <code>OurEvent</code> from an plugin.<p>
*
- * This method is used to anable the <code>PluginManager</code> calling
+ * This method is used to enable the <code>PluginManager</code> calling
* the plugin associated with a element.
*
* @param tSE Event fired when selection in a tree changes.
@@ -766,7 +769,7 @@
*
* author Sascha Walkenhorst
*
- * Last Revision: 22-Jul-2003 by Sascha W.
+ * Last Revision: 25-Jul-2003 by Sascha W.
*/
public void valueChanged(TreeSelectionEvent tSE) {
/* case: a new element has been selected */
@@ -826,6 +829,13 @@
//System.out.println("selected Node: " + selectedNode.getLocalName());
+ /* get the transformer needed for transformation of node and environment
+ * for the associated plugin */
+ OurTransformer transformer = (OurTransformer) ((Hashtable) plugins.get(associatedPlugin)).get("xslTo");
+
+ /* get transformed environment for plugin (the actual document) and make it 'final' */
+ final Document environment = transformer.transformNode(documentManagerInterface.getActualDocument()).getOwnerDocument();
+
/* for the transformed node */
final Node transformedNode;
@@ -836,9 +846,6 @@
|| selectedNode.getNodeType() == Node.ENTITY_NODE)
{
- /* get the transformer needed for transformation of node for the associated plugin */
- OurTransformer transformer = (OurTransformer) ((Hashtable) plugins.get(associatedPlugin)).get("xslTo");
-
/* transform the selected node and make it 'final' */
//testing output
System.out.println("PluginManager: try to transform selected node...");
@@ -864,9 +871,6 @@
transformedNode = selectedNode.cloneNode(true);
}
- /* get environment for plugin (the actual document) and make it 'final' */
- final Document environment = documentManagerInterface.getActualDocument();
-
/* get 'PluginLoader' of plugin for the selected element */
PluginLoader actualPL = (PluginLoader) ((Hashtable) plugins.get(associatedPlugin)).get("loader");
@@ -1166,7 +1170,7 @@
* the associated plugin for the fired node is started. This has the following effect:
* Imagine you are working with the <em>ImageViewer</em>-plugin and switched to the
* <em>TextEditor</em>-plugin. If you change the type of the node, give it the new
- * name <em>DUMMY</em>, and then switch back to associated plugin, the plugi will be
+ * name <em>DUMMY</em>, and then switch back to associated plugin, the plugin will be
* started which is associated with the elements with name <em>DUMMY</em>.
*
* TODO test
@@ -1173,7 +1177,7 @@
*
* author Sascha Walkenhorst
*
- * Last revision: 23-Jul-2003 by Sascha W.
+ * Last revision: 25-Jul-2003 by Sascha W.
*/
private void switchToAndFroDefaultPlugin() {
//testing output
@@ -1198,9 +1202,6 @@
/* get the Node of TreePath, needed by new started plugin */
Node node=((AdapterNode)tp.getLastPathComponent()).toDomNode();
- /* get environment, needed by new started plugin, and make it 'final' */
- final Document environment = documentManagerInterface.getActualDocument();
-
Node transformedNode = null;
/* case: actual plugin is the default plugin
@@ -1213,12 +1214,16 @@
//testing output
System.out.println("name of transferred node: " + elementName + ", associated plugin: " + associatedPlugin);
+ OurTransformer transformer = (OurTransformer) ((Hashtable) plugins.get(associatedPlugin)).get("xslTo");
+
+ /* get transformed environment, needed by new started plugin, and make it 'final' */
+ final Document environment = transformer.transformNode(documentManagerInterface.getActualDocument()).getOwnerDocument();
+
/* case: node has 'normal' type -> transform it */
if( node.getNodeType() == Node.ELEMENT_NODE
|| node.getNodeType() == Node.ENTITY_NODE)
{
/* transform node for assosciated plugin */
- OurTransformer transformer = (OurTransformer) ((Hashtable) plugins.get(associatedPlugin)).get("xslTo");
transformedNode = transformer.transformNode(node);
}
/* node of 'unnormal' type -> must not be transformed */
@@ -1238,12 +1243,16 @@
* -> switch to default plugin */
else {
+ OurTransformer transformer = (OurTransformer) ((Hashtable) plugins.get(defaultPluginName)).get("xslTo");
+
+ /* get transformed environment, needed by new started plugin, and make it 'final' */
+ final Document environment = transformer.transformNode(documentManagerInterface.getActualDocument()).getOwnerDocument();
+
/* case: node has 'normal' type -> transform it */
if( node.getNodeType() == Node.ELEMENT_NODE
|| node.getNodeType() == Node.ENTITY_NODE)
{
/* transform node for default plugin */
- OurTransformer transformer = (OurTransformer) ((Hashtable) plugins.get(actualDocumentName)).get("xslTo");
transformedNode = transformer.transformNode(node);
}
/* node of 'unnormal' type -> must not be transformed */
@@ -1274,27 +1283,29 @@
*
* author Sascha Walkenhorst
*
- * Last revision: 21-Jul-2003 by Sascha W.
+ * Last revision: 25-Jul-2003 by Sascha W.
*/
public void actionPerformed(ActionEvent e) {
/* case: user wants to reset plugin settings */
- if (e.getActionCommand() == "reset configuration") {
+ if (e.getActionCommand() == "Reset configuration") {
reset(configurationFilePath);
}
/* case: user wants to change default plugin */
- if (e.getActionCommand() == "change default plugin") {
+ if (e.getActionCommand() == "Change default plugin") {
defaultPluginName = chooseDefaultPluginName();
}
/* case: user wants to switch between associated plugin and default plugin */
- if (e.getActionCommand() == "switch to and fro default plugin") {
+ if (e.getActionCommand() == "Switch to and fro default plugin") {
switchToAndFroDefaultPlugin();
}
/* case: show the actual configuration */
- if (e.getActionCommand() == "show actual configuration") {
+ if (e.getActionCommand() == "Show actual configuration") {
listVariables();
+ System.out.println(e.paramString());
+ System.out.println(e.getSource());
}
}