Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
Add Prettify library to ClientBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianonicolai authored and porcelli committed Jul 28, 2015
1 parent 680a42c commit bfda0b7
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 6 deletions.
@@ -1,8 +1,7 @@
package org.uberfire.client.views.pfly.sys;

import org.gwtbootstrap3.client.GwtBootstrap3ClientBundle;

import com.google.gwt.core.client.ScriptInjector;
import org.gwtbootstrap3.client.GwtBootstrap3ClientBundle;

/**
* Utilities for ensuring the PatternFly/BS3 system is working early enough that the app can start correctly.
Expand All @@ -14,21 +13,35 @@ public class PatternFlyBootstrapper {
* GWTBootstrap 3 widgets should call this before creating their first such widget.
*/
public static void ensurejQueryIsAvailable() {
if (!isjQueryLoaded()) {
ScriptInjector.fromString(GwtBootstrap3ClientBundle.INSTANCE.jQuery().getText())
.setWindow(ScriptInjector.TOP_WINDOW)
if ( !isjQueryLoaded() ) {
ScriptInjector.fromString( GwtBootstrap3ClientBundle.INSTANCE.jQuery().getText() )
.setWindow( ScriptInjector.TOP_WINDOW )
.inject();
}
}

public static void ensurePrettifyIsAvailable() {
if ( !isPrettifyLoaded() ) {
ScriptInjector.fromString( PatternFlyClientBundle.INSTANCE.prettify().getText() )
.setWindow( ScriptInjector.TOP_WINDOW )
.inject();
}
}

/**
* Checks to see if jQuery is already present.
*
* @return true is jQuery is loaded, false otherwise.
*/
private static native boolean isjQueryLoaded() /*-{
return (typeof $wnd['jQuery'] !== 'undefined');
}-*/;

/**
* Checks to see if Prettify is already present.
* @return true is Prettify is loaded, false otherwise.
*/
private static native boolean isPrettifyLoaded() /*-{
return (typeof $wnd['prettyPrint'] !== 'undefined');
}-*/;
}

@@ -0,0 +1,35 @@
/*
*
* * Copyright 2012 JBoss Inc
* *
* * Licensed under the Apache License, Version 2.0 (the "License"); you may not
* * use this file except in compliance with the License. You may obtain a copy of
* * the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* * License for the specific language governing permissions and limitations under
* * the License.
*
*/

package org.uberfire.client.views.pfly.sys;

import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.TextResource;

/**
* Created by Cristiano Nicolai.
*/
public interface PatternFlyClientBundle extends ClientBundle {

PatternFlyClientBundle INSTANCE = GWT.create( PatternFlyClientBundle.class );

@Source("org/uberfire/client/views/static/patternfly/components/google-code-prettify/bin/prettify.min.js")
TextResource prettify();

}

0 comments on commit bfda0b7

Please sign in to comment.