com.google.gwt.user.client.ui.Panel Java Examples

The following examples show how to use com.google.gwt.user.client.ui.Panel. 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: GalleryPage.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Helper method called by constructor to initialize the app's title section
 * @param container   The container that title resides
 */
private void initAppTitle(Panel container) {
  if (newOrUpdateApp()) {
    // GUI for editable title container
    if (editStatus==NEWAPP) {
      // If it's new app, give a textual hint telling user this is title
      titleText.setText(app.getTitle());
    } else if (editStatus==UPDATEAPP) {
      // If it's not new, just set whatever's in the data field already
      titleText.setText(app.getTitle());
    }
    titleText.addValueChangeHandler(new ValueChangeHandler<String>() {
      @Override
      public void onValueChange(ValueChangeEvent<String> event) {
        app.setTitle(titleText.getText());
      }
    });
    titleText.addStyleName("app-desc-textarea");
    container.add(titleText);
    container.addStyleName("app-title-container");
  } else {
    Label title = new Label(app.getTitle());
    title.addStyleName("app-title");
    container.add(title);
  }
}
 
Example #2
Source File: GalleryPage.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Helper method called by constructor to initialize the app's description
 * @param c1   The container that description resides (editable state)
 * @param c2   The container that description resides (public state)
 */
private void initAppDesc(Panel c1, Panel c2) {
  desc.getElement().setPropertyString("placeholder", MESSAGES.galleryDescriptionHint());
  if (newOrUpdateApp()) {
    desc.addValueChangeHandler(new ValueChangeHandler<String>() {
      @Override
      public void onValueChange(ValueChangeEvent<String> event) {
        app.setDescription(desc.getText());
      }
    });
    if(editStatus==UPDATEAPP){
      desc.setText(app.getDescription());
    }
    desc.addStyleName("app-desc-textarea");
    c1.add(desc);
  } else {
    Label description = new Label(app.getDescription());
    c2.add(description);
    c2.addStyleName("app-description");
  }
}
 
Example #3
Source File: GalleryPage.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Helper method called by constructor to initialize the salvage section
 * @param container   The container that salvage label reside
 */
private void initSalvageSection(Panel container) { //TODO: Update the location of this button
  if (!canSalvage()) {                              // Permitted to salvage?
    return;
  }

  final Label salvagePrompt = new Label("salvage");
  salvagePrompt.addStyleName("primary-link");
  container.add(salvagePrompt);

  salvagePrompt.addClickHandler(new ClickHandler() {
    public void onClick(ClickEvent event) {
      final OdeAsyncCallback<Void> callback = new OdeAsyncCallback<Void>(
          // failure message
          MESSAGES.galleryError()) {
            @Override
            public void onSuccess(Void bool) {
              salvagePrompt.setText("done");
            }
        };
      Ode.getInstance().getGalleryService().salvageGalleryApp(app.getGalleryAppId(), callback);
    }
  });
}
 
Example #4
Source File: KeyBindingRegistryIntegrationGwtTest.java    From swellrt with Apache License 2.0 6 votes vote down vote up
/** Util to help construct an editor instance. */
private EditorImpl createEditor(KeyBindingRegistry keyBinding) {
  EditorStaticDeps.setPopupProvider(new PopupProvider() {
    @Override
    public UniversalPopup createPopup(Element reference, RelativePopupPositioner positioner,
        PopupChrome chrome, boolean autoHide) {
      return new Popup(reference, positioner);
    }
    @Override
    public void setRootPanel(Panel rootPanel) {
      // Not used as we use our own popup implementation.
    }
  });
  Editor editor = Editors.create();
  initEditor(editor, Editor.ROOT_REGISTRIES, keyBinding);
  return (EditorImpl) editor;
}
 
Example #5
Source File: KeyBindingRegistryIntegrationGwtTest.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
/** Util to help construct an editor instance. */
private EditorImpl createEditor(KeyBindingRegistry keyBinding) {
  EditorStaticDeps.setPopupProvider(new PopupProvider() {
    @Override
    public UniversalPopup createPopup(Element reference, RelativePopupPositioner positioner,
        PopupChrome chrome, boolean autoHide) {
      return new Popup(reference, positioner);
    }
    @Override
    public void setRootPanel(Panel rootPanel) {
      // Not used as we use our own popup implementation.
    }
  });
  Editor editor = Editors.create();
  initEditor(editor, Editor.ROOT_REGISTRIES, keyBinding);
  return (EditorImpl) editor;
}
 
Example #6
Source File: OpacityDemo.java    From gwt-traction with Apache License 2.0 5 votes vote down vote up
@Override
   public void onModuleLoad() {

Panel controls = RootPanel.get("controls");

startOpacity = createTextBox("1.0");
endOpacity = createTextBox("0.1");
duration = createTextBox("5000");

addTextBox(controls, "Start Opacity", startOpacity);
addTextBox(controls, "End Opacity", endOpacity);
addTextBox(controls, "Duration", duration);

Button start = new Button("Start");
start.addClickHandler(new ClickHandler() {
    @Override
           public void onClick(ClickEvent event) {
        OpacityAnimation animation = new OpacityAnimation(new Element[] {
							      Document.get().getElementById("box1"),
							      Document.get().getElementById("box2"),
							      Document.get().getElementById("box3")
							  },
							  Float.parseFloat(startOpacity.getText()),
							  Float.parseFloat(endOpacity.getText()));
        animation.run(Integer.parseInt(duration.getText()));
    }
});

controls.add(start);
   }
 
Example #7
Source File: SingleListBoxDemo.java    From gwt-traction with Apache License 2.0 5 votes vote down vote up
@Override
public void onModuleLoad() {

    eventListBox = new ListBox(true);
    eventListBox.setVisibleItemCount(20);
    RootPanel.get("eventlog").add(eventListBox);

    singleListBox = new SingleListBox();
    singleListBox.addItem("Apples");
    singleListBox.addItem("Bananas");
    singleListBox.addItem("Oranges");
    singleListBox.addItem("Pears");
    singleListBox.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            addEvent("ValueChangeEvent: " + event.getValue());
        }
    });
    Panel select = RootPanel.get("select");
    select.add(singleListBox);

    Panel toggle = RootPanel.get("toggle");
    toggle.add(createSetAddMissingValue(true));
    toggle.add(createSetAddMissingValue(false));

    Panel controls1 = RootPanel.get("controls1");
    controls1.add(createSelectButton("Bananas"));
    controls1.add(createSelectButton("Pears"));

    Panel controls2 = RootPanel.get("controls2");
    controls2.add(createSelectButton("Kiwis"));
    controls2.add(createSelectButton("Watermelons"));
}
 
Example #8
Source File: GroupedListBoxDemo.java    From gwt-traction with Apache License 2.0 5 votes vote down vote up
@Override
   public void onModuleLoad() {

groupedListBox1 = new GroupedListBox(false);
groupedListBox2 = new GroupedListBox(true);
RootPanel.get("select1").add(groupedListBox1);
RootPanel.get("select2").add(groupedListBox2);

addItem("Fruits|Apples");
addItem("Fruits|Bananas");
addItem("Fruits|Oranges");
addItem("Fruits|Pears");	
addItem("Vegetables|Tomatoes");	
addItem("Vegetables|Carrots");		

Panel controls = RootPanel.get("controls");
controls.add(createAddButton("Fruits|Blueberries"));
controls.add(createAddButton("Vegetables|Broccoli"));
controls.add(createAddButton("Meats|Chicken"));
controls.add(createAddButton("Meats|Turkey"));

Button remove = new Button("Remove Selected");
remove.addClickHandler(new ClickHandler() {
           
           @Override
           public void onClick(ClickEvent event) {
               removeSelected();
           }
       });

controls.add(remove);
   }
 
Example #9
Source File: ColorDemo.java    From gwt-traction with Apache License 2.0 5 votes vote down vote up
@Override
   public void onModuleLoad() {

Panel controls = RootPanel.get("controls");

startColor = createTextBox("rgba(255,255,0,1)");
endColor = createTextBox("rgba(255,0,255,0)");
duration = createTextBox("5000");

addTextBox(controls, "Start Color", startColor);
addTextBox(controls, "End Color", endColor);
addTextBox(controls, "Duration", duration);

Button start = new Button("Start");
start.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
        ColorAnimation animation = new ColorAnimation(new Element[] {
							      Document.get().getElementById("box1"),
							      Document.get().getElementById("box2"),
							      Document.get().getElementById("box3")
							  },
							  "backgroundColor",
							  RgbaColor.from(startColor.getText()),
							  RgbaColor.from(endColor.getText()));
        animation.run(Integer.parseInt(duration.getText()));
    }
});

controls.add(start);
   }
 
Example #10
Source File: ErrorIndicatorPresenter.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an error indicator.
 *
 * @param container panel to which this widget is to be attached
 */
public static ErrorIndicatorPresenter create(Panel container) {
  ErrorIndicatorWidget ui = ErrorIndicatorWidget.create();
  ErrorIndicatorPresenter presenter = new ErrorIndicatorPresenter(ui);
  ui.init(presenter);
  container.add(ui);
  return presenter;
}
 
Example #11
Source File: DebugOptions.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
private void addCheckBox(Panel panel, String caption, boolean initValue,
    ValueChangeHandler<Boolean> handler) {
  CheckBox box = new CheckBox(caption);
  box.setValue(initValue);
  box.addValueChangeHandler(handler);
  panel.add(box);
}
 
Example #12
Source File: DebugOptions.java    From swellrt with Apache License 2.0 5 votes vote down vote up
private void addCheckBox(Panel panel, String caption, boolean initValue,
    ValueChangeHandler<Boolean> handler) {
  CheckBox box = new CheckBox(caption);
  box.setValue(initValue);
  box.addValueChangeHandler(handler);
  panel.add(box);
}
 
Example #13
Source File: ErrorIndicatorPresenter.java    From swellrt with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an error indicator.
 *
 * @param container panel to which this widget is to be attached
 */
public static ErrorIndicatorPresenter create(Panel container) {
  ErrorIndicatorWidget ui = ErrorIndicatorWidget.create();
  ErrorIndicatorPresenter presenter = new ErrorIndicatorPresenter(ui);
  ui.init(presenter);
  container.add(ui);
  return presenter;
}
 
Example #14
Source File: UniTimeWidget.java    From unitime with Apache License 2.0 5 votes vote down vote up
@Deprecated
public void clear() {
	if (getWidget() instanceof ListBox)
		((ListBox)getWidget()).clear();
	if (getWidget() instanceof Panel)
		((Panel)getWidget()).clear();
}
 
Example #15
Source File: Menu.java    From sc2gears with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new Menu.
 */
public Menu( final MenuItem[] menuItems, final Panel pageContainer ) {
	this.menuItems     = menuItems;
	this.pageContainer = pageContainer;
	
	for ( final MenuItem mi : menuItems )
		addTab( mi.getLabel() );
	
	addSelectionHandler( new SelectionHandler< Integer >() {
		@Override
		public void onSelection( final SelectionEvent< Integer > event ) {
			menuItems[ event.getSelectedItem() ].onActivate( Menu.this );
		}
	} );
}
 
Example #16
Source File: MaterialLoader.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
/**
 * Static helper class that shows / hides a progress loader within a container
 */
public static void progress(boolean visible, Panel container) {
    loader.setType(LoaderType.PROGRESS);
    loader.setContainer(container);
    if (visible) {
        loader.show();
    } else {
        loader.hide();
    }
}
 
Example #17
Source File: GalleryPage.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to update the app image
 * @param url  The URL of the image to show
 * @param container  The container that image widget resides
 */
private void updateAppImage(String url, final Panel container) {
    image = new Image();
    image.addStyleName("app-image");
    image.setUrl(url);
    // if the user has provided a gallery app image, we'll load it. But if not
    // the error will occur and we'll load default image
    image.addErrorHandler(new ErrorHandler() {
      public void onError(ErrorEvent event) {
        image.setResource(GalleryImages.get().genericApp());
      }
    });
    container.add(image);

    if(gallery.getSystemEnvironment() != null &&
        gallery.getSystemEnvironment().toString().equals("Development")){
      final OdeAsyncCallback<String> callback = new OdeAsyncCallback<String>(
        // failure message
        MESSAGES.galleryError()) {
          @Override
          public void onSuccess(String newUrl) {
            if (newUrl != null) {
              image.setUrl(newUrl + "?" + System.currentTimeMillis());
            }
          }
        };
      Ode.getInstance().getGalleryService().getBlobServingUrl(url, callback);
    }
}
 
Example #18
Source File: MaterialLoader.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
/**
 * Static helper class that shows / hides a circular loader within a container
 */
public static void loading(boolean visible, Panel container) {
    loader.setType(LoaderType.CIRCULAR);
    loader.setContainer(container);
    if (visible) {
        loader.show();
    } else {
        loader.hide();
    }
}
 
Example #19
Source File: CubaTreeTableWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
protected Element getElementTdOrTr(Element eventTarget) {
    Widget widget = WidgetUtil.findWidget(eventTarget, null);
    Widget targetWidget = widget;

    if (widget != this) {
        /*
         * This is a workaround to make Labels, read only TextFields
         * and Embedded in a Table clickable (see #2688). It is
         * really not a fix as it does not work with a custom read
         * only components (not extending VLabel/VEmbedded).
         */
        while (widget != null && widget.getParent() != this) {
            widget = widget.getParent();
        }

        if (!(widget instanceof VLabel)
                && !(widget instanceof VEmbedded)
                && !(widget instanceof VTextField && ((VTextField) widget).isReadOnly())
                && !(targetWidget instanceof VLabel)
                && !(targetWidget instanceof Panel)
                && !(targetWidget instanceof VEmbedded)
                && !(widget instanceof CubaImageWidget)
                && !(targetWidget instanceof VTextField && ((VTextField) targetWidget).isReadOnly())) {
            return null;
        }
    }
    return getTdOrTr(eventTarget);
}
 
Example #20
Source File: ProfilePage.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to update the user's image
 * @param url  The URL of the image to show
 * @param container  The container that image widget resides
 */
private void updateUserImage(final String url, Panel container) {
  userAvatar = new Image();
  //setUrl if the new URL is the same one as it was before; an easy workaround is
  //to make the URL unique so it forces the browser to reload
  userAvatar.setUrl(url + "?" + System.currentTimeMillis());
  userAvatar.addStyleName("app-image");
  if (profileStatus == PRIVATE) {
    //userAvatar.addStyleName("status-updating");
  }
  // if the user has provided a gallery app image, we'll load it. But if not
  // the error will occur and we'll load default image
  userAvatar.addErrorHandler(new ErrorHandler() {
    public void onError(ErrorEvent event) {
      userAvatar.setResource(GalleryImages.get().androidIcon());
    }
  });
  container.add(userAvatar);

  if(gallery.getSystemEnvironment() != null &&
      gallery.getSystemEnvironment().toString().equals("Development")){
    final OdeAsyncCallback<String> callback = new OdeAsyncCallback<String>(
      // failure message
      MESSAGES.galleryError()) {
        @Override
        public void onSuccess(String newUrl) {
          if (userAvatar != null) {
            userAvatar.setUrl(newUrl + "?" + System.currentTimeMillis());
          }
        }
      };
    Ode.getInstance().getGalleryService().getBlobServingUrl(url, callback);
  }
}
 
Example #21
Source File: GalleryPage.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method called by constructor to initialize the app's stats fields
 * @param container   The container that stats fields reside
 */
private void initAppStats(Panel container) {
  // Images for stats data
  Image numDownloads = new Image();
  numDownloads.setUrl(DOWNLOAD_ICON_URL);
  Image numLikes = new Image();
  numLikes.setUrl(HOLLOW_HEART_ICON_URL);

  // Add stats data
  container.addStyleName("app-stats");
  container.add(numDownloads);
  container.add(new Label(Integer.toString(app.getDownloads())));
  // Adds dynamic like
  initLikeSection(container);
  // Adds dynamic feature
  initFeatureSection(container);
  // Adds dynamic tutorial
  initTutorialSection(container);
  // Adds dynamic salvage
  initSalvageSection(container);

  // We are not using views and comments at initial launch
  /*
  Image numViews = new Image();
  numViews.setUrl(NUM_VIEW_ICON_URL);
  Image numComments = new Image();
  numComments.setUrl(NUM_COMMENT_ICON_URL);
  container.add(numViews);
  container.add(new Label(Integer.toString(app.getViews())));
  container.add(numComments);
  container.add(new Label(Integer.toString(app.getComments())));
  */
}
 
Example #22
Source File: MobileUniversalPopup.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
/**
 * Create a new MobileUniversalPopup.
 * @param root The root panel to which popups will be added when show is called.
 */
MobileUniversalPopup(Panel root) {
  this.root = root;
  DebugClassHelper.addDebugClass(popup, DEBUG_CLASS);
}
 
Example #23
Source File: PopupFactory.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
/**
 * Creates popups suitable for current platform.
 */
public static void setRootPanel(Panel rootPanel) {
  getProvider().setRootPanel(rootPanel);
}
 
Example #24
Source File: MobilePopupProvider.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void setRootPanel(Panel root) {
  this.root = root;
}
 
Example #25
Source File: ColorDemo.java    From gwt-traction with Apache License 2.0 4 votes vote down vote up
private static final void addTextBox(Panel panel, String label, TextBox box) {
panel.add(new Label(label));
panel.add(box);
   }
 
Example #26
Source File: GwtMockitoTestRunner.java    From gwtmockito with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a collection of classes whose non-abstract methods should always be replaced with
 * no-ops. By default, this list includes {@link Composite}, {@link DOM} {@link UIObject},
 * {@link Widget}, {@link Image}, and most subclasses of {@link Panel}. It will also include any
 * classes specified via the {@link WithClassesToStub} annotation on the test class. This makes
 * it much safer to test code that uses or extends these types.
 * <p>
 * This list can be customized via {@link WithClassesToStub} or by defining a new test runner
 * extending {@link GwtMockitoTestRunner} and overriding this method. This allows users to
 * explicitly stub out particular classes that are causing problems in tests. If you override this
 * method, you will probably want to retain the classes that are stubbed here by doing something
 * like this:
 *
 * <pre>
 * &#064;Override
 * protected Collection&lt;Class&lt;?&gt;&gt; getClassesToStub() {
 *   Collection&lt;Class&lt;?&gt;&gt; classes = super.getClassesToStub();
 *   classes.add(MyBaseWidget.class);
 *   return classes;
 * }
 * </pre>
 *
 * @return a collection of classes whose methods should be stubbed with no-ops while running tests
 */
protected Collection<Class<?>> getClassesToStub() {
  Collection<Class<?>> classes = new LinkedList<Class<?>>();
  classes.add(Composite.class);
  classes.add(DOM.class);
  classes.add(UIObject.class);
  classes.add(Widget.class);

  classes.add(DataGrid.class);
  classes.add(HTMLTable.class);
  classes.add(Image.class);

  classes.add(AbsolutePanel.class);
  classes.add(CellList.class);
  classes.add(CellPanel.class);
  classes.add(CellTable.class);
  classes.add(ComplexPanel.class);
  classes.add(DeckLayoutPanel.class);
  classes.add(DeckPanel.class);
  classes.add(DecoratorPanel.class);
  classes.add(DockLayoutPanel.class);
  classes.add(DockPanel.class);
  classes.add(FlowPanel.class);
  classes.add(FocusPanel.class);
  classes.add(HorizontalPanel.class);
  classes.add(HTMLPanel.class);
  classes.add(LayoutPanel.class);
  classes.add(Panel.class);
  classes.add(PopupPanel.class);
  classes.add(RenderablePanel.class);
  classes.add(ResizeLayoutPanel.class);
  classes.add(SimpleLayoutPanel.class);
  classes.add(SimplePanel.class);
  classes.add(SplitLayoutPanel.class);
  classes.add(StackPanel.class);
  classes.add(VerticalPanel.class);
  classes.add(ValueListBox.class);

  WithClassesToStub annotation = unitTestClass.getAnnotation(WithClassesToStub.class);
  if (annotation != null) {
    classes.addAll(Arrays.asList(annotation.value()));
  }

  return classes;
}
 
Example #27
Source File: OpacityDemo.java    From gwt-traction with Apache License 2.0 4 votes vote down vote up
private static final void addTextBox(Panel panel, String label, TextBox box) {
panel.add(new Label(label));
panel.add(box);
   }
 
Example #28
Source File: WordCloudApp.java    From swcv with MIT License 4 votes vote down vote up
private void createShowAdvancedButton()
{
    final String COOKIE_NAME = "show-adv-options";

    final Anchor showAdvancedButton = Anchor.wrap(Document.get().getElementById("adv_link"));
    final Panel settingArea = RootPanel.get("settingContainer");

    showAdvancedButton.addClickHandler(new ClickHandler()
    {
        public void onClick(ClickEvent event)
        {
            if (showAdvancedButton.getText().equals("Show Advanced Options"))
            {
                settingArea.removeStyleName("hide");
                showAdvancedButton.setText("Hide Advanced Options");
                Cookies.setCookie(COOKIE_NAME, "1", new Date(System.currentTimeMillis() + (86400 * 7 * 1000)));
            }
            else
            {
                settingArea.addStyleName("hide");
                showAdvancedButton.setText("Show Advanced Options");
                Cookies.removeCookie(COOKIE_NAME);
            }
        }
    });

    boolean needToShow = "1".equals(Cookies.getCookie(COOKIE_NAME));
    if (needToShow)
        showAdvancedButton.fireEvent(new GwtEvent<ClickHandler>()
        {
            @Override
            public com.google.gwt.event.shared.GwtEvent.Type<ClickHandler> getAssociatedType()
            {
                return ClickEvent.getType();
            }

            @Override
            protected void dispatch(ClickHandler handler)
            {
                handler.onClick(null);
            }
        });
}
 
Example #29
Source File: MobileUniversalPopup.java    From swellrt with Apache License 2.0 4 votes vote down vote up
/**
 * Create a new MobileUniversalPopup.
 * @param root The root panel to which popups will be added when show is called.
 */
MobileUniversalPopup(Panel root) {
  this.root = root;
  DebugClassHelper.addDebugClass(popup, DEBUG_CLASS);
}
 
Example #30
Source File: PopupFactory.java    From swellrt with Apache License 2.0 4 votes vote down vote up
/**
 * Creates popups suitable for current platform.
 */
public static void setRootPanel(Panel rootPanel) {
  getProvider().setRootPanel(rootPanel);
}