Java Code Examples for com.google.gwt.core.client.GWT#isClient()
The following examples show how to use
com.google.gwt.core.client.GWT#isClient() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FluentBase.java From vertxui with GNU General Public License v3.0 | 6 votes |
private void addNew(Viewable item) { if (childs == null) { childs = new ArrayList<>(); } if (item instanceof ViewOnBase) { ((ViewOnBase) item).setParent((Fluent) this); ((ViewOnBase) item).sync(); // needs to render! } else { item = getRootOf((Fluent) item); // This line connects staticly created Fluents to the DOM. // see for comments for the if-statement below in ViewOnBase::sync() if (!GWT.isClient() || element != null) { Renderer.syncChild((Fluent) this, item, null); isRendered(true); } } childs.add(item); }
Example 2
Source File: DateUtils.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
/** * Package-private version, takes a fixed "now" time - used for testing */ String formatPastDate(Date date, Date now) { // NOTE(zdwang): For now skip it for junit code; also see formatDateTime() if (!GWT.isClient()) { return "formatPastDate is not yet implemented in unit test code"; } if (!isValid(date, now)) { GWT.log("formatPastDate can only format time in the past, trying anyway", null); } if (isRecent(date, now, 6 * HOUR_MS) || onSameDay(date, now)) { return formatTime(date); } else if (isRecent(date, now, 30 * DAY_MS)) { return getMonthDayFormat().format(date) + " " + formatTime(date); } else if (isSameYear(date, now)) { return getMonthDayFormat().format(date); } else { return DateTimeFormat.getMediumDateFormat().format(date); } }
Example 3
Source File: ParagraphRenderer.java From swellrt with Apache License 2.0 | 6 votes |
/** * * Set/unset an event handler in the paragraph's DOM element * * @param element * @param paragraphType */ private void updateEventHandler(final ContentElement element, ParagraphBehaviour paragraphType) { if (!GWT.isClient()) return; Element implNodelet = element.getImplNodelet(); final EventHandler handler = paragraphType == null ? null : Paragraph.eventHandlerRegistry.get(paragraphType); if (handler != null) { DOM.sinkEvents(DomHelper.castToOld(implNodelet), LISTENER_EVENTS); DOM.setEventListener(DomHelper.castToOld(implNodelet), new EventListener() { @Override public void onBrowserEvent(Event event) { handler.onEvent(element, event); } }); } else { DOM.setEventListener(implNodelet, null); DOM.sinkEvents(implNodelet, DOM.getEventsSunk(implNodelet) & ~LISTENER_EVENTS); } }
Example 4
Source File: DateUtils.java From swellrt with Apache License 2.0 | 6 votes |
/** * Package-private version, takes a fixed "now" time - used for testing */ String formatPastDate(Date date, Date now) { // NOTE(zdwang): For now skip it for junit code; also see formatDateTime() if (!GWT.isClient()) { return "formatPastDate is not yet implemented in unit test code"; } if (!isValid(date, now)) { GWT.log("formatPastDate can only format time in the past, trying anyway", null); } if (isRecent(date, now, 6 * HOUR_MS) || onSameDay(date, now)) { return formatTime(date); } else if (isRecent(date, now, 30 * DAY_MS)) { return getMonthDayFormat().format(date) + " " + formatTime(date); } else if (isSameYear(date, now)) { return getMonthDayFormat().format(date); } else { return DateTimeFormat.getMediumDateFormat().format(date); } }
Example 5
Source File: Controller.java From vertxui with GNU General Public License v3.0 | 6 votes |
public Controller(Store store, View view) { this.store = store; this.view = view; // Get the initial state for the buttons if (GWT.isClient()) { String url = Fluent.window.getLocation().getHref(); int start = url.indexOf("#"); if (start == -1) { state.setButtons(Buttons.All); } else { url = url.substring(start + 1, url.length()); if (url.equals("/active")) { state.setButtons(Buttons.Active); } else if (url.equals("/completed")) { state.setButtons(Buttons.Completed); } else { state.setButtons(Buttons.All); } } } }
Example 6
Source File: DomLogger.java From swellrt with Apache License 2.0 | 5 votes |
/** * Constructs a Logger * * @param module Module string. Log entries will be prefixed with this string; and * logging can be enabled/disabled per-module. Loggers may share module string. */ public DomLogger(String module, LogSink logSink) { super(logSink); if (!modules.contains(module)) { modules.add(module); triggerOnNewLogger(module); } this.module = module; if (GWT.isClient()) { setupNativeLogging(module); } }
Example 7
Source File: DomLogger.java From swellrt with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} * * @return If Logger should log based on module, level and * whether logging system is enabled */ @Override protected boolean shouldLog(Level level) { // For production and unit-tests, don't log full stack traces: // NOTE(user): LogLevel.showErrors() indirectly causes a GWT.create, so // guard by GWT.isClient(). boolean shouldShowErrorDetail = GWT.isClient() && LogLevel.showErrors(); // Only log in client/GWTTestCases when logging is not disabled. return shouldShowErrorDetail && (shouldLogToBuffer(module, level) || shouldLogToPanel(module, level)); }
Example 8
Source File: SchedulerTimerService.java From swellrt with Apache License 2.0 | 5 votes |
@Override public double currentTimeMillis() { // Replace this with just Duration.currentTimeMillis() when it is itself // implemented with a GWT.isClient() check. return GWT.isClient() ? Duration.currentTimeMillis() : System.currentTimeMillis(); }
Example 9
Source File: DateUtils.java From swellrt with Apache License 2.0 | 5 votes |
/** * Formats the specified time as a String. */ public String formatTime(Date date) { // NOTE(zdwang): For now skip it for junit code; also see formatPastDate() if (!GWT.isClient()) { return "formatDateTime is not yet implemented in unit test code"; } // AM/PM -> am/pm for consistency with formatPastDate() return DateTimeFormat.getShortTimeFormat().format(date).toLowerCase(); }
Example 10
Source File: DateUtils.java From swellrt with Apache License 2.0 | 5 votes |
/** * Formats the specified date and time as a String. */ public String formatDateTime(Date date) { // NOTE(zdwang): For now skip it for junit code; also see formatPastDate() if (!GWT.isClient()) { return "formatDateTime is not yet implemented in unit test code"; } // AM/PM -> am/pm for consistency with formatPastDate() return DateTimeFormat.getShortDateTimeFormat().format(date).toLowerCase(); }
Example 11
Source File: DateUtils.java From swellrt with Apache License 2.0 | 5 votes |
/** * This is used to get a efficient time for JS. * Warning! Use TimerService if you want to actually test and control the time. */ public double currentTimeMillis() { // Use an optimised time for JS when running in JS. if (!GWT.isClient()) { return System.currentTimeMillis(); } else { return Duration.currentTimeMillis(); } }
Example 12
Source File: DateUtils.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
/** * This is used to get a efficient time for JS. * Warning! Use TimerService if you want to actually test and control the time. */ public double currentTimeMillis() { // Use an optimised time for JS when running in JS. if (!GWT.isClient()) { return System.currentTimeMillis(); } else { return Duration.currentTimeMillis(); } }
Example 13
Source File: FluentBase.java From vertxui with GNU General Public License v3.0 | 5 votes |
/** * Clean the DOM manually before the next junit test. */ public static void clearVirtualDOM() { if (!GWT.isClient()) { body = new Fluent(null); } else { throw new IllegalArgumentException( "Calling this method has zero meaning inside your browser, reload the page in your browser for a clean start."); } }
Example 14
Source File: DateUtils.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
/** * Formats the specified time as a String. */ public String formatTime(Date date) { // NOTE(zdwang): For now skip it for junit code; also see formatPastDate() if (!GWT.isClient()) { return "formatDateTime is not yet implemented in unit test code"; } // AM/PM -> am/pm for consistency with formatPastDate() return DateTimeFormat.getShortTimeFormat().format(date).toLowerCase(); }
Example 15
Source File: DomLogger.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} * * @return If Logger should log based on module, level and * whether logging system is enabled */ @Override protected boolean shouldLog(Level level) { // For production and unit-tests, don't log full stack traces: // NOTE(user): LogLevel.showErrors() indirectly causes a GWT.create, so // guard by GWT.isClient(). boolean shouldShowErrorDetail = GWT.isClient() && LogLevel.showErrors(); // Only log in client/GWTTestCases when logging is not disabled. return shouldShowErrorDetail && (shouldLogToBuffer(module, level) || shouldLogToPanel(module, level)); }
Example 16
Source File: WildcardTester.java From gwt-jackson with Apache License 2.0 | 5 votes |
public void testSerializeGenericWildcard( ObjectWriterTester<GenericWildcard<Animal>> writer ) { GenericWildcard<Animal> bean = new GenericWildcard<Animal>(); bean.generics = Arrays.asList( new Dog( "Bully", 120 ), new Cat( "Felix" ) ); String expected; if ( GWT.isClient() ) { expected = "{\"generics\":[" + "{" + "\"type\":\"doggy\"," + "\"name\":\"Bully\"," + "\"boneCount\":120" + "}," + "{" + "\"type\":\"cat\"," + "\"name\":\"Felix\"" + "}" + "]}"; } else { expected = "{\"generics\":[" + "{" + "\"name\":\"Bully\"," + "\"boneCount\":120" + "}," + "{" + "\"name\":\"Felix\"" + "}" + "]}"; } assertEquals( expected, writer.write( bean ) ); }
Example 17
Source File: UserAgentRuntimeProperties.java From incubator-retired-wave with Apache License 2.0 | 4 votes |
private static UserAgentRuntimeProperties createInstance() { return GWT.isClient() ? new UserAgentRuntimeProperties(getNativeUserAgent()) : new UserAgentRuntimeProperties(""); }
Example 18
Source File: ProfileSessionImpl.java From swellrt with Apache License 2.0 | 4 votes |
private double getCurrentTime() { return GWT.isClient() ? Duration.currentTimeMillis() : System.currentTimeMillis(); }
Example 19
Source File: UserAgentStaticProperties.java From incubator-retired-wave with Apache License 2.0 | 3 votes |
/** * Creates an instance of UserAgent. * * NOTE(danilatos): This method is designed to be statically evaluable by * the compiler, such that the compiler can determine that * only one subclass of UserAgent is ever used within a * given permutation. This is possible because * GWT.isClient() is replaced with true by the compiler, * even though it is executed normally in unit tests. * Testing the return value of GWT.create() is not adequate * because only boolean values can be statically evaluated * by the compiler at this time. * * @return an instance of UserAgent. */ private static UserAgentStaticProperties createInstance() { if (GWT.isClient()) { return GWT.create(UserAgentStaticProperties.class); } else { return new FirefoxImpl(); } }
Example 20
Source File: UserAgentStaticProperties.java From swellrt with Apache License 2.0 | 3 votes |
/** * Creates an instance of UserAgent. * * NOTE(danilatos): This method is designed to be statically evaluable by * the compiler, such that the compiler can determine that * only one subclass of UserAgent is ever used within a * given permutation. This is possible because * GWT.isClient() is replaced with true by the compiler, * even though it is executed normally in unit tests. * Testing the return value of GWT.create() is not adequate * because only boolean values can be statically evaluated * by the compiler at this time. * * @return an instance of UserAgent. */ private static UserAgentStaticProperties createInstance() { if (GWT.isClient()) { return GWT.create(UserAgentStaticProperties.class); } else { return new FirefoxImpl(); } }