issrg.utils.gui.xml
Class AddDelList

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by issrg.utils.gui.xml.AddDelList
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ListSelectionListener
Direct Known Subclasses:
ListPanel, NodeItemList, ResFunctionStringList, StringItemList, WSDLFilesListConfig, WSDLItemList

public abstract class AddDelList
extends javax.swing.JPanel
implements java.awt.event.ActionListener, javax.swing.event.ListSelectionListener, java.awt.event.MouseListener

This class is an abstract class and is a general purpose list editing component. Implements methods from ActionListener, ListSelectionListener and MouseListener.

This class extends a JPanel, and places a JListBox and three JButtons for adding/deleting/modifying entries in the listBox.

It is designed as an abstract class so that each class that uses it will, specify its own needs for adding/deleting/modifying.

This Class is one of the Basic Building blocks of the Policy Editor, as many classes implement it in some way or another.

Author:
Christian Azzopardi
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 javax.swing.JButton addButton
          The Add Button Variable
 javax.swing.JPanel addDisplay
          Panels needed in order to construct the final output of the AddDelList.
 java.awt.GridBagConstraints constraints
          Constraints for the GridBagLayout.
 javax.swing.JButton deleteButton
          The Delete Button Variable
 javax.swing.JPanel deleteDisplay
          Panels needed in order to construct the final output of the AddDelList.
 javax.swing.JMenuItem[] items
          List of Items that appear in the popupMenu.
 javax.swing.JList listBox
          The List Box Variable
 javax.swing.JPanel listBoxDisplay
          Panels needed in order to construct the final output of the AddDelList.
protected  java.lang.String[] listData
          The Data Elements Contained in the listBox, initialised to zero, so as not to have available selections in the listbox, when the list is empty.
 javax.swing.JPopupMenu popupMenu
          A pop-up Menu, that appears on right clicking in the ListBox.
 javax.swing.JButton replaceButton
          The Replace Button Variable
 javax.swing.JPanel replaceDisplay
          Panels needed in order to construct the final output of the AddDelList.
 javax.swing.JScrollPane scrollList
          Scroll Pane Variable, to enable list scrolling
protected static int sizeOfPopupMenu
          Declaration that the size of the popup menu used is going to be of 1 item.
 javax.swing.JPanel viewDisplay
          Panels needed in order to construct the final output of the AddDelList.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
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
AddDelList()
          Sets the Layout for this GUI Component, and adds the contents created in the getContentPanel() method.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent av)
          On clicking of a button the respective abstract methods are then called.
 void addComponent(java.awt.Component component, javax.swing.JPanel pane, int row, int column, int width, int height, int anchor, double weightx, double weighty, int fill)
          Method that adds a component to a JPanel when the Layout is of GridBagLayout Type.
abstract  void addItem()
          An abstract method that is called when an item is to be added to a list.
 int convertYToRow(int y)
          Method that given the Y-Coordinate, will return the corresponding value in the JList (listBox)
abstract  void deleteItem()
          An abstract method that is called when an item is to be removed from a list.
 javax.swing.JPanel getContentPanel()
          A JPanel containing the basic panel.
 java.lang.String[] getListData()
          A method that gets the data of the list component.
 int getSelectedIndex()
          Returns the Selected index of the List Component
abstract  void itemSelected()
          An abstract method that is called when an item is Selected from a list.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 javax.swing.JPanel removeAddButton()
          A method to remove the Add Button from the panel given by the getContentPanel() method.
 javax.swing.JPanel removeDeleteButton()
          A method to remove the Delete Button from the panel given by the getContentPanel() method.
 javax.swing.JPanel removeListBox()
          A method to remove the listBox JList from the panel given by the getContentPanel() method.
 javax.swing.JPanel removeReplaceButton()
          A method to remove the Replace Button from the panel given by the getContentPanel() method.
abstract  void replaceItem()
          An abstract method that is called when an item is to be replaced from a list.
 void setCaption(java.lang.String internalName, java.lang.String internationalName)
          Sets the text the component will show.
 void setListData(java.lang.String[] arguments)
          A method that sets the data to be displayed in the list component
 void setSelectedIndex(int idx)
          Sets the Selected index of the List Component
 void valueChanged(javax.swing.event.ListSelectionEvent e)
          When a list selection occurs this method is executed, and updates the functionality of the buttons in order to specify what the user can / can not press.
 
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, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, 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, transferFocusBackward, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

addButton

public javax.swing.JButton addButton
The Add Button Variable


deleteButton

public javax.swing.JButton deleteButton
The Delete Button Variable


replaceButton

public javax.swing.JButton replaceButton
The Replace Button Variable


listBox

public javax.swing.JList listBox
The List Box Variable


scrollList

public javax.swing.JScrollPane scrollList
Scroll Pane Variable, to enable list scrolling


viewDisplay

public javax.swing.JPanel viewDisplay
Panels needed in order to construct the final output of the AddDelList. They are mainly used is the getContentPanel() method.


addDisplay

public javax.swing.JPanel addDisplay
Panels needed in order to construct the final output of the AddDelList. They are mainly used is the getContentPanel() method.


deleteDisplay

public javax.swing.JPanel deleteDisplay
Panels needed in order to construct the final output of the AddDelList. They are mainly used is the getContentPanel() method.


replaceDisplay

public javax.swing.JPanel replaceDisplay
Panels needed in order to construct the final output of the AddDelList. They are mainly used is the getContentPanel() method.


listBoxDisplay

public javax.swing.JPanel listBoxDisplay
Panels needed in order to construct the final output of the AddDelList. They are mainly used is the getContentPanel() method.


popupMenu

public javax.swing.JPopupMenu popupMenu
A pop-up Menu, that appears on right clicking in the ListBox.


items

public javax.swing.JMenuItem[] items
List of Items that appear in the popupMenu. So far it only contains a link for Clearing the current List Selection.

This was implemented, as to clear Selection from a list may be hard or impossible, when the rows in the list are full (Even when the scroll bar can be used).


sizeOfPopupMenu

protected static int sizeOfPopupMenu
Declaration that the size of the popup menu used is going to be of 1 item.


constraints

public java.awt.GridBagConstraints constraints
Constraints for the GridBagLayout. This will enable better presentation constraints.


listData

protected java.lang.String[] listData
The Data Elements Contained in the listBox, initialised to zero, so as not to have available selections in the listbox, when the list is empty.

Constructor Detail

AddDelList

public AddDelList()
Sets the Layout for this GUI Component, and adds the contents created in the getContentPanel() method. The Contents are added with a BorderLayout.CENTER constraint so as to grow/shrink accordingly.

Method Detail

getContentPanel

public javax.swing.JPanel getContentPanel()
A JPanel containing the basic panel. This creates the GUI of the AddDelList, and returns it.

Returns:
The basic panel containing one list and 3 Buttons. The Buttons are themselves placed in panels.

valueChanged

public void valueChanged(javax.swing.event.ListSelectionEvent e)
When a list selection occurs this method is executed, and updates the functionality of the buttons in order to specify what the user can / can not press.

Specified by:
valueChanged in interface javax.swing.event.ListSelectionListener
Parameters:
e - the ListSelectionEvent

itemSelected

public abstract void itemSelected()
An abstract method that is called when an item is Selected from a list.


addItem

public abstract void addItem()
An abstract method that is called when an item is to be added to a list.


replaceItem

public abstract void replaceItem()
An abstract method that is called when an item is to be replaced from a list.


deleteItem

public abstract void deleteItem()
An abstract method that is called when an item is to be removed from a list.


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent av)
On clicking of a button the respective abstract methods are then called.

The ListBox can also be made to clear its selection, by right clicking on the listbox and clicking on the clear selection pop up menu.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

convertYToRow

public int convertYToRow(int y)
Method that given the Y-Coordinate, will return the corresponding value in the JList (listBox)

Parameters:
y - The Y-Coordinate.
Returns:
The Current Row that corresponds to the Y mouse Value.

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

removeAddButton

public javax.swing.JPanel removeAddButton()
A method to remove the Add Button from the panel given by the getContentPanel() method. This will return the panel that can then be reused or replaced where needed.

Returns:
A panel containing the Add Button and its functionality

removeReplaceButton

public javax.swing.JPanel removeReplaceButton()
A method to remove the Replace Button from the panel given by the getContentPanel() method. This will return the panel that can then be reused or replaced where needed.

Returns:
A panel containing the Replace Button and its functionality

removeDeleteButton

public javax.swing.JPanel removeDeleteButton()
A method to remove the Delete Button from the panel given by the getContentPanel() method. This will return the panel that can then be reused or replaced where needed.

Returns:
A panel containing the Delete Button and its functionality

removeListBox

public javax.swing.JPanel removeListBox()
A method to remove the listBox JList from the panel given by the getContentPanel() method. This will return the panel that can then be reused or replaced where needed.

Returns:
A panel containing the Delete Button and its functionality

setCaption

public void setCaption(java.lang.String internalName,
                       java.lang.String internationalName)
Sets the text the component will show.

Parameters:
internalName - The internal name used in the program.
internationalName - The international name to set the text to.

setListData

public void setListData(java.lang.String[] arguments)
A method that sets the data to be displayed in the list component

Parameters:
arguments - An array of strings to set the List Data.

getListData

public java.lang.String[] getListData()
A method that gets the data of the list component.

Returns:
An array of strings of the List Data items.

getSelectedIndex

public int getSelectedIndex()
Returns the Selected index of the List Component

Returns:
An integer with the current index of the selected Value in the List.

setSelectedIndex

public void setSelectedIndex(int idx)
Sets the Selected index of the List Component

Parameters:
idx - An integer with the wanted index of the selected Value in the List.

addComponent

public void addComponent(java.awt.Component component,
                         javax.swing.JPanel pane,
                         int row,
                         int column,
                         int width,
                         int height,
                         int anchor,
                         double weightx,
                         double weighty,
                         int fill)
Method that adds a component to a JPanel when the Layout is of GridBagLayout Type.

Parameters:
component - The component to add the the JPanel.
pane - The JPanel to add the component on.
row - The Row to start placing the component in.
column - The Column to start placing the component in.
width - The amount of rows the component can be placed on.
height - The amount of columns the component can be placed on.
anchor - The anchor GridBagLayout constraints.
weightx - The proportion to grow in the x direction.
weighty - The proportion to grow in the y direction.
fill - The Directions GridBagLayout Constant for which to fill.