diff --git a/uberfire-workbench/uberfire-workbench-client-views-patternfly/src/main/java/org/uberfire/client/views/pfly/sys/PatternFlyBootstrapper.java b/uberfire-workbench/uberfire-workbench-client-views-patternfly/src/main/java/org/uberfire/client/views/pfly/sys/PatternFlyBootstrapper.java index e5067a8b9c..6e428a67f3 100644 --- a/uberfire-workbench/uberfire-workbench-client-views-patternfly/src/main/java/org/uberfire/client/views/pfly/sys/PatternFlyBootstrapper.java +++ b/uberfire-workbench/uberfire-workbench-client-views-patternfly/src/main/java/org/uberfire/client/views/pfly/sys/PatternFlyBootstrapper.java @@ -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. @@ -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'); + }-*/; } diff --git a/uberfire-workbench/uberfire-workbench-client-views-patternfly/src/main/java/org/uberfire/client/views/pfly/sys/PatternFlyClientBundle.java b/uberfire-workbench/uberfire-workbench-client-views-patternfly/src/main/java/org/uberfire/client/views/pfly/sys/PatternFlyClientBundle.java new file mode 100644 index 0000000000..40ff64ceb2 --- /dev/null +++ b/uberfire-workbench/uberfire-workbench-client-views-patternfly/src/main/java/org/uberfire/client/views/pfly/sys/PatternFlyClientBundle.java @@ -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(); + +}