xwiki-devs
Threads by month
- ----- 2026 -----
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- 9399 discussions
Hi,
I've played a bit with Yourkit and a default XE to see the memory
requirements. Here are some preliminary results (more tests needed):
* After home page loaded: 38MB non-heap, 6377 classes
* After code macro execution: 38 --> 52MB non heap, 8629 classes <---
a lot
* After groovy macro execution: 52 --> 56MB, 9920 classes
* After treeview + opened top level nodes: 56MB --> 63MB, 10960
classes <-- a lot
* After Import: 63MB --> 65MB, 13036 classes
* After Export: no change
* After navigating a bit everywhere at random: heap memory needed:
155MB (used: 132MB), non heap: 65MB, classes: 13078
* After adding attachment of 1.1MB: almost no change
* After deletion of 1.1MB attachment: used memory from 98MB to
132MB !! But still within the 155MB allocated heap memory
Conclusion so far:
==============
* We need around < 80MB non heap memory and < 200MB heap memory for
the default XE pages and if the user manipulates attachments less than
1MB.
* The default permgen size is 64MB so we're just above it (65MB).
That's why some users have reported permgen issues I believe. Jython
is eating a lot of it (14MB)
* After adding a 7.3MB attachment: heap memory max from 155 to 261
(=>110MB!)
* After removing it, need 297MB heap (even more)
Second conclusion:
==============
* Apart from attachments the memory needs seem reasonable IMO (< 255MB).
* I'd still need to make sure I test all features of the wiki to be sure
What more should I test? What should we do to reduce our permgen
needs? Should we reduce it?
Thanks
-Vincent
2
3
[xwiki-devs] Vote for XWiki at the Enterprise 2.0 Conference Launchpad !!
by Guillaume Lerouge 12 Oct '09
by Guillaume Lerouge 12 Oct '09
12 Oct '09
Hi XWikiers,
XWiki has been selected among a set of other candidates to create a video
describing what the product does. Winners get a chance to present on stage
at the Enterprise 2.0 Conference in San Francisco next November. Please vote
for the video at:
*http://launchpad.e2conf.com/vote-now/* (XWiki is the last video, at the
bottom of the list)
and help give XWiki a chance to present on stage at the Enterprise 2.0
Conference !
RT appreciated ;-)
Many thanks in advance,
Guillaume
--
Guillaume Lerouge
Product Manager - XWiki SAS
Skype: wikibc
Twitter: glerouge
http://guillaumelerouge.com/
1
1
Hi Everyone, Hi Marius,
Sorry, last message I have not finished and I pressed the space key
mistakenly and it have been sent.
Here is the code that I embeded in the Xwiki page, I just only include
js/xwiki/mail/mail.nocache.js
just once:
{{velocity}}
$xwiki.jsfx.use("js/xwiki/mail/mail.nocache.js", true)
{{html}}
<div id="DR_TreeView"></div>
{{/html}}
{{/velocity}}
or
{{velocity}}
$xwiki.jsfx.use("js/xwiki/mail/mail.nocache.js", true)
{{/velocity}}
{{html}}
<div id="DR_TreeView"></div>
{{/html}}
This will result at the top of the page that have the clickable Mail example
functioning well, at the bottom it follows two unclickable Mail example,
just like html displayed. And follows 6 xwe.onInjectionDone('xwe') sep . It
seems although I used $xwiki.jsfx.use, the JavaScript code still parsed as
wiki syntax and display as text. So what should I do?
Marius, you said "to include the JavaScript code so that it ends up in your
HTML page's head not body". Could you explain a little what do you mean by
page's body and head?" by head do you mean on the top of the page.
Thank you for your help!
Leon
3
2
Hi Everyone, Hi Marius,
Maybe the last three of unclickable mail html is generated before and saved
in the page. I will farther look into this. Thank you.
Here is the last email that I sent:
Here is the code that I embeded in the Xwiki page, I just only include
js/xwiki/mail/mail.nocache.js
just once:
{{velocity}}
$xwiki.jsfx.use("js/xwiki/mail/mail.nocache.js", true)
{{html}}
<div id="DR_TreeView"></div>
{{/html}}
{{/velocity}}
or
{{velocity}}
$xwiki.jsfx.use("js/xwiki/mail/mail.nocache.js", true)
{{/velocity}}
{{html}}
<div id="DR_TreeView"></div>
{{/html}}
This will result at the top of the page that have the clickable Mail example
functioning well, at the bottom it follows two unclickable Mail example,
just like html displayed. And follows 6 xwe.onInjectionDone('xwe') sep . It
seems although I used $xwiki.jsfx.use, the JavaScript code still parsed as
wiki syntax and display as text. So what should I do?
Marius, you said "to include the JavaScript code so that it ends up in your
HTML page's head not body". Could you explain a little what do you mean by
page's body and head?" by head do you mean on the top of the page.
Thank you.
Leon
1
0
[xwiki-devs] FYI groovy tuplespaces implementation -- gruple -- multithreaded concurrent programming library
by Niels Mayer 11 Oct '09
by Niels Mayer 11 Oct '09
11 Oct '09
http://code.google.com/p/gruple/ <-- seems potentially useful for use w/
xwiki; distributed/replicated wikis, realtime-collaboration wikis and other
future work... This will become more useful once "future release" allows
coordinating across processes, not just threads:
> A concurrent programming library written in Groovy, providing simple
> programming models for complex multi-threaded tasks.
Introduction
At its core, Gruple provides an in-process tuplespace abstraction to enable
a JavaSpaces-style programming model for communication and coordination
among threads. (A remote implementation allowing coordination among
processes is planned for a future release.)
Getting Started
The current release implements an in-memory tuplespace, with basic
operations (put, get, and take.) See the
Overview<http://code.google.com/p/gruple/wiki/Overview> page
for an introduction to the project, and the
TuplespaceUsage<http://code.google.com/p/gruple/wiki/TuplespaceUsage>
page
for documentation. Also be sure to try the
Demos<http://code.google.com/p/gruple/wiki/Demos>
See the Project Roadmap <http://code.google.com/p/gruple/wiki/Roadmap> for
other planned features.
Niels
http://nielsmayer.com
1
0
Hi Everyone, Hi Marius,
Here is the code that I embeded in the Xwiki page, I just only include
js/xwiki/mail/mail.nocache.js
just once:
{{velocity}}
$xwiki.jsfx.use("js/xwiki/mail/mail.nocache.js", true)
{{html}}
<div id="DR_TreeView"></div>
{{/html}}
{{/velocity}}
or
{{velocity}}
$xwiki.jsfx.use("js/xwiki/mail/mail.nocache.js", true)
{{/velocity}}
{{html}}
<div id="DR_TreeView"></div>
{{/html}}
This will result at the top of the page that have the clickable Mail example
functioning well, at the bottom it follows two unclickable Mail example,
just like html displayed. And follows 6 xwe.onInjectionDone('xwe') sep . It
seems although I used $xwiki.jsfx.use, the JavaScript code still parsed as
wiki syntax and display as text. So what should I do?
You said "to include the JavaScript code so that it ends up in your HTML
page's head not body".
1
0
[xwiki-devs] [xwiki-notifications] r24354 - platform/xwiki-plugins/trunk/skinx/src/main/java/com/xpn/xwiki/plugin/skinx
by Caleb James DeLisle 10 Oct '09
by Caleb James DeLisle 10 Oct '09
10 Oct '09
Hey Sergiu,
line 58 is failing checkstyle for being 2 characters too long.
* @return HTML code linking to the pulled resource (eg: <script type="text/javascript" src="/this/url.js"></script>)
Thanks again,
Caleb
sdumitriu (SVN) wrote:
> Author: sdumitriu
> Date: 2009-10-10 01:04:21 +0200 (Sat, 10 Oct 2009)
> New Revision: 24354
>
> Added:
> platform/xwiki-plugins/trunk/skinx/src/main/java/com/xpn/xwiki/plugin/skinx/AbstractResourceSkinExtensionPlugin.java
> Modified:
> platform/xwiki-plugins/trunk/skinx/src/main/java/com/xpn/xwiki/plugin/skinx/CssResourceSkinExtensionPlugin.java
> platform/xwiki-plugins/trunk/skinx/src/main/java/com/xpn/xwiki/plugin/skinx/JsResourceSkinExtensionPlugin.java
> Log:
> XSKINX-29: Refactor duplicate code
> Refactor JsResourceSkinExtensionPlugin and CssResourceSkinExtensionPlugin.
> Patch from Caleb James DeLisle, applied with several changes.
>
>
> Added: platform/xwiki-plugins/trunk/skinx/src/main/java/com/xpn/xwiki/plugin/skinx/AbstractResourceSkinExtensionPlugin.java
> ===================================================================
> --- platform/xwiki-plugins/trunk/skinx/src/main/java/com/xpn/xwiki/plugin/skinx/AbstractResourceSkinExtensionPlugin.java (rev 0)
> +++ platform/xwiki-plugins/trunk/skinx/src/main/java/com/xpn/xwiki/plugin/skinx/AbstractResourceSkinExtensionPlugin.java 2009-10-09 23:04:21 UTC (rev 24354)
> @@ -0,0 +1,102 @@
> +/*
> + * See the NOTICE file distributed with this work for additional
> + * information regarding copyright ownership.
> + *
> + * This is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as
> + * published by the Free Software Foundation; either version 2.1 of
> + * the License, or (at your option) any later version.
> + *
> + * This software is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this software; if not, write to the Free
> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> + */
> +package com.xpn.xwiki.plugin.skinx;
> +
> +import java.util.Collections;
> +import java.util.Set;
> +
> +import com.xpn.xwiki.XWikiContext;
> +import com.xpn.xwiki.XWikiException;
> +
> +/**
> + * Skin Extension plugin to use extension files from JAR resources.
> + * @version $Id$
> + */
> +public abstract class AbstractResourceSkinExtensionPlugin extends AbstractSkinExtensionPlugin
> +{
> + /**
> + * XWiki plugin constructor.
> + *
> + * @param name The name of the plugin, which can be used for retrieving the plugin API from velocity. Unused.
> + * @param className The canonical classname of the plugin. Unused.
> + * @param context The current request context.
> + * @see com.xpn.xwiki.plugin.XWikiDefaultPlugin#XWikiDefaultPlugin(String,String,com.xpn.xwiki.XWikiContext)
> + */
> + public AbstractResourceSkinExtensionPlugin(String name, String className, XWikiContext context)
> + {
> + super(name, className, context);
> + }
> +
> + /**
> + * Get the action which the url should specify for calling this resource.
> + *
> + * @return String Action name.
> + */
> + protected abstract String getAction();
> +
> + /**
> + * Takes a URL string and outputs a link which will cause the browser to load the url.
> + *
> + * @param url String representation of the url to load (eg: "/this/url.js")
> + * @return HTML code linking to the pulled resource (eg: <script type="text/javascript" src="/this/url.js"></script>)
> + */
> + protected abstract String generateLink(String url);
> +
> + /**
> + * {@inheritDoc}
> + *
> + * @see AbstractSkinExtensionPlugin#getLink(String, XWikiContext)
> + */
> + public String getLink(String resourceName, XWikiContext context)
> + {
> + // If the current user has access to Main.WebHome, we will use this document in the URL
> + // to serve the resource. This way, the resource can be efficiently cached, since it has a
> + // common URL for any page.
> + try {
> + String page = context.getWiki().getDefaultWeb(context) + "." + context.getWiki().getDefaultPage(context);
> + if (!context.getWiki().getRightService().hasAccessLevel("view", context.getUser(), page, context)) {
> + page = context.getDoc().getFullName();
> + }
> + return generateLink(context.getWiki().getURL(page, getAction(),
> + "resource=" + resourceName + parametersAsQueryString(resourceName, context), context));
> + } catch (XWikiException e) {
> + // Do nothing here; we can't access the wiki, so don't link to this resource at all.
> + return "";
> + }
> + }
> +
> + /**
> + * {@inheritDoc}
> + * <p>
> + * There is no support for always used resource-based extensions yet.
> + * </p>
> + *
> + * @see AbstractSkinExtensionPlugin#getAlwaysUsedExtensions(XWikiContext)
> + */
> + @Override
> + public Set<String> getAlwaysUsedExtensions(XWikiContext context)
> + {
> + // There is no mean to define an always used extension for something else than a document extension now,
> + // so for resources-based extensions, we return an emtpy set.
> + // An idea for the future could be to have an API for plugins and components to register always used resources
> + // extensions.
> + return Collections.emptySet();
> + }
> +}
>
>
> Property changes on: platform/xwiki-plugins/trunk/skinx/src/main/java/com/xpn/xwiki/plugin/skinx/AbstractResourceSkinExtensionPlugin.java
> ___________________________________________________________________
> Name: svn:keywords
> + Id
> Name: svn:eol-style
> + native
>
> Modified: platform/xwiki-plugins/trunk/skinx/src/main/java/com/xpn/xwiki/plugin/skinx/CssResourceSkinExtensionPlugin.java
> ===================================================================
> --- platform/xwiki-plugins/trunk/skinx/src/main/java/com/xpn/xwiki/plugin/skinx/CssResourceSkinExtensionPlugin.java 2009-10-09 18:28:50 UTC (rev 24353)
> +++ platform/xwiki-plugins/trunk/skinx/src/main/java/com/xpn/xwiki/plugin/skinx/CssResourceSkinExtensionPlugin.java 2009-10-09 23:04:21 UTC (rev 24354)
> @@ -20,11 +20,7 @@
> */
> package com.xpn.xwiki.plugin.skinx;
>
> -import java.util.Collections;
> -import java.util.Set;
> -
> import com.xpn.xwiki.XWikiContext;
> -import com.xpn.xwiki.XWikiException;
>
> /**
> * Skin Extension plugin to use css files from JAR resources.
> @@ -32,7 +28,7 @@
> * @version $Id$
> * @since 1.3
> */
> -public class CssResourceSkinExtensionPlugin extends AbstractSkinExtensionPlugin
> +public class CssResourceSkinExtensionPlugin extends AbstractResourceSkinExtensionPlugin
> {
> /**
> * XWiki plugin constructor.
> @@ -45,7 +41,6 @@
> public CssResourceSkinExtensionPlugin(String name, String className, XWikiContext context)
> {
> super(name, className, context);
> - init(context);
> }
>
> /**
> @@ -61,47 +56,22 @@
>
> /**
> * {@inheritDoc}
> - *
> - * @see AbstractSkinExtensionPlugin#getLink(String, XWikiContext)
> + *
> + * @see AbstractSkinExtensionPlugin#getAction()
> */
> - @Override
> - public String getLink(String documentName, XWikiContext context)
> + protected String getAction()
> {
> - String result = "";
> - // If the current user has access to Main.WebHome, we will use this document in the URL
> - // to serve the css resource. This way, the resource can be efficiently cached, since it has a
> - // common URL for any page.
> - try {
> - String page = context.getWiki().getDefaultWeb(context) + "." + context.getWiki().getDefaultPage(context);
> - if (!context.getWiki().getRightService().hasAccessLevel("view", context.getUser(), page, context)) {
> - page = context.getDoc().getFullName();
> - }
> - String url =
> - context.getWiki().getURL(page, "ssx",
> - "resource=" + documentName + parametersAsQueryString(documentName, context), context);
> - result = "<link rel='stylesheet' type='text/css' href='" + url + "'/>";
> - } catch (XWikiException e) {
> - // Do nothing here; we can't access the wiki, so don't link to this resource at all.
> - }
> - return result;
> + return "ssx";
> }
>
> /**
> * {@inheritDoc}
> - * <p>
> - * There is no support for always used resource-based extensions yet.
> - * </p>
> - *
> - * @see AbstractSkinExtensionPlugin#getAlwaysUsedExtensions(XWikiContext)
> + *
> + * @see AbstractSkinExtensionPlugin#generateLink()
> */
> - @Override
> - public Set<String> getAlwaysUsedExtensions(XWikiContext context)
> + protected String generateLink(String url)
> {
> - // There is no mean to define an always used extension for something else than a document extension now,
> - // so for resources-based extensions, we return an emtpy set.
> - // An idea for the future could be to have an API for plugins and components to register always used resources
> - // extensions.
> - return Collections.emptySet();
> + return "<link rel='stylesheet' type='text/css' href='" + url + "'/>\n";
> }
>
> /**
>
> Modified: platform/xwiki-plugins/trunk/skinx/src/main/java/com/xpn/xwiki/plugin/skinx/JsResourceSkinExtensionPlugin.java
> ===================================================================
> --- platform/xwiki-plugins/trunk/skinx/src/main/java/com/xpn/xwiki/plugin/skinx/JsResourceSkinExtensionPlugin.java 2009-10-09 18:28:50 UTC (rev 24353)
> +++ platform/xwiki-plugins/trunk/skinx/src/main/java/com/xpn/xwiki/plugin/skinx/JsResourceSkinExtensionPlugin.java 2009-10-09 23:04:21 UTC (rev 24354)
> @@ -20,11 +20,7 @@
> */
> package com.xpn.xwiki.plugin.skinx;
>
> -import java.util.Collections;
> -import java.util.Set;
> -
> import com.xpn.xwiki.XWikiContext;
> -import com.xpn.xwiki.XWikiException;
>
> /**
> * Skin Extension plugin that allows pulling javascript files from JAR resources.
> @@ -32,7 +28,7 @@
> * @version $Id$
> * @since 1.3
> */
> -public class JsResourceSkinExtensionPlugin extends AbstractSkinExtensionPlugin
> +public class JsResourceSkinExtensionPlugin extends AbstractResourceSkinExtensionPlugin
> {
> /**
> * XWiki plugin constructor.
> @@ -44,57 +40,42 @@
> */
> public JsResourceSkinExtensionPlugin(String name, String className, XWikiContext context)
> {
> - super("jsrx", className, context);
> - init(context);
> + super(name, className, context);
> }
>
> /**
> * {@inheritDoc}
> *
> - * @see AbstractSkinExtensionPlugin#getLink(String, XWikiContext)
> + * @see com.xpn.xwiki.plugin.XWikiDefaultPlugin#getName()
> */
> @Override
> - public String getLink(String documentName, XWikiContext context)
> + public String getName()
> {
> - String result = "";
> - // If the current user has access to Main.WebHome, we will use this document in the URL
> - // to serve the js resource. This way, the resource can be efficiently cached, since it has a
> - // common URL for any page.
> - try {
> - String page = context.getWiki().getDefaultWeb(context) + "." + context.getWiki().getDefaultPage(context);
> - if (!context.getWiki().getRightService().hasAccessLevel("view", context.getUser(), page, context)) {
> - page = context.getDoc().getFullName();
> - }
> - String url =
> - context.getWiki().getURL(page, "jsx",
> - "resource=" + documentName + parametersAsQueryString(documentName, context), context);
> - result = "<script type=\"text/javascript\" src=\"" + url + "\"></script>";
> - } catch (XWikiException e) {
> - // Do nothing here; we can't access the wiki, so don't link to this resource at all.
> - }
> - return result;
> + return "jsrx";
> }
>
> /**
> * {@inheritDoc}
> - * <p>
> - * There is no support for always used resource-based extensions yet.
> - * </p>
> - *
> - * @see AbstractSkinExtensionPlugin#getAlwaysUsedExtensions(XWikiContext)
> + *
> + * @see AbstractSkinExtensionPlugin#getAction()
> */
> - @Override
> - public Set<String> getAlwaysUsedExtensions(XWikiContext context)
> + protected String getAction()
> {
> - // There is no mean to define an always used extension for something else than a document extension now,
> - // so for resources-based extensions, we return an emtpy set.
> - // An idea for the future could be to have an API for plugins and components to register always used resources
> - // extensions.
> - return Collections.emptySet();
> + return "jsx";
> }
>
> /**
> * {@inheritDoc}
> + *
> + * @see AbstractSkinExtensionPlugin#generateLink()
> + */
> + protected String generateLink(String url)
> + {
> + return "<script type=\"text/javascript\" src=\"" + url + "\"></script>\n";
> + }
> +
> + /**
> + * {@inheritDoc}
> * <p>
> * We must override this method since the plugin manager only calls it for classes that provide their own
> * implementation, and not an inherited one.
>
> _______________________________________________
> notifications mailing list
> notifications(a)xwiki.org
> http://lists.xwiki.org/mailman/listinfo/notifications
>
2
1
Could we get this one in the paper cut list ?
http://jira.xwiki.org/jira/browse/XWIKI-831
The patch in this jira both fixes:
- the ability to add version instead of overriding (the current behavior
can result in data loss)
- the setting of contentAuthor (this is the paper cut as it forces to
resave all pages which require prog rights)
These bugs do lead to productivity loss. If I just sum the time it takes
to do the resaves I'm sure this amounts in days since the beginning of
the year
Ludovic
--
Ludovic Dubost
Blog: http://blog.ludovic.org/
XWiki: http://www.xwiki.com
Skype: ldubost GTalk: ldubost
1
0
Re: [xwiki-devs] [xwiki-notifications] r24335 - in platform/web/trunk: standard/src/main/webapp/templates wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/editor wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/image/ui wysiwyg/src/main/java/com/xpn/xw
by Asiri Rathnayake 09 Oct '09
by Asiri Rathnayake 09 Oct '09
09 Oct '09
Hi,
> > + /**
> > + * {@inheritDoc}
> > + */
> > + public String getSpace()
> > + {
> > + return config.getParameter("space", "Main");
> > + }
> > +
> > + /**
> > + * {@inheritDoc}
> > + */
> > + public String getWiki()
> > + {
> > + return config.getParameter("wiki", "xwiki");
> > + }
>
> Actually I don't see a good reason for which I made these functions public.
> We
> should make them protected.
>
+1, I'll do it.
>
> > +
> > + /**
> > + * {@inheritDoc}
> > + */
> > + protected String getFileHelpLabel()
> > + {
> > + return Strings.INSTANCE.importOfficeFileHelpLabel();
> > + }
> > +
> > + /**
> > + * {@inheritDoc}
> > + */
> > + protected void onAttachmentUploaded(Attachment attach, final
> AsyncCallback<Boolean> async)
> > + {
> > +
> > + String fullPageName = getSpace() + "." + getPage();
>
> you should use the ResourceName class to build wiki names, since it's the
> client
> wiki reference serializer/deserializer.
> > +
> WysiwygService.Singleton.getInstance().officeToXHTML(fullPageName,
> getHTMLCleaningParams(),
>
Actually this code will go away when I introduce the new
officeToXHTML(Attachment....) method.
> + // Display the error and avoid submit operation from
> continuing.
> > + displayError(thrown.getMessage());
> > + async.onSuccess(false);
>
> As a convention, we used the onFailure to signal an error on the server or
> in
> the server-client communication (like a GWT failure in the RPC call), while
> the
> submit async.onSuccess(false) is an "application error", a way in which a
> wizard
> step prevents the submit to be done because, for example, the user didn't
> insert
> valid data in the wizard form and another chance is being given to him.
>
> Now, which are the cases in which the importer service fails (throws
> exception)?
> is it correct to do this conversion here (from a server error / exception
> to a
> "validation" error)? or you should rather call async.onFailure()? this only
> depends on the logic of the service function failure.
>
Thanks. I will look into this and fix it.
> + */
> > + public EnumSet<NavigationDirection> getValidDirections()
> > + {
> > + return EnumSet.of(NavigationDirection.FINISH);
>
> We also return CANCEL here, even if a button for it is not displayed and
> it's
> always possible (through the dialog's close button), but in case we will
> ever
> want to display a button, or want to prevent the cancel in certain steps.
>
Ok, I will fix this.
>
> > + public void init(Object data, AsyncCallback< ?> cb)
> > + {
> > + textArea.setHTML("");
> > + textArea.setFocus(true);
>
> I seriously doubt this works, you should a FocusCommand(), look at its
> comment
> for reasons.
>
Ok.
>
> > + protected Map<String, String> getHTMLCleaningParams()
> > + {
> > + Map<String, String> params = new HashMap<String, String>();
> > + params.put("filterStyles", "strict");
> > + // For Office2007: Office2007 generates an xhtml document (when
> copied) which has attributes and tags of
> > + // several namespaces. But the document itself doesn't contain
> the namespace definitions, which causes
> > + // the HTMLCleaner (the DomSerializer) to fail while performing
> it's operations. As a workaround we
> > + // force HTMLCleaner to avoid parsing of namespace information.
> > + params.put("namespacesAware", Boolean.toString(false));
> > + return params;
> > + }
>
> Is this the same function as in the other class?
>
Yes, I am reluctant to introduce a super class or a utility class to wrap up
this functionality. Not sure if I should do it or not.
> + return requestedStep;
>
> Maybe we could create a super class for this, it's the same everywhere.
>
+1.
> Also,
>
> svn propset svn:keywords "Author Id Revision HeadURL" <new-file-path>
>
> for all new added files.
>
> check
>
> http://dev.xwiki.org/xwiki/bin/view/Community/DevelopmentPractices#HSubvers…
> for how to configure this for your svn client. Note that, even if correctly
> configured, the settings will not be considered by the eclipse plugin (I
> didn't
> manage to make them work), you'll have to do a command-line svn add for
> that to
> work right.
>
Ok, thanks for the tip.
- Asiri
1
0
Hi Asiri,
see below
On 10/09/2009 02:32 PM, asiri (SVN) wrote:
> Author: asiri
> Date: 2009-10-09 13:32:44 +0200 (Fri, 09 Oct 2009)
> New Revision: 24335
>
> Added:
> platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImportMenuExtension.java
> platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImportPlugin.java
> platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImportPluginFactory.java
> platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ImportOfficeFileWizardStep.java
> platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ImportOfficePasteWizardStep.java
> platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ImportWizard.java
> platform/web/trunk/wysiwyg/src/main/resources/com/xpn/xwiki/wysiwyg/client/editor/import.gif
> platform/web/trunk/wysiwyg/src/main/resources/com/xpn/xwiki/wysiwyg/client/editor/import_office_file.gif
> platform/web/trunk/wysiwyg/src/main/resources/com/xpn/xwiki/wysiwyg/client/editor/import_office_paste.gif
> Removed:
> platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImporterListener.java
> platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImporterPlugin.java
> platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImporterPluginFactory.java
> platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/AbstractImporter.java
> platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ClipboardImporter.java
> platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/FileImporter.java
> platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ImporterDialog.java
> platform/web/trunk/wysiwyg/src/main/resources/com/xpn/xwiki/wysiwyg/client/editor/importer.gif
> Modified:
> platform/web/trunk/standard/src/main/webapp/templates/macros.vm
> platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/editor/Images.java
> platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/editor/Strings.java
> platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/editor/WysiwygEditorFactory.java
> platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/image/ui/ImageUploadWizardStep.java
> platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/link/ui/AttachmentUploadWizardStep.java
> platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/widget/wizard/util/AbstractFileUploadWizardStep.java
> platform/web/trunk/wysiwyg/src/main/resources/com/xpn/xwiki/wysiwyg/client/editor/Strings.properties
> platform/web/trunk/wysiwyg/src/main/resources/com/xpn/xwiki/wysiwyg/public/stylesheets/importer.css
> Log:
> XWIKI-4469: Move officeimporter plugin functionality to wysiwyg top-level menu.
>
> * Implemented, need to re-integrate the "Filter Styles" checkbox. Will be done shortly.
>
> Modified: platform/web/trunk/standard/src/main/webapp/templates/macros.vm
> ===================================================================
> --- platform/web/trunk/standard/src/main/webapp/templates/macros.vm 2009-10-09 10:17:25 UTC (rev 24334)
> +++ platform/web/trunk/standard/src/main/webapp/templates/macros.vm 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -2211,9 +2211,9 @@
> displayTabs: true,
> defaultEditor: "wysiwyg",
> #end
> - plugins: '$xwiki.getXWikiPreference("wysiwyg.plugins", "submit line separator text valign list indent history format symbol link image table macro importer#if($full&& $request.sync) sync#end")',
> - menu: '$xwiki.getXWikiPreference("wysiwyg.menu", "link image table macro")',
> - toolbar: '$xwiki.getXWikiPreference("wysiwyg.toolbar", "bold italic underline strikethrough | subscript superscript | unorderedlist orderedlist | outdent indent | undo redo | format | hr symbol | link unlink | importer")',
> + plugins: '$xwiki.getXWikiPreference("wysiwyg.plugins", "submit line separator text valign list indent history format symbol link image table macro import#if($full&& $request.sync) sync#end")',
> + menu: '$xwiki.getXWikiPreference("wysiwyg.menu", "link image table macro import")',
> + toolbar: '$xwiki.getXWikiPreference("wysiwyg.toolbar", "bold italic underline strikethrough | subscript superscript | unorderedlist orderedlist | outdent indent | undo redo | format | hr symbol | link unlink")',
> wiki: '$!{editedDocument.wiki.replace("'", "\'")}',
> space: '$!{editedDocument.space.replace("'", "\'")}',
> page: '$!{editedDocument.name.replace("'", "\'")}',
>
> Modified: platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/editor/Images.java
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/editor/Images.java 2009-10-09 10:17:25 UTC (rev 24334)
> +++ platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/editor/Images.java 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -53,8 +53,17 @@
> @Resource("image.gif")
> AbstractImagePrototype image();
>
> - @Resource("importer.gif")
> - AbstractImagePrototype importer();
> + @Resource("import.gif")
> + AbstractImagePrototype importMenuEntryIcon();
> +
> + @Resource("import.gif")
> + AbstractImagePrototype importWizardIcon();
> +
> + @Resource("import_office_file.gif")
> + AbstractImagePrototype importOfficeFileMenuEntryIcon();
> +
> + @Resource("import_office_paste.gif")
> + AbstractImagePrototype importOfficePasteMenuEntryIcon();
>
> @Resource("indent.gif")
> AbstractImagePrototype indent();
>
> Modified: platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/editor/Strings.java
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/editor/Strings.java 2009-10-09 10:17:25 UTC (rev 24334)
> +++ platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/editor/Strings.java 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -361,32 +361,30 @@
>
> String tableInsertDialogTitle();
>
> - String tableInsertStrictPositiveIntegerRequired();
> -
> - String importerToolTip();
> -
> - String importerCaption();
> -
> - String importerClipboardTabCaption();
> -
> - String importerClipboardTabInfoLabel();
> -
> - String importerClipboardTabHelpLabel();
> -
> - String importerFileTabCaption();
> -
> - String importerFileTabInfoLabel();
> -
> - String importerFileTabHelpLabel();
> + String tableInsertStrictPositiveIntegerRequired();
>
> - String importerFileTabNotAvailableLabel();
> + String importMenuEntryCaption();
> +
> + String importWizardTitle();
> +
> + String importWizardImportButtonCaption();
> +
> + String importOfficeFileMenuItemCaption();
> +
> + String importOfficeFileFeatureNotAvailable();
> +
> + String importOfficeFileWizardStepTitle();
> +
> + String importOfficeFileHelpLabel();
> +
> + String importOfficePasteMenuItemCaption();
> +
> + String importOfficePasteWizardStepTitle();
> +
> + String importOfficePasteInfoLabel();
> +
> + String importOfficePasteHelpLabel();
>
> - String importerFilterStylesCheckBoxCaption();
> -
> - String importerImportButtonCaption();
> -
> - String importerCancelButtonCaption();
> -
> String wizardCancel();
>
> String wizardPrevious();
>
> Modified: platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/editor/WysiwygEditorFactory.java
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/editor/WysiwygEditorFactory.java 2009-10-09 10:17:25 UTC (rev 24334)
> +++ platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/editor/WysiwygEditorFactory.java 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -26,7 +26,7 @@
> import com.xpn.xwiki.wysiwyg.client.plugin.format.FormatPluginFactory;
> import com.xpn.xwiki.wysiwyg.client.plugin.history.HistoryPluginFactory;
> import com.xpn.xwiki.wysiwyg.client.plugin.image.ImagePluginFactory;
> -import com.xpn.xwiki.wysiwyg.client.plugin.importer.ImporterPluginFactory;
> +import com.xpn.xwiki.wysiwyg.client.plugin.importer.ImportPluginFactory;
> import com.xpn.xwiki.wysiwyg.client.plugin.indent.IndentPluginFactory;
> import com.xpn.xwiki.wysiwyg.client.plugin.internal.DefaultPluginFactoryManager;
> import com.xpn.xwiki.wysiwyg.client.plugin.justify.JustifyPluginFactory;
> @@ -100,7 +100,7 @@
> pfm.addPluginFactory(LinkPluginFactory.getInstance());
> pfm.addPluginFactory(TablePluginFactory.getInstance());
> pfm.addPluginFactory(ImagePluginFactory.getInstance());
> - pfm.addPluginFactory(ImporterPluginFactory.getInstance());
> + pfm.addPluginFactory(ImportPluginFactory.getInstance());
> pfm.addPluginFactory(MacroPluginFactory.getInstance());
> // add additional PluginFactory for other plug-ins
> }
>
> Modified: platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/image/ui/ImageUploadWizardStep.java
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/image/ui/ImageUploadWizardStep.java 2009-10-09 10:17:25 UTC (rev 24334)
> +++ platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/image/ui/ImageUploadWizardStep.java 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -86,12 +86,13 @@
> * {@inheritDoc}
> */
> @Override
> - protected void onAttachmentUploaded(Attachment attach)
> + protected void onAttachmentUploaded(Attachment attach, AsyncCallback<Boolean> async)
> {
> // upload is done successfully, commit the data in the image config
> imageData.setImageURL(attach.getDownloadUrl());
> ResourceName ref = new ResourceName(attach.getReference(), true);
> imageData.setReference(ref.getRelativeTo(editedResource).toString());
> + async.onSuccess(true);
> }
>
> /**
>
> Added: platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImportMenuExtension.java
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImportMenuExtension.java (rev 0)
> +++ platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImportMenuExtension.java 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -0,0 +1,103 @@
> +/*
> + * See the NOTICE file distributed with this work for additional
> + * information regarding copyright ownership.
> + *
> + * This is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as
> + * published by the Free Software Foundation; either version 2.1 of
> + * the License, or (at your option) any later version.
> + *
> + * This software is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this software; if not, write to the Free
> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> + */
> +package com.xpn.xwiki.wysiwyg.client.plugin.importer;
> +
> +import com.google.gwt.user.client.Command;
> +import com.xpn.xwiki.wysiwyg.client.editor.Images;
> +import com.xpn.xwiki.wysiwyg.client.editor.Strings;
> +import com.xpn.xwiki.wysiwyg.client.plugin.internal.MenuItemUIExtension;
> +import com.xpn.xwiki.wysiwyg.client.widget.MenuBar;
> +import com.xpn.xwiki.wysiwyg.client.widget.MenuItem;
> +
> +/**
> + * Provides access to various content importers through the top-level wysiwyg menu.
> + *
> + * @version $Id$
> + * @since 2.0.1
> + */
> +public class ImportMenuExtension extends MenuItemUIExtension
> +{
> + /**
> + * The top level menu entry.
> + */
> + private MenuItem importMenuEntry;
> +
> + /**
> + * The sub-menu that gets expanded once clicked on importMenuEntry.
> + */
> + private MenuBar importMenu;
> +
> + /**
> + * Creates a new import menu extension.
> + *
> + * @param importPlugin import plugin instance.
> + */
> + public ImportMenuExtension(final ImportPlugin importPlugin)
> + {
> + super("menu");
> +
> + // Office File Import.
> + MenuItem importOfficeFileMenuItem =
> + new MenuItem(Strings.INSTANCE.importOfficeFileMenuItemCaption(), new Command()
> + {
> + public void execute()
> + {
> + importPlugin.onImportOfficeFile();
> + }
> + });
> + importOfficeFileMenuItem.setIcon(Images.INSTANCE.importOfficeFileMenuEntryIcon().createElement());
> +
> + // Office Paste Import.
> + MenuItem importOfficePasteMenuItem =
> + new MenuItem(Strings.INSTANCE.importOfficePasteMenuItemCaption(), new Command()
> + {
> + public void execute()
> + {
> + importPlugin.onImportOfficePaste();
> +
> + }
> + });
> + importOfficePasteMenuItem.setIcon(Images.INSTANCE.importOfficePasteMenuEntryIcon().createElement());
> +
> + importMenu = new MenuBar(true);
> + importMenu.setAnimationEnabled(false);
> + importMenu.addItem(importOfficeFileMenuItem);
> + importMenu.addItem(importOfficePasteMenuItem);
> +
> + importMenuEntry = new MenuItem(Strings.INSTANCE.importMenuEntryCaption(), importMenu);
> + importMenuEntry.setIcon(Images.INSTANCE.importMenuEntryIcon().createElement());
> +
> + addFeature(ImportPluginFactory.getInstance().getPluginName(), importMenuEntry);
> + }
> +
> + /**
> + * Cleans up this menu extension on destroy.
> + */
> + public void destroy()
> + {
> + importMenu.clearItems();
> + importMenu = null;
> +
> + importMenuEntry.getParentMenu().removeItem(importMenuEntry);
> + importMenuEntry = null;
> +
> + this.clearFeatures();
> + }
> +}
>
> Copied: platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImportPlugin.java (from rev 24287, platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImporterPlugin.java)
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImportPlugin.java (rev 0)
> +++ platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImportPlugin.java 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -0,0 +1,122 @@
> +/*
> + * See the NOTICE file distributed with this work for additional
> + * information regarding copyright ownership.
> + *
> + * This is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as
> + * published by the Free Software Foundation; either version 2.1 of
> + * the License, or (at your option) any later version.
> + *
> + * This software is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this software; if not, write to the Free
> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> + */
> +package com.xpn.xwiki.wysiwyg.client.plugin.importer;
> +
> +import com.google.gwt.user.client.Window;
> +import com.xpn.xwiki.wysiwyg.client.Wysiwyg;
> +import com.xpn.xwiki.wysiwyg.client.editor.Strings;
> +import com.xpn.xwiki.wysiwyg.client.plugin.importer.ui.ImportWizard;
> +import com.xpn.xwiki.wysiwyg.client.plugin.importer.ui.ImportWizard.ImportWizardStep;
> +import com.xpn.xwiki.wysiwyg.client.plugin.internal.AbstractPlugin;
> +import com.xpn.xwiki.wysiwyg.client.util.Config;
> +import com.xpn.xwiki.wysiwyg.client.widget.rta.RichTextArea;
> +import com.xpn.xwiki.wysiwyg.client.widget.rta.cmd.Command;
> +import com.xpn.xwiki.wysiwyg.client.widget.wizard.Wizard;
> +import com.xpn.xwiki.wysiwyg.client.widget.wizard.WizardListener;
> +
> +/**
> + * Plugin responsible for importing external content into wysiwyg editor.
> + *
> + * @version $Id$
> + */
> +public class ImportPlugin extends AbstractPlugin implements WizardListener
> +{
> + /**
> + * Import wizard.
> + */
> + private Wizard importWizard;
> +
> + /**
> + * Import menu extension.
> + */
> + private ImportMenuExtension importMenuExtension;
> +
> + /**
> + * {@inheritDoc}
> + */
> + public void init(Wysiwyg wysiwyg, RichTextArea textArea, Config config)
> + {
> + super.init(wysiwyg, textArea, config);
> + this.importMenuExtension = new ImportMenuExtension(this);
> + getUIExtensionList().add(importMenuExtension);
> + }
> +
> + /**
> + * Method invoked by {@link ImportMenuExtension} when "Import -> Office File" menu item is clicked.
> + */
> + public void onImportOfficeFile()
> + {
> + boolean isOpenOfficeServerConnected =
> + getConfig().getParameter("openofficeServerConnected", "false").equals("true");
> + if (isOpenOfficeServerConnected) {
> + getImportWizard().start(ImportWizardStep.OFFICE_FILE.toString(), null);
> + } else {
> + Window.alert(Strings.INSTANCE.importOfficeFileFeatureNotAvailable());
> + }
> + }
> +
> + /**
> + * Method invoked by {@link ImportMenuExtension} when "Import -> Office Content" menu item is clicked.
> + */
> + public void onImportOfficePaste()
> + {
> + getImportWizard().start(ImportWizardStep.OFFICE_PASTE.toString(), null);
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public void onCancel(Wizard sender)
> + {
> + getTextArea().setFocus(true);
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public void onFinish(Wizard sender, Object result)
> + {
> + getTextArea().setFocus(true);
> + getTextArea().getCommandManager().execute(Command.INSERT_HTML, result.toString());
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public void destroy()
> + {
> + importMenuExtension.destroy();
> + super.destroy();
> + }
> +
> + /**
> + * Creates and returns the import wizard.
> + *
> + * @return import wizard instance.
> + */
> + private Wizard getImportWizard()
> + {
> + if (null == importWizard) {
> + importWizard = new ImportWizard(getConfig());
> + importWizard.addWizardListener(this);
> + }
> + return importWizard;
> + }
> +}
>
> Copied: platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImportPluginFactory.java (from rev 24287, platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImporterPluginFactory.java)
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImportPluginFactory.java (rev 0)
> +++ platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImportPluginFactory.java 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -0,0 +1,63 @@
> +/*
> + * See the NOTICE file distributed with this work for additional
> + * information regarding copyright ownership.
> + *
> + * This is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as
> + * published by the Free Software Foundation; either version 2.1 of
> + * the License, or (at your option) any later version.
> + *
> + * This software is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this software; if not, write to the Free
> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> + */
> +package com.xpn.xwiki.wysiwyg.client.plugin.importer;
> +
> +import com.xpn.xwiki.wysiwyg.client.plugin.Plugin;
> +import com.xpn.xwiki.wysiwyg.client.plugin.internal.AbstractPluginFactory;
> +
> +/**
> + * {@link PluginFactory} class for the office importer wysiwyg plugin.
> + *
> + * @version $Id$
> + */
> +public final class ImportPluginFactory extends AbstractPluginFactory
> +{
> + /**
> + * Private instance of the plugin factory. Plugin factory is a singleton.
> + */
> + private static ImportPluginFactory instance;
> +
> + /**
> + * Private constructor.
> + */
> + private ImportPluginFactory()
> + {
> + super("import");
> + }
> +
> + /**
> + * @return The singleton instance of the plugin factory.
> + */
> + public static synchronized ImportPluginFactory getInstance()
> + {
> + if (null == instance) {
> + instance = new ImportPluginFactory();
> + }
> + return instance;
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public Plugin newInstance()
> + {
> + return new ImportPlugin();
> + }
> +}
>
> Deleted: platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImporterListener.java
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImporterListener.java 2009-10-09 10:17:25 UTC (rev 24334)
> +++ platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImporterListener.java 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -1,44 +0,0 @@
> -/*
> - * See the NOTICE file distributed with this work for additional
> - * information regarding copyright ownership.
> - *
> - * This is free software; you can redistribute it and/or modify it
> - * under the terms of the GNU Lesser General Public License as
> - * published by the Free Software Foundation; either version 2.1 of
> - * the License, or (at your option) any later version.
> - *
> - * This software is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - * Lesser General Public License for more details.
> - *
> - * You should have received a copy of the GNU Lesser General Public
> - * License along with this software; if not, write to the Free
> - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> - * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> - */
> -
> -package com.xpn.xwiki.wysiwyg.client.plugin.importer;
> -
> -/**
> - * The interface allowing a controller to listen to office import events.
> - *
> - * @version $Id$
> - * @since 2.0.1
> - */
> -public interface ImporterListener
> -{
> - /**
> - * This method will be invoked when an office import operation completes successfully.
> - *
> - * @param result the result of import operation.
> - */
> - void onSuccess(String result);
> -
> - /**
> - * This method will be invoked when an office import operation fails for some reason.
> - *
> - * @param error a message explaining the error.
> - */
> - void onFailure(String error);
> -}
>
> Deleted: platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImporterPlugin.java
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImporterPlugin.java 2009-10-09 10:17:25 UTC (rev 24334)
> +++ platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImporterPlugin.java 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -1,138 +0,0 @@
> -/*
> - * See the NOTICE file distributed with this work for additional
> - * information regarding copyright ownership.
> - *
> - * This is free software; you can redistribute it and/or modify it
> - * under the terms of the GNU Lesser General Public License as
> - * published by the Free Software Foundation; either version 2.1 of
> - * the License, or (at your option) any later version.
> - *
> - * This software is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - * Lesser General Public License for more details.
> - *
> - * You should have received a copy of the GNU Lesser General Public
> - * License along with this software; if not, write to the Free
> - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> - * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> - */
> -package com.xpn.xwiki.wysiwyg.client.plugin.importer;
> -
> -import com.google.gwt.event.dom.client.ClickEvent;
> -import com.google.gwt.event.dom.client.ClickHandler;
> -import com.google.gwt.user.client.Window;
> -import com.google.gwt.user.client.ui.PushButton;
> -import com.xpn.xwiki.wysiwyg.client.Wysiwyg;
> -import com.xpn.xwiki.wysiwyg.client.editor.Images;
> -import com.xpn.xwiki.wysiwyg.client.editor.Strings;
> -import com.xpn.xwiki.wysiwyg.client.plugin.importer.ui.ImporterDialog;
> -import com.xpn.xwiki.wysiwyg.client.plugin.internal.AbstractPlugin;
> -import com.xpn.xwiki.wysiwyg.client.plugin.internal.FocusWidgetUIExtension;
> -import com.xpn.xwiki.wysiwyg.client.util.Config;
> -import com.xpn.xwiki.wysiwyg.client.widget.CompositeDialogBox;
> -import com.xpn.xwiki.wysiwyg.client.widget.rta.RichTextArea;
> -import com.xpn.xwiki.wysiwyg.client.widget.rta.cmd.Command;
> -
> -/**
> - * Office Importer wysiwyg plugin.
> - *
> - * @version $Id$
> - */
> -public class ImporterPlugin extends AbstractPlugin implements ClickHandler, ImporterListener
> -{
> - /**
> - * Import button placed on the tool bar.
> - */
> - private PushButton importPushButton;
> -
> - /**
> - * Importer dialog used to communicate with the user.
> - */
> - private CompositeDialogBox importerDialog;
> -
> - /**
> - * The toolbar extension used to add the link buttons to the toolbar.
> - */
> - private final FocusWidgetUIExtension toolBarExtension = new FocusWidgetUIExtension("toolbar");
> -
> - /**
> - * {@inheritDoc}
> - */
> - public void init(Wysiwyg wysiwyg, RichTextArea textArea, Config config)
> - {
> - super.init(wysiwyg, textArea, config);
> -
> - if (getTextArea().getCommandManager().isSupported(Command.INSERT_HTML)) {
> - importPushButton = new PushButton(Images.INSTANCE.importer().createImage());
> - saveRegistration(importPushButton.addClickHandler(this));
> - importPushButton.setTitle(Strings.INSTANCE.importerToolTip());
> - toolBarExtension.addFeature("importer", importPushButton);
> - }
> -
> - if (toolBarExtension.getFeatures().length> 0) {
> - getUIExtensionList().add(toolBarExtension);
> - }
> - }
> -
> - /**
> - * {@inheritDoc}
> - */
> - public void destroy()
> - {
> - if (importPushButton != null) {
> - importPushButton.removeFromParent();
> - importPushButton = null;
> - }
> - if (importerDialog != null) {
> - importerDialog.hide();
> - importerDialog.removeFromParent();
> - importerDialog = null;
> - }
> - if (toolBarExtension.getFeatures().length> 0) {
> - toolBarExtension.clearFeatures();
> - }
> - super.destroy();
> - }
> -
> - /**
> - * {@inheritDoc}
> - *
> - * @see ClickHandler#onClick(ClickEvent)
> - */
> - public void onClick(ClickEvent event)
> - {
> - if (event.getSource() == importPushButton) {
> - getImporterDialog().center();
> - }
> - }
> -
> - /**
> - * @return The importer dialog instance.
> - */
> - private CompositeDialogBox getImporterDialog()
> - {
> - if (null == importerDialog) {
> - importerDialog = new ImporterDialog(getConfig(), this);
> - }
> - return importerDialog;
> - }
> -
> - /**
> - * {@inheritDoc}
> - */
> - public void onFailure(String error)
> - {
> - Window.alert(error);
> - importerDialog.hide();
> - }
> -
> - /**
> - * {@inheritDoc}
> - */
> - public void onSuccess(String result)
> - {
> - getTextArea().getCommandManager().execute(Command.INSERT_HTML, result);
> - importerDialog.hide();
> - }
> -}
>
> Deleted: platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImporterPluginFactory.java
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImporterPluginFactory.java 2009-10-09 10:17:25 UTC (rev 24334)
> +++ platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ImporterPluginFactory.java 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -1,63 +0,0 @@
> -/*
> - * See the NOTICE file distributed with this work for additional
> - * information regarding copyright ownership.
> - *
> - * This is free software; you can redistribute it and/or modify it
> - * under the terms of the GNU Lesser General Public License as
> - * published by the Free Software Foundation; either version 2.1 of
> - * the License, or (at your option) any later version.
> - *
> - * This software is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - * Lesser General Public License for more details.
> - *
> - * You should have received a copy of the GNU Lesser General Public
> - * License along with this software; if not, write to the Free
> - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> - * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> - */
> -package com.xpn.xwiki.wysiwyg.client.plugin.importer;
> -
> -import com.xpn.xwiki.wysiwyg.client.plugin.Plugin;
> -import com.xpn.xwiki.wysiwyg.client.plugin.internal.AbstractPluginFactory;
> -
> -/**
> - * {@link PluginFactory} class for the office importer wysiwyg plugin.
> - *
> - * @version $Id$
> - */
> -public final class ImporterPluginFactory extends AbstractPluginFactory
> -{
> - /**
> - * Private instance of the plugin factory. Plugin factory is a singleton.
> - */
> - private static ImporterPluginFactory instance;
> -
> - /**
> - * Private constructor.
> - */
> - private ImporterPluginFactory()
> - {
> - super("importer");
> - }
> -
> - /**
> - * @return The singleton instance of the plugin factory.
> - */
> - public static synchronized ImporterPluginFactory getInstance()
> - {
> - if (null == instance) {
> - instance = new ImporterPluginFactory();
> - }
> - return instance;
> - }
> -
> - /**
> - * {@inheritDoc}
> - */
> - public Plugin newInstance()
> - {
> - return new ImporterPlugin();
> - }
> -}
>
> Deleted: platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/AbstractImporter.java
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/AbstractImporter.java 2009-10-09 10:17:25 UTC (rev 24334)
> +++ platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/AbstractImporter.java 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -1,187 +0,0 @@
> -/*
> - * See the NOTICE file distributed with this work for additional
> - * information regarding copyright ownership.
> - *
> - * This is free software; you can redistribute it and/or modify it
> - * under the terms of the GNU Lesser General Public License as
> - * published by the Free Software Foundation; either version 2.1 of
> - * the License, or (at your option) any later version.
> - *
> - * This software is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - * Lesser General Public License for more details.
> - *
> - * You should have received a copy of the GNU Lesser General Public
> - * License along with this software; if not, write to the Free
> - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> - * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> - */
> -
> -package com.xpn.xwiki.wysiwyg.client.plugin.importer.ui;
> -
> -import java.util.HashMap;
> -import java.util.Map;
> -
> -import com.google.gwt.event.dom.client.ClickEvent;
> -import com.google.gwt.event.dom.client.ClickHandler;
> -import com.google.gwt.user.client.ui.Button;
> -import com.google.gwt.user.client.ui.CheckBox;
> -import com.google.gwt.user.client.ui.Composite;
> -import com.google.gwt.user.client.ui.FlowPanel;
> -import com.google.gwt.user.client.ui.Panel;
> -import com.xpn.xwiki.wysiwyg.client.WysiwygService;
> -import com.xpn.xwiki.wysiwyg.client.WysiwygServiceAsync;
> -import com.xpn.xwiki.wysiwyg.client.editor.Strings;
> -import com.xpn.xwiki.wysiwyg.client.plugin.importer.ImporterListener;
> -import com.xpn.xwiki.wysiwyg.client.util.Config;
> -
> -/**
> - * Base class for both file / clipboard importers.
> - *
> - * @version $Id$
> - * @since 2.0.1
> - */
> -public abstract class AbstractImporter extends Composite implements ClickHandler
> -{
> - /**
> - * CSS style name for indicating busy waiting.
> - */
> - protected static final String STYLE_LOADING = "loading";
> -
> - /**
> - * Wysiwyg configuration.
> - */
> - protected Config config;
> -
> - /**
> - * The importer listener.
> - */
> - protected ImporterListener importerListener;
> -
> - /**
> - * {@link WysiwygServiceAsync} used for invoking remote GWT RPC calls.
> - */
> - protected WysiwygServiceAsync wysiwygService;
> -
> - /**
> - * Base panel which sits on top of the composite.
> - */
> - private Panel basePanel;
> -
> - /**
> - * The content panel sitting on top of the base panel.
> - */
> - private Panel contentPanel;
> -
> - /**
> - * Filter Styles check box.
> - */
> - private CheckBox filterStylesCheckBox;
> -
> - /**
> - * Import button.
> - */
> - private Button importButton;
> -
> - /**
> - * Creates a new importer.
> - *
> - * @param wysiwygConfig wysiwyg configuration.
> - * @param importerListener import process listner.
> - */
> - public AbstractImporter(Config wysiwygConfig, ImporterListener importerListener)
> - {
> - this.config = wysiwygConfig;
> - this.importerListener = importerListener;
> - this.wysiwygService = WysiwygService.Singleton.getInstance();
> -
> - // Create the content panel.
> - this.contentPanel = createContentPanel();
> -
> - // Append the button panel.
> - contentPanel.add(createButtonPanel());
> -
> - // Finally add the content panel to base panel.
> - this.basePanel = new FlowPanel();
> - basePanel.add(contentPanel);
> - initWidget(basePanel);
> - }
> -
> - /**
> - * Creates the button panel.
> - *
> - * @return the button panel.
> - */
> - private Panel createButtonPanel()
> - {
> - Panel buttonPanel = new FlowPanel();
> - filterStylesCheckBox = new CheckBox(Strings.INSTANCE.importerFilterStylesCheckBoxCaption());
> - buttonPanel.add(filterStylesCheckBox);
> - importButton = new Button(Strings.INSTANCE.importerImportButtonCaption());
> - importButton.addStyleName("xImporterImportButton");
> - importButton.addClickHandler(this);
> - buttonPanel.add(importButton);
> - // Add a clear floats panel.
> - Panel fakeClearPanel = new FlowPanel();
> - fakeClearPanel.addStyleName("clearfloats");
> - buttonPanel.add(fakeClearPanel);
> - return buttonPanel;
> - }
> -
> - /**
> - * {@inheritDoc}
> - */
> - public void onClick(ClickEvent event)
> - {
> - if (event.getSource() == importButton) {
> - onImportButtonClick();
> - }
> - }
> -
> - /**
> - * Delegate method for creating content panel.
> - *
> - * @return content panel.
> - */
> - protected abstract Panel createContentPanel();
> -
> - /**
> - * Delegate method for handling the import operation.
> - */
> - protected abstract void onImportButtonClick();
> -
> - /**
> - * Prepares the cleaning parameters map.
> - *
> - * @return a {@link Map} with cleaning parameters for office importer.
> - */
> - protected Map<String, String> getHTMLCleaningParams()
> - {
> - Map<String, String> params = new HashMap<String, String>();
> - if (filterStylesCheckBox.getValue()) {
> - params.put("filterStyles", "strict");
> - }
> - // For Office2007: Office2007 generates an xhtml document (when copied) which has attributes and tags of
> - // several namespaces. But the document itself doesn't contain the namespace definitions, which causes
> - // the HTMLCleaner (the DomSerializer) to fail while performing it's operations. As a workaround we
> - // force HTMLCleaner to avoid parsing of namespace information.
> - params.put("namespacesAware", Boolean.toString(false));
> - return params;
> - }
> -
> - /**
> - * Sets / Unsets this importer UI to 'busy' mode.
> - *
> - * @param busy busy or not.
> - */
> - protected void setBusy(boolean busy)
> - {
> - contentPanel.setVisible(!busy);
> - if (busy) {
> - basePanel.addStyleName(STYLE_LOADING);
> - } else {
> - basePanel.removeStyleName(STYLE_LOADING);
> - }
> - }
> -}
>
> Deleted: platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ClipboardImporter.java
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ClipboardImporter.java 2009-10-09 10:17:25 UTC (rev 24334)
> +++ platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ClipboardImporter.java 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -1,195 +0,0 @@
> -/*
> - * See the NOTICE file distributed with this work for additional
> - * information regarding copyright ownership.
> - *
> - * This is free software; you can redistribute it and/or modify it
> - * under the terms of the GNU Lesser General Public License as
> - * published by the Free Software Foundation; either version 2.1 of
> - * the License, or (at your option) any later version.
> - *
> - * This software is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - * Lesser General Public License for more details.
> - *
> - * You should have received a copy of the GNU Lesser General Public
> - * License along with this software; if not, write to the Free
> - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> - * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> - */
> -package com.xpn.xwiki.wysiwyg.client.plugin.importer.ui;
> -
> -import com.google.gwt.event.dom.client.LoadEvent;
> -import com.google.gwt.event.dom.client.LoadHandler;
> -import com.google.gwt.user.client.DeferredCommand;
> -import com.google.gwt.user.client.rpc.AsyncCallback;
> -import com.google.gwt.user.client.ui.FlowPanel;
> -import com.google.gwt.user.client.ui.InlineLabel;
> -import com.google.gwt.user.client.ui.Label;
> -import com.google.gwt.user.client.ui.Panel;
> -import com.xpn.xwiki.wysiwyg.client.editor.Strings;
> -import com.xpn.xwiki.wysiwyg.client.plugin.importer.ImporterListener;
> -import com.xpn.xwiki.wysiwyg.client.util.Config;
> -import com.xpn.xwiki.wysiwyg.client.util.FocusCommand;
> -import com.xpn.xwiki.wysiwyg.client.util.Selectable;
> -import com.xpn.xwiki.wysiwyg.client.widget.rta.RichTextArea;
> -import com.xpn.xwiki.wysiwyg.client.widget.rta.SelectionPreserver;
> -
> -/**
> - * Office Importer for importing clipboard content.
> - *
> - * @version $Id$
> - */
> -public class ClipboardImporter extends AbstractImporter implements Selectable, LoadHandler, AsyncCallback<String>
> -{
> - /**
> - * The text area where the user can paste his content.
> - */
> - private RichTextArea textArea;
> -
> - /**
> - * Preserves the selection inside the {@link #textArea} while this tab is hidden.
> - */
> - private SelectionPreserver selectionPreserver;
> -
> - /**
> - * Flag indicating if this tab is selected.
> - */
> - private boolean selected;
> -
> - /**
> - * Flag indicating if the text area is loaded.
> - */
> - private boolean loaded;
> -
> - /**
> - * Default constructor.
> - *
> - * @param wysiwygConfig wysiwyg configuration.
> - * @param importerListener importer listener.
> - */
> - public ClipboardImporter(Config wysiwygConfig, ImporterListener importerListener)
> - {
> - super(wysiwygConfig, importerListener);
> - }
> -
> - /**
> - * {@inheritDoc}
> - */
> - protected Panel createContentPanel()
> - {
> - Panel contentPanel = new FlowPanel();
> -
> - // Info label.
> - Panel infoLabel = new FlowPanel();
> - infoLabel.setStyleName("xInfoLabel");
> - infoLabel.add(new InlineLabel(Strings.INSTANCE.importerClipboardTabInfoLabel()));
> - InlineLabel mandatoryLabel = new InlineLabel(Strings.INSTANCE.mandatory());
> - mandatoryLabel.addStyleName("xMandatory");
> - infoLabel.add(mandatoryLabel);
> - contentPanel.add(infoLabel);
> -
> - // Help label.
> - Label helpLabel = new Label(Strings.INSTANCE.importerClipboardTabHelpLabel());
> - helpLabel.setStyleName("xHelpLabel");
> - contentPanel.add(helpLabel);
> -
> - // Text area panel.
> - textArea = new RichTextArea();
> - textArea.addLoadHandler(this);
> - textArea.addStyleName("xImporterClipboardTabEditor");
> - selectionPreserver = new SelectionPreserver(textArea);
> - contentPanel.add(textArea);
> -
> - return contentPanel;
> - }
> -
> - /**
> - * {@inheritDoc}
> - */
> - protected void onImportButtonClick()
> - {
> - String htmlPaste = textArea.getHTML().trim();
> - if (!htmlPaste.equals("")) {
> - setBusy(true);
> - wysiwygService.cleanOfficeHTML(htmlPaste, "wysiwyg", getHTMLCleaningParams(), this);
> - }
> - }
> -
> - /**
> - * {@inheritDoc}
> - */
> - public void onFailure(Throwable thrown)
> - {
> - this.importerListener.onFailure(thrown.getMessage());
> - setBusy(false);
> - textArea.setHTML("");
> - }
> -
> - /**
> - * {@inheritDoc}
> - */
> - public void onSuccess(String result)
> - {
> - this.importerListener.onSuccess(result);
> - setBusy(false);
> - textArea.setHTML("");
> - }
> -
> - /**
> - * {@inheritDoc}
> - *
> - * @see LoadHandler#onLoad(LoadEvent)
> - */
> - public void onLoad(LoadEvent event)
> - {
> - if (event.getSource() == textArea) {
> - loaded = true;
> - maybeFocusTextArea();
> - }
> - }
> -
> - /**
> - * {@inheritDoc}
> - *
> - * @see Selectable#setSelected(boolean)
> - */
> - public void setSelected(boolean selected)
> - {
> - if (this.selected != selected) {
> - this.selected = selected;
> - if (selected) {
> - maybeFocusTextArea();
> - } else {
> - selectionPreserver.saveSelection();
> - }
> - }
> - }
> -
> - /**
> - * {@inheritDoc}
> - *
> - * @see Selectable#isSelected()
> - */
> - public boolean isSelected()
> - {
> - return selected;
> - }
> -
> - /**
> - * Focuses the text area if it is loaded and the tab is selected.
> - */
> - private void maybeFocusTextArea()
> - {
> - if (loaded&& selected) {
> - DeferredCommand.addCommand(new FocusCommand(textArea)
> - {
> - public void execute()
> - {
> - super.execute();
> - selectionPreserver.restoreSelection();
> - }
> - });
> - }
> - }
> -}
>
> Deleted: platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/FileImporter.java
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/FileImporter.java 2009-10-09 10:17:25 UTC (rev 24334)
> +++ platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/FileImporter.java 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -1,183 +0,0 @@
> -/*
> - * See the NOTICE file distributed with this work for additional
> - * information regarding copyright ownership.
> - *
> - * This is free software; you can redistribute it and/or modify it
> - * under the terms of the GNU Lesser General Public License as
> - * published by the Free Software Foundation; either version 2.1 of
> - * the License, or (at your option) any later version.
> - *
> - * This software is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - * Lesser General Public License for more details.
> - *
> - * You should have received a copy of the GNU Lesser General Public
> - * License along with this software; if not, write to the Free
> - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> - * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> - */
> -package com.xpn.xwiki.wysiwyg.client.plugin.importer.ui;
> -
> -import com.google.gwt.user.client.rpc.AsyncCallback;
> -import com.google.gwt.user.client.ui.FileUpload;
> -import com.google.gwt.user.client.ui.FlowPanel;
> -import com.google.gwt.user.client.ui.FormPanel;
> -import com.google.gwt.user.client.ui.InlineLabel;
> -import com.google.gwt.user.client.ui.Label;
> -import com.google.gwt.user.client.ui.Panel;
> -import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
> -import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler;
> -import com.xpn.xwiki.wysiwyg.client.editor.Strings;
> -import com.xpn.xwiki.wysiwyg.client.plugin.importer.ImporterListener;
> -import com.xpn.xwiki.wysiwyg.client.util.Config;
> -
> -/**
> - * Office Importer for importing office documents.
> - *
> - * @version $Id$
> - */
> -public class FileImporter extends AbstractImporter implements SubmitCompleteHandler, AsyncCallback<String>
> -{
> - /**
> - * Style identifier for help message labels.
> - */
> - private static final String HELP_LABEL_STYLE = "xHelpLabel";
> -
> - /**
> - * A {@link FormPanel} to hold the fileUpload widget.
> - */
> - private FormPanel formPanel;
> -
> - /**
> - * The {@link FileUpload} widget.
> - */
> - private FileUpload fileUpload;
> -
> - /**
> - * The name of the current wiki page.
> - */
> - private String fullPageName;
> -
> - /**
> - * A flag indicating if openoffice server is available or not.
> - */
> - private boolean isOpenOfficeServerConnected;
> -
> - /**
> - * Default constructor.
> - *
> - * @param config wysiwyg configuration.
> - * @param importerListener importer listener.
> - */
> - public FileImporter(Config config, ImporterListener importerListener)
> - {
> - super(config, importerListener);
> - }
> -
> - /**
> - * {@inheritDoc}
> - */
> - protected Panel createContentPanel()
> - {
> - // Read current wysiwyg configuration.
> - String currentSpace = config.getParameter("space", "Main");
> - String currentPage = config.getParameter("page", "WebHome");
> - this.fullPageName = currentSpace + "." + currentPage;
> - this.isOpenOfficeServerConnected = config.getParameter("openofficeServerConnected", "false").equals("true");
> - String uploadURL = "../../upload/" + currentSpace + "/" + currentPage;
> -
> - return isOpenOfficeServerConnected ? createMainUI(uploadURL) : createFeatureNotAvailableUI();
> - }
> -
> - /**
> - * {@inheritDoc}
> - */
> - protected void onImportButtonClick()
> - {
> - if (isOpenOfficeServerConnected) {
> - String fileName = fileUpload.getFilename().trim();
> - if (!fileName.equals("")) {
> - setBusy(true);
> - formPanel.submit();
> - }
> - }
> - }
> -
> - /**
> - * Creates a panel that displays a message indicating that this feature is not available.
> - *
> - * @return feature not available message panel.
> - */
> - private Panel createFeatureNotAvailableUI()
> - {
> - Panel container = new FlowPanel();
> - Label featureNotAvailableLabel = new Label(Strings.INSTANCE.importerFileTabNotAvailableLabel());
> - featureNotAvailableLabel.setStyleName(HELP_LABEL_STYLE);
> - container.add(featureNotAvailableLabel);
> - return container;
> - }
> -
> - /**
> - * Creates the main UI panel.
> - *
> - * @param uploadURL file upload url.
> - * @return main ui panel.
> - */
> - private Panel createMainUI(String uploadURL)
> - {
> - Panel contentPanel = new FlowPanel();
> - // Info label.
> - Panel infoLabel = new FlowPanel();
> - infoLabel.setStyleName("xInfoLabel");
> - infoLabel.add(new InlineLabel(Strings.INSTANCE.importerFileTabInfoLabel()));
> - InlineLabel mandatoryLabel = new InlineLabel(Strings.INSTANCE.mandatory());
> - mandatoryLabel.addStyleName("xMandatory");
> - infoLabel.add(mandatoryLabel);
> - contentPanel.add(infoLabel);
> -
> - // Help label.
> - Label helpLabel = new Label(Strings.INSTANCE.importerFileTabHelpLabel());
> - helpLabel.setStyleName(HELP_LABEL_STYLE);
> - contentPanel.add(helpLabel);
> -
> - // Form panel.
> - formPanel = new FormPanel();
> - formPanel.setAction(uploadURL);
> - formPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
> - formPanel.setMethod(FormPanel.METHOD_POST);
> - fileUpload = new FileUpload();
> - fileUpload.setName("filepath");
> - formPanel.add(fileUpload);
> - formPanel.addSubmitCompleteHandler(this);
> - contentPanel.add(formPanel);
> -
> - return contentPanel;
> - }
> -
> - /**
> - * {@inheritDoc}
> - */
> - public void onSubmitComplete(SubmitCompleteEvent event)
> - {
> - wysiwygService.officeToXHTML(fullPageName, getHTMLCleaningParams(), this);
> - }
> -
> - /**
> - * {@inheritDoc}
> - */
> - public void onFailure(Throwable thrown)
> - {
> - this.importerListener.onFailure(thrown.getMessage());
> - setBusy(false);
> - }
> -
> - /**
> - * {@inheritDoc}
> - */
> - public void onSuccess(String result)
> - {
> - this.importerListener.onSuccess(result);
> - setBusy(false);
> - }
> -}
>
> Added: platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ImportOfficeFileWizardStep.java
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ImportOfficeFileWizardStep.java (rev 0)
> +++ platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ImportOfficeFileWizardStep.java 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -0,0 +1,192 @@
> +/*
> + * See the NOTICE file distributed with this work for additional
> + * information regarding copyright ownership.
> + *
> + * This is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as
> + * published by the Free Software Foundation; either version 2.1 of
> + * the License, or (at your option) any later version.
> + *
> + * This software is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this software; if not, write to the Free
> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> + */
> +package com.xpn.xwiki.wysiwyg.client.plugin.importer.ui;
> +
> +import java.util.EnumSet;
> +import java.util.HashMap;
> +import java.util.Map;
> +
> +import com.google.gwt.user.client.rpc.AsyncCallback;
> +import com.xpn.xwiki.wysiwyg.client.WysiwygService;
> +import com.xpn.xwiki.wysiwyg.client.editor.Strings;
> +import com.xpn.xwiki.wysiwyg.client.util.Attachment;
> +import com.xpn.xwiki.wysiwyg.client.util.Config;
> +import com.xpn.xwiki.wysiwyg.client.widget.wizard.NavigationListener.NavigationDirection;
> +import com.xpn.xwiki.wysiwyg.client.widget.wizard.util.AbstractFileUploadWizardStep;
> +
> +/**
> + * Wizard step responsible for importing the content of an office document into the wysiwyg editor.
> + *
> + * @version $Id$
> + * @since 2.0.1
> + */
> +public class ImportOfficeFileWizardStep extends AbstractFileUploadWizardStep
> +{
> + /**
> + * Wysiwyg configuration object.
> + */
> + private Config config;
> +
> + /**
> + * Result of the import operation.
> + */
> + private Object result;
> +
> + /**
> + * Instantiates the office document import wizard step.
> + *
> + * @param config wysiwyg configuration.
> + */
> + public ImportOfficeFileWizardStep(Config config)
> + {
> + this.config = config;
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public String getPage()
> + {
> + return config.getParameter("page", "WebHome");
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public String getSpace()
> + {
> + return config.getParameter("space", "Main");
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public String getWiki()
> + {
> + return config.getParameter("wiki", "xwiki");
> + }
Actually I don't see a good reason for which I made these functions public. We
should make them protected.
> +
> + /**
> + * {@inheritDoc}
> + */
> + protected String getFileHelpLabel()
> + {
> + return Strings.INSTANCE.importOfficeFileHelpLabel();
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + protected void onAttachmentUploaded(Attachment attach, final AsyncCallback<Boolean> async)
> + {
> +
> + String fullPageName = getSpace() + "." + getPage();
you should use the ResourceName class to build wiki names, since it's the client
wiki reference serializer/deserializer.
> + WysiwygService.Singleton.getInstance().officeToXHTML(fullPageName, getHTMLCleaningParams(),
> + new AsyncCallback<String>()
> + {
> + public void onSuccess(String result)
> + {
> + setResult(result);
> +
> + // Resume the wizard step submit operation.
> + async.onSuccess(true);
> + }
> +
> + public void onFailure(Throwable thrown)
> + {
> + setResult(null);
> +
> + // Display the error and avoid submit operation from continuing.
> + displayError(thrown.getMessage());
> + async.onSuccess(false);
As a convention, we used the onFailure to signal an error on the server or in
the server-client communication (like a GWT failure in the RPC call), while the
submit async.onSuccess(false) is an "application error", a way in which a wizard
step prevents the submit to be done because, for example, the user didn't insert
valid data in the wizard form and another chance is being given to him.
Now, which are the cases in which the importer service fails (throws exception)?
is it correct to do this conversion here (from a server error / exception to a
"validation" error)? or you should rather call async.onFailure()? this only
depends on the logic of the service function failure.
> + }
> + });
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public Object getResult()
> + {
> + return this.result;
> + }
> +
> + /**
> + * Sets the result of this wizard step.
> + *
> + * @param result the result.
> + */
> + private void setResult(Object result)
> + {
> + this.result = result;
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public String getNextStep()
> + {
> + return null;
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public String getDirectionName(NavigationDirection direction)
> + {
> + if (direction == NavigationDirection.FINISH) {
> + return Strings.INSTANCE.importWizardImportButtonCaption();
> + }
> + return null;
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public String getStepTitle()
> + {
> + return Strings.INSTANCE.importOfficeFileWizardStepTitle();
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public EnumSet<NavigationDirection> getValidDirections()
> + {
> + return EnumSet.of(NavigationDirection.FINISH);
We also return CANCEL here, even if a button for it is not displayed and it's
always possible (through the dialog's close button), but in case we will ever
want to display a button, or want to prevent the cancel in certain steps.
> + }
> +
> + /**
> + * Prepares the cleaning parameters map.
> + *
> + * @return a {@link Map} with cleaning parameters for office importer.
> + */
> + protected Map<String, String> getHTMLCleaningParams()
> + {
> + Map<String, String> params = new HashMap<String, String>();
> + params.put("filterStyles", "strict");
> + // For Office2007: Office2007 generates an xhtml document (when copied) which has attributes and tags of
> + // several namespaces. But the document itself doesn't contain the namespace definitions, which causes
> + // the HTMLCleaner (the DomSerializer) to fail while performing it's operations. As a workaround we
> + // force HTMLCleaner to avoid parsing of namespace information.
> + params.put("namespacesAware", Boolean.toString(false));
> + return params;
> + }
> +}
>
> Added: platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ImportOfficePasteWizardStep.java
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ImportOfficePasteWizardStep.java (rev 0)
> +++ platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ImportOfficePasteWizardStep.java 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -0,0 +1,209 @@
> +/*
> + * See the NOTICE file distributed with this work for additional
> + * information regarding copyright ownership.
> + *
> + * This is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as
> + * published by the Free Software Foundation; either version 2.1 of
> + * the License, or (at your option) any later version.
> + *
> + * This software is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this software; if not, write to the Free
> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> + */
> +package com.xpn.xwiki.wysiwyg.client.plugin.importer.ui;
> +
> +import java.util.EnumSet;
> +import java.util.HashMap;
> +import java.util.Map;
> +
> +import com.google.gwt.user.client.rpc.AsyncCallback;
> +import com.google.gwt.user.client.ui.FlowPanel;
> +import com.google.gwt.user.client.ui.InlineLabel;
> +import com.google.gwt.user.client.ui.Label;
> +import com.google.gwt.user.client.ui.Panel;
> +import com.google.gwt.user.client.ui.Widget;
> +import com.xpn.xwiki.wysiwyg.client.WysiwygService;
> +import com.xpn.xwiki.wysiwyg.client.editor.Strings;
> +import com.xpn.xwiki.wysiwyg.client.widget.rta.RichTextArea;
> +import com.xpn.xwiki.wysiwyg.client.widget.wizard.WizardStep;
> +import com.xpn.xwiki.wysiwyg.client.widget.wizard.NavigationListener.NavigationDirection;
> +
> +/**
> + * Wizard step responsible for importing copy-pasted office content.
> + *
> + * @version $Id$
> + * @since 2.0.1
> + */
> +public class ImportOfficePasteWizardStep implements WizardStep
> +{
> + /**
> + * Main UI of this wizard.
> + */
> + private Panel mainPanel;
> +
> + /**
> + * The text area where the user can paste his content.
> + */
> + private RichTextArea textArea;
> +
> + /**
> + * Storage for the result of the import operation.
> + */
> + private Object result;
> +
> + /**
> + * Creates an instance of {@link ImportOfficePasteWizardStep}.
> + */
> + public ImportOfficePasteWizardStep()
> + {
> + mainPanel = new FlowPanel();
> +
> + // Info label.
> + Panel infoLabel = new FlowPanel();
> + infoLabel.setStyleName("xInfoLabel");
> + infoLabel.add(new InlineLabel(Strings.INSTANCE.importOfficePasteInfoLabel()));
> + InlineLabel mandatoryLabel = new InlineLabel(Strings.INSTANCE.mandatory());
> + mandatoryLabel.addStyleName("xMandatory");
> + infoLabel.add(mandatoryLabel);
> + mainPanel.add(infoLabel);
> +
> + // Help label.
> + Label helpLabel = new Label(Strings.INSTANCE.importOfficePasteHelpLabel());
> + helpLabel.setStyleName("xHelpLabel");
> + mainPanel.add(helpLabel);
> +
> + // Text area panel.
> + textArea = new RichTextArea();
> + textArea.addStyleName("xImportOfficeContentEditor");
> + mainPanel.add(textArea);
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public Widget display()
> + {
> + return this.mainPanel;
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public void init(Object data, AsyncCallback< ?> cb)
> + {
> + textArea.setHTML("");
> + textArea.setFocus(true);
I seriously doubt this works, you should a FocusCommand(), look at its comment
for reasons.
> + cb.onSuccess(null);
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public EnumSet<NavigationDirection> getValidDirections()
> + {
> + return EnumSet.of(NavigationDirection.FINISH);
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public String getDirectionName(NavigationDirection direction)
> + {
> + if (direction == NavigationDirection.FINISH) {
> + return Strings.INSTANCE.importWizardImportButtonCaption();
> + }
> + return null;
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public String getNextStep()
> + {
> + return null;
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public Object getResult()
> + {
> + return this.result;
> + }
> +
> + /**
> + * Sets the result of this wizard step.
> + *
> + * @param result the result.
> + */
> + private void setResult(Object result)
> + {
> + this.result = result;
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public String getStepTitle()
> + {
> + return Strings.INSTANCE.importOfficePasteWizardStepTitle();
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public void onCancel()
> + {
> + textArea.setHTML("");
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public void onSubmit(final AsyncCallback<Boolean> async)
> + {
> + String officeHTML = textArea.getHTML();
> + if (officeHTML.trim().equals("")) {
> + async.onSuccess(false);
> + } else {
> + WysiwygService.Singleton.getInstance().cleanOfficeHTML(officeHTML, "wysiwyg", getHTMLCleaningParams(),
> + new AsyncCallback<String>()
> + {
> + public void onSuccess(String result)
> + {
> + setResult(result);
> + async.onSuccess(true);
> + }
> +
> + public void onFailure(Throwable thrown)
> + {
> + async.onFailure(thrown);
> + }
> + });
> + }
> + }
> +
> + /**
> + * Prepares the cleaning parameters map.
> + *
> + * @return a {@link Map} with cleaning parameters for office importer.
> + */
> + protected Map<String, String> getHTMLCleaningParams()
> + {
> + Map<String, String> params = new HashMap<String, String>();
> + params.put("filterStyles", "strict");
> + // For Office2007: Office2007 generates an xhtml document (when copied) which has attributes and tags of
> + // several namespaces. But the document itself doesn't contain the namespace definitions, which causes
> + // the HTMLCleaner (the DomSerializer) to fail while performing it's operations. As a workaround we
> + // force HTMLCleaner to avoid parsing of namespace information.
> + params.put("namespacesAware", Boolean.toString(false));
> + return params;
> + }
Is this the same function as in the other class?
> +}
>
> Added: platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ImportWizard.java
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ImportWizard.java (rev 0)
> +++ platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ImportWizard.java 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -0,0 +1,128 @@
> +/*
> + * See the NOTICE file distributed with this work for additional
> + * information regarding copyright ownership.
> + *
> + * This is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as
> + * published by the Free Software Foundation; either version 2.1 of
> + * the License, or (at your option) any later version.
> + *
> + * This software is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this software; if not, write to the Free
> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> + */
> +
> +package com.xpn.xwiki.wysiwyg.client.plugin.importer.ui;
> +
> +import java.util.HashMap;
> +import java.util.Map;
> +
> +import com.xpn.xwiki.wysiwyg.client.editor.Images;
> +import com.xpn.xwiki.wysiwyg.client.editor.Strings;
> +import com.xpn.xwiki.wysiwyg.client.util.Config;
> +import com.xpn.xwiki.wysiwyg.client.widget.wizard.Wizard;
> +import com.xpn.xwiki.wysiwyg.client.widget.wizard.WizardStep;
> +import com.xpn.xwiki.wysiwyg.client.widget.wizard.WizardStepProvider;
> +
> +/**
> + * Import wizard responsible for performing various content import operation into wysiwyg editor.
> + *
> + * @version $Id$
> + * @since 2.0.1
> + */
> +public class ImportWizard extends Wizard implements WizardStepProvider
> +{
> + /**
> + * Enumeration of steps comprising the import wizard.
> + *
> + * @version $Id$
> + * @since 2.0.1
> + */
> + public static enum ImportWizardStep
> + {
> + /**
> + * Office file import wizard step.
> + */
> + OFFICE_FILE,
> +
> + /**
> + * Office paste import wizard step.
> + */
> + OFFICE_PASTE
> + };
> +
> + /**
> + * Map with the instantiated steps to return. Will be lazily initialized upon request.
> + */
> + private Map<ImportWizardStep, WizardStep> stepsMap = new HashMap<ImportWizardStep, WizardStep>();
> +
> + /**
> + * The wysiwyg configuration.
> + */
> + private Config config;
> +
> + /**
> + * Instantiates the import wizard.
> + *
> + * @param config wysiwyg configuration.
> + */
> + public ImportWizard(Config config)
> + {
> + super(Strings.INSTANCE.importWizardTitle(), Images.INSTANCE.importWizardIcon().createImage());
> + this.config = config;
> + this.setProvider(this);
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public WizardStep getStep(String name)
> + {
> + ImportWizardStep requestedStep = parseStepName(name);
> + WizardStep step = stepsMap.get(requestedStep);
> + if (null == step) {
> + switch (requestedStep) {
> + case OFFICE_FILE:
> + step = new ImportOfficeFileWizardStep(this.config);
> + break;
> + case OFFICE_PASTE:
> + step = new ImportOfficePasteWizardStep();
> + break;
> + default:
> + // nothing here, leave it null
> + break;
> + }
> + // if something has been created, add it in the map
> + if (step != null) {
> + stepsMap.put(requestedStep, step);
> + }
> + }
> + // return the found or newly created step
> + return step;
> + }
> +
> + /**
> + * Parses the specified step name in a {@link ImportWizardStep} value.
> + *
> + * @param name the name of the step to parse
> + * @return the {@link ImportWizardStep} {@code enum} value corresponding to the passed name, or {@code null} if no
> + * such value exists.
> + */
> + private ImportWizardStep parseStepName(String name)
> + {
> + // let's be careful about this
> + ImportWizardStep requestedStep = null;
> + try {
> + requestedStep = ImportWizardStep.valueOf(name);
> + } catch (IllegalArgumentException e) {
> + // nothing, just leave it null if it cannot be found in the enum
> + }
> + return requestedStep;
Maybe we could create a super class for this, it's the same everywhere.
> + }
> +}
>
> Deleted: platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ImporterDialog.java
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ImporterDialog.java 2009-10-09 10:17:25 UTC (rev 24334)
> +++ platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/importer/ui/ImporterDialog.java 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -1,92 +0,0 @@
> -/*
> - * See the NOTICE file distributed with this work for additional
> - * information regarding copyright ownership.
> - *
> - * This is free software; you can redistribute it and/or modify it
> - * under the terms of the GNU Lesser General Public License as
> - * published by the Free Software Foundation; either version 2.1 of
> - * the License, or (at your option) any later version.
> - *
> - * This software is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - * Lesser General Public License for more details.
> - *
> - * You should have received a copy of the GNU Lesser General Public
> - * License along with this software; if not, write to the Free
> - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> - * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> - */
> -package com.xpn.xwiki.wysiwyg.client.plugin.importer.ui;
> -
> -import com.google.gwt.user.client.ui.FlowPanel;
> -import com.google.gwt.user.client.ui.TabPanel;
> -import com.xpn.xwiki.wysiwyg.client.editor.Images;
> -import com.xpn.xwiki.wysiwyg.client.editor.Strings;
> -import com.xpn.xwiki.wysiwyg.client.plugin.importer.ImporterListener;
> -import com.xpn.xwiki.wysiwyg.client.util.Config;
> -import com.xpn.xwiki.wysiwyg.client.util.TabPanelSelector;
> -import com.xpn.xwiki.wysiwyg.client.widget.ComplexDialogBox;
> -
> -/**
> - * Office Importer wysiwyg dialog box.
> - *
> - * @version $Id$
> - */
> -public class ImporterDialog extends ComplexDialogBox
> -{
> - /**
> - * Container panel.
> - */
> - private FlowPanel mainPanel;
> -
> - /**
> - * Tab panel.
> - */
> - private TabPanel tabPanel;
> -
> - /**
> - * File import tab.
> - */
> - private FileImporter fileImporter;
> -
> - /**
> - * Clipboard (copy-paste) import tab.
> - */
> - private ClipboardImporter clipboardImporter;
> -
> - /**
> - * Default constructor.
> - *
> - * @param wysiwygConfig the wysiwyg configuration object.
> - * @param importerListener the import process listener.
> - */
> - public ImporterDialog(Config wysiwygConfig, ImporterListener importerListener)
> - {
> - // Dialog box.
> - super(false, true);
> - getDialog().setIcon(Images.INSTANCE.importer().createImage());
> - getDialog().setCaption(Strings.INSTANCE.importerCaption());
> - addStyleName("xImporterDialog");
> - getHeader().clear();
> -
> - // Main container panel.
> - mainPanel = new FlowPanel();
> - mainPanel.addStyleName("xImporterPanel");
> -
> - // Tab panel.
> - tabPanel = new TabPanel();
> - TabPanelSelector tabPanelSelector = new TabPanelSelector();
> - tabPanel.addBeforeSelectionHandler(tabPanelSelector);
> - tabPanel.addSelectionHandler(tabPanelSelector);
> - clipboardImporter = new ClipboardImporter(wysiwygConfig, importerListener);
> - tabPanel.add(clipboardImporter, Strings.INSTANCE.importerClipboardTabCaption());
> - fileImporter = new FileImporter(wysiwygConfig, importerListener);
> - tabPanel.add(fileImporter, Strings.INSTANCE.importerFileTabCaption());
> - tabPanel.selectTab(0);
> - tabPanel.addStyleName("xImporterTabPanel");
> - mainPanel.add(tabPanel);
> -
> - getBody().add(mainPanel);
> - }
> -}
>
> Modified: platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/link/ui/AttachmentUploadWizardStep.java
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/link/ui/AttachmentUploadWizardStep.java 2009-10-09 10:17:25 UTC (rev 24334)
> +++ platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/plugin/link/ui/AttachmentUploadWizardStep.java 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -132,7 +132,7 @@
> * {@inheritDoc}
> */
> @Override
> - protected void onAttachmentUploaded(Attachment attach)
> + protected void onAttachmentUploaded(Attachment attach, AsyncCallback<Boolean> async)
> {
> // commit the attachment data in the link config
> // commit relative reference
> @@ -140,5 +140,6 @@
> // FIXME: move the reference setting logic in a controller
> linkData.setReference("attach:" + ref.getRelativeTo(editedResource).toString());
> linkData.setUrl(attach.getDownloadUrl());
> + async.onSuccess(true);
> }
> }
>
> Modified: platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/widget/wizard/util/AbstractFileUploadWizardStep.java
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/widget/wizard/util/AbstractFileUploadWizardStep.java 2009-10-09 10:17:25 UTC (rev 24334)
> +++ platform/web/trunk/wysiwyg/src/main/java/com/xpn/xwiki/wysiwyg/client/widget/wizard/util/AbstractFileUploadWizardStep.java 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -260,8 +260,7 @@
> displayError(Strings.INSTANCE.fileUploadSubmitError());
> async.onSuccess(false);
> } else {
> - onAttachmentUploaded(result);
> - async.onSuccess(true);
> + onAttachmentUploaded(result, async);
> }
> }
>
> @@ -276,8 +275,11 @@
> * Notifies the successful completion of a file upload, to be overridden by subclasses to provide specific behavior.
> *
> * @param attach the successfully uploaded attachment
> + * @param async the call-back used to indicate the completion of this method. It's required that the sub-classes
> + * invoke async.onSuccess(true); method once they are done with processing the attachment. Without this
> + * method being invoked, the submission of this wizard step will not complete.
> */
> - protected abstract void onAttachmentUploaded(Attachment attach);
> + protected abstract void onAttachmentUploaded(Attachment attach, AsyncCallback<Boolean> async);
>
> /**
> * @return the wiki of the document to upload this file to, or null if the default wiki should be used.
>
> Modified: platform/web/trunk/wysiwyg/src/main/resources/com/xpn/xwiki/wysiwyg/client/editor/Strings.properties
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/resources/com/xpn/xwiki/wysiwyg/client/editor/Strings.properties 2009-10-09 10:17:25 UTC (rev 24334)
> +++ platform/web/trunk/wysiwyg/src/main/resources/com/xpn/xwiki/wysiwyg/client/editor/Strings.properties 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -180,19 +180,20 @@
> macroCategoryUsed=Previously Inserted Macros
> macroNoMacroSelected=Please select a macro from the list below.
>
> -importerToolTip=Import Office Content
> -importerCaption=Office Importer
> -importerClipboardTabCaption=Clipboard
> -importerClipboardTabInfoLabel=Content
> -importerClipboardTabHelpLabel=Paste the content copied from the office document in the area below.
> -importerFileTabCaption=File
> -importerFileTabInfoLabel=File path
> -importerFileTabHelpLabel=Choose the office document to import. The file will be uploaded and attached to the current wiki document and its content imported in this wiki document.
> -importerFileTabNotAvailableLabel=This feature requires an active OpenOffice server which we could not locate, please contact your system administrator to resolve this issue.
> -importerFilterStylesCheckBoxCaption=Filter styles
> -importerImportButtonCaption=Import
> -importerCancelButtonCaption=Cancel
> +importMenuEntryCaption=Import
> +importWizardTitle=Import External Content
> +importWizardImportButtonCaption=Import
>
> +importOfficeFileMenuItemCaption=Office Document
> +importOfficeFileFeatureNotAvailable=This feature requires an active openoffice server which we could not locate, please contact your administrator to resolve this issue.
> +importOfficeFileWizardStepTitle=Import Office Document
> +importOfficeFileHelpLabel=Choose the office document to import. The file will be uploaded and attached to the current wiki document and its content imported in this wiki document.
> +
> +importOfficePasteMenuItemCaption=Office Content (Copy / Paste)
> +importOfficePasteWizardStepTitle=Import Office Content (Copy / Paste)
> +importOfficePasteInfoLabel=Content
> +importOfficePasteHelpLabel=Paste the content copied from the office document in the area below and click import.
> +
> wizardCancel=Cancel
> wizardPrevious=Previous
> wizardNext=Next
>
> Added: platform/web/trunk/wysiwyg/src/main/resources/com/xpn/xwiki/wysiwyg/client/editor/import.gif
> ===================================================================
> (Binary files differ)
>
>
> Property changes on: platform/web/trunk/wysiwyg/src/main/resources/com/xpn/xwiki/wysiwyg/client/editor/import.gif
> ___________________________________________________________________
> Name: svn:mime-type
> + application/octet-stream
>
> Added: platform/web/trunk/wysiwyg/src/main/resources/com/xpn/xwiki/wysiwyg/client/editor/import_office_file.gif
> ===================================================================
> (Binary files differ)
>
>
> Property changes on: platform/web/trunk/wysiwyg/src/main/resources/com/xpn/xwiki/wysiwyg/client/editor/import_office_file.gif
> ___________________________________________________________________
> Name: svn:mime-type
> + application/octet-stream
>
> Added: platform/web/trunk/wysiwyg/src/main/resources/com/xpn/xwiki/wysiwyg/client/editor/import_office_paste.gif
> ===================================================================
> (Binary files differ)
>
>
> Property changes on: platform/web/trunk/wysiwyg/src/main/resources/com/xpn/xwiki/wysiwyg/client/editor/import_office_paste.gif
> ___________________________________________________________________
> Name: svn:mime-type
> + application/octet-stream
>
> Deleted: platform/web/trunk/wysiwyg/src/main/resources/com/xpn/xwiki/wysiwyg/client/editor/importer.gif
> ===================================================================
> (Binary files differ)
>
> Modified: platform/web/trunk/wysiwyg/src/main/resources/com/xpn/xwiki/wysiwyg/public/stylesheets/importer.css
> ===================================================================
> --- platform/web/trunk/wysiwyg/src/main/resources/com/xpn/xwiki/wysiwyg/public/stylesheets/importer.css 2009-10-09 10:17:25 UTC (rev 24334)
> +++ platform/web/trunk/wysiwyg/src/main/resources/com/xpn/xwiki/wysiwyg/public/stylesheets/importer.css 2009-10-09 11:32:44 UTC (rev 24335)
> @@ -1,21 +1,5 @@
> -.xImporterPanel {
> - width: 100%;
> - height: 100%;
> - /* hidden overflow since the IE browsers detect badly the size of some tables */
> - overflow: hidden;
> -}
> -
> -.xImporterTabPanel {
> - width: 459px;
> - height: auto;
> -}
> -
> -.xImporterClipboardTabEditor {
> - height: 240px;
> -}
> -
> -.xImporterDialog .xDialogFooter .gwt-CheckBox {
> - float: left;
> - padding-top: 0;
> - margin-bottom: 0;
> +.xImportOfficeContentEditor {
> + width: 450px;
> + height: 250px;
> + border: 1px solid;
> }
> \ No newline at end of file
Also,
svn propset svn:keywords "Author Id Revision HeadURL" <new-file-path>
for all new added files.
check
http://dev.xwiki.org/xwiki/bin/view/Community/DevelopmentPractices#HSubvers…
for how to configure this for your svn client. Note that, even if correctly
configured, the settings will not be considered by the eclipse plugin (I didn't
manage to make them work), you'll have to do a command-line svn add for that to
work right.
Happy coding,
Anca
>
> _______________________________________________
> notifications mailing list
> notifications(a)xwiki.org
> http://lists.xwiki.org/mailman/listinfo/notifications
1
0