List of usage examples for com.google.gwt.user.client.ui Label setText
public void setText(String text)
From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.HeadingPitchRoll.java
License:Apache License
@Override public void buildPanel() { ViewerPanel csVPanel = new ViewerPanel(); pathPosition = new SampledPositionProperty(); PathGraphicsOptions pathGraphicsOptions = new PathGraphicsOptions(); pathGraphicsOptions.show = new ConstantProperty<>(true); pathGraphicsOptions.leadTime = new ConstantProperty<>(0); pathGraphicsOptions.trailTime = new ConstantProperty<>(60); pathGraphicsOptions.width = new ConstantProperty<>(10); pathGraphicsOptions.resolution = new ConstantProperty<>(1); pathGraphicsOptions.material = PolylineGlowMaterialProperty.create(Color.PALEGOLDENROD(), 0.3); EntityOptions entityOptions = new EntityOptions(); entityOptions.position = pathPosition; entityOptions.name = "path"; entityOptions.path = new PathGraphics(pathGraphicsOptions); Entity entityPath = csVPanel.getViewer().entities().add(entityOptions); final org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().camera; final ScreenSpaceCameraController controller = csVPanel.getViewer().scene().screenSpaceCameraController(); final Cartesian3 center = new Cartesian3(); final org.cesiumjs.cs.core.HeadingPitchRoll hpRoll = new org.cesiumjs.cs.core.HeadingPitchRoll(); final HeadingPitchRange hpRange = new HeadingPitchRange(); position = Cartesian3.fromDegrees(-123.0744619, 44.0503706, 5000.0); speedVector = new Cartesian3(); final Transforms.LocalFrameToFixedFrame fixedFrameTransform = Transforms .localFrameToFixedFrameGenerator("north", "west"); FromGltfOptions fromGltfOptions = new FromGltfOptions(); fromGltfOptions.url = GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb"; fromGltfOptions.modelMatrix = Transforms.headingPitchRollToFixedFrame(position, hpRoll, Ellipsoid.WGS84());//, fixedFrameTransform); fromGltfOptions.minimumPixelSize = 128; planePrimitive = (Model) csVPanel.getViewer().scene().primitives().add(Model.fromGltf(fromGltfOptions)); planePrimitive.readyPromise().then(new Fulfill<Model>() { @Override/* w w w.jav a 2 s . co m*/ public void onFulfilled(Model model) { ModelAnimationOptions modelAnimationOptions = new ModelAnimationOptions(); modelAnimationOptions.multiplier = 0.5; modelAnimationOptions.loop = ModelAnimationLoop.REPEAT(); model.activeAnimations.addAll(modelAnimationOptions); // Zoom to model r = 2.0 * max(model.boundingSphere().radius, ((PerspectiveFrustum) camera.frustum).near); controller.minimumZoomDistance = r * 0.5; Matrix4.multiplyByPoint(model.modelMatrix, model.boundingSphere().center, center); double heading = Math.toRadians(230.0); double pitch = Math.toRadians(-20.0); hpRange.heading = heading; hpRange.pitch = pitch; hpRange.range = r * 50.0; camera.lookAt(center, hpRange); } }); fromBehind = new CheckBox(); fromBehind.getElement().getStyle().setColor("white"); fromBehind.setWidth("100px"); fromBehind.setValue(false); final com.google.gwt.user.client.ui.Label headingLabel = new Label(); headingLabel.getElement().getStyle().setColor("white"); headingLabel.setText("Heading:"); final com.google.gwt.user.client.ui.Label pitchLabel = new Label(); pitchLabel.getElement().getStyle().setColor("white"); pitchLabel.setText("Pitch:"); final com.google.gwt.user.client.ui.Label rollLabel = new Label(); rollLabel.getElement().getStyle().setColor("white"); rollLabel.setText("Roll:"); final com.google.gwt.user.client.ui.Label speedLabel = new Label(); speedLabel.getElement().getStyle().setColor("white"); speedLabel.setText("Speed:m/s"); FlexTable flexTable = new FlexTable(); flexTable.setWidget(0, 0, headingLabel); flexTable.setHTML(1, 0, "<font color=\"white\">? to left/ to right</font>"); flexTable.setWidget(2, 0, pitchLabel); flexTable.setHTML(3, 0, "<font color=\"white\"> to up/ to down</font>"); flexTable.setWidget(4, 0, rollLabel); flexTable.setHTML(5, 0, "<font color=\"white\">? + left/ + right</font>"); flexTable.setWidget(6, 0, speedLabel); flexTable.setHTML(7, 0, "<font color=\"white\"> + to speed up/ + to speed down</font>"); flexTable.setHTML(8, 0, "<font color=\"white\">Following aircraft</font>"); flexTable.setWidget(8, 1, fromBehind); AbsolutePanel aPanel = new AbsolutePanel(); aPanel.add(csVPanel); aPanel.add(flexTable, 20, 20); contentPanel.add(new HTML("<p>Click on the 3D window then use the keyboard to change settings.</p>")); contentPanel.add(aPanel); csVPanel.getViewer().scene().preRender().addEventListener(new Scene.Listener() { @Override public void function(Scene scene, JulianDate time) { headingLabel.setText("Heading:" + Math.toDegrees(hpRoll.heading) + ""); pitchLabel.setText("Pitch:" + Math.toDegrees(hpRoll.pitch) + ""); rollLabel.setText("Roll:" + Math.toDegrees(hpRoll.roll) + ""); speedLabel.setText("Speed:" + speed + "m/s"); speedVector = Cartesian3.multiplyByScalar(Cartesian3.UNIT_X(), speed / 10, speedVector); position = Matrix4.multiplyByPoint(planePrimitive.modelMatrix, speedVector, position); pathPosition.addSample(JulianDate.now(), position); Transforms.headingPitchRollToFixedFrame(position, hpRoll, Ellipsoid.WGS84(), fixedFrameTransform, planePrimitive.modelMatrix); if (fromBehind.getValue()) { // Zoom to model Matrix4.multiplyByPoint(planePrimitive.modelMatrix, planePrimitive.boundingSphere().center, center); hpRange.heading = hpRoll.heading; hpRange.pitch = hpRoll.pitch; camera.lookAt(center, hpRange); } } }); RootPanel.get().addDomHandler(new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent keyDownEvent) { switch (keyDownEvent.getNativeKeyCode()) { case 40: if (keyDownEvent.getNativeEvent().getShiftKey()) { speed = max(--speed, 1); } else { hpRoll.pitch -= deltaRadians; if (hpRoll.pitch < -Math.TWO_PI()) { hpRoll.pitch += Math.TWO_PI(); } } break; case 38: if (keyDownEvent.getNativeEvent().getShiftKey()) { // speed up speed = min(++speed, 100); } else { // pitch up hpRoll.pitch += deltaRadians; if (hpRoll.pitch > Math.TWO_PI()) { hpRoll.pitch -= Math.TWO_PI(); } } break; case 39: if (keyDownEvent.getNativeEvent().getShiftKey()) { // roll right hpRoll.roll += deltaRadians; if (hpRoll.roll > Math.TWO_PI()) { hpRoll.roll -= Math.TWO_PI(); } } else { // turn right hpRoll.heading += deltaRadians; if (hpRoll.heading > Math.TWO_PI()) { hpRoll.heading -= Math.TWO_PI(); } } break; case 37: if (keyDownEvent.getNativeEvent().getShiftKey()) { // roll left until hpRoll.roll -= deltaRadians; if (hpRoll.roll < 0.0) { hpRoll.roll += Math.TWO_PI(); } } else { // turn left hpRoll.heading -= deltaRadians; if (hpRoll.heading < 0.0) { hpRoll.heading += Math.TWO_PI(); } } break; default: break; } } }, KeyDownEvent.getType()); initWidget(contentPanel); }
From source file:org.cloudcoder.app.client.view.AccordionPanel.java
License:Open Source License
private void decorateLabel(Label label, String decoration) { String text = label.getText(); label.setText(decoration + " " + text.substring(4)); }
From source file:org.codehaus.mojo.gwt.test.client.Hello.java
License:Apache License
public void onModuleLoad() { User user = new User(); final Label l = new Label("GWT says : " + user.sayHello()); RootPanel.get().add(l);//from w w w .j a v a 2 s . c o m Button b = new Button("click me !"); RootPanel.get().add(b); b.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { service.sayHello("hello", new AsyncCallback<String>() { public void onFailure(Throwable caught) { l.setText("RPC failure " + caught.getMessage()); GWT.log("RPC failure", caught); } public void onSuccess(String result) { l.setText(result); } }); } }); }
From source file:org.cruxframework.crux.plugin.errorhandler.client.SuperErrorHandler.java
License:Apache License
private void checkErrorsOnServer(final ErrorHandlerServiceAsync errorHandlerService, final SuperErrorHandlerResource resources, final Throwable originalError) { errorHandlerService.getError(new AsyncCallback<ArrayList<Throwable>>() { @Override//from ww w .j a v a2 s.c o m public void onSuccess(ArrayList<Throwable> result) { if (result == null) { result = new ArrayList<Throwable>(); } if (originalError != null) { result.add(result.size(), originalError); } FlowPanel errorContainer = new FlowPanel(); for (Throwable throwable : result) { FlowPanel errorMsgContainer = new FlowPanel(); errorMsgContainer.setStyleName(resources.css().errorMsgContainer()); FlowPanel errorMsgContainerHeader = new FlowPanel(); errorMsgContainerHeader.setStyleName(resources.css().errorMsgContainerHeader()); Label labelHeader = new Label(); labelHeader.setText(throwable.getMessage()); errorMsgContainerHeader.add(labelHeader); errorMsgContainer.add(errorMsgContainerHeader); StringBuffer sb = new StringBuffer(); if (throwable.getStackTrace() != null) { for (StackTraceElement stackTraceElement : throwable.getStackTrace()) { sb.append(stackTraceElement.toString() + "\n"); } FlowPanel errorMsgContainerBody = new FlowPanel(); errorMsgContainerBody.setStyleName(resources.css().errorMsgContainerBody()); Label labelStack = new Label(); labelStack.setText(sb.toString()); errorMsgContainerBody.add(labelStack); errorMsgContainer.add(errorMsgContainerBody); } errorContainer.add(errorMsgContainer); } Document.get().getBody().appendChild(errorContainer.getElement()); } @Override public void onFailure(Throwable exception) { Window.alert("CRITICAL ERROR: failed to connect service to get log: " + exception.getMessage()); } }); }
From source file:org.cruxframework.crux.widgets.client.uploader.AbstractFileUploader.java
License:Apache License
protected void createThumbnailIfSupported(Blob file, final FlowPanel filePanel) { FileReader fileReader = FileReader.createIfSupported(); // if is supported and is image create it, otherwise create a visual fallback. // image must have mimetype AND extension of images to pass if (fileReader == null || !SUPPORTED_IMAGES_MIMETYPES.contains(file.getType()) || !SUPPORTED_IMAGES_EXTENSIONS.contains(this.retrieveFileExtension(((File) file).getName()))) { String fileExt = "." + this.retrieveFileExtension(((File) file).getName()); Label label = new Label(); label.setStyleName("thumbnailImage noPreview"); label.setText(fileExt); filePanel.add(label);//w w w . j av a 2s . co m return; } else { fileReader.readAsDataURL(file, new ReaderStringCallback() { public void onComplete(String result) { Image image = new Image(result); image.setStyleName("thumbnailImage"); image.getElement().getStyle().setFloat(Float.LEFT); filePanel.add(image); } }); } }
From source file:org.dashbuilder.renderer.client.metric.AbstractMetricDisplayer.java
License:Apache License
/** * Clear the current display and show a notification message. */// ww w . j a v a 2 s.c o m public void displayMessage(String msg) { panel.clear(); Label label = new Label(); panel.add(label); label.setText(msg); }
From source file:org.datacleaner.monitor.scheduling.widgets.SchedulingOverviewPanel.java
License:Open Source License
private Label createLabel(String text, String... styleNames) { final Label label = new Label(); label.setText(text); for (String styleName : styleNames) { label.addStyleName(styleName);/*from w w w . j a va 2 s .co m*/ } return label; }
From source file:org.dataconservancy.dcs.access.client.model.JsDeliverableUnit.java
License:Apache License
public Widget display(CellTree tree, boolean allowDownload) { FlowPanel panel = new FlowPanel(); panel.setStylePrimaryName("Entity"); Button b = new Button("Download (Email download link)"); // if(!getCoreMd().getRights().equalsIgnoreCase("restricted")) if (allowDownload) panel.add(b);/* w ww . jav a 2 s. c om*/ b.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { //pop window //send email // Window.open(Application.datastreamURLnoEncoding(getId()), "_blank", ""); SeadApp.userService.checkSession(null, new AsyncCallback<UserSession>() { @Override public void onSuccess(UserSession session) { String emailAddress = null; if (session.isSession()) emailAddress = session.getEmail(); EmailPopupPanel emailPopup = new EmailPopupPanel(getId(), emailAddress); emailPopup.show(); } @Override public void onFailure(Throwable caught) { new ErrorPopupPanel("Error:" + caught.getMessage()); } }); } }); panel.add(Util.label("Core metadata", "SubSectionHeader")); panel.add(getCoreMd().display(getId(), tree)); final FlexTable table = Util.createTable("Publication Date:", "Abstract:", "Site:", //"Identifier:", "Entity type:", "Creators:", "Parents:", // "Collections:", // "Former refs", // "Metadata refs:", // "Provenance:", // "Surrogate:", "Alternate Ids:", "Location:", "ACR Location:", "Lineage:"); panel.add(table); table.setWidth("90%"); if (getPubdate() != null) { table.setWidget(0, 1, new Label(getPubdate())); } if (getAbstract() != null) { FlowPanel abstractPanel = new FlowPanel(); abstractPanel.add(new Label(getAbstract())); table.setWidget(1, 1, abstractPanel); } if (getSite() != null) { table.setWidget(2, 1, new Label(getSite())); } //table.setWidget(3, 1, Util.entityLink(getId())); table.setText(3, 1, "Collection"); table.setWidget(4, 1, JsCreator.display(getCreators())); if (getParents() != null) { table.setWidget(5, 1, Util.entityLinks(getParents())); } /* if (getCollections() != null) { table.setWidget(6, 1, Util.entityLinks(getCollections())); } table.setText(7, 1, toString(getFormerExternalRefs())); table.setWidget(8, 1, Util.metadataLinks(getMetadataRefs())); table.setText(10, 1, isDigitalSurrogate() == null ? "Unknown" : "" + isDigitalSurrogate()); */ Panel locationPanel = new FlowPanel(); if (getPrimaryDataLocation() != null) locationPanel.add(getPrimaryDataLocation().display()); if (getAlternateIds() != null) { JsArray<JsAlternateId> altIds = getAlternateIds(); FlowPanel altIdPanel = new FlowPanel(); FlowPanel altLocPanel = new FlowPanel(); int doiFlag1 = 0; for (int i = 0; i < altIds.length(); i++) { String altIdStr; altIdStr = altIds.get(i).getIdValue(); final String finalLink; if (!altIds.get(i).getTypeId().equalsIgnoreCase("storage_format")) { if (altIds.get(i).getTypeId().equals("medici")) { finalLink = "http://nced.ncsa.illinois.edu/acr/#collection?uri=" + altIds.get(i).getIdValue(); altIdStr = getCoreMd().getTitle(); } else finalLink = altIdStr; Label altIdLabel = Util.label(altIdStr, "Hyperlink"); altIdLabel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Window.open(finalLink, "_blank", ""); } }); if (altIds.get(i).getTypeId().equals("medici")) { altLocPanel.add(altIdLabel); } else altIdPanel.add(altIdLabel); } } table.setWidget(6, 1, altIdPanel); table.setWidget(8, 1, altLocPanel); } if (getDataLocations() != null) { JsArray<JsDataLocation> locs = getDataLocations(); for (int i = 0; i < locs.length(); i++) { String location = locs.get(i).getLocation(); if (locs.get(i).getName().contains("SDA")) location = "https://www.sdarchive.iu.edu"; Image image; if (locs.get(i).getType().contains("IU")) image = new Image("images/IU_Scholarworks.jpg"); else if (locs.get(i).getType().contains("Ideals")) { image = new Image("images/Ideals.png"); location = location.replace("xmlui/", ""); } else image = new Image("images/local.jpg"); Label locationLabel; location = location.replace("jspui", "iuswdark"); final String finalLink = location; if (!locs.get(i).getName().contains("SDA")) { locationLabel = Util.label(location, "Hyperlink"); locationLabel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Window.open(finalLink, "_blank", ""); } }); } else { locationLabel = new Label(); locationLabel.setText(location); } FlexTable smallTable = Util.createTable(); smallTable.setWidget(0, 0, locationLabel); smallTable.setWidget(0, 1, image); locationPanel.add(smallTable); } } table.setWidget(7, 1, locationPanel); // if (getMetadata() != null && getMetadata().length() > 0) { // panel.add(Util.label("Additional metadata", "SubSectionHeader")); // JsMetadata.display(panel, getMetadata()); // } if (getRelations() != null && getRelations().length() > 0) { panel.add(Util.label("Relations", "SubSectionHeader")); JsRelation.display(panel, getRelations()); } /* TreeDemo demo = new TreeDemo(); demo.setId(getId()); demo.start(); table.setWidget(9, 1, demo); */ return panel; }
From source file:org.dataconservancy.dcs.access.client.model.JsMetadata.java
License:Apache License
public Widget display() { String label = getSchemaUri().isEmpty() ? "Schema: Unknown" : "Schema: " + getSchemaUri(); final String inputXml = getMetadata().replace("\n", "").replace("\t", ""); final DisclosurePanel dp = new DisclosurePanel(label); dp.setAnimationEnabled(true);//from ww w . j a v a2s . c om Label export = new Label(); export.setText("Convert to ISO"); export.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { try { transformer.xslTransform(Name.FGDC, Name.ISO19115, inputXml, new AsyncCallback<String>() { @Override public void onFailure(Throwable caught) { Window.alert("Unable to transform"); } @Override public void onSuccess(String output) { HTML html = new HTML(output); dp.setContent(html); System.out.println(html); } }); } catch (Exception e) { e.printStackTrace(); } } }); dp.add(export); final AsyncCallback<String> transformCb = new AsyncCallback<String>() { @Override public void onFailure(Throwable caught) { Window.alert("Unable to transform"); } @Override public void onSuccess(String fgdcHtml) { HTML html = new HTML(fgdcHtml); dp.add(html); //dp.setContent(html); } }; AsyncCallback<Name> validateCb = new AsyncCallback<Name>() { @Override public void onFailure(Throwable caught) { Window.alert("Unable to validate"); } @Override public void onSuccess(Name result) { if (result != null) { try { transformer.xslTransform(result, Name.HTML, inputXml, transformCb); } catch (Exception e) { e.printStackTrace(); } } else Window.alert("Does not match any of the existing schemas"); } }; transformer.validateXML(inputXml, getSchemaUri(), validateCb); return dp; }
From source file:org.dataconservancy.dcs.access.client.model.JsPrimaryDataLocation.java
License:Apache License
public Widget display() { FlexTable smallTable = Util.createTable(); Image image;/*from www . j a v a 2 s .co m*/ if (getLocation() != null) { String location = getLocation().replace("jspui", "iuswdark").replace("sword/deposit", "iuswdark/handle"); if (getType() != null) if (getType().contains("dspace") && getName().contains("Ideals")) location = location.replace("xmlui/", ""); final String locationLink = location; Label locationLabel; if (!getName().contains("SDA")) { locationLabel = Util.label(location, "Hyperlink"); locationLabel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Window.open(locationLink, "_blank", ""); } }); } else { locationLabel = new Label(); locationLabel.setText(location); } if (!location.contains("communities")) smallTable.setWidget(0, 0, locationLabel); } if (getType() != null) { if (getType().contains("dspace") && getName().contains("local")) { image = new Image("images/local_dspace.jpg"); smallTable.setWidget(0, 1, image); } else if (getType().contains("dspace") && getName().contains("IU")) { image = new Image("images/IU_Scholarworks.jpg"); smallTable.setWidget(0, 1, image); } else if (getName().contains("SDA")) { image = new Image("images/hpss.jpg"); smallTable.setWidget(0, 1, image); } else if (getType().contains("dspace") && getName().contains("Ideals")) { image = new Image("images/Ideals.png"); smallTable.setWidget(0, 1, image); } } return smallTable; }