List of usage examples for com.google.gwt.user.client.ui HTML HTML
protected HTML(Element element)
From source file:com.allen_sauer.gwt.dnd.demo.client.ExampleTabPanel.java
License:Apache License
/** * Describe an example in a consistent way by including a description and the name of the * {@link com.allen_sauer.gwt.dnd.client.drop.DropController} used in the example. * /*from w ww . j a v a2s .c o m*/ * @param classes the primary DropController used in this example * @param description a brief description of the example * @return HTML widget describing the example */ public static HTML describe(Class<?>[] classes, String description) { String sourceCodeLinks = ""; for (int i = 0; i < classes.length; i++) { sourceCodeLinks += GWTUtil.getClassAnchorHTML(classes[i]); if (i < classes.length - 1) { sourceCodeLinks += ", "; } } HTML html = new HTML("<i>" + description + "</i><br>\n(Source code: " + sourceCodeLinks + ")"); html.addStyleName(CSS_DEMO_EXAMPLE_DESCRIPTION); return html; }
From source file:com.allen_sauer.gwt.log.demo.client.InteractiveDemoPanel.java
License:Apache License
/** * Default constructor.// w w w . j a v a 2 s. c om */ public InteractiveDemoPanel() { add(new HTML("Log a message:")); for (int i = 0; i < levels.length - 1; i++) { final int level = levels[i]; final String levelString = levelTexts[i]; messageButtons[i] = new Button("Log." + levelString.toLowerCase() + "(...)"); add(messageButtons[i]); messageButtons[i].addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { String msg = "This is a '" + levelString + "' test message"; switch (level) { case Log.LOG_LEVEL_TRACE: Log.trace(msg); break; case Log.LOG_LEVEL_DEBUG: Log.debug(msg); break; case Log.LOG_LEVEL_INFO: Log.info(msg); break; case Log.LOG_LEVEL_WARN: Log.warn(msg); break; case Log.LOG_LEVEL_ERROR: Log.error(msg); break; case Log.LOG_LEVEL_FATAL: Log.fatal(msg); break; } } }); } add(new HTML("<br>")); add(new HTML("Catch some exceptions:")); jsniCatchButtonFatal = new Button("JSNI with try/catch"); add(jsniCatchButtonFatal); jsniCatchButtonFatal.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { jsniCatch(); } }); jsniNoCatchButtonFatal = new Button("JSNI without try/catch"); add(jsniNoCatchButtonFatal); jsniNoCatchButtonFatal.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { jsniNoCatch(); } }); clinitButtonFatal = new Button("static (class) initialization failure"); add(clinitButtonFatal); clinitButtonFatal.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { new Broken(); } }); add(new HTML("<br>")); npeButtonFatal = new Button("NullPointerException"); add(npeButtonFatal); npeButtonFatal.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { throw new NullPointerException(); } }); jsTimeoutExceptionButtonFatal = new Button("JavaScript setTimeout() exception [FF/IE/Chrome only]"); add(jsTimeoutExceptionButtonFatal); jsTimeoutExceptionButtonFatal.addClickHandler(new ClickHandler() { @Override public native void onClick(ClickEvent event) /*-{ setTimeout(function() { my_non_existant_variable.my_non_existant_method(); }, 1); }-*/; }); nullButtonDebug = new Button("Log.debug(null)"); add(nullButtonDebug); nullButtonDebug.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Log.debug(null); } }); add(new HTML("<br>")); add(new HTML("Clear log output (on supported destinations):")); Button clearButton = new Button("clear()"); add(clearButton); clearButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Log.clear(); } }); // add(new HTML("<br>")); // add(new HTML("Set runtime log level to:")); // // for (int i = 0; i < levels.length; i++) { // final int level = levels[i]; // levelButtons[i] = new Button(levelTexts[i]); // levelButtons[i].addClickHandler(new ClickHandler() { // public void onClick(ClickEvent event) { // Log.setCurrentLogLevel(level); // updateLogLevelLabels(); // } // }); // add(levelButtons[i]); // } add(new HTML("<br>")); add(new HTML("Change the compile time <code>log_level</code> URL parameter to:")); for (int i = 0; i < levels.length; i++) { final int level = levels[i]; final String url = makePageURL(levelTexts[i]); Anchor anchor = new Anchor(levelTexts[i], url); anchor.getElement().getStyle().setPadding(0.3, Unit.EM); anchor.setTitle("Switch to '" + levelTexts[i] + "' compile time log level"); add(anchor); if (level == Log.getLowestLogLevel()) { anchor.addStyleDependentName(CSS_CURRENT); } } add(new HTML("<br>")); add(new HTML("Launch server side JavaScript stack trace deobfuscation demo:")); add(new HTML("<a href='LogClientServerDemo.html" + Window.Location.getQueryString() + "'>Client server demo</a>")); updateLogLevelLabels(); if (Log.isLoggingEnabled()) { initDivLogger(); } }
From source file:com.allen_sauer.gwt.voices.crowd.client.VoicesCrowd.java
License:Apache License
private void logAlways(String text) { rootPanel.add(new HTML(text)); }
From source file:com.allen_sauer.gwt.voices.crowd.client.VoicesCrowd.java
License:Apache License
private void renderSummary(List<TestResultSummary> list, boolean includeUserAgentDetail) { HashSet<TestResults> testResultsSet = getUniqueTestResults(list); // Build HTML table StringBuffer html = new StringBuffer(); if (!embed) { html.append("<div style='font-weight: bold; font-size: 1.2em;'>") .append("<a href='https://github.com/fredsa/gwt-voices'>gwt-voices</a>") .append(" - Sound for your Google Web Toolkit projects.</div>") .append("<div style='font-style: italic; margin-bottom: 1em;'>by Fred Sauer</div>"); html.append("<h3>Your user agent</h3>"); html.append("<div style='margin-left: 1.5em;'>").append(myUserAgent.toString()).append("</div>"); html.append("<h3>Your browser</h3>"); String prettyUserAgent = myTestResultSummary.getPrettyUserAgent(); html.append("<div style='margin-left: 1.5em;'>").append(formatPrettyUserAgentOrNull(prettyUserAgent)) .append("</div>"); html.append("<h3 style='margin-top: 3em;'>HTML5 MIME Type support by User-Agent</h3>"); }/* w w w . j a v a2 s . com*/ UrlBuilder urlBuilder = Window.Location.createUrlBuilder(); urlBuilder = detail ? urlBuilder.removeParameter("detail") : urlBuilder.setParameter("detail", "1"); String text = (detail ? "Hide" : "Show full") + " user agent values"; html.append("<a href='" + urlBuilder.buildString() + "'>" + text + "</a>"); html.append("<table>"); for (TestResults testResults : testResultsSet) { makeHeaderRow(html, includeUserAgentDetail); HashSet<Tuple<String>> tuples = getMatchingTuples(testResults, list, includeUserAgentDetail); int count = 0; for (Tuple<String> tuple : tuples) { count++; html.append("<tr>"); boolean highlightRow = makeTuple(myTestResultSummary, includeUserAgentDetail).equals(tuple); makeUserAgentCells(html, tuple, highlightRow); if (count == 1) { makeResultCells(html, testResults, tuples.size()); } html.append("</tr>"); } } html.append("</table>"); rootPanel.add(new HTML(html.toString())); }
From source file:com.allen_sauer.gwt.voices.demo.client.DemoSoundPanel.java
License:Apache License
public DemoSoundPanel(final ThirdPartySound thirdPartySound) { // use a horizontal panel to hold our content HorizontalPanel horizontalPanel = new HorizontalPanel(); initWidget(horizontalPanel);// w w w . j a va 2s . com // add a (temporarily disabled) play button final Button playButton = new Button("wait..."); playButton.setEnabled(false); playButton.addStyleName("voices-button"); horizontalPanel.add(playButton); final Button stopButton = new Button("wait..."); stopButton.setEnabled(false); stopButton.addStyleName("voices-button"); horizontalPanel.add(stopButton); // display a description of the sound next to the button horizontalPanel.add(new HTML(" " + thirdPartySound.toHTMLString())); // display a load state status final HTML loadStateHTML = new HTML(); horizontalPanel.add(loadStateHTML); // enable the play button once the sound has loaded thirdPartySound.getSound().addEventHandler(new SoundHandler() { @Override public void onPlaybackComplete(PlaybackCompleteEvent event) { } @Override public void onSoundLoadStateChange(final SoundLoadStateChangeEvent event) { // simulate a slight variable delay for local development new Timer() { @Override public void run() { loadStateHTML.setHTML(" (<code>" + event.getLoadState().name() + "</code>)"); switch (event.getLoadState()) { case LOAD_STATE_SUPPORTED_AND_READY: case LOAD_STATE_SUPPORTED_NOT_READY: case LOAD_STATE_SUPPORTED_MAYBE_READY: playButton.setEnabled(true); playButton.setText("play"); stopButton.setEnabled(true); stopButton.setText("stop"); break; case LOAD_STATE_NOT_SUPPORTED: playButton.setText("(sound or plugin unavailable)"); break; case LOAD_STATE_SUPPORT_NOT_KNOWN: playButton.setEnabled(true); playButton.setText("play (may not work)"); stopButton.setEnabled(true); stopButton.setText("stop"); break; case LOAD_STATE_UNINITIALIZED: default: throw new IllegalArgumentException("Unhandled state " + event.getLoadState()); } } }.schedule(Random.nextInt(500) + 200); } }); // play the sound when button is clicked playButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { thirdPartySound.getSound().play(); } }); stopButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { thirdPartySound.getSound().stop(); } }); }
From source file:com.allen_sauer.gwt.voices.demo.client.ui.DeferredContentPanel.java
License:Apache License
public DeferredContentPanel() { SimplePanel simplePanel = new SimplePanel(); initWidget(simplePanel);//from w ww . j a v a2 s . co m simplePanel.setWidget( new HTML("<div class='demo-loading'><img src='images/preview61_cycle_eight_16-black-on-white.gif'>" + "Loading. Please wait...</div>")); }
From source file:com.allen_sauer.gwt.voices.demo.client.ui.MimeTypeDemo.java
License:Apache License
private void addPanel(VerticalPanel containerPanel, SoundController soundController) { HTML note = null;/*from w w w . j a v a 2 s . co m*/ VerticalPanel soundsPanel = new VerticalPanel(); for (ThirdPartySound thirdPartySound : thirdPartySoundList) { Sound sound = soundController.createSound(mimeType, thirdPartySound.getActualURL(), false, false); sound.addEventHandler(demoSoundHandler); thirdPartySound.setSound(sound); if (note == null) { note = new HTML( "Note:<ul><li>Some browsers will play these sound files natively, while others may require" + " plugins such as <a href='http://www.adobe.com/products/flashplayer/'>Adobe Flash Player</a>," + " <a href='http://www.apple.com/quicktime/download/'>Apple QuickTime</a>" + " or <a href='http://www.microsoft.com/windows/windowsmedia/'>Windows Media Player</a>" + " in order to hear sound.</li>\n" + "<li>Based on your current browser/platform/plugin configuration, gwt-voices is using (or trying to use)" + " <b style='background-color: yellow'>" + sound.getSoundType() + "</b> to play <code>" + mimeType + "</code> sounds.</li></ul>"); note.addStyleName(DemoClientBundle.INSTANCE.css().demoNote()); containerPanel.add(note); } soundsPanel.add(new DemoSoundPanel(thirdPartySound)); } containerPanel.add(soundsPanel); }
From source file:com.allen_sauer.gwt.voices.demo.client.ui.SupportedMimeTypeSummary.java
License:Apache License
public SupportedMimeTypeSummary() { VerticalPanel containerPanel = new VerticalPanel(); containerPanel.clear();/*from www. j a v a 2 s . c o m*/ containerPanel.add(new HTML("Your user agent is:")); HTML userAgentHTML = new HTML(getUserAgent()); userAgentHTML.addStyleName(DemoClientBundle.INSTANCE.css().demoUserAgent()); containerPanel.add(userAgentHTML); containerPanel.add(new HTML("This browser/platform," + " and its installed plugins," + " provide the following sound support via gwt-voices:")); FlexTable flexTable = new FlexTable(); flexTable.addStyleName(DemoClientBundle.INSTANCE.css().demoSupportedMimeTypeSummaryTable()); containerPanel.add(flexTable); flexTable.setWidget(0, 0, new HTML("MIME Type")); flexTable.setWidget(0, 1, new HTML("Web Audio API")); flexTable.setWidget(0, 2, new HTML("HTML5 audio")); flexTable.setWidget(0, 3, new HTML("Native browser <i>or</i> Plugin based support")); flexTable.setWidget(0, 4, new HTML("Flash based support")); flexTable.getRowFormatter().addStyleName(0, DemoClientBundle.INSTANCE.css().header()); SoundController soundController = new SoundController(); int i = 0; for (String mimeType : VoicesDemo.MIME_TYPES) { i++; // Native/Plugin based support MimeTypeSupport nativeMimeTypeSupport = NativeSound.getMimeTypeSupport(mimeType); String nativeMimeTypeSupportText = mimeTypeSupportToString(nativeMimeTypeSupport); Sound dummySound = soundController.createSound(Sound.MIME_TYPE_AUDIO_BASIC, "/empty.au"); if (nativeMimeTypeSupport == MIME_TYPE_SUPPORT_READY) { nativeMimeTypeSupportText += " via <code>" + dummySound.getSoundType() + "</code>"; } // Flash based support VoicesMovie movieWidget = new VoicesMovie("gwt-voices-dummy", GWT.getModuleBaseURL()); MimeTypeSupport flashMimeTypeSupport = movieWidget.getMimeTypeSupport(mimeType); String flashMimeTypeSupportText = mimeTypeSupportToString(flashMimeTypeSupport); // HTML5 audio MimeTypeSupport html5MimeTypeSupport = Html5Sound.getMimeTypeSupport(mimeType); String html5MimeTypeSupportText = mimeTypeSupportToString(html5MimeTypeSupport); // Web Audio API MimeTypeSupport webAudioMimeTypeSupport = WebAudioSound.getMimeTypeSupport(mimeType); String webAudioMimeTypeSupportText = mimeTypeSupportToString(webAudioMimeTypeSupport); // Place results in the table flexTable.setWidget(i + 1, 0, new HTML("<code>" + mimeType + "</code>")); flexTable.setWidget(i + 1, 1, new HTML(webAudioMimeTypeSupportText)); flexTable.setWidget(i + 1, 2, new HTML(html5MimeTypeSupportText)); flexTable.setWidget(i + 1, 3, new HTML(nativeMimeTypeSupportText)); flexTable.setWidget(i + 1, 4, new HTML(flashMimeTypeSupportText)); flexTable.getRowFormatter().addStyleName(i + 1, i % 2 == 0 ? DemoClientBundle.INSTANCE.css().odd() : DemoClientBundle.INSTANCE.css().even()); } initWidget(containerPanel); }
From source file:com.anzsoft.client.utils.ChatTextFormatter.java
License:Open Source License
public static HTML format(final String messageOrig) { String message = messageOrig; message = escapeHtmlLight(message);/*from ww w. ja v a 2 s. co m*/ message = message.replaceAll("\n", "<br>\n"); message = formatUrls(message); message = formatEmoticons(message); return new HTML(message); }
From source file:com.appspot.codsallarts.client.Application.java
License:Apache License
/** * Constructor.//from w ww . jav a 2s . c o m */ public Application() { // Setup the main layout widget FlowPanel layout = new FlowPanel(); initWidget(layout); // Setup the top panel with the title and links createTopPanel(); layout.add(topPanel); // Add the main menu bottomPanel = new HorizontalPanel(); bottomPanel.setWidth("100%"); bottomPanel.setSpacing(0); bottomPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); layout.add(bottomPanel); // Setup the content layout contentLayout = new Grid(2, 1); contentLayout.setStyleName("Application-content-grid"); contentLayout.setCellPadding(0); contentLayout.setCellSpacing(0); contentDecorator = new DecoratorPanel(); contentDecorator.setWidget(contentLayout); contentDecorator.addStyleName(DEFAULT_STYLE_NAME + "-content-decorator"); bottomPanel.add(contentDecorator); if (LocaleInfo.getCurrentLocale().isRTL()) { bottomPanel.setCellHorizontalAlignment(contentDecorator, HasHorizontalAlignment.ALIGN_LEFT); contentDecorator.getElement().setAttribute("align", "LEFT"); } else { bottomPanel.setCellHorizontalAlignment(contentDecorator, HasHorizontalAlignment.ALIGN_RIGHT); contentDecorator.getElement().setAttribute("align", "RIGHT"); } CellFormatter formatter = contentLayout.getCellFormatter(); // Add the content title setContentTitle(new HTML("Welcome")); formatter.setStyleName(0, 0, DEFAULT_STYLE_NAME + "-content-title"); // Add the content wrapper contentWrapper = new SimplePanel(); contentLayout.setWidget(1, 0, contentWrapper); formatter.setStyleName(1, 0, DEFAULT_STYLE_NAME + "-content-wrapper"); setContent(null); //createMainMenu(); //bottomPanel.add(mainMenu); navigationPanel = new SimplePanel(); navigationPanel.addStyleName(DEFAULT_STYLE_NAME + "-nav"); bottomPanel.add(navigationPanel); // Add a window resize handler Window.addResizeHandler(this); }