You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by ca...@apache.org on 2007/11/13 01:40:58 UTC

svn commit: r594367 [6/9] - in /xmlgraphics/batik/trunk: ./ resources/org/apache/batik/apps/svgbrowser/resources/ resources/org/apache/batik/util/gui/resources/ sources-1.3/org/apache/batik/util/ sources-1.3/org/apache/batik/util/gui/ sources-1.4/org/a...

Added: xmlgraphics/batik/trunk/sources/org/apache/batik/apps/svgbrowser/NodeTemplates.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/apps/svgbrowser/NodeTemplates.java?rev=594367&view=auto
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/apps/svgbrowser/NodeTemplates.java (added)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/apps/svgbrowser/NodeTemplates.java Mon Nov 12 16:40:53 2007
@@ -0,0 +1,1368 @@
+/*
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+package org.apache.batik.apps.svgbrowser;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.batik.util.SVGConstants;
+import org.w3c.dom.Node;
+
+/**
+ * Provides basic xml representation and description for most commonly used
+ * nodes.
+ *
+ * @version $Id$
+ */
+public class NodeTemplates {
+
+    // Node template descriptions provide basic information on node properties,
+    // such as: xml represenation (suffix "Value"), element name
+    // (suffix "Name"), element type (suffix "Type"), element category
+    // (suffix "Category"), element description (suffix "Description").
+    // Base node name on which these suffixes are appended is read from the
+    // class members ending with "MemberName".
+
+    // Example:
+    // public static String rectMemberName = "rectElement";
+    // Other class members that describe this node should be declared as:
+    // rectElementValue = "...", rectElementType = "...", rectElementName =
+    // "...", rectElementCategory = "..." and rectElementDescription = "..."
+
+    // Suffixes
+    public static final String VALUE = "Value";
+
+    public static final String NAME = "Name";
+
+    public static final String TYPE = "Type";
+
+    public static final String DESCRIPTION = "Description";
+
+    public static final String CATEGORY = "Category";
+
+    // Categories
+    public static final String BASIC_SHAPES = "Basic Shapes";
+
+    public static final String LINKING = "Linking";
+
+    public static final String TEXT = "Text";
+
+    public static final String ANIMATION = "Animation";
+
+    public static final String CLIP_MASK_COMPOSITE = "Clipping, Masking and Compositing";
+
+    public static final String COLOR = "Color";
+
+    public static final String INTERACTIVITY = "Interactivity";
+
+    public static final String FONTS = "Fonts";
+
+    public static final String DOCUMENT_STRUCTURE = "Document Structure";
+
+    public static final String FILTER_EFFECTS = "Filter Effects";
+
+    public static final String EXTENSIBILITY = "Extensibility";
+
+    public static final String GRADIENTS_AND_PATTERNS = "Gradients and Patterns";
+
+    public static final String PAINTING = "Painting: Filling, Stroking and Marker Symbols";
+
+    public static final String METADATA = "Metadata";
+
+    public static final String PATHS = "Paths";
+
+    public static final String SCRIPTING = "Scripting";
+
+    public static final String STYLING = "Styling";
+
+    // Maps
+    /**
+     * Map with node template wrappers.
+     */
+    private Map nodeTemplatesMap = new HashMap();
+
+    /**
+     * List with all node categories.
+     */
+    private ArrayList categoriesList = new ArrayList();
+
+
+    // Rect element
+    public static String rectMemberName = "rectElement";
+
+    public static String rectElementValue = "<rect width=\"0\" height=\"0\"/>";
+
+    public static String rectElementName = SVGConstants.SVG_RECT_TAG;
+
+    public static short rectElementType = Node.ELEMENT_NODE;
+
+    public static String rectElementCategory = BASIC_SHAPES;
+
+    public static String rectElementDescription = "Rect";
+
+    // Circle element
+    public static String circleMemberName = "circleElement";
+
+    public static String circleElementValue = "<circle r=\"0\"/>";
+
+    public static String circleElementName = SVGConstants.SVG_CIRCLE_TAG;
+
+    public short circleElementType = Node.ELEMENT_NODE;
+
+    public static String circleElementCategory = BASIC_SHAPES;
+
+    public static String circleElementDescription = "Circle";
+
+    // Line element
+    public static String lineElementMemberName = "lineElement";
+
+    public static String lineElementName = SVGConstants.SVG_LINE_TAG;
+
+    public static String lineElementValue = "<line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"0\"/>";
+
+    public static short lineElementType = Node.ELEMENT_NODE;
+
+    public static String lineElementCategory = BASIC_SHAPES;
+
+    public static String lineElementDescription = "Text";
+
+    // Path element
+    public static String pathElementMemberName = "pathElement";
+
+    public static String pathElementName = SVGConstants.SVG_PATH_TAG;
+
+    public static String pathElementValue = "<path d=\"M0,0\"/>";
+
+    public static short pathElementType = Node.ELEMENT_NODE;
+
+    public static String pathElementCategory = PATHS;
+
+    public static String pathElementDescription = "Path";
+
+    // G element
+    public static String groupElementMemberName = "groupElement";
+
+    public static String groupElementName = SVGConstants.SVG_G_TAG;
+
+    public static String groupElementValue = "<g/>";
+
+    public static short groupElementType = Node.ELEMENT_NODE;
+
+    public static String groupElementCategory = DOCUMENT_STRUCTURE;
+
+    public static String groupElementDescription = "Group";
+
+    // Ellipse element
+    public static String ellipseElementMemberName = "ellipseElement";
+
+    public static String ellipseElementName = SVGConstants.SVG_ELLIPSE_TAG;
+
+    public static String ellipseElementValue = "<ellipse/>";
+
+    public static short ellipseElementType = Node.ELEMENT_NODE;
+
+    public static String ellipseElementCategory = BASIC_SHAPES;
+
+    public static String ellipseElementDescription = "Ellipse";
+
+    // Image element
+    public static String imageElementMemberName = "imageElement";
+
+    public static String imageElementName = SVGConstants.SVG_IMAGE_TAG;
+
+    public static String imageElementValue = "<image xlink:href=\"file/c://\"/>";
+
+    public static short imageElementType = Node.ELEMENT_NODE;
+
+    public static String imageElementCategory = DOCUMENT_STRUCTURE;
+
+    public static String imageElementDescription = "Image";
+
+    // Polygon element
+    public static String polygonElementMemberName = "polygonElement";
+
+    public static String polygonElementName = SVGConstants.SVG_POLYGON_TAG;
+
+    public static String polygonElementValue = "<polygon/>";
+
+    public static short polygonElementType = Node.ELEMENT_NODE;
+
+    public static String polygonElementCategory = BASIC_SHAPES;
+
+    public static String polygonElementDescription = "Polygon";
+
+    // Polyline element
+    public static String polylineElementMemberName = "polylineElement";
+
+    public static String polylineElementName = SVGConstants.SVG_POLYLINE_TAG;
+
+    public static String polylineElementValue = "<polyline/>";
+
+    public static short polylineElementType = Node.ELEMENT_NODE;
+
+    public static String polylineElementCategory = BASIC_SHAPES;
+
+    public static String polylineElementDescription = "Polyline";
+
+    // Text element
+    public static String textElementMemberName = "textElement";
+
+    public static String textElementName = SVGConstants.SVG_TEXT_TAG;
+
+    public static String textElementValue = "<text> </text>";
+
+    public static short textElementType = Node.ELEMENT_NODE;
+
+    public static String textElementCategory = TEXT;
+
+    public static String textElementDescription = "Text";
+
+    // TRef element
+    public static String tRefElementMemberName = "tRefElement";
+
+    public static String tRefElementName = SVGConstants.SVG_TREF_TAG;
+
+    public static String tRefElementValue = "<tref/>";
+
+    public static short tRefElementType = Node.ELEMENT_NODE;
+
+    public static String tRefElementCategory = TEXT;
+
+    public static String tRefElementDescription = "TRef";
+
+    // TSpan element
+    public static String tspanElementMemberName = "tspanElement";
+
+    public static String tspanElementName = SVGConstants.SVG_TSPAN_TAG;
+
+    public static String tspanElementValue = "<tspan/>";
+
+    public static short tspanElementType = Node.ELEMENT_NODE;
+
+    public static String tspanElementCategory = TEXT;
+
+    public static String tspanElementDescription = "TSpan";
+
+    // TextPath element
+    public static String textPathElementMemberName = "textPathElement";
+
+    public static String textPathElementName = SVGConstants.SVG_TEXT_PATH_TAG;
+
+    public static String textPathElementValue = "<textPath/>";
+
+    public static short textPathElementType = Node.ELEMENT_NODE;
+
+    public static String textPathElementCategory = TEXT;
+
+    public static String textPathElementDescription = "TextPath";
+
+    // Svg element
+    public static String svgElementMemberName = "svgElement";
+
+    public static String svgElementName = SVGConstants.SVG_SVG_TAG;
+
+    public static String svgElementValue = "<svg/>";
+
+    public static short svgElementType = Node.ELEMENT_NODE;
+
+    public static String svgElementCategory = DOCUMENT_STRUCTURE;
+
+    public static String svgElementDescription = "svg";
+
+    // FeBlend element
+    public static String feBlendElementMemberName = "feBlendElement";
+
+    public static String feBlendElementName = SVGConstants.SVG_FE_BLEND_TAG;
+
+    public static String feBlendElementValue = "<feBlend/>";
+
+    public static short feBlendElementType = Node.ELEMENT_NODE;
+
+    public static String feBlendElementCategory = FILTER_EFFECTS;
+
+    public static String feBlendElementDescription = "FeBlend";
+
+    // FeColorMatrix element
+    public static String feColorMatrixElementMemberName = "feColorMatrixElement";
+
+    public static String feColorMatrixElementName = SVGConstants.SVG_FE_COLOR_MATRIX_TAG;
+
+    public static String feColorMatrixElementValue = "<feColorMatrix/>";
+
+    public static short feColorMatrixElementType = Node.ELEMENT_NODE;
+
+    public static String feColorMatrixElementCategory = FILTER_EFFECTS;
+
+    public static String feColorMatrixElementDescription = "FeColorMatrix";
+
+    // FeComponentTransfer element
+    public static String feComponentTransferElementMemberName = "feComponentTransferElement";
+
+    public static String feComponentTransferElementName = SVGConstants.SVG_FE_COMPONENT_TRANSFER_TAG;
+
+    public static String feComponentTransferElementValue = "<feComponentTransfer/>";
+
+    public static short feComponentTransferElementType = Node.ELEMENT_NODE;
+
+    public static String feComponentTransferElementCategory = FILTER_EFFECTS;
+
+    public static String feComponentTransferElementDescription = "FeComponentTransfer";
+
+    // FeComposite element
+    public static String feCompositeElementMemberName = "feCompositeElement";
+
+    public static String feCompositeElementName = SVGConstants.SVG_FE_COMPOSITE_TAG;
+
+    public static String feCompositeElementValue = "<feComposite/>";
+
+    public static short feCompositeElementType = Node.ELEMENT_NODE;
+
+    public static String feCompositeElementCategory = FILTER_EFFECTS;
+
+    public static String feCompositeElementDescription = "FeComposite";
+
+    // FeConvolveMatrix element
+    public static String feConvolveMatrixElementMemberName = "feConvolveMatrixElement";
+
+    public static String feConvolveMatrixElementName = SVGConstants.SVG_FE_CONVOLVE_MATRIX_TAG;
+
+    public static String feConvolveMatrixElementValue = "<feConvolveMatrix/>";
+
+    public static short feConvolveMatrixElementType = Node.ELEMENT_NODE;
+
+    public static String feConvolveMatrixElementCategory = FILTER_EFFECTS;
+
+    public static String feConvolveMatrixElementDescription = "FeConvolveMatrix";
+
+    // FeDiffuseLighting element
+    public static String feDiffuseLightingElementMemberName = "feDiffuseLightingElement";
+
+    public static String feDiffuseLightingElementName = SVGConstants.SVG_FE_DIFFUSE_LIGHTING_TAG;
+
+    public static String feDiffuseLightingElementValue = "<feDiffuseLighting/>";
+
+    public static short feDiffuseLightingElementType = Node.ELEMENT_NODE;
+
+    public static String feDiffuseLightingElementCategory = FILTER_EFFECTS;
+
+    public static String feDiffuseLightingElementDescription = "FeDiffuseLighting";
+
+    // FeDisplacementMap element
+    public static String feDisplacementMapElementMemberName = "feDisplacementMapElement";
+
+    public static String feDisplacementMapElementName = SVGConstants.SVG_FE_DISPLACEMENT_MAP_TAG;
+
+    public static String feDisplacementMapElementValue = "<feDisplacementMap/>";
+
+    public static short feDisplacementMapElementType = Node.ELEMENT_NODE;
+
+    public static String feDisplacementMapElementCategory = FILTER_EFFECTS;
+
+    public static String feDisplacementMapElementDescription = "FeDisplacementMap";
+
+    // FeDistantLight element
+    public static String feDistantLightElementMemberName = "feDistantLightElement";
+
+    public static String feDistantLightElementName = SVGConstants.SVG_FE_DISTANT_LIGHT_TAG;
+
+    public static String feDistantLightElementValue = "<feDistantLight/>";
+
+    public static short feDistantLightElementType = Node.ELEMENT_NODE;
+
+    public static String feDistantLightElementCategory = FILTER_EFFECTS;
+
+    public static String feDistantLightElementDescription = "FeDistantLight";
+
+    // FeFlood element
+    public static String feFloodElementMemberName = "feFloodElement";
+
+    public static String feFloodElementName = SVGConstants.SVG_FE_FLOOD_TAG;
+
+    public static String feFloodElementValue = "<feFlood/>";
+
+    public static short feFloodElementType = Node.ELEMENT_NODE;
+
+    public static String feFloodElementCategory = FILTER_EFFECTS;
+
+    public static String feFloodElementDescription = "FeFlood";
+
+    // FeFuncA element
+    public static String feFuncAElementMemberName = "feFuncAElement";
+
+    public static String feFuncAElementName = SVGConstants.SVG_FE_FUNC_A_TAG;
+
+    public static String feFuncAElementValue = "<feFuncA/>";
+
+    public static short feFuncAElementType = Node.ELEMENT_NODE;
+
+    public static String feFuncAElementCategory = FILTER_EFFECTS;
+
+    public static String feFuncAElementDescription = "FeFuncA";
+
+    // FeFuncB element
+    public static String feFuncBElementMemberName = "feFuncBElement";
+
+    public static String feFuncBElementName = SVGConstants.SVG_FE_FUNC_B_TAG;
+
+    public static String feFuncBElementValue = "<feFuncB/>";
+
+    public static short feFuncBElementType = Node.ELEMENT_NODE;
+
+    public static String feFuncBElementCategory = FILTER_EFFECTS;
+
+    public static String feFuncBElementDescription = "FeFuncB";
+
+    // FeFuncG element
+    public static String feFuncGElementMemberName = "feFuncGElement";
+
+    public static String feFuncGElementName = SVGConstants.SVG_FE_FUNC_G_TAG;
+
+    public static String feFuncGElementValue = "<feFuncG/>";
+
+    public static short feFuncGElementType = Node.ELEMENT_NODE;
+
+    public static String feFuncGElementCategory = FILTER_EFFECTS;
+
+    public static String feFuncGElementDescription = "FeFuncG";
+
+    // FeFuncR element
+    public static String feFuncRElementMemberName = "feFuncRElement";
+
+    public static String feFuncRElementName = SVGConstants.SVG_FE_FUNC_R_TAG;
+
+    public static String feFuncRElementValue = "<feFuncR/>";
+
+    public static short feFuncRElementType = Node.ELEMENT_NODE;
+
+    public static String feFuncRElementCategory = FILTER_EFFECTS;
+
+    public static String feFuncRElementDescription = "FeFuncR";
+
+    // FeGaussianBlur element
+    public static String feGaussianBlurElementMemberName = "feGaussianBlurElement";
+
+    public static String feGaussianBlurElementName = SVGConstants.SVG_FE_GAUSSIAN_BLUR_TAG;
+
+    public static String feGaussianBlurElementValue = "<feGaussianBlur/>";
+
+    public static short feGaussianBlurElementType = Node.ELEMENT_NODE;
+
+    public static String feGaussianBlurElementCategory = FILTER_EFFECTS;
+
+    public static String feGaussianBlurElementDescription = "FeGaussianBlur";
+
+    // FeImage element
+    public static String feImageElementMemberName = "feImageElement";
+
+    public static String feImageElementName = SVGConstants.SVG_FE_IMAGE_TAG;
+
+    public static String feImageElementValue = "<feImage/>";
+
+    public static short feImageElementType = Node.ELEMENT_NODE;
+
+    public static String feImageElementCategory = FILTER_EFFECTS;
+
+    public static String feImageElementDescription = "FeImage";
+
+    // FeMerge element
+    public static String feMergeElementMemberName = "feImageElement";
+
+    public static String feMergeElementName = SVGConstants.SVG_FE_MERGE_TAG;
+
+    public static String feMergeElementValue = "<feMerge/>";
+
+    public static short feMergeElementType = Node.ELEMENT_NODE;
+
+    public static String feMergeElementCategory = FILTER_EFFECTS;
+
+    public static String feMergeElementDescription = "FeMerge";
+
+    // FeMergeNode element
+    public static String feMergeNodeElementMemberName = "feMergeNodeElement";
+
+    public static String feMergeNodeElementName = SVGConstants.SVG_FE_MERGE_NODE_TAG;
+
+    public static String feMergeNodeElementValue = "<feMergeNode/>";
+
+    public static short feMergeNodeElementType = Node.ELEMENT_NODE;
+
+    public static String feMergeNodeElementCategory = FILTER_EFFECTS;
+
+    public static String feMergeNodeElementDescription = "FeMergeNode";
+
+    // FeMorphology element
+    public static String feMorphologyElementMemberName = "feMorphologyElement";
+
+    public static String feMorphologyElementName = SVGConstants.SVG_FE_MORPHOLOGY_TAG;
+
+    public static String feMorphologyElementValue = "<feMorphology/>";
+
+    public static short feMorphologyElementType = Node.ELEMENT_NODE;
+
+    public static String feMorphologyElementCategory = FILTER_EFFECTS;
+
+    public static String feMorphologyElementDescription = "FeMorphology";
+
+    // FeOffset element
+    public static String feOffsetElementMemberName = "feMorphologyElement";
+
+    public static String feOffsetElementName = SVGConstants.SVG_FE_OFFSET_TAG;
+
+    public static String feOffsetElementValue = "<feOffset/>";
+
+    public static short feOffsetElementType = Node.ELEMENT_NODE;
+
+    public static String feOffsetElementCategory = FILTER_EFFECTS;
+
+    public static String feOffsetElementDescription = "FeOffset";
+
+    // FePointLight element
+    public static String fePointLightElementMemberName = "fePointLightElement";
+
+    public static String fePointLightElementName = SVGConstants.SVG_FE_POINT_LIGHT_TAG;
+
+    public static String fePointLightElementValue = "<fePointLight/>";
+
+    public static short fePointLightElementType = Node.ELEMENT_NODE;
+
+    public static String fePointLightElementCategory = FILTER_EFFECTS;
+
+    public static String fePointLightElementDescription = "FePointLight";
+
+    // FeSpecularLighting element
+    public static String feSpecularLightingElementMemberName = "fePointLightElement";
+
+    public static String feSpecularLightingElementName = SVGConstants.SVG_FE_SPECULAR_LIGHTING_TAG;
+
+    public static String feSpecularLightingElementValue = "<feSpecularLighting/>";
+
+    public static short feSpecularLightingElementType = Node.ELEMENT_NODE;
+
+    public static String feSpecularLightingElementCategory = FILTER_EFFECTS;
+
+    public static String feSpecularLightingElementDescription = "FeSpecularLighting";
+
+    // FeSpotLight element
+    public static String feSpotLightElementMemberName = "feSpotLightElement";
+
+    public static String feSpotLightElementName = SVGConstants.SVG_FE_SPOT_LIGHT_TAG;
+
+    public static String feSpotLightElementValue = "<feSpotLight/>";
+
+    public static short feSpotLightElementType = Node.ELEMENT_NODE;
+
+    public static String feSpotLightElementCategory = FILTER_EFFECTS;
+
+    public static String feSpotLightElementDescription = "FeSpotLight";
+
+    // FeTile element
+    public static String feTileElementMemberName = "feTileElement";
+
+    public static String feTileElementName = SVGConstants.SVG_FE_TILE_TAG;
+
+    public static String feTileElementValue = "<feTile/>";
+
+    public static short feTileElementType = Node.ELEMENT_NODE;
+
+    public static String feTileElementCategory = FILTER_EFFECTS;
+
+    public static String feTileElementDescription = "FeTile";
+
+    // FeTurbulence element
+    public static String feTurbulenceElementMemberName = "feTurbulenceElement";
+
+    public static String feTurbulenceElementName = SVGConstants.SVG_FE_TURBULENCE_TAG;
+
+    public static String feTurbulenceElementValue = "<feTurbulence/>";
+
+    public static short feTurbulenceElementType = Node.ELEMENT_NODE;
+
+    public static String feTurbulenceElementCategory = FILTER_EFFECTS;
+
+    public static String feTurbulenceElementDescription = "FeTurbulence";
+
+    // Filter element
+    public static String filterElementMemberName = "filterElement";
+
+    public static String filterElementName = SVGConstants.SVG_FILTER_TAG;
+
+    public static String filterElementValue = "<filter/>";
+
+    public static short filterElementType = Node.ELEMENT_NODE;
+
+    public static String filterElementCategory = FILTER_EFFECTS;
+
+    public static String filterElementDescription = "Filter";
+
+//    // Text node
+//    public static String textNodeMemberName = "textNode";
+//
+//    public static String textNodeName = "textNode";
+//
+//    public static String textNodeValue = " ";
+//
+//    public static short textNodeType = Node.TEXT_NODE;
+//
+//    public static String textNodeCategory = METADATA;
+//
+//    public static String textNodeDescription = "Text node";
+//
+//    // CDataSection node
+//    public static String cdataSectionNodeMemberName = "cdataSectionNode";
+//
+//    public static String cdataSectionNodeName = "cdataSectionNode";
+//
+//    public static String cdataSectionNodeValue = " ";
+//
+//    public static short cdataSectionNodeType = Node.CDATA_SECTION_NODE;
+//
+//    public static String cdataSectionNodeCategory = METADATA;
+//
+//    public static String cdataSectionNodeDescription = "CDataSection";
+//
+//    // Comment node
+//    public static String commentNodeMemberName = "commentNode";
+//
+//    public static String commentNodeName = "commentNode";
+//
+//    public static String commentNodeValue = " ";
+//
+//    public static short commentNodeType = Node.COMMENT_NODE;
+//
+//    public static String commentNodeCategory = METADATA;
+//
+//    public static String commentNodeDescription = "CommentNode";
+
+    // A element
+    public static String aElementMemberName = "aElement";
+
+    public static String aElementName = SVGConstants.SVG_A_TAG;
+
+    public static String aElementValue = "<a/>";
+
+    public static short aElementType = Node.ELEMENT_NODE;
+
+    public static String aElementCategory = LINKING;
+
+    public static String aElementDescription = "A";
+
+    // AltGlyph element
+    public static String altGlyphElementMemberName = "altGlyphElement";
+
+    public static String altGlyphElementName = SVGConstants.SVG_ALT_GLYPH_TAG;
+
+    public static String altGlyphElementValue = "<altGlyph/>";
+
+    public static short altGlyphElementType = Node.ELEMENT_NODE;
+
+    public static String altGlyphElementCategory = TEXT;
+
+    public static String altGlyphElementDescription = "AltGlyph";
+
+    // AltGlyphDef element
+    public static String altGlyphDefElementMemberName = "altGlyphDefElement";
+
+    public static String altGlyphDefElementName = SVGConstants.SVG_ALT_GLYPH_DEF_TAG;
+
+    public static String altGlyphDefElementValue = "<altGlyphDef/>";
+
+    public static short altGlyphDefElementType = Node.ELEMENT_NODE;
+
+    public static String altGlyphDefElementCategory = TEXT;
+
+    public static String altGlyphDefElementDescription = "AltGlyphDef";
+
+    // AltGlyphItem element
+    public static String altGlyphItemElementMemberName = "altGlyphItemElement";
+
+    public static String altGlyphItemElementName = SVGConstants.SVG_ALT_GLYPH_ITEM_TAG;
+
+    public static String altGlyphItemElementValue = "<altGlyphItem/>";
+
+    public static short altGlyphItemElementType = Node.ELEMENT_NODE;
+
+    public static String altGlyphItemElementCategory = TEXT;
+
+    public static String altGlyphItemElementDescription = "AltGlyphItem";
+
+    // ClipPath element
+    public static String clipPathElementMemberName = "clipPathElement";
+
+    public static String clipPathElementName = SVGConstants.SVG_CLIP_PATH_TAG;
+
+    public static String clipPathElementValue = "<clipPath/>";
+
+    public static short clipPathElementType = Node.ELEMENT_NODE;
+
+    public static String clipPathElementCategory = CLIP_MASK_COMPOSITE;
+
+    public static String clipPathElementDescription = "ClipPath";
+
+    // ColorProfile element
+    public static String colorProfileElementMemberName = "colorProfileElement";
+
+    public static String colorProfileElementName = SVGConstants.SVG_COLOR_PROFILE_TAG;
+
+    public static String colorProfileElementValue = "<color-profile/>";
+
+    public static short colorProfileElementType = Node.ELEMENT_NODE;
+
+    public static String colorProfileElementCategory = COLOR;
+
+    public static String colorProfileElementDescription = "ColorProfile";
+
+    // Cursor element
+    public static String cursorElementMemberName = "cursorElement";
+
+    public static String cursorElementName = SVGConstants.SVG_CURSOR_TAG;
+
+    public static String cursorElementValue = "<cursor/>";
+
+    public static short cursorElementType = Node.ELEMENT_NODE;
+
+    public static String cursorElementCategory = INTERACTIVITY;
+
+    public static String cursorElementDescription = "Cursor";
+
+    // DefinitionSrc element
+    public static String definitionSrcElementMemberName = "definitionSrcElement";
+
+    public static String definitionSrcElementName = SVGConstants.SVG_DEFINITION_SRC_TAG;
+
+    public static String definitionSrcElementValue = "<definition-src/>";
+
+    public static short definitionSrcElementType = Node.ELEMENT_NODE;
+
+    public static String definitionSrcElementCategory = FONTS;
+
+    public static String definitionSrcElementDescription = "DefinitionSrc";
+
+    // Defs element
+    public static String defsElementMemberName = "defsElement";
+
+    public static String defsElementName = SVGConstants.SVG_DEFS_TAG;
+
+    public static String defsElementValue = "<defs/>";
+
+    public static short defsElementType = Node.ELEMENT_NODE;
+
+    public static String defsElementCategory = DOCUMENT_STRUCTURE;
+
+    public static String defsElementDescription = "Defs";
+
+    // Desc element
+    public static String descElementMemberName = "descElement";
+
+    public static String descElementName = SVGConstants.SVG_DESC_TAG;
+
+    public static String descElementValue = "<desc/>";
+
+    public static short descElementType = Node.ELEMENT_NODE;
+
+    public static String descElementCategory = DOCUMENT_STRUCTURE;
+
+    public static String descElementDescription = "Desc";
+
+    // ForeignObject element
+    public static String foreignObjectElementMemberName = "foreignObjectElement";
+
+    public static String foreignObjectElementName = SVGConstants.SVG_FOREIGN_OBJECT_TAG;
+
+    public static String foreignObjectElementValue = "<foreignObject/>";
+
+    public static short foreignObjectElementType = Node.ELEMENT_NODE;
+
+    public static String foreignObjectElementCategory = EXTENSIBILITY;
+
+    public static String foreignObjectElementDescription = "ForeignObject";
+
+    // Glyph element
+    public static String glyphElementMemberName = "glyphElement";
+
+    public static String glyphElementName = SVGConstants.SVG_GLYPH_TAG;
+
+    public static String glyphElementValue = "<glyph/>";
+
+    public static short glyphElementType = Node.ELEMENT_NODE;
+
+    public static String glyphElementCategory = FONTS;
+
+    public static String glyphElementDescription = "Glyph";
+
+    // GlyphRef element
+    public static String glyphRefElementMemberName = "glyphRefElement";
+
+    public static String glyphRefElementName = SVGConstants.SVG_GLYPH_REF_TAG;
+
+    public static String glyphRefElementValue = "<glyphRef/>";
+
+    public static short glyphRefElementType = Node.ELEMENT_NODE;
+
+    public static String glyphRefElementCategory = TEXT;
+
+    public static String glyphRefElementDescription = "GlyphRef";
+
+    // Hkern element
+    public static String hkernElementMemberName = "hkernElement";
+
+    public static String hkernElementName = SVGConstants.SVG_HKERN_TAG;
+
+    public static String hkernElementValue = "<hkern/>";
+
+    public static short hkernElementType = Node.ELEMENT_NODE;
+
+    public static String hkernElementCategory = FONTS;
+
+    public static String hkernElementDescription = "Hkern";
+
+    // LinearGradient element
+    public static String linearGradientElementMemberName = "linearGradientElement";
+
+    public static String linearGradientElementName = SVGConstants.SVG_LINEAR_GRADIENT_TAG;
+
+    public static String linearGradientElementValue = "<linearGradient/>";
+
+    public static short linearGradientElementType = Node.ELEMENT_NODE;
+
+    public static String linearGradientElementCategory = GRADIENTS_AND_PATTERNS;
+
+    public static String linearGradientElementDescription = "LinearGradient";
+
+    // Marker element
+    public static String markerElementMemberName = "markerElement";
+
+    public static String markerElementName = SVGConstants.SVG_MARKER_TAG;
+
+    public static String markerElementValue = "<marker/>";
+
+    public static short markerElementType = Node.ELEMENT_NODE;
+
+    public static String markerElementCategory = PAINTING;
+
+    public static String markerElementDescription = "Marker";
+
+    // Mask element
+    public static String maskElementMemberName = "maskElement";
+
+    public static String maskElementName = SVGConstants.SVG_MASK_TAG;
+
+    public static String maskElementValue = "<mask/>";
+
+    public static short maskElementType = Node.ELEMENT_NODE;
+
+    public static String maskElementCategory = CLIP_MASK_COMPOSITE;
+
+    public static String maskElementDescription = "Mask";
+
+    // Metadata element
+    public static String metadataElementMemberName = "metadataElement";
+
+    public static String metadataElementName = SVGConstants.SVG_METADATA_TAG;
+
+    public static String metadataElementValue = "<metadata/>";
+
+    public static short metadataElementType = Node.ELEMENT_NODE;
+
+    public static String metadataElementCategory = METADATA;
+
+    public static String metadataElementDescription = "Metadata";
+
+    // MissingGlyph element
+    public static String missingGlyphElementMemberName = "missingGlyphElement";
+
+    public static String missingGlyphElementName = SVGConstants.SVG_MISSING_GLYPH_TAG;
+
+    public static String missingGlyphElementValue = "<missing-glyph/>";
+
+    public static short missingGlyphElementType = Node.ELEMENT_NODE;
+
+    public static String missingGlyphElementCategory = FONTS;
+
+    public static String missingGlyphElementDescription = "MissingGlyph";
+
+    // Mpath element
+    public static String mpathElementMemberName = "mpathElement";
+
+    public static String mpathElementName = SVGConstants.SVG_MPATH_TAG;
+
+    public static String mpathElementValue = "<mpath/>";
+
+    public static short mpathElementType = Node.ELEMENT_NODE;
+
+    public static String mpathElementCategory = ANIMATION;
+
+    public static String mpathElementDescription = "Mpath";
+
+    // Pattern element
+    public static String patternElementMemberName = "patternElement";
+
+    public static String patternElementName = SVGConstants.SVG_PATTERN_TAG;
+
+    public static String patternElementValue = "<pattern/>";
+
+    public static short patternElementType = Node.ELEMENT_NODE;
+
+    public static String patternElementCategory = GRADIENTS_AND_PATTERNS;
+
+    public static String patternElementDescription = "Pattern";
+
+    // RadialGradient element
+    public static String radialGradientElementMemberName = "radialGradientElement";
+
+    public static String radialGradientElementName = SVGConstants.SVG_RADIAL_GRADIENT_TAG;
+
+    public static String radialGradientElementValue = "<radialGradient/>";
+
+    public static short radialGradientElementType = Node.ELEMENT_NODE;
+
+    public static String radialGradientElementCategory = GRADIENTS_AND_PATTERNS;
+
+    public static String radialGradientElementDescription = "RadialGradient";
+
+    // Script element
+    public static String scriptElementMemberName = "scriptElement";
+
+    public static String scriptElementName = SVGConstants.SVG_SCRIPT_TAG;
+
+    public static String scriptElementValue = "<script/>";
+
+    public static short scriptElementType = Node.ELEMENT_NODE;
+
+    public static String scriptElementCategory = SCRIPTING;
+
+    public static String scriptElementDescription = "script";
+
+    // Set element
+    public static String setElementMemberName = "setElement";
+
+    public static String setElementName = SVGConstants.SVG_SET_TAG;
+
+    public static String setElementValue = "<set attributeName=\"fill\" from=\"white\" to=\"black\" dur=\"1s\"/>";
+
+    public static short setElementType = Node.ELEMENT_NODE;
+
+    public static String setElementCategory = ANIMATION;
+
+    public static String setElementDescription = "set";
+
+    // Stop element
+    public static String stopElementMemberName = "stopElement";
+
+    public static String stopElementName = SVGConstants.SVG_STOP_TAG;
+
+    public static String stopElementValue = "<stop/>";
+
+    public static short stopElementType = Node.ELEMENT_NODE;
+
+    public static String stopElementCategory = GRADIENTS_AND_PATTERNS;
+
+    public static String stopElementDescription = "Stop";
+
+    // Style element
+    public static String styleElementMemberName = "styleElement";
+
+    public static String styleElementName = SVGConstants.SVG_STYLE_TAG;
+
+    public static String styleElementValue = "<style/>";
+
+    public static short styleElementType = Node.ELEMENT_NODE;
+
+    public static String styleElementCategory = STYLING;
+
+    public static String styleElementDescription = "Style";
+
+    // Switch element
+    public static String switchElementMemberName = "switchElement";
+
+    public static String switchElementName = SVGConstants.SVG_SWITCH_TAG;
+
+    public static String switchElementValue = "<switch/>";
+
+    public static short switchElementType = Node.ELEMENT_NODE;
+
+    public static String switchElementCategory = DOCUMENT_STRUCTURE;
+
+    public static String switchElementDescription = "Switch";
+
+    // Symbol element
+    public static String symbolElementMemberName = "symbolElement";
+
+    public static String symbolElementName = SVGConstants.SVG_SYMBOL_TAG;
+
+    public static String symbolElementValue = "<symbol/>";
+
+    public static short symbolElementType = Node.ELEMENT_NODE;
+
+    public static String symbolElementCategory = DOCUMENT_STRUCTURE;
+
+    public static String symbolElementDescription = "Symbol";
+
+    // Title element
+    public static String titleElementMemberName = "titleElement";
+
+    public static String titleElementName = SVGConstants.SVG_TITLE_TAG;
+
+    public static String titleElementValue = "<title/>";
+
+    public static short titleElementType = Node.ELEMENT_NODE;
+
+    public static String titleElementCategory = DOCUMENT_STRUCTURE;
+
+    public static String titleElementDescription = "Title";
+
+    // Use element
+    public static String useElementMemberName = "useElement";
+
+    public static String useElementName = SVGConstants.SVG_USE_TAG;
+
+    public static String useElementValue = "<use/>";
+
+    public static short useElementType = Node.ELEMENT_NODE;
+
+    public static String useElementCategory = DOCUMENT_STRUCTURE;
+
+    public static String useElementDescription = "Use";
+
+    // View element
+    public static String viewElementMemberName = "viewElement";
+
+    public static String viewElementName = SVGConstants.SVG_VIEW_TAG;
+
+    public static String viewElementValue = "<view/>";
+
+    public static short viewElementType = Node.ELEMENT_NODE;
+
+    public static String viewElementCategory = LINKING;
+
+    public static String viewElementDescription = "View";
+
+    // Vkern element
+    public static String vkernElementMemberName = "vkernElement";
+
+    public static String vkernElementName = SVGConstants.SVG_VKERN_TAG;
+
+    public static String vkernElementValue = "<vkern/>";
+
+    public static short vkernElementType = Node.ELEMENT_NODE;
+
+    public static String vkernElementCategory = FONTS;
+
+    public static String vkernElementDescription = "Vkern";
+
+    // Font element
+    public static String fontElementMemberName = "fontElement";
+
+    public static String fontElementName = SVGConstants.SVG_FONT_TAG;
+
+    public static String fontElementValue = "<font/>";
+
+    public static short fontElementType = Node.ELEMENT_NODE;
+
+    public static String fontElementCategory = FONTS;
+
+    public static String fontElementDescription = "Font";
+
+    // FontFace element
+    public static String fontFaceElementMemberName = "fontFaceElement";
+
+    public static String fontFaceElementName = SVGConstants.SVG_FONT_FACE_TAG;
+
+    public static String fontFaceElementValue = "<font-face/>";
+
+    public static short fontFaceElementType = Node.ELEMENT_NODE;
+
+    public static String fontFaceElementCategory = FONTS;
+
+    public static String fontFaceElementDescription = "FontFace";
+
+    // FontFaceFormat element
+    public static String fontFaceFormatElementMemberName = "fontFaceFormatElement";
+
+    public static String fontFaceFormatElementName = SVGConstants.SVG_FONT_FACE_FORMAT_TAG;
+
+    public static String fontFaceFormatElementValue = "<font-face-format/>";
+
+    public static short fontFaceFormatElementType = Node.ELEMENT_NODE;
+
+    public static String fontFaceFormatElementCategory = FONTS;
+
+    public static String fontFaceFormatElementDescription = "FontFaceFormat";
+
+    // FontFaceName element
+    public static String fontFaceNameElementMemberName = "fontFaceNameElement";
+
+    public static String fontFaceNameElementName = SVGConstants.SVG_FONT_FACE_NAME_TAG;
+
+    public static String fontFaceNameElementValue = "<font-face-name/>";
+
+    public static short fontFaceNameElementType = Node.ELEMENT_NODE;
+
+    public static String fontFaceNameElementCategory = FONTS;
+
+    public static String fontFaceNameElementDescription = "FontFaceName";
+
+    // FontFaceSrc element
+    public static String fontFaceSrcElementMemberName = "fontFaceSrcElement";
+
+    public static String fontFaceSrcElementName = SVGConstants.SVG_FONT_FACE_SRC_TAG;
+
+    public static String fontFaceSrcElementValue = "<font-face-src/>";
+
+    public static short fontFaceSrcElementType = Node.ELEMENT_NODE;
+
+    public static String fontFaceSrcElementCategory = FONTS;
+
+    public static String fontFaceSrcElementDescription = "FontFaceSrc";
+
+    // FontFaceUri element
+    public static String fontFaceUriElementMemberName = "fontFaceUriElement";
+
+    public static String fontFaceUriElementName = SVGConstants.SVG_FONT_FACE_URI_TAG;
+
+    public static String fontFaceUriElementValue = "<font-face-uri/>";
+
+    public static short fontFaceUriElementType = Node.ELEMENT_NODE;
+
+    public static String fontFaceUriElementCategory = FONTS;
+
+    public static String fontFaceUriElementDescription = "FontFaceUri";
+
+    // Animate element
+    public static String animateElementMemberName = "fontFaceUriElement";
+
+    public static String animateElementName = SVGConstants.SVG_ANIMATE_TAG;
+
+    public static String animateElementValue = "<animate attributeName=\"fill\" from=\"white\" to=\"black\" dur=\"1s\"/>";
+
+    public static short animateElementType = Node.ELEMENT_NODE;
+
+    public static String animateElementCategory = ANIMATION;
+
+    public static String animateElementDescription = "Animate";
+
+    // AnimateColor element
+    public static String animateColorElementMemberName = "animateColorElement";
+
+    public static String animateColorElementName = SVGConstants.SVG_ANIMATE_COLOR_TAG;
+
+    public static String animateColorElementValue = "<animateColor attributeName=\"fill\" from=\"white\" to=\"black\" dur=\"1s\"/>";
+
+    public static short animateColorElementType = Node.ELEMENT_NODE;
+
+    public static String animateColorElementCategory = ANIMATION;
+
+    public static String animateColorElementDescription = "AnimateColor";
+
+    // AnimateMotion element
+    public static String animateMotionElementMemberName = "animateMotionElement";
+
+    public static String animateMotionElementName = SVGConstants.SVG_ANIMATE_MOTION_TAG;
+
+    public static String animateMotionElementValue = "<animateMotion dur=\"1s\" path=\"M0,0\"/>";
+
+    public static short animateMotionElementType = Node.ELEMENT_NODE;
+
+    public static String animateMotionElementCategory = ANIMATION;
+
+    public static String animateMotionElementDescription = "AnimateMotion";
+
+    // AnimateTransform element
+    public static String animateTransformElementMemberName = "animateTransformElement";
+
+    public static String animateTransformElementName = SVGConstants.SVG_ANIMATE_TRANSFORM_TAG;
+
+    public static String animateTransformElementValue = "<animateTransform attributeName=\"transform\" type=\"rotate\" from=\"0\" to=\"0\" dur=\"1s\"/>";
+
+    public static short animateTransformElementType = Node.ELEMENT_NODE;
+
+    public static String animateTransformElementCategory = ANIMATION;
+
+    public static String animateTransformElementDescription = "AnimateTransform";
+
+    /**
+     * Constructor.
+     */
+    public NodeTemplates() {
+        // Initialize categories
+        categoriesList.add(DOCUMENT_STRUCTURE);
+        categoriesList.add(STYLING);
+        categoriesList.add(PATHS);
+        categoriesList.add(BASIC_SHAPES);
+        categoriesList.add(TEXT);
+        categoriesList.add(PAINTING);
+        categoriesList.add(COLOR);
+        categoriesList.add(GRADIENTS_AND_PATTERNS);
+        categoriesList.add(CLIP_MASK_COMPOSITE);
+        categoriesList.add(FILTER_EFFECTS);
+        categoriesList.add(INTERACTIVITY);
+        categoriesList.add(LINKING);
+        categoriesList.add(SCRIPTING);
+        categoriesList.add(ANIMATION);
+        categoriesList.add(FONTS);
+        categoriesList.add(METADATA);
+        categoriesList.add(EXTENSIBILITY);
+
+        // Initialize templates
+        initializeTemplates();
+    }
+
+    /**
+     * Initializes node templates.
+     */
+    private void initializeTemplates() {
+        Field[] fields = getClass().getDeclaredFields();
+        for (int i = 0; i < fields.length; i++) {
+            Field currentField = fields[i];
+            try {
+                if (currentField.getType() == String.class
+                        && currentField.getName().endsWith("MemberName")) {
+                    boolean isAccessible = currentField.isAccessible();
+                    currentField.setAccessible(true);
+                    String baseFieldName = currentField.get(this).toString();
+                    String nodeValue = getClass().getField(
+                            baseFieldName + VALUE).get(this).toString();
+                    String nodeName = getClass().getField(baseFieldName + NAME)
+                            .get(this).toString();
+                    short nodeType = ((Short) getClass().getField(
+                            baseFieldName + TYPE).get(this)).shortValue();
+                    String nodeDescription = getClass().getField(
+                            baseFieldName + DESCRIPTION).get(this).toString();
+                    String nodeCategory = getClass().getField(
+                            baseFieldName + CATEGORY).get(this).toString();
+                    NodeTemplateDescriptor desc = new NodeTemplateDescriptor(
+                            nodeName, nodeValue, nodeType, nodeCategory,
+                            nodeDescription);
+                    nodeTemplatesMap.put(desc.getName(), desc);
+                    currentField.setAccessible(isAccessible);
+                }
+            } catch (IllegalArgumentException e) {
+                e.printStackTrace();
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            } catch (SecurityException e) {
+                e.printStackTrace();
+            } catch (NoSuchFieldException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /**
+     * Wrapper for a node template. Provides the information on the node
+     */
+    public static class NodeTemplateDescriptor {
+
+        /**
+         * Node name.
+         */
+        private String name;
+
+        /**
+         * Node xml representation.
+         */
+        private String xmlValue;
+
+        /**
+         * Node type.
+         */
+        private short type;
+
+        /**
+         * Node category.
+         */
+        private String category;
+
+        /**
+         * Short node description.
+         */
+        private String description;
+
+        /**
+         * Constructor.
+         */
+        public NodeTemplateDescriptor(String name, String xmlValue, short type,
+                String category, String description) {
+            this.name = name;
+            this.xmlValue = xmlValue;
+            this.type = type;
+            this.category = category;
+            this.description = description;
+        }
+
+        public String getCategory() {
+            return category;
+        }
+
+        public void setCategory(String category) {
+            this.category = category;
+        }
+
+        public String getDescription() {
+            return description;
+        }
+
+        public void setDescription(String description) {
+            this.description = description;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        public short getType() {
+            return type;
+        }
+
+        public void setType(short type) {
+            this.type = type;
+        }
+
+        public String getXmlValue() {
+            return xmlValue;
+        }
+
+        public void setXmlValue(String xmlValue) {
+            this.xmlValue = xmlValue;
+        }
+    }
+
+    /**
+     * Gets the categories list.
+     *
+     * @return categoriesList
+     */
+    public ArrayList getCategories() {
+        return categoriesList;
+    }
+
+    /**
+     * Map of objects describing node templates.
+     *
+     * @return nodeTemplatesMap
+     */
+    public Map getNodeTemplatesMap() {
+        return nodeTemplatesMap;
+    }
+}

Added: xmlgraphics/batik/trunk/sources/org/apache/batik/apps/svgbrowser/UndoableCommand.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/apps/svgbrowser/UndoableCommand.java?rev=594367&view=auto
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/apps/svgbrowser/UndoableCommand.java (added)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/apps/svgbrowser/UndoableCommand.java Mon Nov 12 16:40:53 2007
@@ -0,0 +1,54 @@
+/*
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+package org.apache.batik.apps.svgbrowser;
+
+/**
+ * The undoable/redoable command.
+ *
+ * @version $Id$
+ */
+public interface UndoableCommand {
+
+    /**
+     * Executes this command.
+     */
+    void execute();
+
+    /**
+     * Performs undo for this command.
+     */
+    void undo();
+
+    /**
+     * Performs redo for this command.
+     */
+    void redo();
+
+    /**
+     * Gets the command name.
+     */
+    String getName();
+
+    /**
+     * Tests if the command can be executed.
+     *
+     * @return True if command should be executed
+     */
+    boolean shouldExecute();
+}

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/CursorManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/CursorManager.java?rev=594367&r1=594366&r2=594367&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/CursorManager.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/CursorManager.java Mon Nov 12 16:40:53 2007
@@ -178,8 +178,6 @@
         return (Cursor)cursorMap.get(cursorName);
     }
 
-
-
     /**
      * Returns the Cursor corresponding to the input element's cursor property
      *

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/ScriptingEnvironment.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/ScriptingEnvironment.java?rev=594367&r1=594366&r2=594367&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/ScriptingEnvironment.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/ScriptingEnvironment.java Mon Nov 12 16:40:53 2007
@@ -19,30 +19,29 @@
 package org.apache.batik.bridge;
 
 import java.io.BufferedReader;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Reader;
 import java.io.StringReader;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
-
 import java.net.URL;
 import java.net.URLConnection;
-
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Timer;
 import java.util.TimerTask;
-import java.util.zip.GZIPOutputStream;
 import java.util.zip.DeflaterOutputStream;
+import java.util.zip.GZIPOutputStream;
 
 import org.apache.batik.dom.GenericDOMImplementation;
 import org.apache.batik.dom.events.NodeEventTarget;
 import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
 import org.apache.batik.dom.svg.SVGOMDocument;
+import org.apache.batik.dom.util.DOMUtilities;
 import org.apache.batik.dom.util.SAXDocumentFactory;
 import org.apache.batik.dom.util.XLinkSupport;
 import org.apache.batik.script.Interpreter;
@@ -71,19 +70,6 @@
  */
 public class ScriptingEnvironment extends BaseScriptingEnvironment {
 
-    /**
-     * Used in 'parseXML()'.
-     */
-    protected static final String FRAGMENT_PREFIX =
-        "<svg xmlns='" +
-        SVGConstants.SVG_NAMESPACE_URI +
-        "' xmlns:xlink='" +
-        XLinkSupport.XLINK_NAMESPACE_URI +
-        "'>";
-
-    protected static final String FRAGMENT_SUFFIX =
-        "</svg>";
-
     public static final String [] SVG_EVENT_ATTRS = {
         "onabort",     // SVG element
         "onerror",     // SVG element
@@ -944,32 +930,23 @@
          * org.apache.batik.script.Window#parseXML(String,Document)}.
          */
         public Node parseXML(String text, Document doc) {
-            // System.err.println("Text: " + text);
             // Try and parse it as an SVGDocument
             SAXSVGDocumentFactory df = new SAXSVGDocumentFactory
                 (XMLResourceDescriptor.getXMLParserClassName());
-            ParsedURL urlObj = null;
-            if ((doc != null) && (doc instanceof SVGOMDocument))
-                urlObj = ((SVGOMDocument)doc).getParsedURL();
+            URL urlObj = null;
+            if (doc instanceof SVGOMDocument) {
+                urlObj = ((SVGOMDocument) doc).getURLObject();
+            }
             if (urlObj == null) {
-                urlObj = ((SVGOMDocument)bridgeContext.getDocument()).
-                    getParsedURL();
+                urlObj = ((SVGOMDocument) bridgeContext.getDocument())
+                        .getURLObject();
             }
-            String uri = (urlObj==null)?"":urlObj.toString();
-            try {
-                Document d = df.createDocument(uri, new StringReader(text));
-                if (doc == null)
-                    return d;
-
-                Node result = doc.createDocumentFragment();
-                result.appendChild(doc.importNode(d.getDocumentElement(),
-                                                  true));
-                return result;
-            } catch (Exception ex) {
-                /* nothing  */
+            String uri = (urlObj == null) ? "" : urlObj.toString();
+            Node res = DOMUtilities.parseXML(text, doc, uri, null, null, df);
+            if (res != null) {
+                return res;
             }
-
-            if ((doc != null) && (doc instanceof SVGOMDocument)) {
+            if (doc instanceof SVGOMDocument) {
                 // Try and parse with an 'svg' element wrapper - for
                 // things like '<rect ../>' - ensure that rect ends up
                 // in SVG namespace - xlink namespace is declared etc...
@@ -977,60 +954,28 @@
                 // Only do this when generating a doc fragment, since
                 // a 'rect' element can not be root of SVG Document
                 // (only an svg element can be).
-                StringBuffer sb = new StringBuffer(FRAGMENT_PREFIX.length() +
-                                                   text.length() +
-                                                   FRAGMENT_SUFFIX.length());
-                sb.append(FRAGMENT_PREFIX);
-                sb.append(text);
-                sb.append(FRAGMENT_SUFFIX);
-                String newText = sb.toString();
-                try {
-                    Document d = df.createDocument
-                        (uri, new StringReader(newText));
-                    // No document given so make doc fragment from our
-                    // new Document.
-                    if (doc == null) doc = d;
-                    for (Node n = d.getDocumentElement().getFirstChild();
-                         n != null;
-                         n = n.getNextSibling()) {
-                        if (n.getNodeType() == Node.ELEMENT_NODE) {
-                            n = doc.importNode(n, true);
-                            Node result = doc.createDocumentFragment();
-                            result.appendChild(n);
-                            return result;
-                        }
-                    }
-                } catch (Exception exc) {
-                    /* nothing - try something else*/
+                Map prefixes = new HashMap();
+                prefixes.put(XMLConstants.XMLNS_PREFIX,
+                        XMLConstants.XMLNS_NAMESPACE_URI);
+                prefixes.put(XMLConstants.XMLNS_PREFIX + ':'
+                        + XMLConstants.XLINK_PREFIX,
+                        XLinkSupport.XLINK_NAMESPACE_URI);
+                res = DOMUtilities.parseXML(text, doc, uri, prefixes,
+                        SVGConstants.SVG_SVG_TAG, df);
+                if (res != null) {
+                    return res;
                 }
             }
-
             // Parse as a generic XML document.
             SAXDocumentFactory sdf;
             if (doc != null) {
-                sdf = new SAXDocumentFactory
-                    (doc.getImplementation(),
-                     XMLResourceDescriptor.getXMLParserClassName());
+                sdf = new SAXDocumentFactory(doc.getImplementation(),
+                        XMLResourceDescriptor.getXMLParserClassName());
             } else {
-                sdf = new SAXDocumentFactory
-                    (new GenericDOMImplementation(),
-                     XMLResourceDescriptor.getXMLParserClassName());
-            }
-            try {
-                Document d = sdf.createDocument(uri, new StringReader(text));
-                if (doc == null)
-                    return d;
-
-                Node result = doc.createDocumentFragment();
-                result.appendChild(doc.importNode(d.getDocumentElement(),
-                                                  true));
-                return result;
-            } catch (Exception ext) {
-                if (userAgent != null)
-                    userAgent.displayError(ext);
+                sdf = new SAXDocumentFactory(new GenericDOMImplementation(),
+                        XMLResourceDescriptor.getXMLParserClassName());
             }
-
-            return null;
+            return DOMUtilities.parseXML(text, doc, uri, null, null, sdf);
         }
 
         /**

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/dom/AbstractParentNode.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/dom/AbstractParentNode.java?rev=594367&r1=594366&r2=594367&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/dom/AbstractParentNode.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/dom/AbstractParentNode.java Mon Nov 12 16:40:53 2007
@@ -218,7 +218,7 @@
             ExtendedNode n = childNodes.append((ExtendedNode)newChild);
             n.setParentNode(this);
 
-        nodeAdded(n);
+            nodeAdded(n);
 
             // Mutation event
             fireDOMNodeInsertedEvent(n);

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/dom/util/DOMUtilities.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/dom/util/DOMUtilities.java?rev=594367&r1=594366&r2=594367&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/dom/util/DOMUtilities.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/dom/util/DOMUtilities.java Mon Nov 12 16:40:53 2007
@@ -19,9 +19,16 @@
 package org.apache.batik.dom.util;
 
 import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
 import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
 
 import org.apache.batik.xml.XMLUtilities;
+
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.DOMImplementation;
@@ -30,6 +37,7 @@
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 /**
  * A collection of utility functions for the DOM.
@@ -138,6 +146,25 @@
     }
 
     /**
+     * Serializes the given DOM node using {@link #writeNode(Node,Writer)}
+     * and returns the XML as a String.
+     *
+     * @param n The Node to serialize.
+     * @return A String containing the XML serialization of the Node, or an
+     *   empty String if there was a problem during serialization.
+     */
+    public static String getXML(Node n) {
+        Writer writer = new StringWriter();
+        try {
+            DOMUtilities.writeNode(n, writer);
+            writer.close();
+        } catch (IOException ex) {
+            return "";
+        }
+        return writer.toString();
+    }
+
+    /**
      * Returns the given content value transformed to replace invalid
      * characters with entities.
      */
@@ -169,6 +196,260 @@
         }
 
         return result.toString();
+    }
+
+    /**
+     * Finds and returns the index of child node in the given parent's children
+     * array
+     *
+     * @param child
+     *            The child node
+     * @param parent
+     *            The parent node
+     * @return the index
+     */
+    public static int getChildIndex(Node child, Node parent) {
+        if (child == null || child.getParentNode() != parent
+                || child.getParentNode() == null) {
+            return -1;
+        }
+        return getChildIndex(child);
+    }
+
+    /**
+     * Finds and returns the index of child node in its parent's children array
+     *
+     * @param child
+     *            The child node
+     * @return the index in children array
+     */
+    public static int getChildIndex(Node child) {
+        NodeList children = child.getParentNode().getChildNodes();
+        for (int i = 0; i < children.getLength(); i++) {
+            Node currentChild = children.item(i);
+            if (currentChild == child) {
+                return i;
+            }
+        }
+        return -1;
+    }
+
+    /**
+     * Checks if any of from the given list of nodes is an ancestor to another
+     * node
+     *
+     * @param ancestorNodes
+     *            The potential ancestor nodes
+     * @param node
+     *            The potential descendant node
+     * @return True if at least one node is ancestor of the given node
+     */
+    public static boolean isAnyNodeAncestorOf(ArrayList ancestorNodes, Node node) {
+        int n = ancestorNodes.size();
+        for (int i = 0; i < n; i++) {
+            Node ancestor = (Node) ancestorNodes.get(i);
+            if (isAncestorOf(ancestor, node)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Checks whether a node is ancestor of another node.
+     *
+     * @param node
+     *            The potential ancestor node
+     * @param descendant
+     *            The potential descendant node
+     * @return True if node is ancestor of the descendant node
+     */
+    public static boolean isAncestorOf(Node node, Node descendant) {
+        if (node == null || descendant == null) {
+            return false;
+        }
+        for (Node currentNode = descendant.getParentNode(); currentNode != null; currentNode = currentNode
+                .getParentNode()) {
+            if (currentNode == node) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Tests whether the given node is a child of the given parent node.
+     *
+     * @param node
+     *            The potential child node
+     * @param parentNode
+     *            Parent node
+     * @return True if a node is a child of the given parent node
+     */
+    public static boolean isParentOf(Node node, Node parentNode) {
+        if (node == null || parentNode == null
+                || node.getParentNode() != parentNode) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Checks if the node can be appended on the given parent node
+     *
+     * @param node
+     *            The given node
+     * @param parentNode
+     *            The given parent node
+     * @return True if the given node can be appended on the parent node
+     */
+    public static boolean canAppend(Node node, Node parentNode) {
+        if (node == null || parentNode == null || node == parentNode
+                || isAncestorOf(node, parentNode)) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Checks whether any of the nodes from the list can be appended to a given
+     * parentNode.
+     *
+     * @param children
+     *            The given node list
+     * @param parentNode
+     *            The potential parent node
+     * @return true if at least one node from a list can be appended
+     */
+    public static boolean canAppendAny(ArrayList children, Node parentNode) {
+        if (!canHaveChildren(parentNode)) {
+            return false;
+        }
+        int n = children.size();
+        for (int i = 0; i < n; i++) {
+            Node child = (Node) children.get(i);
+            if (canAppend(child, parentNode)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Returns whether the given Node can have children.
+     *
+     * @param parentNode The Node to test
+     * @return <code>true</code> if the node can have children,
+     *   <code>false</code> otherwise
+     */
+    public static boolean canHaveChildren(Node parentNode) {
+        if (parentNode == null) {
+            return false;
+        }
+        switch (parentNode.getNodeType()) {
+            case Node.DOCUMENT_NODE:
+            case Node.TEXT_NODE:
+            case Node.COMMENT_NODE:
+            case Node.CDATA_SECTION_NODE:
+            case Node.PROCESSING_INSTRUCTION_NODE:
+                return false;
+            default:
+                return true;
+        }
+    }
+
+    /**
+     * Parses the given XML string into a DocumentFragment of the given document
+     * or a new document if 'doc' is null.
+     *
+     * @param text
+     *            The given XML string
+     * @param doc
+     *            The given document
+     * @param uri
+     *            The document URI
+     * @param prefixes
+     *            The prefixes map with (prefix, namespaceURI) pairs
+     * @param wrapperElementName
+     *            null: Ignore the wrapper element and prefixes map and try to
+     *            parse the text as a whole document otherwise: Wrap the given
+     *            text with the wrapper element with prefixes specified from the
+     *            prefixes map
+     * @param documentFactory
+     *            What document factory to use when parsing the text
+     * @return The document fragment or null on error.
+     */
+    public static Node parseXML(String text, Document doc, String uri,
+            Map prefixes, String wrapperElementName,
+            SAXDocumentFactory documentFactory) {
+
+        // Create the wrapper element prefix and suffix, copying the (prefix,
+        // namespaceURI) pairs from the prefixes map
+        String wrapperElementPrefix = "";
+        String wrapperElementSuffix = "";
+        if (wrapperElementName != null) {
+            wrapperElementPrefix = "<" + wrapperElementName;
+            // Copy the prefixes from the prefixes map to the wrapper element
+            if (prefixes != null) {
+                wrapperElementPrefix += " ";
+                Set keySet = prefixes.keySet();
+                Iterator iter = keySet.iterator();
+                while (iter.hasNext()) {
+                    String currentKey = (String) iter.next();
+                    String currentValue = (String) prefixes.get(currentKey);
+                    wrapperElementPrefix += currentKey + "=\"" + currentValue
+                            + "\" ";
+                }
+            }
+            wrapperElementPrefix += ">";
+            wrapperElementSuffix += "</" + wrapperElementName + ">";
+        }
+
+        // Try and parse as a whole document, if no wrapper element is specified
+        if (wrapperElementPrefix.trim().length() == 0
+                && wrapperElementSuffix.trim().length() == 0) {
+            try {
+                Document d = documentFactory.createDocument(uri,
+                        new StringReader(text));
+                if (doc == null) {
+                    return d;
+                }
+                Node result = doc.createDocumentFragment();
+                result
+                        .appendChild(doc.importNode(d.getDocumentElement(),
+                                true));
+                return result;
+            } catch (Exception ex) {
+
+            }
+        }
+
+        // Try and parse as a document fragment
+        StringBuffer sb = new StringBuffer(wrapperElementPrefix.length()
+                + text.length() + wrapperElementSuffix.length());
+        sb.append(wrapperElementPrefix);
+        sb.append(text);
+        sb.append(wrapperElementSuffix);
+        String newText = sb.toString();
+        try {
+            Document d = documentFactory.createDocument(uri, new StringReader(
+                    newText));
+            if (doc == null) {
+                return d;
+            }
+            for (Node node = d.getDocumentElement().getFirstChild(); node != null;
+                    node = node.getNextSibling()) {
+                if (node.getNodeType() == Node.ELEMENT_NODE) {
+                    node = doc.importNode(node, true);
+                    Node result = doc.createDocumentFragment();
+                    result.appendChild(node);
+                    return result;
+                }
+            }
+        } catch (Exception exc) {
+
+        }
+        return null;
     }
 
     /**

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/swing/JSVGCanvas.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/swing/JSVGCanvas.java?rev=594367&r1=594366&r2=594367&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/swing/JSVGCanvas.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/swing/JSVGCanvas.java Mon Nov 12 16:40:53 2007
@@ -20,6 +20,7 @@
 
 import java.awt.Dimension;
 import java.awt.EventQueue;
+import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.InputEvent;
 import java.awt.event.KeyEvent;
@@ -52,13 +53,18 @@
 import org.apache.batik.swing.gvt.AbstractRotateInteractor;
 import org.apache.batik.swing.gvt.AbstractZoomInteractor;
 import org.apache.batik.swing.gvt.Interactor;
+import org.apache.batik.swing.gvt.Overlay;
 import org.apache.batik.swing.svg.JSVGComponent;
 import org.apache.batik.swing.svg.SVGDocumentLoaderEvent;
 import org.apache.batik.swing.svg.SVGUserAgent;
 import org.apache.batik.util.SVGConstants;
 import org.apache.batik.util.XMLConstants;
+// import org.apache.batik.util.gui.DOMViewer;
+// import org.apache.batik.util.gui.DOMViewerController;
+// import org.apache.batik.util.gui.ElementOverlayManager;
 import org.apache.batik.util.gui.JErrorPane;
 
+import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.events.Event;
@@ -584,6 +590,51 @@
 
         super.installSVGDocument(doc);
     }
+
+//     // DOMViewerController
+// 
+//     /**
+//      * DOMViewerController implementation.
+//      */
+//     protected class CanvasDOMViewerController implements DOMViewerController {
+// 
+//         public boolean canEdit() {
+//             return getUpdateManager() != null;
+//         }
+// 
+//         public ElementOverlayManager createSelectionManager() {
+//             if (canEdit()) {
+//                 return new ElementOverlayManager(JSVGCanvas.this);
+//             }
+//             return null;
+//         }
+// 
+//         public Document getDocument() {
+//             return svgDocument;
+//         }
+// 
+//         public void performUpdate(Runnable r) {
+//             if (canEdit()) {
+//                 getUpdateManager().getUpdateRunnableQueue().invokeLater(r);
+//             } else {
+//                 r.run();
+//             }
+//         }
+// 
+//         public void removeSelectionOverlay(Overlay selectionOverlay) {
+//             getOverlays().remove(selectionOverlay);
+//         }
+// 
+//         public void selectNode(Node node) {
+//             DOMViewer domViewer = new DOMViewer(this);
+//             Rectangle fr = getBounds();
+//             Dimension td = domViewer.getSize();
+//             domViewer.setLocation(fr.x + (fr.width - td.width) / 2,
+//                                   fr.y + (fr.height - td.height) / 2);
+//             domViewer.setVisible(true);
+//             domViewer.selectNode(node);
+//         }
+//     }
 
     // ----------------------------------------------------------------------
     // Actions

Added: xmlgraphics/batik/trunk/sources/org/apache/batik/util/gui/AbstractJEnhEditTextArea.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/util/gui/AbstractJEnhEditTextArea.java?rev=594367&view=auto
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/util/gui/AbstractJEnhEditTextArea.java (added)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/util/gui/AbstractJEnhEditTextArea.java Mon Nov 12 16:40:53 2007
@@ -0,0 +1,188 @@
+/*
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+package org.apache.batik.util.gui;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
+
+import javax.swing.event.UndoableEditEvent;
+import javax.swing.event.UndoableEditListener;
+import javax.swing.undo.CannotRedoException;
+import javax.swing.undo.CannotUndoException;
+import javax.swing.undo.UndoManager;
+
+import org.gjt.sp.jedit.textarea.JEditTextArea;
+import org.gjt.sp.jedit.textarea.TextAreaDefaults;
+
+/**
+ * The abstract enhanced JEditTextArea. Has cut / copy / paste, select all and
+ * undo / redo shortcuts added.
+ *
+ * @version $Id$
+ */
+public class AbstractJEnhEditTextArea extends JEditTextArea {
+   
+    /**
+     * The number of the edits to remember. 
+     */
+    public static final int HISTORY_SIZE = 1000;
+    
+    /**
+     * The undo manager.
+     */
+    protected UndoManager undoManager;
+    
+    /**
+     * Creates a new JEnhEditTextArea with the specified settings.
+     * 
+     * @param defaults
+     *            The default settings
+     */
+    public AbstractJEnhEditTextArea(TextAreaDefaults defaults) {
+        super(defaults);
+
+        // XXX Make these key bindings use Command on OS X.
+
+        // Cut / copy / paste
+        getInputHandler().addKeyBinding("C+x", new CutAction());
+        getInputHandler().addKeyBinding("C+c", new CopyAction());
+        getInputHandler().addKeyBinding("C+v", new PasteAction());
+
+        // Select all
+        getInputHandler().addKeyBinding("C+a", new SelectAllAction());
+
+        // Undo / Redo
+        getInputHandler().addKeyBinding("C+z", new UndoAction());
+        getInputHandler().addKeyBinding("C+y", new RedoAction());
+        getDocument().addUndoableEditListener(new UndoableEditSupport());
+        addFocusListener(new FocusSupport());
+    }
+    
+    // Cut / copy / paste
+    /**
+     * The copy action.
+     */
+    protected class CopyAction implements ActionListener {
+        public void actionPerformed(ActionEvent e) {
+            copy();
+        }
+    }
+
+    /**
+     * The paste action.
+     */
+    protected class PasteAction implements ActionListener {
+        public void actionPerformed(ActionEvent e) {
+            paste();
+        }
+    }
+
+    /**
+     * The cut action.
+     */
+    protected class CutAction implements ActionListener {
+        public void actionPerformed(ActionEvent e) {
+            cut();
+        }
+    }
+
+    // Select all
+    /**
+     * The select all action.
+     */
+    protected class SelectAllAction implements ActionListener {
+        public void actionPerformed(ActionEvent arg0) {
+            selectAll();
+        }
+    }
+
+    // Undo / Redo
+    /**
+     * The undo action.
+     */
+    protected class UndoAction implements ActionListener {
+        public void actionPerformed(ActionEvent e) {
+            try {
+                getUndoManager().undo();
+            } catch (CannotUndoException cue) {
+            }
+        }
+    }
+
+    /**
+     * The redo action.
+     */
+    protected class RedoAction implements ActionListener {
+        public void actionPerformed(ActionEvent e) {
+            try {
+                getUndoManager().redo();
+            } catch (CannotRedoException cue) {
+            }
+        }
+    }
+    
+    /**
+     * Listening for the undoable edits. Adds the undoable edit to undo manager.
+     */
+    protected class UndoableEditSupport implements UndoableEditListener {
+        public void undoableEditHappened(UndoableEditEvent e) {
+            getUndoManager().addEdit(e.getEdit());
+        }
+    }
+
+    /**
+     * Focus listener. Creates new undo manager when focus gained. Ends the
+     * current update manager when focus is lost.
+     */
+    protected class FocusSupport extends FocusAdapter {
+        
+        public void focusGained(FocusEvent e) {
+            undoManager = createUndoManger();
+        }
+
+        public void focusLost(FocusEvent e) {
+            undoManager.end();
+        }
+    }
+
+    /**
+     * Gets the UndoManager.
+     * 
+     * @return the UndoManager
+     */
+    protected UndoManager getUndoManager() {
+        if (undoManager == null) {
+            undoManager = createUndoManger();
+        }
+        return undoManager;
+    }
+
+    /**
+     * Creates new UndoManager, sets its limit and returns it
+     * 
+     * @return the UndoManager
+     */
+    protected UndoManager createUndoManger() {
+        UndoManager newUndoManager = new UndoManager();
+        newUndoManager.setLimit(HISTORY_SIZE);
+        return newUndoManager;
+    }
+}