Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.ListButton$ListButtonBindingListenerList


    @Override
    public void install(Component component) {
        super.install(component);

        ListButton listButton = (ListButton)component;
        listButton.getListButtonListeners().add(this);
        listButton.getListButtonSelectionListeners().add(this);

        listView.setListData(listButton.getListData());
        listView.setItemRenderer(listButton.getItemRenderer());
    }
View Full Code Here


        boolean consumed = super.mouseDown(component, button, x, y);

        pressed = true;
        repaintComponent();

        ListButton listButton = (ListButton)component;

        if (listViewPopup.isOpen()) {
            listViewPopup.close();
        } else if (listButton.isRepeatable() && !getTriggerBounds().contains(x, y)) {
            listButton.requestFocus();
        } else {
            listViewPopup.open(component.getWindow());
        }

        return consumed;
View Full Code Here

    @Override
    public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
        boolean consumed = super.mouseClick(component, button, x, y, count);

        ListButton listButton = (ListButton)getComponent();
        if (listButton.isRepeatable() && !getTriggerBounds().contains(x, y)) {
            listButton.press();
        }

        return consumed;
    }
View Full Code Here

     */
    @Override
    public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
        boolean consumed = false;

        ListButton listButton = (ListButton)getComponent();

        if (keyCode == Keyboard.KeyCode.SPACE) {
            pressed = true;
            repaintComponent();

            if (listViewPopup.isOpen()) {
                listViewPopup.close();
            } else if (!listButton.isRepeatable()){
                listViewPopup.open(component.getWindow());
            }
        } else if (keyCode == Keyboard.KeyCode.UP) {
            int index = listButton.getSelectedIndex();

            do {
                index--;
            } while (index >= 0
                && listButton.isItemDisabled(index));

            if (index >= 0) {
                listButton.setSelectedIndex(index);
                consumed = true;
            }
        } else if (keyCode == Keyboard.KeyCode.DOWN) {
            if (Keyboard.isPressed(Keyboard.Modifier.ALT)) {
                listViewPopup.open(component.getWindow());

                consumed = true;
            } else {
                int index = listButton.getSelectedIndex();
                int count = listButton.getListData().getLength();

                do {
                    index++;
                } while (index < count
                    && listView.isItemDisabled(index));

                if (index < count) {
                    listButton.setSelectedIndex(index);
                    consumed = true;
                }
            }
        } else {
            consumed = super.keyPressed(component, keyCode, keyLocation);
View Full Code Here

     */
    @Override
    public boolean keyReleased(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
        boolean consumed = false;

        ListButton listButton = (ListButton)getComponent();

        if (keyCode == Keyboard.KeyCode.SPACE) {
            pressed = false;
            repaintComponent();

            if (listButton.isRepeatable()) {
                listButton.press();
            }
        } else {
            consumed = super.keyReleased(component, keyCode, keyLocation);
        }

View Full Code Here

     */
    @Override
    public boolean keyTyped(Component component, char character) {
        boolean consumed = super.keyTyped(component, character);

        ListButton listButton = (ListButton)getComponent();

        List<?> listData = listButton.getListData();
        ListView.ItemRenderer itemRenderer = listButton.getItemRenderer();

        character = Character.toUpperCase(character);

        for (int i = listButton.getSelectedIndex() + 1, n = listData.getLength(); i < n; i++) {
            if (!listButton.isItemDisabled(i)) {
                String string = itemRenderer.toString(listData.get(i));

                if (string != null
                    && string.length() > 0) {
                    char first = Character.toUpperCase(string.charAt(0));

                    if (first == character) {
                        listButton.setSelectedIndex(i);
                        consumed = true;
                        break;
                    }
                }
            }
View Full Code Here

        Enum<?>[] enumConstants = type.getEnumConstants();
        for (int i = 0; i < enumConstants.length; i++) {
            listData.add(enumConstants[i]);
        }

        ListButton listButton = new ListButton();
        listButton.setListData(listData);
        listButton.setSelectedItem(value);
        section.add(listButton);
        Form.setLabel(listButton, key);

        listButton.getListButtonSelectionListeners().add(new ListButtonSelectionListener.Adapter() {
            private boolean updating = false;

            @Override
            public void selectedIndexChanged(ListButton listButton, int previousSelectedIndex) {
                if (!updating) {
                    updating = true;
                    try {
                        dictionary.put(key, listButton.getSelectedItem());
                    } catch (Exception exception) {
                        displayErrorMessage(exception, listButton.getWindow());
                        listButton.setSelectedIndex(previousSelectedIndex);
                    } finally {
                        updating = false;
                    }
                }
            }
View Full Code Here

        return listButton;
    }

    private void updateEnumControl(Dictionary<String, Object> dictionary, String key) {
        ListButton listButton = (ListButton)controls.get(key);

        if (listButton != null) {
            Enum<?> value = (Enum<?>)dictionary.get(key);
            listButton.setSelectedItem(value);
        }
    }
View Full Code Here

            e.printStackTrace();
        } catch (SerializationException e) {
            e.printStackTrace();
        }

        final ListButton motif = (ListButton)bxmlSerializer.getNamespace().get("motif");

        ArrayList<String> al = new ArrayList<String>();
        al.add("One");
        al.add("Two");
        motif.setListData(al);

        CalendarButton cbDate = (CalendarButton)bxmlSerializer.getNamespace().get("date");
        dcl = (new DialogCloseListener() {
            public void dialogClosed(Dialog dialog, boolean modal) {
            }
View Full Code Here

        listViewPopup.getDecorators().add(dropShadowDecorator);
    }

    @Override
    public int getPreferredWidth(int height) {
        ListButton listButton = (ListButton)getComponent();
        Button.DataRenderer dataRenderer = listButton.getDataRenderer();

        // Determine the preferred width of the current button data
        dataRenderer.render(listButton.getButtonData(), listButton, false);
        int preferredWidth = dataRenderer.getPreferredWidth(-1);

        // The preferred width of the button is the max. width of the rendered
        // content plus padding and the trigger width
        List<?> listData = listButton.getListData();
        for (Object item : listData) {
            dataRenderer.render(item, listButton, false);
            preferredWidth = Math.max(preferredWidth, dataRenderer.getPreferredWidth(-1));
        }
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.ListButton$ListButtonBindingListenerList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.