List of usage examples for com.google.gwt.user.client.ui Label setText
public void setText(String text)
From source file:com.preferanser.client.application.mvp.player.PlayerViewImpl.java
License:Open Source License
@Override protected void displayHandContract(Hand hand, Contract contract) { Label label = getHandContractTextHolder(hand); label.setText( constants.getString(hand.name()) + " " + i18nHelper.getContractName(contract).toLowerCase()); label.setVisible(true);//ww w.j a v a2 s . c o m }
From source file:com.qtitools.player.client.view.PlayerWidget.java
License:Open Source License
/** * Create view for given assessment item and show it in player * @param index of assessment item//from w w w . j a v a2 s. c o m */ public void showPage(Assessment assessment, Item assessmentItem, int pageIndex) { Label itemTitleLabel = new Label(); // this.assessmentItem = assessmentItem; bodyPanel.clear(); footer.setVisible(true); counterPanel.setVisible(true); showFeedback(""); counterListBox.setSelectedIndex(pageIndex); counterLabel.setText("/" + assessment.DEBUGgetAssessmentItemsCount()); itemTitleLabel.setText(String.valueOf(pageIndex + 1) + ". " + assessmentItem.getTitle()); itemTitleLabel.setStyleName("qp-item-title"); bodyPanel.add(itemTitleLabel); bodyPanel.add(assessmentItem.getContentView()); bodyPanel.add(assessmentItem.getFeedbackView()); /* InlineHTML h = new InlineHTML(); h.setHTML("asdasd<script type=\"math/mml\"><math display=\"inline\"><mi>x</mi><mo>=</mo><mn>1</mn></math></script>"); bodyPanel.add(h); */ //MathExprInlineModule mein = new MathExprInlineModule("<msup><mfenced><mrow><mi>x</mi><mo>=</mo><mn>1</mn></mrow></mfenced><mn>4</mn></msup>"); //bodyPanel.add(mein); }
From source file:com.qualogy.qafe.gwt.client.component.QPagingScrollTable.java
License:Apache License
private void showPrompt(final String senderId, final String listenerType) { final org.gwt.mosaic.ui.client.MessageBox prompt = new org.gwt.mosaic.ui.client.MessageBox( MessageBoxType.PROMPT, "Confirm") { @Override/*from ww w . j ava2 s.co m*/ public void onClose(final boolean result) { } }; final Label message = new Label(); message.setText("Click ok to reset the data to initial value."); final Button ok = new Button("Ok"); ok.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent event) { resetInitialData = false; //datagridRendered = false; getRowValues().clear(); getDataTable().clear(); final List<DataContainerGVO> cloneOfInitialData = makeClone(initialData); insertData(cloneOfInitialData, false, senderId, listenerType); prompt.removeFromParent(); clearSelection(); } }); final Button cancel = new Button("Cancel"); cancel.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent event) { prompt.removeFromParent(); } }); final HorizontalPanel hp = new HorizontalPanel(); hp.add(ok); hp.add(cancel); final VerticalPanel vp = new VerticalPanel(); vp.add(message); vp.add(hp); prompt.add(vp); final int width = Window.getClientWidth() - 10; final int height = Window.getClientHeight() - 10; prompt.setSize(width + "", height + ""); prompt.showModal(); }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.events.EventFactory.java
License:Apache License
public static SubmitCompleteHandler createSubmitCompleteHandler(final UIObject ui, final EventListenerGVO ev, final List<InputVariableGVO> inputVariables) { SubmitCompleteHandler submitCompleteHandler = new SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { String uuId = event.getResults(); boolean success = false; if ((uuId != null) && (uuId.indexOf("=") > 0)) { uuId = uuId.substring(uuId.indexOf("=") + 1); success = true;//from w w w. j a v a2 s. c o m } FormPanel fp = (FormPanel) ui; if (fp instanceof HasWidgets) { HasWidgets hasWidgets = (HasWidgets) fp; Iterator<Widget> itr = hasWidgets.iterator(); while (itr.hasNext()) { Widget widget = itr.next(); if (widget instanceof Grid) { Grid gridPanel = (Grid) widget; FileUpload fileUpload = (FileUpload) gridPanel.getWidget(0, 0); if (success) { DOM.setElementAttribute(fileUpload.getElement(), "fu-uuid", uuId); CallbackHandler.createCallBack(ui, QAMLConstants.EVENT_ONFINISH, ev, inputVariables); } else { Label fileNameLabel = new Label("Uploading unsuccessfull.");// (Hyperlink) // gridPanel.getWidget(1, // 0); fileNameLabel.setText("Uploading unsuccessfull."); fileNameLabel.setVisible(true); gridPanel.add(fileNameLabel); } } } } } }; return submitCompleteHandler; }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.FileUploadRenderer.java
License:Apache License
public UIObject render(ComponentGVO component, String uuid, String parent, String context) { HorizontalPanel uiObject = null;// w ww . j a v a2 s. com final String finalParent = parent; if (component != null) { if (component instanceof FileUploadGVO) { if (component.getMenu() != null) { final ComponentGVO finalComponentGVO = component; final String finalUuid = uuid; uiObject = new HorizontalPanel() { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { uiObject = new HorizontalPanel(); } final FormPanel formPanel = new FormPanel(); formPanel.setAction(GWT.getModuleBaseURL() + "/rpc.upload"); formPanel.setEncoding(FormPanel.ENCODING_MULTIPART); formPanel.setMethod(FormPanel.METHOD_POST); final Button uploadButtonComponent = new Button("Upload"); uploadButtonComponent.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { formPanel.submit(); } }); final FileUpload fileUploadComponent = new FileUpload(); fileUploadComponent.setName("uploadElement"); fileUploadComponent.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { String filename = fileUploadComponent.getFilename(); boolean enabled = (filename != null) && (filename.length() > 0); uploadButtonComponent.setEnabled(enabled); } }); Hidden appId = new Hidden(); final String appID = ClientApplicationContext.getInstance().getWindowSession(); appId.setName("APPUUID=" + appID); Hidden windowId = new Hidden(); windowId.setName("WINDOWID=" + parent); Grid gridPanel = new Grid(2, 4); gridPanel.setWidget(0, 0, fileUploadComponent); gridPanel.setWidget(0, 1, uploadButtonComponent); gridPanel.setWidget(0, 2, appId); gridPanel.setWidget(0, 3, windowId); formPanel.add(gridPanel); RendererHelper.fillIn(component, formPanel, uuid, parent, context); formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { String uuId = event.getResults(); boolean success = false; if (uuId != null && uuId.indexOf("=") > 0) { uuId = uuId.substring(uuId.indexOf("=") + 1); success = true; } if (formPanel instanceof HasWidgets) { HasWidgets hasWidgets = (HasWidgets) formPanel; Iterator<Widget> itr = hasWidgets.iterator(); while (itr.hasNext()) { Widget widget = itr.next(); if (widget instanceof Grid) { Grid gridPanel = (Grid) widget; final FileUpload fileUpload = (FileUpload) gridPanel.getWidget(0, 0); final Button uploadButton = (Button) gridPanel.getWidget(0, 1); if (success) { fileUpload.setVisible(false); uploadButton.setVisible(false); String fileName = event.getResults().substring(0, event.getResults().indexOf("#")); final String viewUrl = GWT.getModuleBaseURL() + "/rpc.view?APPUUID=" + appID + "&WINDOWID=" + finalParent + "&VIEW=" + uuId; final Label fileNameLabel = new Label(fileName); DOM.setStyleAttribute(fileNameLabel.getElement(), "textDecoration", "underline"); DOM.setStyleAttribute(fileNameLabel.getElement(), "cursor", "hand"); fileNameLabel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Window.open(viewUrl, "UploadedFile", null); } }); fileNameLabel.setVisible(true); final Label clearLabel = new Label("Clear"); clearLabel.setVisible(true); final String finalUuId = uuId; DOM.setStyleAttribute(clearLabel.getElement(), "textDecoration", "underline"); DOM.setStyleAttribute(clearLabel.getElement(), "cursor", "hand"); clearLabel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { MainFactoryActions.removeUploadedFile(appID, finalParent, finalUuId); DOM.setElementAttribute(fileUpload.getElement(), "fu-uuid", ""); fileNameLabel.setVisible(false); clearLabel.setVisible(false); fileUpload.setVisible(true); uploadButton.setVisible(true); init(fileUpload, uploadButton); } }); gridPanel.setWidget(1, 0, fileNameLabel); gridPanel.setWidget(1, 1, clearLabel); DOM.setElementAttribute(fileUpload.getElement(), "fu-uuid", uuId); CallbackHandler.createCallBack(formPanel, "onfinish", null, null); } else { Hyperlink fileNameLabel = (Hyperlink) gridPanel.getWidget(1, 0); fileNameLabel.setText("Uploading unsuccessfull."); fileNameLabel.setVisible(true); } } } } } }); uiObject.add(formPanel); init(fileUploadComponent, uploadButtonComponent); } } return uiObject; }
From source file:com.qualogy.qafe.mgwt.client.ui.renderer.FileUploadRenderer.java
License:Apache License
public UIObject render(ComponentGVO component, String owner, String uuid, String parent, String context, AbstractActivity activity) {// w w w . j a v a 2 s .co m HorizontalPanel uiObject = null; final String finalParent = parent; if (component != null) { if (component instanceof FileUploadGVO) { if (component.getMenu() != null) { final ComponentGVO finalComponentGVO = component; final String finalUuid = uuid; uiObject = new HorizontalPanel() { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { uiObject = new HorizontalPanel(); } final FormPanel formPanel = new FormPanel(); formPanel.setAction(GWT.getModuleBaseURL() + "/rpc.upload"); formPanel.setEncoding(FormPanel.ENCODING_MULTIPART); formPanel.setMethod(FormPanel.METHOD_POST); FileUpload fileUploadComponent = new FileUpload(); fileUploadComponent.setName("uploadElement"); Button uploadButtonComponent = new Button("Upload"); uploadButtonComponent.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { formPanel.submit(); } }); Hidden appId = new Hidden(); appId.setName("APPUUID=" + uuid); final String appID = uuid; Hidden windowId = new Hidden(); windowId.setName("WINDOWID=" + parent); Grid gridPanel = new Grid(2, 4); gridPanel.setWidget(0, 0, fileUploadComponent); gridPanel.setWidget(0, 1, uploadButtonComponent); gridPanel.setWidget(0, 2, appId); gridPanel.setWidget(0, 3, windowId); formPanel.add(gridPanel); RendererHelper.fillIn(component, formPanel, uuid, parent, context); formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { String uuId = event.getResults(); boolean success = false; if (uuId != null && uuId.indexOf("=") > 0) { uuId = uuId.substring(uuId.indexOf("=") + 1); success = true; } if (formPanel instanceof HasWidgets) { HasWidgets hasWidgets = (HasWidgets) formPanel; Iterator<Widget> itr = hasWidgets.iterator(); while (itr.hasNext()) { Widget widget = itr.next(); if (widget instanceof Grid) { Grid gridPanel = (Grid) widget; final FileUpload fileUpload = (FileUpload) gridPanel.getWidget(0, 0); final Button uploadButton = (Button) gridPanel.getWidget(0, 1); if (success) { fileUpload.setVisible(false); uploadButton.setVisible(false); String fileName = event.getResults().substring(0, event.getResults().indexOf("#")); final String viewUrl = GWT.getModuleBaseURL() + "/rpc.view?APPUUID=" + appID + "&WINDOWID=" + finalParent + "&VIEW=" + uuId; final Label fileNameLabel = new Label(fileName); DOM.setStyleAttribute(fileNameLabel.getElement(), "textDecoration", "underline"); DOM.setStyleAttribute(fileNameLabel.getElement(), "cursor", "hand"); fileNameLabel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Window.open(viewUrl, "UploadedFile", null); } }); fileNameLabel.setVisible(true); final Label removeLabel = new Label("Remove"); removeLabel.setVisible(true); final String finalUuId = uuId; DOM.setStyleAttribute(removeLabel.getElement(), "textDecoration", "underline"); DOM.setStyleAttribute(removeLabel.getElement(), "cursor", "hand"); removeLabel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { MainFactoryActions.removeUploadedFile(appID, finalParent, finalUuId); DOM.setElementAttribute(fileUpload.getElement(), "fu-uuid", ""); fileNameLabel.setVisible(false); removeLabel.setVisible(false); fileUpload.setVisible(true); uploadButton.setVisible(true); } }); gridPanel.setWidget(1, 0, fileNameLabel); gridPanel.setWidget(1, 1, removeLabel); DOM.setElementAttribute(fileUpload.getElement(), "fu-uuid", uuId); CallbackHandler.createCallBack(formPanel, "onfinish", null, null); } else { Hyperlink fileNameLabel = (Hyperlink) gridPanel.getWidget(1, 0); fileNameLabel.setText("Uploading unsuccessfull."); fileNameLabel.setVisible(true); } } } } } }); uiObject.add(formPanel); } } return uiObject; }
From source file:com.sciencegadgets.client.algebra.AlgebraActivity.java
License:Open Source License
/** * Updates the equation in all places when a change is made * /*from w w w .jav a 2 s. c o m*/ * @param changeComment * - use null for simple reload, specify change to add to AlgOut */ public void reloadEquationPanel(String changeComment, HashMap<Skill, Integer> skillsIncrease, boolean updateParameters, final String nodeIdToSelect) { EquationTree equationTree = getEquationTree(); AlgebraHistory currentAlgOut = systemOfEquations.getInfo(equationTree).history; if (ActivityType.interactiveequation == activityType) { if (currentAlgOut == null) { reCreateAlgHistory(); } else if (algOut != currentAlgOut) { algOut = currentAlgOut; setDefaultUpperMidWidget(currentAlgOut); } if (changeComment != null) { Skill skill = null; if (skillsIncrease != null && !skillsIncrease.isEmpty()) { skill = (Skill) skillsIncrease.keySet().toArray()[0]; } algOut.updateAlgebraHistory(changeComment, skill, equationTree); } } if (inProgramaticTransformMode) { return; } else if (activityType == ActivityType.simplifyquiz) { // equationTree.getEquals().setSymbol( // TypeSGET.Operator.ARROW_RIGHT.getSign()); // equationTree.getEquals().setSymbol( // TypeSGET.Operator.SPACE.getSign()); } else if (transformPanel != null && transformPanel.simplifyQuiz != null) { transformPanel.simplifyQuiz.disappear(); transformPanel.simplifyQuiz = null; } try { equationTree.validateTree(); } catch (IllegalStateException e) { String message = e.getMessage(); if (message == null) { Window.alert("Oops, an error occured, please refresh the page"); } else { Window.alert(message); } JSNICalls.error(e.getCause().toString()); return; } eqPanelHolder.clear(); // TODO // revertUpperMidAreaToDefault(); equationTree.reloadDisplay(true, true); if (eqPanel != null && eqPanel.isAttached()) { eqPanel.removeFromParent(); } eqPanel = new EquationPanel(this); eqPanelHolder.add(eqPanel); if (activityType == ActivityType.interactiveequation) { lowerEqArea.clear(); algOut.scrollToBottom(); for (Badge newBadge : Moderator.newBadgeCollection) { Label newBadgeResponse = new Label(); newBadgeResponse.addStyleName(CSS.DROP_ENTER_RESPONSE); newBadgeResponse.setText("New Badge! - " + newBadge.toString()); } // TypeSGET rightType = equationTree.getRightSide().getType(); // TypeSGET leftType = equationTree.getLeftSide().getType(); // // Check if evaluated // if ((TypeSGET.Variable.equals(leftType) && TypeSGET.Number // .equals(rightType))) { // SolvedPrompt solvedPrompt = new SolvedPrompt(); // solvedPrompt.solved(this, equationTree.getRightSide() // .getSymbol()); // } else if ((TypeSGET.Variable.equals(rightType) && TypeSGET.Number // .equals(leftType))) { // SolvedPrompt solvedPrompt = new SolvedPrompt(); // solvedPrompt.solved(this, equationTree.getLeftSide() // .getSymbol()); // } else if (goalTree != null && equationTree.isLike(goalTree)) { // // Check if equation matches goal // SolvedPrompt solvedPrompt = new SolvedPrompt(); // solvedPrompt.solved(this); // } Moderator.newBadgeCollection.clear(); } if (updateParameters && (activityType == ActivityType.interactiveequation || activityType == ActivityType.editequation)) { HashMap<Parameter, String> parameterMap = new HashMap<Parameter, String>(); parameterMap.put(Parameter.equation, equationTree.getEquationXMLString()); parameterMap.put(Parameter.activity, activityType.toString()); if (goalTree != null) { parameterMap.put(Parameter.goal, goalTree.getEquationXMLString()); } if (systemOfEquations.hasMultipleEquations()) { parameterMap.put(Parameter.system, systemOfEquations.getURLParam()); } URLParameters.setParameters(parameterMap, false); } if (nodeIdToSelect != null) { Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { eqPanel.zoomToAndSelect(nodeIdToSelect); } }); } }
From source file:com.sciencegadgets.client.algebra.AlgebraHistory.java
License:Open Source License
public void solvedUpdate(EquationTree mathTree, String evaluation) { AlgebraHistoryRow lastRow = new AlgebraHistoryRow(mathTree.getDisplay()); lastRow.eqSide.getElement().getStyle().setFontSize(300, Unit.PCT); lastRow.ruleSide.removeFromParent(); add(lastRow);/* www . j a v a2s .c o m*/ Label evaluatedBox = new Label(); JSNICalls.log("ev " + evaluation); evaluatedBox.addStyleName(CSS.ALG_OUT_RULE_ROW); // evaluatedBox.addFocusHandler(new HighlightHandler(evaluatedBox)); lastRow.add(evaluatedBox); evaluatedBox.setText(evaluation); }
From source file:com.sciencegadgets.client.algebra.transformations.NumberTransformations.java
License:Open Source License
@Override public void transform() { LinkedHashSet<Integer> primeFactors = AlgebraicTransformations.FIND_PRIME_FACTORS(number); Prompt prompt = new Prompt(false); Label title = new Label(); title.setText("" + number); title.setHeight("20%"); prompt.add(title);/*from w w w .ja v a 2s . c o m*/ for (Integer factor : primeFactors) { prompt.add(new FactorNumberButton(factor, number / factor, prompt, context)); } prompt.appear(); }
From source file:com.sciencegadgets.client.ui.SolvedPrompt.java
License:Open Source License
public void solved(AlgebraActivity algebraActivity, String evaluation) { // Moderator.SOUNDS.RESPONSE_SUCCESS.play(); historyContainer.clear();//from w ww .j a v a 2 s. c o m AlgebraHistory algOut = algebraActivity.getAlgebraHistory(); algOut.solvedUpdate(algebraActivity.getEquationTree(), evaluation); algOut.isSolved = true; historyContainer.getElement().appendChild(algOut.getElement().cloneNode(true)); skillContainer.clear(); //Show new badged if (!Moderator.newBadgeCollection.isEmpty()) { for (Badge newBadge : Moderator.newBadgeCollection) { Label newBadgeResponse = new Label(); newBadgeResponse.addStyleName(CSS.DROP_ENTER_RESPONSE); newBadgeResponse.setText("New Badge! - " + newBadge.toString()); skillContainer.add(newBadgeResponse); } } //Show skills increased if (!Moderator.skillsIncreasedCollection.isEmpty()) { Label skillLabel = new Label("Skills Increased"); skillLabel.getElement().getStyle().setFontWeight(FontWeight.BOLDER); skillContainer.add(skillLabel); for (Entry<Skill, Integer> skillEntry : Moderator.skillsIncreasedCollection.entrySet()) { skillContainer.add(new Label(skillEntry.getKey() + ": +" + skillEntry.getValue())); } Moderator.skillsIncreasedCollection.clear(); } appear(); }