/** * Page widgets. * * @param cellTree the cell tree */ public void createPageView(CellTree cellTree) { this.cellTree = cellTree; mainPanel.setStyleName("div-wrapper"); // main div SimplePanel leftPanel = new SimplePanel(); leftPanel.getElement().setId("leftPanel_SimplePanel"); leftPanel.setStyleName("div-first bottomPadding10px"); // left side div which will have tree SimplePanel rightPanel = new SimplePanel(); rightPanel.getElement().setId("rightPanel_SimplePanel"); rightPanel.setStyleName("div-second"); // right div having tree creation inputs. VerticalPanel treePanel = new VerticalPanel(); treePanel.getElement().setId("treePanel_VerticalPanel"); HorizontalPanel expandCollapse = new HorizontalPanel(); expandCollapse.getElement().setId("expandCollapse_HorizontalPanel"); expandCollapse.setStyleName("leftAndTopPadding"); expandCollapse.setSize("100px", "20px"); buttonExpand.setStylePrimaryName("expandAllButton"); buttonCollapse.setStylePrimaryName("collapseAllButton"); buttonExpand.setTitle("Expand All (Shift +)"); buttonCollapse.setTitle("Collapse All (Shift -)"); expandCollapse.add(buttonExpand); expandCollapse.add(buttonCollapse); buttonExpand.setFocus(true); buttonCollapse.setVisible(true); treePanel.add(expandCollapse); treePanel.add(cellTree); leftPanel.add(treePanel); SimplePanel bottomSavePanel = new SimplePanel(); bottomSavePanel.getElement().setId("bottomSavePanel_SimplePanel"); bottomSavePanel.setStyleName("div-first buttonPadding"); VerticalPanel vp = new VerticalPanel(); HorizontalPanel savePanel = new HorizontalPanel(); savePanel.getElement().setId("savePanel_VerticalPanel"); savePanel.add(new SpacerWidget()); // savePanel.add(errorMessageDisplay); vp.add(successMessageDisplay); // saveBtn.setTitle("Ctrl+Alt+s"); savePanel.add(saveBtn); validateBtn.setTitle("Validate"); savePanel.add(validateBtn); vp.add(warningMessageDisplay); vp.add(savePanel); bottomSavePanel.add(vp); SimplePanel errPanel = new SimplePanel(); errPanel.getElement().setId("errPanel_SimplePanel"); errPanel.add(errorMessageDisplay); mainPanel.add(errPanel); mainPanel.add(leftPanel); mainPanel.add(rightPanel); mainPanel.add(bottomSavePanel); focusPanel.addKeyDownHandler(this); focusPanel.addFocusHandler(this); cellTreeHandlers(); }
public void run(final RootPanel rp, final String nick) { if (Cookies.getCookie(nick) == null) Cookies.setCookie(nick, "" + 0); cl.setPageSize(500); final Button sendMessage = new Button( "sendMessage", new ClickHandler() { public void onClick(ClickEvent event) { if (!message.getText().equals("")) { new Post().postJson(SERVERURL, nick.toString(), message.getText()); message.setText(""); } } }); rp.get("mainDiv2").setVisible(true); message.getElement().setAttribute("placeholder", "Introduce your message"); message.getElement().setAttribute("id", "message"); cl.getElement().setAttribute("id", "chatBox"); sendMessage.getElement().setAttribute("id", "sendMessage"); sendMessage.setText("Send"); vp.getElement().setAttribute("id", "verticalPanel"); hp.getElement().setAttribute("id", "horizontalPanel"); panel.getElement().setAttribute("id", "scroller"); hp.add(message); hp.add(sendMessage); panel.add(cl); vp.add(panel); vp.add(hp); rp.get("mainDiv2").add(vp); Timer t = new Timer() { @Override public void run() { getMessages(); if (chatList != null && Integer.parseInt(Cookies.getCookie(nick)) < chatList.size()) { cl.setRowCount(chatList.size() + 1, true); cl.setRowData( Integer.parseInt(Cookies.getCookie(nick)), chatList.subList(Integer.parseInt(Cookies.getCookie(nick)), chatList.size())); panel.setVerticalScrollPosition(panel.getMaximumVerticalScrollPosition() - 1); Cookies.setCookie(nick, "" + chatList.size()); } } }; t.scheduleRepeating(1000); }
public Widget asWidget() { HorizontalPanel layout = new HorizontalPanel(); layout.getElement().setAttribute("style", "padding:4px;"); server = new ComboBox(); server.addValueChangeHandler( new ValueChangeHandler<String>() { @Override public void onValueChange(final ValueChangeEvent<String> event) { Scheduler.get() .scheduleEntry( new Scheduler.ScheduledCommand() { @Override public void execute() { // Console.MODULES.getEventBus().fireEvent(new // ServerSelectionEvent(event.getValue())); } }); } }); Label hostLabel = new Label("Server:"); hostLabel.setStyleName("header-label"); layout.add(hostLabel); Widget hWidget = server.asWidget(); layout.add(hWidget); // combo box use all available space hWidget.getElement().getParentElement().setAttribute("width", "100%"); return layout; }
protected Widget createCurrentSelectionWidget() { if (!displayerSettings.isFilterEnabled()) return null; Set<String> columnFilters = filterColumns(); if (columnFilters.isEmpty()) return null; HorizontalPanel panel = new HorizontalPanel(); panel.getElement().setAttribute("cellpadding", "2"); for (String columnId : columnFilters) { List<Interval> selectedValues = filterIntervals(columnId); DataColumn column = dataSet.getColumnById(columnId); for (Interval interval : selectedValues) { String formattedValue = formatInterval(interval, column); panel.add(new Label(formattedValue)); } } Anchor anchor = new Anchor(GoogleDisplayerConstants.INSTANCE.googleDisplayer_resetAnchor()); panel.add(anchor); anchor.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { filterReset(); // Update the chart view in order to reflect the current selection // (only if not has already been redrawn in the previous filterUpdate() call) if (!displayerSettings.isFilterSelfApplyEnabled()) { updateVisualization(); } } }); return panel; }
private String getHeaderString(String text, ImageResource imageResource) { HorizontalPanel hPanel = new HorizontalPanel(); hPanel.setSpacing(0); hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); hPanel.add(new Image(imageResource)); HTML headerText = new HTML(text); headerText.setStyleName("cw-StackPanelHeader"); hPanel.add(headerText); return hPanel.getElement().getString(); }
/** * Get a string representation of the header that includes an image and some text. * * @param text the header text * @param image the {@link ImageResource} to add next to the header * @return the header as a string */ @ShowcaseSource private String getHeaderString(String text, ImageResource image) { // Add the image and text to a horizontal panel HorizontalPanel hPanel = new HorizontalPanel(); hPanel.setSpacing(0); hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); hPanel.add(new Image(image)); HTML headerText = new HTML(text); headerText.setStyleName("cw-StackPanelHeader"); hPanel.add(headerText); // Return the HTML string for the panel return hPanel.getElement().getString(); }
@Override public Widget asWidget() { if (widget == null) { widget = new HorizontalPanel(); int barHeight = 210; int topPadding = 50; int barWidth = 250; int right = 5; widget.getElement().getStyle().setPosition(Position.FIXED); widget.getElement().getStyle().setRight(right, Unit.PX); widget.getElement().getStyle().setTop(topPadding, Unit.PX); widget.getElement().getStyle().setHeight(barHeight, Unit.PX); widget.getElement().getStyle().setWidth(barWidth, Unit.PX); widget.getElement().getStyle().setVerticalAlign(VerticalAlign.MIDDLE); widget.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); widget.setVisible(false); initializeStatusPanel(); widget.add(statusPanel); } return widget; }
/** * Creates a header with the specified appearance. * * @param appearance the appearance of the header */ public Header(HeaderAppearance appearance) { this.appearance = appearance; SafeHtmlBuilder sb = new SafeHtmlBuilder(); this.appearance.render(sb); setElement((Element) XDOM.create(sb.toSafeHtml())); addStyleName("x-small-editor"); widgetPanel = new HorizontalPanel(); widgetPanel.addStyleName("x-panel-toolbar"); XElement barElem = appearance.getBarElem(getElement()); barElem.appendChild(widgetPanel.getElement()); if (tools.size() > 0) { for (int i = 0; i < tools.size(); i++) { widgetPanel.add(tools.get(i)); } } else { widgetPanel.setVisible(false); } ComponentHelper.setParent(this, widgetPanel); appearance.getTextElem(getElement()).setId(getId() + "-label"); setText(text); if (icon != null) { setIcon(icon); } getFocusSupport().setIgnore(true); }
@Override public Widget createWidget() { LayoutPanel layout = new LayoutPanel(); FakeTabPanel titleBar = new FakeTabPanel("Socket Binding Groups"); layout.add(titleBar); ToolStrip toolstrip = new ToolStrip(); toolstrip.addToolButtonRight( new ToolButton( "Add", new ClickHandler() { @Override public void onClick(ClickEvent event) { presenter.launchNewSocketDialogue(); } })); layout.add(toolstrip); // ----------- VerticalPanel panel = new VerticalPanel(); panel.setStyleName("rhs-content-panel"); ContentHeaderLabel nameLabel = new ContentHeaderLabel("Socket Binding Declarations"); HorizontalPanel horzPanel = new HorizontalPanel(); horzPanel.getElement().setAttribute("style", "width:100%;"); // Image image = new Image(Icons.INSTANCE.deployment()); // horzPanel.add(image); // image.getElement().getParentElement().setAttribute("width", "25"); horzPanel.add(nameLabel); panel.add(horzPanel); socketTable = new SocketTable(); HorizontalPanel tableOptions = new HorizontalPanel(); tableOptions.getElement().setAttribute("cellpadding", "2px"); groupFilter = new ComboBox(); groupFilter.addValueChangeHandler( new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { presenter.onFilterGroup(event.getValue()); } }); Widget groupFilterWidget = groupFilter.asWidget(); groupFilterWidget.getElement().setAttribute("style", "width:200px;"); tableOptions.add(new Label("Socket Binding Group:")); tableOptions.add(groupFilterWidget); tableOptions.getElement().setAttribute("style", "float:right;"); panel.add(tableOptions); DefaultCellTable socketTableWidget = socketTable.asWidget(); panel.add(socketTableWidget); DefaultPager pager = new DefaultPager(); pager.setPage(0); pager.setPageSize(6); pager.setDisplay(socketTableWidget); panel.add(pager); ScrollPanel scroll = new ScrollPanel(panel); layout.add(scroll); layout.setWidgetTopHeight(titleBar, 0, Style.Unit.PX, 26, Style.Unit.PX); layout.setWidgetTopHeight(toolstrip, 26, Style.Unit.PX, 30, Style.Unit.PX); layout.setWidgetTopHeight(scroll, 56, Style.Unit.PX, 100, Style.Unit.PCT); // ----------- ToolStrip detailToolStrip = new ToolStrip(); editBtn = new ToolButton(Console.CONSTANTS.common_label_edit()); ClickHandler editHandler = new ClickHandler() { @Override public void onClick(ClickEvent event) { SocketBinding editedEntity = form.getEditedEntity(); if (editBtn.getText().equals(Console.CONSTANTS.common_label_edit())) { presenter.editSocketBinding(editedEntity); } else { presenter.saveSocketBinding( editedEntity.getName(), editedEntity.getGroup(), form.getChangedValues()); } } }; editBtn.addClickHandler(editHandler); detailToolStrip.addToolButton(editBtn); ClickHandler clickHandler = new ClickHandler() { @Override public void onClick(ClickEvent event) { SocketBinding socket = form.getEditedEntity(); Feedback.confirm( "Delete Socket Binding", "Really delete this socket binding '" + socket.getName() + "' ?", new Feedback.ConfirmationHandler() { @Override public void onConfirmation(boolean isConfirmed) { if (isConfirmed) { presenter.onDelete(form.getEditedEntity()); } } }); } }; ToolButton deleteBtn = new ToolButton(Console.CONSTANTS.common_label_delete()); deleteBtn.addClickHandler(clickHandler); detailToolStrip.addToolButton(deleteBtn); panel.add(new ContentGroupLabel("Socket Binding")); panel.add(detailToolStrip); // --- form = new Form<SocketBinding>(SocketBinding.class); form.setNumColumns(2); TextItem nameItem = new TextItem("name", "Name"); TextItem interfaceItem = new TextItem("interface", "Interface"); NumberBoxItem portItem = new NumberBoxItem("port", "Port"); TextBoxItem multicastItem = new TextBoxItem("multiCastAddress", "Multicast Address"); NumberBoxItem multicastPortItem = new NumberBoxItem("multiCastPort", "Multicast Port"); form.setFields(nameItem, interfaceItem, portItem, multicastItem, multicastPortItem); form.bind(socketTable.getCellTable()); Widget formWidget = form.asWidget(); form.setEnabled(false); final FormHelpPanel helpPanel = new FormHelpPanel( new FormHelpPanel.AddressCallback() { @Override public ModelNode getAddress() { ModelNode address = new ModelNode(); address.add("socket-binding-group", form.getEditedEntity().getGroup()); address.add("socket-binding", "*"); return address; } }, form); panel.add(helpPanel.asWidget()); panel.add(formWidget); // ------------------------------------------ return layout; }
public ComboBox(String cssSuffix) { cellList = new CellList<String>( new TextCell() { @Override public void render(Context context, String data, SafeHtmlBuilder sb) { String cssName = (context.getIndex() % 2 > 0) ? "combobox-item combobox-item-odd" : "combobox-item"; if (data.equals(currentValue.getText())) cssName += " combobox-item-selected"; sb.append(TEMPLATE.item(cssName, data)); } }); final SingleSelectionModel<String> selectionModel = new SingleSelectionModel<String>(); cellList.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler( new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { String selectedValue = selectionModel.getSelectedObject(); currentValue.setHTML(selectedValue); popup.hide(); onSelection(selectedValue); } }); final String panelId = "popup_" + HTMLPanel.createUniqueId(); popup = new PopupPanel(true, true) { @Override protected void onPreviewNativeEvent(Event.NativePreviewEvent event) { if (Event.ONKEYUP == event.getTypeInt()) { if (event.getNativeEvent().getKeyCode() == ESCAPE) { // Dismiss when escape is pressed popup.hide(); } } } public void onBrowserEvent(Event event) { super.onBrowserEvent(event); } }; popup.getElement().setId(panelId); popup.setStyleName("default-popup"); popup.setWidget(cellList); currentValue = new HTML(" "); currentValue.setStyleName("combobox-value" + cssSuffix); header = new HorizontalPanel(); header.setStyleName("combobox" + cssSuffix); header.add(currentValue); Image img = new Image(Icons.INSTANCE.comboPicker()); header.add(img); currentValue.getElement().getParentElement().setAttribute("width", "100%"); img.getParent().getElement().setAttribute("width", "18"); header.getElement().setAttribute("width", "100%"); header.getElement().setAttribute("cellspacing", "0"); header.getElement().setAttribute("cellpadding", "0"); header.getElement().setAttribute("border", "0"); ClickHandler clickHandler = new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { openPanel(); } }; currentValue.addClickHandler(clickHandler); img.addClickHandler(clickHandler); }
@SuppressWarnings("deprecation") public void onMouseMove(MouseMoveEvent event) { if (startY < 0 && startX < 0) { return; } if (isDisabled()) { Event.releaseCapture(getElement()); mouseMoveStarted = false; startY = -1; startX = -1; removeGlobalResizeStyle(); return; } int currentY = event.getClientY(); int currentX = event.getClientX(); int moveY = (currentY - startY); int moveX = (currentX - startX); if ((moveY < 5 && moveY > -6) && (moveX < 5 && moveX > -6)) { return; } if (!mouseMoveStarted) { setWidth(moveWidth); getElement().getStyle().setMarginLeft(0, Unit.PX); mouseMoveStarted = true; } HorizontalPanel parent = (HorizontalPanel) getParent().getParent(); int relativeX = event.getRelativeX(parent.getElement()) - weekGrid.timebar.getOffsetWidth(); int halfHourDiff = 0; if (moveY > 0) { halfHourDiff = (startYrelative + moveY) / slotHeight; } else { halfHourDiff = (moveY - startYrelative) / slotHeight; } int dateCellWidth = getDateCellWidth(); long dayDiff = 0; if (moveX >= 0) { dayDiff = (startXrelative + moveX) / dateCellWidth; } else { dayDiff = (moveX - (dateCellWidth - startXrelative)) / dateCellWidth; } int dayOffset = relativeX / dateCellWidth; // sanity check for right side overflow int dateCellCount = weekGrid.getDateCellCount(); if (dayOffset >= dateCellCount) { dayOffset--; dayDiff--; } int dayOffsetPx = calculateDateCellOffsetPx(dayOffset) + weekGrid.timebar.getOffsetWidth(); GWT.log( "DateCellWidth: " + dateCellWidth + " dayDiff: " + dayDiff + " dayOffset: " + dayOffset + " dayOffsetPx: " + dayOffsetPx + " startXrelative: " + startXrelative + " moveX: " + moveX); if (relativeX < 0 || relativeX >= getDatesWidth()) { return; } Style s = getElement().getStyle(); Date from = calendarEvent.getStartTime(); Date to = calendarEvent.getEndTime(); long duration = to.getTime() - from.getTime(); if (!clickTargetsResize() && weekGrid.getCalendar().isEventMoveAllowed()) { long daysMs = dayDiff * DateConstants.DAYINMILLIS; from.setTime(startDatetimeFrom.getTime() + daysMs); from.setTime(from.getTime() + ((long) halfHourInMilliSeconds * halfHourDiff)); to.setTime((from.getTime() + duration)); calendarEvent.setStartTime(from); calendarEvent.setEndTime(to); calendarEvent.setStart(new Date(from.getTime())); calendarEvent.setEnd(new Date(to.getTime())); // Set new position for the event long startFromMinutes = (from.getHours() * 60) + from.getMinutes(); long range = calendarEvent.getRangeInMinutes(); startFromMinutes = calculateStartFromMinute(startFromMinutes, from, to, dayOffsetPx); if (startFromMinutes < 0) { range += startFromMinutes; } updatePosition(startFromMinutes, range); s.setLeft(dayOffsetPx, Unit.PX); if (weekGrid.getDateCellWidths() != null) { s.setWidth(weekGrid.getDateCellWidths()[dayOffset], Unit.PX); } else { setWidth(moveWidth); } } else if (clickTarget == topResizeBar) { long oldStartTime = startDatetimeFrom.getTime(); long newStartTime = oldStartTime + ((long) halfHourInMilliSeconds * halfHourDiff); if (!isTimeRangeTooSmall(newStartTime, startDatetimeTo.getTime())) { newStartTime = startDatetimeTo.getTime() - getMinTimeRange(); } from.setTime(newStartTime); calendarEvent.setStartTime(from); calendarEvent.setStart(new Date(from.getTime())); // Set new position for the event long startFromMinutes = (from.getHours() * 60) + from.getMinutes(); long range = calendarEvent.getRangeInMinutes(); updatePosition(startFromMinutes, range); } else if (clickTarget == bottomResizeBar) { long oldEndTime = startDatetimeTo.getTime(); long newEndTime = oldEndTime + ((long) halfHourInMilliSeconds * halfHourDiff); if (!isTimeRangeTooSmall(startDatetimeFrom.getTime(), newEndTime)) { newEndTime = startDatetimeFrom.getTime() + getMinTimeRange(); } to.setTime(newEndTime); calendarEvent.setEndTime(to); calendarEvent.setEnd(new Date(to.getTime())); // Set new position for the event long startFromMinutes = (startDatetimeFrom.getHours() * 60) + startDatetimeFrom.getMinutes(); long range = calendarEvent.getRangeInMinutes(); startFromMinutes = calculateStartFromMinute(startFromMinutes, from, to, dayOffsetPx); if (startFromMinutes < 0) { range += startFromMinutes; } updatePosition(startFromMinutes, range); } }
private DocTab( ImageResource icon, String docId, String title, String tooltip, TabCloseObserver closeHandler) { docId_ = docId; final HorizontalPanel layoutPanel = new HorizontalPanel(); layoutPanel.setStylePrimaryName(styles_.tabLayout()); layoutPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM); layoutPanel.getElement().setDraggable("true"); layoutPanel.addDomHandler( new DragStartHandler() { @Override public void onDragStart(DragStartEvent evt) { evt.getDataTransfer() .setData( getDataTransferFormat(), docId_ + "|" + SourceWindowManager.getSourceWindowId()); JsObject dt = evt.getDataTransfer().cast(); dt.setString("effectAllowed", "move"); // figure out where the cursor is inside the element; because the // drag shows an image of the tab, knowing where the cursor is // inside that image is necessary for us to know the screen // location of the dragged image int evtX = evt.getNativeEvent().getClientX(); ElementEx ele = getElement().cast(); events_.fireEvent( new DocTabDragInitiatedEvent( docId_, getElement().getClientWidth(), evtX - ele.getBoundingClientRect().getLeft())); } }, DragStartEvent.getType()); HTML left = new HTML(); left.setStylePrimaryName(styles_.tabLayoutLeft()); layoutPanel.add(left); contentPanel_ = new HorizontalPanel(); contentPanel_.setTitle(tooltip); contentPanel_.setStylePrimaryName(styles_.tabLayoutCenter()); contentPanel_.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); if (icon != null) contentPanel_.add(imageForIcon(icon)); label_ = new Label(title, false); label_.addStyleName(styles_.docTabLabel()); contentPanel_.add(label_); appendDirtyMarker(); Image img = new Image(ThemeResources.INSTANCE.closeTab()); img.setStylePrimaryName(styles_.closeTabButton()); img.addStyleName(ThemeStyles.INSTANCE.handCursor()); contentPanel_.add(img); layoutPanel.add(contentPanel_); HTML right = new HTML(); right.setStylePrimaryName(styles_.tabLayoutRight()); layoutPanel.add(right); initWidget(layoutPanel); this.sinkEvents(Event.ONCLICK); closeHandler_ = closeHandler; closeElement_ = img.getElement(); }
/** * constructor TabGeographic * * @return the widget composed by the Geographic Tab */ public TabGeographic() { queryButton.setText(constants.runQuery()); // set style titleLabel.removeStyleName("gwt-Label"); // set form names setFormName(); // initialize widget initWidget(uiBinder.createAndBindUi(this)); // add scroll bars dock.getWidgetContainerElement(dock.getWidget(0)).addClassName("auto"); dock.getWidgetContainerElement(dock.getWidget(0)).getStyle().clearOverflow(); Element myTable = dock.getElement().getElementsByTagName("table").getItem(0); @SuppressWarnings("unused") String txt = myTable.getInnerHTML(); myTable.getStyle().clearPosition(); if (summaryHTML.getHTML().isEmpty()) summaryHTML.removeFromParent(); // HTML matchFound = new HTML("<div style=\"height:300px;overflow:auto;\"><div // id=\"responseCount\" style=\"display:none;\"><span style=\"font-weight: bold;\">Matches // found:</span><span id=\"matchCount\" style=\"display:none;\"></span><div // id=\"matches\"></div></div>"); // Workaround to the problem of the map position // Issue 366: Google Map widget does not initialize correctly inside a LayoutPanel if (EUOSMEGWT.apiMapstraction.equalsIgnoreCase("google")) { map = new com.google.gwt.maps.client.MapWidget(); nativeMakeMap( map.getElement(), geoBoundsObj.newTextBoxNorth.getElement(), geoBoundsObj.newTextBoxEast.getElement(), geoBoundsObj.newTextBoxSouth.getElement(), geoBoundsObj.newTextBoxWest.getElement(), queryTextBox.getElement()); mapPanel.add(map); // google.maps.event.trigger(map, 'resize'); // mapPanel.add(matchFound); // Event.trigger(mapWidget.getMap(), "resize"); } else if (EUOSMEGWT.apiMapstraction.equalsIgnoreCase("gwt-ol")) { queryPanel.removeFromParent(); if (mapWidget == null) { initMapGwtOl(); mapPanel.add(mapWidget); mapWidget .getElement() .getFirstChildElement() .getStyle() .setZIndex(0); // force the map to fall behind popups MG 06.05.2015 } } else { queryPanel.removeFromParent(); sinkEvents(Event.ONMOUSEUP); Element map_el = DOM.getElementById("mapstraction"); mxnMakeMap(map_el, EUOSMEGWT.apiMapstraction); mapPanel.getElement().insertFirst(map_el); } preferredObj.add(country); country.myListBox.addChangeHandler( new ChangeHandler() { @Override public void onChange(ChangeEvent event) { String selValue = country.myListBox.getValue(country.myListBox.getSelectedIndex()); if (!selValue.isEmpty()) { // selValue contains a value like S:-21.39;W:55.84;N:51.09;E:-63.15 String[] coordinates = selValue.split(";"); String south = ""; String west = ""; String north = ""; String east = ""; for (int i = 0; i < coordinates.length; i++) { if (coordinates[i].startsWith("S:")) south = coordinates[i].substring(2); if (coordinates[i].startsWith("W:")) west = coordinates[i].substring(2); if (coordinates[i].startsWith("N:")) north = coordinates[i].substring(2); if (coordinates[i].startsWith("E:")) east = coordinates[i].substring(2); } if (!north.isEmpty() && !east.isEmpty() && !south.isEmpty() && !west.isEmpty()) { geoBoundsObj.newTextBoxSouth.setValue(south); geoBoundsObj.newTextBoxWest.setValue(west); geoBoundsObj.newTextBoxNorth.setValue(north); geoBoundsObj.newTextBoxEast.setValue(east); geoBoundsObj.newButton.click(); // zoom to the country bound if (EUOSMEGWT.apiMapstraction.equalsIgnoreCase("gwt-ol")) { Map map = mapWidget.getMap(); map.zoomToExtent( new Bounds( Double.parseDouble(west), Double.parseDouble(south), Double.parseDouble(east), Double.parseDouble(north))); } else setBoundsMapstraction( Double.parseDouble(south), Double.parseDouble(west), Double.parseDouble(north), Double.parseDouble(east)); } else Window.alert(constants.geoCodeListError()); } } }); geoBoundsObj.myListBox.addBlurHandler( new BlurHandler() { @Override public void onBlur(BlurEvent event) { // refresh the map to avoid shifting cursor if (EUOSMEGWT.apiMapstraction.equalsIgnoreCase("gwt-ol")) { mapWidget.getMap().setCenter(mapWidget.getMap().getCenter()); } } }); geoBoundsObj.newButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { // refresh the map to avoid shifting cursor if (EUOSMEGWT.apiMapstraction.equalsIgnoreCase("gwt-ol")) { mapWidget.getMap().setCenter(mapWidget.getMap().getCenter()); } } }); }
public NewServerConfigWizard( final ServerConfigPresenter presenter, List<ServerGroupRecord> serverGroups) { this.presenter = presenter; layout = new VerticalPanel(); final Form<Server> form = new Form<Server>(Server.class); form.setNumColumns(1); TextBoxItem nameItem = new TextBoxItem("name", "Server Name") { @Override public boolean validate(String value) { boolean hasValue = super.validate(value); boolean hasWhitespace = value.contains(" "); return hasValue && !hasWhitespace; } @Override public String getErrMessage() { return "Not empty, no whitespace"; } }; CheckBoxItem startedItem = new CheckBoxItem("autoStart", "Start Instances?"); NumberBoxItem portOffset = new NumberBoxItem("portOffset", "Port Offset"); List<String> groups = new ArrayList<String>(serverGroups.size()); for (ServerGroupRecord rec : serverGroups) groups.add(rec.getGroupName()); groupItem = new ComboBoxItem("group", "Server Group"); groupItem.setDefaultToFirstOption(true); groupItem.setValueMap(groups); form.setFields(nameItem, groupItem, portOffset, startedItem); layout.add(form.asWidget()); // --- DefaultButton submit = new DefaultButton( "Save", new ClickHandler() { @Override public void onClick(ClickEvent event) { Server newServer = form.getUpdatedEntity(); FormValidation validation = form.validate(); if (validation.hasErrors()) return; presenter.createServerConfig(newServer); } }); Label cancel = new Label("Cancel"); cancel.setStyleName("html-link"); cancel.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { presenter.closeDialoge(); } }); HorizontalPanel options = new HorizontalPanel(); options.getElement().setAttribute("style", "width:100%"); HTML spacer = new HTML(" "); options.add(spacer); // spacer.getElement().getParentElement().setAttribute("width", "100%"); options.add(submit); options.add(spacer); options.add(cancel); cancel.getElement().getParentElement().setAttribute("style", "vertical-align:middle"); submit.getElement().getParentElement().setAttribute("align", "right"); submit.getElement().getParentElement().setAttribute("width", "100%"); layout.add(options); }
public Widget asWidget() { HorizontalPanel layout = new HorizontalPanel(); layout.getElement().setAttribute("title", "Notification Center"); layout.setStyleName("notification-center"); messageButton = new HTML(MESSAGE_LABEL + ": " + messageCenter.getNewMessageCount()); messageButton.addStyleName("notification-button"); ClickHandler clickHandler = new ClickHandler() { public void onClick(ClickEvent event) { int numMessages = fetchMessages(messagePopup); if (numMessages == 0) numMessages = 1; int width = 250; int height = numMessages * 35; messagePopup.setPopupPosition( messageButton.getAbsoluteLeft() - (width + 10 - messageButton.getOffsetWidth()), messageButton.getAbsoluteTop() + 25); messagePopup.show(); Scheduler.get() .scheduleDeferred( new Scheduler.ScheduledCommand() { @Override public void execute() { messagePopup.focusOnFirstMessage(); } }); messagePopup.setWidth(width + "px"); messagePopup.setHeight(height + "px"); } }; messageButton.addClickHandler(clickHandler); messageDisplay = new HorizontalPanel(); messageDisplay.getElement().setAttribute("role", "log"); messageDisplay.getElement().setAttribute("aria-live", "polite"); messageDisplay.getElement().setAttribute("aria-atomic", "true"); layout.add(messageDisplay); layout.add(messageButton); messageDisplay .getElement() .getParentElement() .setAttribute("style", "width:100%;padding-right:5px"); messageDisplay.getElement().getParentElement().setAttribute("align", "right"); messageButton.getElement().getParentElement().setAttribute("style", "width:60px"); messageButton.getElement().getParentElement().setAttribute("align", "right"); // register listener messageCenter.addMessageListener(this); Console.getEventBus().addHandler(ReloadEvent.TYPE, this); return layout; }
// Method response to user click of "Address" button in a post row // Causes popup panel to appear protected void doMapPopup(PostData post) { VerticalPanel content = new VerticalPanel(); content.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); final String address = post.getAddress(); // Create a Panel to hold the map HorizontalPanel mapPanel = new HorizontalPanel(); mapPanel.setSize("400px", "400px"); // Create the Google Map object, with set options MapOptions myOptions = MapOptions.create(); myOptions.setZoom(8.0); myOptions.setCenter(LatLng.create(-34.397, 150.644)); myOptions.setMapTypeId(MapTypeId.ROADMAP); final GoogleMap map = GoogleMap.create(mapPanel.getElement(), myOptions); // GeoCoder is Google Maps API for taking an address and finding // latitude-longitude. Geocoder geocoder = Geocoder.create(); GeocoderRequest request = GeocoderRequest.create(); request.setAddress(address); geocoder.geocode( request, new Callback() { public void handle(JsArray<GeocoderResult> results, GeocoderStatus status) { if (status == GeocoderStatus.OK) { GeocoderResult location = results.get(0); // Bug Fix - Needed to make sure that map is re-sized to parent panel map.triggerResize(); map.setCenter(location.getGeometry().getLocation()); // Create Marker (red) to show location MarkerOptions markerOpts = MarkerOptions.create(); markerOpts.setMap(map); // Title of Marker will be address markerOpts.setTitle(address); // Place Marker at address location markerOpts.setPosition(location.getGeometry().getLocation()); Marker.create(markerOpts); } else { Window.alert("Geocode was not successful for the following reason: " + status); } } }); HorizontalPanel btnRow = new HorizontalPanel(); btnRow.setStyleName("search-button-row"); Button cancelBtn = new Button("Cancel"); cancelBtn.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { searchPopup.hide(); } }); btnRow.add(cancelBtn); content.add(mapPanel); content.add(btnRow); searchPopup.setWidget(content); searchPopup.center(); }
public Widget asWidget() { LayoutPanel layout = new LayoutPanel(); VerticalPanel panel = new VerticalPanel(); panel.setStyleName("rhs-content-panel"); ScrollPanel scroll = new ScrollPanel(panel); layout.add(scroll); layout.setWidgetTopHeight(scroll, 0, Style.Unit.PX, 100, Style.Unit.PCT); // --- HorizontalPanel horzPanel = new HorizontalPanel(); horzPanel.getElement().setAttribute("style", "width:100%;"); Image image = new Image(Icons.INSTANCE.messaging()); horzPanel.add(image); horzPanel.add(new ContentHeaderLabel("JMS Subsystem Configuration")); image.getElement().getParentElement().setAttribute("width", "25"); panel.add(horzPanel); // ---- panel.add(new ContentGroupLabel("Connection Factories")); factoryTable = new DefaultCellTable<ConnectionFactory>(10); Column<ConnectionFactory, String> nameColumn = new Column<ConnectionFactory, String>(new TextCell()) { @Override public String getValue(ConnectionFactory object) { return object.getName(); } }; Column<ConnectionFactory, String> jndiColumn = new Column<ConnectionFactory, String>(new TextCell()) { @Override public String getValue(ConnectionFactory object) { return object.getJndiName(); } }; factoryTable.addColumn(nameColumn, "Name"); factoryTable.addColumn(jndiColumn, "JNDI"); StaticHelpPanel helpPanel = new StaticHelpPanel(MessagingDescription.getFactoryDescription()); panel.add(helpPanel.asWidget()); panel.add(factoryTable); // ---- panel.add(new ContentGroupLabel("Subresources")); TabPanel bottomLayout = new TabPanel(); bottomLayout.addStyleName("default-tabpanel"); bottomLayout.getElement().setAttribute("style", "padding-top:20px;"); queueList = new QueueList(presenter); bottomLayout.add(queueList.asWidget(), "Queues"); topicList = new TopicList(presenter); bottomLayout.add(topicList.asWidget(), "Topics"); bottomLayout.selectTab(0); panel.add(bottomLayout); return layout; }
public Widget asWidget() { if (null == cellTable.getSelectionModel()) cellTable.setSelectionModel(new SingleSelectionModel<T>()); cellTable .getSelectionModel() .addSelectionChangeHandler( new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent selectionChangeEvent) { T selection = ((SingleSelectionModel<T>) cellTable.getSelectionModel()).getSelectedObject(); String displayValue = renderer.render(selection); currentDisplayedValue.setText(displayValue); } }); final String panelId = "popup_" + HTMLPanel.createUniqueId(); popup = new PopupPanel(true, true) { @Override protected void onPreviewNativeEvent(Event.NativePreviewEvent event) { if (Event.ONKEYUP == event.getTypeInt()) { if (event.getNativeEvent().getKeyCode() == ESCAPE) { // Dismiss when escape is pressed popup.hide(); } } } public void onBrowserEvent(Event event) { super.onBrowserEvent(event); } }; popup.getElement().setId(panelId); popup.setStyleName("default-popup"); /*popup.addCloseHandler(new CloseHandler<PopupPanel>() { public void onClose(CloseEvent<PopupPanel> event) { } });*/ VerticalPanel layout = new VerticalPanel(); layout.setStyleName("fill-layout-width"); layout.addStyleName("tablepicker-popup"); if (description != null) layout.add(new Label(description)); layout.add(cellTable); DefaultPager pager = new DefaultPager(); pager.setDisplay(cellTable); layout.add(pager); popup.setWidget(layout); currentDisplayedValue = new HTML(" "); currentDisplayedValue.setStyleName("table-picker-value"); header = new HorizontalPanel(); header.setStyleName("table-picker"); header.add(currentDisplayedValue); Image img = new Image(ConsoleIcons.INSTANCE.tablePicker()); header.add(img); currentDisplayedValue.getElement().getParentElement().setAttribute("width", "100%"); img.getParent().getElement().setAttribute("width", "18"); header.getElement().setAttribute("width", "100%"); header.getElement().setAttribute("cellspacing", "0"); header.getElement().setAttribute("cellpadding", "0"); header.getElement().setAttribute("border", "0"); ClickHandler clickHandler = new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { openPanel(); } }; currentDisplayedValue.addClickHandler(clickHandler); img.addClickHandler(clickHandler); return header; }