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:
java.awt.event.ActionListener,java.awt.event.FocusListener,java.awt.event.ItemListener,java.awt.event.KeyListener,java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,java.util.EventListener,javax.accessibility.Accessible,javax.swing.event.TableModelListener
public class BasicUploadSettingsPanel extends javax.swing.JPanel implements java.awt.event.ActionListener, java.awt.event.FocusListener, java.awt.event.ItemListener, java.awt.event.KeyListener, javax.swing.event.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
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description private UploadTextComponentValidator.UploadAreaValidatorareaValidatorprivate javax.swing.JLabelareaValidatorFeedbackprivate javax.swing.JCheckBoxcbRequestReviewthe checkbox to request feedback from other usersstatic java.lang.StringCOMMENT_HISTORY_KEYPreference name for the history of commentsstatic java.lang.StringCOMMENT_LAST_USED_KEYPreference name for last used upload commentstatic java.lang.StringCOMMENT_MAX_AGE_KEYPreference name for the max age search comments may haveprivate HistoryComboBoxhcbUploadCommentthe history combo box for the upload commentprivate HistoryComboBoxhcbUploadSourceprivate javax.swing.JLabelhcbUploadSourceFeedbackprivate booleanlockeda lock to prevent loops in notificationsprivate UploadDialogModelmodelthe changeset comment modelprivate javax.swing.JCheckBoxobtainSourceAutomaticallyprivate UploadParameterSummaryPanelpnlUploadParameterSummarythe panel with a summary of the upload parametersstatic java.lang.StringSOURCE_HISTORY_KEYPreference name for the history of sourcesprivate javax.swing.JLabeluploadCommentFeedbackprivate UploadTextComponentValidator.UploadCommentValidatoruploadCommentValidatorprivate UploadTextComponentValidator.UploadSourceValidatoruploadSourceValidator-
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
-
-
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 voidactionPerformed(java.awt.event.ActionEvent e)Update the model when the selection changes in a combobox.protected voidbuild()protected javax.swing.JPanelbuildUploadCommentPanel()protected javax.swing.JPanelbuildUploadSourcePanel()voidfocusGained(java.awt.event.FocusEvent e)voidfocusLost(java.awt.event.FocusEvent e)Update the model and combobox history when a combobox editor loses focus.private java.lang.Stringget(java.lang.String key)Get a key's value from the model.static java.util.List<java.lang.String>getDefaultSources()Returns the default list of sources.private UploadDialoggetDialog()Returns the UplodDialog that is our ancestor(package private) static longgetHistoryLastUsedKey()(package private) static longgetHistoryMaxAgeKey()static java.lang.StringgetLastChangesetTagFromHistory(java.lang.String historyKey, java.util.List<java.lang.String> def)Get the topmost item from the history if not expired.(package private) java.lang.StringgetSourceFromLayer()Add the "source" tagUploadParameterSummaryPanelgetUploadParameterSummaryPanel()Returns the panel that displays a summary of data the user is about to upload.protected java.util.List<UploadTextComponentValidator>getUploadTextValidators()Returns the list ofUploadTextComponentValidatordefined by this panel.voidinitEditingOfUploadComment()Initializes editing of upload comment.voidinitEditingOfUploadSource()Initializes editing of upload source.voidinitLifeCycle(java.util.Map<java.lang.String,java.lang.String> map)Initializes this life cycle of the panel.voiditemStateChanged(java.awt.event.ItemEvent e)Updates the table editor model upon changes in the "review" checkbox.voidkeyPressed(java.awt.event.KeyEvent e)voidkeyReleased(java.awt.event.KeyEvent e)voidkeyTyped(java.awt.event.KeyEvent e)Set the focus directly to the upload button if "Enter" key is pressed in any combobox.voidrememberUserInput()Remembers the user input in the preference settingsvoidsaveEdits()Save all outstanding edits to the model.private voidsetFocusToUploadButton()(package private) voidsetUploadedPrimitives(java.util.List<OsmPrimitive> primitives)voidtableChanged(javax.swing.event.TableModelEvent e)Updates the controls upon changes in the table editor model.private voidupdateHistory(javax.swing.JTextField text)Updates the combobox histories when a combobox editor loses focus.private voidupdateModel(javax.swing.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 java.lang.String COMMENT_HISTORY_KEY
Preference name for the history of comments- See Also:
- Constant Field Values
-
COMMENT_LAST_USED_KEY
public static final java.lang.String COMMENT_LAST_USED_KEY
Preference name for last used upload comment- See Also:
- Constant Field Values
-
COMMENT_MAX_AGE_KEY
public static final java.lang.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 java.lang.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 javax.swing.JCheckBox obtainSourceAutomatically
-
pnlUploadParameterSummary
private final UploadParameterSummaryPanel pnlUploadParameterSummary
the panel with a summary of the upload parameters
-
cbRequestReview
private final javax.swing.JCheckBox cbRequestReview
the checkbox to request feedback from other users
-
areaValidatorFeedback
private final javax.swing.JLabel areaValidatorFeedback
-
areaValidator
private final UploadTextComponentValidator.UploadAreaValidator areaValidator
-
model
private final transient UploadDialogModel model
the changeset comment model
-
uploadCommentFeedback
private final transient javax.swing.JLabel uploadCommentFeedback
-
uploadCommentValidator
private final transient UploadTextComponentValidator.UploadCommentValidator uploadCommentValidator
-
hcbUploadSourceFeedback
private final transient javax.swing.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 javax.swing.JPanel buildUploadCommentPanel()
-
buildUploadSourcePanel
protected javax.swing.JPanel buildUploadSourcePanel()
-
initLifeCycle
public void initLifeCycle(java.util.Map<java.lang.String,java.lang.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 java.lang.String get(java.lang.String key)
Get a key's value from the model.- Parameters:
key- The key- Returns:
- The value or ""
- Since:
- 18173
-
getLastChangesetTagFromHistory
public static java.lang.String getLastChangesetTagFromHistory(java.lang.String historyKey, java.util.List<java.lang.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
java.lang.String getSourceFromLayer()
Add the "source" tag- Returns:
- The source from the layer info.
-
getDefaultSources
public static java.util.List<java.lang.String> getDefaultSources()
Returns the default list of sources.- Returns:
- the default list of sources
-
getUploadTextValidators
protected java.util.List<UploadTextComponentValidator> getUploadTextValidators()
Returns the list ofUploadTextComponentValidatordefined by this panel.- Returns:
- the list of
UploadTextComponentValidatordefined 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(java.util.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(javax.swing.JTextField text)
Updates the combobox histories when a combobox editor loses focus.- Parameters:
text- TheJTextFieldof the combobox editor.
-
updateModel
private void updateModel(javax.swing.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- TheJTextFieldof 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(java.awt.event.ActionEvent e)
Update the model when the selection changes in a combobox.- Specified by:
actionPerformedin interfacejava.awt.event.ActionListener- Parameters:
e- The action event.
-
focusGained
public void focusGained(java.awt.event.FocusEvent e)
- Specified by:
focusGainedin interfacejava.awt.event.FocusListener
-
focusLost
public void focusLost(java.awt.event.FocusEvent e)
Update the model and combobox history when a combobox editor loses focus.- Specified by:
focusLostin interfacejava.awt.event.FocusListener
-
itemStateChanged
public void itemStateChanged(java.awt.event.ItemEvent e)
Updates the table editor model upon changes in the "review" checkbox.- Specified by:
itemStateChangedin interfacejava.awt.event.ItemListener
-
tableChanged
public void tableChanged(javax.swing.event.TableModelEvent e)
Updates the controls upon changes in the table editor model.- Specified by:
tableChangedin interfacejavax.swing.event.TableModelListener
-
keyTyped
public void keyTyped(java.awt.event.KeyEvent e)
Set the focus directly to the upload button if "Enter" key is pressed in any combobox.- Specified by:
keyTypedin interfacejava.awt.event.KeyListener
-
keyPressed
public void keyPressed(java.awt.event.KeyEvent e)
- Specified by:
keyPressedin interfacejava.awt.event.KeyListener
-
keyReleased
public void keyReleased(java.awt.event.KeyEvent e)
- Specified by:
keyReleasedin interfacejava.awt.event.KeyListener
-
setFocusToUploadButton
private void setFocusToUploadButton()
-
-