[kune-commits] r1070 - in trunk/src:
main/java/org/ourproject/kune/platf/client/services
main/java/org/ourproject/kune/platf/client/ui/rte
main/java/org/ourproject/kune/platf/client/ui/rte/basic
main/java/org/ourproject/kune/platf/client/ui/rte/insertimg
main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext
main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext
main/java/org/ourproject/kune/platf/client/ui/rte/saving
main/java/org/ourproject/kune/workspace/client
main/java/org/ourproject/kune/workspace/client/editor
main/java/org/ourproject/kune/workspace/client/editor/insert
test/java/org/ourproject/kune/platf/client/ui/rte
test/java/org/ourproject/kune/platf/client/ui/rte/saving
vjrj
vjrj at ourproject.org
Wed Mar 11 14:47:16 CET 2009
Author: vjrj
Date: 2009-03-11 14:47:13 +0100 (Wed, 11 Mar 2009)
New Revision: 1070
Added:
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbar.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbarPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbar.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbarPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEcanBeBasic.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditor.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/insertimg/ext/
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExt.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPanel.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/insertimg/ext/InsertImageExtView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditor.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPanel.java
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/RTESavingEditorView.java
trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/saving/
trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenterTest.java
Removed:
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbar.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbarPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbar.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbarPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditor.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEcanBeBasic.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExt.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtView.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditor.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorImages.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorToolbar.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorView.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/alignleft.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/alignright.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/backcolor.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/bold.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/centerpara.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/charfontname.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/decrementindent.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/defaultbullet.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/defaultnumbering.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/edithtml.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/fontcolor.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/fontheight.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/hfixedline.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/images.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/incrementindent.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/abstractlink/
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkemail/
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkext/
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linklocal/
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/italic.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/link.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/link_break.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/removeFormat.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/strikeout.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/subscript.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/superscript.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/underline.png
trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenterTest.java
Modified:
trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java
trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java
Log:
Incomplete - task Better RTE (Rich Text Editor) support
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -48,17 +48,14 @@
import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalettePanel;
import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalettePresenter;
-import org.ourproject.kune.platf.client.ui.rte.RTEActionSndToolbar;
-import org.ourproject.kune.platf.client.ui.rte.RTEActionSndToolbarPresenter;
-import org.ourproject.kune.platf.client.ui.rte.RTEActionTopToolbar;
-import org.ourproject.kune.platf.client.ui.rte.RTEActionTopToolbarPresenter;
-import org.ourproject.kune.platf.client.ui.rte.RTESavingEditor;
-import org.ourproject.kune.platf.client.ui.rte.RTESavingEditorPanel;
-import org.ourproject.kune.platf.client.ui.rte.RTESavingEditorPresenter;
-import org.ourproject.kune.platf.client.ui.rte.RTEditor;
-import org.ourproject.kune.platf.client.ui.rte.RTEditorPanel;
-import org.ourproject.kune.platf.client.ui.rte.RTEditorPresenter;
import org.ourproject.kune.platf.client.ui.rte.TestRTEDialog;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEActionSndToolbar;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEActionSndToolbarPresenter;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEActionTopToolbar;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEActionTopToolbarPresenter;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPanel;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPresenter;
import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtml;
import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlGroup;
import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlPanel;
@@ -74,9 +71,9 @@
import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageGroup;
import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImagePanel;
import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImagePresenter;
-import org.ourproject.kune.platf.client.ui.rte.insertimgext.InsertImageExt;
-import org.ourproject.kune.platf.client.ui.rte.insertimgext.InsertImageExtPanel;
-import org.ourproject.kune.platf.client.ui.rte.insertimgext.InsertImageExtPresenter;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.ext.InsertImageExt;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.ext.InsertImageExtPanel;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.ext.InsertImageExtPresenter;
import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElement;
import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElementGroup;
import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElementPanel;
@@ -88,6 +85,9 @@
import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.TextEditorInsertLinkExtPanel;
import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.TextEditorInsertLinkExtPresenter;
import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.TextEditorInsertLinkExtView;
+import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditor;
+import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPanel;
+import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPresenter;
import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
import org.ourproject.kune.platf.client.utils.TimerWrapper;
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbar.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbar.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,7 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-
-public interface RTEActionSndToolbar extends ActionToolbar<Object> {
-
-}
\ No newline at end of file
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbarPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbarPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbarPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,12 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPresenter;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarView;
-
-public class RTEActionSndToolbarPresenter extends ActionToolbarPresenter<Object> implements RTEActionSndToolbar {
-
- public RTEActionSndToolbarPresenter(ActionToolbarView<Object> toolbar) {
- super(toolbar);
- }
-
-}
\ No newline at end of file
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbar.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbar.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,7 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-
-public interface RTEActionTopToolbar extends ActionToolbar<Object> {
-
-}
\ No newline at end of file
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbarPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbarPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbarPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,12 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPresenter;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarView;
-
-public class RTEActionTopToolbarPresenter extends ActionToolbarPresenter<Object> implements RTEActionTopToolbar {
-
- public RTEActionTopToolbarPresenter(ActionToolbarView<Object> toolbar) {
- super(toolbar);
- }
-
-}
\ No newline at end of file
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditor.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditor.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,26 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.actions.BeforeActionListener;
-
-import com.calclab.suco.client.events.Listener;
-import com.calclab.suco.client.events.Listener0;
-
-public interface RTESavingEditor {
-
- void edit(String html, Listener<String> onSave, Listener0 onEditCancelled);
-
- RTEditor getBasicEditor();
-
- /**
- * This is use for listen to changes as url changes, window close, and
- * save/cancel or stop these actions
- *
- * @return
- */
- BeforeActionListener getBeforeSavingListener();
-
- void onSavedSuccessful();
-
- void onSaveFailed();
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPanel.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,14 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
-
-import com.calclab.suco.client.events.Listener0;
-
-public class RTESavingEditorPanel implements RTESavingEditorView {
-
- public void askConfirmation(String confirmationTitle, String confirmationText, Listener0 onConfirm,
- Listener0 onCancel) {
- NotifyUser.askConfirmation(confirmationTitle, confirmationText, onConfirm, onCancel);
- }
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,244 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.actions.ActionShortcut;
-import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator;
-import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
-import org.ourproject.kune.platf.client.actions.BeforeActionListener;
-import org.ourproject.kune.platf.client.dto.AccessRolDTO;
-import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-import org.ourproject.kune.platf.client.state.StateManager;
-import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
-import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
-import org.ourproject.kune.platf.client.utils.TimerWrapper;
-
-import com.calclab.suco.client.events.Listener;
-import com.calclab.suco.client.events.Listener0;
-
-public class RTESavingEditorPresenter implements RTESavingEditor {
-
- @Deprecated
- private static final String FILE_MENU_OPTION = "File";
- public static final int AUTOSAVE_AFTER_FAILS_IN_MILLISECONS = 20000;
- public static final int AUTOSAVE_IN_MILLISECONDS = 10000;
-
- private final RTEditor editor;
- private final boolean autoSave;
- private boolean savePending;
- private boolean saveAndCloseConfirmed;
- private Listener<String> onSave;
- private Listener0 onEditCancelled;
- private final RTEImgResources imgResources;
- private final TimerWrapper timer;
- private final DeferredCommandWrapper deferredCommandWrapper;
- private final I18nTranslationService i18n;
- private final StateManager stateManager;
- private final BeforeActionListener beforeStateChangeListener;
- ActionToolbarButtonDescriptor<Object> saveBtn;
- private RTESavingEditorView view;
-
- public RTESavingEditorPresenter(RTEditor editor, final boolean autoSave, final I18nTranslationService i18n,
- StateManager stateManager, DeferredCommandWrapper deferredCommandWrapper,
- RTEImgResources imgResources, TimerWrapper timer) {
- this.editor = editor;
- this.autoSave = autoSave;
- this.i18n = i18n;
- this.stateManager = stateManager;
- this.deferredCommandWrapper = deferredCommandWrapper;
- this.imgResources = imgResources;
- this.savePending = false;
- this.saveAndCloseConfirmed = false;
- createActions();
- this.timer = timer;
- timer.configure(new Listener0() {;
-
- public void onEvent() {
- onAutoSave();
- }
- });
- editor.addOnEditListener(new Listener0() {
- public void onEvent() {
- onEdit();
- }
- });
- beforeStateChangeListener = new BeforeActionListener() {
- public boolean beforeAction() {
- return beforeTokenChange();
- }
- };
- }
-
- public void edit(String html, Listener<String> onSave, Listener0 onEditCancelled) {
- this.onSave = onSave;
- this.onEditCancelled = onEditCancelled;
- editor.setHtml(html);
- editor.attach();
- stateManager.addBeforeStateChangeListener(beforeStateChangeListener);
- enableSaveBtn(false);
- }
-
- public RTEditor getBasicEditor() {
- return editor;
- }
-
- public BeforeActionListener getBeforeSavingListener() {
- return beforeStateChangeListener;
- }
-
- public void init(RTESavingEditorView view) {
- this.view = view;
- }
-
- public void onDoSaveAndClose() {
- saveAndCloseConfirmed = true;
- onDoSave();
- }
-
- public void onSavedSuccessful() {
- if (saveAndCloseConfirmed) {
- onCancelConfirmed();
- } else {
- reset();
- }
- }
-
- public void onSaveFailed() {
- timer.schedule(AUTOSAVE_AFTER_FAILS_IN_MILLISECONS);
- if (saveAndCloseConfirmed) {
- saveAndCloseConfirmed = false;
- }
- }
-
- protected void onAutoSave() {
- onDoSave();
- }
-
- protected void onCancel() {
- if (savePending) {
- timer.cancel();
- Listener0 onYes = new Listener0() {
- public void onEvent() {
- onDoSaveAndClose();
- }
- };
- Listener0 onCancel = new Listener0() {
- public void onEvent() {
- onCancelConfirmed();
- }
- };
- view.askConfirmation(i18n.t("Save confirmation"),
- i18n.t("Do you want to save before closing the editor?"), onYes, onCancel);
- } else {
- onCancelConfirmed();
- }
- }
-
- protected void onCancelConfirmed() {
- stateManager.removeBeforeStateChangeListener(beforeStateChangeListener);
- stateManager.resumeTokenChange();
- reset();
- editor.reset();
- onDoEditCancelled();
- }
-
- protected void onDoSave() {
- onSave.onEvent(editor.getHtml());
- }
-
- boolean beforeTokenChange() {
- if (savePending) {
- onCancel();
- return false;
- } else {
- deferredCommandWrapper.addCommand(new Listener0() {
- public void onEvent() {
- onCancelConfirmed();
- }
- });
- return true;
- }
- }
-
- void onEdit() {
- if (!savePending) {
- savePending = true;
- if (autoSave) {
- timer.schedule(AUTOSAVE_IN_MILLISECONDS);
- }
- enableSaveBtn(true);
- }
- }
-
- private void createActions() {
- Listener0 onPerformSaveCall = new Listener0() {
- public void onEvent() {
- onDoSave();
- }
- };
- saveBtn = new ActionToolbarButtonDescriptor<Object>(AccessRolDTO.Editor, RTEditor.sndbar, onPerformSaveCall);
- saveBtn.setIconCls(RTEImgResources.SUFFIX + imgResources.save().getName());
- saveBtn.setToolTip(i18n.t("Save"));
- saveBtn.setShortcut(new ActionShortcut(true, 'S'));
- saveBtn.setPosition(0);
-
- 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.setTextDescription(i18n.t("Save"));
- save.setShortcut(new ActionShortcut(true, 'S'));
- save.setPosition(0);
-
- ActionToolbarMenuDescriptor<Object> close = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor,
- RTEditor.topbar, new Listener<Object>() {
- public void onEvent(Object parameter) {
- onCancel();
- }
- });
- close.setParentMenuTitle(i18n.t(FILE_MENU_OPTION));
- close.setTextDescription(i18n.t("Close"));
-
- Listener0 onPerformSaveAndCloseCall = new Listener0() {
- public void onEvent() {
- if (savePending) {
- timer.cancel();
- onDoSaveAndClose();
- } else {
- onCancelConfirmed();
- }
- }
- };
- ActionToolbarMenuDescriptor<Object> saveclose = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor,
- RTEditor.topbar, onPerformSaveAndCloseCall);
- saveclose.setParentMenuTitle(i18n.t(FILE_MENU_OPTION));
- saveclose.setTextDescription(i18n.t("Save & Close"));
-
- ActionToolbarButtonDescriptor<Object> saveCloseBtn = new ActionToolbarButtonDescriptor<Object>(
- AccessRolDTO.Editor, RTEditor.topbar, onPerformSaveAndCloseCall);
- // saveCloseBtn.setIconCls(RTEImgResources.SUFFIX +
- // imgResources.save().getName());
- saveCloseBtn.setTextDescription(i18n.t("Save & Close"));
- saveCloseBtn.setLeftSeparator(ActionToolbarButtonSeparator.fill);
-
- editor.addAction(save);
- editor.addAction(saveclose);
- editor.addAction(close);
- editor.addAction(saveBtn);
- editor.addAction(saveCloseBtn);
- }
-
- private void enableSaveBtn(boolean enable) {
- editor.getSndBar().setButtonEnable(saveBtn, enable);
- }
-
- private void onDoEditCancelled() {
- onEditCancelled.onEvent();
- }
-
- private void reset() {
- timer.cancel();
- savePending = false;
- saveAndCloseConfirmed = false;
- enableSaveBtn(false);
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorView.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorView.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,10 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.View;
-
-import com.calclab.suco.client.events.Listener0;
-
-public interface RTESavingEditorView extends View {
-
- void askConfirmation(String confirmationTitle, String confirmationText, Listener0 onConfirm, Listener0 onCancel);
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEcanBeBasic.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEcanBeBasic.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEcanBeBasic.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,10 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.actions.ActionAddCondition;
-
-public class RTEcanBeBasic implements ActionAddCondition<Object> {
- public boolean mustBeAdded(Object param) {
- // TODO Auto-generated method stub
- return false;
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,46 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.actions.ActionAddCondition;
-import org.ourproject.kune.platf.client.actions.ActionCollection;
-import org.ourproject.kune.platf.client.actions.ActionDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarPosition;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-
-import com.calclab.suco.client.events.Listener0;
-
-public interface RTEditor {
-
- public final ActionToolbarPosition topbar = new ActionToolbarPosition("rte-topbar");
- public final ActionToolbarPosition sndbar = new ActionToolbarPosition("rte-sndbar");;
-
- void addAction(ActionDescriptor<Object> action);
-
- void addActions(ActionCollection<Object> actions);
-
- void addOnEditListener(Listener0 listener);
-
- void attach();
-
- ActionAddCondition<Object> canBeBasic();
-
- ActionAddCondition<Object> canBeExtended();
-
- View getEditorArea();
-
- String getHtml();
-
- ActionToolbar<Object> getSndBar();
-
- String getText();
-
- ActionToolbar<Object> getTopBar();
-
- void reset();
-
- void setExtended(boolean extended);
-
- void setHtml(String html);
-
- void setText(String text);
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,318 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import java.util.Date;
-import java.util.HashMap;
-
-import org.ourproject.kune.platf.client.actions.ActionDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionItem;
-import org.ourproject.kune.platf.client.actions.ActionItemCollection;
-import org.ourproject.kune.platf.client.actions.ActionManager;
-import org.ourproject.kune.platf.client.actions.ActionShortcut;
-import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
-import org.ourproject.kune.platf.client.ui.rte.RichTextArea.BasicFormatter;
-import org.ourproject.kune.platf.client.ui.rte.RichTextArea.ExtendedFormatter;
-import org.ourproject.kune.platf.client.ui.rte.RichTextArea.FontSize;
-import org.ourproject.kune.platf.client.ui.rte.RichTextArea.Justification;
-
-import com.allen_sauer.gwt.log.client.Log;
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.ui.ChangeListener;
-import com.google.gwt.user.client.ui.ClickListener;
-import com.google.gwt.user.client.ui.FocusListener;
-import com.google.gwt.user.client.ui.KeyboardListener;
-import com.google.gwt.user.client.ui.Widget;
-
-public class RTEditorPanel implements RTEditorView {
-
- private class EventListener implements ClickListener, ChangeListener, KeyboardListener, FocusListener {
-
- public void onChange(Widget sender) {
- presenter.fireOnEdit();
- }
-
- public void onClick(Widget sender) {
- if (sender == rta) {
- // We use the RichTextArea's onKeyUp event to update the
- // toolbar status. This will catch any cases where the user
- // moves the cursor using the keyboard, or uses one of the
- // browser's built-in keyboard shortcuts.
- updateStatus();
- }
- }
-
- public void onFocus(Widget sender) {
- presenter.onEditorFocus();
- }
-
- public void onKeyDown(final Widget sender, final char keyCode, final int modifiers) {
- }
-
- public void onKeyPress(final Widget sender, final char keyCode, final int modifiers) {
- }
-
- public void onKeyUp(final Widget sender, final char keyCode, final int modifiers) {
- if (sender == rta) {
- // We use the RichTextArea's onKeyUp event to update the
- // toolbar status.
- // This will catch any cases where the user moves the cursor
- // using the keyboard, or uses one of the browser's built-in
- // keyboard shortcuts.
-
- updateStatus();
- fireEdit();
- if (modifiers != 0) {
- Log.debug("RTE shortcut pressed (" + modifiers + ", " + keyCode + ")");
- ActionItem<Object> actionItem = shortcuts.get(new ActionShortcut(keyCode, modifiers));
- if (actionItem != null) {
- actionManager.doAction(actionItem);
- updateStatus();
- } else {
- Log.debug("...but not mapped to any action");
- }
- }
- }
- }
-
- public void onLostFocus(Widget sender) {
-
- }
- }
- private final I18nUITranslationService i18n;
- private final RichTextArea rta;
- private final BasicFormatter basic;
- private final ExtendedFormatter extended;
- private final HashMap<ActionShortcut, ActionItem<Object>> shortcuts;
- private final ActionManager actionManager;
- private final RTEditorPresenter presenter;
-
- public RTEditorPanel(final RTEditorPresenter presenter, I18nUITranslationService i18n, ActionManager actionManager) {
- this.presenter = presenter;
- this.i18n = i18n;
- this.actionManager = actionManager;
- rta = new RichTextArea();
- basic = rta.getBasicFormatter();
- extended = rta.getExtendedFormatter();
- shortcuts = new HashMap<ActionShortcut, ActionItem<Object>>();
- EventListener listener = new EventListener();
- rta.addClickListener(listener);
- rta.addKeyboardListener(listener);
- rta.addFocusListener(listener);
- rta.setWidth("96%");
- rta.setHeight("100%");
- }
-
- public void addActions(ActionItemCollection<Object> actionItems) {
- for (ActionItem<Object> actionItem : actionItems) {
- ActionDescriptor<Object> action = actionItem.getAction();
- if (action.hasShortcut() && action.mustBeAdded(null)) {
- ActionShortcut shortcut = action.getShortcut();
- shortcuts.put(shortcut, actionItem);
- }
- }
- }
-
- public void addComment(String userName) {
- String time = i18n.formatDateWithLocale(new Date(), true);
- Element span = DOM.createSpan();
- span.setInnerHTML("<em>" + i18n.t("type your comment here") + "</em> -" + userName + " " + time);
- DOM.setElementProperty(span.<com.google.gwt.user.client.Element> cast(), "className", "k-rte-comment");
- insertHtml(" " + span.getString() + " ");
- }
-
- public void adjustSize(int height) {
- rta.setHeight("" + height);
- }
-
- public boolean canBeBasic() {
- return basic != null;
- }
-
- public boolean canBeExtended() {
- return extended != null;
- }
-
- public void copy() {
- extended.copy();
- }
-
- public void createLink(String url) {
- extended.createLink(url);
- }
-
- public void cut() {
- extended.cut();
- }
-
- public void delete() {
- extended.delete();
- }
-
- public void focus() {
- rta.setFocus(true);
- }
-
- public String getHtml() {
- return rta.getHTML();
- }
-
- public Widget getRTE() {
- return rta;
- }
-
- public String getText() {
- return rta.getText();
- }
-
- public void insertHorizontalRule() {
- extended.insertHorizontalRule();
- }
-
- public void insertHtml(String html) {
- extended.insertHtml(html);
- }
-
- public void insertImage(String url) {
- extended.insertImage(url);
- }
-
- public void insertOrderedList() {
- extended.insertOrderedList();
- }
-
- public void insertUnorderedList() {
- extended.insertUnorderedList();
- }
-
- public boolean isAttached() {
- return rta.isAttached();
- }
-
- public boolean isBold() {
- return basic.isBold();
- }
-
- public boolean isItalic() {
- return basic.isItalic();
- }
-
- public boolean isStrikethrough() {
- return extended.isStrikethrough();
- }
-
- public boolean isSubscript() {
- return basic.isSubscript();
- }
-
- public boolean isSuperscript() {
- return basic.isSuperscript();
- }
-
- public boolean isUnderlined() {
- return basic.isUnderlined();
- }
-
- public void justifyCenter() {
- basic.setJustification(Justification.CENTER);
- }
-
- public void justifyLeft() {
- basic.setJustification(Justification.LEFT);
- }
-
- public void justifyRight() {
- basic.setJustification(Justification.RIGHT);
- }
-
- public void leftIndent() {
- extended.leftIndent();
- }
-
- public void paste() {
- extended.paste();
- }
-
- public void redo() {
- extended.redo();
- }
-
- public void removeFormat() {
- extended.removeFormat();
- }
-
- public void rightIndent() {
- extended.rightIndent();
- }
-
- public void selectAll() {
- basic.selectAll();
- }
-
- public void setBackColor(String color) {
- basic.setBackColor(color);
- }
-
- public void setFontName(String name) {
- basic.setFontName(name);
- }
-
- public void setFontSize(FontSize size) {
- basic.setFontSize(size);
- }
-
- public void setForeColor(String color) {
- basic.setForeColor(color);
- }
-
- public void setHtml(String html) {
- rta.setHTML(html);
- }
-
- public void setText(String text) {
- rta.setText(text);
- }
-
- public void toggleBold() {
- basic.toggleBold();
- }
-
- public void toggleItalic() {
- basic.toggleItalic();
- }
-
- public void toggleStrikethrough() {
- extended.toggleStrikethrough();
- }
-
- public void toggleSubscript() {
- basic.toggleSubscript();
- }
-
- public void toggleSuperscript() {
- basic.toggleSuperscript();
- }
-
- public void toggleUnderline() {
- basic.toggleUnderline();
- }
-
- public void undo() {
- extended.undo();
- }
-
- public void unlink() {
- extended.removeLink();
- }
-
- protected void fireEdit() {
- presenter.fireOnEdit();
- }
-
- /**
- * Updates the status of all the stateful buttons.
- */
- private void updateStatus() {
- presenter.updateStatus();
- }
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,761 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.actions.ActionAddCondition;
-import org.ourproject.kune.platf.client.actions.ActionCollection;
-import org.ourproject.kune.platf.client.actions.ActionDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionEnableCondition;
-import org.ourproject.kune.platf.client.actions.ActionItem;
-import org.ourproject.kune.platf.client.actions.ActionItemCollection;
-import org.ourproject.kune.platf.client.actions.ActionShortcut;
-import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator;
-import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarPushButtonDescriptor;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-import org.ourproject.kune.platf.client.dto.AccessRolDTO;
-import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-import org.ourproject.kune.platf.client.state.Session;
-import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
-import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtml;
-import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImage;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElement;
-import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
-
-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;
-
-public class RTEditorPresenter implements RTEditor {
-
- private final String fontNames[] = { "Times New Roman", "Arial", "Courier New", "Georgia", "Trebuchet", "Verdana" };
- private final String fontSizes[] = { "Extra small", "Very small", "Small", "Medium", "Large", "Very large",
- "Extra large" };
- private static final RichTextArea.FontSize[] fontSizesConstants = new RichTextArea.FontSize[] {
- RichTextArea.FontSize.XX_SMALL, RichTextArea.FontSize.X_SMALL, RichTextArea.FontSize.SMALL,
- RichTextArea.FontSize.MEDIUM, RichTextArea.FontSize.LARGE, RichTextArea.FontSize.X_LARGE,
- RichTextArea.FontSize.XX_LARGE };
-
- private static final String EDIT_MENU = "Edit";
- private static final String INSERT_MENU = "Insert";
- private static final String FORMAT_MENU = "Format";
- private RTEditorView view;
- private boolean extended;
- private final AccessRolDTO accessRol;
- private final I18nTranslationService i18n;
- private final Session session;
- private final ActionItemCollection<Object> actions;
- private final RTEImgResources imgResources;
- private final RTEActionTopToolbar topBar;
- private final RTEActionSndToolbar sndBar;
- private ActionToolbarPushButtonDescriptor<Object> bold;
- private ActionToolbarPushButtonDescriptor<Object> italic;
- private ActionToolbarPushButtonDescriptor<Object> underline;
- private ActionToolbarPushButtonDescriptor<Object> strikethrough;
- private final Event0 onEdit;
- private final TextEditorInsertElement insertElement;
- private final ColorWebSafePalette palette;
- private final DeferredCommandWrapper deferred;
- private final ActionAddCondition<Object> canBeBasic;
- private final ActionAddCondition<Object> canBeExtended;
- private final Provider<EditHtml> editHtmlDialog;
- private final Provider<InsertImage> insertImageDialog;
-
- public RTEditorPresenter(I18nTranslationService i18n, Session session, RTEActionTopToolbar topBar,
- RTEActionSndToolbar sndBar, RTEImgResources imgResources, TextEditorInsertElement textEditorInsertElement,
- ColorWebSafePalette palette, Provider<EditHtml> editHtmlDialog, Provider<InsertImage> insertImageDialog,
- DeferredCommandWrapper deferred) {
- this.i18n = i18n;
- this.session = session;
- this.topBar = topBar;
- this.sndBar = sndBar;
- this.insertElement = textEditorInsertElement;
- this.palette = palette;
- this.editHtmlDialog = editHtmlDialog;
- this.insertImageDialog = insertImageDialog;
- this.deferred = deferred;
- styleToolbar(sndBar);
- sndBar.attach();
- this.imgResources = imgResources;
- extended = true;
- accessRol = AccessRolDTO.Editor;
- actions = new ActionItemCollection<Object>();
- this.onEdit = new Event0("onRTEEdit");
- canBeBasic = new ActionAddCondition<Object>() {
- public boolean mustBeAdded(Object param) {
- return view.canBeBasic();
- }
- };
- canBeExtended = new ActionAddCondition<Object>() {
- public boolean mustBeAdded(Object param) {
- return isExtended();
- }
- };
- }
-
- public void addAction(ActionDescriptor<Object> action) {
- actions.add(withNoItem(action));
- }
-
- public void addActions(ActionCollection<Object> actioncollection) {
- actions.addAll(withNoItem(actioncollection));
- }
-
- public void addOnEditListener(final Listener0 listener) {
- onEdit.add(listener);
- }
-
- public void adjustSize(final int height) {
- view.adjustSize(height);
- }
-
- public void attach() {
- topBar.clear();
- sndBar.clear();
- topBar.addActions(actions, topbar);
- sndBar.addActions(actions, sndbar);
- view.addActions(actions);
- }
-
- public ActionAddCondition<Object> canBeBasic() {
- return canBeBasic();
- }
-
- public ActionAddCondition<Object> canBeExtended() {
- return canBeExtended();
- }
-
- public void fireOnEdit() {
- onEdit.fire();
- }
-
- public View getEditorArea() {
- return view;
- }
-
- public String getHtml() {
- return view.getHtml();
- }
-
- public ActionToolbar<Object> getSndBar() {
- return sndBar;
- }
-
- public String getText() {
- return view.getText();
- }
-
- public ActionToolbar<Object> getTopBar() {
- return topBar;
- }
-
- public void init(RTEditorView view) {
- this.view = view;
- createBasicActions();
- }
-
- public void onEditorFocus() {
- topBar.hideAllMenus();
- sndBar.hideAllMenus();
- palette.hide();
- }
-
- public void reset() {
- topBar.clear();
- sndBar.clear();
- }
-
- public void setExtended(boolean extended) {
- this.extended = extended;
- }
-
- public void setHtml(String html) {
- view.setHtml(html);
- view.focus();
- }
-
- public void setText(String text) {
- view.setText(text);
- view.focus();
- }
-
- public void updateStatus() {
- if (view.canBeBasic()) {
- sndBar.setPushButtonPressed(bold, view.isBold());
- sndBar.setPushButtonPressed(italic, view.isItalic());
- sndBar.setPushButtonPressed(underline, view.isUnderlined());
- }
- if (isExtended()) {
- sndBar.setPushButtonPressed(strikethrough, view.isStrikethrough());
- }
- }
-
- private void createBasicActions() {
- ActionToolbarMenuDescriptor<Object> selectAll = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
- new Listener0() {
- public void onEvent() {
- view.selectAll();
- }
- });
- selectAll.setIconCls(getCssName(imgResources.selectall()));
- selectAll.setShortcut(new ActionShortcut(true, 'A'));
- selectAll.setTextDescription(i18n.t("Select all"));
- selectAll.setParentMenuTitle(i18n.t(EDIT_MENU));
- selectAll.setAddCondition(canBeBasic);
- selectAll.setTopSeparator(true);
- selectAll.setBottomSeparator(true);
-
- bold = new ActionToolbarPushButtonDescriptor<Object>(accessRol, sndbar, new Listener0() {
- public void onEvent() {
- view.toggleBold();
- fireOnEdit();
- }
- });
- bold.setIconCls(getCssName(imgResources.bold()));
- bold.setToolTip(i18n.t("Bold"));
- bold.setShortcut(new ActionShortcut(true, 'B'));
- bold.setAddCondition(canBeBasic);
-
- italic = new ActionToolbarPushButtonDescriptor<Object>(accessRol, sndbar, new Listener0() {
- public void onEvent() {
- view.toggleItalic();
- fireOnEdit();
- }
- });
- italic.setIconCls(getCssName(imgResources.italic()));
- italic.setToolTip(i18n.t("Italic"));
- italic.setShortcut(new ActionShortcut(true, 'I'));
- italic.setAddCondition(canBeBasic);
- italic.setAddCondition(canBeBasic);
-
- underline = new ActionToolbarPushButtonDescriptor<Object>(accessRol, sndbar, new Listener0() {
- public void onEvent() {
- view.toggleUnderline();
- fireOnEdit();
- }
- });
- underline.setIconCls(getCssName(imgResources.underline()));
- underline.setToolTip(i18n.t("Underline"));
- underline.setShortcut(new ActionShortcut(true, 'U'));
- underline.setAddCondition(canBeBasic);
-
- ActionToolbarMenuDescriptor<Object> subscript = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
- new Listener0() {
- public void onEvent() {
- view.toggleSubscript();
- fireOnEdit();
- }
- });
- subscript.setParentMenuTitle(i18n.t(FORMAT_MENU));
- subscript.setTextDescription(i18n.t("Subscript"));
- subscript.setIconCls(getCssName(imgResources.subscript()));
- subscript.setShortcut(new ActionShortcut(true, '0'));
- subscript.setAddCondition(canBeBasic);
-
- ActionToolbarMenuDescriptor<Object> superscript = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
- new Listener0() {
- public void onEvent() {
- view.toggleSuperscript();
- fireOnEdit();
- }
- });
- superscript.setParentMenuTitle(i18n.t(FORMAT_MENU));
- superscript.setTextDescription(i18n.t("Superscript"));
- superscript.setIconCls(getCssName(imgResources.superscript()));
- superscript.setShortcut(new ActionShortcut(true, '9'));
- superscript.setAddCondition(canBeBasic);
-
- ActionToolbarButtonDescriptor<Object> justifyLeft = new ActionToolbarButtonDescriptor<Object>(accessRol,
- sndbar, new Listener0() {
- public void onEvent() {
- view.justifyLeft();
- fireOnEdit();
- }
- });
- justifyLeft.setIconCls(getCssName(imgResources.alignleft()));
- justifyLeft.setToolTip(i18n.t("Left Justify"));
- justifyLeft.setShortcut(new ActionShortcut(true, 'L'));
- justifyLeft.setAddCondition(canBeBasic);
-
- ActionToolbarButtonDescriptor<Object> justifyCentre = new ActionToolbarButtonDescriptor<Object>(accessRol,
- sndbar, new Listener0() {
- public void onEvent() {
- view.justifyCenter();
- fireOnEdit();
- }
- });
- justifyCentre.setIconCls(getCssName(imgResources.centerpara()));
- justifyCentre.setToolTip(i18n.t("Centre Justify"));
- justifyCentre.setShortcut(new ActionShortcut(true, 'E'));
- justifyCentre.setAddCondition(canBeBasic);
-
- ActionToolbarButtonDescriptor<Object> justifyRight = new ActionToolbarButtonDescriptor<Object>(accessRol,
- sndbar, new Listener0() {
- public void onEvent() {
- view.justifyRight();
- fireOnEdit();
- }
- });
- justifyRight.setIconCls(getCssName(imgResources.alignright()));
- justifyRight.setToolTip(i18n.t("Right Justify"));
- justifyRight.setShortcut(new ActionShortcut(true, 'R'));
- justifyRight.setAddCondition(canBeBasic);
-
- ActionToolbarMenuDescriptor<Object> undo = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
- new Listener0() {
- public void onEvent() {
- view.undo();
- fireOnEdit();
- }
- });
- undo.setShortcut(new ActionShortcut(true, 'Z'));
- undo.setTextDescription(i18n.t("Undo"));
- undo.setParentMenuTitle(i18n.t(EDIT_MENU));
- undo.setAddCondition(canBeExtended);
- undo.setIconCls(getCssName(imgResources.undo()));
-
- ActionToolbarMenuDescriptor<Object> redo = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
- new Listener0() {
- public void onEvent() {
- view.redo();
- fireOnEdit();
- }
- });
- redo.setShortcut(new ActionShortcut(true, 'Y'));
- redo.setTextDescription(i18n.t("Redo"));
- redo.setParentMenuTitle(i18n.t(EDIT_MENU));
- redo.setAddCondition(canBeExtended);
- redo.setBottomSeparator(true);
- redo.setIconCls(getCssName(imgResources.redo()));
-
- ActionToolbarButtonDescriptor<Object> undoBtn = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
- new Listener0() {
- public void onEvent() {
- view.undo();
- fireOnEdit();
- }
- });
- undoBtn.setToolTip(i18n.t("Undo"));
- undoBtn.setAddCondition(canBeExtended);
- undoBtn.setIconCls(getCssName(imgResources.undo()));
- undoBtn.setPosition(0);
-
- ActionToolbarButtonDescriptor<Object> redoBtn = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
- new Listener0() {
- public void onEvent() {
- view.redo();
- fireOnEdit();
- }
- });
- redoBtn.setToolTip(i18n.t("Redo"));
- redoBtn.setAddCondition(canBeExtended);
- redoBtn.setIconCls(getCssName(imgResources.redo()));
- redoBtn.setPosition(1);
- redoBtn.setRightSeparator(ActionToolbarButtonSeparator.separator);
-
- ActionToolbarMenuDescriptor<Object> copy = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
- new Listener0() {
- public void onEvent() {
- view.copy();
- }
- });
- copy.setShortcut(new ActionShortcut(true, 'C'));
- copy.setTextDescription(i18n.t("Copy"));
- copy.setParentMenuTitle(i18n.t(EDIT_MENU));
- copy.setAddCondition(canBeExtended);
- copy.setIconCls(getCssName(imgResources.copy()));
-
- ActionToolbarMenuDescriptor<Object> cut = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
- new Listener0() {
- public void onEvent() {
- view.cut();
- fireOnEdit();
- }
- });
- cut.setShortcut(new ActionShortcut(true, 'X'));
- cut.setTextDescription(i18n.t("Cut"));
- cut.setParentMenuTitle(i18n.t(EDIT_MENU));
- cut.setAddCondition(canBeExtended);
- cut.setIconCls(getCssName(imgResources.cut()));
-
- ActionToolbarMenuDescriptor<Object> paste = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
- new Listener0() {
- public void onEvent() {
- view.paste();
- fireOnEdit();
- }
- });
- paste.setShortcut(new ActionShortcut(true, 'V'));
- paste.setTextDescription(i18n.t("Paste"));
- paste.setParentMenuTitle(i18n.t(EDIT_MENU));
- paste.setAddCondition(canBeExtended);
- paste.setIconCls(getCssName(imgResources.paste()));
-
- ActionToolbarMenuDescriptor<Object> editHtml = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
- new Listener0() {
- public void onEvent() {
- EditHtml dialog = editHtmlDialog.get();
- dialog.setUpdateListener(new Listener<String>() {
- public void onEvent(String html) {
- view.setHtml(html);
- fireOnEdit();
- }
- });
- dialog.show();
- dialog.setHtml(view.getHtml());
- }
- });
- editHtml.setIconCls(getCssName(imgResources.edithtml()));
- editHtml.setTextDescription(i18n.t("Edit HTML"));
- editHtml.setParentMenuTitle(i18n.t(EDIT_MENU));
- editHtml.setAddCondition(canBeExtended);
-
- ActionToolbarMenuDescriptor<Object> comment = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
- new Listener0() {
- public void onEvent() {
- view.focus();
- String author = session.isLogged() ? session.getCurrentUser().getShortName()
- : i18n.t("anonymous user");
- view.addComment(author);
- fireOnEdit();
- }
- });
- comment.setEnableCondition(new ActionEnableCondition<Object>() {
- public boolean mustBeEnabled(Object param) {
- return session.isLogged();
- }
- });
- comment.setShortcut(new ActionShortcut(true, 'M'));
- comment.setTextDescription(i18n.t("Comment..."));
- comment.setParentMenuTitle(i18n.t(INSERT_MENU));
- comment.setEnableCondition(isInsertHtmlSupported());
- comment.setAddCondition(canBeExtended);
-
- ActionToolbarMenuDescriptor<Object> hr = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
- new Listener0() {
- public void onEvent() {
- view.focus();
- view.insertHorizontalRule();
- fireOnEdit();
- }
- });
- hr.setTextDescription(i18n.t("Horizontal line"));
- hr.setShortcut(new ActionShortcut(true, true, ' ', "Space"));
- hr.setIconCls(getCssName(imgResources.hfixedline()));
- hr.setParentMenuTitle(i18n.t(INSERT_MENU));
- hr.setAddCondition(canBeExtended);
-
- ActionToolbarButtonDescriptor<Object> hrButton = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
- new Listener0() {
- public void onEvent() {
- view.focus();
- view.insertHorizontalRule();
- fireOnEdit();
- }
- });
- hrButton.setIconCls(getCssName(imgResources.hfixedline()));
- hrButton.setToolTip(i18n.t("Horizontal line"));
- hrButton.setAddCondition(canBeExtended);
-
- strikethrough = new ActionToolbarPushButtonDescriptor<Object>(accessRol, sndbar, new Listener0() {
- public void onEvent() {
- view.toggleStrikethrough();
- fireOnEdit();
- }
- });
- strikethrough.setIconCls(getCssName(imgResources.strikeout()));
- strikethrough.setToolTip(i18n.t("Strikethrough"));
- strikethrough.setRightSeparator(ActionToolbarButtonSeparator.separator);
- strikethrough.setAddCondition(canBeExtended);
-
- ActionToolbarButtonDescriptor<Object> decreaseIndent = new ActionToolbarButtonDescriptor<Object>(accessRol,
- sndbar, new Listener0() {
- public void onEvent() {
- view.leftIndent();
- fireOnEdit();
- }
- });
- decreaseIndent.setIconCls(getCssName(imgResources.decrementindent()));
- decreaseIndent.setToolTip(i18n.t("Decrease Indent"));
- decreaseIndent.setAddCondition(canBeExtended);
-
- ActionToolbarButtonDescriptor<Object> increaseIndent = new ActionToolbarButtonDescriptor<Object>(accessRol,
- sndbar, new Listener0() {
- public void onEvent() {
- view.rightIndent();
- fireOnEdit();
- }
- });
- increaseIndent.setIconCls(getCssName(imgResources.incrementindent()));
- increaseIndent.setToolTip(i18n.t("Increase Indent"));
- increaseIndent.setAddCondition(canBeExtended);
-
- ActionToolbarButtonDescriptor<Object> ol = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
- new Listener0() {
- public void onEvent() {
- view.insertOrderedList();
- fireOnEdit();
- }
- });
- ol.setIconCls(getCssName(imgResources.defaultnumbering()));
- ol.setToolTip(i18n.t("Numbered List"));
- ol.setShortcut(new ActionShortcut(true, '7'));
- ol.setAddCondition(canBeExtended);
-
- ActionToolbarButtonDescriptor<Object> ul = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
- new Listener0() {
- public void onEvent() {
- view.insertUnorderedList();
- fireOnEdit();
- }
- });
- ul.setIconCls(getCssName(imgResources.defaultbullet()));
- ul.setToolTip(i18n.t("Bullet List"));
- ul.setShortcut(new ActionShortcut(true, '8'));
- ul.setRightSeparator(ActionToolbarButtonSeparator.separator);
- ul.setAddCondition(canBeExtended);
-
- ActionToolbarButtonDescriptor<Object> img = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
- new Listener0() {
- public void onEvent() {
- insertImageDialog.get().show();
- }
- });
- img.setIconCls(getCssName(imgResources.images()));
- img.setToolTip(i18n.t("Insert Image"));
- img.setAddCondition(canBeExtended);
-
- ActionToolbarButtonDescriptor<Object> createLink = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
- new Listener0() {
- public void onEvent() {
- deferred.addCommand(new Listener0() {
- public void onEvent() {
- insertElement.show();
- }
- });
- }
- });
- createLink.setIconCls(getCssName(imgResources.link()));
- createLink.setToolTip(i18n.t("Create Link"));
- createLink.setShortcut(new ActionShortcut(true, 'K'));
- createLink.setAddCondition(canBeExtended);
- insertElement.addOnCreateLink(new Listener2<String, String>() {
- public void onEvent(String name, String url) {
- view.createLink(url);
- fireOnEdit();
- }
- });
-
- ActionToolbarButtonDescriptor<Object> removeLink = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
- new Listener0() {
- public void onEvent() {
- view.unlink();
- fireOnEdit();
- }
- });
- removeLink.setIconCls(getCssName(imgResources.linkbreak()));
- removeLink.setToolTip(i18n.t("Remove Link"));
- removeLink.setShortcut(new ActionShortcut(true, true, 'K'));
- removeLink.setAddCondition(canBeExtended);
-
- final ActionToolbarButtonDescriptor<Object> removeFormat = new ActionToolbarButtonDescriptor<Object>(accessRol,
- sndbar, new Listener0() {
- public void onEvent() {
- view.removeFormat();
- fireOnEdit();
- }
- });
- removeFormat.setIconCls(getCssName(imgResources.removeFormat()));
- removeFormat.setToolTip(i18n.t("Clear Formatting"));
- removeFormat.setShortcut(new ActionShortcut(true, ' ', "Space"));
- removeFormat.setAddCondition(canBeExtended);
- removeFormat.setRightSeparator(ActionToolbarButtonSeparator.separator);
-
- final ActionToolbarMenuDescriptor<Object> insertTable = new ActionToolbarMenuDescriptor<Object>(accessRol,
- topbar, new Listener0() {
- public void onEvent() {
- insertSimpleTable();
- }
- });
- insertTable.setIconCls(getCssName(imgResources.inserttable()));
- insertTable.setTextDescription(i18n.t("Insert Table ..."));
- insertTable.setAddCondition(canBeExtended);
- insertTable.setParentMenuTitle(i18n.t(INSERT_MENU));
-
- final ActionToolbarButtonDescriptor<Object> insertTableBtn = new ActionToolbarButtonDescriptor<Object>(
- accessRol, sndbar, new Listener0() {
- public void onEvent() {
- insertSimpleTable();
- }
- });
- insertTableBtn.setIconCls(getCssName(imgResources.inserttable()));
- insertTableBtn.setToolTip(i18n.t("Insert Table"));
- insertTableBtn.setAddCondition(canBeExtended);
- insertTableBtn.setRightSeparator(ActionToolbarButtonSeparator.separator);
-
- final ActionToolbarButtonDescriptor<Object> fontColor = new ActionToolbarButtonDescriptor<Object>(accessRol,
- sndbar, new Listener0() {
- public void onEvent() {
- palette.show(getActionLeftPosition(sndBar, removeFormat), getActionTopPosition(sndBar,
- removeFormat), new Listener<String>() {
- public void onEvent(String color) {
- palette.hide();
- view.setForeColor(color);
- fireOnEdit();
- }
- });
- }
- });
- fontColor.setIconCls(getCssName(imgResources.fontcolor()));
- fontColor.setToolTip(i18n.t("Text Colour"));
- fontColor.setAddCondition(canBeBasic);
-
- ActionToolbarButtonDescriptor<Object> backgroundColor = new ActionToolbarButtonDescriptor<Object>(accessRol,
- sndbar, new Listener0() {
- public void onEvent() {
- palette.show(getActionLeftPosition(sndBar, fontColor), getActionTopPosition(sndBar, fontColor),
- new Listener<String>() {
- public void onEvent(String color) {
- palette.hide();
- view.setBackColor(color);
- fireOnEdit();
- }
- });
- }
- });
- backgroundColor.setIconCls(getCssName(imgResources.backcolor()));
- backgroundColor.setToolTip(i18n.t("Text Background Colour"));
- backgroundColor.setAddCondition(canBeBasic);
-
- actions.add(withNoItem(bold));
- actions.add(withNoItem(italic));
- actions.add(withNoItem(underline));
- actions.add(withNoItem(strikethrough));
-
- actions.add(withNoItem(justifyLeft));
- actions.add(withNoItem(justifyCentre));
- actions.add(withNoItem(justifyRight));
-
- actions.add(withNoItem(undo));
- actions.add(withNoItem(redo));
- actions.add(withNoItem(copy));
- actions.add(withNoItem(cut));
- actions.add(withNoItem(paste));
- actions.add(withNoItem(selectAll));
- actions.add(withNoItem(editHtml));
- actions.add(withNoItem(hr));
- actions.add(withNoItem(subscript));
- actions.add(withNoItem(superscript));
- actions.add(withNoItem(decreaseIndent));
- actions.add(withNoItem(increaseIndent));
- actions.add(withNoItem(ol));
- actions.add(withNoItem(ul));
- actions.add(withNoItem(removeFormat));
- // topActions.add(withNoItem(hrButton));
- actions.add(withNoItem(img));
- actions.add(withNoItem(createLink));
- actions.add(withNoItem(removeLink));
- actions.add(withNoItem(insertTableBtn));
- actions.add(withNoItem(insertTable));
- actions.add(withNoItem(comment));
- actions.add(withNoItem(undoBtn));
- actions.add(withNoItem(redoBtn));
-
- for (String fontName : this.fontNames) {
- ActionToolbarMenuDescriptor<Object> fontNameAction = createFontNameAction(canBeBasic, fontName);
- actions.add(withNoItem(fontNameAction));
- }
- for (int fontSize = 0; fontSize < fontSizes.length; fontSize++) {
- ActionToolbarMenuDescriptor<Object> fontSizeAction = createFontSizeAction(canBeBasic, fontSize,
- fontSizes[fontSize]);
- actions.add(withNoItem(fontSizeAction));
- }
- actions.add(withNoItem(fontColor));
- actions.add(withNoItem(backgroundColor));
- }
-
- private ActionToolbarMenuDescriptor<Object> createFontNameAction(ActionAddCondition<Object> canBeBasic,
- final String fontName) {
- final ActionToolbarMenuDescriptor<Object> font = new ActionToolbarMenuDescriptor<Object>(accessRol, sndbar,
- new Listener0() {
- public void onEvent() {
- view.setFontName(fontName);
- fireOnEdit();
- }
- });
- font.setTextDescription("<span style=\"font-family: " + fontName + "\">" + fontName + "</span>");
- font.setParentMenuTooltip(i18n.t("Font"));
- font.setParentMenuIconCls(getCssName(imgResources.charfontname()));
- font.setAddCondition(canBeBasic);
- return font;
- }
-
- private ActionToolbarMenuDescriptor<Object> createFontSizeAction(ActionAddCondition<Object> canBeBasic,
- final int fontSize, String fontSizeName) {
- final ActionToolbarMenuDescriptor<Object> font = new ActionToolbarMenuDescriptor<Object>(accessRol, sndbar,
- new Listener0() {
- public void onEvent() {
- view.setFontSize(fontSizesConstants[fontSize]);
- fireOnEdit();
- }
- });
- font.setTextDescription("<font size=\"" + (fontSize + 1) + "\">" + i18n.t(fontSizeName) + "</font>");
- font.setParentMenuTooltip(i18n.t("Font size"));
- font.setParentMenuIconCls(getCssName(imgResources.fontheight()));
- font.setAddCondition(canBeBasic);
- return font;
- }
-
- private int getActionLeftPosition(ActionToolbar<Object> bar, ActionToolbarButtonDescriptor<Object> action) {
- return bar.getLeftPosition(action);
- }
-
- private int getActionTopPosition(ActionToolbar<Object> bar, ActionToolbarButtonDescriptor<Object> action) {
- return bar.getTopPosition(action);
- }
-
- private String getCssName(ImageResource imageResource) {
- return RTEImgResources.SUFFIX + imageResource.getName();
- }
-
- private void insertSimpleTable() {
- view.insertHtml("<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">\n" + "<tbody>\n"
- + "<tr>\n" + "<td width=\"50%\"><br>\n" + "</td>\n" + "<td width=\"50%\"><br>\n" + "</td>\n"
- + "</tr>\n" + "<tr>\n" + "<td width=\"50%\"><br>\n" + "</td>\n" + "<td width=\"50%\"><br>\n"
- + "</td>\n" + "</tr>\n</tbody>\n</table>");
- fireOnEdit();
- }
-
- private boolean isExtended() {
- return extended && view.canBeExtended();
- }
-
- private ActionEnableCondition<Object> isInsertHtmlSupported() {
- return new ActionEnableCondition<Object>() {
- public boolean mustBeEnabled(Object param) {
- return true;
- }
- };
- }
-
- private void styleToolbar(ActionToolbar<Object> bar) {
- bar.setNormalStyle();
- }
-
- private ActionItemCollection<Object> withNoItem(ActionCollection<Object> actions) {
- ActionItemCollection<Object> collection = new ActionItemCollection<Object>();
- for (ActionDescriptor<Object> action : actions) {
- // this action don't have a associated item
- collection.add(withNoItem(action));
- }
- return collection;
- }
-
- private ActionItem<Object> withNoItem(ActionDescriptor<Object> action) {
- return new ActionItem<Object>(action, null);
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,102 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-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;
-
-public interface RTEditorView extends View {
-
- void addActions(ActionItemCollection<Object> actions);
-
- void addComment(String userName);
-
- void adjustSize(int height);
-
- boolean canBeBasic();
-
- boolean canBeExtended();
-
- void copy();
-
- void createLink(String url);
-
- void cut();
-
- void delete();
-
- void focus();
-
- String getHtml();
-
- String getText();
-
- void insertHorizontalRule();
-
- void insertHtml(String html);
-
- void insertImage(String url);
-
- void insertOrderedList();
-
- void insertUnorderedList();
-
- boolean isAttached();
-
- boolean isBold();
-
- boolean isItalic();
-
- boolean isStrikethrough();
-
- boolean isSubscript();
-
- boolean isSuperscript();
-
- boolean isUnderlined();
-
- void justifyCenter();
-
- void justifyLeft();
-
- void justifyRight();
-
- void leftIndent();
-
- void paste();
-
- void redo();
-
- void removeFormat();
-
- void rightIndent();
-
- void selectAll();
-
- void setBackColor(String color);
-
- void setFontName(String name);
-
- void setFontSize(FontSize fontSize);
-
- void setForeColor(String color);
-
- void setHtml(String html);
-
- void setText(String text);
-
- void toggleBold();
-
- void toggleItalic();
-
- void toggleStrikethrough();
-
- void toggleSubscript();
-
- void toggleSuperscript();
-
- void toggleUnderline();
-
- void undo();
-
- void unlink();
-}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -2,6 +2,9 @@
import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPanel;
import org.ourproject.kune.platf.client.ui.dialogs.BasicDialog;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPanel;
+import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditor;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbar.java (from rev 1055, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbar.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbar.java 2009-03-03 01:35:36 UTC (rev 1055)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbar.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,7 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
+
+public interface RTEActionSndToolbar extends ActionToolbar<Object> {
+
+}
\ No newline at end of file
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbarPresenter.java (from rev 1055, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbarPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbarPresenter.java 2009-03-03 01:35:36 UTC (rev 1055)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbarPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,12 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPresenter;
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarView;
+
+public class RTEActionSndToolbarPresenter extends ActionToolbarPresenter<Object> implements RTEActionSndToolbar {
+
+ public RTEActionSndToolbarPresenter(ActionToolbarView<Object> toolbar) {
+ super(toolbar);
+ }
+
+}
\ No newline at end of file
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbar.java (from rev 1055, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbar.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbar.java 2009-03-03 01:35:36 UTC (rev 1055)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbar.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,7 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
+
+public interface RTEActionTopToolbar extends ActionToolbar<Object> {
+
+}
\ No newline at end of file
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbarPresenter.java (from rev 1055, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbarPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbarPresenter.java 2009-03-03 01:35:36 UTC (rev 1055)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbarPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,12 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPresenter;
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarView;
+
+public class RTEActionTopToolbarPresenter extends ActionToolbarPresenter<Object> implements RTEActionTopToolbar {
+
+ public RTEActionTopToolbarPresenter(ActionToolbarView<Object> toolbar) {
+ super(toolbar);
+ }
+
+}
\ No newline at end of file
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEcanBeBasic.java (from rev 1064, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEcanBeBasic.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEcanBeBasic.java 2009-03-10 00:05:50 UTC (rev 1064)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEcanBeBasic.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,10 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import org.ourproject.kune.platf.client.actions.ActionAddCondition;
+
+public class RTEcanBeBasic implements ActionAddCondition<Object> {
+ public boolean mustBeAdded(Object param) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditor.java (from rev 1064, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java 2009-03-10 00:05:50 UTC (rev 1064)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditor.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,46 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.actions.ActionAddCondition;
+import org.ourproject.kune.platf.client.actions.ActionCollection;
+import org.ourproject.kune.platf.client.actions.ActionDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionToolbarPosition;
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
+
+import com.calclab.suco.client.events.Listener0;
+
+public interface RTEditor {
+
+ public final ActionToolbarPosition topbar = new ActionToolbarPosition("rte-topbar");
+ public final ActionToolbarPosition sndbar = new ActionToolbarPosition("rte-sndbar");;
+
+ void addAction(ActionDescriptor<Object> action);
+
+ void addActions(ActionCollection<Object> actions);
+
+ void addOnEditListener(Listener0 listener);
+
+ void attach();
+
+ ActionAddCondition<Object> canBeBasic();
+
+ ActionAddCondition<Object> canBeExtended();
+
+ View getEditorArea();
+
+ String getHtml();
+
+ ActionToolbar<Object> getSndBar();
+
+ String getText();
+
+ ActionToolbar<Object> getTopBar();
+
+ void reset();
+
+ void setExtended(boolean extended);
+
+ void setHtml(String html);
+
+ void setText(String text);
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java (from rev 1066, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java 2009-03-10 13:43:43 UTC (rev 1066)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,319 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import java.util.Date;
+import java.util.HashMap;
+
+import org.ourproject.kune.platf.client.actions.ActionDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionItem;
+import org.ourproject.kune.platf.client.actions.ActionItemCollection;
+import org.ourproject.kune.platf.client.actions.ActionManager;
+import org.ourproject.kune.platf.client.actions.ActionShortcut;
+import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
+import org.ourproject.kune.platf.client.ui.rte.RichTextArea;
+import org.ourproject.kune.platf.client.ui.rte.RichTextArea.BasicFormatter;
+import org.ourproject.kune.platf.client.ui.rte.RichTextArea.ExtendedFormatter;
+import org.ourproject.kune.platf.client.ui.rte.RichTextArea.FontSize;
+import org.ourproject.kune.platf.client.ui.rte.RichTextArea.Justification;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.ChangeListener;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.FocusListener;
+import com.google.gwt.user.client.ui.KeyboardListener;
+import com.google.gwt.user.client.ui.Widget;
+
+public class RTEditorPanel implements RTEditorView {
+
+ private class EventListener implements ClickListener, ChangeListener, KeyboardListener, FocusListener {
+
+ public void onChange(Widget sender) {
+ presenter.fireOnEdit();
+ }
+
+ public void onClick(Widget sender) {
+ if (sender == rta) {
+ // We use the RichTextArea's onKeyUp event to update the
+ // toolbar status. This will catch any cases where the user
+ // moves the cursor using the keyboard, or uses one of the
+ // browser's built-in keyboard shortcuts.
+ updateStatus();
+ }
+ }
+
+ public void onFocus(Widget sender) {
+ presenter.onEditorFocus();
+ }
+
+ public void onKeyDown(final Widget sender, final char keyCode, final int modifiers) {
+ }
+
+ public void onKeyPress(final Widget sender, final char keyCode, final int modifiers) {
+ }
+
+ public void onKeyUp(final Widget sender, final char keyCode, final int modifiers) {
+ if (sender == rta) {
+ // We use the RichTextArea's onKeyUp event to update the
+ // toolbar status.
+ // This will catch any cases where the user moves the cursor
+ // using the keyboard, or uses one of the browser's built-in
+ // keyboard shortcuts.
+
+ updateStatus();
+ fireEdit();
+ if (modifiers != 0) {
+ Log.debug("RTE shortcut pressed (" + modifiers + ", " + keyCode + ")");
+ ActionItem<Object> actionItem = shortcuts.get(new ActionShortcut(keyCode, modifiers));
+ if (actionItem != null) {
+ actionManager.doAction(actionItem);
+ updateStatus();
+ } else {
+ Log.debug("...but not mapped to any action");
+ }
+ }
+ }
+ }
+
+ public void onLostFocus(Widget sender) {
+
+ }
+ }
+ private final I18nUITranslationService i18n;
+ private final RichTextArea rta;
+ private final BasicFormatter basic;
+ private final ExtendedFormatter extended;
+ private final HashMap<ActionShortcut, ActionItem<Object>> shortcuts;
+ private final ActionManager actionManager;
+ private final RTEditorPresenter presenter;
+
+ public RTEditorPanel(final RTEditorPresenter presenter, I18nUITranslationService i18n, ActionManager actionManager) {
+ this.presenter = presenter;
+ this.i18n = i18n;
+ this.actionManager = actionManager;
+ rta = new RichTextArea();
+ basic = rta.getBasicFormatter();
+ extended = rta.getExtendedFormatter();
+ shortcuts = new HashMap<ActionShortcut, ActionItem<Object>>();
+ EventListener listener = new EventListener();
+ rta.addClickListener(listener);
+ rta.addKeyboardListener(listener);
+ rta.addFocusListener(listener);
+ rta.setWidth("96%");
+ rta.setHeight("100%");
+ }
+
+ public void addActions(ActionItemCollection<Object> actionItems) {
+ for (ActionItem<Object> actionItem : actionItems) {
+ ActionDescriptor<Object> action = actionItem.getAction();
+ if (action.hasShortcut() && action.mustBeAdded(null)) {
+ ActionShortcut shortcut = action.getShortcut();
+ shortcuts.put(shortcut, actionItem);
+ }
+ }
+ }
+
+ public void addComment(String userName) {
+ String time = i18n.formatDateWithLocale(new Date(), true);
+ Element span = DOM.createSpan();
+ span.setInnerHTML("<em>" + i18n.t("type your comment here") + "</em> -" + userName + " " + time);
+ DOM.setElementProperty(span.<com.google.gwt.user.client.Element> cast(), "className", "k-rte-comment");
+ insertHtml(" " + span.getString() + " ");
+ }
+
+ public void adjustSize(int height) {
+ rta.setHeight("" + height);
+ }
+
+ public boolean canBeBasic() {
+ return basic != null;
+ }
+
+ public boolean canBeExtended() {
+ return extended != null;
+ }
+
+ public void copy() {
+ extended.copy();
+ }
+
+ public void createLink(String url) {
+ extended.createLink(url);
+ }
+
+ public void cut() {
+ extended.cut();
+ }
+
+ public void delete() {
+ extended.delete();
+ }
+
+ public void focus() {
+ rta.setFocus(true);
+ }
+
+ public String getHtml() {
+ return rta.getHTML();
+ }
+
+ public Widget getRTE() {
+ return rta;
+ }
+
+ public String getText() {
+ return rta.getText();
+ }
+
+ public void insertHorizontalRule() {
+ extended.insertHorizontalRule();
+ }
+
+ public void insertHtml(String html) {
+ extended.insertHtml(html);
+ }
+
+ public void insertImage(String url) {
+ extended.insertImage(url);
+ }
+
+ public void insertOrderedList() {
+ extended.insertOrderedList();
+ }
+
+ public void insertUnorderedList() {
+ extended.insertUnorderedList();
+ }
+
+ public boolean isAttached() {
+ return rta.isAttached();
+ }
+
+ public boolean isBold() {
+ return basic.isBold();
+ }
+
+ public boolean isItalic() {
+ return basic.isItalic();
+ }
+
+ public boolean isStrikethrough() {
+ return extended.isStrikethrough();
+ }
+
+ public boolean isSubscript() {
+ return basic.isSubscript();
+ }
+
+ public boolean isSuperscript() {
+ return basic.isSuperscript();
+ }
+
+ public boolean isUnderlined() {
+ return basic.isUnderlined();
+ }
+
+ public void justifyCenter() {
+ basic.setJustification(Justification.CENTER);
+ }
+
+ public void justifyLeft() {
+ basic.setJustification(Justification.LEFT);
+ }
+
+ public void justifyRight() {
+ basic.setJustification(Justification.RIGHT);
+ }
+
+ public void leftIndent() {
+ extended.leftIndent();
+ }
+
+ public void paste() {
+ extended.paste();
+ }
+
+ public void redo() {
+ extended.redo();
+ }
+
+ public void removeFormat() {
+ extended.removeFormat();
+ }
+
+ public void rightIndent() {
+ extended.rightIndent();
+ }
+
+ public void selectAll() {
+ basic.selectAll();
+ }
+
+ public void setBackColor(String color) {
+ basic.setBackColor(color);
+ }
+
+ public void setFontName(String name) {
+ basic.setFontName(name);
+ }
+
+ public void setFontSize(FontSize size) {
+ basic.setFontSize(size);
+ }
+
+ public void setForeColor(String color) {
+ basic.setForeColor(color);
+ }
+
+ public void setHtml(String html) {
+ rta.setHTML(html);
+ }
+
+ public void setText(String text) {
+ rta.setText(text);
+ }
+
+ public void toggleBold() {
+ basic.toggleBold();
+ }
+
+ public void toggleItalic() {
+ basic.toggleItalic();
+ }
+
+ public void toggleStrikethrough() {
+ extended.toggleStrikethrough();
+ }
+
+ public void toggleSubscript() {
+ basic.toggleSubscript();
+ }
+
+ public void toggleSuperscript() {
+ basic.toggleSuperscript();
+ }
+
+ public void toggleUnderline() {
+ basic.toggleUnderline();
+ }
+
+ public void undo() {
+ extended.undo();
+ }
+
+ public void unlink() {
+ extended.removeLink();
+ }
+
+ protected void fireEdit() {
+ presenter.fireOnEdit();
+ }
+
+ /**
+ * Updates the status of all the stateful buttons.
+ */
+ private void updateStatus() {
+ presenter.updateStatus();
+ }
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,762 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.actions.ActionAddCondition;
+import org.ourproject.kune.platf.client.actions.ActionCollection;
+import org.ourproject.kune.platf.client.actions.ActionDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionEnableCondition;
+import org.ourproject.kune.platf.client.actions.ActionItem;
+import org.ourproject.kune.platf.client.actions.ActionItemCollection;
+import org.ourproject.kune.platf.client.actions.ActionShortcut;
+import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator;
+import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionToolbarPushButtonDescriptor;
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
+import org.ourproject.kune.platf.client.dto.AccessRolDTO;
+import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+import org.ourproject.kune.platf.client.state.Session;
+import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
+import org.ourproject.kune.platf.client.ui.rte.RichTextArea;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtml;
+import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImage;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElement;
+import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
+
+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;
+
+public class RTEditorPresenter implements RTEditor {
+
+ private final String fontNames[] = { "Times New Roman", "Arial", "Courier New", "Georgia", "Trebuchet", "Verdana" };
+ private final String fontSizes[] = { "Extra small", "Very small", "Small", "Medium", "Large", "Very large",
+ "Extra large" };
+ private static final RichTextArea.FontSize[] fontSizesConstants = new RichTextArea.FontSize[] {
+ RichTextArea.FontSize.XX_SMALL, RichTextArea.FontSize.X_SMALL, RichTextArea.FontSize.SMALL,
+ RichTextArea.FontSize.MEDIUM, RichTextArea.FontSize.LARGE, RichTextArea.FontSize.X_LARGE,
+ RichTextArea.FontSize.XX_LARGE };
+
+ private static final String EDIT_MENU = "Edit";
+ private static final String INSERT_MENU = "Insert";
+ private static final String FORMAT_MENU = "Format";
+ private RTEditorView view;
+ private boolean extended;
+ private final AccessRolDTO accessRol;
+ private final I18nTranslationService i18n;
+ private final Session session;
+ private final ActionItemCollection<Object> actions;
+ private final RTEImgResources imgResources;
+ private final RTEActionTopToolbar topBar;
+ private final RTEActionSndToolbar sndBar;
+ private ActionToolbarPushButtonDescriptor<Object> bold;
+ private ActionToolbarPushButtonDescriptor<Object> italic;
+ private ActionToolbarPushButtonDescriptor<Object> underline;
+ private ActionToolbarPushButtonDescriptor<Object> strikethrough;
+ private final Event0 onEdit;
+ private final TextEditorInsertElement insertElement;
+ private final ColorWebSafePalette palette;
+ private final DeferredCommandWrapper deferred;
+ private final ActionAddCondition<Object> canBeBasic;
+ private final ActionAddCondition<Object> canBeExtended;
+ private final Provider<EditHtml> editHtmlDialog;
+ private final Provider<InsertImage> insertImageDialog;
+
+ public RTEditorPresenter(I18nTranslationService i18n, Session session, RTEActionTopToolbar topBar,
+ RTEActionSndToolbar sndBar, RTEImgResources imgResources, TextEditorInsertElement textEditorInsertElement,
+ ColorWebSafePalette palette, Provider<EditHtml> editHtmlDialog, Provider<InsertImage> insertImageDialog,
+ DeferredCommandWrapper deferred) {
+ this.i18n = i18n;
+ this.session = session;
+ this.topBar = topBar;
+ this.sndBar = sndBar;
+ this.insertElement = textEditorInsertElement;
+ this.palette = palette;
+ this.editHtmlDialog = editHtmlDialog;
+ this.insertImageDialog = insertImageDialog;
+ this.deferred = deferred;
+ styleToolbar(sndBar);
+ sndBar.attach();
+ this.imgResources = imgResources;
+ extended = true;
+ accessRol = AccessRolDTO.Editor;
+ actions = new ActionItemCollection<Object>();
+ this.onEdit = new Event0("onRTEEdit");
+ canBeBasic = new ActionAddCondition<Object>() {
+ public boolean mustBeAdded(Object param) {
+ return view.canBeBasic();
+ }
+ };
+ canBeExtended = new ActionAddCondition<Object>() {
+ public boolean mustBeAdded(Object param) {
+ return isExtended();
+ }
+ };
+ }
+
+ public void addAction(ActionDescriptor<Object> action) {
+ actions.add(withNoItem(action));
+ }
+
+ public void addActions(ActionCollection<Object> actioncollection) {
+ actions.addAll(withNoItem(actioncollection));
+ }
+
+ public void addOnEditListener(final Listener0 listener) {
+ onEdit.add(listener);
+ }
+
+ public void adjustSize(final int height) {
+ view.adjustSize(height);
+ }
+
+ public void attach() {
+ topBar.clear();
+ sndBar.clear();
+ topBar.addActions(actions, topbar);
+ sndBar.addActions(actions, sndbar);
+ view.addActions(actions);
+ }
+
+ public ActionAddCondition<Object> canBeBasic() {
+ return canBeBasic();
+ }
+
+ public ActionAddCondition<Object> canBeExtended() {
+ return canBeExtended();
+ }
+
+ public void fireOnEdit() {
+ onEdit.fire();
+ }
+
+ public View getEditorArea() {
+ return view;
+ }
+
+ public String getHtml() {
+ return view.getHtml();
+ }
+
+ public ActionToolbar<Object> getSndBar() {
+ return sndBar;
+ }
+
+ public String getText() {
+ return view.getText();
+ }
+
+ public ActionToolbar<Object> getTopBar() {
+ return topBar;
+ }
+
+ public void init(RTEditorView view) {
+ this.view = view;
+ createBasicActions();
+ }
+
+ public void onEditorFocus() {
+ topBar.hideAllMenus();
+ sndBar.hideAllMenus();
+ palette.hide();
+ }
+
+ public void reset() {
+ topBar.clear();
+ sndBar.clear();
+ }
+
+ public void setExtended(boolean extended) {
+ this.extended = extended;
+ }
+
+ public void setHtml(String html) {
+ view.setHtml(html);
+ view.focus();
+ }
+
+ public void setText(String text) {
+ view.setText(text);
+ view.focus();
+ }
+
+ public void updateStatus() {
+ if (view.canBeBasic()) {
+ sndBar.setPushButtonPressed(bold, view.isBold());
+ sndBar.setPushButtonPressed(italic, view.isItalic());
+ sndBar.setPushButtonPressed(underline, view.isUnderlined());
+ }
+ if (isExtended()) {
+ sndBar.setPushButtonPressed(strikethrough, view.isStrikethrough());
+ }
+ }
+
+ private void createBasicActions() {
+ ActionToolbarMenuDescriptor<Object> selectAll = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
+ new Listener0() {
+ public void onEvent() {
+ view.selectAll();
+ }
+ });
+ selectAll.setIconCls(getCssName(imgResources.selectall()));
+ selectAll.setShortcut(new ActionShortcut(true, 'A'));
+ selectAll.setTextDescription(i18n.t("Select all"));
+ selectAll.setParentMenuTitle(i18n.t(EDIT_MENU));
+ selectAll.setAddCondition(canBeBasic);
+ selectAll.setTopSeparator(true);
+ selectAll.setBottomSeparator(true);
+
+ bold = new ActionToolbarPushButtonDescriptor<Object>(accessRol, sndbar, new Listener0() {
+ public void onEvent() {
+ view.toggleBold();
+ fireOnEdit();
+ }
+ });
+ bold.setIconCls(getCssName(imgResources.bold()));
+ bold.setToolTip(i18n.t("Bold"));
+ bold.setShortcut(new ActionShortcut(true, 'B'));
+ bold.setAddCondition(canBeBasic);
+
+ italic = new ActionToolbarPushButtonDescriptor<Object>(accessRol, sndbar, new Listener0() {
+ public void onEvent() {
+ view.toggleItalic();
+ fireOnEdit();
+ }
+ });
+ italic.setIconCls(getCssName(imgResources.italic()));
+ italic.setToolTip(i18n.t("Italic"));
+ italic.setShortcut(new ActionShortcut(true, 'I'));
+ italic.setAddCondition(canBeBasic);
+ italic.setAddCondition(canBeBasic);
+
+ underline = new ActionToolbarPushButtonDescriptor<Object>(accessRol, sndbar, new Listener0() {
+ public void onEvent() {
+ view.toggleUnderline();
+ fireOnEdit();
+ }
+ });
+ underline.setIconCls(getCssName(imgResources.underline()));
+ underline.setToolTip(i18n.t("Underline"));
+ underline.setShortcut(new ActionShortcut(true, 'U'));
+ underline.setAddCondition(canBeBasic);
+
+ ActionToolbarMenuDescriptor<Object> subscript = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
+ new Listener0() {
+ public void onEvent() {
+ view.toggleSubscript();
+ fireOnEdit();
+ }
+ });
+ subscript.setParentMenuTitle(i18n.t(FORMAT_MENU));
+ subscript.setTextDescription(i18n.t("Subscript"));
+ subscript.setIconCls(getCssName(imgResources.subscript()));
+ subscript.setShortcut(new ActionShortcut(true, '0'));
+ subscript.setAddCondition(canBeBasic);
+
+ ActionToolbarMenuDescriptor<Object> superscript = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
+ new Listener0() {
+ public void onEvent() {
+ view.toggleSuperscript();
+ fireOnEdit();
+ }
+ });
+ superscript.setParentMenuTitle(i18n.t(FORMAT_MENU));
+ superscript.setTextDescription(i18n.t("Superscript"));
+ superscript.setIconCls(getCssName(imgResources.superscript()));
+ superscript.setShortcut(new ActionShortcut(true, '9'));
+ superscript.setAddCondition(canBeBasic);
+
+ ActionToolbarButtonDescriptor<Object> justifyLeft = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ sndbar, new Listener0() {
+ public void onEvent() {
+ view.justifyLeft();
+ fireOnEdit();
+ }
+ });
+ justifyLeft.setIconCls(getCssName(imgResources.alignleft()));
+ justifyLeft.setToolTip(i18n.t("Left Justify"));
+ justifyLeft.setShortcut(new ActionShortcut(true, 'L'));
+ justifyLeft.setAddCondition(canBeBasic);
+
+ ActionToolbarButtonDescriptor<Object> justifyCentre = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ sndbar, new Listener0() {
+ public void onEvent() {
+ view.justifyCenter();
+ fireOnEdit();
+ }
+ });
+ justifyCentre.setIconCls(getCssName(imgResources.centerpara()));
+ justifyCentre.setToolTip(i18n.t("Centre Justify"));
+ justifyCentre.setShortcut(new ActionShortcut(true, 'E'));
+ justifyCentre.setAddCondition(canBeBasic);
+
+ ActionToolbarButtonDescriptor<Object> justifyRight = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ sndbar, new Listener0() {
+ public void onEvent() {
+ view.justifyRight();
+ fireOnEdit();
+ }
+ });
+ justifyRight.setIconCls(getCssName(imgResources.alignright()));
+ justifyRight.setToolTip(i18n.t("Right Justify"));
+ justifyRight.setShortcut(new ActionShortcut(true, 'R'));
+ justifyRight.setAddCondition(canBeBasic);
+
+ ActionToolbarMenuDescriptor<Object> undo = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
+ new Listener0() {
+ public void onEvent() {
+ view.undo();
+ fireOnEdit();
+ }
+ });
+ undo.setShortcut(new ActionShortcut(true, 'Z'));
+ undo.setTextDescription(i18n.t("Undo"));
+ undo.setParentMenuTitle(i18n.t(EDIT_MENU));
+ undo.setAddCondition(canBeExtended);
+ undo.setIconCls(getCssName(imgResources.undo()));
+
+ ActionToolbarMenuDescriptor<Object> redo = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
+ new Listener0() {
+ public void onEvent() {
+ view.redo();
+ fireOnEdit();
+ }
+ });
+ redo.setShortcut(new ActionShortcut(true, 'Y'));
+ redo.setTextDescription(i18n.t("Redo"));
+ redo.setParentMenuTitle(i18n.t(EDIT_MENU));
+ redo.setAddCondition(canBeExtended);
+ redo.setBottomSeparator(true);
+ redo.setIconCls(getCssName(imgResources.redo()));
+
+ ActionToolbarButtonDescriptor<Object> undoBtn = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
+ new Listener0() {
+ public void onEvent() {
+ view.undo();
+ fireOnEdit();
+ }
+ });
+ undoBtn.setToolTip(i18n.t("Undo"));
+ undoBtn.setAddCondition(canBeExtended);
+ undoBtn.setIconCls(getCssName(imgResources.undo()));
+ undoBtn.setPosition(0);
+
+ ActionToolbarButtonDescriptor<Object> redoBtn = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
+ new Listener0() {
+ public void onEvent() {
+ view.redo();
+ fireOnEdit();
+ }
+ });
+ redoBtn.setToolTip(i18n.t("Redo"));
+ redoBtn.setAddCondition(canBeExtended);
+ redoBtn.setIconCls(getCssName(imgResources.redo()));
+ redoBtn.setPosition(1);
+ redoBtn.setRightSeparator(ActionToolbarButtonSeparator.separator);
+
+ ActionToolbarMenuDescriptor<Object> copy = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
+ new Listener0() {
+ public void onEvent() {
+ view.copy();
+ }
+ });
+ copy.setShortcut(new ActionShortcut(true, 'C'));
+ copy.setTextDescription(i18n.t("Copy"));
+ copy.setParentMenuTitle(i18n.t(EDIT_MENU));
+ copy.setAddCondition(canBeExtended);
+ copy.setIconCls(getCssName(imgResources.copy()));
+
+ ActionToolbarMenuDescriptor<Object> cut = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
+ new Listener0() {
+ public void onEvent() {
+ view.cut();
+ fireOnEdit();
+ }
+ });
+ cut.setShortcut(new ActionShortcut(true, 'X'));
+ cut.setTextDescription(i18n.t("Cut"));
+ cut.setParentMenuTitle(i18n.t(EDIT_MENU));
+ cut.setAddCondition(canBeExtended);
+ cut.setIconCls(getCssName(imgResources.cut()));
+
+ ActionToolbarMenuDescriptor<Object> paste = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
+ new Listener0() {
+ public void onEvent() {
+ view.paste();
+ fireOnEdit();
+ }
+ });
+ paste.setShortcut(new ActionShortcut(true, 'V'));
+ paste.setTextDescription(i18n.t("Paste"));
+ paste.setParentMenuTitle(i18n.t(EDIT_MENU));
+ paste.setAddCondition(canBeExtended);
+ paste.setIconCls(getCssName(imgResources.paste()));
+
+ ActionToolbarMenuDescriptor<Object> editHtml = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
+ new Listener0() {
+ public void onEvent() {
+ EditHtml dialog = editHtmlDialog.get();
+ dialog.setUpdateListener(new Listener<String>() {
+ public void onEvent(String html) {
+ view.setHtml(html);
+ fireOnEdit();
+ }
+ });
+ dialog.show();
+ dialog.setHtml(view.getHtml());
+ }
+ });
+ editHtml.setIconCls(getCssName(imgResources.edithtml()));
+ editHtml.setTextDescription(i18n.t("Edit HTML"));
+ editHtml.setParentMenuTitle(i18n.t(EDIT_MENU));
+ editHtml.setAddCondition(canBeExtended);
+
+ ActionToolbarMenuDescriptor<Object> comment = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
+ new Listener0() {
+ public void onEvent() {
+ view.focus();
+ String author = session.isLogged() ? session.getCurrentUser().getShortName()
+ : i18n.t("anonymous user");
+ view.addComment(author);
+ fireOnEdit();
+ }
+ });
+ comment.setEnableCondition(new ActionEnableCondition<Object>() {
+ public boolean mustBeEnabled(Object param) {
+ return session.isLogged();
+ }
+ });
+ comment.setShortcut(new ActionShortcut(true, 'M'));
+ comment.setTextDescription(i18n.t("Comment..."));
+ comment.setParentMenuTitle(i18n.t(INSERT_MENU));
+ comment.setEnableCondition(isInsertHtmlSupported());
+ comment.setAddCondition(canBeExtended);
+
+ ActionToolbarMenuDescriptor<Object> hr = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
+ new Listener0() {
+ public void onEvent() {
+ view.focus();
+ view.insertHorizontalRule();
+ fireOnEdit();
+ }
+ });
+ hr.setTextDescription(i18n.t("Horizontal line"));
+ hr.setShortcut(new ActionShortcut(true, true, ' ', "Space"));
+ hr.setIconCls(getCssName(imgResources.hfixedline()));
+ hr.setParentMenuTitle(i18n.t(INSERT_MENU));
+ hr.setAddCondition(canBeExtended);
+
+ ActionToolbarButtonDescriptor<Object> hrButton = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
+ new Listener0() {
+ public void onEvent() {
+ view.focus();
+ view.insertHorizontalRule();
+ fireOnEdit();
+ }
+ });
+ hrButton.setIconCls(getCssName(imgResources.hfixedline()));
+ hrButton.setToolTip(i18n.t("Horizontal line"));
+ hrButton.setAddCondition(canBeExtended);
+
+ strikethrough = new ActionToolbarPushButtonDescriptor<Object>(accessRol, sndbar, new Listener0() {
+ public void onEvent() {
+ view.toggleStrikethrough();
+ fireOnEdit();
+ }
+ });
+ strikethrough.setIconCls(getCssName(imgResources.strikeout()));
+ strikethrough.setToolTip(i18n.t("Strikethrough"));
+ strikethrough.setRightSeparator(ActionToolbarButtonSeparator.separator);
+ strikethrough.setAddCondition(canBeExtended);
+
+ ActionToolbarButtonDescriptor<Object> decreaseIndent = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ sndbar, new Listener0() {
+ public void onEvent() {
+ view.leftIndent();
+ fireOnEdit();
+ }
+ });
+ decreaseIndent.setIconCls(getCssName(imgResources.decrementindent()));
+ decreaseIndent.setToolTip(i18n.t("Decrease Indent"));
+ decreaseIndent.setAddCondition(canBeExtended);
+
+ ActionToolbarButtonDescriptor<Object> increaseIndent = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ sndbar, new Listener0() {
+ public void onEvent() {
+ view.rightIndent();
+ fireOnEdit();
+ }
+ });
+ increaseIndent.setIconCls(getCssName(imgResources.incrementindent()));
+ increaseIndent.setToolTip(i18n.t("Increase Indent"));
+ increaseIndent.setAddCondition(canBeExtended);
+
+ ActionToolbarButtonDescriptor<Object> ol = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
+ new Listener0() {
+ public void onEvent() {
+ view.insertOrderedList();
+ fireOnEdit();
+ }
+ });
+ ol.setIconCls(getCssName(imgResources.defaultnumbering()));
+ ol.setToolTip(i18n.t("Numbered List"));
+ ol.setShortcut(new ActionShortcut(true, '7'));
+ ol.setAddCondition(canBeExtended);
+
+ ActionToolbarButtonDescriptor<Object> ul = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
+ new Listener0() {
+ public void onEvent() {
+ view.insertUnorderedList();
+ fireOnEdit();
+ }
+ });
+ ul.setIconCls(getCssName(imgResources.defaultbullet()));
+ ul.setToolTip(i18n.t("Bullet List"));
+ ul.setShortcut(new ActionShortcut(true, '8'));
+ ul.setRightSeparator(ActionToolbarButtonSeparator.separator);
+ ul.setAddCondition(canBeExtended);
+
+ ActionToolbarButtonDescriptor<Object> img = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
+ new Listener0() {
+ public void onEvent() {
+ insertImageDialog.get().show();
+ }
+ });
+ img.setIconCls(getCssName(imgResources.images()));
+ img.setToolTip(i18n.t("Insert Image"));
+ img.setAddCondition(canBeExtended);
+
+ ActionToolbarButtonDescriptor<Object> createLink = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
+ new Listener0() {
+ public void onEvent() {
+ deferred.addCommand(new Listener0() {
+ public void onEvent() {
+ insertElement.show();
+ }
+ });
+ }
+ });
+ createLink.setIconCls(getCssName(imgResources.link()));
+ createLink.setToolTip(i18n.t("Create Link"));
+ createLink.setShortcut(new ActionShortcut(true, 'K'));
+ createLink.setAddCondition(canBeExtended);
+ insertElement.addOnCreateLink(new Listener2<String, String>() {
+ public void onEvent(String name, String url) {
+ view.createLink(url);
+ fireOnEdit();
+ }
+ });
+
+ ActionToolbarButtonDescriptor<Object> removeLink = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
+ new Listener0() {
+ public void onEvent() {
+ view.unlink();
+ fireOnEdit();
+ }
+ });
+ removeLink.setIconCls(getCssName(imgResources.linkbreak()));
+ removeLink.setToolTip(i18n.t("Remove Link"));
+ removeLink.setShortcut(new ActionShortcut(true, true, 'K'));
+ removeLink.setAddCondition(canBeExtended);
+
+ final ActionToolbarButtonDescriptor<Object> removeFormat = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ sndbar, new Listener0() {
+ public void onEvent() {
+ view.removeFormat();
+ fireOnEdit();
+ }
+ });
+ removeFormat.setIconCls(getCssName(imgResources.removeFormat()));
+ removeFormat.setToolTip(i18n.t("Clear Formatting"));
+ removeFormat.setShortcut(new ActionShortcut(true, ' ', "Space"));
+ removeFormat.setAddCondition(canBeExtended);
+ removeFormat.setRightSeparator(ActionToolbarButtonSeparator.separator);
+
+ final ActionToolbarMenuDescriptor<Object> insertTable = new ActionToolbarMenuDescriptor<Object>(accessRol,
+ topbar, new Listener0() {
+ public void onEvent() {
+ insertSimpleTable();
+ }
+ });
+ insertTable.setIconCls(getCssName(imgResources.inserttable()));
+ insertTable.setTextDescription(i18n.t("Insert Table ..."));
+ insertTable.setAddCondition(canBeExtended);
+ insertTable.setParentMenuTitle(i18n.t(INSERT_MENU));
+
+ final ActionToolbarButtonDescriptor<Object> insertTableBtn = new ActionToolbarButtonDescriptor<Object>(
+ accessRol, sndbar, new Listener0() {
+ public void onEvent() {
+ insertSimpleTable();
+ }
+ });
+ insertTableBtn.setIconCls(getCssName(imgResources.inserttable()));
+ insertTableBtn.setToolTip(i18n.t("Insert Table"));
+ insertTableBtn.setAddCondition(canBeExtended);
+ insertTableBtn.setRightSeparator(ActionToolbarButtonSeparator.separator);
+
+ final ActionToolbarButtonDescriptor<Object> fontColor = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ sndbar, new Listener0() {
+ public void onEvent() {
+ palette.show(getActionLeftPosition(sndBar, removeFormat), getActionTopPosition(sndBar,
+ removeFormat), new Listener<String>() {
+ public void onEvent(String color) {
+ palette.hide();
+ view.setForeColor(color);
+ fireOnEdit();
+ }
+ });
+ }
+ });
+ fontColor.setIconCls(getCssName(imgResources.fontcolor()));
+ fontColor.setToolTip(i18n.t("Text Colour"));
+ fontColor.setAddCondition(canBeBasic);
+
+ ActionToolbarButtonDescriptor<Object> backgroundColor = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ sndbar, new Listener0() {
+ public void onEvent() {
+ palette.show(getActionLeftPosition(sndBar, fontColor), getActionTopPosition(sndBar, fontColor),
+ new Listener<String>() {
+ public void onEvent(String color) {
+ palette.hide();
+ view.setBackColor(color);
+ fireOnEdit();
+ }
+ });
+ }
+ });
+ backgroundColor.setIconCls(getCssName(imgResources.backcolor()));
+ backgroundColor.setToolTip(i18n.t("Text Background Colour"));
+ backgroundColor.setAddCondition(canBeBasic);
+
+ actions.add(withNoItem(bold));
+ actions.add(withNoItem(italic));
+ actions.add(withNoItem(underline));
+ actions.add(withNoItem(strikethrough));
+
+ actions.add(withNoItem(justifyLeft));
+ actions.add(withNoItem(justifyCentre));
+ actions.add(withNoItem(justifyRight));
+
+ actions.add(withNoItem(undo));
+ actions.add(withNoItem(redo));
+ actions.add(withNoItem(copy));
+ actions.add(withNoItem(cut));
+ actions.add(withNoItem(paste));
+ actions.add(withNoItem(selectAll));
+ actions.add(withNoItem(editHtml));
+ actions.add(withNoItem(hr));
+ actions.add(withNoItem(subscript));
+ actions.add(withNoItem(superscript));
+ actions.add(withNoItem(decreaseIndent));
+ actions.add(withNoItem(increaseIndent));
+ actions.add(withNoItem(ol));
+ actions.add(withNoItem(ul));
+ actions.add(withNoItem(removeFormat));
+ // topActions.add(withNoItem(hrButton));
+ actions.add(withNoItem(img));
+ actions.add(withNoItem(createLink));
+ actions.add(withNoItem(removeLink));
+ actions.add(withNoItem(insertTableBtn));
+ actions.add(withNoItem(insertTable));
+ actions.add(withNoItem(comment));
+ actions.add(withNoItem(undoBtn));
+ actions.add(withNoItem(redoBtn));
+
+ for (String fontName : this.fontNames) {
+ ActionToolbarMenuDescriptor<Object> fontNameAction = createFontNameAction(canBeBasic, fontName);
+ actions.add(withNoItem(fontNameAction));
+ }
+ for (int fontSize = 0; fontSize < fontSizes.length; fontSize++) {
+ ActionToolbarMenuDescriptor<Object> fontSizeAction = createFontSizeAction(canBeBasic, fontSize,
+ fontSizes[fontSize]);
+ actions.add(withNoItem(fontSizeAction));
+ }
+ actions.add(withNoItem(fontColor));
+ actions.add(withNoItem(backgroundColor));
+ }
+
+ private ActionToolbarMenuDescriptor<Object> createFontNameAction(ActionAddCondition<Object> canBeBasic,
+ final String fontName) {
+ final ActionToolbarMenuDescriptor<Object> font = new ActionToolbarMenuDescriptor<Object>(accessRol, sndbar,
+ new Listener0() {
+ public void onEvent() {
+ view.setFontName(fontName);
+ fireOnEdit();
+ }
+ });
+ font.setTextDescription("<span style=\"font-family: " + fontName + "\">" + fontName + "</span>");
+ font.setParentMenuTooltip(i18n.t("Font"));
+ font.setParentMenuIconCls(getCssName(imgResources.charfontname()));
+ font.setAddCondition(canBeBasic);
+ return font;
+ }
+
+ private ActionToolbarMenuDescriptor<Object> createFontSizeAction(ActionAddCondition<Object> canBeBasic,
+ final int fontSize, String fontSizeName) {
+ final ActionToolbarMenuDescriptor<Object> font = new ActionToolbarMenuDescriptor<Object>(accessRol, sndbar,
+ new Listener0() {
+ public void onEvent() {
+ view.setFontSize(fontSizesConstants[fontSize]);
+ fireOnEdit();
+ }
+ });
+ font.setTextDescription("<font size=\"" + (fontSize + 1) + "\">" + i18n.t(fontSizeName) + "</font>");
+ font.setParentMenuTooltip(i18n.t("Font size"));
+ font.setParentMenuIconCls(getCssName(imgResources.fontheight()));
+ font.setAddCondition(canBeBasic);
+ return font;
+ }
+
+ private int getActionLeftPosition(ActionToolbar<Object> bar, ActionToolbarButtonDescriptor<Object> action) {
+ return bar.getLeftPosition(action);
+ }
+
+ private int getActionTopPosition(ActionToolbar<Object> bar, ActionToolbarButtonDescriptor<Object> action) {
+ return bar.getTopPosition(action);
+ }
+
+ private String getCssName(ImageResource imageResource) {
+ return RTEImgResources.SUFFIX + imageResource.getName();
+ }
+
+ private void insertSimpleTable() {
+ view.insertHtml("<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">\n" + "<tbody>\n"
+ + "<tr>\n" + "<td width=\"50%\"><br>\n" + "</td>\n" + "<td width=\"50%\"><br>\n" + "</td>\n"
+ + "</tr>\n" + "<tr>\n" + "<td width=\"50%\"><br>\n" + "</td>\n" + "<td width=\"50%\"><br>\n"
+ + "</td>\n" + "</tr>\n</tbody>\n</table>");
+ fireOnEdit();
+ }
+
+ private boolean isExtended() {
+ return extended && view.canBeExtended();
+ }
+
+ private ActionEnableCondition<Object> isInsertHtmlSupported() {
+ return new ActionEnableCondition<Object>() {
+ public boolean mustBeEnabled(Object param) {
+ return true;
+ }
+ };
+ }
+
+ private void styleToolbar(ActionToolbar<Object> bar) {
+ bar.setNormalStyle();
+ }
+
+ private ActionItemCollection<Object> withNoItem(ActionCollection<Object> actions) {
+ ActionItemCollection<Object> collection = new ActionItemCollection<Object>();
+ for (ActionDescriptor<Object> action : actions) {
+ // this action don't have a associated item
+ collection.add(withNoItem(action));
+ }
+ return collection;
+ }
+
+ private ActionItem<Object> withNoItem(ActionDescriptor<Object> action) {
+ return new ActionItem<Object>(action, null);
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java (from rev 1064, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java 2009-03-10 00:05:50 UTC (rev 1064)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,102 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+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;
+
+public interface RTEditorView extends View {
+
+ void addActions(ActionItemCollection<Object> actions);
+
+ void addComment(String userName);
+
+ void adjustSize(int height);
+
+ boolean canBeBasic();
+
+ boolean canBeExtended();
+
+ void copy();
+
+ void createLink(String url);
+
+ void cut();
+
+ void delete();
+
+ void focus();
+
+ String getHtml();
+
+ String getText();
+
+ void insertHorizontalRule();
+
+ void insertHtml(String html);
+
+ void insertImage(String url);
+
+ void insertOrderedList();
+
+ void insertUnorderedList();
+
+ boolean isAttached();
+
+ boolean isBold();
+
+ boolean isItalic();
+
+ boolean isStrikethrough();
+
+ boolean isSubscript();
+
+ boolean isSuperscript();
+
+ boolean isUnderlined();
+
+ void justifyCenter();
+
+ void justifyLeft();
+
+ void justifyRight();
+
+ void leftIndent();
+
+ void paste();
+
+ void redo();
+
+ void removeFormat();
+
+ void rightIndent();
+
+ void selectAll();
+
+ void setBackColor(String color);
+
+ void setFontName(String name);
+
+ void setFontSize(FontSize fontSize);
+
+ void setForeColor(String color);
+
+ void setHtml(String html);
+
+ void setText(String text);
+
+ void toggleBold();
+
+ void toggleItalic();
+
+ void toggleStrikethrough();
+
+ void toggleSubscript();
+
+ void toggleSuperscript();
+
+ void toggleUnderline();
+
+ void undo();
+
+ void unlink();
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExt.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExt.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExt.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExt.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,5 @@
+package org.ourproject.kune.platf.client.ui.rte.insertimg.ext;
+
+public interface InsertImageExt {
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPanel.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPanel.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPanel.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,61 @@
+package org.ourproject.kune.platf.client.ui.rte.insertimg.ext;
+
+import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+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.insertimg.InsertImageView;
+
+import com.gwtext.client.core.EventObject;
+import com.gwtext.client.widgets.Button;
+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 InsertImageExtPanel extends DefaultForm implements InsertImageExtView {
+
+ private static final String LINK_FIELD = "iiep-img-field";
+ private final TextField linkField;
+ private final Panel previewPanel;
+
+ public InsertImageExtPanel(final InsertImageExtPresenter presenter, I18nTranslationService i18n) {
+ super(i18n.t("External image"));
+ super.setAutoWidth(true);
+ super.setHeight(InsertImageView.HEIGHT);
+ linkField = new TextField();
+ linkField.setTabIndex(1);
+ linkField.setFieldLabel(i18n.t("External image 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);
+ 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
+ public void onClick(Button button, EventObject e) {
+ presenter.onPreview();
+ }
+ });
+ 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);
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPresenter.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,26 @@
+package org.ourproject.kune.platf.client.ui.rte.insertimg.ext;
+
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImage;
+
+public class InsertImageExtPresenter implements InsertImageExt {
+
+ private final InsertImage insertImageDialog;
+
+ public InsertImageExtPresenter(InsertImage insertImageDialog) {
+ this.insertImageDialog = insertImageDialog;
+ }
+
+ public void init(InsertImageExtView view) {
+ insertImageDialog.addOptionTab(view);
+ }
+
+ public void onInsert() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onPreview() {
+ // TODO Auto-generated method stub
+
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtView.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtView.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtView.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtView.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,7 @@
+package org.ourproject.kune.platf.client.ui.rte.insertimg.ext;
+
+import org.ourproject.kune.platf.client.View;
+
+public interface InsertImageExtView extends View {
+}
+
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExt.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExt.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExt.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,5 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.insertimgext;
-
-public interface InsertImageExt {
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPanel.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,61 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.insertimgext;
-
-import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-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.insertimg.InsertImageView;
-
-import com.gwtext.client.core.EventObject;
-import com.gwtext.client.widgets.Button;
-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 InsertImageExtPanel extends DefaultForm implements InsertImageExtView {
-
- private static final String LINK_FIELD = "iiep-img-field";
- private final TextField linkField;
- private final Panel previewPanel;
-
- public InsertImageExtPanel(final InsertImageExtPresenter presenter, I18nTranslationService i18n) {
- super(i18n.t("External image"));
- super.setAutoWidth(true);
- super.setHeight(InsertImageView.HEIGHT);
- linkField = new TextField();
- linkField.setTabIndex(1);
- linkField.setFieldLabel(i18n.t("External image 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);
- 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
- public void onClick(Button button, EventObject e) {
- presenter.onPreview();
- }
- });
- 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);
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,26 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.insertimgext;
-
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImage;
-
-public class InsertImageExtPresenter implements InsertImageExt {
-
- private final InsertImage insertImageDialog;
-
- public InsertImageExtPresenter(InsertImage insertImageDialog) {
- this.insertImageDialog = insertImageDialog;
- }
-
- public void init(InsertImageExtView view) {
- insertImageDialog.addOptionTab(view);
- }
-
- public void onInsert() {
- // TODO Auto-generated method stub
-
- }
-
- public void onPreview() {
- // TODO Auto-generated method stub
-
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtView.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtView.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,7 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.insertimgext;
-
-import org.ourproject.kune.platf.client.View;
-
-public interface InsertImageExtView extends View {
-}
-
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditor.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditor.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditor.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditor.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,27 @@
+package org.ourproject.kune.platf.client.ui.rte.saving;
+
+import org.ourproject.kune.platf.client.actions.BeforeActionListener;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
+
+import com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.events.Listener0;
+
+public interface RTESavingEditor {
+
+ void edit(String html, Listener<String> onSave, Listener0 onEditCancelled);
+
+ RTEditor getBasicEditor();
+
+ /**
+ * This is use for listen to changes as url changes, window close, and
+ * save/cancel or stop these actions
+ *
+ * @return
+ */
+ BeforeActionListener getBeforeSavingListener();
+
+ void onSavedSuccessful();
+
+ void onSaveFailed();
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPanel.java (from rev 1066, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPanel.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPanel.java 2009-03-10 13:43:43 UTC (rev 1066)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,14 @@
+package org.ourproject.kune.platf.client.ui.rte.saving;
+
+import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
+
+import com.calclab.suco.client.events.Listener0;
+
+public class RTESavingEditorPanel implements RTESavingEditorView {
+
+ public void askConfirmation(String confirmationTitle, String confirmationText, Listener0 onConfirm,
+ Listener0 onCancel) {
+ NotifyUser.askConfirmation(confirmationTitle, confirmationText, onConfirm, onCancel);
+ }
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,245 @@
+package org.ourproject.kune.platf.client.ui.rte.saving;
+
+import org.ourproject.kune.platf.client.actions.ActionShortcut;
+import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator;
+import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
+import org.ourproject.kune.platf.client.actions.BeforeActionListener;
+import org.ourproject.kune.platf.client.dto.AccessRolDTO;
+import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+import org.ourproject.kune.platf.client.state.StateManager;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
+import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
+import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
+import org.ourproject.kune.platf.client.utils.TimerWrapper;
+
+import com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.events.Listener0;
+
+public class RTESavingEditorPresenter implements RTESavingEditor {
+
+ @Deprecated
+ private static final String FILE_MENU_OPTION = "File";
+ public static final int AUTOSAVE_AFTER_FAILS_IN_MILLISECONS = 20000;
+ public static final int AUTOSAVE_IN_MILLISECONDS = 10000;
+
+ private final RTEditor editor;
+ private final boolean autoSave;
+ private boolean savePending;
+ private boolean saveAndCloseConfirmed;
+ private Listener<String> onSave;
+ private Listener0 onEditCancelled;
+ private final RTEImgResources imgResources;
+ private final TimerWrapper timer;
+ private final DeferredCommandWrapper deferredCommandWrapper;
+ private final I18nTranslationService i18n;
+ private final StateManager stateManager;
+ private final BeforeActionListener beforeStateChangeListener;
+ ActionToolbarButtonDescriptor<Object> saveBtn;
+ private RTESavingEditorView view;
+
+ public RTESavingEditorPresenter(RTEditor editor, final boolean autoSave, final I18nTranslationService i18n,
+ StateManager stateManager, DeferredCommandWrapper deferredCommandWrapper,
+ RTEImgResources imgResources, TimerWrapper timer) {
+ this.editor = editor;
+ this.autoSave = autoSave;
+ this.i18n = i18n;
+ this.stateManager = stateManager;
+ this.deferredCommandWrapper = deferredCommandWrapper;
+ this.imgResources = imgResources;
+ this.savePending = false;
+ this.saveAndCloseConfirmed = false;
+ createActions();
+ this.timer = timer;
+ timer.configure(new Listener0() {;
+
+ public void onEvent() {
+ onAutoSave();
+ }
+ });
+ editor.addOnEditListener(new Listener0() {
+ public void onEvent() {
+ onEdit();
+ }
+ });
+ beforeStateChangeListener = new BeforeActionListener() {
+ public boolean beforeAction() {
+ return beforeTokenChange();
+ }
+ };
+ }
+
+ public void edit(String html, Listener<String> onSave, Listener0 onEditCancelled) {
+ this.onSave = onSave;
+ this.onEditCancelled = onEditCancelled;
+ editor.setHtml(html);
+ editor.attach();
+ stateManager.addBeforeStateChangeListener(beforeStateChangeListener);
+ enableSaveBtn(false);
+ }
+
+ public RTEditor getBasicEditor() {
+ return editor;
+ }
+
+ public BeforeActionListener getBeforeSavingListener() {
+ return beforeStateChangeListener;
+ }
+
+ public void init(RTESavingEditorView view) {
+ this.view = view;
+ }
+
+ public void onDoSaveAndClose() {
+ saveAndCloseConfirmed = true;
+ onDoSave();
+ }
+
+ public void onSavedSuccessful() {
+ if (saveAndCloseConfirmed) {
+ onCancelConfirmed();
+ } else {
+ reset();
+ }
+ }
+
+ public void onSaveFailed() {
+ timer.schedule(AUTOSAVE_AFTER_FAILS_IN_MILLISECONS);
+ if (saveAndCloseConfirmed) {
+ saveAndCloseConfirmed = false;
+ }
+ }
+
+ protected void onAutoSave() {
+ onDoSave();
+ }
+
+ protected void onCancel() {
+ if (savePending) {
+ timer.cancel();
+ Listener0 onYes = new Listener0() {
+ public void onEvent() {
+ onDoSaveAndClose();
+ }
+ };
+ Listener0 onCancel = new Listener0() {
+ public void onEvent() {
+ onCancelConfirmed();
+ }
+ };
+ view.askConfirmation(i18n.t("Save confirmation"),
+ i18n.t("Do you want to save before closing the editor?"), onYes, onCancel);
+ } else {
+ onCancelConfirmed();
+ }
+ }
+
+ protected void onCancelConfirmed() {
+ stateManager.removeBeforeStateChangeListener(beforeStateChangeListener);
+ stateManager.resumeTokenChange();
+ reset();
+ editor.reset();
+ onDoEditCancelled();
+ }
+
+ protected void onDoSave() {
+ onSave.onEvent(editor.getHtml());
+ }
+
+ boolean beforeTokenChange() {
+ if (savePending) {
+ onCancel();
+ return false;
+ } else {
+ deferredCommandWrapper.addCommand(new Listener0() {
+ public void onEvent() {
+ onCancelConfirmed();
+ }
+ });
+ return true;
+ }
+ }
+
+ void onEdit() {
+ if (!savePending) {
+ savePending = true;
+ if (autoSave) {
+ timer.schedule(AUTOSAVE_IN_MILLISECONDS);
+ }
+ enableSaveBtn(true);
+ }
+ }
+
+ private void createActions() {
+ Listener0 onPerformSaveCall = new Listener0() {
+ public void onEvent() {
+ onDoSave();
+ }
+ };
+ saveBtn = new ActionToolbarButtonDescriptor<Object>(AccessRolDTO.Editor, RTEditor.sndbar, onPerformSaveCall);
+ saveBtn.setIconCls(RTEImgResources.SUFFIX + imgResources.save().getName());
+ saveBtn.setToolTip(i18n.t("Save"));
+ saveBtn.setShortcut(new ActionShortcut(true, 'S'));
+ saveBtn.setPosition(0);
+
+ 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.setTextDescription(i18n.t("Save"));
+ save.setShortcut(new ActionShortcut(true, 'S'));
+ save.setPosition(0);
+
+ ActionToolbarMenuDescriptor<Object> close = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor,
+ RTEditor.topbar, new Listener<Object>() {
+ public void onEvent(Object parameter) {
+ onCancel();
+ }
+ });
+ close.setParentMenuTitle(i18n.t(FILE_MENU_OPTION));
+ close.setTextDescription(i18n.t("Close"));
+
+ Listener0 onPerformSaveAndCloseCall = new Listener0() {
+ public void onEvent() {
+ if (savePending) {
+ timer.cancel();
+ onDoSaveAndClose();
+ } else {
+ onCancelConfirmed();
+ }
+ }
+ };
+ ActionToolbarMenuDescriptor<Object> saveclose = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor,
+ RTEditor.topbar, onPerformSaveAndCloseCall);
+ saveclose.setParentMenuTitle(i18n.t(FILE_MENU_OPTION));
+ saveclose.setTextDescription(i18n.t("Save & Close"));
+
+ ActionToolbarButtonDescriptor<Object> saveCloseBtn = new ActionToolbarButtonDescriptor<Object>(
+ AccessRolDTO.Editor, RTEditor.topbar, onPerformSaveAndCloseCall);
+ // saveCloseBtn.setIconCls(RTEImgResources.SUFFIX +
+ // imgResources.save().getName());
+ saveCloseBtn.setTextDescription(i18n.t("Save & Close"));
+ saveCloseBtn.setLeftSeparator(ActionToolbarButtonSeparator.fill);
+
+ editor.addAction(save);
+ editor.addAction(saveclose);
+ editor.addAction(close);
+ editor.addAction(saveBtn);
+ editor.addAction(saveCloseBtn);
+ }
+
+ private void enableSaveBtn(boolean enable) {
+ editor.getSndBar().setButtonEnable(saveBtn, enable);
+ }
+
+ private void onDoEditCancelled() {
+ onEditCancelled.onEvent();
+ }
+
+ private void reset() {
+ timer.cancel();
+ savePending = false;
+ saveAndCloseConfirmed = false;
+ enableSaveBtn(false);
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorView.java (from rev 1066, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorView.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorView.java 2009-03-10 13:43:43 UTC (rev 1066)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorView.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,10 @@
+package org.ourproject.kune.platf.client.ui.rte.saving;
+
+import org.ourproject.kune.platf.client.View;
+
+import com.calclab.suco.client.events.Listener0;
+
+public interface RTESavingEditorView extends View {
+
+ void askConfirmation(String confirmationTitle, String confirmationText, Listener0 onConfirm, Listener0 onCancel);
+}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -46,14 +46,14 @@
import org.ourproject.kune.platf.client.state.StateManager;
import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
-import org.ourproject.kune.platf.client.ui.rte.RTESavingEditorPanel;
-import org.ourproject.kune.platf.client.ui.rte.RTEditor;
import org.ourproject.kune.platf.client.ui.rte.TestRTEDialog;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImage;
import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageGroup;
import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElement;
import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElementGroup;
+import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPanel;
import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
import org.ourproject.kune.platf.client.utils.TimerWrapper;
import org.ourproject.kune.workspace.client.cnt.ActionContentToolbar;
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-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -4,11 +4,11 @@
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
import org.ourproject.kune.platf.client.state.StateManager;
import org.ourproject.kune.platf.client.ui.AbstractToolbar;
-import org.ourproject.kune.platf.client.ui.rte.RTESavingEditorPresenter;
-import org.ourproject.kune.platf.client.ui.rte.RTESavingEditorView;
-import org.ourproject.kune.platf.client.ui.rte.RTEditor;
-import org.ourproject.kune.platf.client.ui.rte.RTEditorPanel;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPanel;
import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
+import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPresenter;
+import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorView;
import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
import org.ourproject.kune.platf.client.utils.TimerWrapper;
import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignOutLink;
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditor.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditor.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,33 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.workspace.client.editor;
-
-import com.calclab.suco.client.events.Listener;
-import com.calclab.suco.client.events.Listener0;
-
-public interface TextEditor {
-
- void editContent(String content, Listener<String> onSave, Listener0 onEditCancelled);
-
- void onSavedSuccessful();
-
- void onSaveFailed();
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorImages.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorImages.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorImages.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,96 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.workspace.client.editor;
-
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.ImageBundle;
-
-public interface TextEditorImages extends ImageBundle {
-
- @Resource("alignleft.png")
- AbstractImagePrototype alignleft();
-
- @Resource("alignright.png")
- AbstractImagePrototype alignright();
-
- @Resource("backcolor.png")
- AbstractImagePrototype backcolor();
-
- @Resource("bold.png")
- AbstractImagePrototype bold();
-
- @Resource("centerpara.png")
- AbstractImagePrototype centerpara();
-
- @Resource("charfontname.png")
- AbstractImagePrototype charfontname();
-
- @Resource("decrementindent.png")
- AbstractImagePrototype decrementindent();
-
- @Resource("defaultbullet.png")
- AbstractImagePrototype defaultbullet();
-
- @Resource("defaultnumbering.png")
- AbstractImagePrototype defaultnumbering();
-
- @Resource("edithtml.png")
- AbstractImagePrototype edithtml();
-
- @Resource("fontcolor.png")
- AbstractImagePrototype fontcolor();
-
- @Resource("fontheight.png")
- AbstractImagePrototype fontheight();
-
- @Resource("hfixedline.png")
- AbstractImagePrototype hfixedline();
-
- @Resource("images.png")
- AbstractImagePrototype images();
-
- @Resource("incrementindent.png")
- AbstractImagePrototype incrementindent();
-
- @Resource("italic.png")
- AbstractImagePrototype italic();
-
- @Resource("link.png")
- AbstractImagePrototype link();
-
- @Resource("link_break.png")
- AbstractImagePrototype linkBreak();
-
- @Resource("removeFormat.png")
- AbstractImagePrototype removeFormat();
-
- @Resource("strikeout.png")
- AbstractImagePrototype strikeout();
-
- @Resource("subscript.png")
- AbstractImagePrototype subscript();
-
- @Resource("superscript.png")
- AbstractImagePrototype superscript();
-
- @Resource("underline.png")
- AbstractImagePrototype underline();
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPanel.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,155 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.workspace.client.editor;
-
-import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
-import org.ourproject.kune.platf.client.ui.rte.RichTextArea;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElement;
-import org.ourproject.kune.workspace.client.skel.Toolbar;
-import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
-
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Timer;
-import com.google.gwt.user.client.ui.VerticalPanel;
-import com.gwtext.client.widgets.BoxComponent;
-import com.gwtext.client.widgets.MessageBox;
-import com.gwtext.client.widgets.event.ContainerListenerAdapter;
-
-public class TextEditorPanel implements TextEditorView {
- private static final String BACKCOLOR_ENABLED = "#FFF";
- private static final String BACKCOLOR_DISABLED = "#CCC";
- public static final String TEXT_AREA = "k-tep-ta";
- private final RichTextArea gwtRTarea;
- private final TextEditorToolbar textEditorToolbar;
- private final TextEditorPresenter presenter;
- private final Timer saveTimer;
- private final I18nTranslationService i18n;
- private final VerticalPanel mainPanel;
- private final WorkspaceSkeleton ws;
-
- public TextEditorPanel(final TextEditorPresenter presenter, final I18nTranslationService i18n,
- final WorkspaceSkeleton ws, final ColorWebSafePalette colorPalette,
- final TextEditorInsertElement textEditorInsertElement, boolean permitHtmlButton) {
- this.presenter = presenter;
- this.i18n = i18n;
- this.ws = ws;
- mainPanel = new VerticalPanel();
- mainPanel.setWidth("100%");
-
- gwtRTarea = new RichTextArea();
- gwtRTarea.setWidth("96%");
- gwtRTarea.setHeight("100%");
- gwtRTarea.addStyleName("kune-TexEditorPanel-TextArea");
- gwtRTarea.ensureDebugId(TEXT_AREA);
-
- final Toolbar editorTopBar = new Toolbar();
- editorTopBar.getPanel().setWidth("auto");
- textEditorToolbar = new TextEditorToolbar(gwtRTarea, presenter, colorPalette, i18n, permitHtmlButton,
- textEditorInsertElement);
- editorTopBar.add(textEditorToolbar);
- editorTopBar.addStyleName("k-toolbar-bottom-line");
-
- mainPanel.add(editorTopBar.getPanel());
- mainPanel.add(gwtRTarea);
-
- adjustSize(ws.getEntityWorkspace().getContentHeight());
- ws.getEntityWorkspace().addContentListener(new ContainerListenerAdapter() {
- @Override
- public void onResize(final BoxComponent component, final int adjWidth, final int adjHeight,
- final int rawWidth, final int rawHeight) {
- adjustSize(adjHeight);
- }
- });
-
- saveTimer = new Timer() {
- @Override
- public void run() {
- presenter.onSave();
- }
- };
- }
-
- public void attach() {
- ws.getEntityWorkspace().setContent(mainPanel);
- }
-
- public void detach() {
- mainPanel.removeFromParent();
- }
-
- public void editHTML(final boolean edit) {
- textEditorToolbar.editHTML(edit);
- }
-
- public String getHTML() {
- return gwtRTarea.getHTML();
- }
-
- public String getText() {
- return gwtRTarea.getText();
- }
-
- public void saveTimerCancel() {
- saveTimer.cancel();
- }
-
- public void scheduleSave(final int delayMillis) {
- saveTimer.schedule(delayMillis);
- }
-
- public void setEnabled(final boolean enabled) {
- final String bgColor = enabled ? BACKCOLOR_ENABLED : BACKCOLOR_DISABLED;
- DOM.setStyleAttribute(gwtRTarea.getElement(), "backgroundColor", bgColor);
- gwtRTarea.setEnabled(enabled);
- }
-
- public void setHeight(final String height) {
- gwtRTarea.setHeight(height);
- }
-
- public void setHTML(final String html) {
- gwtRTarea.setHTML(html);
- }
-
- public void setText(final String text) {
- gwtRTarea.setText(text);
- }
-
- public void showSaveBeforeDialog() {
- MessageBox.confirm(i18n.t("Save confirmation"), i18n.t("Do you want to save before closing the editor?"),
- new MessageBox.ConfirmCallback() {
- public void execute(final String btnID) {
- if (btnID.equals("yes")) {
- presenter.onSaveAndClose();
- } else {
- presenter.onCancelConfirmed();
- }
- }
- });
-
- }
-
- private void adjustSize(final int height) {
- int newHeight = height - WorkspaceSkeleton.DEF_TOOLBAR_HEIGHT - 27;
- gwtRTarea.setHeight("" + newHeight);
- mainPanel.setCellHeight(gwtRTarea, "" + newHeight);
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,212 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.workspace.client.editor;
-
-import org.ourproject.kune.platf.client.actions.ActionItem;
-import org.ourproject.kune.platf.client.actions.ActionItemCollection;
-import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
-import org.ourproject.kune.platf.client.actions.BeforeActionListener;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-import org.ourproject.kune.platf.client.dto.AccessRolDTO;
-import org.ourproject.kune.platf.client.dto.StateToken;
-import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
-import org.ourproject.kune.platf.client.state.StateManager;
-import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
-import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignOutLink;
-
-import com.calclab.suco.client.events.Listener;
-import com.calclab.suco.client.events.Listener0;
-
-public class TextEditorPresenter implements TextEditor {
- public static final int AUTOSAVE_AFTER_FAILS_IN_MILLISECONS = 20000;
- public static final int AUTOSAVE_IN_MILLISECONDS = 10000;
- public static final String CLOSE_ID = "k-teditc-close";
- public static final String SAVE_ID = "k-teditp-save";
- private boolean editingHtml;
- private TextEditorView view;
- private boolean savePending;
- private final boolean autoSave;
- private boolean saveAndCloseConfirmed;
- private Listener<String> onSave;
- private Listener0 onEditCancelled;
- private final ActionToolbar<StateToken> topToolbar;
- private ActionToolbarMenuDescriptor<StateToken> save;
- private ActionToolbarButtonDescriptor<StateToken> close;
- private final I18nUITranslationService i18n;
- private final BeforeActionListener beforeStateChangeListener;
- private final StateManager stateManager;
- private final SiteSignOutLink siteSignOutLink;
- private final DeferredCommandWrapper deferredCommandWrapper;
-
- public TextEditorPresenter(final boolean isAutoSave, final ActionToolbar<StateToken> topToolbar,
- final I18nUITranslationService i18n, StateManager stateManager, SiteSignOutLink siteSignOutLink,
- DeferredCommandWrapper deferredCommandWrapper) {
- this.topToolbar = topToolbar;
- this.autoSave = isAutoSave;
- this.i18n = i18n;
- this.stateManager = stateManager;
- this.siteSignOutLink = siteSignOutLink;
- this.deferredCommandWrapper = deferredCommandWrapper;
- this.savePending = false;
- this.editingHtml = false;
- this.saveAndCloseConfirmed = false;
- createActions();
-
- beforeStateChangeListener = new BeforeActionListener() {
- public boolean beforeAction() {
- return beforeTokenChange();
- }
- };
- }
-
- public void editContent(final String content, final Listener<String> onSave, final Listener0 onEditCancelled) {
- this.onSave = onSave;
- this.onEditCancelled = onEditCancelled;
- topToolbar.attach();
- view.attach();
- setContent(content);
- stateManager.addBeforeStateChangeListener(beforeStateChangeListener);
- siteSignOutLink.addBeforeSignOut(beforeStateChangeListener);
- }
-
- public void init(final TextEditorView view) {
- this.view = view;
- this.view.setEnabled(true);
- }
-
- public void onEdit() {
- if (!savePending) {
- savePending = true;
- if (autoSave) {
- view.scheduleSave(AUTOSAVE_IN_MILLISECONDS);
- }
- }
- }
-
- public void onSaveAndClose() {
- saveAndCloseConfirmed = true;
- onSave();
- }
-
- public void onSavedSuccessful() {
- if (saveAndCloseConfirmed) {
- onCancelConfirmed();
- } else {
- reset();
- }
- }
-
- public void onSaveFailed() {
- view.scheduleSave(AUTOSAVE_AFTER_FAILS_IN_MILLISECONS);
- if (saveAndCloseConfirmed) {
- saveAndCloseConfirmed = false;
- }
- }
-
- protected void onCancel() {
- if (savePending) {
- view.saveTimerCancel();
- view.showSaveBeforeDialog();
- } else {
- onCancelConfirmed();
- }
- }
-
- protected void onCancelConfirmed() {
- stateManager.removeBeforeStateChangeListener(beforeStateChangeListener);
- siteSignOutLink.removeBeforeSignOut(beforeStateChangeListener);
- stateManager.resumeTokenChange();
- reset();
- view.detach();
- topToolbar.detach();
- onEditCancelled.onEvent();
- }
-
- protected void onEditHTML() {
- if (editingHtml) {
- // normal editor
- final String html = view.getText();
- view.setHTML(html);
- view.editHTML(false);
- editingHtml = false;
- } else {
- // html editor
- final String html = view.getHTML();
- view.setText(html);
- view.editHTML(true);
- editingHtml = true;
- }
- }
-
- protected void onSave() {
- onSave.onEvent(view.getHTML());
- }
-
- boolean beforeTokenChange() {
- if (savePending) {
- onCancel();
- return false;
- } else {
- deferredCommandWrapper.addCommand(new Listener0() {
- public void onEvent() {
- onCancelConfirmed();
- }
- });
- return true;
- }
- }
-
- private void createActions() {
- save = new ActionToolbarMenuDescriptor<StateToken>(AccessRolDTO.Viewer, null, new Listener<StateToken>() {
- public void onEvent(final StateToken token) {
- onSave();
- }
- });
- save.setTextDescription(i18n.tWithNT("Save", "used in button"));
- save.setParentMenuTitle(i18n.t("File"));
- save.setId(SAVE_ID);
- // save.setIconUrl("images/");
-
- close = new ActionToolbarButtonDescriptor<StateToken>(AccessRolDTO.Viewer, null, new Listener<StateToken>() {
- public void onEvent(final StateToken token) {
- onCancel();
- }
- });
- close.setTextDescription(i18n.tWithNT("Close", "used in button"));
- close.setId(CLOSE_ID);
- // close.setIconUrl("images/");
-
- final ActionItemCollection<StateToken> collection = new ActionItemCollection<StateToken>();
- collection.add(new ActionItem<StateToken>(save, null));
- collection.add(new ActionItem<StateToken>(close, null));
- topToolbar.addActions(collection, null);
- }
-
- private void reset() {
- view.saveTimerCancel();
- savePending = false;
- saveAndCloseConfirmed = false;
- }
-
- private void setContent(final String html) {
- this.view.setHTML(html);
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorToolbar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorToolbar.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorToolbar.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,403 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.workspace.client.editor;
-
-import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-import org.ourproject.kune.platf.client.ui.KuneUiUtils;
-import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
-import org.ourproject.kune.platf.client.ui.rte.RichTextArea;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElement;
-
-import com.calclab.suco.client.events.Listener;
-import com.calclab.suco.client.events.Listener2;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.ChangeListener;
-import com.google.gwt.user.client.ui.ClickListener;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.KeyboardListener;
-import com.google.gwt.user.client.ui.MenuBar;
-import com.google.gwt.user.client.ui.PushButton;
-import com.google.gwt.user.client.ui.ToggleButton;
-import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.user.client.ui.Widget;
-import com.gwtext.client.widgets.MessageBox;
-import com.gwtext.client.widgets.MessageBox.PromptCallback;
-
-/**
- * A sample toolbar for use with {@link RichTextArea}. It provides a simple UI
- * for all rich text formatting, dynamically displayed only for the available
- * functionality.
- */
-public class TextEditorToolbar extends Composite {
-
- /**
- * We use an inner EventListener class to avoid exposing event methods on
- * the RichTextToolbar itself.
- */
- private class EventListener implements ClickListener, ChangeListener, KeyboardListener {
-
- public static final String TEXT_EDITOR_TOOLBAR_INS_IMG = "k-textedtol-img";
- private final TextEditorInsertElement insertElement;
-
- public EventListener(TextEditorInsertElement insertElement) {
- this.insertElement = insertElement;
- insertElement.addOnCreateLink(new Listener2<String, String>() {
- public void onEvent(String name, String url) {
- extended.createLink(url);
- }
- });
- }
-
- public void onChange(final Widget sender) {
- fireEdit();
- }
-
- public void onClick(final Widget sender) {
- if (sender == bold) {
- basic.toggleBold();
- } else if (sender == italic) {
- basic.toggleItalic();
- } else if (sender == underline) {
- basic.toggleUnderline();
- } else if (sender == subscript) {
- basic.toggleSubscript();
- } else if (sender == superscript) {
- basic.toggleSuperscript();
- } else if (sender == strikethrough) {
- extended.toggleStrikethrough();
- } else if (sender == indent) {
- extended.rightIndent();
- } else if (sender == outdent) {
- extended.leftIndent();
- } else if (sender == justifyLeft) {
- basic.setJustification(RichTextArea.Justification.LEFT);
- } else if (sender == justifyCenter) {
- basic.setJustification(RichTextArea.Justification.CENTER);
- } else if (sender == justifyRight) {
- basic.setJustification(RichTextArea.Justification.RIGHT);
- } else if (sender == insertImage) {
- showImagePanel();
- } else if (sender == createLink) {
- insertElement.show();
- } else if (sender == backColor) {
- colorPalette.show(sender.getAbsoluteLeft(), sender.getAbsoluteTop() + 20, new Listener<String>() {
- public void onEvent(final String color) {
- basic.setBackColor(color);
- colorPalette.hide();
- }
- });
- } else if (sender == editHtml) {
- presenter.onEditHTML();
- } else if (sender == fontColor) {
- colorPalette.show(sender.getAbsoluteLeft(), sender.getAbsoluteTop() + 20, new Listener<String>() {
- public void onEvent(final String color) {
- basic.setForeColor(color);
- colorPalette.hide();
- }
- });
- } else if (sender == removeLink) {
- extended.removeLink();
- } else if (sender == hr) {
- extended.insertHorizontalRule();
- } else if (sender == ol) {
- extended.insertOrderedList();
- } else if (sender == ul) {
- extended.insertUnorderedList();
- } else if (sender == removeFormat) {
- extended.removeFormat();
- } else if (sender == richText) {
- // We use the RichTextArea's onKeyUp event to update the
- // toolbar status.
- // This will catch any cases where the user moves the cursur
- // using the
- // keyboard, or uses one of the browser's built-in keyboard
- // shortcuts.
- updateStatus();
- }
- if (sender != richText) {
- // some button pressed is equiv to edit
- fireEdit();
- }
- }
-
- public void onKeyDown(final Widget sender, final char keyCode, final int modifiers) {
- if (sender == removeLink && keyCode == KeyboardListener.KEY_ENTER) {
- fireEditHTML();
- }
- }
-
- public void onKeyPress(final Widget sender, final char keyCode, final int modifiers) {
- }
-
- public void onKeyUp(final Widget sender, final char keyCode, final int modifiers) {
- if (sender == richText) {
- // We use the RichTextArea's onKeyUp event to update the
- // toolbar status.
- // This will catch any cases where the user moves the cursor
- // using the keyboard, or uses one of the browser's built-in
- // keyboard shortcuts.
- updateStatus();
- fireEdit();
- }
- }
-
- private void showImagePanel() {
- MessageBox.prompt("Insert image", "Enter an image URL:", new PromptCallback() {
- public void execute(final String btnID, final String text) {
- if (btnID.equals("ok") && text != null) {
- extended.insertImage(text);
- }
- }
- });
-
- }
- }
-
- private static final RichTextArea.FontSize[] fontSizesConstants = new RichTextArea.FontSize[] {
- RichTextArea.FontSize.XX_SMALL, RichTextArea.FontSize.X_SMALL, RichTextArea.FontSize.SMALL,
- RichTextArea.FontSize.MEDIUM, RichTextArea.FontSize.LARGE, RichTextArea.FontSize.X_LARGE,
- RichTextArea.FontSize.XX_LARGE };
-
- private final TextEditorImages images = (TextEditorImages) GWT.create(TextEditorImages.class);
- private final EventListener listener;
- private final RichTextArea richText;
- private final RichTextArea.BasicFormatter basic;
- private final RichTextArea.ExtendedFormatter extended;
- private final VerticalPanel outer = new VerticalPanel();
- private final HorizontalPanel topPanel = new HorizontalPanel();
- private ToggleButton bold;
- private ToggleButton italic;
- private ToggleButton underline;
- private ToggleButton subscript;
- private ToggleButton superscript;
- private ToggleButton strikethrough;
- private ToggleButton editHtml;
- private PushButton indent;
- private PushButton outdent;
- private PushButton justifyLeft;
- private PushButton justifyCenter;
- private PushButton justifyRight;
- private PushButton hr;
- private PushButton ol;
- private PushButton ul;
- private PushButton insertImage;
- private PushButton createLink;
- private PushButton removeLink;
- private PushButton removeFormat;
- private PushButton backColor;
- private PushButton fontColor;
- private MenuBar fonts;
- private MenuBar fontSizes;
- private final ColorWebSafePalette colorPalette;
- private final TextEditorPresenter presenter;
- private final I18nTranslationService i18n;
-
- /**
- * Creates a new toolbar that drives the given rich text area.
- *
- * @param richText
- * the rich text area to be controlled
- */
- public TextEditorToolbar(final RichTextArea richText, final TextEditorPresenter presenter,
- final ColorWebSafePalette colorPalette, final I18nTranslationService i18n, boolean permitEditHtml,
- TextEditorInsertElement insertElement) {
- this.richText = richText;
- this.colorPalette = colorPalette;
- this.i18n = i18n;
- this.basic = richText.getBasicFormatter();
- this.extended = richText.getExtendedFormatter();
- this.presenter = presenter;
- listener = new EventListener(insertElement);
-
- initWidget(outer);
-
- outer.add(topPanel);
- outer.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE);
- setStyleName("gwt-RichTextToolbar");
-
- if (basic != null) {
- topPanel.add(bold = createToggleButton(images.bold(), i18n.t("Toggle Bold")));
- topPanel.add(italic = createToggleButton(images.italic(), i18n.t("Toggle Italic")));
- topPanel.add(underline = createToggleButton(images.underline(), i18n.t("Toggle Underline")));
- }
-
- if (extended != null) {
- topPanel.add(strikethrough = createToggleButton(images.strikeout(), i18n.t("Toggle Strikethrough")));
- }
-
- if (basic != null) {
- subscript = createToggleButton(images.subscript(), i18n.t("Toggle Subscript"));
- superscript = createToggleButton(images.superscript(), i18n.t("Toggle Superscript"));
- topPanel.add(subscript);
- topPanel.add(superscript);
- topPanel.add(justifyLeft = createPushButton(images.alignleft(), i18n.t("Left Justify")));
- topPanel.add(justifyCenter = createPushButton(images.centerpara(), i18n.t("Center")));
- topPanel.add(justifyRight = createPushButton(images.alignright(), i18n.t("Right Justify")));
- }
-
- if (extended != null) {
- topPanel.add(indent = createPushButton(images.incrementindent(), i18n.t("Indent Right")));
- topPanel.add(outdent = createPushButton(images.decrementindent(), i18n.t("Indent Left")));
- hr = createPushButton(images.hfixedline(), i18n.t("Insert Horizontal Rule"));
- topPanel.add(hr);
- topPanel.add(ol = createPushButton(images.defaultnumbering(), i18n.t("Insert Ordered List")));
- topPanel.add(ul = createPushButton(images.defaultbullet(), i18n.t("Insert Unordered List")));
- topPanel.add(insertImage = createPushButton(images.images(), i18n.t("Insert Image")));
- topPanel.add(createLink = createPushButton(images.link(), i18n.t("Create Link")));
- topPanel.add(removeLink = createPushButton(images.linkBreak(), i18n.t("Remove Link")));
- removeFormat = createPushButton(images.removeFormat(), i18n.t("Remove Formatting"));
- topPanel.add(removeFormat);
- }
-
- if (basic != null) {
- topPanel.add(backColor = createPushButton(images.backcolor(), i18n.t("Background Color")));
- topPanel.add(fontColor = createPushButton(images.fontcolor(), i18n.t("Font Color")));
- topPanel.add(fonts = createFontsMenu());
- topPanel.add(fontSizes = createFontSizesMenu());
-
- // We only use these listeners for updating status, so don't
- // hook them up unless at least basic editing is supported.
- richText.addKeyboardListener(listener);
- richText.addClickListener(listener);
- }
-
- if (basic != null && permitEditHtml) {
- topPanel.add(editHtml = createToggleButton(images.edithtml(), i18n.t("Edit HTML")));
- }
-
- // super.setVisible(false);
- }
-
- public void editHTML(final boolean edit) {
- final boolean enable = !edit;
- if (basic != null) {
- bold.setVisible(enable);
- italic.setVisible(enable);
- underline.setVisible(enable);
- subscript.setVisible(enable);
- superscript.setVisible(enable);
- justifyLeft.setVisible(enable);
- justifyCenter.setVisible(enable);
- justifyRight.setVisible(enable);
- backColor.setVisible(enable);
- fontColor.setVisible(enable);
- }
- if (extended != null) {
- strikethrough.setVisible(enable);
- indent.setVisible(enable);
- outdent.setVisible(enable);
- insertImage.setVisible(enable);
- createLink.setVisible(enable);
- removeLink.setVisible(enable);
- ol.setVisible(enable);
- ul.setVisible(enable);
- hr.setVisible(enable);
- removeFormat.setVisible(enable);
- fonts.setVisible(enable);
- fontSizes.setVisible(enable);
- }
- }
-
- private MenuBar createFontSizesMenu() {
- final MenuBar menu = new MenuBar();
- final MenuBar submenu = new MenuBar(true);
- final String fontSizes[] = { i18n.t("Extra small"), i18n.t("Very small"), i18n.t("Small"), i18n.t("Medium"),
- i18n.t("Large"), i18n.t("Very large"), i18n.t("Extra large") };
-
- KuneUiUtils.setQuickTip(menu, i18n.t("Font Size"));
- menu.addItem(images.fontheight().getHTML(), true, submenu);
- for (int i = 0; i < fontSizes.length; i++) {
- final String f = fontSizes[i];
- final int fontSize = i;
- submenu.addItem("<font size=\"" + (i + 1) + "\">" + f + "</font>", true, new Command() {
- public void execute() {
- basic.setFontSize(fontSizesConstants[fontSize]);
- fireEdit();
- }
- });
- }
- menu.setStyleName("RichTextToolbar-menu");
- submenu.setStyleName("RichTextToolbar-submenu");
- return menu;
- }
-
- private MenuBar createFontsMenu() {
- final MenuBar menu = new MenuBar();
- final MenuBar submenu = new MenuBar(true);
- final String fontName[] = { "Times New Roman", "Arial", "Courier New", "Georgia", "Trebuchet", "Verdana" };
-
- KuneUiUtils.setQuickTip(menu, i18n.t("Font Type"));
- menu.addItem(images.charfontname().getHTML(), true, submenu);
- for (final String f : fontName) {
- submenu.addItem("<span style=\"font-family: " + f + "\">" + f + "</span>", true, new Command() {
- public void execute() {
- basic.setFontName(f);
- fireEdit();
- }
- });
- }
- menu.setStyleName("RichTextToolbar-menu");
- submenu.setStyleName("RichTextToolbar-submenu");
- return menu;
- }
-
- private PushButton createPushButton(final AbstractImagePrototype img, final String tip) {
- final PushButton pb = new PushButton(img.createImage());
- pb.addClickListener(listener);
- KuneUiUtils.setQuickTip(pb, tip);
- return pb;
- }
-
- private ToggleButton createToggleButton(final AbstractImagePrototype img, final String tip) {
- final ToggleButton tb = new ToggleButton(img.createImage());
- tb.addClickListener(listener);
- KuneUiUtils.setQuickTip(tb, tip);
- return tb;
- }
-
- private void fireEdit() {
- presenter.onEdit();
- }
-
- private void fireEditHTML() {
- presenter.onEditHTML();
- }
-
- /**
- * Updates the status of all the stateful buttons.
- */
- private void updateStatus() {
- if (basic != null) {
- bold.setDown(basic.isBold());
- italic.setDown(basic.isItalic());
- underline.setDown(basic.isUnderlined());
- subscript.setDown(basic.isSubscript());
- superscript.setDown(basic.isSuperscript());
- }
-
- if (extended != null) {
- strikethrough.setDown(extended.isStrikethrough());
- }
- }
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorView.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorView.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,50 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.workspace.client.editor;
-
-import org.ourproject.kune.platf.client.View;
-
-public interface TextEditorView extends View {
-
- void attach();
-
- void detach();
-
- void editHTML(boolean edit);
-
- String getHTML();
-
- String getText();
-
- void saveTimerCancel();
-
- void scheduleSave(int delayMillis);
-
- void setEnabled(boolean enabled);
-
- void setHeight(String height);
-
- void setHTML(String html);
-
- void setText(String text);
-
- void showSaveBeforeDialog();
-
-}
\ No newline at end of file
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/alignleft.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/alignright.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/backcolor.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/bold.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/centerpara.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/charfontname.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/decrementindent.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/defaultbullet.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/defaultnumbering.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/edithtml.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/fontcolor.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/fontheight.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/hfixedline.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/images.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/incrementindent.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/italic.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/link.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/link_break.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/removeFormat.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/strikeout.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/subscript.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/superscript.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/underline.png
===================================================================
(Binary files differ)
Deleted: trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenterTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenterTest.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenterTest.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,158 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.mockito.internal.verification.api.VerificationMode;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
-import org.ourproject.kune.platf.client.state.StateManager;
-import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
-import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
-import org.ourproject.kune.platf.client.utils.TimerWrapper;
-
-import com.calclab.suco.client.events.Listener0;
-import com.calclab.suco.testing.events.MockedListener;
-import com.calclab.suco.testing.events.MockedListener0;
-import com.google.gwt.libideas.resources.client.ImageResource;
-
-public class RTESavingEditorPresenterTest {
-
- private RTESavingEditorPresenter presenter;
- private MockedListener<String> saveListener;
- private MockedListener0 cancelListener;
- private StateManager stateManager;
- private DeferredCommandWrapper deferredCommandWrapper;
- private RTEditor rteEditor;
- private TimerWrapper timer;
- @SuppressWarnings("unchecked")
- private ActionToolbar sndbar;
- private RTESavingEditorView view;
-
- @SuppressWarnings("unchecked")
- @Before
- public void createObjects() {
- I18nUITranslationService i18n = Mockito.mock(I18nUITranslationService.class);
- stateManager = Mockito.mock(StateManager.class);
- deferredCommandWrapper = Mockito.mock(DeferredCommandWrapper.class);
- rteEditor = Mockito.mock(RTEditor.class);
- RTEImgResources imgResources = Mockito.mock(RTEImgResources.class);
- ImageResource imageResource = Mockito.mock(ImageResource.class);
- Mockito.when(imageResource.getName()).thenReturn("save");
- Mockito.when(imgResources.save()).thenReturn(imageResource);
- sndbar = Mockito.mock(ActionToolbar.class);
- Mockito.when(rteEditor.getSndBar()).thenReturn(sndbar);
- timer = Mockito.mock(TimerWrapper.class);
- view = Mockito.mock(RTESavingEditorView.class);
- presenter = new RTESavingEditorPresenter(rteEditor, true, i18n, stateManager, deferredCommandWrapper,
- imgResources, timer);
- presenter.init(view);
- saveListener = new MockedListener<String>();
- cancelListener = new MockedListener0();
- }
-
- @Test
- public void historyChangeWithoutPendingMustAccept() {
- presenter.edit("Text to edit", saveListener, cancelListener);
- boolean change = presenter.beforeTokenChange();
- assertTrue(change);
- verifyAskConfirmationCalled(Mockito.never());
- Mockito.verify(deferredCommandWrapper, Mockito.times(1)).addCommand((Listener0) Mockito.anyObject());
- }
-
- @Test
- public void historyChangeWithPendingSaveAndCancelMustPosponeIt() {
- editAndChangeHistoryToken();
- presenter.onCancelConfirmed();
- assertTrue(saveListener.isNotCalled());
- Mockito.verify(stateManager, Mockito.times(1)).resumeTokenChange();
- }
-
- @Test
- public void historyChangeWithPendingSaveMustPosponeIt() {
- editAndChangeHistoryToken();
- presenter.onDoSaveAndClose();
- presenter.onSavedSuccessful();
- assertTrue(saveListener.isCalledOnce());
- Mockito.verify(stateManager, Mockito.times(1)).resumeTokenChange();
- }
-
- @Test
- public void initialEditWithCancel() {
- presenter.edit("Text to edit", saveListener, cancelListener);
- presenter.onCancel();
- assertTrue(saveListener.isNotCalled());
- assertTrue(cancelListener.isCalledOnce());
- }
-
- @Test
- public void initialEditWithEditionAndSave() {
- presenter.edit("Text to edit", saveListener, cancelListener);
- String textModified = "Text modified";
- Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
- presenter.onEdit();
- presenter.onDoSave();
- checkSaveBtnDisabled();
- assertTrue(saveListener.isCalledWithEquals(textModified));
- assertTrue(cancelListener.isNotCalled());
- }
-
- @Test
- public void initialEditWithSave() {
- presenter.edit("Text to edit", saveListener, cancelListener);
- presenter.onDoSave();
- checkSaveBtnDisabled();
- assertTrue(saveListener.isCalledOnce());
- assertTrue(cancelListener.isNotCalled());
- }
-
- @Test
- public void testSavePendingAndCancel() {
- presenter.edit("Text to edit", saveListener, cancelListener);
- String textModified = "Text modified";
- Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
- presenter.onEdit();
- presenter.onCancel();
- presenter.onCancelConfirmed();
- assertTrue(saveListener.isNotCalled());
- assertTrue(cancelListener.isCalledOnce());
- }
-
- @Test
- public void testSavePendingAndSaveFails() {
- presenter.edit("Text to edit", saveListener, cancelListener);
- String textModified = "Text modified";
- Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
- presenter.onEdit();
- presenter.onDoSave();
- presenter.onSaveFailed();
- presenter.onDoSave();
- Mockito.verify(timer, Mockito.times(1)).schedule(RTESavingEditorPresenter.AUTOSAVE_IN_MILLISECONDS);
- Mockito.verify(timer, Mockito.times(1)).schedule(RTESavingEditorPresenter.AUTOSAVE_AFTER_FAILS_IN_MILLISECONS);
- assertTrue(saveListener.isCalled(2));
- }
-
- @SuppressWarnings("unchecked")
- private void checkSaveBtnDisabled() {
- Mockito.verify(sndbar, Mockito.times(1)).setButtonEnable(presenter.saveBtn, false);
- }
-
- private String editAndChangeHistoryToken() {
- presenter.edit("Text to edit", saveListener, cancelListener);
- presenter.onEdit();
- String newToken = "somegroup";
- boolean change = presenter.beforeTokenChange();
- assertFalse(change);
- verifyAskConfirmationCalled(Mockito.times(1));
- return newToken;
- }
-
- private void verifyAskConfirmationCalled(VerificationMode mode) {
- Mockito.verify(view, mode).askConfirmation(Mockito.anyString(), Mockito.anyString(),
- (Listener0) Mockito.anyObject(), (Listener0) Mockito.anyObject());
- }
-
-}
Copied: trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenterTest.java (from rev 1069, trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenterTest.java)
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenterTest.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenterTest.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,161 @@
+package org.ourproject.kune.platf.client.ui.rte.saving;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.internal.verification.api.VerificationMode;
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
+import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
+import org.ourproject.kune.platf.client.state.StateManager;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
+import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
+import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPresenter;
+import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorView;
+import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
+import org.ourproject.kune.platf.client.utils.TimerWrapper;
+
+import com.calclab.suco.client.events.Listener0;
+import com.calclab.suco.testing.events.MockedListener;
+import com.calclab.suco.testing.events.MockedListener0;
+import com.google.gwt.libideas.resources.client.ImageResource;
+
+public class RTESavingEditorPresenterTest {
+
+ private RTESavingEditorPresenter presenter;
+ private MockedListener<String> saveListener;
+ private MockedListener0 cancelListener;
+ private StateManager stateManager;
+ private DeferredCommandWrapper deferredCommandWrapper;
+ private RTEditor rteEditor;
+ private TimerWrapper timer;
+ @SuppressWarnings("unchecked")
+ private ActionToolbar sndbar;
+ private RTESavingEditorView view;
+
+ @SuppressWarnings("unchecked")
+ @Before
+ public void createObjects() {
+ I18nUITranslationService i18n = Mockito.mock(I18nUITranslationService.class);
+ stateManager = Mockito.mock(StateManager.class);
+ deferredCommandWrapper = Mockito.mock(DeferredCommandWrapper.class);
+ rteEditor = Mockito.mock(RTEditor.class);
+ RTEImgResources imgResources = Mockito.mock(RTEImgResources.class);
+ ImageResource imageResource = Mockito.mock(ImageResource.class);
+ Mockito.when(imageResource.getName()).thenReturn("save");
+ Mockito.when(imgResources.save()).thenReturn(imageResource);
+ sndbar = Mockito.mock(ActionToolbar.class);
+ Mockito.when(rteEditor.getSndBar()).thenReturn(sndbar);
+ timer = Mockito.mock(TimerWrapper.class);
+ view = Mockito.mock(RTESavingEditorView.class);
+ presenter = new RTESavingEditorPresenter(rteEditor, true, i18n, stateManager, deferredCommandWrapper,
+ imgResources, timer);
+ presenter.init(view);
+ saveListener = new MockedListener<String>();
+ cancelListener = new MockedListener0();
+ }
+
+ @Test
+ public void historyChangeWithoutPendingMustAccept() {
+ presenter.edit("Text to edit", saveListener, cancelListener);
+ boolean change = presenter.beforeTokenChange();
+ assertTrue(change);
+ verifyAskConfirmationCalled(Mockito.never());
+ Mockito.verify(deferredCommandWrapper, Mockito.times(1)).addCommand((Listener0) Mockito.anyObject());
+ }
+
+ @Test
+ public void historyChangeWithPendingSaveAndCancelMustPosponeIt() {
+ editAndChangeHistoryToken();
+ presenter.onCancelConfirmed();
+ assertTrue(saveListener.isNotCalled());
+ Mockito.verify(stateManager, Mockito.times(1)).resumeTokenChange();
+ }
+
+ @Test
+ public void historyChangeWithPendingSaveMustPosponeIt() {
+ editAndChangeHistoryToken();
+ presenter.onDoSaveAndClose();
+ presenter.onSavedSuccessful();
+ assertTrue(saveListener.isCalledOnce());
+ Mockito.verify(stateManager, Mockito.times(1)).resumeTokenChange();
+ }
+
+ @Test
+ public void initialEditWithCancel() {
+ presenter.edit("Text to edit", saveListener, cancelListener);
+ presenter.onCancel();
+ assertTrue(saveListener.isNotCalled());
+ assertTrue(cancelListener.isCalledOnce());
+ }
+
+ @Test
+ public void initialEditWithEditionAndSave() {
+ presenter.edit("Text to edit", saveListener, cancelListener);
+ String textModified = "Text modified";
+ Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
+ presenter.onEdit();
+ presenter.onDoSave();
+ checkSaveBtnDisabled();
+ assertTrue(saveListener.isCalledWithEquals(textModified));
+ assertTrue(cancelListener.isNotCalled());
+ }
+
+ @Test
+ public void initialEditWithSave() {
+ presenter.edit("Text to edit", saveListener, cancelListener);
+ presenter.onDoSave();
+ checkSaveBtnDisabled();
+ assertTrue(saveListener.isCalledOnce());
+ assertTrue(cancelListener.isNotCalled());
+ }
+
+ @Test
+ public void testSavePendingAndCancel() {
+ presenter.edit("Text to edit", saveListener, cancelListener);
+ String textModified = "Text modified";
+ Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
+ presenter.onEdit();
+ presenter.onCancel();
+ presenter.onCancelConfirmed();
+ assertTrue(saveListener.isNotCalled());
+ assertTrue(cancelListener.isCalledOnce());
+ }
+
+ @Test
+ public void testSavePendingAndSaveFails() {
+ presenter.edit("Text to edit", saveListener, cancelListener);
+ String textModified = "Text modified";
+ Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
+ presenter.onEdit();
+ presenter.onDoSave();
+ presenter.onSaveFailed();
+ presenter.onDoSave();
+ Mockito.verify(timer, Mockito.times(1)).schedule(RTESavingEditorPresenter.AUTOSAVE_IN_MILLISECONDS);
+ Mockito.verify(timer, Mockito.times(1)).schedule(RTESavingEditorPresenter.AUTOSAVE_AFTER_FAILS_IN_MILLISECONS);
+ assertTrue(saveListener.isCalled(2));
+ }
+
+ @SuppressWarnings("unchecked")
+ private void checkSaveBtnDisabled() {
+ Mockito.verify(sndbar, Mockito.times(1)).setButtonEnable(presenter.saveBtn, false);
+ }
+
+ private String editAndChangeHistoryToken() {
+ presenter.edit("Text to edit", saveListener, cancelListener);
+ presenter.onEdit();
+ String newToken = "somegroup";
+ boolean change = presenter.beforeTokenChange();
+ assertFalse(change);
+ verifyAskConfirmationCalled(Mockito.times(1));
+ return newToken;
+ }
+
+ private void verifyAskConfirmationCalled(VerificationMode mode) {
+ Mockito.verify(view, mode).askConfirmation(Mockito.anyString(), Mockito.anyString(),
+ (Listener0) Mockito.anyObject(), (Listener0) Mockito.anyObject());
+ }
+
+}
More information about the kune-commits
mailing list