List of usage examples for com.google.gwt.user.client.ui Label setText
public void setText(String text)
From source file:nl.mpi.tg.eg.experiment.client.view.AnnotationTimelinePanel.java
License:Open Source License
public void updateAnnotation(final AnnotationData annotationData) { final Label label = annotationLebels.get(annotationData); label.setWidth(getWidth(annotationData, currentVideoLength) + "px"); label.setText(annotationData.getAnnotationHtml()); final int topPosition = absolutePanel.getWidgetTop(label); absolutePanel.setWidgetPosition(label, getLeftPosition(annotationData, currentVideoLength), topPosition); }
From source file:nl.mpi.tg.eg.experiment.client.view.TimedStimulusView.java
License:Open Source License
public StimulusFreeText addStimulusValidation(final LocalStorage localStorage, final UserId userId, final Stimulus currentStimulus, final String postName, final String validationRegex, final String validationChallenge, final int dataChannel) { final Label errorLabel = new Label(validationChallenge); errorLabel.setStylePrimaryName("metadataErrorMessage"); errorLabel.setVisible(false);//from w w w . java 2s.c o m getActivePanel().add(errorLabel); return new StimulusFreeText() { @Override public Stimulus getStimulus() { return currentStimulus; } @Override public String getPostName() { return postName; } @Override public String getResponseTimes() { return null; } @Override public String getValue() { JSONObject storedStimulusJSONObject = localStorage.getStoredJSONObject(userId, currentStimulus); final JSONValue codeResponse = (storedStimulusJSONObject == null) ? null : storedStimulusJSONObject.get(postName); return (codeResponse != null) ? codeResponse.isString().stringValue() : null; } @Override public boolean isValid() { final String currentValue = getValue(); final boolean isValid; if (currentValue != null) { isValid = currentValue.matches(validationRegex); } else { isValid = false; } if (isValid) { errorLabel.setVisible(false); return true; } else { errorLabel.setText(validationChallenge); errorLabel.setVisible(true); return false; } } @Override public int getDataChannel() { return dataChannel; } @Override public void setFocus(boolean wantsFocus) { // todo: we could use a scroll to method to focus the message here } }; }
From source file:nl.mpi.tg.eg.experiment.client.view.TimedStimulusView.java
License:Open Source License
public StimulusFreeText addStimulusFreeText(final Stimulus stimulus, final String postName, final String validationRegex, final String keyCodeChallenge, final String validationChallenge, final String allowedCharCodes, final SingleShotEventListner enterKeyListner, final int hotKey, final String styleName, final int dataChannel, final String textValue) { final int inputLengthLimit = 1000; // this coud be a parameter from the configuraiton file, however the validationRegex can also limit the input length. // perhaps consider removing allowedCharCodes and doing a regex test on each key? final Label errorLabel = new Label(validationChallenge); errorLabel.setStylePrimaryName("metadataErrorMessage"); errorLabel.setVisible(false);/* w ww .ja v a2 s . c om*/ getActivePanel().add(errorLabel); final Duration duration = new Duration(); final StringBuilder responseTimes = new StringBuilder(); final TextArea textBox = new TextArea(); if (textValue != null) { textBox.setText(textValue); } if (hotKey == KeyCodes.KEY_ENTER) { textBox.setVisibleLines(1); textBox.getElement().getStyle().setProperty("minHeight", "26px"); } if (styleName != null) { textBox.addStyleName(styleName); } textBox.setStylePrimaryName("metadataOK"); getActivePanel().add(textBox); textBox.setFocus(true); textBox.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { final char charCode = event.getCharCode(); if (charCode > -1 && charCode == hotKey) { event.getNativeEvent().preventDefault(); enterKeyListner.eventFired(); errorLabel.setVisible(false); } else if (charCode == 0) { // firefox needs these events to be handled by allowing the event to pass return; } else if (textBox.getText().length() > inputLengthLimit) { event.getNativeEvent().preventDefault(); // todo: update this to give a sensible message errorLabel.setText( keyCodeChallenge.replace("<keycode>", "" + inputLengthLimit) + validationChallenge); errorLabel.setVisible(true); } else if (allowedCharCodes != null) { if (0 > allowedCharCodes.indexOf(charCode)) { event.getNativeEvent().preventDefault(); final char invertedCaseCode = (Character.isLowerCase(charCode)) ? Character.toUpperCase(charCode) : Character.toLowerCase(charCode); if (0 > allowedCharCodes.indexOf(invertedCaseCode)) { // if the key is not allowed, then show a message // final String messageString = "The key '<keycode>' is not allowed. " + validationChallenge; errorLabel.setText( keyCodeChallenge.replace("<keycode>", "" + charCode) + validationChallenge); errorLabel.setVisible(true); } else { responseTimes.append(duration.elapsedMillis()); responseTimes.append(","); // if the case is not allowed, then modify the case to what is final int cursorPos = textBox.getCursorPos(); String pretext = textBox.getText().substring(0, cursorPos); String posttext = textBox.getText().substring(textBox.getCursorPos()); textBox.setText(pretext + invertedCaseCode + posttext); textBox.setCursorPos(cursorPos + 1); errorLabel.setVisible(false); } } else { responseTimes.append(duration.elapsedMillis()); responseTimes.append(","); errorLabel.setVisible(false); } } else { responseTimes.append(duration.elapsedMillis()); responseTimes.append(","); errorLabel.setVisible(false); } } }); final StimulusFreeText stimulusFreeText = new StimulusFreeText() { @Override public Stimulus getStimulus() { return stimulus; } @Override public String getValue() { return textBox.getValue(); } @Override public String getResponseTimes() { return responseTimes.substring(0, responseTimes.length() - 1); } @Override public boolean isValid() { if ((getValue().length() <= inputLengthLimit + 2) && (validationRegex == null || getValue().matches(validationRegex))) { textBox.setStylePrimaryName("metadataOK"); errorLabel.setVisible(false); return true; } else { textBox.setStylePrimaryName("metadataError"); errorLabel.setText(validationChallenge); errorLabel.setVisible(true); textBox.setFocus(true); return false; } } @Override public String getPostName() { return postName; } @Override public int getDataChannel() { return dataChannel; } @Override public void setFocus(boolean wantsFocus) { textBox.setFocus(wantsFocus); } }; return stimulusFreeText; }
From source file:nl.mpi.tg.eg.experiment.client.view.TimedStimulusView.java
License:Open Source License
public void addTimedAudio(final TimedEventMonitor timedEventMonitor, final SafeUri oggPath, final SafeUri mp3Path, boolean showPlaybackIndicator, final CancelableStimulusListener loadedStimulusListener, final CancelableStimulusListener failedStimulusListener, final CancelableStimulusListener playbackStartedStimulusListener, final CancelableStimulusListener playedStimulusListener, final boolean autoPlay, final String mediaId) { cancelableListnerList.add(loadedStimulusListener); cancelableListnerList.add(failedStimulusListener); cancelableListnerList.add(playbackStartedStimulusListener); cancelableListnerList.add(playedStimulusListener); try {/* www . j a v a2s . c o m*/ if (timedEventMonitor != null) { timedEventMonitor.registerEvent("addTimedAudio"); } final AudioPlayer audioPlayer = new AudioPlayer(new AudioExceptionListner() { @Override public void audioExceptionFired(AudioException audioException) { if (timedEventMonitor != null) { timedEventMonitor.registerEvent("audioExceptionFired"); } failedStimulusListener.postLoadTimerFired(); } }, oggPath, mp3Path, autoPlay); audioList.put(mediaId, audioPlayer); // audioPlayer.stopAll(); // Note that this stop all change will be a change in default behaviour, however there shouldn't be any instances where this is depended on, but that should be checked final Label playbackIndicator = new Label(); final Timer playbackIndicatorTimer = new Timer() { public void run() { playbackIndicator.setText("CurrentTime: " + audioPlayer.getCurrentTime()); // playbackIndicator.setWidth(); this.schedule(100); } }; timerList.add(playbackIndicatorTimer); if (showPlaybackIndicator) { playbackIndicator.setStylePrimaryName("playbackIndicator"); getActivePanel().add(playbackIndicator); playbackIndicatorTimer.schedule(500); } audioPlayer.setEventListner(new AudioEventListner() { @Override public void audioLoaded() { if (timedEventMonitor != null) { timedEventMonitor.registerEvent("audioLoaded"); } loadedStimulusListener.postLoadTimerFired(); } @Override public void audioStarted() { if (timedEventMonitor != null) { timedEventMonitor.registerEvent("audioStarted"); } playbackStartedStimulusListener.postLoadTimerFired(); } @Override public void audioFailed() { if (timedEventMonitor != null) { timedEventMonitor.registerEvent("audioFailed"); } failedStimulusListener.postLoadTimerFired(); } @Override public void audioEnded() { if (timedEventMonitor != null) { timedEventMonitor.registerEvent("audioEnded"); timedEventMonitor.registerMediaLength(mediaId, (long) (audioPlayer.getCurrentTime() * 1000)); } // playbackIndicatorTimer.cancel(); // playbackIndicator.removeFromParent(); // audioPlayer.setEventListner(null); // prevent multiple triggering playedStimulusListener.postLoadTimerFired(); } }); } catch (AudioException audioException) { failedStimulusListener.postLoadTimerFired(); } }
From source file:nl.ru.languageininteraction.language.client.view.MapView.java
License:Open Source License
public void addMap() { final Label label = new Label("click a land mass"); verticalPanel.add(label);/*from w w w .ja v a 2s .c o m*/ // String[] items = new String[]{"one", "two", "three"}; SafeHtmlBuilder builder = new SafeHtmlBuilder(); // for (String item : items) { // builder.appendEscaped(item).appendHtmlConstant("<br/>"); // } height = Window.getClientHeight(); width = Window.getClientWidth(); builder.append(SafeHtmlUtils.fromTrustedString("<style>.overlay {pointer-events: none;}</style>")); builder.append(SafeHtmlUtils .fromTrustedString("<svg id='ocean' height='" + height + "px' width='" + width + "px' >")); builder.append(SafeHtmlUtils.fromTrustedString("<g id='zoomableGroup'>")); builder.append(SafeHtmlUtils.fromTrustedString("<g transform='scale(0.3)'>")); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idIndic(), autotypRegions.transformIndic())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath97259(), autotypRegions.stylepath97259(), autotypRegions.datapath97259())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idBasinandPlains(), autotypRegions.transformBasinandPlains())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath107611(), autotypRegions.stylepath107611(), autotypRegions.datapath107611())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idAlaskaOregon(), autotypRegions.transformAlaskaOregon())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath107614(), autotypRegions.stylepath107614(), autotypRegions.datapath107614())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idCalifornia(), autotypRegions.transformCalifornia())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath107582(), autotypRegions.stylepath107582(), autotypRegions.datapath107582())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idMesoamerica(), autotypRegions.transformMesoamerica())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath97265(), autotypRegions.stylepath97265(), autotypRegions.datapath97265())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idSESouthAmerica(), autotypRegions.transformSESouthAmerica())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath107722(), autotypRegions.stylepath107722(), autotypRegions.datapath107722())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idNESouthAmerica(), autotypRegions.transformNESouthAmerica())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath97311(), autotypRegions.stylepath97311(), autotypRegions.datapath97311())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idAndean(), autotypRegions.transformAndean())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath107701(), autotypRegions.stylepath107701(), autotypRegions.datapath107701())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idNAustralia(), autotypRegions.transformNAustralia())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath97635(), autotypRegions.stylepath97635(), autotypRegions.datapath97635())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idGreenland(), autotypRegions.transformGreenland())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath140696(), autotypRegions.stylepath140696(), autotypRegions.datapath140696())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idSAustralia(), autotypRegions.transformSAustralia())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath107441(), autotypRegions.stylepath107441(), autotypRegions.datapath107441())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath99393(), autotypRegions.stylepath99393(), autotypRegions.datapath99393())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idNAfrica(), autotypRegions.transformNAfrica())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath140264(), autotypRegions.stylepath140264(), autotypRegions.datapath140264())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idSAfrica(), autotypRegions.transformSAfrica())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath140076(), autotypRegions.stylepath140076(), autotypRegions.datapath140076())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idGreaterMesopotamia(), autotypRegions.transformGreaterMesopotamia())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath97275(), autotypRegions.stylepath97275(), autotypRegions.datapath97275())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idInnerAsia(), autotypRegions.transformInnerAsia())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath97287(), autotypRegions.stylepath97287(), autotypRegions.datapath97287())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath140112(), autotypRegions.stylepath140112(), autotypRegions.datapath140112())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idEurope(), autotypRegions.transformEurope())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath97263(), autotypRegions.stylepath97263(), autotypRegions.datapath97263())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath97585(), autotypRegions.stylepath97585(), autotypRegions.datapath97585())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath97977(), autotypRegions.stylepath97977(), autotypRegions.datapath97977())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath98383(), autotypRegions.stylepath98383(), autotypRegions.datapath98383())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath99041(), autotypRegions.stylepath99041(), autotypRegions.datapath99041())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath100331(), autotypRegions.stylepath100331(), autotypRegions.datapath100331())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath97431(), autotypRegions.stylepath97431(), autotypRegions.datapath97431())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath98187(), autotypRegions.stylepath98187(), autotypRegions.datapath98187())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath98391(), autotypRegions.stylepath98391(), autotypRegions.datapath98391())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath100255(), autotypRegions.stylepath100255(), autotypRegions.datapath100255())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath100829(), autotypRegions.stylepath100829(), autotypRegions.datapath100829())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath101047(), autotypRegions.stylepath101047(), autotypRegions.datapath101047())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath101127(), autotypRegions.stylepath101127(), autotypRegions.datapath101127())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath101193(), autotypRegions.stylepath101193(), autotypRegions.datapath101193())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath101671(), autotypRegions.stylepath101671(), autotypRegions.datapath101671())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath140654(), autotypRegions.stylepath140654(), autotypRegions.datapath140654())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath97911(), autotypRegions.stylepath97911(), autotypRegions.datapath97911())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath141650(), autotypRegions.stylepath141650(), autotypRegions.datapath141650())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath142374(), autotypRegions.stylepath142374(), autotypRegions.datapath142374())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath143814(), autotypRegions.stylepath143814(), autotypRegions.datapath143814())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath144104(), autotypRegions.stylepath144104(), autotypRegions.datapath144104())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath140764(), autotypRegions.stylepath140764(), autotypRegions.datapath140764())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath140714(), autotypRegions.stylepath140714(), autotypRegions.datapath140714())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath143158(), autotypRegions.stylepath143158(), autotypRegions.datapath143158())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath144174(), autotypRegions.stylepath144174(), autotypRegions.datapath144174())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idSoutheast_Asia(), autotypRegions.transformSoutheast_Asia())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath97365(), autotypRegions.stylepath97365(), autotypRegions.datapath97365())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idNorthCoastAsia(), autotypRegions.transformNorthCoastAsia())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath97393(), autotypRegions.stylepath97393(), autotypRegions.datapath97393())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idENorthAmerica(), autotypRegions.transformENorthAmerica())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath107580(), autotypRegions.stylepath107580(), autotypRegions.datapath107580())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idPapua(), autotypRegions.transformPapua())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath97649(), autotypRegions.stylepath97649(), autotypRegions.datapath97649())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idAfricanSavanah(), autotypRegions.transformAfricanSavanah())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath13257(), autotypRegions.stylepath13257(), autotypRegions.datapath13257())); // builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SVG_TEMPLATE.groupTag(autotypRegions.idOceania(), autotypRegions.transformOceania())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath107904(), autotypRegions.stylepath107904(), autotypRegions.datapath107904())); // builder.append(SVG_TEMPLATE.pathTag(autotypRegions.transformpath97885(), autotypRegions.stylepath97885(), autotypRegions.datapath97885())); builder.append(SVG_TEMPLATE.groupTagEnd()); // builder.append(SafeHtmlUtils.fromTrustedString("<rect id='island' x='250' y='150' height='5px' width='5px' fill='blue'/>")); // builder.append(SafeHtmlUtils.fromTrustedString("<rect id='island' x='255' y='170' height='5px' width='5px' fill='blue'/>")); // builder.append(SafeHtmlUtils.fromTrustedString("<rect id='island' x='10' y='160' height='5px' width='5px' fill='blue'/>")); // builder.append(SafeHtmlUtils.fromTrustedString("<rect id='island' x='30' y='150' height='5px' width='5px' fill='blue'/>")); // builder.append(SafeHtmlUtils.fromTrustedString("<rect id='island' x='20' y='150' height='5px' width='5px' fill='blue'/>")); // builder.append(SafeHtmlUtils.fromTrustedString("<rect id='continent' x='0' y='10'height='88px' width='88px' fill='green'/>")); // builder.append(SafeHtmlUtils.fromTrustedString("<rect id='asia' x='250' y='50' height='88px' width='88px' fill='green'/>")); // builder.append(SafeHtmlUtils.fromTrustedString("<rect id='europe' x='150' y='10' height='88px' width='88px' fill='green'/>")); // builder.append(SafeHtmlUtils.fromTrustedString("<rect id='africa' x='100' y='110' height='88px' width='88px' fill='green'/>")); // builder.append(SafeHtmlUtils.fromTrustedString("<rect id='australia' x='400' y='100' height='88px' width='88px' fill='green'/>")); // builder.append(SafeHtmlUtils.fromTrustedString("<rect id='newzealand' x='500' y='150' height='20px' width='10px' fill='green'/>")); builder.append(SafeHtmlUtils.fromTrustedString("</g>")); builder.append(SafeHtmlUtils.fromTrustedString("</g>")); builder.append(SafeHtmlUtils.fromTrustedString("<line id='horizontal' class='overlay' x1='0' y1='100' x2='" + width + "' y2='100' style='stroke:rgb(255,0,0);stroke-width:2'/>")); builder.append( SafeHtmlUtils.fromTrustedString("<line id='vertical' class='overlay' x1='100' y1='0' x2='100' y2='" + height + "' style='stroke:rgb(255,0,0);stroke-width:2'/>")); builder.append(SafeHtmlUtils.fromTrustedString("</svg>")); final HTML html = new HTML(builder.toSafeHtml()); html.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { final Element targetElement = Element.as(event.getNativeEvent().getEventTarget()); final Element parentElement = targetElement.getParentElement(); if (!parentElement.getId().isEmpty()) { label.setText(parentElement.getId()); } else { label.setText(targetElement.getId()); } final Element horizontalLine = Document.get().getElementById("horizontal"); final Element verticalLine = Document.get().getElementById("vertical"); final Element svgElement = Document.get().getElementById("ocean"); final int relativeX = event.getRelativeX(svgElement); final int relativeY = event.getRelativeY(svgElement); horizontalLine.setAttribute("y1", String.valueOf(relativeY)); horizontalLine.setAttribute("y2", String.valueOf(relativeY)); horizontalLine.setAttribute("x2", String.valueOf(width)); verticalLine.setAttribute("x1", String.valueOf(relativeX)); verticalLine.setAttribute("x2", String.valueOf(relativeX)); verticalLine.setAttribute("y2", String.valueOf(height)); } }); verticalPanel.add(html); // verticalPanel.add(new HTML(builder.toSafeHtml())); setContent(verticalPanel); }
From source file:org.apache.cxf.management.web.browser.client.ui.ErrorDialog.java
License:Apache License
private void initializeLayout(@Nonnull final String errorName, @Nullable final String errorMessage) { // Create error name and error message labels Label errorNameLabel = new Label(errorName); errorNameLabel.setStyleName(resources.css().errorDialogErrorType()); Label errorMessageLabel = null; if (errorMessage != null && !"".equals(errorMessage)) { errorMessageLabel = new Label(errorMessage); DOM.setStyleAttribute(errorMessageLabel.getElement(), "whiteSpace", "pre"); }/*from w w w .jav a 2 s . c o m*/ // Initialize 'close' button closeButton.setText(contants.errorDialogContineButton()); closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { hide(); } }); closeButton.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { /* if the close button is triggered by a key we need to consume the key event, otherwise the key event would be propagated to the parent screen and eventually trigger some unwanted action there after the error dialog was closed */ event.stopPropagation(); } }); // Create 'title' label Label titleLabel = new Label(); titleLabel.setStyleName(resources.css().errorDialogTitle()); titleLabel.setText(contants.errorDialogTitle()); // Create wrapper panel for 'error name' and 'error message' labels FlowPanel contentPanel = new FlowPanel(); contentPanel.add(errorNameLabel); contentPanel.add(errorMessageLabel); // Create wrapper panel for 'close' button FlowPanel buttonsPanel = new FlowPanel(); buttonsPanel.setStyleName(resources.css().errorDialogButtons()); buttonsPanel.add(closeButton); // Create main panel and add all remain widgets FlowPanel centerPanel = new FlowPanel(); centerPanel.add(titleLabel); centerPanel.add(contentPanel); centerPanel.add(buttonsPanel); // Add styles to window setGlassEnabled(true); getGlassElement().addClassName(resources.css().errorDialogGlass()); addStyleName(resources.css().errorDialog()); // Add main panel add(centerPanel); // Set window position int left = Window.getScrollLeft() + 20; int top = Window.getScrollTop() + 20; setPopupPosition(left, top); }
From source file:org.berlin.network.client.ParseLogCriticalErrors.java
License:Open Source License
/** * This is the entry point method./*from w w w . java 2 s .c om*/ */ public void onModuleLoad() { final Button sendButton = new Button("Execute Command"); final TextBox nameField = new TextBox(); final TextBox sessionLookupField = new TextBox(); final TextBox expressionField = new TextBox(); nameField.setText("help"); sessionLookupField.setText(""); expressionField.setText(""); final Label errorLabel = new Label(); final Label statusMessageLabel = new Label(); statusMessageLabel.setText("Status command area - waiting for command..."); // We can add style names to widgets sendButton.addStyleName("sendButton"); // Add the nameField and sendButton to the RootPanel // Use RootPanel.get() to get the entire body element RootPanel.get("nameFieldContainer").add(nameField); RootPanel.get("sessionFieldContainer").add(sessionLookupField); RootPanel.get("expressionFieldContainer").add(expressionField); RootPanel.get("sendButtonContainer").add(sendButton); RootPanel.get("errorLabelContainer").add(errorLabel); RootPanel.get("statusLabelContainer").add(statusMessageLabel); // Focus the cursor on the name field when the app loads nameField.setFocus(true); nameField.selectAll(); // Create the popup dialog box final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Remote Procedure Call"); dialogBox.setAnimationEnabled(true); final Button closeButton = new Button("Close"); // We can set the id of a widget by accessing its Element closeButton.getElement().setId("closeButton"); final Label textToServerLabel = new Label(); final HTML serverResponseLabel = new HTML(); final VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.addStyleName("dialogVPanel"); dialogVPanel.add(new HTML("<b>Sending command to the server:</b>")); dialogVPanel.add(textToServerLabel); dialogVPanel.add(new HTML("<br><b>Server replies:</b>")); dialogVPanel.add(serverResponseLabel); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT); dialogVPanel.add(closeButton); dialogBox.setWidget(dialogVPanel); // Add a handler to close the DialogBox closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); sendButton.setEnabled(true); sendButton.setFocus(true); } }); final CellTable<SessionUIInfo> tableSessionInfo = new CellTable<SessionUIInfo>(); // Create a handler for the sendButton and nameField final class MyHandler implements ClickHandler, KeyUpHandler { /** * Fired when the user clicks on the sendButton. */ public void onClick(ClickEvent event) { sendCommandToServer(); } /** * Fired when the user types in the nameField. */ public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { sendCommandToServer(); } } /** * Send the name from the nameField to the server and wait for a response. */ private void sendCommandToServer() { final String cmdToServer = nameField.getText(); final String sessionIdData = sessionLookupField.getText(); // First, we validate the input. errorLabel.setText(""); statusMessageLabel.setText("Running command [" + cmdToServer + "]..."); tableSessionInfo.setVisible(true); if (!FieldVerifier.isValidName(cmdToServer)) { errorLabel.setText("Please enter a command (Example = help)"); return; } // Then, we send the input to the server. sendButton.setEnabled(false); textToServerLabel.setText(cmdToServer); serverResponseLabel.setText(""); /********************************** * Basic Greet Service Action **********************************/ greetingService.greetServer(cmdToServer, sessionIdData, new AsyncCallback<String>() { public void onFailure(final Throwable caught) { // Show the RPC error message to the user dialogBox.setText("Remote Procedure Call - Failure"); serverResponseLabel.addStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(SERVER_ERROR); statusMessageLabel.setText("Error at command"); dialogBox.center(); closeButton.setFocus(true); } public void onSuccess(final String result) { dialogBox.setText("Remote Procedure Call"); serverResponseLabel.removeStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(result); dialogBox.center(); closeButton.setFocus(true); statusMessageLabel.setText("Message command run - [" + cmdToServer + "]"); System.out.println("On success of command from server "); } }); final String expr = expressionField.getText(); System.out.println("on command, sending request to server"); sessionService.sessionServer(cmdToServer, sessionIdData, expr, sessionCallbackFromCommand(tableSessionInfo)); } } // End of class // // Add a handler to send the name to the server final MyHandler handler = new MyHandler(); sendButton.addClickHandler(handler); nameField.addKeyUpHandler(handler); /**************************************************************** * Add property data table ****************************************************************/ { // Create a CellTable. final CellTable<PropertyEntry> tableProperty = new CellTable<PropertyEntry>(); // Create name column. final TextColumn<PropertyEntry> nameColumn = new TextColumn<PropertyEntry>() { @Override public String getValue(final PropertyEntry contact) { return contact.name; } }; // Make the name column sortable. nameColumn.setSortable(true); // Create address column. final TextColumn<PropertyEntry> addressColumn = new TextColumn<PropertyEntry>() { @Override public String getValue(final PropertyEntry contact) { return contact.value; } }; // Add the columns. tableProperty.addColumn(nameColumn, "Name"); tableProperty.addColumn(addressColumn, "Value"); // Set the total row count. You might send an RPC request to determine the // total row count. tableProperty.setRowCount(34, false); // Set the range to display. In this case, our visible range is smaller than // the data set. tableProperty.setVisibleRange(0, 34); final AsyncDataProvider<PropertyEntry> dataProviderForPropertyList = new AsyncDataProvider<PropertyEntry>() { @Override protected void onRangeChanged(final HasData<PropertyEntry> display) { final Range range = display.getVisibleRange(); // Get the ColumnSortInfo from the table. final ColumnSortList sortList = tableProperty.getColumnSortList(); new Timer() { @Override public void run() { final AsyncCallback<List<PropertyEntry>> callbackPropertyChange = new AsyncCallback<List<PropertyEntry>>() { @Override public void onFailure(final Throwable caught) { System.out.println("Error - " + caught); dialogBox.setText("Remote Procedure Call - Failure"); serverResponseLabel.addStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(SERVER_ERROR); dialogBox.center(); closeButton.setFocus(true); } @Override public void onSuccess(final List<PropertyEntry> result) { if (result == null) { System.out.println("Invalid result set"); return; } System.out.println("onSuccess of Timer Callback Table Property Set"); final int start = range.getStart(); final int end = start + range.getLength(); final List<PropertyEntry> statsList = result; Collections.sort(statsList, new Comparator<PropertyEntry>() { public int compare(final PropertyEntry o1, final PropertyEntry o2) { if (o1 == o2) { return 0; } int diff = -1; if (o1 != null) { diff = (o2 != null) ? o1.name.compareTo(o2.name) : 1; } return sortList.get(0).isAscending() ? diff : -diff; } }); final List<PropertyEntry> dataInRange = statsList.subList(start, end); tableProperty.setRowData(start, dataInRange); } }; // End of Callback // /********************************** * Stats Service Action **********************************/ statsService.statsServer("invalid", "invalid", callbackPropertyChange); } // End of Run method // }.schedule(100); } // onRange Changed // }; // Connect the list to the data provider. dataProviderForPropertyList.addDataDisplay(tableProperty); final AsyncHandler columnSortHandler = new AsyncHandler(tableProperty); tableProperty.addColumnSortHandler(columnSortHandler); // We know that the data is sorted alphabetically by default. tableProperty.getColumnSortList().push(nameColumn); // Add it to the root panel. RootPanel.get("listViewContainer").add(tableProperty); /********************************** * End of adding property table data ***********************************/ } // End - property table // /**************************************************************** * Add session lookup data table ****************************************************************/ { final TextColumn<SessionUIInfo> sessionColumn = new TextColumn<SessionUIInfo>() { @Override public String getValue(final SessionUIInfo info) { return info.sessionId; } }; sessionColumn.setSortable(true); final TextColumn<SessionUIInfo> dateColumn = new TextColumn<SessionUIInfo>() { @Override public String getValue(final SessionUIInfo info) { return info.getJavaDate(); } }; final TextColumn<SessionUIInfo> filenameColumn = new TextColumn<SessionUIInfo>() { @Override public String getValue(final SessionUIInfo info) { return info.filename; } }; // Add the columns. tableSessionInfo.addColumn(sessionColumn, "Session"); tableSessionInfo.addColumn(dateColumn, "Date"); tableSessionInfo.addColumn(filenameColumn, "LogFilename"); tableSessionInfo.setRowCount(24, false); tableSessionInfo.setVisibleRange(0, 24); final AsyncDataProvider<SessionUIInfo> dataProviderForSessionList = new AsyncDataProvider<SessionUIInfo>() { @Override protected void onRangeChanged(final HasData<SessionUIInfo> display) { new Timer() { @Override public void run() { /********************************** * Session Service Action **********************************/ final String cmd = nameField.getText(); final String sessionIdData = sessionLookupField.getText(); final String expr = expressionField.getText(); System.out.println("on Range changed, sending request to server"); sessionService.sessionServer(cmd, sessionIdData, expr, sessionCallback(tableSessionInfo, display)); } // End of Run method // }.schedule(100); } // onRange Changed // }; dataProviderForSessionList.addDataDisplay(tableSessionInfo); final AsyncHandler columnSortHandler = new AsyncHandler(tableSessionInfo); tableSessionInfo.addColumnSortHandler(columnSortHandler); tableSessionInfo.getColumnSortList().push(sessionColumn); // Add it to the root panel. RootPanel.get("sessionViewContainer").add(tableSessionInfo); tableSessionInfo.setVisible(false); } // End of add results table }
From source file:org.bonitasoft.console.client.view.cases.AdminCaseDataFormWidget.java
License:Open Source License
/** * Build the page (template + form fields) * //from w ww .ja va 2s.c o m * @param formPage * the page definition * @param hasAlreadyBeenDisplayed * indicates whether the page has already been displayed or not */ private void buildPage(FormPage formPage, boolean hasAlreadyBeenDisplayed) { dataUpdatePanel.clear(); Label pageLabel = new Label(); if (formPage.getFormWidgets().size() <= 1) { pageLabel.setText(constants.noVariablesForStep()); pageLabel.setStyleName(PAGE_MESSAGE_CLASSNAME); dataUpdatePanel.add(pageLabel); } else { pageLabel.setText(formPage.getPageLabel()); pageLabel.setStyleName(PAGE_LABEL_CLASSNAME); dataUpdatePanel.add(pageLabel); buildform(formPage, hasAlreadyBeenDisplayed); } }
From source file:org.bonitasoft.console.client.view.categories.CategoriesListWidget.java
License:Open Source License
protected void createWidgetsForItem(CategoryUUID anItem) { final Category theItem = myBonitaDataSource.getItem(anItem); final DecoratorPanel theColorPickerContainer = new DecoratorPanel(); final Image theColorPicker = new Image(PICTURE_PLACE_HOLDER); theColorPickerContainer.add(theColorPicker); String theStyleName;//w ww.j a v a2 s .c o m if (theItem.getPreviewCSSStyleName() == null) { theStyleName = LabelModel.DEFAULT_PREVIEW_CSS; } else { theStyleName = theItem.getPreviewCSSStyleName(); } theColorPicker.setStyleName(theStyleName); theColorPickerContainer.setStylePrimaryName(theStyleName + CONTAINER_SUFFIX_STYLE); theItem.addModelChangeListener(Category.CSS_CLASS_NAME_PROPERTY, new ModelChangeListener() { public void modelChange(ModelChangeEvent aEvt) { final String theStyleName = ((Category) aEvt.getSource()).getPreviewCSSStyleName(); theColorPicker.setStyleName(theStyleName); theColorPickerContainer.setStylePrimaryName(theStyleName + CONTAINER_SUFFIX_STYLE); } }); theItem.addModelChangeListener(Category.NAME_PROPERTY, new ModelChangeListener() { public void modelChange(ModelChangeEvent aEvt) { final Category theCategory = (Category) aEvt.getSource(); Label theLabel = myItemNameWidgets.get(theCategory.getUUID()); if (theLabel != null) { theLabel.setText(theCategory.getName()); } } }); myItemSelectionWidgets.put(anItem, new ItemSelectionWidget<CategoryUUID>(myItemSelection, anItem)); myItemColorWidgets.put(anItem, theColorPickerContainer); myItemNameWidgets.put(anItem, new Label(theItem.getName())); }
From source file:org.bonitasoft.console.client.view.labels.LabelViewer.java
License:Open Source License
private DecoratorPanel buildLabelTable(LabelModel aLabelModel) { DecoratorPanel theContainer = new DecoratorPanel(); // Create the layout container. final HorizontalPanel theTable = new HorizontalPanel(); final Label theNameLabel = new Label(buildShortName(LocaleUtil.translate(aLabelModel.getUUID()))); theNameLabel.setTitle(LocaleUtil.translate(aLabelModel.getUUID())); theTable.add(theNameLabel);/*from w ww.j a v a2 s. c o m*/ aLabelModel.addModelChangeListener(LabelModel.NAME_PROPERTY, new ModelChangeListener() { public void modelChange(ModelChangeEvent anEvt) { theNameLabel.setText(buildShortName(((LabelUUID) anEvt.getNewValue()).getValue())); } }); if (isDeletable && aLabelModel.isAssignableByUser()) { final Label theRemoveLabel; theTable.setStylePrimaryName(aLabelModel.getEditableCSSStyleName()); theRemoveLabel = new Label("X"); theRemoveLabel.addClickHandler(new RemoveLabelClickHandler(aLabelModel)); theRemoveLabel.setStyleName("remove"); theTable.add(theRemoveLabel); } else { theTable.setStylePrimaryName(aLabelModel.getReadonlyCSSStyleName()); } theContainer.add(theTable); theContainer.setStylePrimaryName(aLabelModel.getReadonlyCSSStyleName() + ROUNDED_CORNER_SUFFIX_STYLE_NAME); return theContainer; }