Java Code Examples for com.google.gwt.user.client.ui.SimplePanel#setWidget()

The following examples show how to use com.google.gwt.user.client.ui.SimplePanel#setWidget() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MockBall.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new MockBall component.
 *
 * @param editor  editor of source file the component belongs to
 */
public MockBall(SimpleEditor editor) {
  super(editor, TYPE, images.ball());

  // Initialize mock ball UI
  ballWidget = new SimplePanel();
  ballWidget.setStylePrimaryName("ode-SimpleMockComponent");

  // Create an appropriately sized ball
  canvas = new GWTCanvas(diameter, diameter);
  canvas.setPixelSize(diameter, diameter);
  canvas.setBackgroundColor(GWTCanvas.TRANSPARENT);
  fillCircle();
  ballWidget.setWidget(canvas);

  initComponent(ballWidget);
}
 
Example 2
Source File: WeekGrid.java    From calendar-component with Apache License 2.0 5 votes vote down vote up
private void setVerticalScroll(boolean isVerticalScrollEnabled) {
    if (isVerticalScrollEnabled && !(isVerticalScrollable())) {
        verticalScrollEnabled = true;
        horizontalScrollEnabled = false;
        wrapper.remove(content);

        final ScrollPanel scrollPanel = new ScrollPanel();
        scrollPanel.setStylePrimaryName("v-calendar-week-wrapper");
        scrollPanel.setWidget(content);

        scrollPanel.addScrollHandler(event -> {
            if (calendar.getScrollListener() != null) {
                int vScrollPos = scrollPanel.getVerticalScrollPosition();
                calendar.getScrollListener().scroll(vScrollPos);

                if (vScrollPos > 1) {
                    content.addStyleName("scrolled");
                } else {
                    content.removeStyleName("scrolled");
                }
            }
        });

        setWidget(scrollPanel);
        wrapper = scrollPanel;

    } else if (!isVerticalScrollEnabled && (isVerticalScrollable())) {
        verticalScrollEnabled = false;
        horizontalScrollEnabled = false;
        wrapper.remove(content);

        SimplePanel simplePanel = new SimplePanel();
        simplePanel.setStylePrimaryName("v-calendar-week-wrapper");
        simplePanel.setWidget(content);

        setWidget(simplePanel);
        wrapper = simplePanel;
    }
}
 
Example 3
Source File: MockVideoPlayer.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new MockVideoPlayer component.
 *
 * @param editor  editor of source file the component belongs to
 */
public MockVideoPlayer(SimpleEditor editor) {
  super(editor, TYPE, images.videoplayer());

  // Initialize mock video UI
  videoPlayerWidget = new SimplePanel();
  videoPlayerWidget.setStylePrimaryName("ode-SimpleMockComponent");
  videoPlayerWidget.setWidget(getIconImage());
  initComponent(videoPlayerWidget);
}
 
Example 4
Source File: MockSlider.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new MockSlider component.
 *
 * @param editor editor of source file the component belongs to
 */
public MockSlider(SimpleEditor editor) {
  super(editor, TYPE, images.slider());

  // Initialize mock slider UI
  sliderWidget = new SimplePanel();
  sliderWidget.setStylePrimaryName("ode-SimpleMockComponent");

  sliderWidget.setWidget(getIconImage());

  initComponent(sliderWidget);
}
 
Example 5
Source File: MockWebViewer.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new MockWebViewer component.
 *
 * @param editor  editor of source file the component belongs to
 */
public MockWebViewer(SimpleEditor editor) {
  super(editor, TYPE, images.webviewer());

  // Initialize mock WebViewer UI
  SimplePanel webViewerWidget = new SimplePanel();
  webViewerWidget.setStylePrimaryName("ode-SimpleMockContainer");
  // TODO(halabelson): Center vertically as well as horizontally
  webViewerWidget.addStyleDependentName("centerContents");
  webViewerWidget.setWidget(largeImage);
  initComponent(webViewerWidget);
}
 
Example 6
Source File: WidgetComboBox.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Highlights the visual item in the drop down list if it's selected in the model.
 *
 * @param event is an event that contains data about selected item.
 */
protected void select(ListModelEvent event) {
  if (isListPanelOpened()) {
    getListPanel().setHighlightRow(event.getItemIndex());
  }

  final Widget widget = getListItemFactory().createWidget(model.getSelected());
  final SimplePanel selectedValue = getSelectedValue();
  selectedValue.setWidget(widget);
}
 
Example 7
Source File: GwtImageBoxImplConnector.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
  super.onStateChanged(stateChangeEvent);

  SimplePanel widget = getWidget();
  MultiImageState state = getState().myImageState;
  widget.setHeight(state.myHeight + "px");
  widget.setWidth(state.myWidth + "px");

  widget.setWidget(ImageConverter.create(state));
}
 
Example 8
Source File: GwtTabbedLayoutImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void setTabs(int index, Map<TabbedLayoutState.TabState, Widget> map) {
  clear();

  for (Map.Entry<TabbedLayoutState.TabState, Widget> entry : map.entrySet()) {
    TabbedLayoutState.TabState state = entry.getKey();
    GwtHorizontalLayoutImpl tabWidget = GwtComboBoxImplConnector.buildItem(state);
    if (state.myCloseButton != null) {
      SimplePanel closeButton = new SimplePanel();

      tabWidget.add(closeButton);
      tabWidget.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_RIGHT);

      Widget closeIcon = ImageConverter.create(state.myCloseButton);
      closeButton.setWidget(closeIcon);
      Widget closeHoveredIcon = ImageConverter.create(state.myCloseHoverButton);

      closeButton.addDomHandler(event -> {
        closeButton.setWidget(closeHoveredIcon);
      }, MouseOverEvent.getType());

      closeButton.addDomHandler(event -> {
        closeButton.setWidget(closeIcon);
      }, MouseOutEvent.getType());

      closeButton.addDomHandler(event -> {
        if (myCloseHandler != null) {
          int idx = getWidgetIndex(entry.getValue());
          if (idx != -1) {
            myCloseHandler.accept(idx);
          }
        }
      }, ClickEvent.getType());
    }
    else {
      tabWidget.addStyleName("gwt-TabBarItem-no-close-button");
    }
    add(entry.getValue(), tabWidget);
  }

  selectTab(index);
}