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

The following examples show how to use com.google.gwt.user.client.ui.HorizontalPanel#setHorizontalAlignment() . 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: Toolbar.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes and assembles all commands into buttons in the toolbar.
 */
public Toolbar() {
  buttonMap = new HashMap<String, TextButton>();
  dropDownButtonMap = new HashMap<String, DropDownButton>();

  leftButtons = new HorizontalPanel();
  leftButtons.setSpacing(4);

  rightButtons = new HorizontalPanel();
  rightButtons.setSpacing(4);
  rightButtons.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);

  HorizontalPanel toolbar = new HorizontalPanel();
  toolbar.add(leftButtons);  // this nesting keeps buttons left aligned
  toolbar.add(rightButtons);
  toolbar.setCellHorizontalAlignment(rightButtons, HorizontalPanel.ALIGN_RIGHT);
  toolbar.setWidth("100%");
  toolbar.setStylePrimaryName("ya-Toolbar");

  initWidget(toolbar);
}
 
Example 2
Source File: GalleryAppBox.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Creates new Gallery app box.
 */
private GalleryAppBox() {
  gContainer = new FlowPanel();
  final HorizontalPanel container = new HorizontalPanel();
  container.setWidth("100%");
  container.setSpacing(0);
  container.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
  HorizontalPanel panel = new HorizontalPanel();
  Image image = new Image();
  image.setResource(Ode.getImageBundle().waitingIcon());
  panel.add(image);
  Label label = new Label();
  label.setText(Ode.getMessages().defaultRpcMessage());
  panel.add(label);
  gContainer.add(panel);
  this.add(gContainer);
}
 
Example 3
Source File: StatusPanel.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
   * Initializes and assembles all UI elements shown in the status panel.
   */
  public StatusPanel() {
    HorizontalPanel hpanel = new HorizontalPanel();
    hpanel.setWidth("100%");
    hpanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
    String tosUrl = Ode.getInstance().getSystemConfig().getTosUrl();
    if (!Strings.isNullOrEmpty(tosUrl)) {
      String appInventorFooter =
          "<a href=\"" + tosUrl + "\" target=\"_blank\">" + MESSAGES.privacyTermsLink() + "</a>";
      hpanel.add(new HTML(appInventorFooter));
    }

    // This shows the git version and the date of the build
//    String version = GitBuildId.getVersion();
//    String date = GitBuildId.getDate();
//    if (version != null && date != null) {
//      Label buildId = new Label(MESSAGES.gitBuildId(date, version));
//      hpanel.add(buildId);
//      hpanel.setCellHorizontalAlignment(buildId, HorizontalPanel.ALIGN_RIGHT);
//    }

    initWidget(hpanel);
    setStyleName("ode-StatusPanel");
  }
 
Example 4
Source File: BasicToolBar.java    From geowe-core with GNU General Public License v3.0 6 votes vote down vote up
private void initializew3wPanel() {
	w3wPanel = new HorizontalPanel();
	w3wPanel.setSpacing(5);
	w3wPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
	StyleInjector.inject(".w3wPanel { " + "background: #E0ECF8;"
			+ "border-radius: 5px 10px;" + "opacity: 0.8}");
	w3wPanel.setStyleName("w3wPanel");
	w3wPanel.setWidth("415px");

	wordsLabel = new Label();
	w3wAnchor = new AnchorBuilder().setHref("https://what3words.com/")
			.setText(UIMessages.INSTANCE.what3Words())
			.setTitle("https://what3words.com/").build();
	w3wAnchor.getElement().getStyle().setColor("#FF0000");
	w3wAnchor.setVisible(false);
	w3wPanel.add(w3wAnchor);
	w3wPanel.add(wordsLabel);
}
 
Example 5
Source File: JoinDataDialog.java    From geowe-core with GNU General Public License v3.0 6 votes vote down vote up
private void createSeparatorPanel() {
	separatorPanel = new HorizontalPanel();
	separatorPanel.setSpacing(1);
	separatorPanel.setWidth("100%");
	separatorPanel.addStyleName(ThemeStyles.get().style().borderTop());
	separatorPanel.addStyleName(ThemeStyles.get().style().borderBottom());
	separatorPanel
			.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
	separatorPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
	separatorPanel.add(new Label(UIMessages.INSTANCE
			.separator(DEFAULT_CSV_SEPARATOR)));
	separatorTextField = new TextField();
	separatorTextField.setText(DEFAULT_CSV_SEPARATOR);
	separatorTextField.setWidth(30);

	separatorPanel.add(separatorTextField);
}
 
Example 6
Source File: OpenProjectDialog.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private Widget createUrlToShareAnchor() {
	urlPanel = new HorizontalPanel();
	urlPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
	urlPanel.setSpacing(1);
	urlToShareAnchor = new AnchorBuilder().build();
	urlPanel.add(urlToShareAnchor);
	Image img = new Image(ImageProvider.INSTANCE.externalLink16());
	urlPanel.add(img);
	urlPanel.setVisible(false);
	return urlPanel;
}
 
Example 7
Source File: GeoDataImportDialog.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private Widget createUrlToShareAnchor() {
	urlPanel = new HorizontalPanel();
	urlPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
	urlPanel.setSpacing(1);
	urlToShareAnchor = new AnchorBuilder().build();
	urlPanel.add(urlToShareAnchor);
	Image img = new Image(ImageProvider.INSTANCE.externalLink16());
	urlPanel.add(img);
	urlPanel.setVisible(false);
	return urlPanel;
}
 
Example 8
Source File: HelpDialog.java    From circuitjs1 with GNU General Public License v2.0 4 votes vote down vote up
HelpDialog() {
	super();
	vp = new VerticalPanel();
	setWidget(vp);
	setText(sim.LS("Help"));

	TabPanel tp = new TabPanel();
	vp.add(tp);
	String tab1Title = "EN";
	String tab2Title = "RU";
	String tab3Title = "PL";
	String tab4Title = "DE";
	String tab5Title = "DA";

	      //create tabs 
	tp.add(vpEN = new VerticalPanel(), tab1Title);
	vpEN.setWidth("500px");
	vpEN.add(new HTML("<iframe style=\"border:0;\" src=\"help/EN.html\" width=\"500\" height=\"400\" scrolling=\"auto\" frameborder=\"1\"></iframe>"));
	
	tp.add(vpRU = new VerticalPanel(), tab2Title);
	vpRU.setWidth("500px");
	vpRU.add(new HTML("<iframe style=\"border:0;\" src=\"help/RU.html\" width=\"500\" height=\"400\" scrolling=\"auto\" frameborder=\"1\"></iframe>"));

	tp.add(vpPL = new VerticalPanel(), tab3Title);
	vpPL.setWidth("500px");
	vpPL.add(new HTML("<iframe style=\"border:0;\" src=\"help/PL.html\" width=\"500\" height=\"400\" scrolling=\"auto\" frameborder=\"1\"></iframe>"));

	tp.add(vpDE = new VerticalPanel(), tab4Title);
	vpDE.setWidth("500px");
	vpDE.add(new HTML("<iframe style=\"border:0;\" src=\"help/DE.html\" width=\"500\" height=\"400\" scrolling=\"auto\" frameborder=\"1\"></iframe>"));

	tp.add(vpDA = new VerticalPanel(), tab5Title);
	vpDA.setWidth("500px");
	vpDA.add(new HTML("<iframe style=\"border:0;\" src=\"help/DA.html\" width=\"500\" height=\"400\" scrolling=\"auto\" frameborder=\"1\"></iframe>"));
	
	HorizontalPanel hp = new HorizontalPanel();
	hp.setWidth("100%");
	hp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
	hp.setStyleName("topSpace");
	
	//select first tab
	tp.selectTab(0);

	//set width if tabpanel
	tp.setWidth("500");
	
	vp.add(hp);
	hp.add(okButton = new Button("OK"));
	okButton.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			closeDialog();
		}
	});
	center();
	show();
}
 
Example 9
Source File: ShowBarcodeCommand.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
BarcodeDialogBox(String projectName, String appInstallUrl) {
      super(false, true);
      setStylePrimaryName("ode-DialogBox");
      setText(MESSAGES.barcodeTitle(projectName));

      ClickHandler buttonHandler = new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
          hide();
        }
      };

      Button cancelButton = new Button(MESSAGES.cancelButton());
      cancelButton.addClickHandler(buttonHandler);
      Button okButton = new Button(MESSAGES.okButton());
      okButton.addClickHandler(buttonHandler);
      HTML barcodeQrcode = new HTML("<center>" + BlocklyPanel.getQRCode(appInstallUrl) + "</center>");
      HTML linkQrcode = new HTML("<center><a href=\"" + appInstallUrl + "\" target=\"_blank\">" + appInstallUrl + "</a></center>");
      HorizontalPanel buttonPanel = new HorizontalPanel();
      buttonPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
      HTML warningLabel = new HTML(MESSAGES.barcodeWarning(
          "<a href=\"" + "http://appinventor.mit.edu/explore/ai2/share.html" +
          "\" target=\"_blank\">",
          "</a>"));
      warningLabel.setWordWrap(true);
      warningLabel.setWidth("200px");  // set width to get the text to wrap
      HorizontalPanel warningPanel = new HorizontalPanel();
      warningPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
      warningPanel.add(warningLabel);

      // The cancel button is removed from the panel since it has no meaning in this
      // context.  But the logic is still here in case we want to restore it, and as
      // an example of how to code this stuff in GWT.
      // buttonPanel.add(cancelButton);
      buttonPanel.add(okButton);
      buttonPanel.setSize("100%", "24px");
      VerticalPanel contentPanel = new VerticalPanel();
      contentPanel.add(barcodeQrcode);
      contentPanel.add(linkQrcode);
      contentPanel.add(buttonPanel);
      contentPanel.add(warningPanel);
//      contentPanel.setSize("320px", "100%");
      add(contentPanel);
    }
 
Example 10
Source File: PreviewFileCommand.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(final ProjectNode node) {
  final DialogBox dialogBox = new DialogBox();
  dialogBox.setText(node.getName());
  dialogBox.setStylePrimaryName("ode-DialogBox");

  //setting position of dialog box
  dialogBox.center();
  dialogBox.setAnimationEnabled(true);

  //button element
  final Button closeButton = new Button(MESSAGES.closeFilePreview());
  closeButton.getElement().setId("closeButton");
  closeButton.addClickHandler(new ClickHandler() {
      @Override
      public void onClick(ClickEvent event) {
        dialogBox.hide();
      }
    });

  HorizontalPanel buttonPanel = new HorizontalPanel();
  buttonPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
  buttonPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
  buttonPanel.add(closeButton);

  VerticalPanel dialogPanel = new VerticalPanel();
  dialogPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
  dialogPanel.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE);

  Widget filePreview = generateFilePreview(node);
  dialogPanel.clear();
  dialogPanel.add(filePreview);

  dialogPanel.add(buttonPanel);
  dialogPanel.setWidth("300px");

  dialogBox.setGlassEnabled(false);
  dialogBox.setModal(false);

  // Set the contents of the Widget
  dialogBox.setWidget(dialogPanel);
  dialogBox.center();
  dialogBox.show();
}
 
Example 11
Source File: ProgressBarDialogBox.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
public ProgressBarDialogBox(String serviceName, ProjectNode projectNode) {
  super(false, true);
  this.serviceName = serviceName;
  setStylePrimaryName("ode-DialogBox");
  setText(projectNode.getName() + " " + MESSAGES.ProgressBarFor());

  //click handler for the mini html buttons
  ClickHandler buttonHandler = new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      hide();
      progressBarShow++;
    }
  };

  //declare the ok button
  dismissButton.addClickHandler(buttonHandler);
  HorizontalPanel buttonPanel = new HorizontalPanel();
  buttonPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
  dismissButton.setVisible(false); // we don't need the button unless we get an error

  //warning label
  warningLabel = new HTML("");
  warningLabel.setWordWrap(true);
  warningLabel.setWidth("60em");  // set width to get the text to wrap

  //warning panel
  HorizontalPanel warningPanel = new HorizontalPanel();
  warningPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
  warningPanel.add(warningLabel);

  // button panel
  buttonPanel.add(dismissButton);
  buttonPanel.setSize("100%", "24px");

  //content panel
  VerticalPanel contentPanel = new VerticalPanel();
  contentPanel.add(mpb);
  contentPanel.add(warningPanel);
  contentPanel.add(buttonPanel);
  setWidget(contentPanel);
}
 
Example 12
Source File: Ode.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
private Widget createLoadingWidget(final int pending) {
  final HorizontalPanel container = new HorizontalPanel();
  container.setWidth("100%");
  container.setSpacing(0);
  container.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
  HorizontalPanel panel = new HorizontalPanel();
  Image image = new Image();
  image.setResource(IMAGES.waitingIcon());
  panel.add(image);
  Label label = new Label();
  label.setText(MESSAGES.defaultRpcMessage());
  panel.add(label);
  container.add(panel);
  GalleryClient.getInstance().addListener(new GalleryRequestListener() {
    volatile int count = pending;
    private void hideLoadingWidget() {
      if (container.getParent() != null) {
        container.clear();
        container.removeFromParent();
      }
    }
    @Override
    public boolean onAppListRequestCompleted(GalleryAppListResult appsResult, int requestID, boolean refreshable) {
      if ((--count) <= 0) {
        hideLoadingWidget();
        return true;
      }
      return false;
    }
    @Override
    public boolean onCommentsRequestCompleted(List<GalleryComment> comments) {
      if ((--count) <= 0) {
        hideLoadingWidget();
        return true;
      }
      return false;
    }
    @Override
    public boolean onSourceLoadCompleted(UserProject projectInfo) {
      if ((--count) <= 0) {
        hideLoadingWidget();
        return true;
      }
      return false;
    }
  });
  return container;
}
 
Example 13
Source File: HorizImageListEditorView.java    From dashbuilder with Apache License 2.0 4 votes vote down vote up
@Override
public ImageListEditorView<T> add(final SafeUri uri, final String width, final String height,
                                   final SafeHtml heading, final SafeHtml text, 
                                   final boolean selected, final Command clickCommand) {
    final VerticalPanel panel = new VerticalPanel();
    panel.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE);
    panel.setHeight("100%");

    final Image image = new Image(uri);
    image.setWidth(width);
    image.setHeight(height);
    image.addStyleName(style.image());
    final double alpha = selected ? 1 : 0.2;
    image.getElement().setAttribute("style", "filter: alpha(opacity=5);opacity: " + alpha);

    final Tooltip tooltip = new Tooltip();
    tooltip.setTitle( text.asString() );
    tooltip.setWidget(image);
    tooltip.setContainer("body");
    tooltip.setPlacement(Placement.BOTTOM);
    tooltip.setIsAnimated(false);
    tooltip.setShowDelayMs(100);

    final HTML label = new HTML(heading.asString());
    final HorizontalPanel labelPanel = new HorizontalPanel();
    labelPanel.setWidth("100%");
    labelPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
    labelPanel.add(label);

    panel.add(tooltip);
    panel.add(labelPanel);        
    mainPanel.add(panel);

    image.addClickHandler(e -> {
        tooltip.hide();
        tooltip.destroy();
        clickCommand.execute();
    });

    return this;
}