Java Code Examples for com.google.gwt.user.client.ui.HorizontalPanel#setCellWidth()

The following examples show how to use com.google.gwt.user.client.ui.HorizontalPanel#setCellWidth() . 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: LabeledTextBox.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new TextBox with the given leading caption.
 *
 * @param caption  caption for leading label
 */
public LabeledTextBox(String caption) {
  HorizontalPanel panel = new HorizontalPanel();
  Label label = new Label(caption);
  panel.add(label);
  panel.setCellVerticalAlignment(label, HasVerticalAlignment.ALIGN_MIDDLE);
  textbox = new TextBox();
  textbox.setStylePrimaryName("ode-LabeledTextBox");
  textbox.setWidth("100%");
  panel.add(textbox);
  panel.setCellWidth(label, "40%");
  panel.setCellVerticalAlignment(textbox, HasVerticalAlignment.ALIGN_MIDDLE);

  initWidget(panel);

  setWidth("100%");
}
 
Example 2
Source File: TopPanel.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
private void addLogo(HorizontalPanel panel) {
  // Logo is a link to App Inv homepage. Add timestamp to logo url
  // to get around browsers that agressively cache the image! This
  // same trick is used in StorageUtil.getFilePath().
  Image logo = new Image(LOGO_IMAGE_URL + "?t=" + System.currentTimeMillis());
  logo.setSize("180px", "40px");
  logo.setStyleName("ode-Logo");
  String logoUrl = ode.getSystemConfig().getLogoUrl();
  if (!Strings.isNullOrEmpty(logoUrl)) {
    logo.addClickHandler(new WindowOpenClickHandler(logoUrl));
  }
  panel.add(logo);
  panel.setCellWidth(logo, "230px");
  panel.setCellHorizontalAlignment(logo, HorizontalPanel.ALIGN_LEFT);
  panel.setCellVerticalAlignment(logo, HorizontalPanel.ALIGN_MIDDLE);
}
 
Example 3
Source File: Status.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The status
 */
public Status() {
	super(false, true);
	hPanel = new HorizontalPanel();
	image = new Image(OKMBundleResources.INSTANCE.indicator());
	msg = new HTML("");
	space = new HTML("");

	hPanel.add(image);
	hPanel.add(msg);
	hPanel.add(space);

	hPanel.setCellVerticalAlignment(image, HasAlignment.ALIGN_MIDDLE);
	hPanel.setCellVerticalAlignment(msg, HasAlignment.ALIGN_MIDDLE);
	hPanel.setCellHorizontalAlignment(image, HasAlignment.ALIGN_CENTER);
	hPanel.setCellWidth(image, "30px");
	hPanel.setCellWidth(space, "7px");

	hPanel.setHeight("25px");

	msg.setStyleName("okm-NoWrap");

	super.hide();
	setWidget(hPanel);
}
 
Example 4
Source File: Status.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Status
 */
public Status() {
	super(false, true);
	hPanel = new HorizontalPanel();
	image = new Image(OKMBundleResources.INSTANCE.indicator());
	msg = new HTML("");
	space = new HTML("");

	hPanel.add(image);
	hPanel.add(msg);
	hPanel.add(space);

	hPanel.setCellVerticalAlignment(image, HasAlignment.ALIGN_MIDDLE);
	hPanel.setCellVerticalAlignment(msg, HasAlignment.ALIGN_MIDDLE);
	hPanel.setCellHorizontalAlignment(image, HasAlignment.ALIGN_CENTER);
	hPanel.setCellWidth(image, "30px");
	hPanel.setCellWidth(space, "7px");

	hPanel.setHeight("25px");

	msg.setStyleName("okm-NoWrap");

	super.hide();
	setWidget(hPanel);
}
 
Example 5
Source File: DesignToolbar.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes and assembles all commands into buttons in the toolbar.
 */
public DesignToolbar() {
  super();

  isReadOnly = Ode.getInstance().isReadOnly();

  projectNameLabel = new Label();
  projectNameLabel.setStyleName("ya-ProjectName");
  HorizontalPanel toolbar = (HorizontalPanel) getWidget();
  toolbar.insert(projectNameLabel, 0);

  // width of palette minus cellspacing/border of buttons
  toolbar.setCellWidth(projectNameLabel, "222px");

  addButton(new ToolbarItem(WIDGET_NAME_TUTORIAL_TOGGLE,
      MESSAGES.toggleTutorialButton(), new ToogleTutorialAction()));
  setButtonVisible(WIDGET_NAME_TUTORIAL_TOGGLE, false); // Don't show unless needed

  List<DropDownItem> screenItems = Lists.newArrayList();
  addDropDownButton(WIDGET_NAME_SCREENS_DROPDOWN, MESSAGES.screensButton(), screenItems);

  if (AppInventorFeatures.allowMultiScreenApplications() && !isReadOnly) {
    addButton(new ToolbarItem(WIDGET_NAME_ADDFORM, MESSAGES.addFormButton(),
        new AddFormAction()));
    addButton(new ToolbarItem(WIDGET_NAME_REMOVEFORM, MESSAGES.removeFormButton(),
        new RemoveFormAction()));
  }

  addButton(new ToolbarItem(WIDGET_NAME_SWITCH_TO_FORM_EDITOR,
      MESSAGES.switchToFormEditorButton(), new SwitchToFormEditorAction()), true);
  addButton(new ToolbarItem(WIDGET_NAME_SWITCH_TO_BLOCKS_EDITOR,
      MESSAGES.switchToBlocksEditorButton(), new SwitchToBlocksEditorAction()), true);

  // Gray out the Designer button and enable the blocks button
  toggleEditor(false);
  Ode.getInstance().getTopToolbar().updateFileMenuButtons(0);
}
 
Example 6
Source File: LabeledTextBox.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Use this TextBox if you want to have text validation while a user is typing
 *
 * @param caption    caption for leading label
 * @param validator  The validator to use for a specific textBox
 */
public LabeledTextBox(String caption, Validator validator) {
  this.validator = validator;

  HorizontalPanel panel = new HorizontalPanel();
  Label label = new Label(caption);
  panel.add(label);
  panel.setCellVerticalAlignment(label, HasVerticalAlignment.ALIGN_MIDDLE);
  textbox = new TextBox();
  textbox.setStylePrimaryName("ode-LabeledTextBox");
  defaultTextBoxColor = textbox.getElement().getStyle().getBorderColor();
  textbox.setWidth("100%");
  panel.add(textbox);
  panel.setCellWidth(label, "40%");
  panel.setCellVerticalAlignment(textbox, HasVerticalAlignment.ALIGN_MIDDLE);

  HorizontalPanel errorPanel = new HorizontalPanel();
  errorLabel = new Label("");
  errorPanel.add(errorLabel);

  VerticalPanel vp = new VerticalPanel();
  vp.add(panel);
  vp.add(errorPanel);
  vp.setHeight("85px");

  initWidget(vp);

  setWidth("100%");
}
 
Example 7
Source File: AriaTabBar.java    From unitime with Apache License 2.0 5 votes vote down vote up
public void setRestWidget(Widget rest) {
	HorizontalPanel panel = (HorizontalPanel)getWidget();
	rest.addStyleName("gwt-TabBarRest");
	rest.setHeight("100%");
	panel.remove(panel.getWidgetCount() - 1);
	panel.add(rest);
	panel.setCellWidth(rest, "100%");
	setStyleName(rest.getElement().getParentElement(), "gwt-TabBarRest-wrapper");
}
 
Example 8
Source File: DiagramTab.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates the Slider the user can interact with to change the shown time intervals of the given
 * timeseries'.
 *
 * @return the TimeSlider as a whole
 */
private HorizontalPanel createOverviewSlider() {
    HorizontalPanel horizontalSlider = new HorizontalPanel();
    DOM.setStyleAttribute(horizontalSlider.getElement(), "marginTop", "6px");
    horizontalSlider.setHeight("75px");

    this.leftHandleWidget = buildSliderPart("8px", "75px", "w-resize", "#6585d0", 0.5);
    this.rightHandleWidget = buildSliderPart("8px", "75px", "e-resize", "#6585d0", 0.5);
    this.mainHandleWidget = buildSliderPart("100%", "75px", "move", "#aaa", 0.5);

    horizontalSlider.add(this.leftHandleWidget);
    horizontalSlider.setCellWidth(this.leftHandleWidget, "15px");
    horizontalSlider.add(this.mainHandleWidget);
    horizontalSlider.setCellWidth(this.mainHandleWidget, "100%");
    horizontalSlider.add(this.rightHandleWidget);
    horizontalSlider.setCellWidth(this.rightHandleWidget, "15px");
    DOM.setStyleAttribute(horizontalSlider.getElement(), "visibility", "hidden");

    GenericWidgetViewImpl view = new GenericWidgetViewImpl(horizontalSlider);
    OverviewPresenter overviewPresenter = new OverviewPresenter(view, this.overviewEventBus, this.mainChartEventBus);

    // Define handles for overview control
    GenericWidgetView leftHandle = new GenericWidgetViewImpl(this.leftHandleWidget);
    GenericWidgetView mainHandle = new GenericWidgetViewImpl(this.mainHandleWidget);
    GenericWidgetView rightHandle = new GenericWidgetViewImpl(this.rightHandleWidget);

    overviewPresenter.addHandle(leftHandle, Bound.LEFT);
    overviewPresenter.addHandle(mainHandle, Bound.RIGHT, Bound.LEFT);
    overviewPresenter.addHandle(rightHandle, Bound.RIGHT);
    overviewPresenter.setMinClippingWidth(40); // min width
    overviewPresenter.setVerticallyLocked(true); // drag horizontally only

    return horizontalSlider;
}
 
Example 9
Source File: SimplePaletteItem.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new palette item.
 *
 * @param scd component descriptor for palette item
 * @param dropTargetProvider provider of targets that palette items can be dropped on
 */
public SimplePaletteItem(SimpleComponentDescriptor scd, DropTargetProvider dropTargetProvider) {
  this.dropTargetProvider = dropTargetProvider;
  this.scd = scd;

  componentPrototype = null;

  // Initialize palette item UI
  HorizontalPanel panel = new HorizontalPanel();
  panel.setStylePrimaryName("ode-SimplePaletteItem");

  Image image = scd.getImage();
  image.setStylePrimaryName("ode-SimplePaletteItem-icon");
  panel.add(image);
  panel.setCellHorizontalAlignment(image, HorizontalPanel.ALIGN_LEFT);
  panel.setCellWidth(image, "30px");

  Label label = new Label(ComponentsTranslation.getComponentName(scd.getName()));
  label.setHorizontalAlignment(Label.ALIGN_LEFT);
  label.addStyleName("ode-SimplePaletteItem-caption");
  panel.add(label);

  HorizontalPanel optPanel = new HorizontalPanel();

  ComponentHelpWidget helpImage = new ComponentHelpWidget(scd);
  optPanel.add(helpImage);
  optPanel.setCellHorizontalAlignment(helpImage, HorizontalPanel.ALIGN_LEFT);

  if (scd.getExternal()) {
    ComponentRemoveWidget deleteImage = new ComponentRemoveWidget(scd);
    optPanel.add(deleteImage);
    optPanel.setCellHorizontalAlignment(deleteImage, HorizontalPanel.ALIGN_RIGHT);
  }

  panel.add(optPanel);
  panel.setCellHorizontalAlignment(optPanel, HorizontalPanel.ALIGN_RIGHT);

  panel.setWidth("100%");
  add(panel);
  setWidth("100%");

  addHandlers();
}
 
Example 10
Source File: HomePage.java    From sc2gears with Apache License 2.0 4 votes vote down vote up
@Override
  public void buildGUI() {
add( ClientUtils.createVerticalEmptyWidget( 30 ) );

final HorizontalPanel greetingsPanel = new HorizontalPanel();
add( greetingsPanel );

if ( sharedApiAccountUserInfo == null ) {
	// Greeting
	if ( apiUserInfo.getLastVisit() == null ) {
		greetingsPanel.add( new Label( "Welcome " ) );
		greetingsPanel.add( ClientUtils.createHorizontalEmptyWidget( 5 ) );
		greetingsPanel.add( ClientUtils.styledWidget( new Label( apiUserInfo.getUserName() ), "strong" ) );
		greetingsPanel.add( new Label( "!" ) );
	}
	else {
		greetingsPanel.add( new Label( "Welcome back" ) );
		greetingsPanel.add( ClientUtils.createHorizontalEmptyWidget( 5 ) );
		greetingsPanel.add( ClientUtils.styledWidget( new Label( apiUserInfo.getUserName() ), "strong" ) );
		greetingsPanel.add( new Label( "! Your last visit was at:" ) );
		greetingsPanel.add( ClientUtils.createHorizontalEmptyWidget( 5 ) );
		greetingsPanel.add( ClientUtils.createTimestampWidget( apiUserInfo.getLastVisit() ) );
	}
}
else {
	if ( sharedApiAccountUserInfo.isHasApiAccount() )
		greetingsPanel.add( new Label( "You are now viewing the" ) );
	else
		greetingsPanel.add( new Label( "You do NOT have access to the" ) );
	greetingsPanel.add( ClientUtils.createHorizontalEmptyWidget( 9 ) );
	greetingsPanel.add( ClientUtils.styledWidget( new Label( sharedApiAccountUserInfo.getSharedApiAccount() ), "strong" ) );
	greetingsPanel.add( ClientUtils.createHorizontalEmptyWidget( 9 ) );
	greetingsPanel.add( new Label( "API account!" ) );
}

// Replay parser engine version
if ( apiUserInfo.getRepParserEngineVer() != null ) {
	add( ClientUtils.createVerticalEmptyWidget( 30 ) );
	final HorizontalPanel rowPanel = new HorizontalPanel();
	rowPanel.add( new Label( "Replay parser engine version:" ) );
	rowPanel.add( ClientUtils.createHorizontalEmptyWidget( 5 ) );
	rowPanel.add( ClientUtils.styledWidget( new Label( apiUserInfo.getRepParserEngineVer() ), "strong" ) );
	add( rowPanel );
}

// Parsing service tester page
add( ClientUtils.createVerticalEmptyWidget( 30 ) );
add( new Anchor( "Parsing Service Tester page", "/parsing_service_tester.html", "_blank" ) );

add( ClientUtils.createVerticalEmptyWidget( 70 ) );

// Footer
final HorizontalPanel linksPanel = new HorizontalPanel();
linksPanel.setWidth( "500px" );
DOM.setStyleAttribute( linksPanel.getElement(), "padding", "2px" );
DOM.setStyleAttribute( linksPanel.getElement(), "borderTop", "1px solid #555555" );
linksPanel.addStyleName( "noWrap" );
linksPanel.add( new Anchor( "About the Service", "https://sites.google.com/site/sc2gears/parsing-service", "_blank" ) );
linksPanel.add( ClientUtils.createHorizontalEmptyWidget( 10 ) );
linksPanel.add( new Anchor( "Terms of Service", "https://sites.google.com/site/sc2gears/parsing-service#TOC-Terms-of-Service", "_blank" ) );
linksPanel.add( ClientUtils.createHorizontalEmptyWidget( 10 ) );
linksPanel.add( new Anchor( "Privacy Policy", "https://sites.google.com/site/sc2gears/parsing-service#TOC-Privacy-Policy", "_blank" ) );
linksPanel.add( ClientUtils.createHorizontalEmptyWidget( 15 ) );
final Label lastLabel = new Label( "© András Belicza, 2011-2014, Icons: Fugue" );
DOM.setStyleAttribute( lastLabel.getElement(), "color", "#555555" );
DOM.setStyleAttribute( lastLabel.getElement(), "paddingTop", "3px" );
linksPanel.add( lastLabel );
linksPanel.setCellWidth( lastLabel, "100%" );
linksPanel.setCellHorizontalAlignment( lastLabel, HasHorizontalAlignment.ALIGN_RIGHT );
for ( int i = linksPanel.getWidgetCount() - 1; i >= 0; i-- )
	DOM.setStyleAttribute( linksPanel.getWidget( i ).getElement(), "fontSize", "80%" );
add( linksPanel );
  }
 
Example 11
Source File: HistoryViewer.java    From swellrt with Apache License 2.0 4 votes vote down vote up
public void buildUI() {

    //
    // Panel Left (document viewer and playback controls)
    //

    panelLeft = new VerticalPanel();
    panelLeft.add(docViewer.getWidget());
    panelLeft.setWidth("100%");
    setCSS(docViewer.getWidget(),
        "padding", "5px",
        "margin", "10px",
        "border", "1px solid darkgray",
        "min-height", "300px");


    panelPlayControl = new VerticalPanel();
    panelLeft.add(panelPlayControl);

    labelShowingRevision = new Label("Base revision #");
    panelPlayControl.add(labelShowingRevision);

    labelBaseRevision = new Label("?");
    panelPlayControl.add(labelBaseRevision);

    panelPlayControl.add(new Label("Diff with revision #"));
    boxTargetRevision = new TextBox();
    boxTargetRevision.setWidth("5em");
    boxTargetRevision.setValue("?");
    panelPlayControl.add(boxTargetRevision);


    btnShowDiff = new Button("Show diffs", new ClickHandler() {
      public void onClick(ClickEvent e) {

        try {
          int targetRevisionIndex = Integer.valueOf(boxTargetRevision.getValue());
          targetRevision = docHistory.getUnsafe(targetRevisionIndex);

          docViewer.removeContentAndUnrender();
          playbackDoc.renderDiff(baseRevision, targetRevision, doc -> {
          });
          docViewer.setContent(playbackDoc.getDocument());

        } catch (NumberFormatException ex) {

        }
      }
    });
    panelPlayControl.add(btnShowDiff);
    panelLeft.add(panelPlayControl);


    //
    // Right panel (history log)
    //

    panelRight = new VerticalPanel();

    DocHistory.Iterator history = docHistory.getIterator();

    traverseAllPrev(history, revision -> {
      panelRight.add(new Button(revision.toString(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
          docViewer.removeContentAndUnrender();
          playbackDoc.render(revision, doc -> {
          });
          docViewer.setContent(playbackDoc.getDocument());
          baseRevision = revision;
          labelBaseRevision.setText("" + baseRevision.getRevisionIndex());
        }

      }));

    });

    //
    //
    //

    HorizontalPanel mainPanel = new HorizontalPanel();
    mainPanel.setWidth("100%");

    mainPanel.add(panelLeft);
    mainPanel.setCellWidth(panelLeft, "75%");

    mainPanel.add(panelRight);
    mainPanel.setCellWidth(panelRight, "25%");

    initWidget(mainPanel);

  }