[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui ...
Christian Bauer
christian at hibernate.org
Mon Apr 2 14:25:06 EDT 2007
User: cbauer
Date: 07/04/02 14:25:06
Modified: examples/wiki/src/main/org/jboss/seam/wiki/core/ui
FileServlet.java UIWikiFormattedText.java
Log:
Totally overengineered but definitely cool system/user/instance wiki preferences architecture
Revision Changes Path
1.5 +1 -1 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/FileServlet.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: FileServlet.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/FileServlet.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- FileServlet.java 18 Mar 2007 19:01:15 -0000 1.4
+++ FileServlet.java 2 Apr 2007 18:25:06 -0000 1.5
@@ -21,7 +21,7 @@
public class FileServlet extends HttpServlet {
- private static final String DOWNLOAD_PATH = "/download";
+ private static final String DOWNLOAD_PATH = "/download.seam";
/**
* The maximum width allowed for image rescaling
1.12 +29 -4 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.)
Index: UIWikiFormattedText.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/UIWikiFormattedText.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- UIWikiFormattedText.java 22 Mar 2007 12:47:50 -0000 1.11
+++ UIWikiFormattedText.java 2 Apr 2007 18:25:06 -0000 1.12
@@ -13,14 +13,16 @@
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.util.Resources;
import org.jboss.seam.ui.JSF;
-import org.jboss.seam.wiki.core.model.GlobalPreferences;
import org.jboss.seam.wiki.core.model.File;
import org.jboss.seam.wiki.core.engine.WikiLink;
import org.jboss.seam.wiki.core.engine.WikiTextRenderer;
import org.jboss.seam.wiki.core.engine.WikiTextParser;
+import org.jboss.seam.wiki.core.action.PluginPreferenceEditor;
+import org.jboss.seam.wiki.core.action.prefs.WikiPreferences;
import org.jboss.seam.wiki.util.WikiUtil;
import org.jboss.seam.Component;
import org.jboss.seam.core.Expressions;
+import org.jboss.seam.core.Conversation;
import com.sun.facelets.Facelet;
import com.sun.facelets.impl.DefaultFaceletFactory;
@@ -99,7 +101,8 @@
case 'L': thumbnailWidth = 320; break;
default: thumbnailWidth = file.getImageMetaInfo().getSizeX();
}
- String thumbnailUrl = WikiUtil.renderURL(inlineLink.getNode()) + "&width=" + thumbnailWidth;
+ Conversation conversation = (Conversation)Component.getInstance("conversation");
+ String thumbnailUrl = WikiUtil.renderURL(inlineLink.getNode()) + "&width=" + thumbnailWidth + "&cid=" + conversation.getId();
return "<a href=\""
+ (inlineLink.isBroken() ? inlineLink.getUrl() : WikiUtil.renderURL(inlineLink.getNode()))
@@ -120,6 +123,11 @@
Contexts.getEventContext().set("wikiTextExternalLinks", externalLinks);
}
+ public void setMacroNames(Set<String> macroNames) {
+ // Put macro names into the event context for later usage
+ Contexts.getEventContext().set("wikiTextMacroNames", macroNames);
+ }
+
public String renderMacro(String macroName) {
if (macroName == null || macroName.length() == 0) return "";
@@ -137,8 +145,25 @@
if (url == null) return "";
// Try to get the CSS for it
- GlobalPreferences globalPrefs = (GlobalPreferences) Component.getInstance("globalPrefs");
- String includeViewCSS = "/themes/" + globalPrefs.getThemeName() + "/css/" + macroName + ".css";
+ WikiPreferences wikiPrefs = (WikiPreferences) Component.getInstance("wikiPreferences");
+ String includeViewCSS = "/themes/" + wikiPrefs.getThemeName() + "/css/" + macroName + ".css";
+
+ // If this plugin has preferences and editing is enabled, instantiate a
+ // plugin preferences editor and put it in the PAGE context
+ String pluginPreferenceName = macroName + "Preferences";
+ Boolean showPluginPreferences = (Boolean)Component.getInstance("showPluginPreferences");
+ Object existingEditor = Contexts.getConversationContext().get(pluginPreferenceName+"Editor");
+ if ( showPluginPreferences != null && showPluginPreferences && existingEditor == null) {
+ PluginPreferenceEditor pluginPreferenceEditor = new PluginPreferenceEditor(pluginPreferenceName);
+ PluginPreferenceEditor.FlushObserver observer =
+ (PluginPreferenceEditor.FlushObserver)Component.getInstance("pluginPreferenceEditorFlushObserver");
+ if (pluginPreferenceEditor.getPreferenceValues().size() > 0) {
+ Contexts.getConversationContext().set(pluginPreferenceName+"Editor", pluginPreferenceEditor);
+ observer.addPluginPreferenceEditor(pluginPreferenceEditor);
+ }
+ } else if (showPluginPreferences == null || !showPluginPreferences) {
+ Contexts.getConversationContext().set(pluginPreferenceName+"Editor", null);
+ }
// Prepare all the writers for rendering
ResponseWriter originalResponseWriter = facesContext.getResponseWriter();
More information about the jboss-cvs-commits
mailing list