r1083 - in trunk: . src/main/java src/main/java/org/ourproject/kune/app/client src/main/java/org/ourproject/kune/blogs/client src/main/java/org/ourproject/kune/docs/client src/main/java/org/ourproject/kune/platf src/main/java/org/ourproject/kune/platf/client/actions/toolbar src/main/java/org/ourproject/kune/platf/client/services src/main/java/org/ourproject/kune/platf/client/ui/dialogs src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed src/main/java/org/ourproject/kune/platf/cli
Author: vjrj Date: 2009-03-23 20:21:30 +0100 (Mon, 23 Mar 2009) New Revision: 1083 Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/AbstractRichTextAreaTest.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkExecutableUtils.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstractPanel.java trunk/src/main/java/org/ourproject/kune/workspace/client/search/AbstractLiveSearcherField.java Removed: trunk/src/main/java/com/ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/AbstractRichTextAreaTest.java Modified: trunk/COPYRIGHT trunk/TODO trunk/TODO_done trunk/pom.xml trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientActions.java trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java trunk/src/main/java/org/ourproject/kune/platf/Kune-Platform.gwt.xml trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbar.java trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPresenter.java trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarView.java trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/DefaultForm.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialog.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogPanel.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogPresenter.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogView.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RichTextArea.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/editor/EditHtmlEditorPresenter.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/preview/EditHtmlPreviewPresenter.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPresenter.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialog.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPanel.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPresenter.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogView.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfo.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfoTest.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstract.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstractPresenter.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstractView.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailPanel.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailPresenter.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailView.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtPanel.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtPresenter.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtView.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertspecialchar/asian/InsertSpecialAsianCharPanel.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertspecialchar/occidental/InsertSpecialOccCharPanel.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertspecialchar/utf8/InsertSpecialUTF8CharPanel.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocalimg/InsertImageLocalPresenter.java trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocalPanel.java trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocalPresenter.java trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptions.java trunk/src/main/java/org/ourproject/kune/workspace/client/options/license/EntityOptionsDefLicensePresenter.java trunk/src/main/java/org/ourproject/kune/workspace/client/options/logo/EntityOptionsLogoPresenter.java trunk/src/main/java/org/ourproject/kune/workspace/client/options/pscape/EntityOptionsPublicSpaceConfPresenter.java trunk/src/main/java/org/ourproject/kune/workspace/client/options/tools/EntityOptionsToolsConfPresenter.java trunk/src/main/java/org/ourproject/kune/workspace/client/search/AbstractLiveSearcherPanel.java Log: Incomplete - task RTE Create link improved Modified: trunk/COPYRIGHT =================================================================== --- trunk/COPYRIGHT 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/COPYRIGHT 2009-03-23 19:21:30 UTC (rev 1083) @@ -109,7 +109,7 @@ Copyright: under GNU Lesser General Public License http://www.gnu.org/licenses/lgpl.html -dom region and diff libraries: +dom region library: XWiki Platform http://www.xwiki.org/ Copyright: under GNU Lesser General Public License Modified: trunk/TODO =================================================================== --- trunk/TODO 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/TODO 2009-03-23 19:21:30 UTC (rev 1083) @@ -22,7 +22,6 @@ <a href="http://example.com">s^amp^le</a> --- Parse and edit <a href="http://example.com">s^a<em>kk</em>mp^le</a> --- Parse, get contains and edit ^some text <a href="http://example.com">samp^le</a> --- new link with get inner content? -**** with different menus (File/Blog ...) **** bidi support **** images (local/remote) with preview **** youtube videos/podcasts @@ -113,6 +112,12 @@ ** vjrj <v> IconHyperlink.java and IconLabel.java to gwt1.5 * MID-TERM +** vjrj <v> shortcuts enhacement +*** Clarify the keycodes vs utf8 chars Shortcut definition (Function keys and so on...) +*** shortcuts in tool actions no registered in GlobalShorcuts +*** Links: + http://www.quirksmode.org/js/keys.html + http://www.cambiaresearch.com/c4/702b8cd1-e5b0-42e6-83ac-25f0306e3e25/Javasc... ** TODO <s> tag UI refactorization Think about wikipedia suggestions: http://www.mediawiki.org/wiki/API @@ -424,6 +429,8 @@ http://creativecommons.org/license/zero/ ** TODO <v> Revise use the HP and VP in gwt code http://groups.google.com/group/Google-Web-Toolkit/browse_frm/thread/5d01cd80... +** TODO <v> captcha in anonymous comments/edits + http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/99c25... * LONG-TERM ** <s> integrate some blog/wiki converter: http://code.google.com/p/google-blog-converters-appengine/ Modified: trunk/TODO_done =================================================================== --- trunk/TODO_done 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/TODO_done 2009-03-23 19:21:30 UTC (rev 1083) @@ -39,7 +39,17 @@ http://extjs.com/deploy/ext/examples/locale/dutch-form.js http://groups.google.com/group/gwt-ext/browse_thread/thread/ebec316effea2b80... http://extjs.com/forum/showthread.php?t=20160&highlight=localization +* FIXED with different menus (File/Blog ...) +* FIXED with different menus (File/Blog ...) + :PROPERTIES: + :ARCHIVE_TIME: 2009-03-20 vie 09:12 + :ARCHIVE_FILE: ~/proyectos/dev/kune/trunk/TODO + :ARCHIVE_OLPATH: SHORT-TERM (URGENT)/<v> better RTE/Pending + :ARCHIVE_CATEGORY: TODO + :END: + + Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/pom.xml 2009-03-23 19:21:30 UTC (rev 1083) @@ -94,13 +94,11 @@ <artifactId>jmagick</artifactId> <version>6.2.6-0</version> </dependency> - <!-- <dependency> - <groupId>com.xpn.xwiki.platform</groupId> - <artifactId>xwiki-web-gwt</artifactId> + <groupId>org.xwiki.platform</groupId> + <artifactId>xwiki-web-gwt-dom</artifactId> <version>1.9-SNAPSHOT</version> </dependency> - --> <!-- xmpp --> <dependency> Modified: trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -48,7 +48,8 @@ Log.setUncaughtExceptionHandler(); GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() { public void onUncaughtException(Throwable e) { - Log.error(e.toString()); + String message = e.getMessage(); + Log.error("Caught: " + e.toString() + " " + (message != null ? message : ""), e); } }); Modified: trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientActions.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientActions.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientActions.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -79,7 +79,7 @@ Position.ctx, TYPE_BLOG); createContentRenameAction(parentMenuTitle, i18n.t("Rename"), contents); - createEditAction(TYPE_POST); + createEditAction(parentMenuTitle, TYPE_POST); createContentModeratedActions(parentMenuTitle, contentsModerated); createRenameContentInCtxAction(parentMenuTitleCtx, i18n.t("Rename"), containersNoRoot); Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -80,7 +80,7 @@ Position.ctx, TYPE_ROOT, TYPE_FOLDER); createContentRenameAction(parentMenuTitle, i18n.t("Rename"), contents); - createEditAction(TYPE_DOCUMENT); + createEditAction(parentMenuTitle, TYPE_DOCUMENT); createContentModeratedActions(parentMenuTitle, contentsModerated); createRenameContentInCtxAction(parentMenuTitleCtx, i18n.t("Rename"), containersNoRoot); Modified: trunk/src/main/java/org/ourproject/kune/platf/Kune-Platform.gwt.xml =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/Kune-Platform.gwt.xml 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/Kune-Platform.gwt.xml 2009-03-23 19:21:30 UTC (rev 1083) @@ -8,7 +8,7 @@ <inherits name="com.google.gwt.libideas.ImmutableResources" /> <inherits name="com.google.gwt.libideas.StyleInjector" /> - <inherits name="com.xpn.xwiki.wysiwyg.Wysiwyg" /> + <inherits name="org.xwiki.gwt.dom.DOM" /> <public path="public" /> Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbar.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbar.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbar.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -21,7 +21,6 @@ import org.ourproject.kune.platf.client.actions.ActionDescriptor; import org.ourproject.kune.platf.client.actions.ActionItemCollection; -import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor; import org.ourproject.kune.platf.client.actions.ActionToolbarPosition; public interface ActionToolbar<T> { @@ -52,7 +51,7 @@ void setNormalStyle(); - void setParentMenuTitle(ActionToolbarMenuDescriptor<T> action, String origTitle, String origTooltip, String newTitle); + void setParentMenuTitle(ActionToolbarPosition position, String origTitle, String origTooltip, String newTitle); void setPushButtonPressed(ActionDescriptor<T> action, boolean pressed); Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -167,12 +167,11 @@ toolbar.setNormalStyle(); } - public void setParentMenuTitle(ActionToolbarMenuDescriptor<T> action, String origTitle, String origTooltip, - String newTitle) { - final String menuKey = genMenuKey(action.getActionPosition(), origTitle, origTooltip, null, null); - Menu menu = menus.get(menuKey); - if (menu != null) { - menu.setTitle(newTitle); + public void setParentMenuTitle(ActionToolbarPosition position, String origTitle, String origTooltip, String newTitle) { + final String menuKey = genMenuKey(position, origTitle, origTooltip, null, null); + ToolbarButton button = buttons.get(menuKey); + if (button != null) { + button.setText(newTitle); } else { Log.error("Tryng to rename a non existent menu"); } @@ -310,6 +309,7 @@ toolbarMenu.setTooltip(menuTooltip); } menus.put(menuKey, menu); + buttons.put(menuKey, toolbarMenu); add(toolbarMenu); return menu; } @@ -343,7 +343,7 @@ private String genMenuKey(final ActionToolbarPosition pos, final String menuTitle, final String menuTooltip, final String menuSubTitle, final String actionText) { - final String basePart = "km-atp-menu-" + pos.toString().substring(0, 2) + "-" + menuTitle + "-" + menuTooltip; + final String basePart = "km-atp-menu-" + pos + "-" + menuTitle + "-" + menuTooltip; final String subMenuPart = menuSubTitle != null ? "-subm-" + menuSubTitle : ""; final String itemPart = actionText != null ? "-item-" + actionText : ""; return basePart + subMenuPart + itemPart; Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPresenter.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPresenter.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -110,9 +110,8 @@ view.setNormalStyle(); } - public void setParentMenuTitle(ActionToolbarMenuDescriptor<T> action, String origTitle, String origTooltip, - String newTitle) { - view.setParentMenuTitle(action, origTitle, origTooltip, newTitle); + public void setParentMenuTitle(ActionToolbarPosition position, String origTitle, String origTooltip, String newTitle) { + view.setParentMenuTitle(position, origTitle, origTooltip, newTitle); } public void setPushButtonPressed(ActionDescriptor<T> action, boolean pressed) { Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarView.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarView.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarView.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -22,7 +22,7 @@ import org.ourproject.kune.platf.client.View; import org.ourproject.kune.platf.client.actions.ActionDescriptor; import org.ourproject.kune.platf.client.actions.ActionItem; -import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor; +import org.ourproject.kune.platf.client.actions.ActionToolbarPosition; public interface ActionToolbarView<T> extends View { @@ -49,7 +49,7 @@ void setNormalStyle(); - void setParentMenuTitle(ActionToolbarMenuDescriptor<T> action, String origTitle, String origTooltip, String newTitle); + void setParentMenuTitle(ActionToolbarPosition position, String origTitle, String origTooltip, String newTitle); void setPushButtonPressed(ActionDescriptor<T> action, boolean pressed); Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -301,6 +301,27 @@ } }); + register(InsertLinkGroup.class, new Factory<InsertLinkExt>(InsertLinkExt.class) { + @Override + public InsertLinkExt create() { + final InsertLinkExtPresenter presenter = new InsertLinkExtPresenter($(InsertLinkDialog.class)); + final InsertLinkExtView panel = new InsertLinkExtPanel(presenter, $(I18nTranslationService.class)); + presenter.init(panel); + return presenter; + } + }); + + register(InsertLinkGroup.class, new Factory<InsertLinkEmail>(InsertLinkEmail.class) {; + + @Override + public InsertLinkEmail create() { + final InsertLinkEmailPresenter presenter = new InsertLinkEmailPresenter($(InsertLinkDialog.class)); + final InsertLinkEmailPanel panel = new InsertLinkEmailPanel(presenter, $(I18nTranslationService.class)); + presenter.init(panel); + return presenter; + } + }); + register(NoDecoration.class, new Factory<RTEditor>(RTEditor.class) { @Override public RTEditor create() { @@ -413,26 +434,6 @@ } }); - register(InsertLinkGroup.class, new Factory<InsertLinkExt>(InsertLinkExt.class) { - @Override - public InsertLinkExt create() { - final InsertLinkExtPresenter presenter = new InsertLinkExtPresenter($(InsertLinkDialog.class)); - final InsertLinkExtView panel = new InsertLinkExtPanel(presenter, $(I18nTranslationService.class)); - presenter.init(panel); - return presenter; - } - }); - - register(InsertLinkGroup.class, new Factory<InsertLinkEmail>(InsertLinkEmail.class) { - @Override - public InsertLinkEmail create() { - final InsertLinkEmailPresenter presenter = new InsertLinkEmailPresenter($(InsertLinkDialog.class)); - final InsertLinkEmailPanel panel = new InsertLinkEmailPanel(presenter, $(I18nTranslationService.class)); - presenter.init(panel); - return presenter; - } - }); - register(Singleton.class, new Factory<InsertTableDialog>(InsertTableDialog.class) { @Override public InsertTableDialog create() { Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/DefaultForm.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/DefaultForm.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/DefaultForm.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -21,11 +21,13 @@ import com.gwtext.client.core.Position; import com.gwtext.client.widgets.Button; +import com.gwtext.client.widgets.Component; import com.gwtext.client.widgets.PaddedPanel; import com.gwtext.client.widgets.form.Field; import com.gwtext.client.widgets.form.FieldSet; import com.gwtext.client.widgets.form.FormPanel; import com.gwtext.client.widgets.form.Label; +import com.gwtext.client.widgets.form.event.FormPanelListener; public class DefaultForm { @@ -81,6 +83,10 @@ form.addButton(button); } + public void addListener(FormPanelListener listener) { + form.addListener(listener); + } + public void addStyleName(final String cls) { form.addStyleName(cls); } @@ -93,6 +99,10 @@ return form; } + public void insert(int index, Component component) { + form.insert(index, component); + } + public boolean isValid() { return form.getForm().isValid(); } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialog.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialog.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialog.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -28,8 +28,10 @@ public void setErrorMessage(String message, Level level); - void addOptionTab(View view); + void addTab(View view); + void insertTab(int index, View view); + void show(); } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogPanel.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogPanel.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -83,14 +83,8 @@ } } - public void addOptionTab(View view) { - if (view instanceof Panel) { - addTab((Panel) view); - } else if (view instanceof DefaultForm) { - addTab(((DefaultForm) view).getFormPanel()); - } else { - Log.error("Programatic error: Unexpected element added to GroupOptions"); - } + public void addTab(View view) { + addTabPanel(castPanel(view)); doLayoutIfNeeded(); } @@ -117,6 +111,11 @@ } } + public void insertTab(int index, View view) { + insertTabPanel(index, castPanel(view)); + doLayoutIfNeeded(); + } + public boolean isVisible() { createDialogIfNecessary(); return dialog.isVisible(); @@ -163,11 +162,24 @@ }); } - private void addTab(Panel newTab) { + private void addTabPanel(Panel newTab) { createDialogIfNecessary(); tabPanel.add(newTab); } + private Panel castPanel(View view) { + Panel panel; + if (view instanceof Panel) { + panel = (Panel) view; + } else if (view instanceof DefaultForm) { + panel = ((DefaultForm) view).getFormPanel(); + } else { + panel = null; + Log.error("Programatic error: Unexpected element added to GroupOptions"); + } + return panel; + } + private void createDialog() { dialog = new BasicDialog(dialogId, title, modal, true, width, height, minWidth, minHeight); dialog.setCollapsible(false); @@ -192,4 +204,9 @@ createDialog(); } } + + private void insertTabPanel(int index, Panel newTab) { + createDialogIfNecessary(); + tabPanel.insert(index, newTab); + } } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogPresenter.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogPresenter.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -26,8 +26,8 @@ private AbstractTabbedDialogView view; - public void addOptionTab(View tab) { - view.addOptionTab(tab); + public void addTab(View tab) { + view.addTab(tab); } public View getView() { @@ -46,6 +46,10 @@ this.view = view; } + public void insertTab(int index, View tab) { + view.insertTab(index, tab); + } + public void setErrorMessage(String message, Level level) { view.setErrorMessage(message, level); } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogView.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogView.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogView.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -24,7 +24,7 @@ public interface AbstractTabbedDialogView extends View { - void addOptionTab(View tab); + void addTab(View tab); void createAndShow(); @@ -32,6 +32,8 @@ void hideMessages(); + void insertTab(int index, View tab); + void setErrorMessage(final String message, final Level level); } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RichTextArea.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RichTextArea.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RichTextArea.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -16,6 +16,7 @@ package org.ourproject.kune.platf.client.ui.rte; import org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl; +import org.xwiki.gwt.dom.client.Document; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.IFrameElement; @@ -26,7 +27,6 @@ import com.google.gwt.user.client.ui.MouseListener; import com.google.gwt.user.client.ui.MouseListenerCollection; import com.google.gwt.user.client.ui.SourcesMouseEvents; -import com.xpn.xwiki.wysiwyg.client.dom.Document; /** * A rich text editor that allows complex styling and formatting. Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -20,16 +20,19 @@ import org.ourproject.kune.platf.client.shortcuts.GlobalShortcutRegister; import org.ourproject.kune.platf.client.shortcuts.ShortcutDescriptor; import org.ourproject.kune.platf.client.shortcuts.ShortcutRegister; +import org.ourproject.kune.platf.client.ui.noti.NotifyUser; import org.ourproject.kune.platf.client.ui.rte.RichTextArea; +import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkExecutableUtils; +import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkInfo; +import org.xwiki.gwt.dom.client.DocumentFragment; +import org.xwiki.gwt.dom.client.Range; +import org.xwiki.gwt.dom.client.Selection; import com.google.gwt.dom.client.Element; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.FocusListener; import com.google.gwt.user.client.ui.Widget; -import com.xpn.xwiki.wysiwyg.client.dom.DocumentFragment; -import com.xpn.xwiki.wysiwyg.client.dom.Range; -import com.xpn.xwiki.wysiwyg.client.dom.Selection; public class RTEditorPanel extends RichTextArea implements RTEditorView { @@ -108,9 +111,39 @@ setFocus(true); } + public LinkInfo getLinkInfoIfHref() { + LinkInfo linkinfo = null; + org.xwiki.gwt.dom.client.Element selectedAnchor = LinkExecutableUtils.getSelectedAnchor(this); + if (selectedAnchor != null) { + Range range = getDocument().createRange(); + range.selectNode(selectedAnchor); + getSelection().addRange(range); + linkinfo = LinkInfo.parse(selectedAnchor); + } else { + linkinfo = new LinkInfo(getSelectionText()); + } + return linkinfo; + } + + public void getRangeInfo() { + // Selection selection = getSelection(); + // String info = "range count: " + selection.getRangeCount() + + // "<br/>focus offset: " + selection.getFocusOffset() + // + "<br/>anchor offset:" + selection.getAnchorOffset() + + // "<br/>range 0 as html: " + // + selection.getRangeAt(0).toHTML(); + // NotifyUser.info(info); + String info = "range count: " + getFstRange().getCommonAncestorContainer().getFirstChild().getNodeName(); + NotifyUser.info(info); + } + + public String getSelectionText() { + return getFstRange().cloneContents().getInnerText(); + } + public void insertBlockquote() { DocumentFragment extracted = getFstRange().cloneContents(); - delete(); + // delete(); insertHtml("<blockquote>" + extracted.getInnerHTML() + "</blockquote>"); focus(); } @@ -162,6 +195,10 @@ return basic.isBold(); } + public boolean isCollapsed() { + return getFstRange().isCollapsed(); + } + public boolean isItalic() { return basic.isItalic(); } @@ -346,5 +383,4 @@ private void updateStatus() { presenter.updateStatus(); } - } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -24,14 +24,15 @@ import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources; import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialog; import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialog; +import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkInfo; import org.ourproject.kune.platf.client.ui.rte.insertspecialchar.InsertSpecialCharDialog; import org.ourproject.kune.platf.client.ui.rte.inserttable.InsertTableDialog; import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper; +import com.allen_sauer.gwt.log.client.Log; import com.calclab.suco.client.events.Event0; import com.calclab.suco.client.events.Listener; import com.calclab.suco.client.events.Listener0; -import com.calclab.suco.client.events.Listener2; import com.calclab.suco.client.ioc.Provider; import com.google.gwt.libideas.resources.client.ImageResource; @@ -71,7 +72,7 @@ private final Provider<InsertImageDialog> insertImageDialog; private final Provider<InsertTableDialog> insertTableDialog; private Listener<String> insertTableListener; - private Listener2<String, String> insertLinkListener; + private Listener<LinkInfo> insertLinkListener; private Listener<String> updateHtmlListener; private ActionToolbarButtonDescriptor<Object> insertTableBtn; private final Provider<InsertSpecialCharDialog> insertSpecialCharDialog; @@ -592,13 +593,17 @@ deferred.addCommand(new Listener0() { public void onEvent() { if (insertLinkListener == null) { - insertLinkListener = new Listener2<String, String>() { - public void onEvent(String name, String url) { - view.createLink(url); + insertLinkListener = new Listener<LinkInfo>() { + public void onEvent(LinkInfo linkInfo) { + String link = linkInfo.toString(); + Log.debug("Link: " + link); + view.focus(); + view.insertHtml(link); fireOnEdit(); } }; } + insertElement.setLinkInfo(view.getLinkInfoIfHref()); insertElement.setOnCreateLink(insertLinkListener); insertElement.show(); } @@ -742,17 +747,7 @@ public void onEvent() { deferred.addCommand(new Listener0() { public void onEvent() { - // Selection selection = - // view.getDocument().getSelection(); - // String info = "range count: " + - // selection.getRangeCount() + - // "<br/>focus offset: " - // + selection.getFocusOffset() + - // "<br/>anchor offset:" - // + selection.getAnchorOffset() + - // "<br/>range 0 as html: " - // + selection.getRangeAt(0).toHTML(); - // NotifyUser.info(info); + view.getRangeInfo(); } }); } @@ -799,7 +794,7 @@ actions.add(withNoItem(hr)); actions.add(withNoItem(undoBtn)); actions.add(withNoItem(redoBtn)); - // actions.add(withNoItem(devInfo)); + actions.add(withNoItem(devInfo)); for (String fontName : this.fontNames) { ActionToolbarMenuDescriptor<Object> fontNameAction = createFontNameAction(canBeBasic, fontName); Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -3,6 +3,7 @@ import org.ourproject.kune.platf.client.View; import org.ourproject.kune.platf.client.actions.ActionItemCollection; import org.ourproject.kune.platf.client.ui.rte.RichTextArea.FontSize; +import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkInfo; public interface RTEditorView extends View { @@ -26,6 +27,12 @@ String getHTML(); + LinkInfo getLinkInfoIfHref(); + + void getRangeInfo(); + + String getSelectionText(); + String getText(); void insertBlockquote(); Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/editor/EditHtmlEditorPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/editor/EditHtmlEditorPresenter.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/editor/EditHtmlEditorPresenter.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -24,7 +24,7 @@ public void init(EditHtmlEditorView view) { this.view = view; - editHtml.addOptionTab(view); + editHtml.addTab(view); } public void setHtml(String html) { Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/preview/EditHtmlPreviewPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/preview/EditHtmlPreviewPresenter.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/preview/EditHtmlPreviewPresenter.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -22,6 +22,6 @@ public void init(EditHtmlPreviewView view) { this.view = view; - editHtml.addOptionTab(view); + editHtml.addTab(view); } } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPresenter.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPresenter.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -11,7 +11,7 @@ } public void init(InsertImageExtView view) { - insertImageDialog.addOptionTab(view); + insertImageDialog.addTab(view); } public void onInsert() { Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/AbstractRichTextAreaTest.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/AbstractRichTextAreaTest.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/AbstractRichTextAreaTest.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -1,161 +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 org.ourproject.kune.platf.client.ui.rte.insertlink; - -import org.ourproject.kune.platf.client.ui.rte.RichTextArea; - -import com.google.gwt.user.client.Timer; -import com.google.gwt.user.client.ui.LoadListener; -import com.google.gwt.user.client.ui.RootPanel; -import com.google.gwt.user.client.ui.SourcesLoadEvents; -import com.google.gwt.user.client.ui.Widget; -import com.xpn.xwiki.wysiwyg.client.dom.Element; -import com.xpn.xwiki.wysiwyg.client.dom.Range; -import com.xpn.xwiki.wysiwyg.client.dom.Selection; - -/** - * Base class for tests running on a rich text area. - * - * @version $Id$ - */ -public class AbstractRichTextAreaTest extends AbstractWysiwygClientTest implements LoadListener { - /** - * The number of milliseconds we delay the test finish. This delay is needed - * because in some browsers the rich text area is initialized after a - * timeout. - */ - public static final int FINISH_DELAY = 400; - - /** - * The number of milliseconds we delay the test start. This delay is needed - * because in some browsers the rich text area is initialized after a - * timeout and we want to start the test after the rich text area is fully - * initialized. - */ - public static final int START_DELAY = 300; - - /** - * The rich text area on which we run the tests. - */ - protected RichTextArea rta; - - /** - * {@inheritDoc} - * - * @see LoadListener#onError(Widget) - */ - public void onError(Widget sender) { - // ignore - } - - /** - * {@inheritDoc} - * - * @see LoadListener#onLoad(Widget) - */ - public void onLoad(Widget sender) { - // http://wiki.codetalks.org/wiki/index.php/Docs/Keyboard_navigable_JS_widgets - // #Use_setTimeout_with_element.focus.28.29_to_set_focus - (new Timer() { - @Override - public void run() { - rta.setFocus(true); - } - }).schedule(1); - } - - /** - * Cleans the HTML input. This is needed in order to have uniform tests - * between Firefox and Internet Explorer. - * - * @param html - * The HTML fragment to be cleaned. - * @return The input string in lower case, stripped of new lines. - */ - protected String clean(String html) { - return html.replaceAll("\r\n", "").toLowerCase(); - } - - /** - * @return The body element of the DOM document edited with the rich text - * area. - */ - protected Element getBody() { - return rta.getDocument().getBody().cast(); - } - - /** - * {@inheritDoc} - * - * @see AbstractWysiwygClientTest#gwtSetUp() - */ - @Override - protected void gwtSetUp() throws Exception { - super.gwtSetUp(); - - if (rta == null) { - rta = new RichTextArea(); - // Workaround till GWT provides a way to detect when the rich text - // area has finished loading. - if (rta.getBasicFormatter() != null && rta.getBasicFormatter() instanceof SourcesLoadEvents) { - ((SourcesLoadEvents) rta.getBasicFormatter()).addLoadListener(this); - } - } - RootPanel.get().add(rta); - } - - /** - * {@inheritDoc} - * - * @see AbstractWysiwygClientTest#gwtTearDown() - */ - @Override - protected void gwtTearDown() throws Exception { - super.gwtTearDown(); - - RootPanel.get().remove(rta); - } - - /** - * Removes the non-breaking spaces, {@code }, from the given HTML. The - * is method is needed because the Selection implementation for Internet - * Explorer adds {@code } when it cannot place the caret at the - * specified place. - * - * @param html - * the HTML fragment to be cleaned of non-breaking spaces - * @return the input HTML fragment without any non-breaking spaces - */ - protected String removeNonBreakingSpaces(String html) { - return html.replace(" ", ""); - } - - /** - * Selects the given range. - * - * @param range - * The range to be selected. - */ - protected void select(Range range) { - Selection selection = rta.getDocument().getSelection(); - selection.removeAllRanges(); - selection.addRange(range); - } -} Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/AbstractRichTextAreaTest.java (from rev 1078, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/AbstractRichTextAreaTest.java) =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/AbstractRichTextAreaTest.java 2009-03-16 04:13:36 UTC (rev 1078) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/AbstractRichTextAreaTest.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -0,0 +1,161 @@ +/* + * 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 org.ourproject.kune.platf.client.ui.rte.insertlink; + +import org.ourproject.kune.platf.client.ui.rte.RichTextArea; +import org.xwiki.gwt.dom.client.Element; +import org.xwiki.gwt.dom.client.Range; +import org.xwiki.gwt.dom.client.Selection; + +import com.google.gwt.user.client.Timer; +import com.google.gwt.user.client.ui.LoadListener; +import com.google.gwt.user.client.ui.RootPanel; +import com.google.gwt.user.client.ui.SourcesLoadEvents; +import com.google.gwt.user.client.ui.Widget; + +/** + * Base class for tests running on a rich text area. + * + * @version $Id$ + */ +public class AbstractRichTextAreaTest extends AbstractWysiwygClientTest implements LoadListener { + /** + * The number of milliseconds we delay the test finish. This delay is needed + * because in some browsers the rich text area is initialized after a + * timeout. + */ + public static final int FINISH_DELAY = 400; + + /** + * The number of milliseconds we delay the test start. This delay is needed + * because in some browsers the rich text area is initialized after a + * timeout and we want to start the test after the rich text area is fully + * initialized. + */ + public static final int START_DELAY = 300; + + /** + * The rich text area on which we run the tests. + */ + protected RichTextArea rta; + + /** + * {@inheritDoc} + * + * @see LoadListener#onError(Widget) + */ + public void onError(Widget sender) { + // ignore + } + + /** + * {@inheritDoc} + * + * @see LoadListener#onLoad(Widget) + */ + public void onLoad(Widget sender) { + // http://wiki.codetalks.org/wiki/index.php/Docs/Keyboard_navigable_JS_widgets + // #Use_setTimeout_with_element.focus.28.29_to_set_focus + (new Timer() { + @Override + public void run() { + rta.setFocus(true); + } + }).schedule(1); + } + + /** + * Cleans the HTML input. This is needed in order to have uniform tests + * between Firefox and Internet Explorer. + * + * @param html + * The HTML fragment to be cleaned. + * @return The input string in lower case, stripped of new lines. + */ + protected String clean(String html) { + return html.replaceAll("\r\n", "").toLowerCase(); + } + + /** + * @return The body element of the DOM document edited with the rich text + * area. + */ + protected Element getBody() { + return rta.getDocument().getBody().cast(); + } + + /** + * {@inheritDoc} + * + * @see AbstractWysiwygClientTest#gwtSetUp() + */ + @Override + protected void gwtSetUp() throws Exception { + super.gwtSetUp(); + + if (rta == null) { + rta = new RichTextArea(); + // Workaround till GWT provides a way to detect when the rich text + // area has finished loading. + if (rta.getBasicFormatter() != null && rta.getBasicFormatter() instanceof SourcesLoadEvents) { + ((SourcesLoadEvents) rta.getBasicFormatter()).addLoadListener(this); + } + } + RootPanel.get().add(rta); + } + + /** + * {@inheritDoc} + * + * @see AbstractWysiwygClientTest#gwtTearDown() + */ + @Override + protected void gwtTearDown() throws Exception { + super.gwtTearDown(); + + RootPanel.get().remove(rta); + } + + /** + * Removes the non-breaking spaces, {@code }, from the given HTML. The + * is method is needed because the Selection implementation for Internet + * Explorer adds {@code } when it cannot place the caret at the + * specified place. + * + * @param html + * the HTML fragment to be cleaned of non-breaking spaces + * @return the input HTML fragment without any non-breaking spaces + */ + protected String removeNonBreakingSpaces(String html) { + return html.replace(" ", ""); + } + + /** + * Selects the given range. + * + * @param range + * The range to be selected. + */ + protected void select(Range range) { + Selection selection = rta.getDocument().getSelection(); + selection.removeAllRanges(); + selection.addRange(range); + } +} Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialog.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialog.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialog.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -21,12 +21,23 @@ import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialog; -import com.calclab.suco.client.events.Listener2; +import com.calclab.suco.client.events.Listener; +import com.calclab.suco.client.events.Listener0; public interface InsertLinkDialog extends AbstractTabbedDialog { - void fireOnCreateLink(String name, String link); + void fireOnInsertLink(LinkInfo linkInfo); - void setOnCreateLink(Listener2<String, String> listener); + LinkInfo getLinkInfo(); + void setLinkInfo(LinkInfo linkInfo); + + void setLinkText(String text); + + void setLinkTitle(String title); + + void setOnCreateLink(Listener<LinkInfo> listener); + + void setOnInsertLinkPressed(Listener0 onInsertLinkPressed); + } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPanel.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPanel.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -24,16 +24,19 @@ import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialogPanel; import com.calclab.suco.client.events.Listener0; +import com.gwtext.client.core.EventObject; +import com.gwtext.client.widgets.Button; +import com.gwtext.client.widgets.event.ButtonListenerAdapter; public class InsertLinkDialogPanel extends AbstractTabbedDialogPanel implements InsertLinkDialogView { public static final String TEXT_EDT_INSERT_DIALOG = "k-ted-iep-dialog"; public static final String TEXT_EDT_INSERT_DIALOG_ERROR_ID = "k-ted-iep-dialog-err"; private final InsertLinkGroup textEditorInsertElementGroup; - public InsertLinkDialogPanel(final InsertLinkDialogPresenter presenter, Images images, - I18nTranslationService i18n, final InsertLinkGroup textEditorInsertElementGroup) { + public InsertLinkDialogPanel(final InsertLinkDialogPresenter presenter, Images images, I18nTranslationService i18n, + final InsertLinkGroup textEditorInsertElementGroup) { super(TEXT_EDT_INSERT_DIALOG, i18n.tWithNT("Insert a link", - "Option in a text editor to insert links and other elements"), 380, HEIGHT + 90, 380, HEIGHT + 90, + "Option in a text editor to insert links and other elements"), 380, HEIGHT + 100, 380, HEIGHT + 100, true, images, TEXT_EDT_INSERT_DIALOG_ERROR_ID); super.setIconCls("k-link-icon"); this.textEditorInsertElementGroup = textEditorInsertElementGroup; @@ -42,6 +45,25 @@ textEditorInsertElementGroup.resetAll(); } }); + + Button insert = new Button(i18n.t("Insert")); + insert.addListener(new ButtonListenerAdapter() { + @Override + public void onClick(Button button, EventObject e) { + presenter.onInsert(); + } + }); + + Button cancel = new Button(i18n.t("Cancel")); + cancel.addListener(new ButtonListenerAdapter() { + @Override + public void onClick(Button button, EventObject e) { + presenter.onCancel(); + } + }); + addButton(insert); + addButton(cancel); + } @Override Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPresenter.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPresenter.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -21,27 +21,53 @@ import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialogPresenter; -import com.calclab.suco.client.events.Listener2; +import com.calclab.suco.client.events.Listener; +import com.calclab.suco.client.events.Listener0; public class InsertLinkDialogPresenter extends AbstractTabbedDialogPresenter implements InsertLinkDialog { - private Listener2<String, String> onCreateListener; + private Listener<LinkInfo> onCreateListener; + private LinkInfo linkInfo; + private Listener0 onInsertLinkPressed; public InsertLinkDialogPresenter() { } - public void fireOnCreateLink(String name, String link) { - onCreateListener.onEvent(name, link); + public void fireOnInsertLink(LinkInfo linkInfo) { + onCreateListener.onEvent(linkInfo); super.hide(); } - public void fireOnInsertHtml(String name, String link) { - onCreateListener.onEvent(name, link); + public LinkInfo getLinkInfo() { + return linkInfo; + } + + public void onCancel() { super.hide(); } - public void setOnCreateLink(final Listener2<String, String> listener) { + public void setLinkInfo(LinkInfo linkInfo) { + this.linkInfo = linkInfo; + } + + public void setLinkText(String text) { + linkInfo.setText(text); + } + + public void setLinkTitle(String title) { + linkInfo.setTitle(title); + } + + public void setOnCreateLink(final Listener<LinkInfo> listener) { this.onCreateListener = listener; } + public void setOnInsertLinkPressed(Listener0 onInsertLinkPressed) { + this.onInsertLinkPressed = onInsertLinkPressed; + } + + protected void onInsert() { + onInsertLinkPressed.onEvent(); + } + } \ No newline at end of file Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogView.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogView.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogView.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -23,5 +23,7 @@ import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialogView; public interface InsertLinkDialogView extends AbstractTabbedDialogView, View { - int HEIGHT = 225; + + int HEIGHT = 320; + } Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkExecutableUtils.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkExecutableUtils.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkExecutableUtils.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -0,0 +1,106 @@ +/* + * 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 org.ourproject.kune.platf.client.ui.rte.insertlink; + +import org.ourproject.kune.platf.client.ui.rte.RichTextArea; +import org.xwiki.gwt.dom.client.DOMUtils; +import org.xwiki.gwt.dom.client.Element; +import org.xwiki.gwt.dom.client.Range; + +import com.google.gwt.dom.client.Node; + +/** + * Utility class to perform functions associated to link executables, such as + * detecting the selected anchor. We have this as static function in a distinct + * class since there is no way to insert this on both the + * {@link CreateLinkExecutable} and {@link UnlinkExecutable} hierarchies. + * + * @version $Id$ + */ +public class LinkExecutableUtils { + /** + * The tag name of the anchor element. + */ + public static final String ANCHOR_TAG_NAME = "a"; + + /** + * Returns the currently selected anchor element in the passed + * {@link RichTextArea}, as the user perceives the selection. The algorithm + * used is as follows: + * <ul> + * <li>find anchor ancestor of the first leaf of the selection. If the first + * leaf is the selection start container and the offset is at the end, then + * eliminate this first leaf and analyze the second</li> + * <li>find anchor ancestor of the last leaf of the selection. If the last + * leaf is the end container and the selection starts at its very beginning, + * skip this and analyze the previous leaf</li> + * <li>is the two ancestor anchors are not null and are the same, this + * anchor is the selected anchor</li> + * </ul> + * + * @param rta + * the rich text area whose selection to test + * @return the anchor in which the current selection is found + */ + public static Element getSelectedAnchor(RichTextArea rta) { + // there is no wrapping anchor if there is no selection + if (rta.getDocument().getSelection().getRangeCount() == 0) { + return null; + } + // Find the selected anchor by the following algorithm: + Range range = rta.getDocument().getSelection().getRangeAt(0); + // if the selection is collapsed, we have our answer already + if (range.isCollapsed()) { + return (Element) DOMUtils.getInstance().getFirstAncestor(range.getStartContainer(), ANCHOR_TAG_NAME); + } + Element foundAncestorStart = null; + Element foundAncestorEnd = null; + // get the first leaf of the selection and check it out + Node firstLeaf = DOMUtils.getInstance().getFirstLeaf(range); + if (firstLeaf == range.getStartContainer() + && range.getStartOffset() == DOMUtils.getInstance().getLength(firstLeaf)) { + firstLeaf = DOMUtils.getInstance().getNextLeaf(firstLeaf); + } + foundAncestorStart = (Element) DOMUtils.getInstance().getFirstAncestor(firstLeaf, ANCHOR_TAG_NAME); + // if no anchor found for start, it's pointless to keep looking, won't + // find anything + if (foundAncestorStart == null) { + return null; + } + // check the other end + Node lastLeaf = DOMUtils.getInstance().getLastLeaf(range); + if (lastLeaf == range.getEndContainer() && range.getEndOffset() == 0) { + lastLeaf = DOMUtils.getInstance().getPreviousLeaf(lastLeaf); + } + foundAncestorEnd = (Element) DOMUtils.getInstance().getFirstAncestor(lastLeaf, ANCHOR_TAG_NAME); + + if (foundAncestorStart == foundAncestorEnd && foundAncestorStart != null) { + return foundAncestorStart; + } + + return null; + } + + /** + * Protected constructor. + */ + protected LinkExecutableUtils() { + } +} Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfo.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfo.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfo.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -1,9 +1,9 @@ package org.ourproject.kune.platf.client.ui.rte.insertlink; import com.google.gwt.dom.client.Element; +import com.google.gwt.user.client.DOM; public class LinkInfo { - private static final String HREF = "href"; // private static final String TITLE = "title"; private static final String TARGET = "target"; @@ -15,19 +15,57 @@ && target.equals(_BLANK)); } + public static LinkInfo parse(org.xwiki.gwt.dom.client.Element element) { + String target = element.getAttribute(TARGET); + return new LinkInfo(element.getInnerText(), element.getTitle(), element.getAttribute(HREF), target != null + && target.equals(_BLANK)); + } + private String text; private String title; - private String url; + private String href; + private String target; - private boolean inNewWindow; + public LinkInfo(String text) { + this(text, null, "", false); + } - public LinkInfo(String text, String title, String url, boolean inNewWindow) { + public LinkInfo(String text, String href) { this.text = text; + this.href = href; + } + + public LinkInfo(String text, String title, String href, boolean inNewWindow) { + this.text = text; + this.href = href; this.title = title; - this.url = url; - this.inNewWindow = inNewWindow; + if (inNewWindow) { + this.setTarget(_BLANK); + } } + public Element getElement() { + Element anchor = DOM.createAnchor(); + com.google.gwt.user.client.Element element = (com.google.gwt.user.client.Element) anchor; + DOM.setElementProperty(element, "href", href); + if (getTarget() != null) { + DOM.setElementProperty(element, TARGET, getTarget()); + } + if (title != null) { + DOM.setElementAttribute(element, "title", title); + } + DOM.setInnerText(element, text); + return anchor; + } + + public String getHref() { + return href; + } + + public String getTarget() { + return target; + } + public String getText() { return text; } @@ -36,16 +74,20 @@ return title; } - public String getUrl() { - return url; + public boolean inSameWindow() { + if (target != null) { + return target.equals(_BLANK); + } else { + return false; + } } - public boolean isInNewWindow() { - return inNewWindow; + public void setHref(String href) { + this.href = href; } - public void setInNewWindow(boolean inNewWindow) { - this.inNewWindow = inNewWindow; + public void setTarget(String target) { + this.target = target; } public void setText(String text) { @@ -56,8 +98,10 @@ this.title = title; } - public void setUrl(String url) { - this.url = url; + @Override + public String toString() { + Element anchor = getElement(); + return anchor.getString(); } } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfoTest.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfoTest.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfoTest.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -1,8 +1,11 @@ package org.ourproject.kune.platf.client.ui.rte.insertlink; +import org.xwiki.gwt.dom.client.Element; +import org.xwiki.gwt.dom.client.Range; +import org.xwiki.gwt.dom.client.Selection; + import com.allen_sauer.gwt.log.client.Log; -import com.xpn.xwiki.wysiwyg.client.dom.Range; -import com.xpn.xwiki.wysiwyg.client.dom.Selection; +import com.google.gwt.user.client.Timer; public class LinkInfoTest extends AbstractRichTextAreaTest { @@ -11,35 +14,48 @@ private static final String TITLE = "on over"; private static final String _BLANK = "_blank"; - @Override - public String getModuleName() { - return "org.ourproject.kune.app.Kune"; - } - - public void testSimpleLink() { - // String html = createHtmlLink(HREF, TITLE, _BLANK, TEXT); - rta.setHTML(TEXT); + public void doTestSimpleLink() { + String html = createHtmlLink(HREF, TITLE, _BLANK, TEXT); + rta.setHTML(html); Log.debug(rta.getHTML()); Range range = rta.getDocument().createRange(); range.setStart(getBody().getFirstChild(), 1); - range.setEnd(getBody().getFirstChild(), 3); - String selectedText = "om"; + range.setEnd(getBody().getFirstChild(), 1); Selection selection = rta.getDocument().getSelection(); selection.removeAllRanges(); selection.addRange(range); - assertEquals(selectedText, selection.toString()); - // - // LinkInfo linkParsed = - // LinkInfo.parse(getBody().getFirstChildElement()); - // assertEquals(TEXT, linkParsed.getText()); - // assertEquals(HREF, linkParsed.getUrl()); - // assertEquals(TITLE, linkParsed.getTitle()); - // assertEquals(false, linkParsed.isInNewWindow()); + + Element selectedAnchor = LinkExecutableUtils.getSelectedAnchor(rta); + + Log.info(selectedAnchor.getString()); + + LinkInfo linkParsed = LinkInfo.parse(getBody().getFirstChildElement()); + assertEquals(TEXT, linkParsed.getText()); + assertEquals(HREF, linkParsed.getHref()); + assertEquals(TITLE, linkParsed.getTitle()); + assertEquals(_BLANK, linkParsed.getTarget()); } + @Override + public String getModuleName() { + return "org.ourproject.kune.app.Kune"; + } + + public void testPlainTextSelectionWithoutModification() { + delayTestFinish(FINISH_DELAY); + (new Timer() { + @Override + public void run() { + doTestSimpleLink(); + finishTest(); + } + }).schedule(START_DELAY); + } + private String createHtmlLink(String href, String title, String target, String text) { return "<a title=\"" + title + "\" href=\"" + href + "\" target=\"" + target + "\">" + text + "</a>"; } + } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstract.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstract.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstract.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -22,5 +22,4 @@ public interface InsertLinkAbstract { void reset(); - } Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstractPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstractPanel.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstractPanel.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -0,0 +1,120 @@ +package org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink; + +import org.ourproject.kune.platf.client.i18n.Resources; +import org.ourproject.kune.platf.client.ui.dialogs.DefaultForm; +import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialogView; +import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkInfo; + +import com.google.gwt.user.client.Command; +import com.google.gwt.user.client.DeferredCommand; +import com.gwtext.client.core.EventCallback; +import com.gwtext.client.core.EventObject; +import com.gwtext.client.widgets.Component; +import com.gwtext.client.widgets.Panel; +import com.gwtext.client.widgets.form.Checkbox; +import com.gwtext.client.widgets.form.TextField; +import com.gwtext.client.widgets.form.event.FormPanelListenerAdapter; + +public class InsertLinkAbstractPanel extends DefaultForm { + + protected TextField textField; + protected TextField hrefField; + protected TextField onOverField; + protected final Checkbox sameWindow; + + public InsertLinkAbstractPanel(String title, final InsertLinkAbstractPresenter presenter) { + super(title); + super.setAutoWidth(true); + super.setHeight(InsertLinkDialogView.HEIGHT); + + hrefField = new TextField(); + hrefField.setTabIndex(1); + hrefField.setWidth(DEF_FIELD_WIDTH); + hrefField.setAllowBlank(false); + hrefField.setMinLength(3); + hrefField.setMaxLength(250); + hrefField.setValidationEvent(false); + + textField = new TextField(); + textField.setTabIndex(2); + textField.setFieldLabel(Resources.i18n.t("Text")); + textField.setWidth(DEF_FIELD_WIDTH); + textField.setValidationEvent(false); + textField.setTitle(Resources.i18n.t("The hyper-linked text, like: ") + + "<span style=\"font-color:navy !important; text-decoration:underline;\">" + + Resources.i18n.t("Click me for more information!")); + + onOverField = new TextField(); + onOverField.setTabIndex(3); + onOverField.setFieldLabel(Resources.i18n.t("Flyover")); + onOverField.setWidth(DEF_FIELD_WIDTH); + onOverField.setValidationEvent(false); + onOverField.setTitle(Resources.i18n.t("The flyover appears when the viewer's mouse cursor is over the link.")); + + sameWindow = new Checkbox(Resources.i18n.t("Open link in new window")); + sameWindow.setChecked(false); + + textField.addKeyPressListener(new EventCallback() { + public void execute(EventObject e) { + DeferredCommand.addCommand(new Command() { + public void execute() { + presenter.onTextFieldChanged(textField.getRawValue()); + } + }); + } + }); + + onOverField.addKeyPressListener(new EventCallback() { + public void execute(EventObject e) { + DeferredCommand.addCommand(new Command() { + public void execute() { + presenter.onOverFieldChanged(onOverField.getRawValue()); + } + }); + } + }); + + super.addListener(new FormPanelListenerAdapter() { + @Override + public void onActivate(Panel panel) { + LinkInfo linkInfo = presenter.getLinkInfo(); + updateValues(linkInfo); + presenter.onActivate(); + } + }); + + add(hrefField); + add(textField); + add(onOverField); + add(sameWindow); + } + + public String getHref() { + return hrefField.getRawValue(); + } + + public String getText() { + return textField.getRawValue(); + } + + public String getTitle() { + return onOverField.getRawValue(); + } + + public boolean inSameWindow() { + return sameWindow.getValue(); + } + + @Override + public void insert(int index, Component component) { + super.insert(index, component); + } + + protected void updateValues(LinkInfo linkInfo) { + textField.setValue(linkInfo.getText()); + onOverField.setValue(linkInfo.getTitle()); + if (sameWindow.isVisible()) { + sameWindow.setChecked(linkInfo.inSameWindow()); + } + } +} Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstractPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstractPresenter.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstractPresenter.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -21,31 +21,70 @@ import org.ourproject.kune.platf.client.View; import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialog; +import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkInfo; +import com.allen_sauer.gwt.log.client.Log; +import com.calclab.suco.client.events.Listener0; + public class InsertLinkAbstractPresenter implements InsertLinkAbstract { - private InsertLinkAbstractView view; - private final InsertLinkDialog editorInsertElement; + protected InsertLinkAbstractView view; + protected final InsertLinkDialog editorInsertDialog; + private final Listener0 onInsertLinkPressed; - public InsertLinkAbstractPresenter(InsertLinkDialog editorInsertElement) { - this.editorInsertElement = editorInsertElement; + public InsertLinkAbstractPresenter(final InsertLinkDialog editorInsertDialog) { + this.editorInsertDialog = editorInsertDialog; + onInsertLinkPressed = new Listener0() { + public void onEvent() { + if (isValid()) { + LinkInfo linkInfo = updateLinkInfo(); + editorInsertDialog.fireOnInsertLink(linkInfo); + } else { + Log.debug("Form in InsertLink not valid"); + } + } + }; } + public LinkInfo getLinkInfo() { + return editorInsertDialog.getLinkInfo(); + } + public View getView() { return view; } public void init(InsertLinkAbstractView view) { this.view = view; - editorInsertElement.addOptionTab(view); + editorInsertDialog.addTab(view); } - public void onInsert(String name, String link) { - editorInsertElement.fireOnCreateLink(name, link); + public boolean isValid() { + return view.isValid(); + } + + public void onActivate() { + editorInsertDialog.setOnInsertLinkPressed(onInsertLinkPressed); + } + + public void onInsert(LinkInfo linkInfo) { + editorInsertDialog.fireOnInsertLink(linkInfo); reset(); } + public void onOverFieldChanged(String title) { + editorInsertDialog.setLinkTitle(title); + } + + public void onTextFieldChanged(String text) { + editorInsertDialog.setLinkText(text); + } + public void reset() { view.reset(); } + + protected LinkInfo updateLinkInfo() { + return new LinkInfo(view.getText(), view.getTitle(), view.getHref(), view.inSameWindow()); + } } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstractView.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstractView.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstractView.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -23,6 +23,15 @@ public interface InsertLinkAbstractView extends View { + String getHref(); + + String getText(); + + String getTitle(); + + boolean inSameWindow(); + + boolean isValid(); + void reset(); - } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailPanel.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailPanel.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -20,48 +20,31 @@ package org.ourproject.kune.platf.client.ui.rte.insertlink.email; import org.ourproject.kune.platf.client.i18n.I18nTranslationService; -import org.ourproject.kune.platf.client.ui.dialogs.DefaultForm; -import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialogView; +import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkInfo; +import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.InsertLinkAbstractPanel; -import com.gwtext.client.core.EventObject; -import com.gwtext.client.widgets.Button; -import com.gwtext.client.widgets.event.ButtonListenerAdapter; -import com.gwtext.client.widgets.form.TextField; import com.gwtext.client.widgets.form.VType; -public class InsertLinkEmailPanel extends DefaultForm implements InsertLinkEmailView { +public class InsertLinkEmailPanel extends InsertLinkAbstractPanel implements InsertLinkEmailView { - public static final String EMAIL_FIELD = "k-teilep-email-field"; - private final TextField emailField; + public InsertLinkEmailPanel(final InsertLinkEmailPresenter presenter, I18nTranslationService i18n) { + super(i18n.t("Email link"), presenter); - public InsertLinkEmailPanel(final InsertLinkEmailPresenter presenter, - I18nTranslationService i18n) { - super(i18n.t("Email link")); - super.setAutoWidth(true); - super.setHeight(InsertLinkDialogView.HEIGHT); - emailField = new TextField(); - emailField.setTabIndex(4); - emailField.setFieldLabel(i18n.t("Email")); - emailField.setName(EMAIL_FIELD); - emailField.setVtype(VType.EMAIL); - emailField.setWidth(DEF_MEDIUM_FIELD_WIDTH); - emailField.setAllowBlank(false); - emailField.setValidationEvent(false); - emailField.setId(EMAIL_FIELD); - add(emailField); - Button insert = new Button(i18n.t("Insert")); - insert.addListener(new ButtonListenerAdapter() { - @Override - public void onClick(Button button, EventObject e) { - if (getFormPanel().getForm().isValid()) { - presenter.onInsert("", "mailto://" + emailField.getRawValue()); - } - } - }); - addButton(insert); + hrefField.setFieldLabel(i18n.t("Email")); + hrefField.setVtype(VType.EMAIL); + + sameWindow.setVisible(false); } public void clear() { super.reset(); } + + @Override + protected void updateValues(LinkInfo linkInfo) { + super.updateValues(linkInfo); + if (!linkInfo.getHref().startsWith("mailto")) { + hrefField.reset(); + } + } } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailPresenter.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailPresenter.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -20,13 +20,24 @@ package org.ourproject.kune.platf.client.ui.rte.insertlink.email; import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialog; +import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkInfo; import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.InsertLinkAbstractPresenter; -public class InsertLinkEmailPresenter extends InsertLinkAbstractPresenter implements - InsertLinkEmail { +public class InsertLinkEmailPresenter extends InsertLinkAbstractPresenter implements InsertLinkEmail { + private InsertLinkEmailView view; + public InsertLinkEmailPresenter(InsertLinkDialog editorInsertElement) { super(editorInsertElement); } + public void init(InsertLinkEmailView view) { + super.init(view); + this.view = view; + } + + @Override + protected LinkInfo updateLinkInfo() { + return new LinkInfo(view.getText(), view.getTitle(), "mailto://" + view.getHref(), false); + } } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailView.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailView.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailView.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -22,4 +22,5 @@ import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.InsertLinkAbstractView; public interface InsertLinkEmailView extends InsertLinkAbstractView { + } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtPanel.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtPanel.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -20,9 +20,10 @@ package org.ourproject.kune.platf.client.ui.rte.insertlink.ext; import org.ourproject.kune.platf.client.i18n.I18nTranslationService; +import org.ourproject.kune.platf.client.i18n.Resources; import org.ourproject.kune.platf.client.ui.TextUtils; -import org.ourproject.kune.platf.client.ui.dialogs.DefaultForm; -import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialogView; +import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkInfo; +import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.InsertLinkAbstractPanel; import com.google.gwt.user.client.ui.Frame; import com.gwtext.client.core.EventObject; @@ -30,37 +31,25 @@ import com.gwtext.client.widgets.PaddedPanel; import com.gwtext.client.widgets.Panel; import com.gwtext.client.widgets.event.ButtonListenerAdapter; -import com.gwtext.client.widgets.form.TextField; import com.gwtext.client.widgets.layout.FitLayout; -public class InsertLinkExtPanel extends DefaultForm implements InsertLinkExtView { +public class InsertLinkExtPanel extends InsertLinkAbstractPanel implements InsertLinkExtView { - public static final String LINK_FIELD = "k-teilep-link-f"; - final TextField linkField; final Panel previewPanel; - public InsertLinkExtPanel(final InsertLinkExtPresenter presenter, - final I18nTranslationService i18n) { - super(i18n.t("External link")); - super.setAutoWidth(true); - super.setHeight(InsertLinkDialogView.HEIGHT); - linkField = new TextField(); - linkField.setTabIndex(1); - linkField.setFieldLabel(i18n.t("External link (URL)")); - linkField.setRegex(TextUtils.URL_REGEXP); - linkField.setRegexText(i18n.t("The link should be a URL in the format 'http://www.domain.com'")); - linkField.setName(LINK_FIELD); - linkField.setWidth(DEF_FIELD_WIDTH); - linkField.setAllowBlank(false); - linkField.setMinLength(3); - linkField.setMaxLength(250); - linkField.setValidationEvent(false); - linkField.setId(LINK_FIELD); - add(linkField); + public InsertLinkExtPanel(final InsertLinkExtPresenter presenter, final I18nTranslationService i18n) { + super(i18n.t("External link"), presenter); + + hrefField.setFieldLabel(Resources.i18n.t("External link (URL)")); + hrefField.setRegex(TextUtils.URL_REGEXP); + hrefField.setRegexText(Resources.i18n.t("The link should be a URL in the format 'http://www.domain.com'")); + previewPanel = new Panel(); previewPanel.setLayout(new FitLayout()); previewPanel.setHeight(125); + add(new PaddedPanel(previewPanel, 0)); + Button preview = new Button(i18n.t("Preview")); preview.addListener(new ButtonListenerAdapter() { @Override @@ -69,19 +58,10 @@ } }); addButton(preview); - - Button insert = new Button(i18n.t("Insert")); - insert.addListener(new ButtonListenerAdapter() { - @Override - public void onClick(Button button, EventObject e) { - presenter.onInsert(); - } - }); - addButton(insert); } public String getUrl() { - return linkField.getRawValue(); + return hrefField.getRawValue(); } @Override @@ -98,6 +78,18 @@ } public void setUrl(String url) { - linkField.setValue(url); + hrefField.setValue(url); } + + @Override + protected void updateValues(LinkInfo linkInfo) { + super.updateValues(linkInfo); + String href = linkInfo.getHref(); + if (href != null && !href.equals("")) { + String hrefValue = hrefField.getRawValue(); + if (hrefValue != null && hrefValue.length() == 0) { + hrefField.setValue(href); + } + } + } } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtPresenter.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtPresenter.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -23,13 +23,8 @@ import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialog; import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.InsertLinkAbstractPresenter; -public class InsertLinkExtPresenter extends InsertLinkAbstractPresenter implements - InsertLinkExt { +public class InsertLinkExtPresenter extends InsertLinkAbstractPresenter implements InsertLinkExt { - interface Action { - void onValid(String url); - } - private InsertLinkExtView view; public InsertLinkExtPresenter(InsertLinkDialog editorInsertElement) { @@ -39,41 +34,33 @@ public void init(InsertLinkExtView view) { super.init(view); this.view = view; + // editorInsertDialog.insertTab(0, view); } - public void onInsert() { - doActionIfValid(new Action() { - public void onValid(String url) { - onInsert("", url); - } - }); - } - - public void onPreview() { - doActionIfValid(new Action() { - public void onValid(String url) { - view.setPreviewUrl(url); - } - }); - } - - private void doActionIfValid(Action action) { + @Override + public boolean isValid() { String url = view.getUrl(); if (url.matches(TextUtils.URL_REGEXP)) { - action.onValid(url); + return true; } else { if (!url.startsWith("http://")) { url = "http://" + url; if (url.matches(TextUtils.URL_REGEXP)) { view.setUrl(url); - action.onValid(url); + return true; } else { - view.isValid(); + return view.isValid(); } } else { // Seems is not valid - view.isValid(); + return view.isValid(); } } } + + public void onPreview() { + if (isValid()) { + view.setPreviewUrl(view.getUrl()); + } + } } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtView.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtView.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtView.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -30,4 +30,6 @@ public void setPreviewUrl(String url); public void setUrl(String url); + + boolean inSameWindow(); } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertspecialchar/asian/InsertSpecialAsianCharPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertspecialchar/asian/InsertSpecialAsianCharPanel.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertspecialchar/asian/InsertSpecialAsianCharPanel.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -17,6 +17,6 @@ public InsertSpecialAsianCharPanel(InsertSpecialCharDialog insertSpecialCharDialog, I18nTranslationService i18n) { super(insertSpecialCharDialog, i18n.t("Asian characters"), i18n.t(InsertSpecialCharDialog.DEF_LABEL), SPECIAL_CHARS, 7, 20); - insertSpecialCharDialog.addOptionTab(this); + insertSpecialCharDialog.addTab(this); } } \ No newline at end of file Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertspecialchar/occidental/InsertSpecialOccCharPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertspecialchar/occidental/InsertSpecialOccCharPanel.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertspecialchar/occidental/InsertSpecialOccCharPanel.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -20,6 +20,6 @@ public InsertSpecialOccCharPanel(InsertSpecialCharDialog insertSpecialCharDialog, I18nTranslationService i18n) { super(insertSpecialCharDialog, i18n.t("Special characters"), i18n.t(InsertSpecialCharDialog.DEF_LABEL), SPECIAL_CHARS, 11, 20); - insertSpecialCharDialog.addOptionTab(this); + insertSpecialCharDialog.addTab(this); } } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertspecialchar/utf8/InsertSpecialUTF8CharPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertspecialchar/utf8/InsertSpecialUTF8CharPanel.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertspecialchar/utf8/InsertSpecialUTF8CharPanel.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -79,7 +79,7 @@ form.addButton(insert); super.add(form.getFormPanel()); - charDialog.addOptionTab(this); + charDialog.addTab(this); } private char getCharEntered() { Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -18,8 +18,7 @@ public class RTESavingEditorPresenter implements RTESavingEditor { - @Deprecated - public static final String FILE_MENU_OPTION = "File"; + public static final String FILE_DEF_MENU_OPTION = "File"; public static final int AUTOSAVE_AFTER_FAILS_IN_MILLISECONS = 20000; public static final int AUTOSAVE_IN_MILLISECONDS = 10000; @@ -190,7 +189,7 @@ ActionToolbarMenuDescriptor<Object> save = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor, RTEditor.topbar, onPerformSaveCall); save.setIconCls(RTEImgResources.SUFFIX + imgResources.save().getName()); - save.setParentMenuTitle(i18n.t(FILE_MENU_OPTION)); + save.setParentMenuTitle(i18n.t(FILE_DEF_MENU_OPTION)); save.setTextDescription(i18n.t("Save") + (ctrl_S.toString())); save.setPosition(0); @@ -200,7 +199,7 @@ onCancel(); } }); - close.setParentMenuTitle(i18n.t(FILE_MENU_OPTION)); + close.setParentMenuTitle(i18n.t(FILE_DEF_MENU_OPTION)); close.setTextDescription(i18n.t("Close")); Listener0 onPerformSaveAndCloseCall = new Listener0() { @@ -215,7 +214,7 @@ }; ActionToolbarMenuDescriptor<Object> saveclose = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor, RTEditor.topbar, onPerformSaveAndCloseCall); - saveclose.setParentMenuTitle(i18n.t(FILE_MENU_OPTION)); + saveclose.setParentMenuTitle(i18n.t(FILE_DEF_MENU_OPTION)); saveclose.setTextDescription(i18n.t("Save & Close")); ActionToolbarButtonDescriptor<Object> saveCloseBtn = new ActionToolbarButtonDescriptor<Object>( Modified: trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -83,7 +83,7 @@ createContentRenameAction(parentMenuTitle, i18n.t("Rename"), contents); createRenameContentInCtxAction(parentMenuTitleCtx, i18n.t("Rename"), containersNoRoot); - createEditAction(TYPE_WIKIPAGE); + createEditAction(parentMenuTitle, TYPE_WIKIPAGE); // final ActionToolbarMenuDescriptor<StateToken> setAsDefGroupCxt = // createSetAsDefContent(parentMenuTitleCtx); Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -228,7 +228,8 @@ contextActionRegistry.addAction(downloadCtx, typeUploadedfile); } - protected ActionToolbarButtonDescriptor<StateToken> createEditAction(String... registerInTypes) { + protected ActionToolbarButtonDescriptor<StateToken> createEditAction(final String fileMenuTitle, + String... registerInTypes) { ActionToolbarButtonDescriptor<StateToken> editContent = new ActionToolbarButtonDescriptor<StateToken>( AccessRolDTO.Editor, CONTENT_TOPBAR, new Listener<StateToken>() { public void onEvent(final StateToken stateToken) { @@ -280,6 +281,7 @@ }); } }); + editor.setFileMenuTitle(fileMenuTitle); NotifyUser.hideProgress(); } }); Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -810,17 +810,6 @@ } }); - register(InsertLinkGroup.class, new Factory<InsertLinkLocal>(InsertLinkLocal.class) { - @Override - public InsertLinkLocal create() { - final InsertLinkLocalPresenter presenter = new InsertLinkLocalPresenter($(InsertLinkDialog.class)); - final InsertLinkLocalPanel panel = new InsertLinkLocalPanel(presenter, $(WorkspaceSkeleton.class), - $(I18nTranslationService.class), $(FileDownloadUtils.class)); - presenter.init(panel); - return presenter; - } - }); - register(Singleton.class, new Factory<LanguageSelector>(LanguageSelector.class) { @Override public LanguageSelector create() { @@ -956,6 +945,17 @@ } }); + register(InsertLinkGroup.class, new Factory<InsertLinkLocal>(InsertLinkLocal.class) { + @Override + public InsertLinkLocal create() { + final InsertLinkLocalPresenter presenter = new InsertLinkLocalPresenter($(InsertLinkDialog.class)); + final InsertLinkLocalPanel panel = new InsertLinkLocalPanel(presenter, $(WorkspaceSkeleton.class), + $(I18nTranslationService.class), $(FileDownloadUtils.class)); + presenter.init(panel); + return presenter; + } + }); + $(GlobalShortcutRegister.class).enable(); } } Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -39,6 +39,8 @@ private final SiteSignOutLink siteSignOutLink; private final I18nTranslationService i18n; private final EntityTitle entityTitle; + private final String fileMenuTitle; + private final AbstractToolbar sndbar; public ContentEditor(RTEditor editor, boolean autoSave, final I18nTranslationService i18n, StateManager stateManager, SiteSignOutLink siteSignOutLink, DeferredCommandWrapper deferredCommandWrapper, @@ -50,6 +52,7 @@ this.entityTitle = entityTitle; super.init(view); this.ws = ws; + fileMenuTitle = i18n.t(RTESavingEditorPresenter.FILE_DEF_MENU_OPTION); Window.addWindowCloseListener(new WindowCloseListener() { public void onWindowClosed() { } @@ -79,6 +82,7 @@ } }); topbar = ((ActionToolbarPanel<Object>) basicEditor.getTopBar().getView()).getToolbar(); + sndbar = ((ActionToolbarPanel<Object>) basicEditor.getSndBar().getView()).getToolbar(); } @Override @@ -92,6 +96,10 @@ siteSignOutLink.addBeforeSignOut(getBeforeSavingListener()); } + public void setFileMenuTitle(String fileMenuTitleNew) { + basicEditor.getTopBar().setParentMenuTitle(RTEditor.topbar, fileMenuTitle, null, fileMenuTitleNew); + } + @Override protected void onCancelConfirmed() { ws.getEntityWorkspace().clearContent(); @@ -107,14 +115,13 @@ // basicEditor.setFocus(false); } }); - rename.setParentMenuTitle(i18n.t(RTESavingEditorPresenter.FILE_MENU_OPTION)); + rename.setParentMenuTitle(fileMenuTitle); rename.setShortcut(new ShortcutDescriptor(false, Keyboard.KEY_F2, i18n.tWithNT("F2", "The F2 Function key"))); rename.setTextDescription(i18n.t("Rename")); basicEditor.addAction(rename); } private void adjHeight(final int height) { - AbstractToolbar sndbar = ((ActionToolbarPanel<Object>) basicEditor.getSndBar().getView()).getToolbar(); int barHeight = sndbar.getOffsetHeight(); int newHeight = height - 20 - barHeight; // Log.debug("Sndbar height: " + barHeight + " new height: " + Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocalimg/InsertImageLocalPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocalimg/InsertImageLocalPresenter.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocalimg/InsertImageLocalPresenter.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -11,6 +11,6 @@ } public void init(InsertImageLocalView view) { - insertImageDialog.addOptionTab(view); + insertImageDialog.addTab(view); } } Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocalPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocalPanel.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocalPanel.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -22,30 +22,43 @@ import org.ourproject.kune.platf.client.dto.LinkDTO; import org.ourproject.kune.platf.client.dto.StateToken; import org.ourproject.kune.platf.client.i18n.I18nTranslationService; -import org.ourproject.kune.platf.client.ui.WindowUtils; import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils; -import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialogView; +import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.InsertLinkAbstractPanel; +import org.ourproject.kune.workspace.client.search.AbstractLiveSearcherField; import org.ourproject.kune.workspace.client.search.AbstractLiveSearcherPanel; import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton; import com.calclab.suco.client.events.Listener; -public class InsertLinkLocalPanel extends AbstractLiveSearcherPanel implements InsertLinkLocalView { +public class InsertLinkLocalPanel extends InsertLinkAbstractPanel implements InsertLinkLocalView { private static final String DATA_PROXY_URL = "/kune/json/ContentJSONService/search"; - public InsertLinkLocalPanel(final InsertLinkLocalPresenter presenter, - final WorkspaceSkeleton ws, I18nTranslationService i18n, FileDownloadUtils downloadUtils) { - super(i18n, TEMPLATE_TEXT_PREFIX + downloadUtils.getLogoImageUrl(new StateToken("{shortName}")) - + TEMPLATE_TEXT_SUFFIX, DATA_PROXY_URL, new Listener<LinkDTO>() { - public void onEvent(LinkDTO link) { - // FIXME - presenter.onInsert("", WindowUtils.getLocation().getHref() + link.getLink()); - } - }); - super.setTitle(i18n.t("Local link")); - super.setFrame(true); - super.setHeight(InsertLinkDialogView.HEIGHT); - super.setPaddings(20); + private String href; + + public InsertLinkLocalPanel(final InsertLinkLocalPresenter presenter, final WorkspaceSkeleton ws, + I18nTranslationService i18n, FileDownloadUtils downloadUtils) { + super(i18n.t("Local link"), presenter); + + AbstractLiveSearcherField cb = new AbstractLiveSearcherField(i18n, + AbstractLiveSearcherPanel.TEMPLATE_TEXT_PREFIX + + downloadUtils.getLogoImageUrl(new StateToken("{shortName}")) + + AbstractLiveSearcherPanel.TEMPLATE_TEXT_SUFFIX, DATA_PROXY_URL, new Listener<LinkDTO>() { + public void onEvent(LinkDTO link) { + href = (new StateToken(link.getLink())).getPublicUrl(); + } + }); + cb.setLabel(i18n.t("Local content")); + cb.setHideLabel(false); + cb.setAllowBlank(false); + cb.setWidth(220); + hrefField.setVisible(false); + hrefField.disable(); + super.insert(0, cb); } + + @Override + public String getHref() { + return href; + } } Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocalPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocalPresenter.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocalPresenter.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -22,8 +22,7 @@ import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialog; import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.InsertLinkAbstractPresenter; -public class InsertLinkLocalPresenter extends InsertLinkAbstractPresenter implements - InsertLinkLocal { +public class InsertLinkLocalPresenter extends InsertLinkAbstractPresenter implements InsertLinkLocal { public InsertLinkLocalPresenter(InsertLinkDialog editorInsertElement) { super(editorInsertElement); Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptions.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptions.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptions.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -25,7 +25,7 @@ public interface EntityOptions extends AbstractTabbedDialog { - public void addOptionTab(View tab); + public void addTab(View tab); public View getView(); Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/options/license/EntityOptionsDefLicensePresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/options/license/EntityOptionsDefLicensePresenter.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/options/license/EntityOptionsDefLicensePresenter.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -59,7 +59,7 @@ public void init(EntityOptionsDefLicenseView view) { this.view = view; - entityOptions.addOptionTab(view); + entityOptions.addTab(view); setState(); } Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/options/logo/EntityOptionsLogoPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/options/logo/EntityOptionsLogoPresenter.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/options/logo/EntityOptionsLogoPresenter.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -62,7 +62,7 @@ public void init(EntityOptionsLogoView view) { this.view = view; - entityOptions.addOptionTab(view); + entityOptions.addTab(view); setState(); } Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/options/pscape/EntityOptionsPublicSpaceConfPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/options/pscape/EntityOptionsPublicSpaceConfPresenter.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/options/pscape/EntityOptionsPublicSpaceConfPresenter.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -37,6 +37,6 @@ public void init(EntityOptionsPublicSpaceConfView view) { this.view = view; - entityOptions.addOptionTab(view); + entityOptions.addTab(view); } } Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/options/tools/EntityOptionsToolsConfPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/options/tools/EntityOptionsToolsConfPresenter.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/options/tools/EntityOptionsToolsConfPresenter.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -66,7 +66,7 @@ public void init(EntityOptionsToolsConfView view) { this.view = view; setState(); - entityOptions.addOptionTab(view); + entityOptions.addTab(view); } public void onCheck(ToolSimpleDTO tool, boolean checked) { Added: trunk/src/main/java/org/ourproject/kune/workspace/client/search/AbstractLiveSearcherField.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/search/AbstractLiveSearcherField.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/search/AbstractLiveSearcherField.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -0,0 +1,78 @@ +package org.ourproject.kune.workspace.client.search; + +import org.ourproject.kune.platf.client.dto.LinkDTO; +import org.ourproject.kune.platf.client.i18n.I18nTranslationService; + +import com.calclab.suco.client.events.Listener; +import com.google.gwt.user.client.Command; +import com.google.gwt.user.client.DeferredCommand; +import com.gwtext.client.core.Connection; +import com.gwtext.client.core.Template; +import com.gwtext.client.core.UrlParam; +import com.gwtext.client.data.DataProxy; +import com.gwtext.client.data.FieldDef; +import com.gwtext.client.data.HttpProxy; +import com.gwtext.client.data.JsonReader; +import com.gwtext.client.data.Record; +import com.gwtext.client.data.RecordDef; +import com.gwtext.client.data.Store; +import com.gwtext.client.data.StringFieldDef; +import com.gwtext.client.widgets.form.ComboBox; +import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter; + +public class AbstractLiveSearcherField extends ComboBox { + private static final String LONG_NAME_FIELD = "longName"; + private static final String SHORT_NAME_FIELD = "shortName"; + private static final String ICON_URL_FIELD = "iconUrl"; + private static final String LINK_FIELD = "link"; + public static final int PAGINATION_SIZE = 10; + + public AbstractLiveSearcherField(I18nTranslationService i18n, String templateText, String dataProxyUrl, + final Listener<LinkDTO> listener) { + DataProxy dataProxy = new HttpProxy(dataProxyUrl, Connection.POST); + + final JsonReader reader = new JsonReader(new RecordDef( + new FieldDef[] { new StringFieldDef(SHORT_NAME_FIELD), new StringFieldDef(LONG_NAME_FIELD), + new StringFieldDef(LINK_FIELD), new StringFieldDef(ICON_URL_FIELD) })); + reader.setRoot("list"); + reader.setTotalProperty("size"); + reader.setId(SHORT_NAME_FIELD); + + final Store store = new Store(dataProxy, reader); + + store.load(new UrlParam[] { new UrlParam("query", "."), new UrlParam("first", 1), + new UrlParam("max", PAGINATION_SIZE) }); + + final Template resultTpl = new Template(templateText); + super.setStore(store); + super.setEmptyText(i18n.t("Write here to search")); + super.setDisplayField(LONG_NAME_FIELD); + super.setTypeAhead(true); + super.setLoadingText(i18n.t("Searching...")); + super.setWidth(268); + super.setPageSize(PAGINATION_SIZE); + super.setTpl(resultTpl); + super.setMode(ComboBox.REMOTE); + super.setMinChars(2); + super.setSelectOnFocus(false); + super.setHideTrigger(true); + super.setHideLabel(true); + // setTitle(i18n.t("User or group")); + super.setItemSelector("div.search-item"); + + super.addListener(new ComboBoxListenerAdapter() { + @Override + public void onSelect(final ComboBox comboBox, final Record record, final int index) { + DeferredCommand.addCommand(new Command() { + public void execute() { + final LinkDTO link = new LinkDTO(record.getAsString(SHORT_NAME_FIELD), + record.getAsString(LONG_NAME_FIELD), record.getAsString(ICON_URL_FIELD), + record.getAsString(LINK_FIELD)); + listener.onEvent(link); + } + }); + } + }); + + } +} Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/search/AbstractLiveSearcherPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/search/AbstractLiveSearcherPanel.java 2009-03-18 14:37:36 UTC (rev 1082) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/search/AbstractLiveSearcherPanel.java 2009-03-23 19:21:30 UTC (rev 1083) @@ -23,88 +23,19 @@ import org.ourproject.kune.platf.client.i18n.I18nTranslationService; import com.calclab.suco.client.events.Listener; -import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.DeferredCommand; -import com.gwtext.client.core.Connection; -import com.gwtext.client.core.Template; -import com.gwtext.client.core.UrlParam; -import com.gwtext.client.data.DataProxy; -import com.gwtext.client.data.FieldDef; -import com.gwtext.client.data.HttpProxy; -import com.gwtext.client.data.JsonReader; -import com.gwtext.client.data.Record; -import com.gwtext.client.data.RecordDef; -import com.gwtext.client.data.Store; -import com.gwtext.client.data.StringFieldDef; -import com.gwtext.client.widgets.form.ComboBox; import com.gwtext.client.widgets.form.FormPanel; -import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter; public class AbstractLiveSearcherPanel extends FormPanel { - protected static final String TEMPLATE_TEXT_PREFIX = "<div class=\"search-item\"><span class=\"kune-IconHyperlink\"><img src=\""; - protected static final String TEMPLATE_TEXT_SUFFIX = "\" style=\"height: 16px; width: 16px;\" />{shortName}: {longName}</span></div>"; + public static final String TEMPLATE_TEXT_PREFIX = "<div class=\"search-item\"><span class=\"kune-IconHyperlink\"><img src=\""; + public static final String TEMPLATE_TEXT_SUFFIX = "\" style=\"height: 16px; width: 16px;\" />{shortName}: {longName}</span></div>"; - private static final String LONG_NAME_FIELD = "longName"; - private static final String SHORT_NAME_FIELD = "shortName"; - private static final String ICON_URL_FIELD = "iconUrl"; - private static final String LINK_FIELD = "link"; - - public static final int PAGINATION_SIZE = 10; - public AbstractLiveSearcherPanel(I18nTranslationService i18n, String templateText, String dataProxyUrl, final Listener<LinkDTO> listener) { - DataProxy dataProxy = new HttpProxy(dataProxyUrl, Connection.POST); - - final JsonReader reader = new JsonReader(new RecordDef( - new FieldDef[] { new StringFieldDef(SHORT_NAME_FIELD), new StringFieldDef(LONG_NAME_FIELD), - new StringFieldDef(LINK_FIELD), new StringFieldDef(ICON_URL_FIELD) })); - reader.setRoot("list"); - reader.setTotalProperty("size"); - reader.setId(SHORT_NAME_FIELD); - - final Store store = new Store(dataProxy, reader); - - store.load(new UrlParam[] { new UrlParam("query", "."), new UrlParam("first", 1), - new UrlParam("max", PAGINATION_SIZE) }); - super.setBorder(false); super.setWidth(275); super.setHideLabels(true); - - final Template resultTpl = new Template(templateText); - final ComboBox cb = new ComboBox(); - cb.setStore(store); - cb.setEmptyText(i18n.t("Write here to search")); - cb.setDisplayField(LONG_NAME_FIELD); - cb.setTypeAhead(true); - cb.setLoadingText(i18n.t("Searching...")); - cb.setWidth(268); - cb.setPageSize(PAGINATION_SIZE); - cb.setTpl(resultTpl); - cb.setMode(ComboBox.REMOTE); - cb.setMinChars(2); - cb.setSelectOnFocus(false); - cb.setHideTrigger(true); - cb.setHideLabel(true); - // setTitle(i18n.t("User or group")); - cb.setItemSelector("div.search-item"); - - cb.addListener(new ComboBoxListenerAdapter() { - @Override - public void onSelect(final ComboBox comboBox, final Record record, final int index) { - DeferredCommand.addCommand(new Command() { - public void execute() { - final LinkDTO link = new LinkDTO(record.getAsString(SHORT_NAME_FIELD), - record.getAsString(LONG_NAME_FIELD), record.getAsString(ICON_URL_FIELD), - record.getAsString(LINK_FIELD)); - listener.onEvent(link); - } - }); - } - }); - - super.add(cb); + super.add(new AbstractLiveSearcherField(i18n, templateText, dataProxyUrl, listener)); } public void reset() {
participants (1)
-
vjrj