List of usage examples for com.google.gwt.user.client.ui LayoutPanel setWidgetLeftRight
public void setWidgetLeftRight(IsWidget child, double left, Unit leftUnit, double right, Unit rightUnit)
From source file:at.ac.fhcampuswien.atom.client.gui.frames.TabLayoutPanelCopy.java
License:Apache License
/** * Creates an empty tab panel.//from w w w . ja va 2s .c om * * @param barHeight the size of the tab bar * @param barUnit the unit in which the tab bar size is specified */ public TabLayoutPanelCopy(double barHeight, Unit barUnit) { LayoutPanel panel = new LayoutPanel(); initWidget(panel); // Add the tab bar to the panel. panel.add(tabBar); panel.setWidgetLeftRight(tabBar, 0, Unit.PX, 0, Unit.PX); panel.setWidgetTopHeight(tabBar, 0, Unit.PX, barHeight, barUnit); panel.setWidgetVerticalPosition(tabBar, Alignment.END); // Add the deck panel to the panel. // CHANGE4: styles again: deckPanel.addStyleName(CONTENT_CONTAINER_STYLE); panel.add(deckPanel); panel.setWidgetLeftRight(deckPanel, 0, Unit.PX, 0, Unit.PX); panel.setWidgetTopBottom(deckPanel, barHeight, barUnit, 0, Unit.PX); // Make the tab bar extremely wide so that tabs themselves never wrap. // (Its layout container is overflow:hidden) // CHANGE5: Adapt the TabBar Style element to our needs Style tabBarStyle = tabBar.getElement().getStyle(); tabBarStyle.setHeight(barHeight, barUnit); tabBarStyle.setWidth(BIG_ENOUGH_TO_NOT_WRAP, Unit.PX); // CHANGE6: We don't want the standard GWT styles // tabBar.setStyleName("gwt-TabLayoutPanelTabs"); // setStyleName("gwt-TabLayoutPanel"); }
From source file:com.google.gwt.sample.stockwatcher.client.Panels.java
private Widget loadLayouPanel() { Widget child0 = new Label("Test 1"); Widget child1 = new Label("Test 2"); Widget child2 = new Label("Test 3"); LayoutPanel p = new LayoutPanel(); p.add(child0);/* w w w. j a va2 s.co m*/ p.add(child1); p.add(child2); p.setWidgetLeftWidth(child0, 0, PCT, 50, PCT); // Left panel p.setWidgetRightWidth(child1, 0, PCT, 50, PCT); // Right panel p.setWidgetLeftRight(child2, 5, EM, 5, EM); // Center panel p.setWidgetTopBottom(child2, 5, EM, 5, EM); return p; }
From source file:com.puzzlebazar.client.ui.AspectRatioLayoutPanel.java
License:Apache License
@Override public void onResize() { LayoutPanel parent = (LayoutPanel) getParent(); // Compute width and height available for inside area int parentWidth = parent.getOffsetWidth(); int parentHeight = parent.getOffsetHeight(); int availableWidth = parentWidth - 2 * border; int availableHeight = parentHeight - 2 * border; if (availableWidth > 0 && availableHeight > 0) { float parentRatio = (float) availableWidth / (float) availableHeight; if (parentRatio < aspectRatio) { // availableWidth/availableHeight < desiredWidth/desiredHeight // Set desiredWidth = availableWidth ==> availableHeight > desiredHeight (good!) // Then desiredHeight = availableWidth / aspectRatio int desiredHeight = (int) (availableWidth / aspectRatio); parent.setWidgetLeftRight(this, 0, Unit.PX, 0, Unit.PX); parent.setWidgetTopHeight(this, (parentHeight - desiredHeight) / 2 - border, Unit.PX, desiredHeight + 2 * border, Unit.PX); } else {/* w w w .jav a2 s .c o m*/ // availableWidth/availableHeight > desiredWidth/desiredHeight // Set desiredHeight = availableHeight ==> availableWidth > desiredWidth (good!) // Then desiredWidth = availableHeight * aspectRatio int desiredWidth = (int) (availableHeight * aspectRatio); parent.setWidgetTopBottom(this, 0, Unit.PX, 0, Unit.PX); parent.setWidgetLeftWidth(this, (parentWidth - desiredWidth) / 2 - border, Unit.PX, desiredWidth + 2 * border, Unit.PX); } } else { // Not enough room for inside area, border takes up everything. if (parentWidth < parentHeight) { // parentWidth is smaller, allocate parentWidth x parentWidth parent.setWidgetLeftRight(this, 0, Unit.PX, 0, Unit.PX); parent.setWidgetTopHeight(this, (parentHeight - parentWidth) / 2, Unit.PX, parentWidth, Unit.PX); } else { // parentHeight is smaller, allocate parentHeight x parentHeight parent.setWidgetTopBottom(this, 0, Unit.PX, 0, Unit.PX); parent.setWidgetLeftWidth(this, (parentWidth - parentHeight) / 2, Unit.PX, parentHeight, Unit.PX); } } super.onResize(); }
From source file:com.spinque.gwt.utils.client.widgets.VerticalTabLayoutPanel.java
License:Apache License
/** * Creates an empty tab panel./*w ww . j a v a2 s . co m*/ * * @param barHeight the size of the tab bar * @param barUnit the unit in which the tab bar size is specified */ public VerticalTabLayoutPanel(double barHeight, Unit barUnit) { LayoutPanel panel = new LayoutPanel(); initWidget(panel); // Add the tab bar to the panel. panel.add(tabBar); panel.setWidgetTopBottom(tabBar, 0, Unit.PX, 0, Unit.PX); panel.setWidgetLeftWidth(tabBar, 0, Unit.PX, barHeight, barUnit); panel.setWidgetHorizontalPosition(tabBar, Alignment.END); // Add the deck panel to the panel. deckPanel.addStyleName(CONTENT_CONTAINER_STYLE); panel.add(deckPanel); panel.setWidgetTopBottom(deckPanel, 0, Unit.PX, 0, Unit.PX); panel.setWidgetLeftRight(deckPanel, barHeight, barUnit, 0, Unit.PX); // Make the tab bar extremely wide so that tabs themselves never wrap. // (Its layout container is overflow:hidden) // tabBar.getElement().getStyle().setWidth(BIG_ENOUGH_TO_NOT_WRAP, Unit.PX); tabBar.setStyleName("gwt-TabLayoutPanelTabs"); setStyleName("gwt-TabLayoutPanel"); }
From source file:hu.mapro.gwt.client.widget.MyTabLayoutPanel.java
License:Apache License
/** * Creates an empty tab panel./*ww w . j a v a 2 s.c o m*/ * * @param barHeight the size of the tab bar * @param barUnit the unit in which the tab bar size is specified * @param resource the ClientBundle to use for some internal images. */ public MyTabLayoutPanel(double barHeight, Unit barUnit, Resources resource) { LayoutPanel panel = new LayoutPanel(); initWidget(panel); // Add the tab bar to the panel. Panel navPanel = getTabNavPanel(); navPanel.add(tabBarAnimator); tabBarAnimator.add(tabBar); navPanel.add(previousButtonPanel); navPanel.add(nextButtonPanel); navPanel.getElement().getStyle().setHeight(barHeight, barUnit); setTabAnimiationDuration(0); panel.add(navPanel); panel.setWidgetLeftRight(navPanel, 0, Unit.PX, 0, Unit.PX); panel.setWidgetTopHeight(navPanel, 0, Unit.PX, barHeight, barUnit); panel.setWidgetVerticalPosition(navPanel, Alignment.END); // Add the deck panel to the panel. deckPanel.addStyleName(CONTENT_CONTAINER_STYLE); panel.add(deckPanel); panel.setWidgetLeftRight(deckPanel, 0, Unit.PX, 0, Unit.PX); panel.setWidgetTopBottom(deckPanel, barHeight, barUnit, 0, Unit.PX); // Make the tab bar extremely wide so that tabs themselves never wrap. // (Its layout container is overflow:hidden) tabBar.getElement().getStyle().setWidth(BIG_ENOUGH_TO_NOT_WRAP, Unit.PX); tabBar.setStyleName("gwt-TabLayoutPanelTabs"); setStyleName("gwt-TabLayoutPanel"); setTabNavOffset(0); previous = new Image(resource.previousTab()); previous.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { selectPreviousTab(); } }); next = new Image(resource.nextTab()); next.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { selectNextTab(); } }); next.getElement().getStyle().setCursor(Cursor.POINTER); previous.getElement().getStyle().setCursor(Cursor.POINTER); previousDisabled = new Image(resource.previousTabDisabled()); nextDisabled = new Image(resource.nextTabDisabled()); previousButtonPanel.add(previous); nextButtonPanel.add(next); setNavButtonsVisible(false); }
From source file:hu.mapro.gwt.client.widget.MyTabLayoutPanel.java
License:Apache License
/** * Updates the size of the tabNavPanel./*from w w w. j a v a2s .c o m*/ */ private void setTabPanelSizes(int prev, int next) { LayoutPanel panel = getTabNavPanel(); Unit unit = Unit.PX; if (isRtl()) { panel.setWidgetRightWidth(previousButtonPanel, 0, unit, prev, unit); panel.setWidgetLeftWidth(nextButtonPanel, 0, unit, next, unit); panel.setWidgetLeftRight(tabBarAnimator, next, unit, prev, unit); } else { panel.setWidgetLeftWidth(previousButtonPanel, 0, unit, prev, unit); panel.setWidgetRightWidth(nextButtonPanel, 0, unit, next, unit); panel.setWidgetLeftRight(tabBarAnimator, prev, unit, next, unit); } panel.forceLayout(); }
From source file:hu.mapro.gwt.client.widget.ScrollableTabLayoutPanel.java
License:Apache License
public ScrollableTabLayoutPanel(double barHeight, Unit barUnit) { super(barHeight, barUnit); LayoutPanel panel = (LayoutPanel) getWidget(); tabBar = (FlowPanel) panel.getWidget(0); tabWindow = tabBar.getElement().getParentElement(); tabBarStyle = tabBar.getElement().getStyle(); tabBarStyle.setLeft(tabBarLeft, Unit.PX); panel.setWidgetLeftRight(tabBar, barHeight, barUnit, barHeight, barUnit); panel.setWidgetTopHeight(tabBar, 0, Unit.PX, barHeight, barUnit); leftButton = new FlowPanel(); panel.add(leftButton);/*from w ww . ja va2 s . com*/ panel.setWidgetLeftWidth(leftButton, 0, Unit.PX, barHeight, barUnit); panel.setWidgetTopHeight(leftButton, 0, Unit.PX, barHeight, barUnit); leftButton.addStyleName("gwt-TabLayoutPanelLeft"); leftButton.addStyleName(bundle.css().leftDisabled()); rightButton = new FlowPanel(); panel.add(rightButton); panel.setWidgetRightWidth(rightButton, 0, Unit.PX, barHeight, barUnit); panel.setWidgetTopHeight(rightButton, 0, Unit.PX, barHeight, barUnit); rightButton.addStyleName("gwt-TabLayoutPanelRight"); rightButton.addStyleName(bundle.css().rightDisabled()); addSelectionHandler(new SelectionHandler<Integer>() { @Override public void onSelection(SelectionEvent<Integer> event) { updateButtons(); com.google.gwt.core.client.Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { ensureSelectedVisible(); } }); } }); // addAttachHandler(new Handler() { // @Override // public void onAttachOrDetach(AttachEvent event) { // updateButtons(); // } // }); leftButton.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (getSelectedIndex() > 0) { selectTab(getSelectedIndex() - 1); } } }, ClickEvent.getType()); rightButton.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (getSelectedIndex() < getWidgetCount() - 1) { selectTab(getSelectedIndex() + 1); } } }, ClickEvent.getType()); updateButtons(); }
From source file:org.apache.solr.explorer.client.core.ui.consolepane.log.LogPane.java
License:Apache License
public LogPane() { logger = new AbstractLogger() { public void log(Level level, String message, Throwable t) { LogPane.this.log(level, message, t); }/*from w w w . j a v a 2 s . c o m*/ }; HorizontalPanel toolbar = new HorizontalPanel(); toolbar.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); toolbar.add(new Label("Level:")); addGap(toolbar, "3px"); levelDropDown = new DropDownBox<AbstractLogger.Level>(); for (AbstractLogger.Level level : AbstractLogger.Level.values()) { levelDropDown.addOption(level.name(), level); } levelDropDown.addSelectionHandler(new SelectionHandler<AbstractLogger.Level>() { public void onSelection(SelectionEvent<Logger.Level> event) { logger.setLevel(event.getSelectedItem()); } }); toolbar.add(levelDropDown); addGap(toolbar, "10px"); SimpleButton clearButton = new SimpleButton("Clear", new ClickHandler() { public void onClick(ClickEvent event) { doClear(); } }); toolbar.add(clearButton); logEntries = new FlowPanel(); logEntries.setStylePrimaryName("LogEntries"); logEntriesScrollPanel = new ScrollPanel(logEntries); DOM.setStyleAttribute(logEntriesScrollPanel.getElement(), "border", "2px inset gray"); LayoutPanel main = new LayoutPanel(); main.add(toolbar); main.setWidgetLeftRight(toolbar, 10, Style.Unit.PX, 10, Style.Unit.PX); main.setWidgetTopHeight(toolbar, 10, Style.Unit.PX, 25, Style.Unit.PX); main.add(logEntriesScrollPanel); main.setWidgetLeftRight(logEntriesScrollPanel, 10, Style.Unit.PX, 10, Style.Unit.PX); main.setWidgetTopBottom(logEntriesScrollPanel, 45, Style.Unit.PX, 10, Style.Unit.PX); initWidget(main); setStylePrimaryName("LogPane"); }
From source file:org.cee.webreader.client.error.ErrorDialog.java
License:Apache License
public ErrorDialog() { setHTML("System Error"); LayoutPanel layoutPanel = new LayoutPanel(); setWidget(layoutPanel);/*from w w w.j a v a2s . c o m*/ layoutPanel.setSize("574px", "312px"); InlineLabel nlnlblASystemError = new InlineLabel("A System Error occured:"); layoutPanel.add(nlnlblASystemError); layoutPanel.setWidgetTopHeight(nlnlblASystemError, 0.0, Unit.PX, 21.0, Unit.PX); layoutPanel.setWidgetLeftRight(nlnlblASystemError, 0.0, Unit.PX, 0.0, Unit.PX); InlineLabel nlnlblErrorMessage = new InlineLabel("Error Message:"); layoutPanel.add(nlnlblErrorMessage); layoutPanel.setWidgetLeftWidth(nlnlblErrorMessage, 0.0, Unit.PX, 90.0, Unit.PX); layoutPanel.setWidgetTopHeight(nlnlblErrorMessage, 21.0, Unit.PX, 16.0, Unit.PX); labelErrorMessage = new InlineLabel(""); layoutPanel.add(labelErrorMessage); layoutPanel.setWidgetLeftRight(labelErrorMessage, 0.0, Unit.PX, 0.0, Unit.PX); layoutPanel.setWidgetTopBottom(labelErrorMessage, 43.0, Unit.PX, 37.0, Unit.PX); Button buttonOk = new Button("OK"); layoutPanel.add(buttonOk); layoutPanel.setWidgetLeftWidth(buttonOk, 484.0, Unit.PX, 78.0, Unit.PX); layoutPanel.setWidgetTopHeight(buttonOk, 281.0, Unit.PX, 24.0, Unit.PX); buttonOk.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); }
From source file:org.cloudcoder.app.client.view.CoursesListPanel.java
License:Open Source License
public CoursesListPanel(CloudCoderPage page) { this.page = page; LayoutPanel panel = new LayoutPanel(); panel.setWidth("100%"); panel.setHeight("400px"); this.buttonPanel = new ButtonPanel<CourseAdminAction>(CourseAdminAction.values()) { @Override/* w ww . j a v a2 s .c o m*/ public void onButtonClick(CourseAdminAction action) { switch (action) { case DELETE: handleDelete(); break; default: break; } } @Override public boolean isEnabled(CourseAdminAction action) { CourseAndCourseRegistration selected = view.getSelectedCourse(); return selected != null; } }; buttonPanel.setStyleName("cc-inlineFlowPanel", true); panel.add(buttonPanel); panel.setWidgetLeftRight(buttonPanel, 10.0, Unit.PX, 10.0, Unit.PX); panel.setWidgetTopHeight(buttonPanel, 0.0, Unit.PX, ButtonPanel.HEIGHT_PX, Unit.PX); view = new CoursesListView(); panel.add(view); panel.setWidgetTopBottom(view, 44.0, Unit.PX, 20.0, Unit.PX); panel.setWidgetLeftRight(view, 10.0, Unit.PX, 10.0, Unit.PX); initWidget(panel); }