[kune-commits] r1057 - in trunk/src:
main/java/org/ourproject/kune/platf/client/actions
main/java/org/ourproject/kune/platf/client/actions/toolbar
main/java/org/ourproject/kune/platf/client/i18n
main/java/org/ourproject/kune/platf/client/services
main/java/org/ourproject/kune/platf/client/ui/rte
test/java/org/ourproject/kune/platf/client/actions
vjrj
vjrj at ourproject.org
Tue Mar 3 20:31:58 CET 2009
Author: vjrj
Date: 2009-03-03 20:31:56 +0100 (Tue, 03 Mar 2009)
New Revision: 1057
Modified:
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuDescriptor.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/i18n/I18nUITranslationService.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.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/TestRTEDialog.java
trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java
Log:
Incomplete - task Better RTE (Rich Text Editor) support
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java 2009-03-03 15:10:55 UTC (rev 1056)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java 2009-03-03 19:31:56 UTC (rev 1057)
@@ -10,32 +10,46 @@
return ((modifiers & modifier) == modifier);
}
- final boolean alt;
- final boolean ctrl;
- final boolean shift;
+ private final boolean alt;
+ private final boolean ctrl;
+ private final boolean shift;
+ private final char key;
+ private final String keyName;
- final char key;
-
- public ActionShortcut(boolean alt, boolean ctrl, boolean shift, char key) {
+ public ActionShortcut(boolean alt, boolean ctrl, boolean shift, char key, String keyName) {
this.alt = alt;
this.ctrl = ctrl;
this.shift = shift;
this.key = key;
+ this.keyName = keyName;
}
public ActionShortcut(boolean ctrl, boolean shift, char key) {
- this(false, ctrl, shift, key);
+ this(false, ctrl, shift, key, null);
}
+ public ActionShortcut(boolean ctrl, boolean shift, char key, String keyName) {
+ this(false, ctrl, shift, key, keyName);
+ }
+
public ActionShortcut(boolean ctrl, char key) {
- this(false, ctrl, false, key);
+ this(false, ctrl, false, key, null);
}
+ public ActionShortcut(boolean ctrl, char key, String keyName) {
+ this(false, ctrl, false, key, keyName);
+ }
+
public ActionShortcut(char key, int modifiers) {
this(has(modifiers, KeyboardListener.MODIFIER_ALT), has(modifiers, KeyboardListener.MODIFIER_CTRL), has(
- modifiers, KeyboardListener.MODIFIER_SHIFT), key);
+ modifiers, KeyboardListener.MODIFIER_SHIFT), key, null);
}
+ public ActionShortcut(char key, int modifiers, String keyName) {
+ this(has(modifiers, KeyboardListener.MODIFIER_ALT), has(modifiers, KeyboardListener.MODIFIER_CTRL), has(
+ modifiers, KeyboardListener.MODIFIER_SHIFT), key, keyName);
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -89,12 +103,16 @@
s += sKey(alt, "Alt", i18n);
s += sKey(ctrl, "Ctrl", i18n);
s += sKey(shift, "Shift", i18n);
- s += String.valueOf(key).toUpperCase() + ")";
+ s += keyName != null ? translateKey(keyName, i18n) + ")" : String.valueOf(key).toUpperCase() + ")";
return s;
}
- private String sKey(boolean key, String keyName, I18nTranslationService i18n) {
- return key ? i18n.tWithNT(keyName, "The '" + keyName + "' keyboard key") + "+" : "";
+ private String sKey(boolean key, String specialKeyName, I18nTranslationService i18n) {
+ return key ? translateKey(specialKeyName, i18n) + "+" : "";
}
+ private String translateKey(String keyNameToTranslate, I18nTranslationService i18n) {
+ return i18n.tWithNT(keyNameToTranslate, "The '" + keyNameToTranslate + "' keyboard key");
+ }
+
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuDescriptor.java 2009-03-03 15:10:55 UTC (rev 1056)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuDescriptor.java 2009-03-03 19:31:56 UTC (rev 1057)
@@ -29,6 +29,7 @@
private String parentMenuTitle;
private String parentMenuIconUrl;
+ private String parentMenuIconCls;
private String parentSubMenuTitle;
public ActionToolbarMenuDescriptor(final AccessRolDTO accessRolDTO,
@@ -65,6 +66,10 @@
super(accessRolDTO, actionToolbarPosition, onPerformCall, enableCondition);
}
+ public String getParentMenuIconCls() {
+ return parentMenuIconCls;
+ }
+
public String getParentMenuIconUrl() {
return parentMenuIconUrl;
}
@@ -77,6 +82,10 @@
return parentSubMenuTitle;
}
+ public void setParentMenuIconCls(String parentMenuIconCls) {
+ this.parentMenuIconCls = parentMenuIconCls;
+ }
+
public void setParentMenuIconUrl(final String parentMenuIconUrl) {
this.parentMenuIconUrl = parentMenuIconUrl;
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java 2009-03-03 15:10:55 UTC (rev 1056)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java 2009-03-03 19:31:56 UTC (rev 1057)
@@ -207,19 +207,20 @@
final ActionToolbarMenuDescriptor<T> action = (ActionToolbarMenuDescriptor<T>) actionItem.getAction();
final Item item;
if (action instanceof ActionToolbarMenuRadioDescriptor) {
- CheckItem checkItem = new CheckItem(action.getText() + action.getShortcutToS(i18n));
+ CheckItem checkItem = new CheckItem();
ActionToolbarMenuRadioDescriptor<T> radioDescriptor = (ActionToolbarMenuRadioDescriptor<T>) action;
checkItem.setGroup(radioDescriptor.getGroup());
checkItem.setChecked(radioDescriptor.mustBeChecked());
item = checkItem;
} else if (action instanceof ActionToolbarMenuCheckItemDescriptor) {
- CheckItem checkItem = new CheckItem(action.getText() + action.getShortcutToS(i18n));
+ CheckItem checkItem = new CheckItem();
ActionToolbarMenuCheckItemDescriptor<T> checkItemDescriptor = (ActionToolbarMenuCheckItemDescriptor<T>) action;
checkItem.setChecked(checkItemDescriptor.getMustBeChecked().mustBeChecked());
item = checkItem;
} else {
- item = new Item(action.getText() + action.getShortcutToS(i18n));
+ item = new Item();
}
+ item.setText(genMenuItemText(action));
BaseItemListenerAdapter clickListener = new BaseItemListenerAdapter() {
@Override
public void onClick(BaseItem item, EventObject e) {
@@ -227,11 +228,13 @@
}
};
item.addListener(clickListener);
- if (action.getIconCls() != null) {
- item.setIconCls(action.getIconCls());
+ String iconCls = action.getIconCls();
+ String iconUrl = action.getIconUrl();
+ if (iconCls != null) {
+ item.setIconCls(iconCls);
}
- if (action.getIconUrl() != null) {
- item.setIcon(action.getIconUrl());
+ if (iconUrl != null) {
+ item.setIcon(iconUrl);
}
// ToolTip tip = new ToolTip();
// tip.setHtml(action.getToolTip());
@@ -250,7 +253,8 @@
subMenu = new Menu();
final MenuItem subMenuItem = new MenuItem(menuSubTitle, subMenu);
if (menu == null) {
- menu = createToolbarMenu(toolBarPos, action.getParentMenuIconUrl(), menuTitle, menuKey);
+ menu = createToolbarMenu(toolBarPos, action.getParentMenuIconUrl(), action.getParentMenuIconCls(),
+ menuTitle, menuKey);
}
menu.addItem(subMenuItem);
toolbarMenus.put(subMenuKey, subMenu);
@@ -260,14 +264,14 @@
} else {
// Menu action without submenu
if (menu == null) {
- menu = createToolbarMenu(toolBarPos, action.getParentMenuIconUrl(), menuTitle, menuKey);
+ menu = createToolbarMenu(toolBarPos, action.getParentMenuIconUrl(), null, menuTitle, menuKey);
}
menu.addItem(item);
}
return item;
}
- private Menu createToolbarMenu(final ActionToolbarPosition barPosition, final String iconUrl,
+ private Menu createToolbarMenu(final ActionToolbarPosition barPosition, final String iconUrl, final String iconCls,
final String menuTitle, final String menuKey) {
final Menu menu = new Menu();
final ToolbarButton toolbarMenu = new ToolbarButton(menuTitle);
@@ -275,6 +279,9 @@
if (iconUrl != null) {
toolbarMenu.setIcon(iconUrl);
}
+ if (iconCls != null) {
+ toolbarMenu.setIconCls(iconCls);
+ }
toolbarMenus.put(menuKey, menu);
add(barPosition, toolbarMenu);
return menu;
@@ -300,6 +307,16 @@
return id;
}
+ private String genMenuItemText(final ActionToolbarMenuDescriptor<T> action) {
+ // HorizontalPanel hp = new HorizontalPanel();
+ // Label title = new Label(action.getText());
+ // hp.add(title);
+ // hp.setCellWidth(title, "100%");
+ // hp.add(new Label(action.getShortcutToS(i18n)));
+ // return hp.getElement().getInnerHTML();
+ return action.getText() + action.getShortcutToS(i18n);
+ }
+
private String genMenuKey(final ActionToolbarPosition pos, final String menuTitle, final String menuSubTitle,
final String actionText) {
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/i18n/I18nUITranslationService.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/i18n/I18nUITranslationService.java 2009-03-03 15:10:55 UTC (rev 1056)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/i18n/I18nUITranslationService.java 2009-03-03 19:31:56 UTC (rev 1057)
@@ -62,15 +62,24 @@
}
public String formatDateWithLocale(final Date date) {
- String dateFormat = currentLang.getDateFormat();
+ return formatDateWithLocale(date, false);
+ }
+
+ public String formatDateWithLocale(final Date date, boolean shortFormat) {
+ String dateFormat = shortFormat ? currentLang.getDateFormatShort() : currentLang.getDateFormat();
+
final DateTimeFormat fmt;
if (dateFormat == null) {
- fmt = DateTimeFormat.getFormat("M/d/yyyy h:mm a");
+ fmt = shortFormat ? DateTimeFormat.getFormat("M/d/yyyy") : DateTimeFormat.getFormat("M/d/yyyy h:mm a");
} else {
- String abrevMonthInEnglish = DateTimeFormat.getFormat("MMM").format(date);
- String monthToTranslate = abrevMonthInEnglish + " [%NT abbreviated month]";
- dateFormat = dateFormat.replaceFirst("MMM", "'" + t(monthToTranslate) + "'");
- fmt = DateTimeFormat.getFormat(dateFormat + " h:mm a");
+ if (shortFormat) {
+ fmt = DateTimeFormat.getFormat(dateFormat);
+ } else {
+ String abrevMonthInEnglish = DateTimeFormat.getFormat("MMM").format(date);
+ String monthToTranslate = abrevMonthInEnglish + " [%NT abbreviated month]";
+ dateFormat = dateFormat.replaceFirst("MMM", "'" + t(monthToTranslate) + "'");
+ fmt = DateTimeFormat.getFormat(dateFormat + " h:mm a");
+ }
}
String dateFormated = fmt.format(date);
return dateFormated;
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-03 15:10:55 UTC (rev 1056)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java 2009-03-03 19:31:56 UTC (rev 1057)
@@ -57,6 +57,7 @@
import org.ourproject.kune.platf.client.ui.rte.TestRTEDialog;
import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
+import org.ourproject.kune.workspace.client.editor.insert.TextEditorInsertElement;
import com.calclab.suco.client.events.Listener0;
import com.calclab.suco.client.ioc.decorator.NoDecoration;
@@ -232,7 +233,7 @@
RTEActionTopToolbar topBar = $(RTEActionTopToolbar.class);
RTEActionSndToolbar sndBar = $(RTEActionSndToolbar.class);
final RTEditorPresenter presenter = new RTEditorPresenter($(I18nTranslationService.class),
- $(Session.class), topBar, sndBar, $(RTEImgResources.class));
+ $(Session.class), topBar, sndBar, $(RTEImgResources.class), $(TextEditorInsertElement.class));
final RTEditorPanel panel = new RTEditorPanel(presenter, $(I18nUITranslationService.class),
$(ActionManager.class));
presenter.init(panel);
Modified: 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-03 15:10:55 UTC (rev 1056)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java 2009-03-03 19:31:56 UTC (rev 1057)
@@ -4,25 +4,26 @@
import org.ourproject.kune.platf.client.actions.ActionCollection;
import org.ourproject.kune.platf.client.actions.ActionDescriptor;
import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-import org.ourproject.kune.platf.client.dto.AccessRolDTO;
import org.ourproject.kune.platf.client.ui.rte.RTEditorPresenter.ActionPosition;
+import com.calclab.suco.client.events.Listener0;
+
public interface RTEditor {
void addAction(ActionDescriptor<Object> action, boolean basic, ActionPosition position);
void addActions(ActionCollection<Object> actions, boolean basic, ActionPosition position);
+ void addOnEditListener(Listener0 listener);
+
void editContent(String content);
+ View getEditorArea();
+
ActionToolbar<Object> getSndBar();
ActionToolbar<Object> getTopBar();
- View getView();
-
- void setAccessRol(AccessRolDTO accessRol);
-
void setExtended(boolean extended);
}
Modified: 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-03 15:10:55 UTC (rev 1056)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java 2009-03-03 19:31:56 UTC (rev 1057)
@@ -53,7 +53,7 @@
}
public void addComment(String userName) {
- String time = i18n.formatDateWithLocale(new Date());
+ String time = i18n.formatDateWithLocale(new Date(), true);
Element span = DOM.createSpan();
span.setInnerText(i18n.t("type here") + " -" + userName + " " + time);
DOM.setElementProperty(span.<com.google.gwt.user.client.Element> cast(), "className", "k-rte-comment");
@@ -92,10 +92,6 @@
extended.insertHorizontalRule();
}
- public void insertHR() {
- extended.insertHorizontalRule();
- }
-
public void insertHtml(String html) {
extended.insertHtml(html);
}
@@ -112,8 +108,11 @@
extended.insertUnorderedList();
}
+ public boolean isAttached() {
+ return rta.isAttached();
+ }
+
public boolean isBold() {
- Log.debug("Is bold: " + basic.isBold());
return basic.isBold();
}
@@ -239,16 +238,18 @@
extended.removeLink();
}
+ protected void fireEdit() {
+ presenter.fireOnEdit();
+ }
+
private void createListeners() {
rta.addClickListener(new ClickListener() {
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 cursur
- // using the
- // keyboard, or uses one of the browser's built-in keyboard
- // shortcuts.
+ // 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();
}
}
@@ -270,7 +271,7 @@
// keyboard shortcuts.
updateStatus();
- // fireEdit();
+ fireEdit();
if (modifiers != 0) {
ActionItem<Object> actionItem = shortcuts.get(new ActionShortcut(keyCode, modifiers));
if (actionItem != null) {
Modified: 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-03 15:10:55 UTC (rev 1056)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java 2009-03-03 19:31:56 UTC (rev 1057)
@@ -7,17 +7,25 @@
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.ActionToolbarPosition;
import org.ourproject.kune.platf.client.actions.ActionToolbarPushButtonDescriptor;
import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPanel;
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.SimpleToolbar;
+import org.ourproject.kune.platf.client.ui.TextUtils;
import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
+import org.ourproject.kune.workspace.client.editor.insert.TextEditorInsertElement;
+import com.calclab.suco.client.events.Event0;
import com.calclab.suco.client.events.Listener0;
+import com.calclab.suco.client.events.Listener2;
import com.google.gwt.libideas.resources.client.ImageResource;
public class RTEditorPresenter implements RTEditor {
@@ -30,7 +38,7 @@
private static final String INSERT_MENU = "Insert";
private RTEditorView view;
private boolean extended;
- private AccessRolDTO accessRol;
+ private final AccessRolDTO accessRol;
private final I18nTranslationService i18n;
private final Session session;
private final ActionItemCollection<Object> basicTopActions;
@@ -44,13 +52,20 @@
private ActionToolbarPushButtonDescriptor<Object> italic;
private ActionToolbarPushButtonDescriptor<Object> underline;
private ActionToolbarPushButtonDescriptor<Object> strikethrough;
+ private final Event0 onEdit;
+ private ActionToolbarPushButtonDescriptor<Object> subscript;
+ private ActionToolbarPushButtonDescriptor<Object> superscript;
+ private final TextEditorInsertElement insertElement;
public RTEditorPresenter(I18nTranslationService i18n, Session session, RTEActionTopToolbar topBar,
- RTEActionSndToolbar sndBar, RTEImgResources imgResources) {
+ RTEActionSndToolbar sndBar, RTEImgResources imgResources, TextEditorInsertElement textEditorInsertElement) {
this.i18n = i18n;
this.session = session;
this.topBar = topBar;
this.sndBar = sndBar;
+ this.insertElement = textEditorInsertElement;
+ styleToolbar(topBar);
+ styleToolbar(sndBar);
sndBar.attach();
this.imgResources = imgResources;
extended = true;
@@ -59,6 +74,7 @@
basicSndActions = new ActionItemCollection<Object>();
extendedTopActions = new ActionItemCollection<Object>();
extendedSndActions = new ActionItemCollection<Object>();
+ this.onEdit = new Event0("onRTEEdit");
}
public void addAction(ActionDescriptor<Object> action, boolean basic, ActionPosition position) {
@@ -99,9 +115,21 @@
}
}
+ public void addOnEditListener(final Listener0 listener) {
+ onEdit.add(listener);
+ }
+
public void editContent(String content) {
}
+ public void fireOnEdit() {
+ onEdit.fire();
+ }
+
+ public View getEditorArea() {
+ return view;
+ }
+
public ActionToolbar<Object> getSndBar() {
return sndBar;
}
@@ -110,13 +138,9 @@
return topBar;
}
- public View getView() {
- return view;
- }
-
public void init(RTEditorView view) {
this.view = view;
- createDefBasicActions();
+ createBasicActions();
if (view.canBeBasic()) {
view.addActions(basicTopActions);
view.addActions(basicSndActions);
@@ -124,7 +148,6 @@
sndBar.addActions(basicSndActions);
}
if (isExtended()) {
- createDefExtendedActions();
view.addActions(extendedTopActions);
view.addActions(extendedSndActions);
topBar.addActions(extendedTopActions);
@@ -132,10 +155,6 @@
}
}
- public void setAccessRol(AccessRolDTO accessRol) {
- this.accessRol = accessRol;
- }
-
public void setExtended(boolean extended) {
this.extended = extended;
}
@@ -145,13 +164,15 @@
sndBar.setPushButtonPressed(bold, view.isBold());
sndBar.setPushButtonPressed(italic, view.isItalic());
sndBar.setPushButtonPressed(underline, view.isUnderlined());
+ sndBar.setPushButtonPressed(subscript, view.isSubscript());
+ sndBar.setPushButtonPressed(superscript, view.isSuperscript());
}
if (isExtended()) {
sndBar.setPushButtonPressed(strikethrough, view.isStrikethrough());
}
}
- private void createDefBasicActions() {
+ private void createBasicActions() {
ActionToolbarMenuDescriptor<Object> selectAll = new ActionToolbarMenuDescriptor<Object>(accessRol,
ActionToolbarPosition.topbar, new Listener0() {
public void onEvent() {
@@ -189,14 +210,60 @@
});
underline.setIconCls(getCssName(imgResources.underline()));
underline.setToolTip(i18n.t("Toggle Underline"));
+ underline.setShortcut(new ActionShortcut(true, 'U'));
- basicTopActions.add(withNoItem(selectAll));
- basicSndActions.add(withNoItem(bold));
- basicSndActions.add(withNoItem(italic));
- basicSndActions.add(withNoItem(underline));
- }
+ subscript = new ActionToolbarPushButtonDescriptor<Object>(accessRol, ActionToolbarPosition.topbar,
+ new Listener0() {
+ public void onEvent() {
+ view.toggleSubscript();
+ }
+ });
+ subscript.setIconCls(getCssName(imgResources.superscript()));
+ subscript.setToolTip(i18n.t("Toggle Subscript"));
+ subscript.setShortcut(new ActionShortcut(true, ','));
- private void createDefExtendedActions() {
+ superscript = new ActionToolbarPushButtonDescriptor<Object>(accessRol, ActionToolbarPosition.topbar,
+ new Listener0() {
+ public void onEvent() {
+ view.toggleSuperscript();
+ }
+ });
+ superscript.setIconCls(getCssName(imgResources.superscript()));
+ superscript.setToolTip(i18n.t("Toggle Superscript"));
+ superscript.setRightSeparator(ActionToolbarButtonSeparator.spacer);
+ superscript.setShortcut(new ActionShortcut(true, '.'));
+
+ ActionToolbarButtonDescriptor<Object> justifyLeft = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ ActionToolbarPosition.topbar, new Listener0() {
+ public void onEvent() {
+ view.justifyLeft();
+ }
+ });
+ justifyLeft.setIconCls(getCssName(imgResources.alignleft()));
+ justifyLeft.setToolTip(i18n.t("Left Justify"));
+ justifyLeft.setShortcut(new ActionShortcut(true, 'L'));
+
+ ActionToolbarButtonDescriptor<Object> justifyCentre = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ ActionToolbarPosition.topbar, new Listener0() {
+ public void onEvent() {
+ view.justifyCenter();
+ }
+ });
+ justifyCentre.setIconCls(getCssName(imgResources.centerpara()));
+ justifyCentre.setToolTip(i18n.t("Centre Justify"));
+ justifyCentre.setShortcut(new ActionShortcut(true, 'E'));
+
+ ActionToolbarButtonDescriptor<Object> justifyRight = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ ActionToolbarPosition.topbar, new Listener0() {
+ public void onEvent() {
+ view.justifyRight();
+ }
+ });
+ justifyRight.setIconCls(getCssName(imgResources.alignright()));
+ justifyRight.setToolTip(i18n.t("Right Justify"));
+ justifyRight.setShortcut(new ActionShortcut(true, 'R'));
+ justifyRight.setRightSeparator(ActionToolbarButtonSeparator.spacer);
+
ActionToolbarMenuDescriptor<Object> undo = new ActionToolbarMenuDescriptor<Object>(accessRol,
ActionToolbarPosition.topbar, new Listener0() {
public void onEvent() {
@@ -279,8 +346,19 @@
}
});
hr.setTextDescription(i18n.t("Horizontal line"));
+ hr.setIconCls(getCssName(imgResources.hfixedline()));
hr.setParentMenuTitle(i18n.t(INSERT_MENU));
+ ActionToolbarButtonDescriptor<Object> hrButton = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ ActionToolbarPosition.topbar, new Listener0() {
+ public void onEvent() {
+ view.insertHorizontalRule();
+ }
+ });
+ hrButton.setIconCls(getCssName(imgResources.hfixedline()));
+ hrButton.setToolTip(i18n.t("Horizontal line"));
+ hrButton.setShortcut(new ActionShortcut(true, true, ' ', "Space"));
+
strikethrough = new ActionToolbarPushButtonDescriptor<Object>(accessRol, ActionToolbarPosition.topbar,
new Listener0() {
public void onEvent() {
@@ -289,7 +367,103 @@
});
strikethrough.setIconCls(getCssName(imgResources.strikeout()));
strikethrough.setToolTip(i18n.t("Toggle Strikethrough"));
+ strikethrough.setRightSeparator(ActionToolbarButtonSeparator.spacer);
+ ActionToolbarButtonDescriptor<Object> decreaseIndent = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ ActionToolbarPosition.topbar, new Listener0() {
+ public void onEvent() {
+ view.leftIndent();
+ }
+ });
+ decreaseIndent.setIconCls(getCssName(imgResources.decrementindent()));
+ decreaseIndent.setToolTip(i18n.t("Decrease Indent"));
+
+ ActionToolbarButtonDescriptor<Object> increaseIndent = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ ActionToolbarPosition.topbar, new Listener0() {
+ public void onEvent() {
+ view.rightIndent();
+ }
+ });
+ increaseIndent.setIconCls(getCssName(imgResources.incrementindent()));
+ increaseIndent.setToolTip(i18n.t("Increase Indent"));
+ increaseIndent.setRightSeparator(ActionToolbarButtonSeparator.spacer);
+
+ ActionToolbarButtonDescriptor<Object> ol = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ ActionToolbarPosition.topbar, new Listener0() {
+ public void onEvent() {
+ view.insertOrderedList();
+ }
+ });
+ ol.setIconCls(getCssName(imgResources.defaultnumbering()));
+ ol.setToolTip(i18n.t("Numbered List"));
+ ol.setShortcut(new ActionShortcut(true, '7'));
+
+ ActionToolbarButtonDescriptor<Object> ul = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ ActionToolbarPosition.topbar, new Listener0() {
+ public void onEvent() {
+ view.insertUnorderedList();
+ }
+ });
+ ul.setIconCls(getCssName(imgResources.defaultbullet()));
+ ul.setToolTip(i18n.t("Bullet List"));
+ ul.setShortcut(new ActionShortcut(true, '8'));
+ ul.setRightSeparator(ActionToolbarButtonSeparator.spacer);
+
+ ActionToolbarButtonDescriptor<Object> img = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ ActionToolbarPosition.topbar, new Listener0() {
+ public void onEvent() {
+ NotifyUser.info(TextUtils.IN_DEVELOPMENT);
+ }
+ });
+ img.setIconCls(getCssName(imgResources.images()));
+ img.setToolTip(i18n.t("Insert Image"));
+
+ ActionToolbarButtonDescriptor<Object> createLink = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ ActionToolbarPosition.topbar, new Listener0() {
+ public void onEvent() {
+ insertElement.show();
+ }
+ });
+ createLink.setIconCls(getCssName(imgResources.link()));
+ createLink.setToolTip(i18n.t("Create Link"));
+ createLink.setShortcut(new ActionShortcut(true, 'K'));
+ insertElement.addOnCreateLink(new Listener2<String, String>() {
+ public void onEvent(String name, String url) {
+ view.createLink(url);
+ }
+ });
+
+ ActionToolbarButtonDescriptor<Object> removeLink = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ ActionToolbarPosition.topbar, new Listener0() {
+ public void onEvent() {
+ view.unlink();
+ }
+ });
+ removeLink.setIconCls(getCssName(imgResources.linkbreak()));
+ removeLink.setToolTip(i18n.t("Remove Link"));
+ removeLink.setShortcut(new ActionShortcut(true, true, 'K'));
+
+ ActionToolbarButtonDescriptor<Object> removeFormat = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ ActionToolbarPosition.topbar, new Listener0() {
+ public void onEvent() {
+ view.removeFormat();
+ }
+ });
+ removeFormat.setIconCls(getCssName(imgResources.removeFormat()));
+ removeFormat.setToolTip(i18n.t("Clear Formatting"));
+ removeFormat.setShortcut(new ActionShortcut(true, ' ', "Space"));
+
+ basicTopActions.add(withNoItem(selectAll));
+ basicSndActions.add(withNoItem(bold));
+ basicSndActions.add(withNoItem(italic));
+ basicSndActions.add(withNoItem(underline));
+ extendedSndActions.add(withNoItem(strikethrough));
+ basicSndActions.add(withNoItem(subscript));
+ basicSndActions.add(withNoItem(superscript));
+ basicSndActions.add(withNoItem(justifyLeft));
+ basicSndActions.add(withNoItem(justifyCentre));
+ basicSndActions.add(withNoItem(justifyRight));
+
extendedTopActions.add(withNoItem(undo));
extendedTopActions.add(withNoItem(redo));
extendedTopActions.add(withNoItem(copy));
@@ -297,8 +471,16 @@
extendedTopActions.add(withNoItem(paste));
extendedTopActions.add(withNoItem(editHtml));
extendedTopActions.add(withNoItem(hr));
+ extendedSndActions.add(withNoItem(hrButton));
+ extendedSndActions.add(withNoItem(decreaseIndent));
+ extendedSndActions.add(withNoItem(increaseIndent));
+ extendedSndActions.add(withNoItem(ol));
+ extendedSndActions.add(withNoItem(ul));
+ extendedSndActions.add(withNoItem(img));
+ extendedSndActions.add(withNoItem(createLink));
+ extendedSndActions.add(withNoItem(removeLink));
+ extendedSndActions.add(withNoItem(removeFormat));
extendedTopActions.add(withNoItem(comment));
- extendedSndActions.add(withNoItem(strikethrough));
}
private String getCssName(ImageResource imageResource) {
@@ -317,6 +499,13 @@
};
}
+ private void styleToolbar(ActionToolbar<Object> topBar) {
+ SimpleToolbar toolbar = ((ActionToolbarPanel<Object>) topBar.getView()).getToolbar(ActionToolbarPosition.topbar);
+ toolbar.setStyleName("x-toolbar");
+ toolbar.addStyleName("x-panel");
+ toolbar.addStyleName("k-toolbar-bottom-line");
+ }
+
private ActionItemCollection<Object> withNoItem(ActionCollection<Object> actions) {
ActionItemCollection<Object> collection = new ActionItemCollection<Object>();
for (ActionDescriptor<Object> action : actions) {
Modified: 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-03 15:10:55 UTC (rev 1056)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java 2009-03-03 19:31:56 UTC (rev 1057)
@@ -31,6 +31,8 @@
void insertUnorderedList();
+ boolean isAttached();
+
boolean isBold();
boolean isItalic();
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-03 15:10:55 UTC (rev 1056)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java 2009-03-03 19:31:56 UTC (rev 1057)
@@ -9,12 +9,12 @@
public class TestRTEDialog {
public TestRTEDialog(RTEditor editor) {
- BasicDialog dialog = new BasicDialog("Testing RTE", false);
+ BasicDialog dialog = new BasicDialog("Testing RTE", false, false, 400, 200);
VerticalPanel vp = new VerticalPanel();
vp.add(((ActionToolbarPanel<Object>) editor.getTopBar().getView()).getToolbar(ActionToolbarPosition.topbar));
vp.add(((ActionToolbarPanel<Object>) editor.getSndBar().getView()).getToolbar(ActionToolbarPosition.topbar));
- vp.add(((RTEditorPanel) editor.getView()).getRTE());
+ vp.add(((RTEditorPanel) editor.getEditorArea()).getRTE());
dialog.add(vp);
dialog.show();
}
Modified: trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java 2009-03-03 15:10:55 UTC (rev 1056)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java 2009-03-03 19:31:56 UTC (rev 1057)
@@ -15,7 +15,7 @@
@Test
public void altS() {
- ActionShortcut shortcut = new ActionShortcut(true, false, false, 'S');
+ ActionShortcut shortcut = new ActionShortcut(true, false, false, 'S', null);
assertEquals(" (Alt+S)", shortcut.toString(i18n));
assertTrue(shortcut.is('S', KeyboardListener.MODIFIER_ALT));
assertTrue(!shortcut.is('S', KeyboardListener.MODIFIER_CTRL));
@@ -47,7 +47,7 @@
@Test
public void ctrlShiftS() {
- ActionShortcut shortcut = new ActionShortcut(false, true, true, 'S');
+ ActionShortcut shortcut = new ActionShortcut(false, true, true, 'S', null);
assertEquals(" (Ctrl+Shift+S)", shortcut.toString(i18n));
assertTrue(!shortcut.is('S', KeyboardListener.MODIFIER_ALT));
assertTrue(shortcut.is('S', KeyboardListener.MODIFIER_SHIFT | KeyboardListener.MODIFIER_CTRL));
More information about the kune-commits
mailing list