Package com.google.gwt.user.client.ui

Examples of com.google.gwt.user.client.ui.ListBox$Impl


    public void testWidget() {
        UnitBoxItem<String> ubi = new UnitBoxItem<String>("amount", "Amount", String.class);
        ubi.setUnitPropertyName("units");
        ComplexPanel widget = (ComplexPanel) ubi.asWidget();
        TextBox foundTextBox = null;
        ListBox foundListBox = null;
        for (int i=0; i < widget.getWidgetCount(); i++) {
            Widget child = widget.getWidget(i);
            if (child instanceof TextBox)
                foundTextBox = (TextBox) child;
View Full Code Here


        ListBoxItem lbi = new ListBoxItem("listbox", "List Box");
        assertEquals("listbox", lbi.getName());
        assertEquals("List Box", lbi.getTitle());

        HorizontalPanel panel = (HorizontalPanel) lbi.asWidget();
        ListBox listBox = findListBox(panel);
        assertEquals(0, listBox.getItemCount());

        lbi.setChoices(Arrays.asList("b", "a"), null);
        assertEquals(2, listBox.getItemCount());
        assertEquals("a", listBox.getItemText(0));
        assertEquals("b", listBox.getItemText(1));

        assertNull(lbi.getValue());
        try {
            lbi.setValue("c");
            fail("Should have thrown an exception as 'c' is not one of the listbox values");
        } catch (IllegalStateException ise) {
            // good
        }
        assertNull(lbi.getValue());

        lbi.setValue("b");
        assertEquals("b", lbi.getValue());

        listBox.setSelectedIndex(0);
        assertEquals("a", lbi.getValue());

        lbi.setChoices(Collections.singleton("d"), "d");
        assertEquals(1, listBox.getItemCount());
        assertEquals("d", listBox.getItemText(0));
        assertEquals("d", lbi.getValue());
    }
View Full Code Here

    @Test
    public void testListBoxItemEnablement() {
        ListBoxItem lbi = new ListBoxItem("listbox", "List Box");
        HorizontalPanel panel = (HorizontalPanel) lbi.asWidget();
        ListBox listBox = findListBox(panel);
        assertTrue(listBox.isEnabled());

        lbi.setEnabled(false);
        assertFalse(listBox.isEnabled());

        lbi.setEnabled(true);
        assertTrue(listBox.isEnabled());
    }
View Full Code Here

        if ( this.readOnly ) {
            return new SmallLabel( this.constraint.getValue() );
        }

        final ListBox box = new ListBox();
        box.addItem( Constants.INSTANCE.Choose() );

        List<String> bindingsInScope = this.model.getBoundVariablesInScope( this.constraint );
        List<String> applicableBindingsInScope = getApplicableBindingsInScope( bindingsInScope );
        for ( String var : applicableBindingsInScope ) {
            box.addItem( var );
            if ( this.constraint.getValue() != null && this.constraint.getValue().equals( var ) ) {
                box.setSelectedIndex( box.getItemCount() - 1 );
            }
        }

        box.addChangeHandler( new ChangeHandler() {

            public void onChange( ChangeEvent event ) {
                executeOnValueChangeCommand();
                int selectedIndex = box.getSelectedIndex();
                if ( selectedIndex > 0 ) {
                    constraint.setValue( box.getItemText( selectedIndex ) );
                } else {
                    constraint.setValue( null );
                }
            }
        } );
View Full Code Here

        return layoutPanel;
    }

    private ListBox makeChoicesListBox() {
        choices = new ListBox( true );
        choices.setPixelSize( getChoicesWidth(),
                              getChoicesHeight() );

        choices.addKeyUpHandler( new KeyUpHandler() {
            public void onKeyUp( com.google.gwt.event.dom.client.KeyUpEvent event ) {
View Full Code Here

    /**
     * Return a listbox of choices for rule attributes.
     * @return
     */
    public static ListBox getAttributeList() {
        ListBox list = new ListBox();
        list.addItem( Constants.INSTANCE.Choose() );

        list.addItem( SALIENCE_ATTR );
        list.addItem( ENABLED_ATTR );
        list.addItem( DATE_EFFECTIVE_ATTR );
        list.addItem( DATE_EXPIRES_ATTR );
        list.addItem( NO_LOOP_ATTR );
        list.addItem( AGENDA_GROUP_ATTR );
        list.addItem( ACTIVATION_GROUP_ATTR );
        list.addItem( DURATION_ATTR );
        list.addItem( TIMER_ATTR );
        list.addItem( CALENDARS_ATTR );
        list.addItem( DURATION_ATTR );
        list.addItem( AUTO_FOCUS_ATTR );
        list.addItem( LOCK_ON_ACTIVE_ATTR );
        list.addItem( RULEFLOW_GROUP_ATTR );
        list.addItem( DIALECT_ATTR );

        return list;
    }
View Full Code Here

    /**
     * Pops up the fact selector.
     */
    protected void showFactTypeSelector( final Widget w ) {
        final ListBox box = new ListBox();
        PackageDataModelOracle completions = this.getModeller().getSuggestionCompletions();
        String[] facts = completions.getFactTypes();

        box.addItem( Constants.INSTANCE.Choose() );
        for ( int i = 0; i < facts.length; i++ ) {
            box.addItem( facts[ i ] );
        }
        box.setSelectedIndex( 0 );

        final FormStylePopup popup = new FormStylePopup();
        popup.setTitle( Constants.INSTANCE.NewFactPattern() );
        popup.addAttribute( Constants.INSTANCE.chooseFactType(),
                            box );
        box.addChangeHandler( new ChangeHandler() {

            public void onChange( ChangeEvent event ) {
                pattern.addFactPattern( new FactPattern( box.getItemText( box.getSelectedIndex() ) ) );
                setModified( true );
                getModeller().refreshWidget();
                popup.hide();
            }
        } );
View Full Code Here

    //Actual drop-down
    private Widget getDropDown() {

        String selected = "";
        String selectedText = "";
        box = new ListBox();

        box.addItem( Constants.INSTANCE.pleaseChoose(),
                     "" );
        for ( int i = 0; i < operators.length; i++ ) {
            String op = operators[ i ];
View Full Code Here

        }
        return "";
    }

    private Widget createStartPointWidget() {
        ListBox startPoint = new ListBox();
        panel.add( startPoint );

        startPoint.addItem( Constants.INSTANCE.ChooseDotDotDot(),
                            "" );

        // TODO {baunax} uncomment when global collections is implemented.
        // for (String gc : getCompletionEngine().getGlobalCollections()) {
        // startPoint.addItem(gc, GLOBAL_COLLECTION_VALUE_PREFIX + "." + gc);
        // }

        for ( String gv : getCompletionEngine().getGlobalVariables() ) {
            startPoint.addItem( gv,
                                GLOBAL_VARIABLE_VALUE_PREFIX + "." + gv );
        }

        for ( String v : getRuleModel().getAllLHSVariables() ) {
            startPoint.addItem( v,
                                VARIABLE_VALUE_PREFIX + "." + v );
        }

        startPoint.setVisibleItemCount( 1 );
        startPoint.addChangeHandler( new ChangeHandler() {

            public void onChange( ChangeEvent event ) {
                ListBox lb = (ListBox) event.getSource();
                int index = lb.getSelectedIndex();
                if ( index > 0 ) {
                    ExpressionBuilder.this.makeDirty();
                    startPointChange( lb.getValue( index ) );
                }
            }
        } );
        return startPoint;
    }
View Full Code Here

            return createStartPointWidget();
        }

        ChangeHandler ch = new ChangeHandler() {
            public void onChange( ChangeEvent event ) {
                ListBox box = (ListBox) event.getSource();
                panel.remove( box );
                if ( box.getSelectedIndex() > 0 ) {
                    onChangeSelection( box.getValue( box.getSelectedIndex() ) );
                }
            }
        };

        ListBox lb = new ListBox();
        lb.setVisibleItemCount( 1 );
        lb.addItem( Constants.INSTANCE.ChooseDotDotDot(),
                    "" );
        lb.addItem( "<==" + Constants.INSTANCE.DeleteItem(),
                    DELETE_VALUE );
        for ( Map.Entry<String, String> entry : getCompletionsForCurrentType( expression.getParts().size() > 1 ).entrySet() ) {
            lb.addItem( entry.getKey(),
                        entry.getValue() );
        }
        lb.addChangeHandler( ch );
        return lb;
    }
View Full Code Here

TOP

Related Classes of com.google.gwt.user.client.ui.ListBox$Impl

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.