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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classThe action associated with the 'Add' button.protected classThe action associated with the 'Apply' button.static classThe attributesTable model.protected classListens for the changes in the table and updates this node picker panel if needed.static classDialog for choosing element name.static classThe adapter for the NodePicker listener.protected classManages the edits on focus events.static classEvent to pass to listener.static interfaceNode picker listener.protected classThe action associated with the 'Remove' button.protected classThe action associated with the 'Reset' button.protected static classThe panel to view and edit the elements xml representation.protected classListens for the changes in the xml text area and updates this node picker panel if needed.Nested classes/interfaces inherited from class JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intCreates new element while in this mode.private JButtonThe Add button.private JButtonThe Apply button.private JScrollPaneThe Attributes table ScrollPane.private JLabelThe Attributes table label.private JPanelThe Attributes table and buttons Panel.private JTableThe attributes table - the table that consists of attribute name and attribute value columns.private static ResourceBundleThe resource bundle.private ButtonFactoryThe Button factory.private JPanelThe OK and Cancel button Panel.private ElementThe copy of the original (preview) element.private NodePickerControllerThe controller for this panel.private static final intEdit mode.private EventListenerListListeners list.private booleanIf the element being edited is actually changed.private JLabelThe isWellFormed label.private MapThe map that contains the listenersprivate intThe panel mode.private NodeThe parent Element for the element to be added.private ElementThe element that is being previewed or edited it's content (xml representation).private JButtonThe Remove button.private JButtonThe Reset button.private static ResourceManagerThe resource manager.private static final StringThe resource file name.private booleanIf the attribute table listener should process the update event and update node picker after an update on the table had triggered.private NodePickerPanel.SVGInputPanelThe svg input panel.private JLabelThe svgInputPanel name label.private TableModelListenerThe Attribute table model listener.private static final intView only.Fields inherited from class JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidAdds button actions.voidAdds the listener to the listener list.voidenterAddNewElementMode(Element newElement, Node parent) Enters the add new element mode.voidEnters the edit mode.voidEnters the view mode.voidFires the AddNewElement event.voidFires the updateElement event.Returns the action associated with the given string or null on errorprivate JButtonGets the Add button.private JButtonGets the Apply button.private JPanelGets the attributesPanel.private ButtonFactoryGets buttonFactory.private JPanelGets the choosePanel.private intgetMode()Gets the current working mode.private StringgetNamespaceURI(String prefix) Looks up for the namespaceURI based on the given prefix.private ElementGetter for the preivewElement.private JButtonGets the Remove button.private JButtonGets the Reset sbutton.Gets the results of this node picker panel - gets the contents of the xml text area.private NodePickerPanel.SVGInputPanelGets the svgInputPanel.private voidInitalizes this panel.private booleanisANodePickerComponent(Component component) Checks whether the given component is a part component of the this node picker.private booleanWhether the element being edit is changed.(package private) booleanInvoked by theDOMViewerto inform theNodePickerPanelthat it is being hidden.private ElementParses the given xml and return parsed document's root element.booleanShows a dialog to save changes.private voidremoveAttributes(Element element) Removes all the attributes from an element.voidsetEditable(boolean editable) Sets the node picker components to be editable / uneditable.voidsetPreviewElement(Element elem) Sets the preview element.private booleanshouldUpdate(String mutationEventType, Node affectedNode, Node currentNode) If the panel should update its components after dom mutation event.private voidupdateAttributesTable(Element elem) Fills the attributesTable with the given element attribute name - value pairs.private voidupdateElementAttributes(Element element, NodePickerPanel.AttributesTableModel tableModel) Replaces all of the atributes of a given element with the values from the given table model.private voidupdateElementAttributes(Element elem, Element referentElement) Replaces all of the attributes of the given element with the referent element's attributes.private voidupdateNodeXmlArea(Node node) Shows node's String representation in svgInputPanelvoidupdateOnDocumentChange(String mutationEventType, Node targetNode) Updates the panel when DOM Mutation event occures.private voidupdateViewAfterSvgInput(Element referentElement, Element elementToUpdate) Update the components and the element after text is being inputted in the xml text area.Methods inherited from class JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class 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, updateMethods inherited from class 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, validateTreeMethods inherited from class 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
-
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
-
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
-
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
-
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 theDOMViewerto inform theNodePickerPanelthat 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
-
updateOnDocumentChange
-
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
-
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:
getActionin 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
-