Package org.apache.batik.apps.svgbrowser
Class NodePickerPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.apache.batik.apps.svgbrowser.NodePickerPanel
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
,ActionMap
Used to preview and edit nodes.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
The action associated with the 'Add' button.protected class
The action associated with the 'Apply' button.static class
The attributesTable model.protected class
Listens for the changes in the table and updates this node picker panel if needed.static class
Dialog for choosing element name.static class
The adapter for the NodePicker listener.protected class
Manages the edits on focus events.static class
Event to pass to listener.static interface
Node picker listener.protected class
The action associated with the 'Remove' button.protected class
The action associated with the 'Reset' button.protected static class
The panel to view and edit the elements xml representation.protected class
Listens for the changes in the xml text area and updates this node picker panel if needed.Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
Creates new element while in this mode.private JButton
The Add button.private JButton
The Apply button.private JScrollPane
The Attributes table ScrollPane.private JLabel
The Attributes table label.private JPanel
The Attributes table and buttons Panel.private JTable
The attributes table - the table that consists of attribute name and attribute value columns.private static ResourceBundle
The resource bundle.private ButtonFactory
The Button factory.private JPanel
The OK and Cancel button Panel.private Element
The copy of the original (preview) element.private NodePickerController
The controller for this panel.private static final int
Edit mode.private EventListenerList
Listeners list.private boolean
If the element being edited is actually changed.private JLabel
The isWellFormed label.private Map
The map that contains the listenersprivate int
The panel mode.private Node
The parent Element for the element to be added.private Element
The element that is being previewed or edited it's content (xml representation).private JButton
The Remove button.private JButton
The Reset button.private static ResourceManager
The resource manager.private static final String
The resource file name.private boolean
If the attribute table listener should process the update event and update node picker after an update on the table had triggered.private NodePickerPanel.SVGInputPanel
The svg input panel.private JLabel
The svgInputPanel name label.private TableModelListener
The Attribute table model listener.private static final int
View only.Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Adds button actions.void
Adds the listener to the listener list.void
enterAddNewElementMode
(Element newElement, Node parent) Enters the add new element mode.void
Enters the edit mode.void
Enters the view mode.void
Fires the AddNewElement event.void
Fires the updateElement event.Returns the action associated with the given string or null on errorprivate JButton
Gets the Add button.private JButton
Gets the Apply button.private JPanel
Gets the attributesPanel.private ButtonFactory
Gets buttonFactory.private JPanel
Gets the choosePanel.private int
getMode()
Gets the current working mode.private String
getNamespaceURI
(String prefix) Looks up for the namespaceURI based on the given prefix.private Element
Getter for the preivewElement.private JButton
Gets the Remove button.private JButton
Gets the Reset sbutton.Gets the results of this node picker panel - gets the contents of the xml text area.private NodePickerPanel.SVGInputPanel
Gets the svgInputPanel.private void
Initalizes this panel.private boolean
isANodePickerComponent
(Component component) Checks whether the given component is a part component of the this node picker.private boolean
Whether the element being edit is changed.(package private) boolean
Invoked by theDOMViewer
to inform theNodePickerPanel
that it is being hidden.private Element
Parses the given xml and return parsed document's root element.boolean
Shows a dialog to save changes.private void
removeAttributes
(Element element) Removes all the attributes from an element.void
setEditable
(boolean editable) Sets the node picker components to be editable / uneditable.void
setPreviewElement
(Element elem) Sets the preview element.private boolean
shouldUpdate
(String mutationEventType, Node affectedNode, Node currentNode) If the panel should update its components after dom mutation event.private void
updateAttributesTable
(Element elem) Fills the attributesTable with the given element attribute name - value pairs.private void
updateElementAttributes
(Element element, NodePickerPanel.AttributesTableModel tableModel) Replaces all of the atributes of a given element with the values from the given table model.private void
updateElementAttributes
(Element elem, Element referentElement) Replaces all of the attributes of the given element with the referent element's attributes.private void
updateNodeXmlArea
(Node node) Shows node's String representation in svgInputPanelvoid
updateOnDocumentChange
(String mutationEventType, Node targetNode) Updates the panel when DOM Mutation event occures.private void
updateViewAfterSvgInput
(Element referentElement, Element elementToUpdate) Update the components and the element after text is being inputted in the xml text area.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
VIEW_MODE
private static final int VIEW_MODEView only. Inspects the associated node.- See Also:
-
EDIT_MODE
private static final int EDIT_MODEEdit mode. Used for editing the associated node.- See Also:
-
ADD_NEW_ELEMENT
private static final int ADD_NEW_ELEMENTCreates new element while in this mode.- See Also:
-
RESOURCES
The resource file name.- See Also:
-
bundle
The resource bundle. -
resources
The resource manager. -
attributesTable
The attributes table - the table that consists of attribute name and attribute value columns. Shows the element's attributes. -
tableModelListener
The Attribute table model listener. -
attributePane
The Attributes table ScrollPane. -
attributesPanel
The Attributes table and buttons Panel. -
buttonFactory
The Button factory. -
addButton
The Add button. -
removeButton
The Remove button. -
attributesLabel
The Attributes table label. -
applyButton
The Apply button. -
resetButton
The Reset button. -
choosePanel
The OK and Cancel button Panel. -
svgInputPanel
The svg input panel. -
isWellFormedLabel
The isWellFormed label. -
svgInputPanelNameLabel
The svgInputPanel name label. -
shouldProcessUpdate
private boolean shouldProcessUpdateIf the attribute table listener should process the update event and update node picker after an update on the table had triggered. Used instead of removing and adding the table listener. -
previewElement
The element that is being previewed or edited it's content (xml representation). -
clonedElement
The copy of the original (preview) element. Used to synchronize svginput area and the attributes table, since the original elements attributes shouldn't be changed while previewing or editing it. -
parentElement
The parent Element for the element to be added. It is used when adding the new element, to get the information on where to be appended. -
mode
private int modeThe panel mode. -
isDirty
private boolean isDirtyIf the element being edited is actually changed. -
eventListeners
Listeners list. -
controller
The controller for this panel. -
listeners
The map that contains the listeners
-
-
Constructor Details
-
NodePickerPanel
Constructor.- Parameters:
controller
- The node picker panel controller
-
-
Method Details
-
initialize
private void initialize()Initalizes this panel. -
getButtonFactory
Gets buttonFactory. -
addButtonActions
private void addButtonActions()Adds button actions. -
getAddButton
Gets the Add button. -
getRemoveButton
Gets the Remove button. -
getApplyButton
Gets the Apply button. -
getResetButton
Gets the Reset sbutton. -
getAttributesPanel
Gets the attributesPanel. -
getSvgInputPanel
Gets the svgInputPanel. -
getChoosePanel
Gets the choosePanel. -
getResults
Gets the results of this node picker panel - gets the contents of the xml text area. -
updateViewAfterSvgInput
Update the components and the element after text is being inputted in the xml text area.- Parameters:
referentElement
- The updated element, referent elementelementToUpdate
- The element to update.
-
updateElementAttributes
Replaces all of the attributes of the given element with the referent element's attributes.- Parameters:
elem
- The element whose attributes should be replacedreferentElement
- The referentElement to copy the attributes from
-
updateElementAttributes
private void updateElementAttributes(Element element, NodePickerPanel.AttributesTableModel tableModel) Replaces all of the atributes of a given element with the values from the given table model.- Parameters:
element
- The node whose attributes should updatetableModel
- The tableModel from which to get attributes
-
removeAttributes
Removes all the attributes from an element.- Parameters:
element
- The given element
-
getNamespaceURI
Looks up for the namespaceURI based on the given prefix. Uses the Node.lookupNamespaceURI method, starting from the parent element of the element being edited / created.- Parameters:
prefix
- The given prefix- Returns:
- namespaceURI or null
-
updateAttributesTable
Fills the attributesTable with the given element attribute name - value pairs.- Parameters:
elem
- The given element
-
updateNodeXmlArea
Shows node's String representation in svgInputPanel- Parameters:
node
- The given node
-
getPreviewElement
Getter for the preivewElement.- Returns:
- the preivewElement
-
setPreviewElement
Sets the preview element. Enters the view mode and updates the associated components.- Parameters:
elem
- the element to set
-
panelHiding
boolean panelHiding()Invoked by theDOMViewer
to inform theNodePickerPanel
that it is being hidden. -
getMode
private int getMode()Gets the current working mode.- Returns:
- the mode
-
enterViewMode
public void enterViewMode()Enters the view mode. -
enterEditMode
public void enterEditMode()Enters the edit mode. -
enterAddNewElementMode
Enters the add new element mode.- Parameters:
newElement
- The element to be addedparent
- The parent node of the element to be added
-
updateOnDocumentChange
Updates the panel when DOM Mutation event occures. -
shouldUpdate
If the panel should update its components after dom mutation event. Checks whether any node that is the child node of the node currently being previewed has changed. If true, updates the xml text area of this NodePicker. In case of DOMAttrModiefied mutation event, the additional condition is added - to check whether the attributes of an element that is being previewed are changed. If true, the xml text area is refreshed.- Returns:
- True if should update
-
parseXml
Parses the given xml and return parsed document's root element. Used to check whether the given xml is well formed.- Parameters:
xmlString
- Xml as a String- Returns:
- Element
-
setEditable
public void setEditable(boolean editable) Sets the node picker components to be editable / uneditable.- Parameters:
editable
- Whether to enable or disable edit
-
isANodePickerComponent
Checks whether the given component is a part component of the this node picker.- Parameters:
component
- The given component- Returns:
- True if the given component is a part of the this NodePicker
-
promptForChanges
public boolean promptForChanges()Shows a dialog to save changes. -
isElementModified
private boolean isElementModified()Whether the element being edit is changed.- Returns:
- True if the element being edit is changed
-
getAction
Returns the action associated with the given string or null on error- Specified by:
getAction
in interfaceActionMap
- Parameters:
key
- the key mapped with the action to get- Throws:
MissingListenerException
- if the action is not found
-
fireUpdateElement
Fires the updateElement event.- Parameters:
event
- The associated NodePickerEvent event
-
fireAddNewElement
Fires the AddNewElement event.- Parameters:
event
- The associated NodePickerEvent event
-
addListener
Adds the listener to the listener list.- Parameters:
listener
- The listener to add
-