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