Class ValueChooser

  • All Implemented Interfaces:
    org.eclipse.swt.graphics.Drawable
    Direct Known Subclasses:
    ValueComboChooser

    public class ValueChooser
    extends org.eclipse.swt.widgets.Composite
    1C-specific composite widget for displaying/editing the value of the text field in property/scheme editor(s) as well as providing controls for changing the value of the field via actions associated with this field. The widget consists of two major areas:
    • Content area which shows selected value and optional graphical decoration (image)
    • And control area holding a set of content management action buttons (like selection from list, cleaning of the current field value, etc
    TODO vertical text centering - not done at the moment, as original text field don't do this as well
    • Field Summary

      • Fields inherited from class org.eclipse.swt.widgets.Control

        handle
    • Constructor Summary

      Constructors 
      Constructor Description
      ValueChooser​(org.eclipse.swt.widgets.Composite parent, org.eclipse.ui.forms.widgets.FormToolkit toolkit, int maxDecorationWidth, int style)
      Constructs new instance of the widget using parent and style as input arguments.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addActionBarListener​(IActionBarListener listener)
      Adds action bar listener to the embedded action bar.
      IActionBarItem addButton​(String name, org.eclipse.swt.graphics.Image image, String toolTip, int style)
      Adds a button to the contained action bar.
      void addDisposeListener​(org.eclipse.swt.events.DisposeListener listener)
      Adds dispose listener to the control.
      void addFocusListener​(org.eclipse.swt.events.FocusListener listener)
      void addListener​(int eventType, org.eclipse.swt.widgets.Listener listener)
      Adds a listener to the text field in case of keyUp or keyDown event
      void addModifyListener​(org.eclipse.swt.events.ModifyListener listener)
      Adds modification listener to the control.
      IActionBarItem addSpinner​(String name, int style)  
      void addTraverseListener​(org.eclipse.swt.events.TraverseListener listener)
      Adds traverse listener to the control
      void addVerifyListener​(org.eclipse.swt.events.VerifyListener listener)
      Adds verification listener to the control.
      void clearSelection()
      Clears selection from the text in the content area.
      void dispose()  
      IActionBarItem[] getActionBarItems()  
      org.eclipse.swt.graphics.Image getImage()
      Gets decorating image for the content area of the control.
      org.eclipse.swt.graphics.Point getSelection()
      Returns the selection.
      int getSelectionCount()
      Gets the number of selected characters.
      org.eclipse.swt.custom.StyledText getStyledText()
      Get current styled text
      String getText()
      Gets the text entered into the text field.
      boolean isEditable()
      Checks if the control is in editable state.
      void removeActionBarListener​(IActionBarListener listener)
      Removes action bar listener from the embedded action bar.
      void removeModifyListener​(org.eclipse.swt.events.ModifyListener modifyListener)  
      void removeVerifyListener​(org.eclipse.swt.events.VerifyListener listener)
      Removes verification listener from the control.
      void selectAll()
      Selects the whole text within the text control of the widget.
      void setEditable​(boolean editable)
      Sets/resets the read-only mode for the text control.
      void setImage​(org.eclipse.swt.graphics.Image image)
      Sets decorating image for the content area of the control/
      void setMultiLine​(boolean multiLine)
      Sets the multiline mode for the value chooser.
      void setSelection​(int start)
      Sets selection to the text with given offsets.
      void setSelection​(int start, int end)
      Sets selection to the text with given offsets.
      void setText​(String text)
      Sets the text to the text field.
      void setVisibleLineCount​(int count)
      Sets visible line count, activates multiline mode.
      • Methods inherited from class org.eclipse.swt.widgets.Composite

        changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
      • Methods inherited from class org.eclipse.swt.widgets.Scrollable

        computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
      • Methods inherited from class org.eclipse.swt.widgets.Control

        addControlListener, addDragDetectListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
      • Methods inherited from class org.eclipse.swt.widgets.Widget

        checkWidget, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
      • Methods inherited from interface org.eclipse.swt.graphics.Drawable

        isAutoScalable
    • Constructor Detail

      • ValueChooser

        public ValueChooser​(org.eclipse.swt.widgets.Composite parent,
                            org.eclipse.ui.forms.widgets.FormToolkit toolkit,
                            int maxDecorationWidth,
                            int style)
        Constructs new instance of the widget using parent and style as input arguments.
        Parameters:
        parent - Parent container.
        toolkit - Form toolkit reference.
        maxDecorationWidth - Maximum width allowed for the control decoration.
        style - The style flag set.
    • Method Detail

      • getActionBarItems

        public IActionBarItem[] getActionBarItems()
        Returns:
        array of action items of the action bar associated with this value chooser. Never null.
      • addActionBarListener

        public void addActionBarListener​(IActionBarListener listener)
        Adds action bar listener to the embedded action bar.
        Parameters:
        listener - Listener to add.
      • addButton

        public IActionBarItem addButton​(String name,
                                        org.eclipse.swt.graphics.Image image,
                                        String toolTip,
                                        int style)
        Adds a button to the contained action bar.
        Parameters:
        name - Name of the button.
        image - Image being shown on the button.
        toolTip - Button tooltip which is shown when hovering over the button/.
        stele - Style modifer of the buttong being added.
        Returns:
        The action bar button instance for further configuration.
      • addDisposeListener

        public void addDisposeListener​(org.eclipse.swt.events.DisposeListener listener)
        Adds dispose listener to the control.
        Overrides:
        addDisposeListener in class org.eclipse.swt.widgets.Widget
        Parameters:
        listener - The listener to add.
      • addFocusListener

        public void addFocusListener​(org.eclipse.swt.events.FocusListener listener)
        Overrides:
        addFocusListener in class org.eclipse.swt.widgets.Control
      • addListener

        public void addListener​(int eventType,
                                org.eclipse.swt.widgets.Listener listener)
        Adds a listener to the text field in case of keyUp or keyDown event
        Overrides:
        addListener in class org.eclipse.swt.widgets.Widget
        Parameters:
        eventType - Type of the event
        listener - Listener to add
      • addModifyListener

        public void addModifyListener​(org.eclipse.swt.events.ModifyListener listener)
        Adds modification listener to the control.
        Parameters:
        listener - The listener to add.
      • addTraverseListener

        public void addTraverseListener​(org.eclipse.swt.events.TraverseListener listener)
        Adds traverse listener to the control
        Overrides:
        addTraverseListener in class org.eclipse.swt.widgets.Control
        Parameters:
        listner - Ther listener to add.
      • addVerifyListener

        public void addVerifyListener​(org.eclipse.swt.events.VerifyListener listener)
        Adds verification listener to the control.
        Parameters:
        listener - The listener to add.
      • clearSelection

        public void clearSelection()
        Clears selection from the text in the content area.
      • getImage

        public org.eclipse.swt.graphics.Image getImage()
        Gets decorating image for the content area of the control.
        Returns:
        The image (if any) decorating content area.
      • getSelection

        public org.eclipse.swt.graphics.Point getSelection()
        Returns the selection. Text selections are specified in terms of caret positions. In a text widget that contains N characters, there are N+1 caret positions, ranging from 0..N
        Returns:
        start and end of the selection, x is the offset of the first selected character, y is the offset after the last selected character. The selection values returned are visual (i.e., x will always always be <= y). To determine if a selection is right-to-left (RtoL) vs. left-to-right (LtoR), compare the caretOffset to the start and end of the selection (e.g., caretOffset == start of selection implies that the selection is RtoL).
      • getSelectionCount

        public int getSelectionCount()
        Gets the number of selected characters.
        Returns:
        the number of selected characters.
      • getStyledText

        public org.eclipse.swt.custom.StyledText getStyledText()
        Get current styled text
        Returns:
        Styled Text
      • getText

        public String getText()
        Gets the text entered into the text field.
        Returns:
        The text contained in the text field.
      • isEditable

        public boolean isEditable()
        Checks if the control is in editable state.
        Returns:
        True if control is editable; false otherwise.
      • removeActionBarListener

        public void removeActionBarListener​(IActionBarListener listener)
        Removes action bar listener from the embedded action bar.
        Parameters:
        listener - Listener to remove.
      • removeModifyListener

        public void removeModifyListener​(org.eclipse.swt.events.ModifyListener modifyListener)
      • removeVerifyListener

        public void removeVerifyListener​(org.eclipse.swt.events.VerifyListener listener)
        Removes verification listener from the control.
        Parameters:
        listener - The listener to remove.
      • selectAll

        public void selectAll()
        Selects the whole text within the text control of the widget.
      • setEditable

        public void setEditable​(boolean editable)
        Sets/resets the read-only mode for the text control.
        Parameters:
        readOnly - The editable flag.
      • setImage

        public void setImage​(org.eclipse.swt.graphics.Image image)
        Sets decorating image for the content area of the control/
        Parameters:
        image - Image to set.
      • setMultiLine

        public void setMultiLine​(boolean multiLine)
        Sets the multiline mode for the value chooser.
        Parameters:
        multiline - True if the chooser should be a multiline one; false otherwise.
      • setVisibleLineCount

        public void setVisibleLineCount​(int count)
        Sets visible line count, activates multiline mode.
        Parameters:
        count - number of visible lines.
      • setSelection

        public void setSelection​(int start)
        Sets selection to the text with given offsets. Index is zero-based.
      • setSelection

        public void setSelection​(int start,
                                 int end)
        Sets selection to the text with given offsets. Index is zero-based.
        Parameters:
        start - Start index of the selection.
        end - End index of the seletion.
      • setText

        public void setText​(String text)
        Sets the text to the text field.
        Parameters:
        text - The text to set.
      • dispose

        public void dispose()
        Overrides:
        dispose in class org.eclipse.swt.widgets.Widget