Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 742 → Rev 743

/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.50 $
* @version $Revision: 1.51 $
*
* Last modification: $Date: 2003/07/22 14:06:58 $
* $Id: PluginManager.java,v 1.50 2003/07/22 14:06:58 swalkenh Exp $
* Last modification: $Date: 2003/07/22 16:14:23 $
* $Id: PluginManager.java,v 1.51 2003/07/22 16:14:23 swalkenh Exp $
*/
 
package src.plugins;
44,6 → 44,7
import src.control.OurEventListener;
import src.gui.GuiInterface;
import src.gui.LogInterface;
import src.gui.UpdateViewInterface;
import src.parser.AdapterNode;
 
 
55,7 → 56,7
*
* @author Sascha Walkenhorst
*
* @version $Revision: 1.50 $ Last modification: $Date: 2003/07/22 14:06:58 $
* @version $Revision: 1.51 $ Last modification: $Date: 2003/07/22 16:14:23 $
*/
public class PluginManager implements TreeSelectionListener,
PluginManagerInterface,
88,9 → 89,12
/** name of the default plugin */
private String defaultPluginName;
/** needed to get the selected node */
/** needed to get the actual document */
private DocumentManagerInterface documentManagerInterface;
 
/** needed to get the selected node in method <code>switchToAndFroDefaultPlugin</code> */
private UpdateViewInterface updateViewInterface;
/** for messages to a log area */
private LogInterface logInterfaceReference;
108,6 → 112,10
/** needed for correct updating nodes */
private Node lastUpdatedNode;
private Node retransformedNode = null;
 
/**
1050,11 → 1058,11
 
 
/**
* Sets the internal DocumentManagerInterface-variable. Used to get the
* selected node in method <code>valueChanged</code>.
* Sets the internal <code>DocumentManagerInterface</code>-variable. Used to get the
* actual document in method <code>valueChanged</code>.
*
* @param newDocumentManagerInterface:
*
* @param newDocumentManagerInterface The needed <code>DocumentManagerInterface</code>.
*
* author Sascha Walkenhorst
*
* Last revision: 12-Jul-2003 by Sascha W.
1065,6 → 1073,21
 
 
/**
* Sets the internal <code>UpdateViewInterface</code>-variable. Used to get the
* selected node in method <code>valueChanged</code>.
*
* @param newUpdateViewInterface The needed <code>UpdateViewInterface</code>.
*
* author Sascha Walkenhorst
*
* Last revision: 23-Jul-2003 by Sascha W.
*/
public void setUpdateViewInterface(UpdateViewInterface newUpdateViewInterface) {
updateViewInterface = newUpdateViewInterface;
}
 
 
/**
* Delivers the informations fired by a plugin with the path of the former selected
* element to the listener of this class. It awaits an <code>OurEvent</code>-object
* fired by a plugin which contains the old followed by the perhaps new node. The
1086,7 → 1109,7
* Last Revision: 19-Jul-2003 by Matthias D.
*/
public void firedOurEvent(OurEvent e) {
Node retransformedNode = null;
// Node retransformedNode = null;
/* read out the event contents */
Object[] oldMessage = (Object[]) e.getSource();
1142,47 → 1165,84
 
 
/**
* ...
* This method performs the switching between the associated and the default plugin.
* It stops the actual plugin and starts the new plugin with the node which has been
* fired from stopped active plugin. If the active plugin was an assosciated plugin
* the new plugin is the default plugin, if the active plugin was the default plugin
* 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
* started which is associated with the elements with name <em>DUMMY</em>.
*
* TODO set up, comment
* TODO test
*
* author Sascha Walkenhorst
*
* Last revision: 21-Jul-2003 by Sascha W.
* Last revision: 23-Jul-2003 by Sascha W.
*/
private void switchToAndFroDefaultPlugin() {
//for testing only!
//testing output
System.out.println("PluginManager - method \"switchToAndFroDefaultPlugin()\" running...");
return;
// return;
 
/* get name of actual plugin for actual document */
String actualDocumentName = documentManagerInterface.getActualDocumentName();
LinkedList lL = (LinkedList) documents.get(actualDocumentName);
String actualPlugin = (String) lL.getFirst();
// /* get name of active plugin for actual document */
// String actualDocumentName = documentManagerInterface.getActualDocumentName();
// LinkedList lL = (LinkedList) documents.get(actualDocumentName);
// String actualPlugin = (String) lL.getFirst();
//
// /* case: actual plugin and default plugin are the same plugin
// * -> no need to change */
// if (actualPlugin == defaultPluginName) {
//
// }
// else {
// /* stop the active plugin */
// PluginLoader pL = (PluginLoader) ((Hashtable) plugins.get(actualPlugin)).get("loader");
// pL.stopPlugin(actualDocumentName);
//
// //get node, transform it?, which TreePath?
//
// /* get environment for default plugin (the actual document) and make it 'final' */
// final Document environment = documentManagerInterface.getActualDocument();
//
// /* get 'PluginLoader' of default plugin */
// PluginLoader defaultPL = (PluginLoader) ((Hashtable) plugins.get(defaultPluginName)).get("loader");
//
// /* start the default plugin with transformed node and environment */
// //defaultPL.startPlugin(transformedNode, environment, tp, actualDocumentName);
//
// //...
// }
/* stop actual plugin */
PluginLoader actualPL = (PluginLoader) ((Hashtable) plugins.get(actualPlugin)).get("loader");
actualPL.stopPlugin(actualDocumentName);
 
/* get the TreePath for node, transferred from stopped active plugin,
* needed by new started plugin */
TreePath tp = updateViewInterface.getActualSelectedPath();
System.out.println(tp);
 
/* 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();
 
/* case: actual plugin is the default plugin
* -> switch to associated plugin */
if (actualPlugin == defaultPluginName) {
/* get associated plugin for node */
String elementName = node.getNodeName();
String associatedPlugin = getAssociatedPlugin(elementName);
//testing output
System.out.println("name of transferred node: " + elementName + ", associated plugin: " + associatedPlugin);
/* transform node for assosciated plugin */
OurTransformer transformer = (OurTransformer) ((Hashtable) plugins.get(associatedPlugin)).get("xslTo");
Node transformedNode = transformer.transformNode(node);
/* get 'PluginLoader' of default plugin */
PluginLoader associatedPL = (PluginLoader) ((Hashtable) plugins.get(associatedPlugin)).get("loader");
/* start the associated plugin with transformed node and environment */
associatedPL.startPlugin(transformedNode, environment, tp, actualDocumentName);
}
/* case: actual plugin is not the default plugin (this means that the actual
* plugin is a associated plugin because the option "switchToAndFroDefaultPlugin"
* is not available if the default plugin was started after selecting a element)
* -> switch to default plugin */
else {
/* transform node for default plugin */
OurTransformer transformer = (OurTransformer) ((Hashtable) plugins.get(defaultPluginName)).get("xslTo");
Node transformedNode = transformer.transformNode(node);
/* get 'PluginLoader' of default plugin */
PluginLoader defaultPL = (PluginLoader) ((Hashtable) plugins.get(defaultPluginName)).get("loader");
/* start the default plugin with transformed node and environment */
defaultPL.startPlugin(transformedNode, environment, tp, actualDocumentName);
}
}