org.ceryle.ui.graph
Class ResourceSelectionDialog

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by javax.swing.JDialog
                      extended by org.ceryle.ui.graph.ResourceSelectionDialog
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ListDataListener, ListSelectionListener, RootPaneContainer, WindowConstants, MessageWriter

public class ResourceSelectionDialog
extends JDialog
implements ListDataListener, ListSelectionListener, MessageWriter

A subclass of JDialog providing a selection list populated by a Vector. This dialog is hidden upon button action and must be disposed of manually. The result is obtained via getSelection().

NOTE: use in single modes

Note that the dialog can be initialized with only one of the tabs showing. This is how it is used as a bookmarks editor. The value of the static boolean useTable determines whether the bookmarks display uses a list or table view, the latter more appropriate to editing (since the user can see the URLs in the list).

NOTE: use with topic map panels

When a ResourceSelectionDialog is called with an optional TMPanel (TGPanel), it is assumed that the currently displayed graph is being passed to it. When this is the case, disposing of the dialog will nullify the TGPanel, so prior to doing so it is important to release and reattach the TGPanel to its original parent. An example of this is below:

     // ...
     GraphSettings settings = new GraphSettings(tmlp); // capture current settings
     ResourceSelectionDialog dlog = new ResourceSelectionDialog(
             desktop,"dialog title"
             ResourceSelectionDialog.GRAPH_TAB,
             ResourceSelectionDialog.SINGLE_SELECTION,
             (TMLayoutPanel)tmlp.getTGPanel(),
             settings);
     // get current node selection
     Iterator selection = dlog.getSelection();
     TMPanel gp = dlog.releaseTMPanel(); // release use of TGPanel
     dlog.dispose();
     tmlp.initialize(gp);      // reinitialize parent graph
     gp.setTGScrollPane(tmlp); // reattach parent to TGPanel
     settings.restore(tmlp);    // restore previous settings
     tmlp.setEditable(true);    // turn back on editing ability
     if ( selection != null ) {
         // process accordingly...
 

Since:
JDK1.3
Version:
$Id: ResourceSelectionDialog.java,v 3.20 2007-06-20 01:28:21 altheim Exp $
Author:
Murray Altheim
See Also:
Serialized Form

Nested Class Summary
 class ResourceSelectionDialog.DialogDisposer
           
 class ResourceSelectionDialog.TabbedPaneListener
          The listener class to handle changes in the tabbed pane.
 
Nested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialog
 
Nested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int BOOKMARKS_TAB
          ResourceSelectionDialog.BOOKMARKS_TAB indicates the bookmarks tab.
static int DATABASE_TAB
          ResourceSelectionDialog.DATABASE_TAB indicates the database tab.
static int dlog_height
          The preferred height of the dialog.
static int dlog_width
          The preferred width of the dialog.
static int GRAPH_TAB
          ResourceSelectionDialog.GRAPH_TAB indicates the graph tab.
static int HISTORY_TAB
          ResourceSelectionDialog.HISTORY_TAB indicates the history tab.
 boolean includeBrowse
           
static boolean isModalDialog
          A boolean that when true sets the dialog as modal (the default) or non-modal.
static int MULTIPLE_INTERVAL_SELECTION
          A value for the selectionMode property: select one or more contiguous ranges of indices at a time.
protected  org.ceryle.ui.graph.ResourceSelectionDialog.NodeSelectionListener nsl
           
static int SINGLE_INTERVAL_SELECTION
          A value for the selectionMode property: select one contiguous range of indices at a time.
static int SINGLE_SELECTION
          A value for the selectionMode property: select one list index at a time.
static boolean useTable
          Use a JTable display rather than a JList for the bookmark list.
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ResourceSelectionDialog(Desktop desktop, String title, String message, int selectionMode)
          Constructor for a dialog box containing a tabbed panel used to select a resource (URI) via one of several methods.
ResourceSelectionDialog(Desktop desktop, String title, String message, int whichTab, int selectionMode, TMPanel tmpanel, GraphSettings settings)
          Constructor for a dialog box containing a tabbed panel used to select a resource (URI) via one of several methods.
 
Method Summary
 void browse()
          Display a file chooser and put the result into the selection.
 void contentsChanged(ListDataEvent e)
          Public method required by the ListDataListener API.
protected  JPanel createButtonPanel()
          Returns the southernmost panel containing the submit and cancel buttons.
protected  JPanel createCenterPanel(int selectionMode, TMPanel tmpanel)
          Returns the center panel containing the selection area(s).
protected  JSplitPane createCollectionPanel()
          Creates a scrollable, clickable selection list (as a JComboBox), returning it as a new panel.
protected  JPanel createNorthPanel(String message)
          Returns the northernmost panel containing the message text.
protected  String getCollection(String cid)
          Opens the Collection cid as the default Collection.
 Iterator getSelection()
          Return the URI field contents as the provided Iterator, null if empty.
 int getSelectionCount()
          Return the number of items in the selection.
 TMLayoutPanel getTMLayoutPanel()
          Returns the TMLayoutPanel used by the graph tab.
 void go()
          Open the current topmost URI in the selection list.
protected  Iterator indexNodes(String cid, String nid)
          Set the Node list to the contents of the Collection whose ID is cid.
 void intervalAdded(ListDataEvent e)
          Public method required by the ListDataListener API.
 void intervalRemoved(ListDataEvent e)
          Public method required by the ListDataListener API.
 TMPanel releaseTMPanel()
          Returns a reference to the TGPanel used by the graph tab.
protected  void selectTab(int tab)
          Selects the tab indicated by the int tab, using one of the enumerated constants.
protected  void setContent(Object content, boolean clear, String caller)
          Set the URI field contents to the provided Object[] array (of Strings), String, (or toString()).
 void setTGPanel(TMPanel tmpanel)
          Sets the TouchGraph panel used in the graph tab to tmpanel.
 void valueChanged(ListSelectionEvent e)
          Public method required by the ListDataListener API.
 String writeMessage(int status, String message)
          Implements the MessageWriter API, passing off messages to the Desktop.
 void writeMessage(String message)
          Implements the MessageWriter API, passing off messages to the Desktop.
 void writeStatus(String message)
          Implements the MessageWriter API, passing off status messages to the Desktop.
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Dialog
addNotify, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DATABASE_TAB

public static final int DATABASE_TAB
ResourceSelectionDialog.DATABASE_TAB indicates the database tab.

See Also:
Constant Field Values

BOOKMARKS_TAB

public static final int BOOKMARKS_TAB
ResourceSelectionDialog.BOOKMARKS_TAB indicates the bookmarks tab.

See Also:
Constant Field Values

HISTORY_TAB

public static final int HISTORY_TAB
ResourceSelectionDialog.HISTORY_TAB indicates the history tab.

See Also:
Constant Field Values

GRAPH_TAB

public static final int GRAPH_TAB
ResourceSelectionDialog.GRAPH_TAB indicates the graph tab.

See Also:
Constant Field Values

dlog_width

public static int dlog_width
The preferred width of the dialog. The default is 700.


dlog_height

public static int dlog_height
The preferred height of the dialog. The default is 450.


isModalDialog

public static boolean isModalDialog
A boolean that when true sets the dialog as modal (the default) or non-modal.


useTable

public static boolean useTable
Use a JTable display rather than a JList for the bookmark list.


SINGLE_SELECTION

public static final int SINGLE_SELECTION
A value for the selectionMode property: select one list index at a time.

See Also:
ListSelectionModel.SINGLE_SELECTION, Constant Field Values

SINGLE_INTERVAL_SELECTION

public static final int SINGLE_INTERVAL_SELECTION
A value for the selectionMode property: select one contiguous range of indices at a time.

See Also:
ListSelectionModel.SINGLE_INTERVAL_SELECTION, Constant Field Values

MULTIPLE_INTERVAL_SELECTION

public static final int MULTIPLE_INTERVAL_SELECTION
A value for the selectionMode property: select one or more contiguous ranges of indices at a time.

See Also:
ListSelectionModel.MULTIPLE_INTERVAL_SELECTION, Constant Field Values

nsl

protected org.ceryle.ui.graph.ResourceSelectionDialog.NodeSelectionListener nsl

includeBrowse

public boolean includeBrowse
Constructor Detail

ResourceSelectionDialog

public ResourceSelectionDialog(Desktop desktop,
                               String title,
                               String message,
                               int selectionMode)
Constructor for a dialog box containing a tabbed panel used to select a resource (URI) via one of several methods. The dialog obtains the necessary hooks via the Desktop. The tabs include selection via the history list, the bookmarks list, a selection from the database, or from a graph.

Options for selectionMode are:

Note: currently only single selection is supported.

Parameters:
desktop - the parent desktop
title - the dialog title
message - the text prompt to display
selectionMode - a value of JList's selection mode

ResourceSelectionDialog

public ResourceSelectionDialog(Desktop desktop,
                               String title,
                               String message,
                               int whichTab,
                               int selectionMode,
                               TMPanel tmpanel,
                               GraphSettings settings)
Constructor for a dialog box containing a tabbed panel used to select a resource (URI) via one of several methods. This constructor displays only a single tab, chosen using whichTab. If the graph tab is used, an optional TMPanel can be supplied.

Parameters:
desktop - the parent desktop
title - the dialog title
message - the text prompt to display
whichTab - the tab to display
selectionMode - a value of JList's selection mode
tmpanel - a supplied TMPanel (optional)
settings - graph settings (optional)
See Also:
DATABASE_TAB, BOOKMARKS_TAB, HISTORY_TAB, GRAPH_TAB
Method Detail

createNorthPanel

protected JPanel createNorthPanel(String message)
Returns the northernmost panel containing the message text.


createCenterPanel

protected JPanel createCenterPanel(int selectionMode,
                                   TMPanel tmpanel)
Returns the center panel containing the selection area(s).


selectTab

protected void selectTab(int tab)
Selects the tab indicated by the int tab, using one of the enumerated constants. If the dialog was created with only one tab, this method is ignored.

See Also:
DATABASE_TAB, BOOKMARKS_TAB, HISTORY_TAB, GRAPH_TAB

getSelectionCount

public int getSelectionCount()
Return the number of items in the selection.


getSelection

public Iterator getSelection()
Return the URI field contents as the provided Iterator, null if empty. If the selection mode was set for single selection, the first element in the Iterator will be the selection. The values are all Strings.


setContent

protected void setContent(Object content,
                          boolean clear,
                          String caller)
Set the URI field contents to the provided Object[] array (of Strings), String, (or toString()).


go

public void go()
Open the current topmost URI in the selection list.


browse

public void browse()
Display a file chooser and put the result into the selection.


createCollectionPanel

protected JSplitPane createCollectionPanel()
Creates a scrollable, clickable selection list (as a JComboBox), returning it as a new panel.


contentsChanged

public void contentsChanged(ListDataEvent e)
Public method required by the ListDataListener API.

Specified by:
contentsChanged in interface ListDataListener

intervalAdded

public void intervalAdded(ListDataEvent e)
Public method required by the ListDataListener API.

Specified by:
intervalAdded in interface ListDataListener

intervalRemoved

public void intervalRemoved(ListDataEvent e)
Public method required by the ListDataListener API.

Specified by:
intervalRemoved in interface ListDataListener

valueChanged

public void valueChanged(ListSelectionEvent e)
Public method required by the ListDataListener API.

Specified by:
valueChanged in interface ListSelectionListener

getCollection

protected String getCollection(String cid)
Opens the Collection cid as the default Collection. Returns a String containing the name of the default Collection, null is unavailable.


indexNodes

protected Iterator indexNodes(String cid,
                              String nid)
Set the Node list to the contents of the Collection whose ID is cid.


setTGPanel

public void setTGPanel(TMPanel tmpanel)
Sets the TouchGraph panel used in the graph tab to tmpanel. This can be used to include the current graph in the dialog box. Note that the object set here will be set to null upon dialog disposal.


getTMLayoutPanel

public TMLayoutPanel getTMLayoutPanel()
Returns the TMLayoutPanel used by the graph tab.


createButtonPanel

protected JPanel createButtonPanel()
Returns the southernmost panel containing the submit and cancel buttons.


releaseTMPanel

public TMPanel releaseTMPanel()
Returns a reference to the TGPanel used by the graph tab. To be called upon prior to closing the dialog, for any cleanup.


writeMessage

public void writeMessage(String message)
Implements the MessageWriter API, passing off messages to the Desktop.

Specified by:
writeMessage in interface MessageWriter

writeMessage

public String writeMessage(int status,
                           String message)
Implements the MessageWriter API, passing off messages to the Desktop.

Specified by:
writeMessage in interface MessageWriter
Returns:
the String value of the message, including any changes made.
See Also:
MessageHandler

writeStatus

public void writeStatus(String message)
Implements the MessageWriter API, passing off status messages to the Desktop.

Specified by:
writeStatus in interface MessageWriter


The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.