List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder SafeHtmlBuilder
public SafeHtmlBuilder()
From source file:edu.arizona.biosemantics.gxt.theme.green.client.sliced.button.SlicedButtonCellAppearance.java
License:sencha.com license
@Override public void render(final ButtonCell<C> cell, Context context, C value, SafeHtmlBuilder sb) { String constantHtml = cell.getHTML(); boolean hasConstantHtml = constantHtml != null && constantHtml.length() != 0; boolean isBoolean = value != null && value instanceof Boolean; // is a boolean always a toggle button? String text = hasConstantHtml ? cell.getText() : (value != null && !isBoolean) ? SafeHtmlUtils.htmlEscape(value.toString()) : ""; ImageResource icon = cell.getIcon(); IconAlign iconAlign = cell.getIconAlign(); String cls = style.button();/*from w w w. j a va 2s. c om*/ String arrowCls = ""; if (cell.getMenu() != null) { if (cell instanceof SplitButtonCell) { switch (cell.getArrowAlign()) { case RIGHT: arrowCls = style.split(); break; case BOTTOM: arrowCls = style.splitBottom(); break; default: // empty } } else { switch (cell.getArrowAlign()) { case RIGHT: arrowCls = style.arrow(); break; case BOTTOM: arrowCls = style.arrowBottom(); break; } } } ButtonScale scale = cell.getScale(); switch (scale) { case SMALL: cls += " " + style.small(); break; case MEDIUM: cls += " " + style.medium(); break; case LARGE: cls += " " + style.large(); break; default: // empty } SafeStylesBuilder stylesBuilder = new SafeStylesBuilder(); int width = -1; if (cell.getWidth() != -1) { int w = cell.getWidth(); if (w < cell.getMinWidth()) { w = cell.getMinWidth(); } stylesBuilder.appendTrustedString("width:" + w + "px;"); cls += " " + style.hasWidth() + " x-has-width"; width = w; } else { if (cell.getMinWidth() != -1) { TextMetrics.get().bind(style.text()); int length = TextMetrics.get().getWidth(text); length += 6; // frames if (icon != null) { switch (iconAlign) { case LEFT: case RIGHT: length += icon.getWidth(); break; default: // empty } } } } final int height = cell.getHeight(); if (height != -1) { stylesBuilder.appendTrustedString("height:" + height + "px;"); } if (icon != null) { switch (iconAlign) { case TOP: arrowCls += " " + style.iconTop(); break; case BOTTOM: arrowCls += " " + style.iconBottom(); break; case LEFT: arrowCls += " " + style.iconLeft(); break; case RIGHT: arrowCls += " " + style.iconRight(); break; } } else { arrowCls += " " + style.noIcon(); } // toggle button if (value == Boolean.TRUE) { cls += " " + frame.pressedClass(); } sb.append(templates.outer(cls, new SafeStylesBuilder().toSafeStyles())); SafeHtmlBuilder inside = new SafeHtmlBuilder(); String innerWrap = arrowCls; if (GXT.isIE6() || GXT.isIE7()) { arrowCls += " " + CommonStyles.get().inlineBlock(); } inside.appendHtmlConstant("<div class='" + innerWrap + "'>"); inside.appendHtmlConstant("<table cellpadding=0 cellspacing=0 class='" + style.mainTable() + "'>"); boolean hasText = text != null && !text.equals(""); if (icon != null) { switch (iconAlign) { case LEFT: inside.appendHtmlConstant("<tr>"); writeIcon(inside, icon, height); if (hasText) { int w = width - (icon != null ? icon.getWidth() : 0) - 4; writeText(inside, text, w, height); } inside.appendHtmlConstant("</tr>"); break; case RIGHT: inside.appendHtmlConstant("<tr>"); if (hasText) { int w = width - (icon != null ? icon.getWidth() : 0) - 4; writeText(inside, text, w, height); } writeIcon(inside, icon, height); inside.appendHtmlConstant("</tr>"); break; case TOP: inside.appendHtmlConstant("<tr>"); writeIcon(inside, icon, height); inside.appendHtmlConstant("</tr>"); if (hasText) { inside.appendHtmlConstant("<tr>"); writeText(inside, text, width, height); inside.appendHtmlConstant("</tr>"); } break; case BOTTOM: if (hasText) { inside.appendHtmlConstant("<tr>"); writeText(inside, text, width, height); inside.appendHtmlConstant("</tr>"); } inside.appendHtmlConstant("<tr>"); writeIcon(inside, icon, height); inside.appendHtmlConstant("</tr>"); break; } } else { inside.appendHtmlConstant("<tr>"); if (text != null) { writeText(inside, text, width, height); } inside.appendHtmlConstant("</tr>"); } inside.appendHtmlConstant("</table>"); inside.appendHtmlConstant("</div>"); frame.render(sb, new Frame.FrameOptions(0, CommonStyles.get().noFocusOutline(), stylesBuilder.toSafeStyles()), inside.toSafeHtml()); sb.appendHtmlConstant("</div>"); }
From source file:edu.arizona.biosemantics.gxt.theme.green.client.sliced.mask.SlicedMaskAppearance.java
License:sencha.com license
@Override public void mask(XElement parent, String message) { XElement mask = XElement.createElement("div"); mask.setClassName(resources.style().mask()); parent.appendChild(mask);/* w w w. ja v a 2 s . c om*/ XElement box = null; if (message != null) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); SafeHtml content = template.template(resources.style(), SafeHtmlUtils.htmlEscape(message)); frame.render(sb, Frame.EMPTY_FRAME, content); box = XDOM.create(sb.toSafeHtml()).cast(); parent.appendChild(box); } if (GXT.isIE() && !(GXT.isIE7()) && "auto".equals(parent.getStyle().getHeight())) { mask.setSize(parent.getOffsetWidth(), parent.getOffsetHeight()); } if (box != null) { box.updateZIndex(0); box.center(parent); } }
From source file:fr.mncc.sandbox.client.layouts.photogallery.PhotoGalleryLayout.java
License:Open Source License
private void fillLayout() { SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); for (int i = 0; i < images_.size(); i++) { safeHtmlBuilder.append(createImageWrapper(images_.get(i))); }// ww w . j a v a 2 s. com wrapper.setInnerSafeHtml(safeHtmlBuilder.toSafeHtml()); }
From source file:fr.onevu.gwt.uibinder.test.client.UiRendererUi.java
License:Apache License
public SafeHtml render(String value, String valueTwice) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); getRenderer().render(sb, new Foo(value), new Foo(valueTwice)); return sb.toSafeHtml(); }
From source file:gov.nist.appvet.gwt.client.gui.table.appslist.AppsListPagingDataGrid.java
License:Open Source License
@Override public void initTableColumns(DataGrid<T> dataGrid, ListHandler<T> sortHandler) { //--------------------------- App ID ----------------------------------- final Column<T, String> appIdColumn = new Column<T, String>(new TextCell()) { @Override/* w w w . ja va 2s .c o m*/ public String getValue(T object) { return ((AppInfoGwt) object).appId; } }; appIdColumn.setSortable(true); sortHandler.setComparator(appIdColumn, new Comparator<T>() { @Override public int compare(T o1, T o2) { return ((AppInfoGwt) o1).appId.compareTo(((AppInfoGwt) o2).appId); } }); appIdColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); dataGrid.addColumn(appIdColumn, "ID"); dataGrid.setColumnWidth(appIdColumn, "60px"); //--------------------------- App Icon --------------------------------- final SafeHtmlCell iconCell = new SafeHtmlCell(); final Column<T, SafeHtml> iconColumn = new Column<T, SafeHtml>(iconCell) { @Override public SafeHtml getValue(T object) { final SafeHtmlBuilder sb = new SafeHtmlBuilder(); final String appId = ((AppInfoGwt) object).appId; final AppStatus appStatus = ((AppInfoGwt) object).appStatus; if (appStatus == null) { log.warning("App status is null"); return sb.toSafeHtml(); } else { log.info("App status in table is: " + appStatus.name()); } if (appStatus == AppStatus.REGISTERING) { iconVersion++; final String iconPath = appVetHostUrl + "/appvet_images/default.png?v" + iconVersion; sb.appendHtmlConstant("<img width=\"20\" src=\"" + iconPath + "\" alt=\"\" />"); } else if (appStatus == AppStatus.PENDING) { final String iconPath = appVetHostUrl + "/appvet_images/default.png"; sb.appendHtmlConstant("<img width=\"20\" src=\"" + iconPath + "\" alt=\"\" />"); } else if (appStatus == AppStatus.PROCESSING) { iconVersion++; final String iconPath = appVetHostUrl + "/appvet_images/" + appId + ".png?v" + iconVersion; sb.appendHtmlConstant("<img width=\"20\" src=\"" + iconPath + "\" alt=\"\" />"); } else { iconVersion++; final String iconPath = appVetHostUrl + "/appvet_images/" + appId + ".png"; sb.appendHtmlConstant("<img width=\"20\" src=\"" + iconPath + "\" alt=\"\" />"); } return sb.toSafeHtml(); } }; iconColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); iconColumn.setSortable(false); dataGrid.addColumn(iconColumn, ""); dataGrid.setColumnWidth(iconColumn, "25px"); //------------------------- App Name ----------------------------------- final Column<T, String> appNameColumn = new Column<T, String>(new TextCell()) { @Override public String getValue(T object) { return ((AppInfoGwt) object).appName; } }; appNameColumn.setSortable(true); sortHandler.setComparator(appNameColumn, new Comparator<T>() { @Override public int compare(T o1, T o2) { return ((AppInfoGwt) o1).appName.compareTo(((AppInfoGwt) o2).appName); } }); appNameColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); dataGrid.addColumn(appNameColumn, "App"); dataGrid.setColumnWidth(appNameColumn, "127px"); //----------------------------- Status --------------------------------- final SafeHtmlCell statusCell = new SafeHtmlCell(); final Column<T, SafeHtml> statusColumn = new Column<T, SafeHtml>(statusCell) { @Override public SafeHtml getValue(T object) { final SafeHtmlBuilder sb = new SafeHtmlBuilder(); final AppStatus appStatus = ((AppInfoGwt) object).appStatus; String statusHtml = null; if (appStatus == AppStatus.ERROR) { statusHtml = "<div id=\"error\" style='color: red'>ERROR</div>"; } else if (appStatus == AppStatus.WARNING) { statusHtml = "<div id=\"warning\" style='color: orange'>" + appStatus + "</div>"; } else if (appStatus == AppStatus.PASS) { statusHtml = "<div id=\"endorsed\" style='color: green'>" + appStatus + "</div>"; } else if (appStatus == AppStatus.FAIL) { statusHtml = "<div id=\"error\" style='color: red'>FAIL</div>"; } else { statusHtml = "<div id=\"error\" style='color: black'>" + appStatus.name() + "</div>"; } sb.appendHtmlConstant(statusHtml); return sb.toSafeHtml(); } }; statusColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); statusColumn.setSortable(true); sortHandler.setComparator(statusColumn, new Comparator<T>() { @Override public int compare(T o1, T o2) { return ((AppInfoGwt) o1).appStatus.compareTo(((AppInfoGwt) o2).appStatus); } }); dataGrid.addColumn(statusColumn, "Status"); dataGrid.setColumnWidth(statusColumn, "60px"); //--------------------------- Submitter ------------------------------- final Column<T, String> submitterColumn = new Column<T, String>(new TextCell()) { @Override public String getValue(T object) { return ((AppInfoGwt) object).userName; } }; submitterColumn.setSortable(true); sortHandler.setComparator(submitterColumn, new Comparator<T>() { @Override public int compare(T o1, T o2) { return ((AppInfoGwt) o1).userName.compareTo(((AppInfoGwt) o2).userName); } }); submitterColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); dataGrid.addColumn(submitterColumn, "User"); dataGrid.setColumnWidth(submitterColumn, "60px"); //--------------------------- Submit Time ------------------------------ final Column<T, String> submitTimeColumn = new Column<T, String>(new TextCell()) { @Override public String getValue(T object) { final AppInfoGwt appInfo = (AppInfoGwt) object; final Date date = new Date(appInfo.submitTime); final String dateString = dateTimeFormat.format(date); return dateString; } }; submitTimeColumn.setSortable(true); sortHandler.setComparator(submitTimeColumn, new Comparator<T>() { @Override public int compare(T o1, T o2) { final AppInfoGwt appInfo1 = (AppInfoGwt) o1; final Date date1 = new Date(appInfo1.submitTime); final String dateString1 = dateTimeFormat.format(date1); final AppInfoGwt appInfo2 = (AppInfoGwt) o2; final Date date2 = new Date(appInfo2.submitTime); final String dateString2 = dateTimeFormat.format(date2); return dateString1.compareTo(dateString2); } }); submitTimeColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); dataGrid.addColumn(submitTimeColumn, "Date/Time"); dataGrid.setColumnWidth(submitTimeColumn, "100px"); }
From source file:gov.nist.spectrumbrowser.client.SensorDataStream.java
License:Open Source License
private void drawMenuItems() { MenuBar menuBar = new MenuBar(); SafeHtmlBuilder safeHtml = new SafeHtmlBuilder(); menuBar.addItem(new SafeHtmlBuilder().appendEscaped(SpectrumBrowserShowDatasets.END_LABEL).toSafeHtml(), new Scheduler.ScheduledCommand() { @Override// ww w .j ava 2 s . co m public void execute() { state = STATUS_MESSAGE_NOT_SEEN; closingState = true; websocket.close(); spectrumBrowserShowDatasets.draw(); } }); if (spectrumBrowser.isUserLoggedIn()) { menuBar.addItem(safeHtml.appendEscaped(SpectrumBrowser.LOGOFF_LABEL).toSafeHtml(), new Scheduler.ScheduledCommand() { @Override public void execute() { state = STATUS_MESSAGE_NOT_SEEN; closingState = true; websocket.close(); spectrumBrowser.logoff(); } }); } verticalPanel.add(menuBar); titlePanel = new VerticalPanel(); verticalPanel.add(titlePanel); HorizontalPanel cutoffHorizontalPanel = new HorizontalPanel(); Label cutoffLabel = new Label("Threshold (dBm):"); cutoffHorizontalPanel.add(cutoffLabel); cutoffTextBox = new TextBox(); cutoffTextBox.setText(Integer.toString((int) cutoff)); cutoffHorizontalPanel.add(cutoffTextBox); Button cutoffButton = new Button("Change"); cutoffHorizontalPanel.add(cutoffButton); cutoffButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { String cutoffString = cutoffTextBox.getValue(); try { cutoff = Integer.parseInt(cutoffString); } catch (NumberFormatException nfe) { Window.alert("Please enter an integer"); if (cutoff < 0) cutoffTextBox.setText(Integer.toString((int) (cutoff - 0.5))); else cutoffTextBox.setText(Integer.toString((int) (cutoff + 0.5))); } } }); freezeButton = new Button("Freeze"); freezeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { isFrozen = !isFrozen; if (isFrozen) { freezeButton.setText("Unfreeze"); } else { freezeButton.setText("Freeze"); } } }); cutoffHorizontalPanel.add(freezeButton); lastCaptureButton = new Button("Show Last Acquistion"); cutoffHorizontalPanel.add(lastCaptureButton); lastCaptureButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { websocket.close(); spectrumBrowser.getSpectrumBrowserService().getLastAcquisitionTime(sensorId, new SpectrumBrowserCallback<String>() { @Override public void onSuccess(String result) { JSONValue jsonValue = JSONParser.parseLenient(result); final long selectionTime = (long) jsonValue.isObject().get("aquisitionTimeStamp") .isNumber().doubleValue(); if (selectionTime != -1) { chartApiLoaded = false; occupancyDataTable = null; websocket.close(); state = STATUS_MESSAGE_NOT_SEEN; isFrozen = false; Timer timer = new Timer() { @Override public void run() { ArrayList<SpectrumBrowserScreen> navigation = new ArrayList<SpectrumBrowserScreen>(); navigation.add(spectrumBrowserShowDatasets); navigation.add(SensorDataStream.this); new FftPowerOneAcquisitionSpectrogramChart(sensorId, selectionTime, sys2detect, minFreqHz, maxFreqHz, verticalPanel, spectrumBrowser, navigation); } }; // Wait for websocket to close. timer.schedule(500); } else { Window.alert("No Capture Found"); } } @Override public void onFailure(Throwable throwable) { logger.log(Level.SEVERE, "Problem contacting web server."); Window.alert("Problem contacting web server"); } }); } }); verticalPanel.add(cutoffHorizontalPanel); }
From source file:gov.nist.spectrumbrowser.client.SpectrumBrowserShowDatasets.java
License:Open Source License
private void populateMenuItems() { selectFrequencyMenuBar = new MenuBar(true); MenuItem menuItem = new MenuItem(new SafeHtmlBuilder().appendEscaped("Show All").toSafeHtml(), new SelectFreqCommand(null, 0, 0, this)); selectFrequencyMenuBar.addItem(menuItem); for (FrequencyRange f : globalFrequencyRanges) { menuItem = new MenuItem(new SafeHtmlBuilder() .appendEscaped(//from w w w.ja v a 2s . com Double.toString(f.minFreq / 1E6) + " - " + Double.toString(f.maxFreq / 1E6) + " MHz") .toSafeHtml(), new SelectFreqCommand(f.sys2detect, f.minFreq, f.maxFreq, this)); selectFrequencyMenuBar.addItem(menuItem); } navigationBar.addItem("Show Sensors By Frequency Band", selectFrequencyMenuBar); navigationBar.setTitle("Subset visible sensor markers on map using:\n " + "\"Show Sensors By Frequency Band\" or \n" + "\"Show Sensors By Detected System\".\n" + "Click on a visible marker to select sensors.\n "); selectSys2DetectMenuBar = new MenuBar(true); menuItem = new MenuItem(new SafeHtmlBuilder().appendEscaped("Show All").toSafeHtml(), new SelectBySys2DetectCommand(null, this)); selectSys2DetectMenuBar.addItem(menuItem); for (String sys2detect : globalSys2Detect) { menuItem = new MenuItem(new SafeHtmlBuilder().appendEscaped(sys2detect).toSafeHtml(), new SelectBySys2DetectCommand(sys2detect, this)); selectSys2DetectMenuBar.addItem(menuItem); } navigationBar.addItem("Show Sensors By Detected System", selectSys2DetectMenuBar).setTitle(sensorText); ; menuItem = new MenuItem(new SafeHtmlBuilder().appendEscaped("Help").toSafeHtml(), new Scheduler.ScheduledCommand() { @Override public void execute() { Window.open(SpectrumBrowser.getHelpPath(), "Help", null); } }); menuItem.setTitle(helpText); navigationBar.addItem(menuItem); if (spectrumBrowser.isUserLoggedIn()) { menuItem = new MenuItem(new SafeHtmlBuilder().appendEscaped("Log Off").toSafeHtml(), new Scheduler.ScheduledCommand() { @Override public void execute() { spectrumBrowser.logoff(); } }); navigationBar.addItem(menuItem); } }
From source file:gov.nist.spectrumbrowser.common.AbstractSpectrumBrowserScreen.java
License:Open Source License
public void drawNavigation() { if (navigationScreens != null) { MenuBar menuBar = new MenuBar(); verticalPanel.add(menuBar);//from w w w .jav a2 s .c o m for (int i = 0; i < navigationScreens.size() - 1; i++) { final SpectrumBrowserScreen thisScreen = navigationScreens.get(i); menuBar.addItem( new SafeHtmlBuilder().appendEscaped(navigationScreens.get(i).getLabel()).toSafeHtml(), new Scheduler.ScheduledCommand() { @Override public void execute() { thisScreen.draw(); } }); } menuBar.addItem(new SafeHtmlBuilder() .appendEscaped(navigationScreens.get(navigationScreens.size() - 1).getEndLabel()).toSafeHtml(), new Scheduler.ScheduledCommand() { @Override public void execute() { navigationScreens.get(navigationScreens.size() - 1).draw(); } }); if (abstractSpectrumBrowser.isUserLoggedIn()) { menuBar.addItem(new SafeHtmlBuilder().appendEscaped("Log Off").toSafeHtml(), new Scheduler.ScheduledCommand() { @Override public void execute() { abstractSpectrumBrowser.logoff(); } }); } } }
From source file:gov.nist.toolkit.xdstools2.client.tabs.simulatorControlTab.SimulatorControlTab.java
License:Creative Commons License
private void addButtonPanel(int row, int maxColumn, final SimulatorConfig config) { table.setHTML(0, maxColumn, "<b>Action</b>"); table.getFlexCellFormatter().setStyleName(0, maxColumn, "lavenderTh"); final SimId simId = config.getId(); HorizontalPanel buttonPanel = new HorizontalPanel(); buttonPanel.getElement().setId("scmButtonPanel"); table.setWidget(row, maxColumn, buttonPanel); Image logImg = new Image("icons2/log-file-format-symbol.png"); logImg.setTitle("View transaction logs"); logImg.setAltText("A picture of a log book."); applyImgIconStyle(logImg);/*from ww w . j a v a 2 s . c o m*/ logImg.addClickHandler(new ClickHandlerData<SimulatorConfig>(config) { @Override public void onClick(ClickEvent clickEvent) { SimulatorConfig config = getData(); SimulatorMessageViewTab viewTab = new SimulatorMessageViewTab(); viewTab.onTabLoad(config.getId()); } }); buttonPanel.add(logImg); Image pidImg = new Image("icons2/id.png"); pidImg.setTitle("Patient ID Feed"); pidImg.setAltText("An ID element."); applyImgIconStyle(pidImg); pidImg.addClickHandler(new ClickHandlerData<SimulatorConfig>(config) { @Override public void onClick(ClickEvent clickEvent) { SimulatorConfig config = getData(); PidEditTab editTab = new PidEditTab(config); editTab.onTabLoad(true, "PIDEdit"); } }); buttonPanel.add(pidImg); if (ActorType.OD_RESPONDING_GATEWAY.getShortName().equals(config.getActorType())) { Image editRgImg = new Image("icons2/edit-rg.png"); editRgImg.setTitle("Edit RG Simulator Configuration"); editRgImg.setAltText("A pencil writing."); applyImgIconStyle(editRgImg); editRgImg.addClickHandler(new ClickHandlerData<SimulatorConfig>(config) { @Override public void onClick(ClickEvent clickEvent) { loadSimStatus(); SimulatorConfig config = getData(); // Generic state-less type simulators GenericQueryTab editTab = new EditTab(self, config); editTab.onTabLoad(true, "SimConfig"); } }); Image editOdImg = new Image("icons2/edit-od.png"); editOdImg.setTitle("Edit ODDS Simulator Configuration"); editOdImg.setAltText("A pencil writing."); applyImgIconStyle(editOdImg); editOdImg.addClickHandler(new ClickHandlerData<SimulatorConfig>(config) { @Override public void onClick(ClickEvent clickEvent) { loadSimStatus(); SimulatorConfig config = getData(); // This simulator requires content state initialization OddsEditTab editTab; editTab = new OddsEditTab(self, config); editTab.onTabLoad(true, "ODDS"); } }); buttonPanel.add(editRgImg); buttonPanel.add(editOdImg); } else { Image editImg = new Image("icons2/edit.png"); editImg.setTitle("Edit Simulator Configuration"); editImg.setAltText("A pencil writing."); applyImgIconStyle(editImg); editImg.addClickHandler(new ClickHandlerData<SimulatorConfig>(config) { @Override public void onClick(ClickEvent clickEvent) { loadSimStatus(); SimulatorConfig config = getData(); // GenericQueryTab editTab; if (ActorType.ONDEMAND_DOCUMENT_SOURCE.getShortName().equals(config.getActorType())) { // This simulator requires content state initialization OddsEditTab editTab; editTab = new OddsEditTab(self, config); editTab.onTabLoad(true, "ODDS"); } else { // Generic state-less type simulators GenericQueryTab editTab = new EditTab(self, config); editTab.onTabLoad(true, "SimConfig"); } } }); buttonPanel.add(editImg); } Image deleteImg = new Image("icons2/garbage.png"); deleteImg.setTitle("Delete"); deleteImg.setAltText("A garbage can."); applyImgIconStyle(deleteImg); final ClickHandlerData<SimulatorConfig> clickHandlerData = new ClickHandlerData<SimulatorConfig>(config) { @Override public void onClick(ClickEvent clickEvent) { SimulatorConfig config = getData(); DeleteButtonClickHandler handler = new DeleteButtonClickHandler(self, config); handler.delete(); } }; deleteImg.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { SimulatorConfigElement ele = config.getConfigEle(SimulatorProperties.locked); boolean locked = (ele == null) ? false : ele.asBoolean(); if (locked) { if (PasswordManagement.isSignedIn) { doDelete(); } else { PasswordManagement.addSignInCallback(signedInCallback); new AdminPasswordDialogBox(simCtrlContainer); return; } } else { doDelete(); } } AsyncCallback<Boolean> signedInCallback = new AsyncCallback<Boolean>() { public void onFailure(Throwable ignored) { } public void onSuccess(Boolean ignored) { doDelete(); } }; private void doDelete() { VerticalPanel body = new VerticalPanel(); body.add(new HTML("<p>Delete " + config.getId().toString() + "?</p>")); Button actionButton = new Button("Yes"); actionButton.addClickHandler(clickHandlerData); SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); safeHtmlBuilder.appendHtmlConstant("<img src=\"icons2/garbage.png\" height=\"16\" width=\"16\"/>"); safeHtmlBuilder.appendHtmlConstant("Confirm Delete Simulator"); new PopupMessage(safeHtmlBuilder.toSafeHtml(), body, actionButton); } }); buttonPanel.add(deleteImg); Image fileDownload = new Image("icons2/download.png"); fileDownload.setTitle("Download Site File"); fileDownload.setAltText("An XML document with a download arrow."); applyImgIconStyle(fileDownload); fileDownload.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { Window.open("siteconfig/" + simId.toString(), "_blank", ""); } }); buttonPanel.add(fileDownload); // Flaticon credits // <div>Icons made by <a href="http://www.flaticon.com/authors/madebyoliver" title="Madebyoliver">Madebyoliver</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div> // <div>Icons made by <a href="http://www.freepik.com" title="Freepik">Freepik</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div> // <div>Icons made by <a href="http://www.flaticon.com/authors/retinaicons" title="Retinaicons">Retinaicons</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div> // <div>Icons made by <a href="http://www.flaticon.com/authors/gregor-cresnar" title="Gregor Cresnar">Gregor Cresnar</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div> }
From source file:gov.wa.wsdot.mobile.client.activities.trafficmap.restarea.RestAreaActivity.java
License:Open Source License
@Override public void start(AcceptsOneWidget panel, final EventBus eventBus) { view = clientFactory.getRestAreaView(); analytics = clientFactory.getAnalytics(); accessibility = clientFactory.getAccessibility(); this.eventBus = eventBus; view.setPresenter(this); Place place = clientFactory.getPlaceController().getWhere(); if (place instanceof RestAreaPlace) { RestAreaPlace restAreaPlace = (RestAreaPlace) place; int restAreaId = Integer.valueOf(restAreaPlace.getId()); String jsonString = AppBundle.INSTANCE.restAreaData().getText(); RestAreaFeed restAreas = JsonUtils.safeEval(jsonString); view.setTitle("Safety Rest Area"); SafeHtmlBuilder detailsHTMLBuilder = new SafeHtmlBuilder(); detailsHTMLBuilder.appendEscaped(restAreas.getRestAreas().get(restAreaId).getRoute() + " - " + restAreas.getRestAreas().get(restAreaId).getLocation()); detailsHTMLBuilder.appendHtmlConstant("<br>"); detailsHTMLBuilder.appendEscaped("Milepost: " + restAreas.getRestAreas().get(restAreaId).getMilepost() + " - " + restAreas.getRestAreas().get(restAreaId).getDirection()); view.setDetails(detailsHTMLBuilder.toSafeHtml()); if (restAreas.getRestAreas().get(restAreaId).getNotes() == null) { view.hideNotesHeading();/* w ww . j av a 2 s . c o m*/ view.setNotes(""); } else { view.showNotesHeading(); view.setNotes(restAreas.getRestAreas().get(restAreaId).getNotes()); } SafeHtmlBuilder amenitiesHTMLBuilder = new SafeHtmlBuilder(); amenitiesHTMLBuilder.appendHtmlConstant("<ul>"); for (int i = 0; i < restAreas.getRestAreas().get(restAreaId).getAmenities().length; i++) { amenitiesHTMLBuilder.appendHtmlConstant("<li>"); amenitiesHTMLBuilder.appendEscaped(restAreas.getRestAreas().get(restAreaId).getAmenities()[i]); amenitiesHTMLBuilder.appendHtmlConstant("</li>"); } if (restAreas.getRestAreas().get(restAreaId).getAmenities().length == 0) { view.hideAmenitiesHeading(); } else { view.showAmenitiesHeading(); } amenitiesHTMLBuilder.appendHtmlConstant("</ul>"); view.setAmenities(amenitiesHTMLBuilder.toSafeHtml()); view.setLatLon(Double.valueOf(restAreas.getRestAreas().get(restAreaId).getLatitude()), Double.valueOf(restAreas.getRestAreas().get(restAreaId).getLongitude())); view.refresh(); } panel.setWidget(view); accessibility.postScreenChangeNotification(); }