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

Examples of com.google.gwt.user.client.ui.ToggleButton


  }
  /** Method to create a Toggle button for the toolbar **/
  private ToggleButton createToggleButton(String url, Integer top, Integer left, Integer width, Integer height, String tip) {
    Image extract = new Image(url, left, top, width, height);
    ToggleButton tb = new ToggleButton(extract);
    tb.setHeight(height+"px");
    tb.setWidth(width+"px");
    tb.addClickHandler(evHandler);
    if (tip != null) {
      tb.setTitle(tip);
    }
    return tb;
  }
View Full Code Here


   private boolean clicked;

   @Test
   public void click() {
      // Arrange
      final ToggleButton toggleButton = new ToggleButton("Up", "Down");

      // needs to be attached
      RootPanel.get().add(toggleButton);

      clicked = false;

      toggleButton.addClickHandler(new ClickHandler() {
         public void onClick(ClickEvent event) {
            clicked = true;
         }
      });

      // Pre-Assert
      assertFalse("ToggleButton should not be toggled by default", toggleButton.isDown());
      assertEquals("Up", toggleButton.getText());

      // Act
      Browser.click(toggleButton);

      // Assert
      assertTrue("ToggleButton onClick was not triggered", clicked);
      assertTrue("ToggleButton should be toggled after being clicked once", toggleButton.isDown());
      assertEquals("Down", toggleButton.getText());

      // Act 2
      Browser.click(toggleButton);
      assertFalse("ToggleButton should not be toggled after being clicked twice",
               toggleButton.isDown());
      assertEquals("Up", toggleButton.getText());
   }
View Full Code Here

  /**
   * @param message
   */
  private void initToggleButtonGroup() {
    toggleButtonGroup = new ToggleButtonGroup();
    characterButton = new ToggleButton(message.getCharactersheet());
    characterButton.setTitle(CHARACTER_SHEET);
    storyBoardButton = new ToggleButton(message.getStoryBoard());
    storyBoardButton.setTitle(STORYBOARD);
    toggleButtonGroup.addButton(storyBoardButton);
    toggleButtonGroup.addButton(characterButton);
  }
View Full Code Here

      @Override
      public void onClick(ClickEvent event) {
        ToggleButtonGroup toggleButtonGroup = (ToggleButtonGroup) event
            .getSource();
        ToggleButton selectedButton = toggleButtonGroup
            .getSelectedButton();
        selectedContent = selectedButton.getTitle();
        refreshContent();
      }
    });
  }
View Full Code Here

    button.addClickHandler(new ClickHandler() {

      @Override
      public void onClick(ClickEvent event) {
        ToggleButton source = (ToggleButton) event.getSource();
        setSelectedButton(source);

      }
    });
    this.add(button);
View Full Code Here

      @Override
      public void onClick(ClickEvent event) {
        ToggleButtonGroup toggleButtonGroup = (ToggleButtonGroup) event
            .getSource();
        ToggleButton selectedButton = toggleButtonGroup
            .getSelectedButton();
        setSelectedContent(selectedButton.getTitle());
        view.setSelectedContent(selectedContent);
        refreshContent();

      }
    });
View Full Code Here

  /**
   * @param message
   */
  private void initToggleButtonGroup() {
    toggleButtonGroup = new ToggleButtonGroup();
    notificationButton = new ToggleButton(message.getNotificationButton());
    notificationButton.setTitle(NOTIFICATION);
    campaignConfigButton = new ToggleButton(
        message.getCampaignConfigButton());
    campaignConfigButton.setTitle(CAMPAIGN_CONFIG);
    storyBoardButton = new ToggleButton(message.getStoryBoardButton());
    storyBoardButton.setTitle(STORY_BOARD);
    charactersListButton = new ToggleButton(
        message.getCharactersListButton());
    charactersListButton.setTitle(CHARACTERS_LIST);
    toggleButtonGroup.addButton(campaignConfigButton);
    toggleButtonGroup.addButton(storyBoardButton);
    toggleButtonGroup.addButton(charactersListButton);
View Full Code Here

            cellTable.addColumn(columnMeta.getColumn(), columnMeta.getHeader());
        }
    }

    public ToggleButton createToggleButton() {
        final ToggleButton button = new ToggleButton(COLUMN_PICKER_IMAGE);
        final PopupPanel popup = new PopupPanel(true);
        popup.addCloseHandler(new CloseHandler<PopupPanel>() {
            public void onClose(CloseEvent<PopupPanel> popupPanelCloseEvent) {
                button.setDown(false);
            }
        });
        VerticalPanel popupContent = new VerticalPanel();
        for (final ColumnMeta<T> columnMeta : columnMetaList) {
            final CheckBox checkBox = new CheckBox(columnMeta.getHeader().getValue());
            checkBox.setValue(columnMeta.isVisible());
            checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
                public void onValueChange(ValueChangeEvent<Boolean> booleanValueChangeEvent) {
                    boolean visible = booleanValueChangeEvent.getValue();
                    if (visible) {
                        // WORKAROUND because CellTable does not support insertColumn at this time
                        for (ColumnMeta<T> resettingColumnMeta : columnMetaList) {
                            if (resettingColumnMeta.isVisible()) {
                                cellTable.removeColumn(resettingColumnMeta.getColumn());
                            }
                        }
                        columnMeta.setVisible(visible);
                        for (ColumnMeta<T> resettingColumnMeta : columnMetaList) {
                            if (resettingColumnMeta.isVisible()) {
                                cellTable.addColumn(resettingColumnMeta.getColumn(), resettingColumnMeta.getHeader());
                            }
                        }
                    } else {
                        columnMeta.setVisible(visible);
                        cellTable.removeColumn(columnMeta.getColumn());
                    }
                }
            });
            popupContent.add(checkBox);
        }
        popup.add(popupContent);
        button.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                if (button.isDown()) {
                    popup.setPopupPosition(button.getAbsoluteLeft(), button.getAbsoluteTop() + button.getOffsetHeight());
                    popup.show();
                }
                // Note: no need to hide the popup when clicked when down,
                // because clicking anywhere outside the popup will hide the popup
            }
View Full Code Here

            cellTable.addColumn(columnMeta.getColumn(), columnMeta.getHeader());
        }
    }

    public ToggleButton createToggleButton() {
        final ToggleButton button = new ToggleButton(COLUMN_PICKER_IMAGE);
        final PopupPanel popup = new PopupPanel(true);
        popup.addCloseHandler(new CloseHandler<PopupPanel>() {
            public void onClose(CloseEvent<PopupPanel> popupPanelCloseEvent) {
                button.setDown(false);
            }
        });
        VerticalPanel popupContent = new VerticalPanel();
        for (final ColumnMeta<T> columnMeta : columnMetaList) {
            final CheckBox checkBox = new CheckBox(columnMeta.getHeader().getValue());
            checkBox.setValue(columnMeta.isVisible());
            checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
                public void onValueChange(ValueChangeEvent<Boolean> booleanValueChangeEvent) {
                    boolean visible = booleanValueChangeEvent.getValue();
                    if (visible) {
                        // WORKAROUND because CellTable does not support insertColumn at this time
                        for (ColumnMeta<T> resettingColumnMeta : columnMetaList) {
                            if (resettingColumnMeta.isVisible()) {
                                cellTable.removeColumn(resettingColumnMeta.getColumn());
                            }
                        }
                        columnMeta.setVisible(visible);
                        for (ColumnMeta<T> resettingColumnMeta : columnMetaList) {
                            if (resettingColumnMeta.isVisible()) {
                                cellTable.addColumn(resettingColumnMeta.getColumn(), resettingColumnMeta.getHeader());
                            }
                        }
                    } else {
                        columnMeta.setVisible(visible);
                        cellTable.removeColumn(columnMeta.getColumn());
                    }
                }
            });
            popupContent.add(checkBox);
        }
        popup.add(popupContent);
        button.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                if (button.isDown()) {
                    popup.setPopupPosition(button.getAbsoluteLeft(), button.getAbsoluteTop() + button.getOffsetHeight());
                    popup.show();
                }
                // Note: no need to hide the popup when clicked when down,
                // because clicking anywhere outside the popup will hide the popup
            }
View Full Code Here

        operations = new HTML();
        operations.setStyleName("fill-layout");
        operations.getElement().setAttribute("style", "padding:10px");

        final ToggleButton toggleAttributes = new ToggleButton("Attributes", "Attributes");
        final ToggleButton toggleOperations= new ToggleButton("Operations", "Operations");

        toggleAttributes.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
            @Override
            public void onValueChange(ValueChangeEvent<Boolean> event) {
                Boolean isDown = event.getValue();
                toggleOperations.setDown(!isDown);
                attributes.setVisible(isDown);
                operations.setVisible(!isDown);
            }
        });

        toggleOperations.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
            @Override
            public void onValueChange(ValueChangeEvent<Boolean> event) {
                Boolean isDown = event.getValue();
                toggleAttributes.setDown(!isDown);
                operations.setVisible(isDown);
                attributes.setVisible(!isDown);
            }
        });

        toggleAttributes.setDown(true);
        toggleOperations.setDown(false);
        operations.setVisible(false);

        HorizontalPanel tools = new HorizontalPanel();
        tools.add(toggleAttributes);
        tools.add(toggleOperations);
View Full Code Here

TOP

Related Classes of com.google.gwt.user.client.ui.ToggleButton

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.