01: /*
02: * $Id: JGraphpadTWikiPlugin.java,v 1.6 2005/10/09 12:00:04 gaudenz Exp $
03: * Copyright (c) 2001-2005, Gaudenz Alder
04: *
05: * All rights reserved.
06: *
07: * See LICENSE file for license details. If you are unable to locate
08: * this file please contact info (at) jgraph (dot) com.
09: */
10: package com.jgraph.twikiplugin;
11:
12: import java.io.IOException;
13:
14: import javax.xml.parsers.ParserConfigurationException;
15:
16: import org.w3c.dom.Node;
17: import org.xml.sax.SAXException;
18:
19: import com.jgraph.JGraphEditor;
20: import com.jgraph.JGraphpad;
21: import com.jgraph.editor.JGraphEditorKit;
22: import com.jgraph.editor.JGraphEditorPlugin;
23: import com.jgraph.editor.JGraphEditorResources;
24: import com.jgraph.editor.JGraphEditorSettings;
25:
26: /**
27: * Action to embed JGraphpad Pro into a TWiki (or other Webapplication). The
28: * upload action requires a -upload URL option and filename to be passed to the
29: * editor at startup, the latter also being a URL.<br>
30: * If the filename is not found for the URL, a new file is created using the URL
31: * as the filename by JGraphpad. <br>
32: * The URL option is used to upload 3 files, using the basename of the diagram
33: * filename. For example, a diagram filename of
34: * http://www.example.com/diagrams/test.xml.gz will result in a basename of
35: * test being used to upload test.xml.gz, test.map and test.png. Note that the
36: * map file is only uploaded if the image map is not empty, ie. if the diagram's
37: * business objects contain at least one property for the name <code>url</code>.
38: */
39: public class JGraphpadTWikiPlugin implements JGraphEditorPlugin {
40:
41: /**
42: * Defines the path to the UI configuration to be merged into the existing
43: * UI configuration.
44: */
45: public static String PATH_UICONFIG = "/com/jgraph/twikiplugin/resources/ui.xml";
46:
47: /**
48: * Adds resource bundles.
49: */
50: static {
51: JGraphEditorResources
52: .addBundles(new String[] { "com.jgraph.twikiplugin.resources.strings" });
53: }
54:
55: /**
56: * Initializes the plugin by registering all action bundles and merging the
57: * UI configuration into the main configuration.
58: *
59: * @param editor
60: * The enclosing editor for the plugin.
61: * @param configuration
62: * The object to configure the plugin with.
63: */
64: public void initialize(JGraphEditor editor, Node configuration)
65: throws ParserConfigurationException, SAXException,
66: IOException {
67: JGraphEditorKit kit = editor.getKit();
68: kit.addBundle(new JGraphpadTWikiAction.AllActions(editor));
69: editor.getSettings().add(
70: JGraphpad.NAME_UICONFIG,
71: JGraphEditorSettings.parse(JGraphEditorResources
72: .getInputStream(PATH_UICONFIG)));
73:
74: // Removes some unwanted actions
75: // editor.getKit().getActions().remove(JGraphpadFileAction.NAME_SAVE);
76: // editor.getKit().getActions()
77: // .remove(JGraphpadFileAction.NAME_NEWDIAGRAM);
78: }
79:
80: }
|