ISIS-793: make easier to override the setup of CSS bundles

Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/c3136bf9
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/c3136bf9
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/c3136bf9

Branch: refs/heads/master
Commit: c3136bf92f0a058407664102cac9d88ee368d2c7
Parents: c566cae
Author: Dan Haywood <[email protected]>
Authored: Mon May 26 11:04:46 2014 +0100
Committer: Dan Haywood <[email protected]>
Committed: Mon May 26 11:04:46 2014 +0100

----------------------------------------------------------------------
 .../wicket/viewer/IsisWicketApplication.java    | 106 ++++++++++---------
 1 file changed, 56 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/c3136bf9/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication.java
----------------------------------------------------------------------
diff --git 
a/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication.java
 
b/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication.java
index 537ac22..259a0bd 100644
--- 
a/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication.java
+++ 
b/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication.java
@@ -371,102 +371,108 @@ public class IsisWicketApplication extends 
AuthenticatedWebApplication implement
     // //////////////////////////////////////
 
     /**
-     * The validation errors, if any, that occurred on {@link #init() startup}.
+     * Made protected visibility for easy (informal) pluggability.
      */
-    public List<String> getValidationErrors() {
-        return validationErrors;
-    }
-    
-    private void logError(String validationError) {
-        log(validationError);
-    }
-
-    private static void logBanner() {
-        String msg = "################################################ ISIS 
METAMODEL VALIDATION ERRORS 
################################################################";
-        log(msg);
-    }
-
-    private static void log(String msg) {
-        System.err.println(msg);
-        LOG.error(msg);
-    }
-
-    private void mountPage(final String mountPath, final PageType pageType) {
-        final Class<? extends Page> pageClass = 
this.pageClassRegistry.getPageClass(pageType);
-        mount(new MountedMapper(mountPath, pageClass){
-            @Override
-            protected String getOptionalPlaceholder(String s) {
-                return getPlaceholder(s, '~');
-            }
-        });
-    }
-
-    private void buildCssBundle() {
+    protected void buildCssBundle() {
         // get the css for all components built by component factories
         final Set<CssResourceReference> references = 
cssResourceReferencesForAllComponents();
-        
+
         // some additional special cases.
         addSpecialCasesToCssBundle(references);
-        
+
         // create the bundle
         getResourceBundles().addCssBundle(
-                IsisWicketApplication.class, "isis-wicket-viewer-bundle.css", 
+                IsisWicketApplication.class, "isis-wicket-viewer-bundle.css",
                 references.toArray(new CssResourceReference[]{}));
     }
 
     /**
      * Additional special cases to be included in the main CSS bundle.
-     * 
+     *
      * <p>
      * These are typically either superclasses or components that don't have 
their own ComponentFactory, or
      * for {@link ComponentFactory}s (such as <tt>StringPanelFactory</tt>) 
that don't quite follow the usual pattern
      * (because they create different types of panels).
-     * 
+     *
      * <p>
-     * Note that it doesn't really matter if we miss one or two; their CSS 
will simply be served up individually. 
+     * Note that it doesn't really matter if we miss one or two; their CSS 
will simply be served up individually.
      */
-    private void addSpecialCasesToCssBundle(final Set<CssResourceReference> 
references) {
+    protected void addSpecialCasesToCssBundle(final Set<CssResourceReference> 
references) {
 
         // abstract classes
-        
-        // ... though it turns out we cannot add this particular one to the 
bundle, because 
+
+        // ... though it turns out we cannot add this particular one to the 
bundle, because
         // it has CSS image links intended to be resolved relative to 
LinksSelectorPanelAbstract.class.
-        // Adding them into the bundle would mean these CSS links are resolved 
relative to IsisWicketApplication.class 
+        // Adding them into the bundle would mean these CSS links are resolved 
relative to IsisWicketApplication.class
         // instead.
         // 
references.add(PanelUtil.cssResourceReferenceFor(LinksSelectorPanelAbstract.class));
-        
+
         // components without factories
         
references.add(PanelUtil.cssResourceReferenceFor(AdditionalLinksPanel.class));
         
references.add(PanelUtil.cssResourceReferenceFor(CssSubMenuItemsPanel.class));
         
references.add(PanelUtil.cssResourceReferenceFor(CssMenuItemPanel.class));
         
references.add(PanelUtil.cssResourceReferenceFor(EntityPropertiesForm.class));
-        
+
         // non-conforming component factories
         
references.add(PanelUtil.cssResourceReferenceFor(MultiLineStringPanel.class));
     }
 
-    private final static Function<ComponentFactory, 
Iterable<CssResourceReference>> getCssResourceReferences = 
+    protected final static Function<ComponentFactory, 
Iterable<CssResourceReference>> getCssResourceReferences =
             new Function<ComponentFactory, Iterable<CssResourceReference>>(){
                 @Override
                 public Iterable<CssResourceReference> apply(final 
ComponentFactory input) {
-                   final CssResourceReference cssResourceReference = 
input.getCssResourceReference();
-                   return cssResourceReference != null? 
-                           Collections.singletonList(cssResourceReference): 
-                           Collections.<CssResourceReference>emptyList();
+                    final CssResourceReference cssResourceReference = 
input.getCssResourceReference();
+                    return cssResourceReference != null?
+                            Collections.singletonList(cssResourceReference):
+                            Collections.<CssResourceReference>emptyList();
                 }
-             };
+            };
 
 
-    private Set<CssResourceReference> cssResourceReferencesForAllComponents() {
+    protected Set<CssResourceReference> 
cssResourceReferencesForAllComponents() {
         Collection<ComponentFactory> componentFactories = 
getComponentFactoryRegistry().listComponentFactories();
         return Sets.newLinkedHashSet(
                 Iterables.concat(
                         Iterables.transform(
-                                componentFactories, 
+                                componentFactories,
                                 getCssResourceReferences)));
     }
 
 
+    // //////////////////////////////////////
+
+    /**
+     * The validation errors, if any, that occurred on {@link #init() startup}.
+     */
+    public List<String> getValidationErrors() {
+        return validationErrors;
+    }
+    
+    private void logError(String validationError) {
+        log(validationError);
+    }
+
+    private static void logBanner() {
+        String msg = "################################################ ISIS 
METAMODEL VALIDATION ERRORS 
################################################################";
+        log(msg);
+    }
+
+    private static void log(String msg) {
+        System.err.println(msg);
+        LOG.error(msg);
+    }
+
+    private void mountPage(final String mountPath, final PageType pageType) {
+        final Class<? extends Page> pageClass = 
this.pageClassRegistry.getPageClass(pageType);
+        mount(new MountedMapper(mountPath, pageClass){
+            @Override
+            protected String getOptionalPlaceholder(String s) {
+                return getPlaceholder(s, '~');
+            }
+        });
+    }
+
+
     /**
      * Whether Wicket tags should be stripped from the markup, as specified by 
configuration settings (otherwise 
      * depends on the {@link #deploymentType deployment type}. 

Reply via email to