Package org.openstreetmap.josm.gui.io
Class BasicUploadSettingsPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- org.openstreetmap.josm.gui.io.BasicUploadSettingsPanel
-
- All Implemented Interfaces:
ActionListener
,FocusListener
,ItemListener
,KeyListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,TableModelListener
public class BasicUploadSettingsPanel extends JPanel implements ActionListener, FocusListener, ItemListener, KeyListener, TableModelListener
BasicUploadSettingsPanel allows to enter the basic parameters required for uploading data.- Since:
- 2599
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
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
Fields Modifier and Type Field Description private UploadTextComponentValidator.UploadAreaValidator
areaValidator
private JLabel
areaValidatorFeedback
private JCheckBox
cbRequestReview
the checkbox to request feedback from other usersstatic String
COMMENT_HISTORY_KEY
Preference name for the history of commentsstatic String
COMMENT_LAST_USED_KEY
Preference name for last used upload commentstatic String
COMMENT_MAX_AGE_KEY
Preference name for the max age search comments may haveprivate HistoryComboBox
hcbUploadComment
the history combo box for the upload commentprivate HistoryComboBox
hcbUploadSource
private JLabel
hcbUploadSourceFeedback
private boolean
locked
a lock to prevent loops in notificationsprivate UploadDialogModel
model
the changeset comment modelprivate JCheckBox
obtainSourceAutomatically
private UploadParameterSummaryPanel
pnlUploadParameterSummary
the panel with a summary of the upload parametersstatic String
SOURCE_HISTORY_KEY
Preference name for the history of sourcesprivate JLabel
uploadCommentFeedback
private UploadTextComponentValidator.UploadCommentValidator
uploadCommentValidator
private UploadTextComponentValidator.UploadSourceValidator
uploadSourceValidator
-
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 Constructor Description BasicUploadSettingsPanel(UploadDialogModel model)
Creates the panel
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(ActionEvent e)
Update the model when the selection changes in a combobox.protected void
build()
protected JPanel
buildUploadCommentPanel()
protected JPanel
buildUploadSourcePanel()
void
focusGained(FocusEvent e)
void
focusLost(FocusEvent e)
Update the model and combobox history when a combobox editor loses focus.private String
get(String key)
Get a key's value from the model.static List<String>
getDefaultSources()
Returns the default list of sources.private UploadDialog
getDialog()
Returns the UplodDialog that is our ancestor(package private) static long
getHistoryLastUsedKey()
(package private) static long
getHistoryMaxAgeKey()
static String
getLastChangesetTagFromHistory(String historyKey, List<String> def)
Get the topmost item from the history if not expired.private String
getSourceFromLayer()
Add the "source" tagUploadParameterSummaryPanel
getUploadParameterSummaryPanel()
Returns the panel that displays a summary of data the user is about to upload.protected List<UploadTextComponentValidator>
getUploadTextValidators()
Returns the list ofUploadTextComponentValidator
defined by this panel.void
initEditingOfUploadComment()
Initializes editing of upload comment.void
initEditingOfUploadSource()
Initializes editing of upload source.void
initLifeCycle(Map<String,String> map)
Initializes this life cycle of the panel.void
itemStateChanged(ItemEvent e)
Updates the table editor model upon changes in the "review" checkbox.void
keyPressed(KeyEvent e)
void
keyReleased(KeyEvent e)
void
keyTyped(KeyEvent e)
Set the focus directly to the upload button if "Enter" key is pressed in any combobox.void
rememberUserInput()
Remembers the user input in the preference settingsvoid
saveEdits()
Save all outstanding edits to the model.private void
setFocusToUploadButton()
(package private) void
setUploadedPrimitives(List<OsmPrimitive> primitives)
void
tableChanged(TableModelEvent e)
Updates the controls upon changes in the table editor model.private void
updateHistory(JTextField text)
Updates the combobox histories when a combobox editor loses focus.private void
updateModel(JTextField text)
Updates the table editor model with changes in the comboboxes.-
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 Detail
-
COMMENT_HISTORY_KEY
public static final String COMMENT_HISTORY_KEY
Preference name for the history of comments- See Also:
- Constant Field Values
-
COMMENT_LAST_USED_KEY
public static final String COMMENT_LAST_USED_KEY
Preference name for last used upload comment- See Also:
- Constant Field Values
-
COMMENT_MAX_AGE_KEY
public static final String COMMENT_MAX_AGE_KEY
Preference name for the max age search comments may have- See Also:
- Constant Field Values
-
SOURCE_HISTORY_KEY
public static final String SOURCE_HISTORY_KEY
Preference name for the history of sources- See Also:
- Constant Field Values
-
hcbUploadComment
private final HistoryComboBox hcbUploadComment
the history combo box for the upload comment
-
hcbUploadSource
private final HistoryComboBox hcbUploadSource
-
obtainSourceAutomatically
private final transient JCheckBox obtainSourceAutomatically
-
pnlUploadParameterSummary
private final UploadParameterSummaryPanel pnlUploadParameterSummary
the panel with a summary of the upload parameters
-
cbRequestReview
private final JCheckBox cbRequestReview
the checkbox to request feedback from other users
-
areaValidatorFeedback
private final JLabel areaValidatorFeedback
-
areaValidator
private final UploadTextComponentValidator.UploadAreaValidator areaValidator
-
model
private final transient UploadDialogModel model
the changeset comment model
-
uploadCommentFeedback
private final transient JLabel uploadCommentFeedback
-
uploadCommentValidator
private final transient UploadTextComponentValidator.UploadCommentValidator uploadCommentValidator
-
hcbUploadSourceFeedback
private final transient JLabel hcbUploadSourceFeedback
-
uploadSourceValidator
private final transient UploadTextComponentValidator.UploadSourceValidator uploadSourceValidator
-
locked
private boolean locked
a lock to prevent loops in notifications
-
-
Constructor Detail
-
BasicUploadSettingsPanel
public BasicUploadSettingsPanel(UploadDialogModel model)
Creates the panel- Parameters:
model
- The tag editor model.- Since:
- 18173 (signature)
-
-
Method Detail
-
build
protected void build()
-
buildUploadCommentPanel
protected JPanel buildUploadCommentPanel()
-
buildUploadSourcePanel
protected JPanel buildUploadSourcePanel()
-
initLifeCycle
public void initLifeCycle(Map<String,String> map)
Initializes this life cycle of the panel. Adds the comment and source tags from history, and/or obtains the source from the layer if the user said so.- Parameters:
map
- Map where tags are added to.- Since:
- 18173
-
get
private String get(String key)
Get a key's value from the model.- Parameters:
key
- The key- Returns:
- The value or ""
- Since:
- 18173
-
getLastChangesetTagFromHistory
public static String getLastChangesetTagFromHistory(String historyKey, List<String> def)
Get the topmost item from the history if not expired.- Parameters:
historyKey
- The preferences key.def
- A default history.- Returns:
- The history item (may be null).
- Since:
- 18173 (signature)
-
getSourceFromLayer
private String getSourceFromLayer()
Add the "source" tag- Returns:
- The source from the layer info.
-
getDefaultSources
public static List<String> getDefaultSources()
Returns the default list of sources.- Returns:
- the default list of sources
-
getUploadTextValidators
protected List<UploadTextComponentValidator> getUploadTextValidators()
Returns the list ofUploadTextComponentValidator
defined by this panel.- Returns:
- the list of
UploadTextComponentValidator
defined by this panel. - Since:
- 17238
-
rememberUserInput
public void rememberUserInput()
Remembers the user input in the preference settings
-
initEditingOfUploadComment
public void initEditingOfUploadComment()
Initializes editing of upload comment.
-
initEditingOfUploadSource
public void initEditingOfUploadSource()
Initializes editing of upload source.
-
setUploadedPrimitives
void setUploadedPrimitives(List<OsmPrimitive> primitives)
-
getUploadParameterSummaryPanel
public UploadParameterSummaryPanel getUploadParameterSummaryPanel()
Returns the panel that displays a summary of data the user is about to upload.- Returns:
- the upload parameter summary panel
-
getHistoryMaxAgeKey
static long getHistoryMaxAgeKey()
-
getHistoryLastUsedKey
static long getHistoryLastUsedKey()
-
updateHistory
private void updateHistory(JTextField text)
Updates the combobox histories when a combobox editor loses focus.- Parameters:
text
- TheJTextField
of the combobox editor.
-
updateModel
private void updateModel(JTextField text)
Updates the table editor model with changes in the comboboxes. The lock prevents loops in change notifications, eg. the combobox notifies the table model and the table model notifies the combobox, which throws IllegalStateException.- Parameters:
text
- TheJTextField
of the combobox editor.
-
saveEdits
public void saveEdits()
Save all outstanding edits to the model.- Since:
- 18173
- See Also:
UploadDialog.saveEdits()
-
getDialog
private UploadDialog getDialog()
Returns the UplodDialog that is our ancestor- Returns:
- the UploadDialog or null
-
actionPerformed
public void actionPerformed(ActionEvent e)
Update the model when the selection changes in a combobox.- Specified by:
actionPerformed
in interfaceActionListener
- Parameters:
e
- The action event.
-
focusGained
public void focusGained(FocusEvent e)
- Specified by:
focusGained
in interfaceFocusListener
-
focusLost
public void focusLost(FocusEvent e)
Update the model and combobox history when a combobox editor loses focus.- Specified by:
focusLost
in interfaceFocusListener
-
itemStateChanged
public void itemStateChanged(ItemEvent e)
Updates the table editor model upon changes in the "review" checkbox.- Specified by:
itemStateChanged
in interfaceItemListener
-
tableChanged
public void tableChanged(TableModelEvent e)
Updates the controls upon changes in the table editor model.- Specified by:
tableChanged
in interfaceTableModelListener
-
keyTyped
public void keyTyped(KeyEvent e)
Set the focus directly to the upload button if "Enter" key is pressed in any combobox.- Specified by:
keyTyped
in interfaceKeyListener
-
keyPressed
public void keyPressed(KeyEvent e)
- Specified by:
keyPressed
in interfaceKeyListener
-
keyReleased
public void keyReleased(KeyEvent e)
- Specified by:
keyReleased
in interfaceKeyListener
-
setFocusToUploadButton
private void setFocusToUploadButton()
-
-