[kune-commits] r1088 - in trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte: basic insertimg insertimg/abstractimg insertlink saving

vjrj vjrj at ourproject.org
Thu Mar 26 01:08:00 CET 2009


Author: vjrj
Date: 2009-03-26 01:07:59 +0100 (Thu, 26 Mar 2009)
New Revision: 1088

Modified:
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ImageInfo.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/abstractimg/InsertImageAbstractPanel.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/abstractimg/InsertImageAbstractPresenter.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/abstractimg/InsertImageAbstractView.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfo.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java
Log:
Incomplete - task RTE: Create Image 

Complete - task RTE Autosave on/off 


Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java	2009-03-25 17:15:09 UTC (rev 1087)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java	2009-03-26 00:07:59 UTC (rev 1088)
@@ -597,7 +597,8 @@
                                     };
                                 }
                                 InsertImageDialog dialog = insertImageDialog.get();
-                                dialog.setImageInfo(new ImageInfo("", true, ImageInfo.POSITION_LEFT,
+                                dialog.setImageInfo(new ImageInfo("", ImageInfo.DEF_WRAP_VALUE,
+                                        ImageInfo.DEF_CLICK_ORIGINAL_VALUE, ImageInfo.POSITION_LEFT,
                                         ImageInfo.SIZE_ORIGINAL));
                                 dialog.setOnCreateImage(insertImageListener);
                                 dialog.show();

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ImageInfo.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ImageInfo.java	2009-03-25 17:15:09 UTC (rev 1087)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ImageInfo.java	2009-03-26 00:07:59 UTC (rev 1088)
@@ -1,12 +1,16 @@
 package org.ourproject.kune.platf.client.ui.rte.insertimg;
 
 import org.cobogw.gwt.user.client.CSS;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkInfo;
 
 import com.google.gwt.dom.client.Element;
 import com.google.gwt.user.client.DOM;
 
 public class ImageInfo {
 
+    public static final boolean DEF_WRAP_VALUE = true;
+    public static final boolean DEF_CLICK_ORIGINAL_VALUE = false;
+
     public static final String SIZE_ORIGINAL = "original";
     public static final String SIZE_FIT = "fit";
     public static final String SIZE_XS = "xs";
@@ -31,28 +35,32 @@
 
     private String src;
     private boolean wraptext;
+    private boolean clickOriginal;
     private String position;
     private String size;
 
-    public ImageInfo(String src, boolean wraptext, String position, String size) {
+    public ImageInfo(String src, boolean wraptext, boolean clickOriginal, String position, String size) {
         this.src = src;
         this.wraptext = wraptext;
+        this.clickOriginal = clickOriginal;
         this.setPosition(position);
         this.setSize(size);
     }
 
+    public boolean getClickOriginal() {
+        return clickOriginal;
+    }
+
     public Element getElement() {
-        com.google.gwt.user.client.Element img = DOM.createImg();
-        DOM.setElementProperty(img, "src", src);
-        CSS.setProperty(img, CSS.A.WIDTH, getStyleSize());
-        if (!wraptext || position.equals(POSITION_CENTER)) {
-            com.google.gwt.user.client.Element divEl = DOM.createDiv();
-            CSS.setProperty(divEl, CSS.A.TEXT_ALIGN, position);
-            divEl.setInnerHTML(img.getString());
-            return divEl;
+        Element imgElement = getImageElement();
+        if (clickOriginal) {
+            com.google.gwt.user.client.Element anchor = DOM.createAnchor();
+            DOM.setElementProperty(anchor, LinkInfo.HREF, src);
+            DOM.setElementProperty(anchor, LinkInfo.TARGET, LinkInfo._BLANK);
+            anchor.setInnerHTML(imgElement.getString());
+            return anchor;
         } else {
-            CSS.setProperty(img, CSS.A.FLOAT, position);
-            return img;
+            return imgElement;
         }
     }
 
@@ -72,6 +80,10 @@
         return wraptext;
     }
 
+    public void setClickOriginal(boolean clickOriginal) {
+        this.clickOriginal = clickOriginal;
+    }
+
     public void setPosition(String position) {
         this.position = position;
     }
@@ -94,6 +106,21 @@
         return element.getString();
     }
 
+    private Element getImageElement() {
+        com.google.gwt.user.client.Element img = DOM.createImg();
+        DOM.setElementProperty(img, "src", src);
+        CSS.setProperty(img, CSS.A.WIDTH, getStyleSize());
+        if (!wraptext || position.equals(POSITION_CENTER)) {
+            com.google.gwt.user.client.Element divEl = DOM.createDiv();
+            CSS.setProperty(divEl, CSS.A.TEXT_ALIGN, position);
+            divEl.setInnerHTML(img.getString());
+            return divEl;
+        } else {
+            CSS.setProperty(img, CSS.A.FLOAT, position);
+            return img;
+        }
+    }
+
     private String getStyleSize() {
         for (String[] current : sizes) {
             if (current[1].equals(size)) {

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/abstractimg/InsertImageAbstractPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/abstractimg/InsertImageAbstractPanel.java	2009-03-25 17:15:09 UTC (rev 1087)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/abstractimg/InsertImageAbstractPanel.java	2009-03-26 00:07:59 UTC (rev 1088)
@@ -23,6 +23,7 @@
     private final ComboBox sizeCombo;
     private final ComboBox positionCombo;
     protected final Checkbox wrapText;
+    protected final Checkbox clickOriginal;
 
     public InsertImageAbstractPanel(String title, final InsertImageAbstractPresenter presenter) {
         super(title);
@@ -39,8 +40,12 @@
         positionCombo = createCombo(storePositions, Resources.i18n.t("Position"));
 
         wrapText = new Checkbox(Resources.i18n.t("Wrap text around image"));
-        wrapText.setChecked(false);
+        wrapText.setChecked(ImageInfo.DEF_WRAP_VALUE);
 
+        clickOriginal = new Checkbox(Resources.i18n.t("Clicking this image links to the original image file"));
+        clickOriginal.setChecked(ImageInfo.DEF_CLICK_ORIGINAL_VALUE);
+        clickOriginal.setWidth(DEF_FIELD_WIDTH);
+
         positionCombo.addListener(new ComboBoxListenerAdapter() {
             @Override
             public void onSelect(ComboBox comboBox, Record record, int index) {
@@ -62,13 +67,20 @@
         advanced.setCollapsible(true);
         advanced.setCollapsed(true);
         advanced.setAutoHeight(true);
+        advanced.setAutoWidth(true);
+        advanced.setAutoScroll(false);
 
         advanced.add(sizeCombo);
         advanced.add(positionCombo);
         advanced.add(wrapText);
+        advanced.add(clickOriginal);
         add(advanced);
     }
 
+    public boolean getClickOriginal() {
+        return clickOriginal.getValue();
+    }
+
     public String getPosition() {
         return positionCombo.getValueAsString();
     }
@@ -81,20 +93,21 @@
         return null;
     }
 
+    public boolean getWrapText() {
+        return wrapText.getValue();
+    }
+
     @Override
     public void insert(int index, Component component) {
         super.insert(index, component);
     }
 
-    public boolean wrapText() {
-        return wrapText.getValue();
-    }
-
     protected void updateValues(ImageInfo imageInfo) {
         sizeCombo.setValue(imageInfo.getSize());
         String position = imageInfo.getPosition();
         positionCombo.setValue(position);
         wrapText.setChecked(imageInfo.isWraptext());
+        clickOriginal.setChecked(imageInfo.getClickOriginal());
         setWrapVisible(position);
     }
 

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/abstractimg/InsertImageAbstractPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/abstractimg/InsertImageAbstractPresenter.java	2009-03-25 17:15:09 UTC (rev 1087)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/abstractimg/InsertImageAbstractPresenter.java	2009-03-26 00:07:59 UTC (rev 1088)
@@ -66,7 +66,7 @@
     }
 
     protected ImageInfo updateImageInfo() {
-        return new ImageInfo(view.getSrc(), view.wrapText(), view.getPosition(), view.getSize());
+        return new ImageInfo(view.getSrc(), view.getWrapText(), view.getClickOriginal(), view.getPosition(),
+                view.getSize());
     }
-
 }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/abstractimg/InsertImageAbstractView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/abstractimg/InsertImageAbstractView.java	2009-03-25 17:15:09 UTC (rev 1087)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/abstractimg/InsertImageAbstractView.java	2009-03-26 00:07:59 UTC (rev 1088)
@@ -4,6 +4,8 @@
 
 public interface InsertImageAbstractView extends View {
 
+    boolean getClickOriginal();
+
     String getPosition();
 
     String getSize();
@@ -14,5 +16,5 @@
 
     void reset();
 
-    boolean wrapText();
+    boolean getWrapText();
 }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfo.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfo.java	2009-03-25 17:15:09 UTC (rev 1087)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfo.java	2009-03-26 00:07:59 UTC (rev 1088)
@@ -4,10 +4,10 @@
 import com.google.gwt.user.client.DOM;
 
 public class LinkInfo {
-    private static final String HREF = "href";
-    // private static final String TITLE = "title";
-    private static final String TARGET = "target";
-    private static final String _BLANK = "_blank";
+    public static final String HREF = "href";
+    public static final String TITLE = "title";
+    public static final String TARGET = "target";
+    public static final String _BLANK = "_blank";
 
     public static LinkInfo parse(Element element) {
         String target = element.getAttribute(TARGET);
@@ -47,12 +47,12 @@
     public Element getElement() {
         Element anchor = DOM.createAnchor();
         com.google.gwt.user.client.Element element = (com.google.gwt.user.client.Element) anchor;
-        DOM.setElementProperty(element, "href", href);
+        DOM.setElementProperty(element, HREF, href);
         if (getTarget() != null) {
             DOM.setElementProperty(element, TARGET, getTarget());
         }
         if (title != null) {
-            DOM.setElementAttribute(element, "title", title);
+            DOM.setElementAttribute(element, TITLE, title);
         }
         DOM.setInnerText(element, text);
         return anchor;

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java	2009-03-25 17:15:09 UTC (rev 1087)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java	2009-03-26 00:07:59 UTC (rev 1088)
@@ -1,7 +1,9 @@
 package org.ourproject.kune.platf.client.ui.rte.saving;
 
+import org.ourproject.kune.platf.client.actions.ActionCheckedCondition;
 import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor;
 import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator;
+import org.ourproject.kune.platf.client.actions.ActionToolbarMenuCheckItemDescriptor;
 import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
 import org.ourproject.kune.platf.client.actions.BeforeActionListener;
 import org.ourproject.kune.platf.client.dto.AccessRolDTO;
@@ -23,7 +25,7 @@
     public static final int AUTOSAVE_IN_MILLISECONDS = 10000;
 
     private final RTEditor editor;
-    private final boolean autoSave;
+    private boolean autoSave;
     private boolean savePending;
     private boolean saveAndCloseConfirmed;
     private Listener<String> onSave;
@@ -193,6 +195,23 @@
         save.setTextDescription(i18n.t("Save") + (ctrl_S.toString()));
         save.setPosition(0);
 
+        ActionToolbarMenuCheckItemDescriptor<Object> autoSaveMenuItem = new ActionToolbarMenuCheckItemDescriptor<Object>(AccessRolDTO.Editor,
+                RTEditor.topbarPosition, new Listener0() {
+                    public void onEvent() {
+                        autoSave = !autoSave;
+                        if (autoSave) {
+                            timer.schedule(AUTOSAVE_IN_MILLISECONDS);
+                        } else {
+                            timer.cancel();
+                        }
+                    }}
+                , new ActionCheckedCondition() {
+                    public boolean mustBeChecked() {
+                        return autoSave;
+                    }});
+        autoSaveMenuItem.setParentMenuTitle(i18n.t(FILE_DEF_MENU_OPTION));
+        autoSaveMenuItem.setTextDescription(i18n.t("Autosave"));
+
         ActionToolbarMenuDescriptor<Object> close = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor,
                 RTEditor.topbarPosition, new Listener<Object>() {
                     public void onEvent(Object parameter) {
@@ -225,8 +244,10 @@
         saveCloseBtn.setLeftSeparator(ActionToolbarButtonSeparator.fill);
 
         editor.addAction(save);
+        editor.addAction(autoSaveMenuItem);
         editor.addAction(saveclose);
         editor.addAction(close);
+
         editor.addAction(saveBtn);
         editor.addAction(saveCloseBtn);
     }




More information about the kune-commits mailing list