[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui ...
Christian Bauer
christian at hibernate.org
Thu Apr 19 01:44:47 EDT 2007
User: cbauer
Date: 07/04/19 01:44:47
Modified: examples/wiki/src/main/org/jboss/seam/wiki/core/ui
WikiFormattedTextHandler.java
UIWikiFormattedText.java
Log:
Fixed a few minor bugs, now runs on 4.2 CR2
Revision Changes Path
1.5 +35 -31 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/WikiFormattedTextHandler.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: WikiFormattedTextHandler.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/WikiFormattedTextHandler.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- WikiFormattedTextHandler.java 18 Apr 2007 15:34:28 -0000 1.4
+++ WikiFormattedTextHandler.java 19 Apr 2007 05:44:47 -0000 1.5
@@ -67,9 +67,6 @@
createPlugins(ctx, cmp);
}
- /**
- * Create the Component
- */
private UIComponent createComponent(FaceletContext ctx) {
UIWikiFormattedText wikiFormattedText = new UIWikiFormattedText();
setAttributes(ctx, wikiFormattedText);
@@ -111,6 +108,8 @@
* prevent parse errors in the wikitext the clientId is stored in
* a list on the parent UIWikiFormattedText component and it's
* position is used as the placeholder.
+ * @param ctx FaceletContext
+ * @param parent Parent component
*/
private void createPlugins(FaceletContext ctx, UIComponent parent) {
if (!(parent instanceof UIWikiFormattedText)) return;
@@ -123,7 +122,13 @@
// Include the plugin
String macroName = matcher.group(1);
- includePluginFacelet(macroName, ctx, parent);
+
+ URL faceletURL = getPluginURL(macroName, ctx);
+ if (faceletURL != null) {
+ includePluginCSS(macroName, parent);
+ includePluginFacelet(faceletURL, ctx, parent);
+ createPreferencesEditor(macroName);
+ includedMacros.add(macroName);
// Get the placeholder to use
String placeHolder;
@@ -133,6 +138,7 @@
parent.getAttributes().remove(UIPlugin.NEXT_PLUGIN);
} else {
// Best guess based plugin renderer
+ // TODO: OOBE in document live preview when typing incomplete macro names
placeHolder = wikiFormattedText.addPlugin(
(parent.getChildren().get(parent.getChildCount() - 1)
.getClientId( ctx.getFacesContext() )
@@ -140,39 +146,39 @@
);
}
matcher.appendReplacement(parsed, " [<=" + placeHolder + "]");
+ } else {
+ matcher.appendReplacement(parsed, " [<=" + macroName + "]");
+ }
}
matcher.appendTail(parsed);
wikiFormattedText.setValue(parsed.toString());
}
- private void includePluginFacelet(String macroName, FaceletContext ctx, UIComponent parent) {
- if (macroName == null || macroName.length() == 0 || includedMacros.contains(macroName)) return;
+ private URL getPluginURL(String macroName, FaceletContext ctx) {
+ if (macroName == null || macroName.length() == 0 || includedMacros.contains(macroName)) return null;
String includeView = "/plugins/" + macroName + "/plugin.xhtml";
// View can't include itself
String currentViewId = ctx.getFacesContext().getViewRoot().getViewId();
- if (currentViewId.equals(includeView)) return;
+ if (currentViewId.equals(includeView)) return null;
// Try to get the XHTML document
- URL includeViewURL = Resources.getResource(includeView);
- if (includeViewURL == null) return;
-
- includePluginCSS(macroName, parent);
+ return Resources.getResource(includeView);
+ }
+ private void includePluginFacelet(URL faceletURL, FaceletContext ctx, UIComponent parent) {
// Cribbed from facelets
VariableMapper orig = ctx.getVariableMapper();
try {
ctx.setVariableMapper(new VariableMapperWrapper(orig));
- ctx.includeFacelet(parent, includeViewURL);
+ ctx.includeFacelet(parent, faceletURL);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
ctx.setVariableMapper(orig);
- includedMacros.add(macroName);
}
- createPreferencesEditor(macroName);
}
/*
@@ -181,8 +187,7 @@
private void includePluginCSS(String macroName, UIComponent cmp) {
// Try to get the CSS for it
WikiPreferences wikiPrefs = (WikiPreferences) Component.getInstance("wikiPreferences");
- String css = "/themes/" + wikiPrefs.getThemeName() + "/css/" + macroName
- + ".css";
+ String css = "/themes/" + wikiPrefs.getThemeName() + "/css/" + macroName + ".css";
if (Resources.getResource(css) != null) {
UILoadStyle style = new UILoadStyle();
style.setSrc(css);
@@ -216,12 +221,11 @@
}
-
/*
* Support method to find the UIWikiFormattedText component created by
* this tag on a previous tree build
*/
- private static final UIComponent findChildByTagId(UIComponent parent, String id) {
+ private static UIComponent findChildByTagId(UIComponent parent, String id) {
Iterator itr = parent.getFacetsAndChildren();
while (itr.hasNext()) {
UIComponent c = (UIComponent) itr.next();
1.18 +0 -0 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/UIWikiFormattedText.java
(In the diff below, changes in quantity of whitespace are not shown.)
More information about the jboss-cvs-commits
mailing list