List of usage examples for com.google.gwt.safehtml.shared SafeHtmlUtils fromString
public static SafeHtml fromString(String s)
From source file:net.cbtltd.client.field.table.ActionCell.java
License:Apache License
/** * Construct a new {@link ActionCell} with a text String that does not contain * HTML markup.//w ww . j a v a 2 s.c o m * * @param text the text to display on the button * @param delegate the delegate that will handle events */ public ActionCell(String text, String style, Delegate<C> delegate) { this(SafeHtmlUtils.fromString(text), style, delegate); }
From source file:net.scran24.admin.client.Scran24Admin.java
private void uploadAdminAccounts() { content.clear();/*from w w w . j a va 2 s . co m*/ content.add(new HTMLPanel("<h1>Upload admin accounts</h1>")); final FlowPanel messageDiv = new FlowPanel(); content.add(messageDiv); content.add(new UserInfoUpload("admin", "admin", new ArrayList<String>(), new Callback1<Option<String>>() { @Override public void call(Option<String> res) { res.accept(new Option.SideEffectVisitor<String>() { @Override public void visitSome(String error) { messageDiv.clear(); messageDiv.getElement().getStyle().setColor("#d00"); messageDiv.add(new HTMLPanel(SafeHtmlUtils.fromString(error))); } @Override public void visitNone() { messageDiv.clear(); messageDiv.getElement().getStyle().setColor("#0d0"); messageDiv.add( new HTMLPanel(SafeHtmlUtils.fromString("Admin accounts uploaded successfully"))); } }); } })); }
From source file:net.scran24.admin.client.SurveyManagement.java
private void setControlsFor(String id) { surveyControls.clear();/*from w w w.j ava2 s . c om*/ final HTMLPanel idLabel = new HTMLPanel("<h2>" + SafeHtmlUtils.htmlEscape(id) + "</h2>"); final HTMLPanel staffUploadLabel = new HTMLPanel("<h3>Upload staff accounts</h3>"); final FlowPanel messageDiv = new FlowPanel(); messageDiv.getElement().addClassName("scran24-admin-survey-id-message"); List<String> permissions = Arrays.asList(new String[] { "downloadData:" + id, "readSurveys:" + id, "uploadUserInfo:" + id, "surveyControl:" + id }); final UserInfoUpload staffUpload = new UserInfoUpload(id, "staff", permissions, new Callback1<Option<String>>() { @Override public void call(Option<String> res) { res.accept(new Option.SideEffectVisitor<String>() { @Override public void visitSome(String error) { messageDiv.clear(); messageDiv.getElement().getStyle().setColor("#d00"); messageDiv.add(new HTMLPanel(SafeHtmlUtils.fromString(error))); } @Override public void visitNone() { messageDiv.clear(); messageDiv.getElement().getStyle().setColor("#0d0"); messageDiv.add(new HTMLPanel( SafeHtmlUtils.fromString("Staff accounts uploaded successfully"))); } }); } }); surveyControls.add(idLabel); surveyControls.add(staffUploadLabel); surveyControls.add(messageDiv); surveyControls.add(staffUpload); }
From source file:net.scran24.common.client.LoadingPanel.java
public LoadingPanel(final String message) { VerticalPanel panel = new VerticalPanel(); panel.setWidth("100%"); panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); panel.add(WidgetFactory.createLoadingPanelText(SafeHtmlUtils.fromString(message))); panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); panel.add(new LoadingWidget()); initWidget(panel);/*w ww .j a va 2 s .c o m*/ }
From source file:net.scran24.staff.client.StaffPage.java
private void initStage2(final long startDate, final long endDate, FlowPanel div) { div.clear();//from w ww . j a v a 2 s .co m div.add(new HTMLPanel("h2", "2. Upload the respondent accounts")); final FlowPanel messageDiv = new FlowPanel(); final Button start = WidgetFactory.createButton("Activate survey", new ClickHandler() { @Override public void onClick(ClickEvent event) { surveyControl.getParameters(new AsyncCallback<SurveyParameters>() { @Override public void onFailure(Throwable caught) { messageDiv.clear(); messageDiv.getElement().getStyle().setColor("#d00"); messageDiv.add(new HTMLPanel( SafeHtmlUtils.fromString("Survey could not be started: " + caught.getMessage()))); } @Override public void onSuccess(SurveyParameters result) { surveyControl.setParameters( result.withDates(startDate, endDate).withState(SurveyState.ACTIVE), new AsyncCallback<Void>() { @Override public void onSuccess(Void result) { Location.reload(); } @Override public void onFailure(Throwable caught) { messageDiv.clear(); messageDiv.getElement().getStyle().setColor("#d00"); messageDiv.add(new HTMLPanel(SafeHtmlUtils.fromString( "Survey could not be started: " + caught.getMessage()))); } }); } }); } }); start.getElement().addClassName("intake24-admin-button"); start.setEnabled(false); List<String> permissions = Arrays.asList(new String[] { "processSurvey:" + surveyId }); final UserInfoUpload userUpload = new UserInfoUpload(surveyId, "respondent", permissions, new Callback1<Option<String>>() { @Override public void call(Option<String> res) { res.accept(new Option.SideEffectVisitor<String>() { @Override public void visitSome(String error) { messageDiv.clear(); messageDiv.getElement().getStyle().setColor("#d00"); messageDiv.add(new HTMLPanel(SafeHtmlUtils.fromString(error))); start.setEnabled(false); } @Override public void visitNone() { messageDiv.clear(); messageDiv.getElement().getStyle().setColor("#0d0"); messageDiv.add(new HTMLPanel( SafeHtmlUtils.fromString("Respondent accounts uploaded successfully"))); start.setEnabled(true); } }); } }); div.add(userUpload); div.add(messageDiv); div.add(start); }
From source file:net.scran24.staff.client.StaffPage.java
private void updateUsers() { content.clear();//from w ww . j a v a2 s.c o m content.add(new HTMLPanel("<h2>Upload participant accounts from CSV</h2>")); content.add(new HTMLPanel( "<p><strong>Note:</strong> participant records from CSV files you upload using this page will be appended to the existing user list, which means that you can only add new accounts or update the passwords and custom fields for existing participants.</p><p>You <strong>cannot delete</strong> participant accounts from this page; if you need to delete existing participants please contact support.</p>")); final FlowPanel messageDiv = new FlowPanel(); List<String> permissions = Arrays.asList(new String[] { "processSurvey:" + surveyId }); final UserInfoUpload userUpload = new UserInfoUpload(surveyId, "respondent", permissions, new Callback1<Option<String>>() { @Override public void call(Option<String> res) { res.accept(new Option.SideEffectVisitor<String>() { @Override public void visitSome(String error) { messageDiv.clear(); messageDiv.getElement().getStyle().setColor("#d00"); messageDiv.add(new HTMLPanel(SafeHtmlUtils.fromString(error))); } @Override public void visitNone() { messageDiv.clear(); messageDiv.getElement().getStyle().setColor("#0d0"); messageDiv.add(new HTMLPanel( SafeHtmlUtils.fromString("Respondent accounts uploaded successfully"))); } }); } }); content.add(messageDiv); content.add(userUpload); }
From source file:net.scran24.user.client.Scran24.java
License:Apache License
public void onModuleLoad() { GWT.setUncaughtExceptionHandler(new Intake24UncaughtExceptionHandler()); // These divs are no longer used for content, but this code is left here // to handle legacy survey files final Element serverError = Document.get().getElementById("serverError"); if (serverError != null) serverError.removeFromParent();//from w ww . ja v a2 s . co m log.info("Fetching user information"); // This page should not be accessed unless the user is authenticated // as a respondent (see net.scran24.common.server.auth.ScranAuthFilter) loginService.getUserInfo(new AsyncCallback<Option<UserInfo>>() { @Override public void onSuccess(Option<UserInfo> result) { result.accept(new Option.SideEffectVisitor<UserInfo>() { @Override public void visitSome(final UserInfo userInfo) { CurrentUser.setUserInfo(userInfo); // Singleton portion size method for weight type-in // Inserted dynamically by client runtime but depends on // server-side configuration parameters (base image url) // so still has to be loaded once FoodLookupPrompt.preloadWeightPortionSizeMethod(new Callback() { @Override public void call() { initPage(userInfo); } }, new Callback() { @Override public void call() { HTMLPanel mainContentPanel = HTMLPanel.wrap(mainContent); mainContentPanel .add(new HTMLPanel(SafeHtmlUtils.fromString(commonMessages.serverError()))); } }); } @Override public void visitNone() { // this should never happen as any unauthenticated user // should be // redirected to the log in page, but still may happen // in some weird // case where the authentication token is lost between // the // authentication and opening this page LoginForm.showPopup(new Callback1<UserInfo>() { @Override public void call(final UserInfo userInfo) { initPage(userInfo); } }); } }); } @Override public void onFailure(Throwable caught) { HTMLPanel mainContentPanel = HTMLPanel.wrap(mainContent); mainContentPanel.add(new HTMLPanel(SafeHtmlUtils.fromString(commonMessages.serverError()))); } }); }
From source file:net.scran24.user.client.survey.prompts.RadioButtonQuestion.java
public RadioButtonQuestion(SafeHtml promptText, PVector<String> choices, String groupId, Option<String> otherOptionName) { this.choices = choices; this.otherOptionName = otherOptionName; UnorderedList<Widget> choiceList = new UnorderedList<Widget>(); choiceList.getElement().setId("intake24-radio-button-choices"); optionButtons = new RadioButton[choices.size()]; for (int i = 0; i < choices.size(); i++) { optionButtons[i] = new RadioButton(groupId, SafeHtmlUtils.fromString(choices.get(i))); choiceList.addItem(optionButtons[i]); }//w w w. ja va2 s. c om radioButtons = choiceList; if (!otherOptionName.isEmpty()) { FlowPanel otherPanel = new FlowPanel(); otherOption = new RadioButton(groupId, otherOptionName.getOrDie() + ": "); otherPanel.add(otherOption); otherBox = new TextBox(); otherPanel.add(otherBox); choiceList.addItem(otherPanel); otherBox.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { otherOption.setValue(true); } }); } contents = new FlowPanel(); contents.addStyleName("intake24-radio-button-question"); promptPanel = WidgetFactory.createPromptPanel(promptText); promptPanel.getElement().setId("intake24-radio-button-question"); contents.add(promptPanel); warningDiv = new FlowPanel(); warningDiv.addStyleName("intake24-radio-button-question-warning"); contents.add(warningDiv); contents.add(choiceList); initWidget(contents); }
From source file:org.activityinfo.core.shared.validation.ValidationUtils.java
License:Open Source License
public static void addMessage(String message, DivElement divContainer) { final SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); safeHtmlBuilder.appendHtmlConstant(divContainer.getInnerHTML()).appendHtmlConstant("<br/>") .append(SafeHtmlUtils.fromString(message)); divContainer.setInnerHTML(safeHtmlBuilder.toSafeHtml().asString()); }
From source file:org.activityinfo.core.shared.validation.ValidationUtils.java
License:Open Source License
public static void showMessages(List<String> messages, DivElement divContainer) { final SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); for (String message : messages) { safeHtmlBuilder.append(SafeHtmlUtils.fromString(message)).appendHtmlConstant("<br/>"); }/*from w w w . ja v a 2s.co m*/ divContainer.setInnerHTML(safeHtmlBuilder.toSafeHtml().asString()); }