HiRISE

HiRISE.HiPlan.HOGG
Class Suggestion_Panel

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 HiRISE.HiPlan.HOGG.Suggestion_Panel
All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class Suggestion_Panel
extends JPanel
implements ActionListener

A graphic panel for managing an observation's suggestion. This panel is one of the components of the HOGG.

Version:
2.62
Author:
Christian Schaller - UA/PIRL
See Also:
Serialized Form

Nested Class Summary
static class Suggestion_Panel.Mapping_Exception
          An exception for reporting problems with the suggestion mapping table.
static class Suggestion_Panel.Mode
          An enumeration describing the possible modes of suggestion editor operation.
 
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
static String APPLICATION_GROUP
           
static Suggestion_Panel.Mode DEFAULT_MODE
           
static String ID
          Class identification name with source code version and date.
static String MODE
           
 
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
Suggestion_Panel(Database database)
          Creates a Suggestion_Panel with a specified database connection object.
Suggestion_Panel(HOGG hogg)
          Creates a Suggestion_Panel with a callback reference to a parent HOGG.
 
Method Summary
 void actionPerformed(ActionEvent e)
          Invoked when an action occurs.
 void checkStlConstraints(boolean useHoggStatus)
           
 Integer getDisplayedId()
          Gets the ID of the suggestion currently displayed by this panel.
 Integer getMappedId()
          Gets the ID of the suggestion currently mapped in the database to this panel's observation.
 String getObservationId()
          Gets the text ID of the observation for which this panel manages the suggestion ID.
 List<String> getStlConstraintsViolations()
          Gets a list of messages describing any STL constraints violations for the current suggestion.
 SuggestedObservation getSuggestion()
          Gets the suggestion editor's suggestion.
 JMenu getSuggestionMenu()
          Gets the suggestion panel's menu, which is suitable to adding to an existing menu bar.
 void init()
          Initializes the panel.
 boolean isClean()
          Indicates whether the suggestion shown in the suggestion editor is clean.
 boolean isSuggestionReady()
          Determines whether the suggestion panel is ready for operation.
 boolean retrieveMappedId()
          Retrieves from the database the suggestion ID mapped to this panel's observation ID.
 boolean retrieveSuggestion(Integer suggestionId, String message)
          Retrieves from the database the indicated suggestion if possible.
 boolean saveSuggestion(boolean notifyOnSave)
          Saves the suggestion displayed in the panel.
 void setObservationId(String observationId)
          Sets the text ID of the observation for which this panel manages the suggestion ID.
 boolean submitMappedId()
          Submits the currently displayed suggestion's ID to the database for mapping.
 int unmapSuggestion()
          Removes the suggestion mapping entry matching the current observation ID.
 int unmapSuggestion(String comment)
          Removes the suggestion mapping entry matching the current observation ID.
 void updateObservationFields()
           
 
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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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

ID

public static final String ID
Class identification name with source code version and date.

See Also:
Constant Field Values

APPLICATION_GROUP

public static final String APPLICATION_GROUP
See Also:
Constant Field Values

MODE

public static final String MODE
See Also:
Constant Field Values

DEFAULT_MODE

public static final Suggestion_Panel.Mode DEFAULT_MODE
Constructor Detail

Suggestion_Panel

public Suggestion_Panel(HOGG hogg)
Creates a Suggestion_Panel with a callback reference to a parent HOGG. The HOGG supplies its database connection via its observation record broker.

Parameters:
hogg - the callback reference to a parent HOGG.

Suggestion_Panel

public Suggestion_Panel(Database database)
Creates a Suggestion_Panel with a specified database connection object.

Parameters:
database - the database connection object that retrieves data from HiCat.
Method Detail

init

public void init()
Initializes the panel.


isSuggestionReady

public boolean isSuggestionReady()
Determines whether the suggestion panel is ready for operation. If it is, then suggestion table-based operations are enabled. If not, they are disabled.

Returns:
true if the suggestion panel is ready; false if not.

getObservationId

public String getObservationId()
Gets the text ID of the observation for which this panel manages the suggestion ID. This ID is not necessarily a formal Observation_ID.

Returns:
the panel's observation ID.

setObservationId

public void setObservationId(String observationId)
Sets the text ID of the observation for which this panel manages the suggestion ID. This ID need not be a formal Observation_ID.

When this ID is set, the panel will attempt to find a mapped suggestion ID from the database. If an ID is found, the suggestion is loaded and the interface is updated with the data. Both getMappedId() and getDisplayedId() are set to the mapped suggestion ID.

If no suggestion ID is mapped to this observation ID or if this observation ID is null, the interface will be initialized with blank fields, ready for a new suggestion to be edited. The mapped ID and the displayed ID will be set to null.

If the observation ID is null, the Load, New, and Reset suggestion buttons will also be disabled.

Parameters:
observationId - the new text observation ID for this panel.

getMappedId

public Integer getMappedId()
Gets the ID of the suggestion currently mapped in the database to this panel's observation. If no suggestion is mapped, this ID is null.

Note that there is no corresponding setter for the mapped ID; the mapping is entirely managed by this panel.

Returns:
the mapped ID for this panel's observation.

getDisplayedId

public Integer getDisplayedId()
Gets the ID of the suggestion currently displayed by this panel. If it has no ID, this method returns null.

This ID is not necessarily the ID mapped to the panel's observation ID.

Returns:
the displayed suggestion ID.
See Also:
SuggestionEditorPanel.getID()

getSuggestionMenu

public JMenu getSuggestionMenu()
Gets the suggestion panel's menu, which is suitable to adding to an existing menu bar. The menu is called "Suggestion."

Returns:
the suggestion panel menu.

getSuggestion

public SuggestedObservation getSuggestion()
Gets the suggestion editor's suggestion. This is the suggestion as defined by the current state of the editor's controls, which is not necessarily the suggestion as it is currently stored in the database.

Returns:
the current suggestion.

actionPerformed

public void actionPerformed(ActionEvent e)
Invoked when an action occurs. The suggestion panel monitors only the buttons on the top row; all other interface controls are managed by the backfill panel.

Specified by:
actionPerformed in interface ActionListener
Parameters:
e - the action event.

retrieveSuggestion

public boolean retrieveSuggestion(Integer suggestionId,
                                  String message)
Retrieves from the database the indicated suggestion if possible. If the suggestion is found, this method returns true; otherwise it returns false. This method does not change the mapping between this panel's observation and the observation's suggestion; it only loads the indicated suggestion. If the submitMappedId() method is called, the mapping will be changed.

Parameters:
suggestionId - the ID of the suggestion to load.
message - the message to display if the suggestion cannot be found; if null, no message is displayed.
Returns:
true if the suggestion was found and loaded; false otherwise.

saveSuggestion

public boolean saveSuggestion(boolean notifyOnSave)
Saves the suggestion displayed in the panel. If the suggestion cannot be saved, an error dialog is displayed.

Parameters:
notifyOnSave - if true, the suggestion editor will alert the operator that the suggestion has been saved.
Returns:
true if the suggestion was successfully saved; false otherwise.

retrieveMappedId

public boolean retrieveMappedId()
                         throws Database_Exception
Retrieves from the database the suggestion ID mapped to this panel's observation ID. This method queries the database's suggestion ID mapping table.

If a suggestion ID is found, getMappedId() is set to the value and the interface is updated to reflect the matching suggestion.

If no suggestion ID is found, or if the observation ID is null, or if the observation ID does not exist in the database, this method does nothing.

Returns:
true if an ID is found; false if not.
Throws:
Database_Exception - if there was a problem with the database.

submitMappedId

public boolean submitMappedId()
                       throws Database_Exception,
                              Suggestion_Panel.Mapping_Exception
Submits the currently displayed suggestion's ID to the database for mapping. The ID is mapped to this panel's observation ID, which results in the mapped ID being set to the displayed ID.

If the panel's observation ID is null, this method does nothing. If the displayed ID is the same as the mapped ID, this method does nothing.

If the displayed ID is null, this method unmaps the observation.

If the panel's observation ID is not a formal HiRISE observation ID, this method does not map the suggestion. Furthermore, it runs an unmapping operation to clean up any extraneous suggestion mapping to this ID. The check for formality in the observation ID is done via the Utilities.isFormalId(java.lang.String) method.

The return value of this method indicates whether the mapping operation proceeded normally or the operator canceled it. A "normal" mapping includes the cases where there is nothing to map (i.e., the displayed suggestion ID is null or the observation ID is null or the observation ID is not a formal observation ID), or where the suggestion is already mapped (i.e., the mapped ID is the same as the displayed ID). It also includes the case where the suggestion panel has been disabled.

Returns:
true if the mapping operation proceeded normally; false if the operator canceled it.
Throws:
Database_Exception - if there was a problem with the database.
Suggestion_Panel.Mapping_Exception - if there was a problem with the mapping.

unmapSuggestion

public int unmapSuggestion(String comment)
                    throws Database_Exception
Removes the suggestion mapping entry matching the current observation ID. If multiple entries exist, all will be removed. The indicated comment will be appended to the SPECIAL_NOTES field of any suggestion that gets unretired by this operation; the comment may be null, in which case nothing is so appended.

Parameters:
comment - the comment to append to the SPECIAL_NOTES field of suggestions unretired. May be null
Returns:
the number of records removed.
Throws:
Database_Exception - if there was a problem with the database.
See Also:
Unretire_Suggestions, Unretire_Suggestions.Comment(String), Unretire_Suggestions.Unretire_Observation_ID(String)

unmapSuggestion

public int unmapSuggestion()
                    throws Database_Exception
Removes the suggestion mapping entry matching the current observation ID. If multiple entries exist, all will be removed. Nothing is appended to the suggestion's SPECIAL_NOTES field during the resulting unretirement.

Returns:
the number of records removed.
Throws:
Database_Exception - if there was a problem with the database.
See Also:
Unretire_Suggestions, Unretire_Suggestions.Unretire_Observation_ID(String)

updateObservationFields

public void updateObservationFields()

checkStlConstraints

public void checkStlConstraints(boolean useHoggStatus)

isClean

public boolean isClean()
Indicates whether the suggestion shown in the suggestion editor is clean. The suggestion is clean if it does not need to be saved. A suggestion needs to be saved if any of its values have changed since it was last saved.

Returns:
true if the suggestion needs to be saved.

getStlConstraintsViolations

public List<String> getStlConstraintsViolations()
Gets a list of messages describing any STL constraints violations for the current suggestion. STL constraints are compared to the observation's corresponding values. If there are no violations, the list size is 0.

Returns:
a list of messages describing the violations. Not null.

HiRISE

Copyright (C) Arizona Board of Regents on behalf of the Planetary Image Research Laboratory, Lunar and Planetary Laboratory at the University of Arizona