Class AbstractMultiInputDialog

java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
javax.swing.JDialog
com.vividsolutions.jump.workbench.ui.AbstractMultiInputDialog
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants
Direct Known Subclasses:
MultiInputDialog

public abstract class AbstractMultiInputDialog extends JDialog
Flexible generic dialog to prompt the user typing input parameters. This abstract class includes the logic from original JUMP MultiInputDialog but does not layout components, which is done by implementing classes.
Author:
Michaël Michaud
See Also:
  • Field Details

    • NO_LABEL

      public static final int NO_LABEL
      The label of the control is not displayed.
      See Also:
    • LEFT_LABEL

      public static final int LEFT_LABEL
      The label is displayed on the left of the control.
      See Also:
    • RIGHT_LABEL

      public static final int RIGHT_LABEL
      The label is displayed on the right of the control.
      See Also:
    • HORIZONTAL

      public static final int HORIZONTAL
      Flag indicating that the main component will fill the space.
      See Also:
    • VERTICAL

      public static final int VERTICAL
      Flag indicating that the main component will fill the space vertically.
      See Also:
    • BOTH

      public static final int BOTH
      Flag indicating that the main component will fill the space.
      See Also:
    • NONE

      public static final int NONE
      Flag indicating that the main component will always use its preferred size.
      See Also:
    • NO_VALID_ATTRIBUTE

      public static final String NO_VALID_ATTRIBUTE
      Attribute combobox message displayed if no valid attribute is available.
  • Constructor Details

    • AbstractMultiInputDialog

      protected AbstractMultiInputDialog(Frame frame, String title, boolean modal)
      Parameters:
      frame - the frame on which to make this dialog modal and centred
      title - the title of the dialog box
      modal - set if the dialog box is modal or not
  • Method Details

    • createDoubleCheck

      public EnableCheck createDoubleCheck(String fieldName)
      Check if the control contains a valid Double.
    • createIntegerCheck

      public EnableCheck createIntegerCheck(String fieldName)
      Check if the control contains a valid Integer.
    • createPositiveCheck

      public EnableCheck createPositiveCheck(String fieldName)
      Check if the control contains a positive Number.
    • createNonNegativeCheck

      public EnableCheck createNonNegativeCheck(String fieldName)
      Check if the control contains a non-negative Number.
    • addComponent

      protected void addComponent(String fieldName, Component label, Component component)
    • getComponent

      protected Component getComponent(String fieldName)
    • getLabel

      public JLabel getLabel(String fieldName)
      Gets JLabel matching this fieldName.
    • getComboBox

      public <T> JComboBox<T> getComboBox(String fieldName)
      Gets JComboBox component matching this fieldName.
    • getCheckBox

      public JCheckBox getCheckBox(String fieldName)
      Gets JCheckBox component matching this fieldName.
    • getRadioButton

      public JRadioButton getRadioButton(String fieldName)
      Gets JRadioButton component matching this fieldName.
    • getFileChooser

      public JFileChooser getFileChooser(String fieldName)
      Gets JFileChooser component matching this fieldName.
    • getValue

      public Object getValue(Component component)
      Fetch the current value held by a component given. Semi intelligent it returns - String text for text components and scrollpanes - selected Objects for combo boxes - Boolean states for buttons and checkboxes - List of files for file choosers
      Parameters:
      component - the Component to get the value from
      Returns:
      an Object containing the value wrapped in the Component
    • getValue

      public Object getValue(String fieldName)
      Convenience method for getValue(Component)
      Parameters:
      fieldName - the field name
      Returns:
      an Object containing the value for this field name
    • getText

      public String getText(String fieldName)
      Gets the string value of a control
      Parameters:
      fieldName - control to read
      Returns:
      the string value of the control
    • getBoolean

      public boolean getBoolean(String fieldName)
      Returns selected state for checkboxes, radio buttons.
    • getDouble

      public double getDouble(String fieldName)
      Returns double value from a JTextField control.
    • getInteger

      public int getInteger(String fieldName)
      Returns integer value from a JTextField control.
    • getLayer

      public Layer getLayer(String fieldName)
      Returns a Layer from a control.
    • getRasterLayer

      public RasterImageLayer getRasterLayer(String fieldName)
      Returns a RasterImageLayer from a control.
    • getLayerable

      public Layerable getLayerable(String fieldName)
      Returns a Layerable from a control.
    • getFiles

      public List<File> getFiles(String fieldName)
      Returns a File Collection from a JFilechooser control.
    • addEnableChecks

      public void addEnableChecks(String fieldName, Collection<EnableCheck> enableChecks)
      Adding enableChecks to the fieldNameToEnableCheckListMap CollectionMap.
      Parameters:
      fieldName - fieldName of the control
      enableChecks - EnableCheck array to validate this control input
    • addEnableChecks

      public void addEnableChecks(String fieldName, EnableCheck... enableChecks)
    • addTextField

      public JTextField addTextField(String fieldName, String initialValue, int approxWidthInChars, EnableCheck[] enableChecks, String toolTipText)
      Adds a JTextField control to this dialog.
      Parameters:
      fieldName - field name of the control
      initialValue - initial value of the control
      approxWidthInChars - approximative width of the control in characters
      enableChecks - checks to validate the input value
      toolTipText - tool tip to help the user
      Returns:
      the JTextField control added to this dialog
    • addComboBox

      public <T> JComboBox<T> addComboBox(String fieldName, T selectedItem, Collection<T> items, String toolTipText)
      Adds a JComboBox control to this dialog.
      Parameters:
      fieldName - field name of the control
      selectedItem - initial selected item
      items - items displayed in the JComboBox
      toolTipText - tool tip to help the user
      Returns:
      the JComboBox control added to this dialog
    • addLabel

      public JLabel addLabel(String text)
      Adds a JLabel to this dialog. The label can contain html (e.g. "Bold label for a subtitle")
      Parameters:
      text - text to display in the JLabel
      Returns:
      the JLabel added to this dialog
    • addSubTitle

      public JLabel addSubTitle(String text)
      Adds a JLabel to display a subtitle in the dialog.
      Parameters:
      text - text to display in the JLabel
      Returns:
      the JLabel added to this dialog
    • addButton

      public JButton addButton(String fieldName, String text, String toolTipText)
      Adds a JButton to this dialog. Action associated to this JButton must be defined.
      Parameters:
      fieldName - will be used for the label text on the left of the button
      text - text to display in the JButton
      toolTipText - tooltip text associated to the JButton
      Returns:
      the JButton added to this dialog
    • addButton

      public JButton addButton(String text)
      Adds a JButton to this dialog. Action associated to this JButton must be defined.
      Parameters:
      text - text to display in the JButton
      Returns:
      the JButton added to this dialog
    • addSeparator

      public void addSeparator()
      Adds a horizontal separator between two set of controls.
    • addIntegerField

      public JTextField addIntegerField(String fieldName, int initialValue, int approxWidthInChars, String toolTipText)
      Adds a JTextField control for integer inputs.
      Parameters:
      fieldName - field name of the control
      initialValue - initial value of the control
      approxWidthInChars - approximative width of the control in characters
      toolTipText - tool tip to help the user
      Returns:
      the JTextField control added to this dialog
    • addPositiveIntegerField

      public JTextField addPositiveIntegerField(String fieldName, int initialValue, int approxWidthInChars, String toolTipText)
      Adds a JTextField control for positive integer inputs.
      Parameters:
      fieldName - field name of the control
      initialValue - initial value of the control
      approxWidthInChars - approximative width of the control in characters
      toolTipText - tool tip to help the user
      Returns:
      the JTextField control added to this dialog
    • addPositiveIntegerField

      public JTextField addPositiveIntegerField(String fieldName, int initialValue, int approxWidthInChars)
      Adds a JTextField control for positive integer inputs.
      Parameters:
      fieldName - field name of the control
      initialValue - initial value of the control
      approxWidthInChars - approximative width of the control in characters
      Returns:
      the JTextField control added to this dialog
    • addDoubleField

      public JTextField addDoubleField(String fieldName, double initialValue, int decimals, int approxWidthInChars, String toolTipText)
      Adds a JTextField field for double values. Allows limiting the number of decimals, defaulting to 0. Always shows the number as decimal and _never_ uses the scientific notation like "1.234E15"
      Parameters:
      fieldName - field name of the control
      initialValue - initial value of the control
      decimals - number of decimals to round to
      approxWidthInChars - approximative width of the control in characters
      Returns:
      the JTextField control added to this dialog
    • addDoubleField

      public JTextField addDoubleField(String fieldName, double initialValue, int approxWidthInChars)
      Adds a JTextField control for double values.
      Parameters:
      fieldName - field name of the control
      initialValue - initial value of the control
      approxWidthInChars - approximative width of the control in characters
      Returns:
      the JTextField control added to this dialog
    • addDoubleField

      public JTextField addDoubleField(String fieldName, double initialValue, int approxWidthInChars, String toolTipText)
      Adds a JTextField control for double value inputs.
      Parameters:
      fieldName - field name of the control
      initialValue - initial value of the control
      approxWidthInChars - approximative width of the control in characters
      toolTipText - tool tip to help the user
      Returns:
      the JTextField control added to this dialog
    • addPositiveDoubleField

      public JTextField addPositiveDoubleField(String fieldName, double initialValue, int approxWidthInChars, String toolTipText)
      Adds a JTextField control for positive double value inputs.
      Parameters:
      fieldName - field name of the control
      initialValue - initial value of the control
      approxWidthInChars - approximative width of the control in characters
      Returns:
      the JTextField control added to this dialog
    • addPositiveDoubleField

      public JTextField addPositiveDoubleField(String fieldName, double initialValue, int approxWidthInChars)
      Adds a JTextField control for positive double value inputs.
      Parameters:
      fieldName - field name of the control
      initialValue - initial value of the control
      approxWidthInChars - approximative width of the control in characters
      Returns:
      the JTextField control added to this dialog
    • addNonNegativeDoubleField

      public JTextField addNonNegativeDoubleField(String fieldName, double initialValue, int approxWidthInChars, String toolTipText)
      Adds a JTextField control for positive double value inputs.
      Parameters:
      fieldName - field name of the control
      initialValue - initial value of the control
      approxWidthInChars - approximative width of the control in characters
      toolTipText - tool tip text associated with this text field
      Returns:
      the JTextField control added to this dialog
    • addNonNegativeDoubleField

      public JTextField addNonNegativeDoubleField(String fieldName, double initialValue, int approxWidthInChars)
      Adds a JTextField control for positive double value inputs.
      Parameters:
      fieldName - field name of the control
      initialValue - initial value of the control
      approxWidthInChars - approximative width of the control in characters
      Returns:
      the JTextField control added to this dialog
    • addLayerComboBox

      public JComboBox<Layer> addLayerComboBox(String fieldName, Layer initialValue, String toolTipText, Collection<Layer> layers)
      Add a JComboBox containing any collection of Layers.
      Parameters:
      fieldName - field name of the control
      initialValue - default layer visible in the combo box
      toolTipText - tool tip text associated with this combo box
      layers - layers to be proposed in the combo box
      Returns:
      the JComboBox
    • addLayerComboBox

      public JComboBox<Layer> addLayerComboBox(String fieldName, Layer initialValue, LayerManager layerManager)
      Add a JComboBox containing available layers from the current LayerManager.
      Parameters:
      fieldName - field name of the control
      initialValue - default layer visible in the combo box
      layerManager - the LayerManager providing layers to the combo box
      Returns:
      the JComboBox
    • addLayerComboBox

      public JComboBox<Layer> addLayerComboBox(String fieldName, Layer initialValue, String toolTipText, LayerManager layerManager)
      Add a JComboBox containing available layers from the current LayerManager.
      Parameters:
      fieldName - field name of the control
      initialValue - default layer visible in the combo box
      toolTipText - tool tip text associated with this combo box
      layerManager - the LayerManager providing layers to the combo box
      Returns:
      the JComboBox
    • addEditableLayerComboBox

      public JComboBox<Layer> addEditableLayerComboBox(String fieldName, Layer initialValue, String toolTipText, LayerManager layerManager)
      Add a JComboBox containing editable layers of a LayerManager.
      Parameters:
      fieldName - field name of the control
      initialValue - default layer visible in the combo box
      toolTipText - tool tip text associated with this combo box
      layerManager - the LayerManager providing layers to the combo box
      Returns:
      the JComboBox
    • addLayerComboBox

      public JComboBox<Layer> addLayerComboBox(String fieldName, String toolTipText, LayerManager layerManager, AttributeTypeFilter filter)
      Add a JComboBox containing layers containing the specified AttributeType.
      Parameters:
      fieldName - field name of the control
      toolTipText - tool tip text associated with this combo box
      layerManager - the LayerManager providing layers to the combo box
      filter - a filter to select layers with specified AttributeTypes
      Returns:
      the JComboBox
    • addRasterLayerComboBox

      public JComboBox<RasterImageLayer> addRasterLayerComboBox(String fieldName, RasterImageLayer initialValue, String toolTipText, LayerManager layerManager)
      Add a JComboBox containing RasterImageLayers.
      Parameters:
      fieldName - field name of the control
      toolTipText - tool tip text associated with this combo box
      layerManager - the LayerManager providing RasterImageLayers to the combo box
      Returns:
      the JComboBox
    • addLayerableComboBox

      public <T extends Layerable> JComboBox<T> addLayerableComboBox(String fieldName, T initialValue, String toolTipText, LayerManager layerManager, Class<T> clazz)
      Add a JComboBox containing layerables of type clazz.
      Parameters:
      fieldName - field name of the control
      toolTipText - tool tip text associated with this combo box
      layerManager - the LayerManager providing layers to the combo box
      clazz - class of the layerables
      Returns:
      the JComboBox
    • addAttributeComboBox

      public JComboBox<String> addAttributeComboBox(String fieldName, String layerFieldName, AttributeTypeFilter filter, String toolTipText)
      Add a JComboBox containing attributes of the Layer selected in layerFieldName
      Parameters:
      fieldName - field name for the attribute
      layerFieldName - field name of the ComboBox used to choose the layer
      filter - filter valid attributes from their type
      toolTipText - a toolTip for this JComboBox
      Returns:
      the JComboBox
    • addCheckBox

      public JCheckBox addCheckBox(String fieldName, boolean initialValue)
      Create a CheckBox to get a boolean value from the user.
      Parameters:
      fieldName - field name of the control
      initialValue - default boolean value
      Returns:
      the JCheckBox
    • addCheckBox

      public JCheckBox addCheckBox(String fieldName, boolean initialValue, String toolTipText)
      Create a CheckBox to get a boolean value from the user.
      Parameters:
      fieldName - field name of the control
      initialValue - default boolean value
      toolTipText - tool tip text associated with this check box
      Returns:
      the JCheckBox
    • addRadioButton

      public JRadioButton addRadioButton(String fieldName, String buttonGroupName, boolean initialValue, String toolTipText)
      Adds a RadioButton to the buttonGroupName group.
      Parameters:
      fieldName - field name of the control
      buttonGroupName - buttonGroupName of this RadioButton
      initialValue - default boolean value
      toolTipText - tool tip text associated with this check box
      Returns:
      the JRadioButton
    • addTextAreaField

      public JTextArea addTextAreaField(String fieldName, String initialValue, int rowNumber, int columnNumber, boolean scrollable, EnableCheck[] enableChecks, String toolTipText)
      Adds a TextArea field.
      Parameters:
      fieldName - field name of the control
      initialValue - default boolean value
      rowNumber - initial row number
      columnNumber - initial column number
      scrollable - if true, the textArea is embeded into a JScrollPane
      enableChecks - checks to validate the input value
      toolTipText - tool tip text associated with this check box
      Returns:
      the JTextArea
    • addRow

      protected abstract void addRow(String fieldName, JComponent label, JComponent component, EnableCheck[] enableChecks, String toolTipText, int labelPos, int fillMode)
      Adds a row (containing either a control or a label) to the Dialog.
      Parameters:
      fieldName - field name of the control (used as a key)
      label - label of the control
      component - the control itself (may also be a label or a separator)
      enableChecks - checks to validate inputs
      toolTipText - ToolTip text
      labelPos - 0, 1 or 2 depending on whether the label is hidden, on the left side or on the right side of the component
      fillMode - true if the component must fill the available space
    • addRow

      protected abstract void addRow(JComponent c)
    • addRow

      protected abstract void addRow()
    • setFieldEnabled

      public void setFieldEnabled(String fieldName, boolean enable)
    • setFieldVisible

      public void setFieldVisible(String fieldName, boolean visible)
    • reportValidationError

      protected void reportValidationError(String errorMessage)
    • isInputValid

      protected boolean isInputValid()
    • firstValidationErrorMessage

      protected String firstValidationErrorMessage()
    • addLayerableComboBox

      public <T> JComboBox<T> addLayerableComboBox(String fieldName, T initialValue, String toolTipText, Collection<T> layerable)
      generic method to load collection of layerable into JComboBox with renderer of layerable (layer icon)
      Parameters:
      fieldName - field name of the control
      initialValue - default layer visible in the combo box
      toolTipText - tool tip text associated with this combo box
      layerable - layers to be proposed in the combo box
      Returns:
      the JComboBox