private void displayMessage(final String message) { if (message != null && !message.isEmpty()) { messageDisplay.setHTML(wrapDisplayMessage(message)); messageDisplay.setVisible(true); } else { messageDisplay.setVisible(false); } }
public void showResult(int status) { String formattedVelocityKM_H = NumberFormat.getFormat(".0").format(Utils.SPEED_LIMITS[speedIndex]); String formattedVelocity = NumberFormat.getFormat(".0").format(Utils.SPEED_LIMITS[speedIndex] / 3.6); if (status == Utils.CORRECT) { htmlResult.setHTML( "Congratulations, you have achieved the goal of driving " + "<span class='app-emphasize'>" + destDistance + "</span> meters " + "by driving your car at the speed of " + "<span class='app-emphasize'>" + formattedVelocityKM_H + "</span> km/h" + "(<span class='app-emphasize'>" + formattedVelocity + "</span> m/s) for " + "<span class='app-emphasize'>" + time + "</span> " + " seconds. A new challenge is set for you. " + "Repeat Steps 1 - 3 to see if you could solve the challenge again."); // reset question int randomTime = Random.nextInt(10) + 1; double randomSpeed = Utils.SPEED_LIMITS[Random.nextInt(Utils.SPEED_LIMITS.length)] / 3.6; destDistance = (int) (randomTime * randomSpeed); description.setHTML( "Your goal is to travel " + "<span class='app-emphasize'>" + destDistance + "</span> " + "meters with your car. " + "Set the number of seconds you would like to drive your car (step 1) " + "and the speed of your car (step 2). Hit the 'Drive' button to see " + "if your car moves exactly " + "<span class='app-emphasize'>" + destDistance + "</span> " + "meters."); } else { htmlResult.setHTML( "Sorry, the distance of your drive " + "(<span class='app-emphasize'>" + (int) (Math.round(velocity * time)) + "m</span>)" + " did not match the goal" + "(<span class='app-emphasize'>" + destDistance + "m</span>). " + "Please adjust your velocity and/or time before hitting the 'Drive' button " + "to see if your adjustment makes the trick."); } htmlResult.setVisible(true); }
*/ @Override public void setBackToSearch() { boolean visible = false; searchRequest = AppClientFactory.getPlaceManager().getPreviousRequest(); if (searchRequest != null) { String query = searchRequest.getParameter("query", null); visible = searchRequest != null && query != null; backToSearchFloPanel.getElement().getStyle().setDisplay(Display.BLOCK); if (visible) { if (query.length() > 50) { query = query.substring(0, 50) + "..."; backToSearchHtml.setHTML(PRE_SEARCH_LINK + query + "\""); } else { backToSearchHtml.setHTML(PRE_SEARCH_LINK + query + "\""); } } } backToSearchPreHtml.setVisible(visible); backToSearchHtml.setVisible(visible); }
public void init(final KieImageType imageType, final int containersRunningCount) { if (imageType == null) return; final SafeUri imageUri = ClientUtils.getImageUri(imageType); typeNameText.setText(imageType.getName()); if (containersRunningCount < 0) { countText.setVisible(false); } else if (containersRunningCount == 0 && showCreateButton && !KieImageCategory.OTHERS.equals(imageType.getCategory())) { countText.setText(Constants.INSTANCE.createNew()); countText.setTitle(Constants.INSTANCE.createNewForThisType()); countText.addStyleName(style.createNewButton()); countText.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { KieImageTypeView.this.fireEvent(new CreateContainerEvent(imageType)); } }); countText.setVisible(true); } else { countText.setText(Integer.toString(containersRunningCount)); countText.removeStyleName(style.createNewButton()); countText.setVisible(true); } typeImage.setUrl(imageUri); typeImage.setSize(size, size); typeImage.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { KieImageTypeView.this.fireEvent(new ImageTypeSelectedEvent(imageType)); } }); mainPanel.setVisible(true); }
@Override public Object getProperty(Object object, String propertyName) { Bloc value = (Bloc) object; if ("draganddrop".equals(propertyName)) { HTML html = new HTML(" "); html.setStyleName("DragRowHandle"); if (controller != null) { BlocClipboard clipboard = new BlocClipboard(value); controller.registerDrag(html, mapper.map(value), clipboard, GROUPNAME); controller.registerDrop(html, clipboard, GROUPNAME); } html.setVisible(!isReadOnly()); return html; } else if ("content".equals(propertyName)) { Component component = newComponent(); component.setValue(value); ItemWidget itemWidget = new ItemWidget(component, mapper); items.add(itemWidget); return itemWidget; } else if (("action").equals(propertyName)) { ActionsPanel actionsPanel = new ActionsPanel(); actionsPanel .getDelete() .addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { if (!isReadOnly()) { if (Window.confirm("Supprimer ce " + contentColumnName + " ?")) { Cell cell = view.getGrid().getCellForEvent(event); Widget w = view.getGrid().getWidget(cell.getRowIndex(), 1); if (w instanceof ItemWidget) { ItemWidget itemWidget = (ItemWidget) w; removeItem(itemWidget.getValue()); items.remove(itemWidget); } refreshWidget(); ValueChangeEvent.fire(ExtendedAbstractComponent.this, getValue()); } } } }); actionsPanel.setVisible(!isReadOnly()); return actionsPanel; } return ""; }
private void attachBackgroundScreenToRootPanel() { if (backgroundScreen == null) { String html = backgroundScreenHtmlTemplate.replaceAll( "DIV_WIDTH", "" + RootPanel.get().getOffsetWidth()); html = html.replaceAll("DIV_HEIGHT", "" + RootPanel.get().getOffsetHeight()); backgroundScreen = new HTML(html); } // if ( RootPanel.get().getWidgetIndex(backgroundScreen) > 0) { // background already attached // } else { backgroundScreen.setVisible(true); RootPanel.get().add(backgroundScreen); // } }
public void initQuestion() { description = new HTML(""); questionPanel.add(description); int randomTime = Random.nextInt(10) + 1; double randomSpeed = Utils.SPEED_LIMITS[Random.nextInt(Utils.SPEED_LIMITS.length)] / 3.6; destDistance = (int) (randomTime * randomSpeed); description.setHTML( "Your goal is to travel " + "<span class='app-emphasize'>" + destDistance + " meters</span> " + "with your car. " + "Set the number of seconds you would like to drive your car (step 1) " + "and the speed of your car (step 2). Hit the 'Drive' button to see " + "if your car moves exactly " + "<span class='app-emphasize'>" + destDistance + " meters</span>. "); HTML step1 = new HTML("<span class='app-title3'>Step 1.</span> Choose the time:"); questionPanel.add(step1); questionPanel.add(this.getTimeSelector()); HTML step2 = new HTML("<span class='app-title3'>Step 2.</span> Choose the limit speed of the road:"); questionPanel.add(step2); questionPanel.add(this.getSpeedSelector()); HTML step3 = new HTML( "<span class='app-title3'>Step 3.</span> Hit the " + "<span class='app-emphasize'>'Drive'</span> button to start challenge:"); questionPanel.add(step3); questionPanel.add(this.getRunButtonPanel()); htmlResult = new HTML(""); htmlResult.setVisible(false); questionPanel.add(htmlResult); questionPanel.add(this.getFootage()); }
public Widget asWidget() { final TabPanel tabs = new TabPanel(); tabs.setStyleName("default-tabpanel"); // ------- VerticalPanel layout = new VerticalPanel(); layout.setStyleName("window-content"); // Create a FormPanel and point it at a service. final FormPanel form = new FormPanel(); String url = Console.getBootstrapContext().getProperty(BootstrapContext.DEPLOYMENT_API); form.setAction(url); form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); // Create a panel to hold all of the form widgets. VerticalPanel panel = new VerticalPanel(); panel.getElement().setAttribute("style", "width:100%"); form.setWidget(panel); // Create a FileUpload widgets. final FileUpload upload = new FileUpload(); upload.setName("uploadFormElement"); panel.add(upload); final HTML errorMessages = new HTML("Please chose a file!"); errorMessages.setStyleName("error-panel"); errorMessages.setVisible(false); panel.add(errorMessages); // Add a 'submit' button. ClickHandler cancelHandler = new ClickHandler() { @Override public void onClick(ClickEvent event) { window.hide(); } }; ClickHandler submitHandler = new ClickHandler() { @Override public void onClick(ClickEvent event) { errorMessages.setVisible(false); // verify form String filename = upload.getFilename(); if (tabs.getTabBar().getSelectedTab() == 1) { // unmanaged content if (unmanagedForm.validate().hasErrors()) { return; } else { wizard.onCreateUnmanaged(unmanagedForm.getUpdatedEntity()); } } else if (filename != null && !filename.equals("")) { loading = Feedback.loading( Console.CONSTANTS.common_label_plaseWait(), Console.CONSTANTS.common_label_requestProcessed(), new Feedback.LoadingCallback() { @Override public void onCancel() {} }); form.submit(); } else { errorMessages.setVisible(true); } } }; DialogueOptions options = new DialogueOptions( Console.CONSTANTS.common_label_next(), submitHandler, Console.CONSTANTS.common_label_cancel(), cancelHandler); // Add an event handler to the form. form.addSubmitCompleteHandler( new FormPanel.SubmitCompleteHandler() { @Override public void onSubmitComplete(FormPanel.SubmitCompleteEvent event) { getLoading().hide(); String html = event.getResults(); // Step 1: upload content, retrieve hash value try { String json = html; try { if (!GWT.isScript()) // TODO: Formpanel weirdness json = html.substring(html.indexOf(">") + 1, html.lastIndexOf("<")); } catch (StringIndexOutOfBoundsException e) { // if I get this exception it means I shouldn't strip out the html // this issue still needs more research Log.debug("Failed to strip out HTML. This should be preferred?"); } JSONObject response = JSONParser.parseLenient(json).isObject(); JSONObject result = response.get("result").isObject(); String hash = result.get("BYTES_VALUE").isString().stringValue(); // step2: assign name and group wizard.onUploadComplete(upload.getFilename(), hash); } catch (Exception e) { Log.error(Console.CONSTANTS.common_error_failedToDecode() + ": " + html, e); } // Option 2: Unmanaged content } }); String stepText = "<h3>" + Console.CONSTANTS.common_label_step() + "1/2: " + Console.CONSTANTS.common_label_deploymentSelection() + "</h3>"; layout.add(new HTML(stepText)); HTML description = new HTML(); description.setHTML(Console.CONSTANTS.common_label_chooseFile()); description.getElement().setAttribute("style", "padding-bottom:15px;"); layout.add(description); layout.add(form); tabs.add(layout, "Managed"); // Unmanaged form only for new deployments if (!wizard.isUpdate()) { VerticalPanel unmanagedPanel = new VerticalPanel(); unmanagedPanel.setStyleName("window-content"); String unmanagedText = "<h3>" + Console.CONSTANTS.common_label_step() + "1/1: Specify Deployment</h3>"; unmanagedPanel.add(new HTML(unmanagedText)); unmanagedForm = new Form<DeploymentRecord>(DeploymentRecord.class); TextAreaItem path = new TextAreaItem("path", "Path"); TextBoxItem relativeTo = new TextBoxItem("relativeTo", "Relative To", false); TextBoxItem name = new TextBoxItem("name", "Name"); TextBoxItem runtimeName = new TextBoxItem("runtimeName", "Runtime Name"); CheckBoxItem archive = new CheckBoxItem("archive", "Is Archive?"); archive.setValue(true); unmanagedForm.setFields(path, relativeTo, archive, name, runtimeName); unmanagedPanel.add(unmanagedForm.asWidget()); tabs.add(unmanagedPanel, "Unmanaged"); } tabs.selectTab(0); return new WindowContentBuilder(tabs, options).build(); }
public CriterionHeader(int idx, int cid, String cdesc, float b, int regrid, int regraccepted) { this.mainPanel = new VerticalPanel(); this.mainPanel.addStyleName(Resources.INSTANCE.css().criterionrow()); this.criterionId = cid; this.criterionDescription = cdesc; this.index = idx; Label lbl = new Label(cdesc); lbl.addStyleName(Resources.INSTANCE.css().criterionheader()); lbl.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { if (commentId > 0 && commentPage > 0) EMarkingWeb.markingInterface .getMarkingPagesInterface() .highlightRubricMark(commentId, commentPage); } }); mainPanel.add(lbl); HorizontalPanel horizontal = new HorizontalPanel(); horizontal.addStyleName(Resources.INSTANCE.css().colorsquaretable()); // the square with the color if (EMarkingConfiguration.isColoredRubric()) { Label lbl2 = new Label(""); Color.setWidgetBackgroundHueColor(cid, lbl2); lbl2.addStyleName(Resources.INSTANCE.css().colorsquare()); lbl2.setTitle(String.valueOf(idx)); // lbl2.addStyleName(MarkingInterface.getMapCss().get("colorsquare")); // HTML rectangle = new HTML(); // rectangle.setHTML("<div data-index='"+idx+"' style='width:20px; height:20px;border:1px // solid #000;' class='"+ MarkingInterface.getMapCss().get("color"+idx) +" // "+MarkingInterface.getMapCss().get("colorsquare") + "' ></div>"); lbl2.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { Label rectangle = (Label) event.getSource(); int index = Integer.parseInt(rectangle.getTitle()); EMarkingWeb.markingInterface .getToolbar() .getMarkingButtons() .changeCriterionList(index); } }); horizontal.add(lbl2); } HTML separation = new HTML(); separation.setHTML("<div style='width:20px;height:20px;'></div>"); horizontal.add(separation); mainPanel.add(horizontal); bonusHtml = new HTML(); setBonus(b); mainPanel.add(bonusHtml); regradeHtml = new HTML(); regradeHtml.setVisible(false); mainPanel.add(regradeHtml); this.setRegradeData(regrid, regraccepted); loadingIcon = new HTML(); loadingIcon.setVisible(false); Icon iconloading = new Icon(IconType.COG); loadingIcon.setHTML(iconloading.toString()); loadingIcon.addStyleName(Resources.INSTANCE.css().loadingicon()); loadingIcon.addStyleName("icon-spin"); mainPanel.add(loadingIcon); mainPanel.setCellHorizontalAlignment(loadingIcon, HasHorizontalAlignment.ALIGN_CENTER); initWidget(mainPanel); }
public void setMarkerVisible(boolean visible) { bonusHtml.setVisible(visible); regradeHtml.setVisible(visible); if (this.regradeid == 0) regradeHtml.setVisible(false); }
public void hideResult() { htmlResult.setVisible(false); }
@Override public void hide(boolean autoClosed) { super.hide(autoClosed); backgroundScreen.setVisible(false); }
@Override public void hide() { super.hide(); backgroundScreen.setVisible(false); }
/** * ********************************************************* Overriden methods, for supporting an * background fading ********************************************************* */ @Override public void show() { super.show(); backgroundScreen.setVisible(true); }
private void initMessage(final String message) { final RootPanel messagePanel = RootPanel.get("messagePlaceholder"); messageDisplay.setVisible(false); messagePanel.add(messageDisplay); displayMessage(message); }