List of usage examples for com.google.gwt.user.client.ui HasVerticalAlignment ALIGN_TOP
VerticalAlignmentConstant ALIGN_TOP
To view the source code for com.google.gwt.user.client.ui HasVerticalAlignment ALIGN_TOP.
Click Source Link
From source file:app.dnd.drag.DraggableCellDecorator.java
License:Apache License
/** * Get the HTML representation of an image. Visible for testing. * * @param res the {@link ImageResource} to render as HTML * @param valign the vertical alignment * @param isPlaceholder if true, do not include the background image * @return the rendered HTML//w w w.j a v a2s .com */ SafeHtml getImageHtml(ImageResource res, HasVerticalAlignment.VerticalAlignmentConstant valign, boolean isPlaceholder) { // Get the HTML for the image. SafeHtml image; if (isPlaceholder) { image = SafeHtmlUtils.fromTrustedString("<div></div>"); } else { AbstractImagePrototype proto = AbstractImagePrototype.create(res); image = SafeHtmlUtils.fromTrustedString(proto.getHTML()); } // Create the wrapper based on the vertical alignment. if (HasVerticalAlignment.ALIGN_TOP == valign) { return template.imageWrapperTop(direction, image, dragHandlerClass); } else if (HasVerticalAlignment.ALIGN_BOTTOM == valign) { return template.imageWrapperBottom(direction, image, dragHandlerClass); } else { int halfHeight = (int) Math.round(res.getHeight() / 2.0); return template.imageWrapperMiddle(direction, halfHeight, image, dragHandlerClass); } }
From source file:cc.alcina.framework.gwt.client.ClientNotificationsImpl.java
License:Apache License
@Override public void showDialog(String captionHTML, Widget captionWidget, String msg, MessageType messageType, List<Button> extraButtons, String containerStyle) { ensureImages();//from ww w.ja v a 2 s . com HorizontalAlignmentConstant align = messageType == MessageType.ERROR ? HasHorizontalAlignment.ALIGN_LEFT : HasHorizontalAlignment.ALIGN_CENTER; if (dialogBox != null) { dialogBox.hide(); } String title = CommonUtils.friendlyConstant(messageType); dialogBox = new GlassDialogBox(); dialogBox.setAnimationEnabled(dialogAnimationEnabled); AbstractImagePrototype aip = null; String text = ""; switch (messageType) { case INFO: aip = AbstractImagePrototype.create(images.info()); text = "Information"; break; case WARN: aip = AbstractImagePrototype.create(images.warning()); text = "Warning"; break; case ERROR: aip = AbstractImagePrototype.create(images.error()); text = "Problem notification"; break; } dialogBox.setText(text); FlexTable ft = new FlexTable(); containerStyle = containerStyle != null ? containerStyle : (messageType == MessageType.ERROR || !CommonUtils.isNullOrEmpty(msg)) ? "medium" : "narrow"; ft.setCellSpacing(4); ft.setStyleName("alcina-Notification"); ft.addStyleName(containerStyle); FlexCellFormatter cf = (FlexCellFormatter) ft.getCellFormatter(); ft.setWidget(0, 0, aip.createImage()); cf.setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP); cf.setWidth(0, 0, "40px"); FlowPanel fp = new FlowPanel(); fp.setStyleName("text"); Widget capWidget = captionHTML != null ? new HTML(captionHTML) : captionWidget; if (captionHTML != null) { capWidget.setStyleName("caption"); } fp.add(capWidget); if (!CommonUtils.isNullOrEmpty(msg)) { Link nh = new Link("View detail"); nh.addStyleName("pad-5"); dialogHtml = new HTML("<span class='logboxpre'>" + msg.replace("\n", "<br>") + "</span>", true); final ScrollPanel sp = new ScrollPanel(dialogHtml); sp.setStyleName("logbox"); sp.setVisible(containerStyle.equals("wide")); nh.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { sp.setVisible(!sp.isVisible()); } }); if (LooseContext.getBoolean(ClientNotifications.CONTEXT_AUTOSHOW_DIALOG_DETAIL)) { sp.setVisible(true); } fp.add(nh); fp.add(sp); } ft.setWidget(0, 1, fp); cf.setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE); HorizontalPanel hp = new HorizontalPanel(); hp.setSpacing(8); Button closeButton = new Button("Close"); hp.add(closeButton); if (extraButtons != null) { for (Button b : extraButtons) { hp.add(b); } } ft.setWidget(1, 0, hp); cf.setColSpan(1, 0, 2); cf.setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER); closeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { dialogBox.hide(); } }); dialogBox.setWidget(ft); dialogBox.center(); dialogBox.show(); Scheduler.get().scheduleDeferred(() -> closeButton.setFocus(true)); }
From source file:cc.alcina.framework.gwt.client.ide.widget.ActionProgress.java
License:Apache License
private void addToGrid(String label, Widget widget) { InlineLabel l = new InlineLabel(label + ": "); l.setStyleName("caption"); grid.setWidget(row, 0, l);//from w w w .jav a 2s . c om grid.setWidget(row, 1, widget); grid.getCellFormatter().setVerticalAlignment(row, 0, HasVerticalAlignment.ALIGN_TOP); grid.getCellFormatter().setVerticalAlignment(row, 1, HasVerticalAlignment.ALIGN_TOP); row++; }
From source file:cc.alcina.framework.gwt.client.objecttree.ObjectTreeExpandableGridRenderer.java
License:Apache License
@Override protected void renderToPanel(TreeRenderable renderable, ComplexPanel cp, int depth, boolean soleChild, RenderContext renderContext, TreeRenderer parent) { super.renderToPanel(renderable, cp, depth, soleChild, renderContext, parent); if (depth == 0) { cp.remove(ft);/*from w w w. j av a2 s. c om*/ if (useExpandableWidgets) { for (Integer level1Row : level1Rows.keySet()) { Widget level1ContentWidget = level1Rows.get(level1Row); TreeRenderer renderer = ObjectTreeExpandableGridRenderer.this.level1ContentRendererMap .get(level1ContentWidget); if (renderer.isAlwaysExpanded()) { continue; } final ExpandableWidgetWithRendererWrapper expandableWidgetWrapper = new ExpandableWidgetWithRendererWrapper( level1ContentWidget, renderer, renderContext); ft.setWidget(level1Row, 1, expandableWidgetWrapper); ft.setWidget(level1Row, colCountMax + 1, new ToggleLink("[Change]", "[Finished]", new SelectionHandler<Integer>() { public void onSelection(SelectionEvent<Integer> event) { expandableWidgetWrapper.showExpanded(event.getSelectedItem() == 0); LayoutEvents.get().fireDeferredGlobalRelayout(); } })); cellFormatter.setVerticalAlignment(level1Row, colCountMax + 1, HasVerticalAlignment.ALIGN_TOP); } } colCountMax += level1Rows.isEmpty() ? 0 : 1; // sort later String section = null; int rowShift = 0; String defaultSectionName = renderContext.getString(DEFAULT_SECTION_NAME); for (Integer i : level1RendererRows.keySet()) { TreeRenderer renderer = level1RendererRows.get(i); String rs = renderer.section(); rs = rs == null ? defaultSectionName : rs; if (!CommonUtils.equalsWithNullEquality(rs, section)) { section = rs; int rowInsert = i + (rowShift++); ft.insertRow(rowInsert); ft.setWidget(rowInsert, 0, UsefulWidgetFactory.mediumTitleWidget(section)); cellFormatter.setColSpan(rowInsert, 0, colCountMax); } } cp.add(ft); } return; }
From source file:cc.alcina.framework.gwt.client.objecttree.ObjectTreeGridRenderer.java
License:Apache License
@Override protected void renderToPanel(TreeRenderable renderable, ComplexPanel cp, int depth, boolean soleChild, RenderContext renderContext, TreeRenderer parent) { super.renderToPanel(renderable, cp, depth, soleChild, renderContext, parent); if (depth == 0) { cellFormatter = (FlexCellFormatter) ft.getCellFormatter(); int widgetCount = cp.getWidgetCount(); colCountMax = 0;/*from ww w. ja v a 2 s . co m*/ int level1WidgetIndex = -1; int row = -1; int col = 0; for (int i = 0; i < widgetCount; i++) { Widget w = cp.getWidget(0);// we'll be removing widgets, so // we'll always be looking at (0) if (w.getStyleName().contains("level-1")) { level1WidgetIndex = i; row++; col = 0; level1RendererRows.put(row, level1LabelMap.get(w)); } else { colCountMax = Math.max(colCountMax, i - level1WidgetIndex); } ft.setWidget(row, col, w); cellFormatter.setVerticalAlignment(row, col, HasVerticalAlignment.ALIGN_BOTTOM); if (col == 0) { cellFormatter.setStyleName(row, col, "td0"); } boolean isCustomiser = w.getStyleName().contains("customiser"); if (col == 1) {// && isCustomiser) { if (isCustomiser && !level1RendererRows.get(row).isSingleLineCustomiser()) { cellFormatter.setVerticalAlignment(row, 0, HasVerticalAlignment.ALIGN_TOP); cellFormatter.addStyleName(row, 0, "multiline-caption"); } level1Rows.put(row, w); } // note, at this point, getWidget(0) is the _next_ widget boolean nextWidgetIsNewRow = i == widgetCount - 1 || cp.getWidget(0).getStyleName().contains("level-1"); if (nextWidgetIsNewRow) { cellFormatter.setColSpan(row, col, colCountMax - col + 1); } col++; } cp.clear(); cp.add(ft); } return; }
From source file:com.anzsoft.client.ui.UserIndicator.java
License:Open Source License
public UserIndicator(final String nick) { createStatusMenu();/*from w w w .j ava 2 s.c o m*/ setWidth("100%"); setCellPadding(0); setCellSpacing(0); setStyleName("indicator"); FlexCellFormatter formatter = getFlexCellFormatter(); // Setup the links cell /* linksPanel = new HorizontalPanel(); setWidget(0, 0, linksPanel); formatter.setStyleName(0, 0, "indicator-links"); formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT); formatter.setColSpan(0, 0, 2); */ // Setup the title cell setTitleWidget(null); formatter.setStyleName(0, 0, "indicator-title"); getRowFormatter().setVerticalAlign(0, HasVerticalAlignment.ALIGN_TOP); getRowFormatter().setVerticalAlign(1, HasVerticalAlignment.ALIGN_TOP); final ChatIcons icons = ChatIcons.App.getInstance(); statusImg = new Image(); statusImg.setWidth("16px"); statusImg.setHeight("16px"); icons.online().applyTo(statusImg); avatarImg = new Image("images/default_avatar.png"); avatarImg.setWidth("32px"); avatarImg.setHeight("32px"); avatarImg.setStyleName("handler"); avatarImg.addClickListener(new ClickListener() { public void onClick(Widget sender) { JabberApp.instance().showInfoSelf(); } }); nickName = new Label(nick); nickName.setDirection(Direction.LTR); nickName.setWidth("100%"); statusLabel = new Label(); statusLabel.setStyleName("status_label"); statusLabel.setWidth("100%"); statusEditor = new TextBox(); statusEditor.setVisible(false); statusEditor.setWidth("100%"); statusButton = new Button(); statusButton.setMenu(statusMenu); statusButton.setStyleName("Status-Menu-Button"); //statusMenuLabel = new Label(); //statusMenuLabel.setStyleName("status_menu_label"); //addLink(new HTML("<a href=\"http://samespace.anzsoft.com\">SameSpace</a>")); // Add the title and some images to the title bar HorizontalPanel titlePanel = new HorizontalPanel(); titlePanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); titlePanel.setWidth("100%"); titlePanel.setSpacing(3); VerticalPanel statusPanel = new VerticalPanel(); statusPanel.setWidth("100%"); statusPanel.add(nickName); HorizontalPanel hPanel = new HorizontalPanel(); hPanel.setWidth("100%"); hPanel.setSpacing(2); hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); hPanel.add(statusLabel); hPanel.add(statusEditor); hPanel.add(statusButton); statusPanel.add(hPanel); titlePanel.add(statusImg); titlePanel.add(statusPanel); titlePanel.add(avatarImg); titlePanel.setCellWidth(statusImg, "20px"); titlePanel.setCellWidth(statusPanel, "100%"); titlePanel.setCellWidth(avatarImg, "32px"); setTitleWidget(titlePanel); JabberApp.instance().getSession().getUser().addUserListener(new XmppUserListener() { public void onPresenceChanged(XmppPresence presence) { String show = new String(""); PresenceShow presenceShow = presence.getShow(); if (presenceShow != null) show = presenceShow.toString(); String statusString = presence.getStatus(); int priority = presence.getPriority(); boolean avaiable = true; String type = presence.getType(); if (type != null && !type.isEmpty()) { if (type.equalsIgnoreCase("unavailable")) avaiable = false; } status = new XmppContactStatus(show, statusString, priority, avaiable); statusLabel.setText(status.status()); iconFromStatus(status).applyTo(statusImg); } }); statusLabel.addClickListener(new ClickListener() { public void onClick(Widget sender) { statusLabel.setVisible(false); statusEditor.setVisible(true); statusEditor.setText(statusLabel.getText()); } }); statusEditor.addKeyboardListener(new KeyboardListener() { public void onKeyDown(Widget sender, char keyCode, int modifiers) { } public void onKeyPress(Widget sender, char keyCode, int modifiers) { } public void onKeyUp(Widget sender, char keyCode, int modifiers) { if (keyCode == 13) doneChangeStatusString(); } }); statusEditor.addFocusListener(new FocusListener() { public void onFocus(Widget sender) { } public void onLostFocus(Widget sender) { doneChangeStatusString(); } }); XmppVCardFactory.instance().addVCardListener(new VCardListener() { public void onVCard(XmppID jid, XmppVCard vcard) { if (jid.toStringNoResource().equalsIgnoreCase(JabberApp.instance().getJid().toStringNoResource())) { if (!vcard.nickName().isEmpty()) nickName.setText(vcard.fullName()); else if (!vcard.fullName().isEmpty()) nickName.setText(vcard.fullName()); String photoData = vcard.photo(); if (!photoData.isEmpty() && !GXT.isIE) { ImageElement imgEl = avatarImg.getElement().cast(); imgEl.removeAttribute("src"); imgEl.setSrc("data:image;base64," + photoData); } } } }); }
From source file:com.appspot.codsallarts.client.Application.java
License:Apache License
/** * Constructor.//from w w w . ja v a 2 s. com */ public Application() { // Setup the main layout widget FlowPanel layout = new FlowPanel(); initWidget(layout); // Setup the top panel with the title and links createTopPanel(); layout.add(topPanel); // Add the main menu bottomPanel = new HorizontalPanel(); bottomPanel.setWidth("100%"); bottomPanel.setSpacing(0); bottomPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); layout.add(bottomPanel); // Setup the content layout contentLayout = new Grid(2, 1); contentLayout.setStyleName("Application-content-grid"); contentLayout.setCellPadding(0); contentLayout.setCellSpacing(0); contentDecorator = new DecoratorPanel(); contentDecorator.setWidget(contentLayout); contentDecorator.addStyleName(DEFAULT_STYLE_NAME + "-content-decorator"); bottomPanel.add(contentDecorator); if (LocaleInfo.getCurrentLocale().isRTL()) { bottomPanel.setCellHorizontalAlignment(contentDecorator, HasHorizontalAlignment.ALIGN_LEFT); contentDecorator.getElement().setAttribute("align", "LEFT"); } else { bottomPanel.setCellHorizontalAlignment(contentDecorator, HasHorizontalAlignment.ALIGN_RIGHT); contentDecorator.getElement().setAttribute("align", "RIGHT"); } CellFormatter formatter = contentLayout.getCellFormatter(); // Add the content title setContentTitle(new HTML("Welcome")); formatter.setStyleName(0, 0, DEFAULT_STYLE_NAME + "-content-title"); // Add the content wrapper contentWrapper = new SimplePanel(); contentLayout.setWidget(1, 0, contentWrapper); formatter.setStyleName(1, 0, DEFAULT_STYLE_NAME + "-content-wrapper"); setContent(null); //createMainMenu(); //bottomPanel.add(mainMenu); navigationPanel = new SimplePanel(); navigationPanel.addStyleName(DEFAULT_STYLE_NAME + "-nav"); bottomPanel.add(navigationPanel); // Add a window resize handler Window.addResizeHandler(this); }
From source file:com.appspot.codsallarts.client.Application.java
License:Apache License
/** * Create the panel at the top of the page that contains the title and links. *///w w w . jav a2 s . com private void createTopPanel() { boolean isRTL = LocaleInfo.getCurrentLocale().isRTL(); topPanel = new FlexTable(); topPanel.setCellPadding(0); topPanel.setCellSpacing(0); topPanel.setStyleName(DEFAULT_STYLE_NAME + "-top"); FlexCellFormatter formatter = topPanel.getFlexCellFormatter(); // Setup the links cell linksPanel = new HorizontalPanel(); topPanel.setWidget(0, 0, linksPanel); formatter.setStyleName(0, 0, DEFAULT_STYLE_NAME + "-links"); if (isRTL) { formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT); } else { formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT); } formatter.setColSpan(0, 0, 2); // Setup the title cell setTitleWidget(null); formatter.setStyleName(1, 0, DEFAULT_STYLE_NAME + "-title"); // Setup the options cell setOptionsWidget(null); formatter.setStyleName(1, 1, DEFAULT_STYLE_NAME + "-options"); if (isRTL) { formatter.setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_LEFT); } else { formatter.setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_RIGHT); } // Align the content to the top topPanel.getRowFormatter().setVerticalAlign(0, HasVerticalAlignment.ALIGN_TOP); topPanel.getRowFormatter().setVerticalAlign(1, HasVerticalAlignment.ALIGN_TOP); }
From source file:com.areahomeschoolers.baconbits.client.content.calendar.agenda.AgendaView.java
License:Open Source License
@Override public void doLayout() { appointmentAdapterList.clear();//from w w w . j a v a2 s . c o m appointmentGrid.clear(); for (int i = appointmentGrid.getRowCount() - 1; i >= 0; i--) { appointmentGrid.removeRow(i); } // Get the start date, make sure time is 0:00:00 AM Date startDate = (Date) calendarWidget.getDate().clone(); Date today = new Date(); Date endDate = (Date) calendarWidget.getDate().clone(); endDate = ClientDateUtils.addDays(endDate, 1); DateUtils.resetTime(today); DateUtils.resetTime(startDate); DateUtils.resetTime(endDate); int row = 0; for (int i = 0; i < calendarWidget.getDays(); i++) { // Filter the list by date List<Appointment> filteredList = AppointmentUtil.filterListByDate(calendarWidget.getAppointments(), startDate, endDate); if (filteredList != null && filteredList.size() > 0) { appointmentGrid.setText(row, 0, DEFAULT_DATE_FORMAT.format(startDate)); appointmentGrid.getCellFormatter().setVerticalAlignment(row, 0, HasVerticalAlignment.ALIGN_TOP); appointmentGrid.getFlexCellFormatter().setRowSpan(row, 0, filteredList.size()); appointmentGrid.getFlexCellFormatter().setStyleName(row, 0, "dateCell"); int startingCell = 1; // Row styles will alternate, so we set the style accordingly String rowStyle = (i % 2 == 0) ? "row" : "row-alt"; // If a Row represents the current date (Today) then we style it differently if (startDate.equals(today)) { rowStyle += "-today"; } for (Appointment appt : filteredList) { // add the time range String timeSpanString = DEFAULT_TIME_FORMAT.format(appt.getStart()) + " - " + DEFAULT_TIME_FORMAT.format(appt.getEnd()); DefaultInlineHyperlink timeSpanLink = new DefaultInlineHyperlink(timeSpanString.toLowerCase(), PageUrl.event(Integer.parseInt(appt.getId()))); appointmentGrid.setWidget(row, startingCell, timeSpanLink); // add the title and description FlowPanel titleContainer = new FlowPanel(); DefaultInlineHyperlink titleLink = new DefaultInlineHyperlink(appt.getTitle(), PageUrl.event(Integer.parseInt(appt.getId()))); titleContainer.add(titleLink); InlineLabel descLabel = new InlineLabel(" - " + appt.getDescription()); descLabel.setStyleName("descriptionLabel"); titleContainer.add(descLabel); appointmentGrid.setWidget(row, startingCell + 1, titleContainer); // Format the Cells appointmentGrid.getCellFormatter().setVerticalAlignment(row, startingCell, HasVerticalAlignment.ALIGN_TOP); appointmentGrid.getCellFormatter().setVerticalAlignment(row, startingCell + 1, HasVerticalAlignment.ALIGN_TOP); appointmentGrid.getCellFormatter().setStyleName(row, startingCell, "timeCell"); appointmentGrid.getCellFormatter().setStyleName(row, startingCell + 1, "titleCell"); appointmentGrid.getRowFormatter().setStyleName(row, rowStyle); // increment the row // make sure the starting column is reset to 0 startingCell = 0; row++; } } // increment the date endDate = ClientDateUtils.addDays(endDate, 1); startDate = ClientDateUtils.addDays(startDate, 1); } }
From source file:com.areahomeschoolers.baconbits.client.content.calendar.dayview.DayViewBody.java
License:Open Source License
@SuppressWarnings("deprecation") public DayViewBody(HasSettings settings) { initWidget(scrollPanel);/* w ww.j a va2s . c o m*/ this.settings = settings; this.timeline = new DayViewTimeline(settings); this.grid = new DayViewGrid(settings); scrollPanel.setStylePrimaryName("scroll-area"); DOM.setStyleAttribute(scrollPanel.getElement(), "overflowX", "hidden"); DOM.setStyleAttribute(scrollPanel.getElement(), "overflowY", "scroll"); // create the calendar body layout table // calendarBodyLayoutTable.setStyleName("scroll-area"); layout.setCellPadding(0); layout.setBorderWidth(0); layout.setCellSpacing(0); layout.getColumnFormatter().setWidth(1, "99%"); // set vertical alignment VerticalAlignmentConstant valign = HasVerticalAlignment.ALIGN_TOP; layout.getCellFormatter().setVerticalAlignment(0, 0, valign); layout.getCellFormatter().setVerticalAlignment(0, 1, valign); grid.setStyleName("gwt-appointment-panel"); layout.getCellFormatter().setWidth(0, 0, "50px"); DOM.setStyleAttribute(layout.getElement(), "tableLayout", "fixed"); layout.setWidget(0, 0, timeline); layout.setWidget(0, 1, grid); scrollPanel.add(layout); }