List of usage examples for com.google.gwt.user.client.ui HasVerticalAlignment ALIGN_MIDDLE
VerticalAlignmentConstant ALIGN_MIDDLE
To view the source code for com.google.gwt.user.client.ui HasVerticalAlignment ALIGN_MIDDLE.
Click Source Link
From source file:org.gss_project.gss.web.client.GSS.java
License:Open Source License
@Override public void onModuleLoad() { // Initialize the singleton before calling the constructors of the // various widgets that might call GSS.get(). singleton = this; parseUserCredentials();//from w ww.j ava 2 s . c o m topPanel = new TopPanel(GSS.images); topPanel.setWidth("100%"); messagePanel.setWidth("100%"); messagePanel.setVisible(false); search = new Search(images); searchStatus.add(search, DockPanel.WEST); searchStatus.add(userDetailsPanel, DockPanel.EAST); searchStatus.setCellHorizontalAlignment(userDetailsPanel, HasHorizontalAlignment.ALIGN_RIGHT); searchStatus.setCellVerticalAlignment(search, HasVerticalAlignment.ALIGN_MIDDLE); searchStatus.setCellVerticalAlignment(userDetailsPanel, HasVerticalAlignment.ALIGN_MIDDLE); searchStatus.setWidth("100%"); fileList = new FileList(images); searchResults = new SearchResults(images); // Inner contains the various lists. inner.sinkEvents(Event.ONCONTEXTMENU); inner.setAnimationEnabled(true); inner.getTabBar().addStyleName("gss-MainTabBar"); inner.getDeckPanel().addStyleName("gss-MainTabPanelBottom"); inner.add(fileList, createHeaderHTML(AbstractImagePrototype.create(images.folders()), "Files"), true); inner.add(groups, createHeaderHTML(AbstractImagePrototype.create(images.groups()), "Groups"), true); inner.add(searchResults, createHeaderHTML(AbstractImagePrototype.create(images.search()), "Search Results"), true); //inner.add(new CellTreeView(images), createHeaderHTML(AbstractImagePrototype.create(images.search()), "Cell tree sample"), true); inner.setWidth("100%"); inner.selectTab(0); inner.addSelectionHandler(new SelectionHandler<Integer>() { @Override public void onSelection(SelectionEvent<Integer> event) { int tabIndex = event.getSelectedItem(); // TreeItem treeItem = GSS.get().getFolders().getCurrent(); switch (tabIndex) { case 0: // Files tab selected //fileList.clearSelectedRows(); fileList.updateCurrentlyShowingStats(); break; case 1: // Groups tab selected groups.updateCurrentlyShowingStats(); updateHistory("Groups"); break; case 2: // Search tab selected searchResults.clearSelectedRows(); searchResults.updateCurrentlyShowingStats(); updateHistory("Search"); break; } } }); // If the application starts with no history token, redirect to a new "Files" state String initToken = History.getToken(); if (initToken.length() == 0) History.newItem("Files"); // Add history listener to handle any history events History.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { String tokenInput = event.getValue(); String historyToken = handleSpecialFolderNames(tokenInput); try { if (historyToken.equals("Search")) inner.selectTab(2); else if (historyToken.equals("Groups")) inner.selectTab(1); else if (historyToken.equals("Files") || historyToken.length() == 0) inner.selectTab(0); else { /*TODO: CELLTREE PopupTree popupTree = GSS.get().getFolders().getPopupTree(); TreeItem treeObj = GSS.get().getFolders().getPopupTree().getTreeItem(historyToken); SelectionEvent.fire(popupTree, treeObj); */ } } catch (IndexOutOfBoundsException e) { inner.selectTab(0); } } }); // Add the left and right panels to the split panel. splitPanel.setLeftWidget(treeView); splitPanel.setRightWidget(inner); splitPanel.setSplitPosition("25%"); splitPanel.setSize("100%", "100%"); splitPanel.addStyleName("gss-splitPanel"); // Create a dock panel that will contain the menu bar at the top, // the shortcuts to the left, the status bar at the bottom and the // right panel taking the rest. VerticalPanel outer = new VerticalPanel(); outer.add(topPanel); outer.add(searchStatus); outer.add(messagePanel); outer.add(splitPanel); outer.add(statusPanel); outer.setWidth("100%"); outer.setCellHorizontalAlignment(messagePanel, HasHorizontalAlignment.ALIGN_CENTER); outer.setSpacing(4); // Hook the window resize event, so that we can adjust the UI. Window.addResizeHandler(this); // Clear out the window's built-in margin, because we want to take // advantage of the entire client area. Window.setMargin("0px"); // Finally, add the outer panel to the RootPanel, so that it will be // displayed. RootPanel.get().add(outer); // Call the window resized handler to get the initial sizes setup. Doing // this in a deferred command causes it to occur after all widgets' // sizes have been computed by the browser. DeferredCommand.addCommand(new Command() { @Override public void execute() { onWindowResized(Window.getClientHeight()); } }); }
From source file:org.gss_project.gss.web.client.MessagePanel.java
License:Open Source License
/** * Build the panel that contains the icon, the message and the 'clear' link. *///from w ww .j a v a2s. c o m private void buildPanel() { inner.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); inner.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); inner.setSpacing(4); inner.add(message); inner.add(clearMessageLink); inner.setCellVerticalAlignment(message, HasVerticalAlignment.ALIGN_MIDDLE); clearMessageLink.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { FadeOut anim = new FadeOut(simplePanel) { @Override protected void onComplete() { super.onComplete(); hideMessage(); } }; anim.run(500); } }); }
From source file:org.gss_project.gss.web.client.Search.java
License:Open Source License
/** * The search widget constructor./*from w ww. ja v a2 s . c om*/ * * @param images the image bundle */ public Search(final Images images) { tb.setWidth("200px"); tb.setText(TEXT_HINT); tb.setStylePrimaryName("gss-search"); tb.addStyleDependentName("empty"); tb.addFocusHandler(this); tb.addBlurHandler(this); tb.getElement().setId("textBox.search"); tb.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { char keyCode = event.getCharCode(); if (keyCode == KeyCodes.KEY_ENTER) GSS.get().showSearchResults(tb.getText()); else if (keyCode == 27) { // Simulate the proper behavior for the escape key // (27 == ESC). onLostFocus((Widget) event.getSource()); tb.setFocus(false); } } }); Button b = new Button(createHeaderHTML(images.searchButton(), "Search"), new ClickHandler() { @Override public void onClick(ClickEvent event) { GSS.get().showSearchResults(tb.getText()); } }); b.getElement().setId("button.search"); HorizontalPanel panel = new HorizontalPanel(); panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); panel.add(tb); panel.add(b); initWidget(panel); }
From source file:org.gss_project.gss.web.client.TopPanel.java
License:Open Source License
/** * The constructor for the top panel.//from w w w . java 2 s.c om * * @param images the supplied images */ public TopPanel(Images images) { fileMenu = new FileMenu(images); editMenu = new EditMenu(images); groupMenu = new GroupMenu(images); settingsMenu = new SettingsMenu(images); helpMenu = new HelpMenu(images); loading = new LoadingIndicator(images); HorizontalPanel outer = new HorizontalPanel(); outer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); menu = new MenuBar(); menu.setWidth("100%"); menu.setAutoOpen(false); menu.setAnimationEnabled(true); menu.setStyleName("toolbarmenu"); Command quitCommand = new Command() { @Override public void execute() { QuitDialog dlg = new QuitDialog(); dlg.center(); } }; MenuItem quitItem = new MenuItem("<table style='font-size: 100%'><tr><td>" + AbstractImagePrototype.create(images.exit()).getHTML() + "</td><td>Quit</td></tr></table>", true, quitCommand); quitItem.getElement().setId("topMenu.quit"); MenuItem fileItem = new MenuItem("<table style='font-size: 100%'><tr><td>" + AbstractImagePrototype.create(images.folder()).getHTML() + "</td><td>File</td></tr></table>", true, new MenuBar(true)) { @Override public MenuBar getSubMenu() { return fileMenu.createMenu(); } }; fileItem.getElement().setId("topMenu.file"); MenuItem editItem = new MenuItem("<table style='font-size: 100%'><tr><td>" + AbstractImagePrototype.create(images.edit()).getHTML() + "</td><td>Edit</td></tr></table>", true, new MenuBar(true)) { @Override public MenuBar getSubMenu() { return editMenu.createMenu(); } }; editItem.getElement().setId("topMenu.edit"); MenuItem groupItem = new MenuItem("<table style='font-size: 100%'><tr><td>" + AbstractImagePrototype.create(images.group()).getHTML() + "</td><td>Group</td></tr></table>", true, groupMenu.getContextMenu()); groupItem.getElement().setId("topMenu.group"); MenuItem configureItem = new MenuItem("<table style='font-size: 100%'><tr><td>" + AbstractImagePrototype.create(images.configure()).getHTML() + "</td><td>Settings</td></tr></table>", true, settingsMenu.getContextMenu()); configureItem.getElement().setId("topMenu.settings"); MenuItem helpItem = new MenuItem("<table style='font-size: 100%'><tr><td>" + AbstractImagePrototype.create(images.help()).getHTML() + "</td><td>Help</td></tr></table>", true, new MenuBar(true)) { @Override public MenuBar getSubMenu() { return helpMenu.createMenu(); } }; helpItem.getElement().setId("topMenu.help"); menu.addItem(quitItem); menu.addItem(fileItem); menu.addItem(editItem); menu.addItem(groupItem); menu.addItem(configureItem); menu.addItem(helpItem); outer.setSpacing(2); outer.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); outer.setCellVerticalAlignment(menu, HasVerticalAlignment.ALIGN_MIDDLE); outer.add(menu); outer.setStyleName("toolbar"); outer.add(loading); HTML logos = new HTML("<table><tr><td><a href='http://pithos.grnet.gr' target='gss'>" + AbstractImagePrototype.create(images.gssLogo()).getHTML() + "</a><a href='http://www.grnet.gr/' " + "target='grnet'>" + AbstractImagePrototype.create(images.grnetLogo()).getHTML() + "</a></td></tr></table>"); outer.add(logos); outer.setCellHorizontalAlignment(logos, HasHorizontalAlignment.ALIGN_RIGHT); initWidget(outer); }
From source file:org.gwm.client.impl.AbstractIconBar.java
License:Apache License
public void addFrame(GFrame gframe) { DefaultGFrame frame = (DefaultGFrame) (gframe); HorizontalPanel icon = new HorizontalPanel(); HorizontalPanel iconLayout = new HorizontalPanel(); icon.setStyleName(getItemTheme(frame, "DeskTop-MinimizedFrameBar")); Label label = new Label(frame.getCaption()); label.setStyleName(getItemTheme(gframe, "Frame-TopBar-minimized")); Label restoreButton = new Label(""); restoreButton.setStyleName(getItemTheme(gframe, "Frame-TopBar-RestoreButton")); Image titleIcon = frame.getTitleIcon(); if (titleIcon != null) { iconLayout.add(titleIcon);//ww w . ja va2 s .c o m iconLayout.setCellVerticalAlignment(titleIcon, HasVerticalAlignment.ALIGN_MIDDLE); } iconLayout.add(label); icon.add(iconLayout); icon.add(restoreButton); buttonFrame.put(restoreButton, frame); buttonIcon.put(restoreButton, icon); buttonByFrame.put(frame, restoreButton); iconByFrame.put(frame, icon); addMinimizedWindow(icon); restoreButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { GFrame myFrame = (GFrame) buttonFrame.get(sender); parent.deIconify(myFrame); } }); }
From source file:org.gwm.client.impl.DefaultGFrame.java
License:Apache License
protected void buildGui() { this.ui = new FlexTable(); if (freeminimized) { this.ui.setWidget(0, 0, topBar); super.setWidget(ui); return;// w ww. j av a 2s. c o m } if (this.width < this.minWidth) { this.width = this.minWidth; } if (this.height < this.minHeight) { this.height = this.minHeight; } setSize(this.width, this.height); topRow.setWidget(0, 0, imgTopLeft); topRow.setWidget(0, 1, topBar); topRow.setWidget(0, 2, imgTopRight); bottomRow.setHTML(0, 0, " "); bottomRow.setWidget(0, 1, imgBot); bottomRow.setHTML(0, 2, " "); centerLeftLabel = new Label(); if (url != null) { setUrl(url); } centerRow.setWidget(0, 0, centerLeftLabel); centerRow.setWidget(0, 1, myContent); centerRow.getFlexCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER); centerRightLabel = new Label(); centerRow.setWidget(0, 2, centerRightLabel); setResizable(resizable); ui.getCellFormatter().setHeight(1, 0, "100%"); ui.getCellFormatter().setWidth(1, 0, "100%"); ui.getCellFormatter().setAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE); ui.setCellPadding(0); ui.setCellSpacing(0); ui.setWidget(0, 0, topRow); ui.setWidget(1, 0, centerRow); ui.setWidget(2, 0, bottomRow); super.setWidget(ui); setTheme(currentTheme); topRow.setCellPadding(0); topRow.setCellSpacing(0); topRow.setHeight("100%"); topRow.getCellFormatter().setWidth(0, 1, "100%"); centerRow.setCellPadding(0); centerRow.setCellSpacing(0); centerRow.setWidth("100%"); centerRow.setHeight("100%"); centerRow.setBorderWidth(0); bottomRow.setCellPadding(0); bottomRow.setCellSpacing(0); bottomRow.setWidth("100%"); // bottomRow.getCellFormatter().setWidth(0, 1, "100%"); if (visible) { setSize(getOffsetWidth(), getOffsetHeight()); } }
From source file:org.gwt.mosaic.ui.client.layout.CustomGridLayout.java
License:Apache License
/** * Lays out the specified {@link LayoutPanel} using this layout. * <p>/*from www . j ava2s . co m*/ * The grid layout manager determines the size of individual widgets by * dividing the free space in the panel into equal-sized portions according to * the number of rows and columns in the layout. The container's free space * equals the container's size minus any margins and any specified horizontal * or vertical gap. * * @param layoutPanel the panel in which to do the layout * * @see org.gwt.mosaic.ui.client.layout.LayoutManager#layoutPanel(org.gwt.mosaic.ui.client.layout.LayoutPanel) */ public void layoutPanel(LayoutPanel layoutPanel) { try { if (layoutPanel == null || !init(layoutPanel)) { return; } final Dimension box = DOM.getClientSize(layoutPanel.getElement()); final int left = paddingLeftMeasure.sizeOf(layoutPanel); final int top = paddingTopMeasure.sizeOf(layoutPanel); int width = box.width - (left + paddingRightMeasure.sizeOf(layoutPanel)); int height = box.height - (top + paddingBottomMeasure.sizeOf(layoutPanel)); final int spacing = layoutPanel.getWidgetSpacing(); // adjust for spacing width -= ((cols - 1) * spacing); height -= ((rows - 1) * spacing); final int colWidth = width / cols; final int rowHeight = height / rows; for (int r = 0; r < rows; r++) { for (int c = 0; c < cols; c++) { Widget widget = widgetMatrix[c][r]; if (widget == null || widget == SPAN) { continue; } if (widget instanceof InternalDecoratorPanel) { widget = ((InternalDecoratorPanel) widget).getWidget(); } int cellWidth; int cellHeight; final GridLayoutData layoutData = (GridLayoutData) widget.getLayoutData(); final Widget parent = widget.getParent(); if (parent instanceof InternalDecoratorPanel) { final InternalDecoratorPanel decPanel = (InternalDecoratorPanel) parent; final int borderSizes[] = decPanel.getBorderSizes(); final Dimension decPanelFrameSize = new Dimension(borderSizes[1] + borderSizes[3], borderSizes[0] + borderSizes[0]); cellWidth = colWidth * layoutData.colspan - decPanelFrameSize.width + spacing * (layoutData.colspan - 1); cellHeight = rowHeight * layoutData.rowspan - decPanelFrameSize.height + spacing * (layoutData.rowspan - 1); } else { cellWidth = colWidth * layoutData.colspan + spacing * (layoutData.colspan - 1); cellHeight = rowHeight * layoutData.rowspan + spacing * (layoutData.rowspan - 1); } HorizontalAlignmentConstant hAlignment = layoutData.getHorizontalAlignment(); if (hAlignment == null) { hAlignment = getHorizontalAlignment(); } Dimension prefSize = null; if (hAlignment == null) { layoutData.targetLeft = left + (spacing + colWidth) * c; layoutData.targetWidth = cellWidth; } else { // (ggeorg) this call to WidgetHelper.getPreferredSize() is // required even for ALIGN_LEFT prefSize = new Dimension(preferredWidthMeasure.sizeOf(widget), preferredHeightMeasure.sizeOf(widget)); if (HasHorizontalAlignment.ALIGN_LEFT == hAlignment) { layoutData.targetLeft = left + (spacing + colWidth) * c; } else if (HasHorizontalAlignment.ALIGN_CENTER == hAlignment) { layoutData.targetLeft = left + (spacing + colWidth) * c + (cellWidth / 2) - prefSize.width / 2; } else { layoutData.targetLeft = left + (spacing + colWidth) * c + cellWidth - prefSize.width; } layoutData.targetWidth = prefSize.width; } VerticalAlignmentConstant vAlignment = layoutData.getVerticalAlignment(); if (vAlignment == null) { vAlignment = getVerticalAlignment(); } if (vAlignment == null) { layoutData.targetTop = top + (spacing + rowHeight) * r; layoutData.targetHeight = cellHeight; } else { if (prefSize == null) { // (ggeorg) this call to WidgetHelper.getPreferredSize() is // required even for ALIGN_TOP prefSize = new Dimension(preferredWidthMeasure.sizeOf(widget), preferredHeightMeasure.sizeOf(widget)); } if (HasVerticalAlignment.ALIGN_TOP == vAlignment) { layoutData.targetTop = top + (spacing + rowHeight) * r; } else if (HasVerticalAlignment.ALIGN_MIDDLE == vAlignment) { layoutData.targetTop = top + (spacing + rowHeight) * r + (cellHeight / 2) - prefSize.height / 2; } else { layoutData.targetTop = top + (spacing + rowHeight) * r + cellHeight - prefSize.height; } layoutData.targetHeight = prefSize.height; } if (layoutPanel.isAnimationEnabled()) { layoutData.setSourceLeft(widget.getAbsoluteLeft() - layoutPanel.getAbsoluteLeft()); layoutData.setSourceTop(widget.getAbsoluteTop() - layoutPanel.getAbsoluteTop()); layoutData.setSourceWidth(widget.getOffsetWidth()); layoutData.setSourceHeight(widget.getOffsetHeight()); } } } super.layoutPanel(layoutPanel); } catch (Exception e) { GWT.log(e.getMessage(), e); Window.alert(this.getClass().getName() + ".layoutPanel(): " + e.getLocalizedMessage()); } }
From source file:org.gwtaf.widgets.expanding.gin.ExpandableTableDepGinModule.java
License:Apache License
/** * Returns the {@link FlexTable} to be used by {@link ExpandableTable} * implementations./*from w ww .ja va2s . c o m*/ * * @return the {@link FlexTable} to be used by {@link ExpandableTable} * implementations. */ @Provides @ExpandableTableDep public FlexTable mainPanelProvider() { FlexTable mainPanel = new FlexTable(); // TODO: removing this line breaks tests. Instantiates 0'th row? NEEDS // FIX mainPanel.getRowFormatter().setVerticalAlign(0, HasVerticalAlignment.ALIGN_MIDDLE); return mainPanel; }
From source file:org.gwtlib.client.table.ui.PagingBar.java
License:Apache License
protected Widget create() { HorizontalPanel panel = new HorizontalPanel(); panel.setSpacing(0);//from w w w . java 2s. com panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); if (_positionWidget != null) panel.add(_positionWidget); if (_loadingWidget != null) panel.add(_loadingWidget); if (_browserWidget != null) panel.add(_browserWidget); panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); if (_gotoWidget != null) panel.add(_gotoWidget); if (_pageSizesWidget != null) panel.add(_pageSizesWidget); return panel; }
From source file:org.gwtlib.client.table.ui.PagingBar.java
License:Apache License
protected Widget createGotoWidget() { final TextBox gotoPage = new TextBox(); int maxlen = String.valueOf(computeNumPages()).length(); gotoPage.setMaxLength(maxlen);//from w w w .j ava 2 s .c o m gotoPage.setVisibleLength(maxlen); final PushButton go = new PushButton(); go.setStylePrimaryName(STYLE_GOTO_BUTTON); go.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { setPage(Integer.parseInt(gotoPage.getText()) - 1); gotoPage.setText(""); go.setEnabled(false); fireChange(); } }); go.setEnabled(false); gotoPage.addKeyDownHandler(new KeyDownHandler() { public void onKeyDown(final KeyDownEvent event) { final int keyCode = event.getNativeKeyCode(); DeferredCommand.addCommand(new Command() { public void execute() { int page = -1; try { page = Integer.parseInt(gotoPage.getText()) - 1; } catch (NumberFormatException e) { } go.setEnabled(page >= 0 && page < computeNumPages()); if (keyCode == KeyCodes.KEY_ENTER && go.isEnabled()) { setPage(Integer.parseInt(gotoPage.getText()) - 1); gotoPage.setText(""); go.setEnabled(false); fireChange(); } } }); } }); HorizontalPanel panel = new HorizontalPanel(); panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); panel.add(new HTML(_messages.go())); panel.add(gotoPage); panel.add(go); panel.setStylePrimaryName(STYLE_GOTO); return panel; }