[kune-commits] r1033 - in trunk/src:
main/java/org/ourproject/kune/app/public/css
main/java/org/ourproject/kune/app/public/css/img
main/java/org/ourproject/kune/platf/client/app
main/java/org/ourproject/kune/platf/client/services
main/java/org/ourproject/kune/platf/client/ui/dialogs
main/java/org/ourproject/kune/workspace/client/editor/insert
main/java/org/ourproject/kune/workspace/client/editor/insert/abstractlink
main/java/org/ourproject/kune/workspace/client/editor/insert/linkemail
main/java/org/ourproject/kune/workspace/client/editor/insert/linkext
main/java/org/ourproject/kune/workspace/client/editor/insert/linklocal
main/java/org/ourproject/kune/workspace/client/options
test/java/org/ourproject/kune/platf/client/ui
vjrj
vjrj at ourproject.org
Mon Jan 19 10:18:01 CET 2009
Author: vjrj
Date: 2009-01-19 10:17:59 +0100 (Mon, 19 Jan 2009)
New Revision: 1033
Added:
trunk/src/main/java/org/ourproject/kune/app/public/css/img/link.gif
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/abstractlink/TextEditorInsertAbstract.java
Modified:
trunk/src/main/java/org/ourproject/kune/app/public/css/all.css
trunk/src/main/java/org/ourproject/kune/app/public/css/kune-new.css
trunk/src/main/java/org/ourproject/kune/platf/client/app/TextEditorInsertElementGroup.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/DefaultForm.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/TextEditorInsertElementPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/TextEditorInsertElementView.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/abstractlink/TextEditorInsertAbstractPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkemail/TextEditorInsertLinkEmail.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkemail/TextEditorInsertLinkEmailPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkext/TextEditorInsertLinkExt.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkext/TextEditorInsertLinkExtPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkext/TextEditorInsertLinkExtPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkext/TextEditorInsertLinkExtView.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linklocal/TextEditorInsertLinkLocal.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linklocal/TextEditorInsertLinkLocalPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsPanel.java
trunk/src/test/java/org/ourproject/kune/platf/client/ui/TextUtilsTest.java
Log:
Complete - task Insert link improvements (preview, better url checks, form reset)
Modified: trunk/src/main/java/org/ourproject/kune/app/public/css/all.css
===================================================================
--- trunk/src/main/java/org/ourproject/kune/app/public/css/all.css 2009-01-16 13:29:28 UTC (rev 1032)
+++ trunk/src/main/java/org/ourproject/kune/app/public/css/all.css 2009-01-19 09:17:59 UTC (rev 1033)
@@ -41,4 +41,4 @@
padding: 1px 0px 1px 1px;
text-decoration:none;
}
-*/.k-textlinethrough{text-decoration:line-through;color:red;}.k-textnormal{text-decoration:inherit;color:green;}.k-textunderline{text-decoration:underline;}.k-info-links{text-decoration:underline;color:gray;cursor:pointer;}.x-tool-kmenu{background-position:0 -75px;}.x-tool-kmenu-over{background-position:-15px -75px;}.k-border-openbox{border-bottom:1px #D0D0D0 solid;border-right:1px #D0D0D0 solid;border-left:1px #D0D0D0 solid;}/* SiteToastMessages */.k-stm-info-icon{background-image:url(img/info.gif)!important;}.k-stm-imp-icon{background-image:url(img/alert.gif)!important;}.k-stm-verimp-icon{background-image:url(img/important.gif)!important;}.k-stm-error-icon{background-image:url(img/error.gif)!important;}.k-error-tb{background:#FFB380 none repeat scroll 0 50%;color:#250;}.k-infod-head{font-size:108%;margin-bottom:10px;}.gwt-DisclosurePanel{}.gwt-DisclosurePanel-open{}.gwt-DisclosurePanel-closed{}.gwt-DisclosurePanel .header,.gwt-DisclosurePanel .header a,.gwt-DisclosurePanel .header td{text-decoration:none;/* Remove underline from header */color:#000;cursor:pointer;cursor:hand;}.gwt-DisclosurePanel .content{border-left:3px solid #e8eef7;padding:4px 0 4px 8px;margin-left:6px;}.k-basic-thumb{background:#FAFAFA none repeat scroll 0 50%;border:1px solid #EBEBEB;padding:3px;margin:3px;}.k-basic-thumb td{padding:2px 3px;border:none;}.k-text-gray{color:gray;}.k-elp-limg{margin-top:4px;margin-left:5px;cursor:pointer;overflow:hidden;}.k-tsp-tag{float:right;margin-right:5px;cursor:pointer;color:#00F;}.k-tsp-cloud{vertical-align:bottom;}.k-options-icon{background-image:url(img/emblem-system.gif)!important;}.k-copyleft-icon{background-image:url(img/copyleft.png)!important;}.k-picture-icon{background-image:url(img/picture.png)!important;}.k-info-icon{background-image:url(img/info.gif)!important;}.k-newgroup-icon{background-image:url(img/kune-icon16.png)!important;}.k-colors-icon{background-image:url(img/colors.gif)!important;}.x-toolbar-body table{/* width: 100%; */}.k-preview-msg{background:#FCA;}.k-preview-msg-lab{background:#FCA;padding:0 5px;}.k-eil-edit{border:thin solid #000;}
\ No newline at end of file
+*/.k-textlinethrough{text-decoration:line-through;color:red;}.k-textnormal{text-decoration:inherit;color:green;}.k-textunderline{text-decoration:underline;}.k-info-links{text-decoration:underline;color:gray;cursor:pointer;}.x-tool-kmenu{background-position:0 -75px;}.x-tool-kmenu-over{background-position:-15px -75px;}.k-border-openbox{border-bottom:1px #D0D0D0 solid;border-right:1px #D0D0D0 solid;border-left:1px #D0D0D0 solid;}/* SiteToastMessages */.k-stm-info-icon{background-image:url(img/info.gif)!important;}.k-stm-imp-icon{background-image:url(img/alert.gif)!important;}.k-stm-verimp-icon{background-image:url(img/important.gif)!important;}.k-stm-error-icon{background-image:url(img/error.gif)!important;}.k-error-tb{background:#FFB380 none repeat scroll 0 50%;color:#250;}.k-infod-head{font-size:108%;margin-bottom:10px;}.gwt-DisclosurePanel{}.gwt-DisclosurePanel-open{}.gwt-DisclosurePanel-closed{}.gwt-DisclosurePanel .header,.gwt-DisclosurePanel .header a,.gwt-DisclosurePanel .header td{text-decoration:none;/* Remove underline from header */color:#000;cursor:pointer;cursor:hand;}.gwt-DisclosurePanel .content{border-left:3px solid #e8eef7;padding:4px 0 4px 8px;margin-left:6px;}.k-basic-thumb{background:#FAFAFA none repeat scroll 0 50%;border:1px solid #EBEBEB;padding:3px;margin:3px;}.k-basic-thumb td{padding:2px 3px;border:none;}.k-text-gray{color:gray;}.k-elp-limg{margin-top:4px;margin-left:5px;cursor:pointer;overflow:hidden;}.k-tsp-tag{float:right;margin-right:5px;cursor:pointer;color:#00F;}.k-tsp-cloud{vertical-align:bottom;}.k-link-icon{background-image:url(img/link.gif)!important;}.k-options-icon{background-image:url(img/emblem-system.gif)!important;}.k-copyleft-icon{background-image:url(img/copyleft.png)!important;}.k-picture-icon{background-image:url(img/picture.png)!important;}.k-info-icon{background-image:url(img/info.gif)!important;}.k-newgroup-icon{background-image:url(img/kune-icon16.png)!important;}.k-colors-icon{background-image:url(img/colors.gif)!important;}.x-toolbar-body table{/* width: 100%; */}.k-preview-msg{background:#FCA;}.k-preview-msg-lab{background:#FCA;padding:0 5px;}.k-eil-edit{border:thin solid #000;}
\ No newline at end of file
Added: trunk/src/main/java/org/ourproject/kune/app/public/css/img/link.gif
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/java/org/ourproject/kune/app/public/css/img/link.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/main/java/org/ourproject/kune/app/public/css/kune-new.css
===================================================================
--- trunk/src/main/java/org/ourproject/kune/app/public/css/kune-new.css 2009-01-16 13:29:28 UTC (rev 1032)
+++ trunk/src/main/java/org/ourproject/kune/app/public/css/kune-new.css 2009-01-19 09:17:59 UTC (rev 1033)
@@ -817,6 +817,10 @@
vertical-align: bottom;
}
+.k-link-icon {
+ background-image: url(img/link.gif) !important;
+}
+
.k-options-icon {
background-image: url(img/emblem-system.gif) !important;
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/app/TextEditorInsertElementGroup.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/app/TextEditorInsertElementGroup.java 2009-01-16 13:29:28 UTC (rev 1032)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/app/TextEditorInsertElementGroup.java 2009-01-19 09:17:59 UTC (rev 1033)
@@ -18,6 +18,8 @@
*
*/package org.ourproject.kune.platf.client.app;
+import org.ourproject.kune.workspace.client.editor.insert.abstractlink.TextEditorInsertAbstract;
+
import com.calclab.suco.client.ioc.Container;
import com.calclab.suco.client.ioc.Provider;
import com.calclab.suco.client.ioc.decorator.ProviderCollection;
@@ -37,7 +39,7 @@
public void resetAll() {
for (final Provider<?> p : getProviders()) {
- // (TextEditorInsertAbstractView) p.get().get).clear();
+ ((TextEditorInsertAbstract) p.get()).reset();
}
}
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java 2009-01-16 13:29:28 UTC (rev 1032)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java 2009-01-19 09:17:59 UTC (rev 1033)
@@ -85,6 +85,7 @@
import org.ourproject.kune.workspace.client.editor.insert.linkext.TextEditorInsertLinkExt;
import org.ourproject.kune.workspace.client.editor.insert.linkext.TextEditorInsertLinkExtPanel;
import org.ourproject.kune.workspace.client.editor.insert.linkext.TextEditorInsertLinkExtPresenter;
+import org.ourproject.kune.workspace.client.editor.insert.linkext.TextEditorInsertLinkExtView;
import org.ourproject.kune.workspace.client.editor.insert.linklocal.TextEditorInsertLinkLocal;
import org.ourproject.kune.workspace.client.editor.insert.linklocal.TextEditorInsertLinkLocalPanel;
import org.ourproject.kune.workspace.client.editor.insert.linklocal.TextEditorInsertLinkLocalPresenter;
@@ -403,7 +404,7 @@
public TextEditorInsertLinkExt create() {
final TextEditorInsertLinkExtPresenter presenter = new TextEditorInsertLinkExtPresenter(
$(TextEditorInsertElement.class));
- final TextEditorInsertLinkExtPanel panel = new TextEditorInsertLinkExtPanel(presenter,
+ final TextEditorInsertLinkExtView panel = new TextEditorInsertLinkExtPanel(presenter,
$(I18nTranslationService.class));
presenter.init(panel);
return presenter;
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/DefaultForm.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/DefaultForm.java 2009-01-16 13:29:28 UTC (rev 1032)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/DefaultForm.java 2009-01-19 09:17:59 UTC (rev 1033)
@@ -18,7 +18,6 @@
*
*/package org.ourproject.kune.platf.client.ui.dialogs;
-import com.allen_sauer.gwt.log.client.Log;
import com.gwtext.client.core.Position;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.PaddedPanel;
@@ -93,7 +92,6 @@
}
public void reset() {
- Log.info("Reset------------------");
form.getForm().reset();
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/TextEditorInsertElementPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/TextEditorInsertElementPanel.java 2009-01-16 13:29:28 UTC (rev 1032)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/TextEditorInsertElementPanel.java 2009-01-19 09:17:59 UTC (rev 1033)
@@ -15,10 +15,10 @@
public TextEditorInsertElementPanel(final TextEditorInsertElementPresenter presenter, final WorkspaceSkeleton ws,
Images images, I18nTranslationService i18n, final TextEditorInsertElementGroup textEditorInsertElementGroup) {
- super(TEXT_EDT_INSERT_DIALOG, i18n.tWithNT("Insert an element",
+ super(TEXT_EDT_INSERT_DIALOG, i18n.tWithNT("Insert a link",
"Option in a text editor to insert links and other elements"), 380, HEIGHT + 90, 380, HEIGHT + 90,
true, images, TEXT_EDT_INSERT_DIALOG_ERROR_ID);
- // super.setIconCls("k-options-icon");
+ super.setIconCls("k-link-icon");
this.textEditorInsertElementGroup = textEditorInsertElementGroup;
super.addHideListener(new Listener0() {
public void onEvent() {
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/TextEditorInsertElementView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/TextEditorInsertElementView.java 2009-01-16 13:29:28 UTC (rev 1032)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/TextEditorInsertElementView.java 2009-01-19 09:17:59 UTC (rev 1033)
@@ -4,5 +4,5 @@
import org.ourproject.kune.workspace.client.options.AbstractOptionsView;
public interface TextEditorInsertElementView extends AbstractOptionsView, View {
- int HEIGHT = 200;
+ int HEIGHT = 225;
}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/abstractlink/TextEditorInsertAbstract.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/abstractlink/TextEditorInsertAbstract.java 2009-01-16 13:29:28 UTC (rev 1032)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/abstractlink/TextEditorInsertAbstract.java 2009-01-19 09:17:59 UTC (rev 1033)
@@ -0,0 +1,7 @@
+package org.ourproject.kune.workspace.client.editor.insert.abstractlink;
+
+public interface TextEditorInsertAbstract {
+
+ void reset();
+
+}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/abstractlink/TextEditorInsertAbstractPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/abstractlink/TextEditorInsertAbstractPresenter.java 2009-01-16 13:29:28 UTC (rev 1032)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/abstractlink/TextEditorInsertAbstractPresenter.java 2009-01-19 09:17:59 UTC (rev 1033)
@@ -3,7 +3,7 @@
import org.ourproject.kune.platf.client.View;
import org.ourproject.kune.workspace.client.editor.insert.TextEditorInsertElement;
-public class TextEditorInsertAbstractPresenter {
+public class TextEditorInsertAbstractPresenter implements TextEditorInsertAbstract {
private TextEditorInsertAbstractView view;
private final TextEditorInsertElement editorInsertElement;
@@ -23,6 +23,10 @@
public void onInsert(String name, String link) {
editorInsertElement.fireOnInsert(name, link);
+ reset();
+ }
+
+ public void reset() {
view.reset();
}
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkemail/TextEditorInsertLinkEmail.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkemail/TextEditorInsertLinkEmail.java 2009-01-16 13:29:28 UTC (rev 1032)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkemail/TextEditorInsertLinkEmail.java 2009-01-19 09:17:59 UTC (rev 1033)
@@ -1,5 +1,7 @@
package org.ourproject.kune.workspace.client.editor.insert.linkemail;
-public interface TextEditorInsertLinkEmail {
+import org.ourproject.kune.workspace.client.editor.insert.abstractlink.TextEditorInsertAbstract;
+public interface TextEditorInsertLinkEmail extends TextEditorInsertAbstract {
+
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkemail/TextEditorInsertLinkEmailPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkemail/TextEditorInsertLinkEmailPresenter.java 2009-01-16 13:29:28 UTC (rev 1032)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkemail/TextEditorInsertLinkEmailPresenter.java 2009-01-19 09:17:59 UTC (rev 1033)
@@ -10,7 +10,4 @@
super(editorInsertElement);
}
- public void init(TextEditorInsertLinkEmailView view) {
- super.init(view);
- }
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkext/TextEditorInsertLinkExt.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkext/TextEditorInsertLinkExt.java 2009-01-16 13:29:28 UTC (rev 1032)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkext/TextEditorInsertLinkExt.java 2009-01-19 09:17:59 UTC (rev 1033)
@@ -1,5 +1,7 @@
package org.ourproject.kune.workspace.client.editor.insert.linkext;
-public interface TextEditorInsertLinkExt {
+import org.ourproject.kune.workspace.client.editor.insert.abstractlink.TextEditorInsertAbstract;
+public interface TextEditorInsertLinkExt extends TextEditorInsertAbstract {
+
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkext/TextEditorInsertLinkExtPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkext/TextEditorInsertLinkExtPanel.java 2009-01-16 13:29:28 UTC (rev 1032)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkext/TextEditorInsertLinkExtPanel.java 2009-01-19 09:17:59 UTC (rev 1033)
@@ -1,19 +1,24 @@
package org.ourproject.kune.workspace.client.editor.insert.linkext;
import org.ourproject.kune.platf.client.services.I18nTranslationService;
+import org.ourproject.kune.platf.client.ui.TextUtils;
import org.ourproject.kune.platf.client.ui.dialogs.DefaultForm;
import org.ourproject.kune.workspace.client.editor.insert.TextEditorInsertElementView;
+import com.google.gwt.user.client.ui.Frame;
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.form.VType;
+import com.gwtext.client.widgets.layout.FitLayout;
public class TextEditorInsertLinkExtPanel extends DefaultForm implements TextEditorInsertLinkExtView {
public static final String LINK_FIELD = "k-teilep-link-f";
- private final TextField linkField;
+ final TextField linkField;
+ final Panel previewPanel;
public TextEditorInsertLinkExtPanel(final TextEditorInsertLinkExtPresenter presenter,
final I18nTranslationService i18n) {
@@ -23,7 +28,8 @@
linkField = new TextField();
linkField.setTabIndex(1);
linkField.setFieldLabel(i18n.t("External link (URL)"));
- linkField.setVtype(VType.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);
@@ -32,19 +38,47 @@
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) {
- if (getFormPanel().getForm().isValid()) {
- presenter.onInsert("", linkField.getRawValue());
- }
+ presenter.onInsert();
}
});
addButton(insert);
}
- public void clear() {
+ public String getUrl() {
+ return linkField.getRawValue();
+ }
+
+ @Override
+ public void reset() {
super.reset();
+ previewPanel.clear();
}
+
+ public void setPreviewUrl(String url) {
+ Frame previewFrame = new Frame(url);
+ previewPanel.clear();
+ previewPanel.add(previewFrame);
+ previewPanel.doLayout();
+ }
+
+ public void setUrl(String url) {
+ linkField.setValue(url);
+ }
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkext/TextEditorInsertLinkExtPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkext/TextEditorInsertLinkExtPresenter.java 2009-01-16 13:29:28 UTC (rev 1032)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkext/TextEditorInsertLinkExtPresenter.java 2009-01-19 09:17:59 UTC (rev 1033)
@@ -1,16 +1,60 @@
package org.ourproject.kune.workspace.client.editor.insert.linkext;
+import org.ourproject.kune.platf.client.ui.TextUtils;
import org.ourproject.kune.workspace.client.editor.insert.TextEditorInsertElement;
import org.ourproject.kune.workspace.client.editor.insert.abstractlink.TextEditorInsertAbstractPresenter;
public class TextEditorInsertLinkExtPresenter extends TextEditorInsertAbstractPresenter implements
TextEditorInsertLinkExt {
+ interface Action {
+ void onValid(String url);
+ }
+
+ private TextEditorInsertLinkExtView view;
+
public TextEditorInsertLinkExtPresenter(TextEditorInsertElement editorInsertElement) {
super(editorInsertElement);
}
public void init(TextEditorInsertLinkExtView view) {
super.init(view);
+ this.view = view;
}
+
+ public void onInsert() {
+ doActionIfValid(new Action() {
+ public void onValid(String url) {
+ onInsert("", url);
+ }
+ });
+ }
+
+ public void onPreview() {
+ doActionIfValid(new Action() {
+ public void onValid(String url) {
+ view.setPreviewUrl(url);
+ }
+ });
+ }
+
+ private void doActionIfValid(Action action) {
+ String url = view.getUrl();
+ if (url.matches(TextUtils.URL_REGEXP)) {
+ action.onValid(url);
+ } else {
+ if (!url.startsWith("http://")) {
+ url = "http://" + url;
+ if (url.matches(TextUtils.URL_REGEXP)) {
+ view.setUrl(url);
+ action.onValid(url);
+ } else {
+ view.isValid();
+ }
+ } else {
+ // Seems is not valid
+ view.isValid();
+ }
+ }
+ }
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkext/TextEditorInsertLinkExtView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkext/TextEditorInsertLinkExtView.java 2009-01-16 13:29:28 UTC (rev 1032)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkext/TextEditorInsertLinkExtView.java 2009-01-19 09:17:59 UTC (rev 1033)
@@ -3,4 +3,12 @@
import org.ourproject.kune.workspace.client.editor.insert.abstractlink.TextEditorInsertAbstractView;
public interface TextEditorInsertLinkExtView extends TextEditorInsertAbstractView {
+
+ public String getUrl();
+
+ public boolean isValid();
+
+ public void setPreviewUrl(String url);
+
+ public void setUrl(String url);
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linklocal/TextEditorInsertLinkLocal.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linklocal/TextEditorInsertLinkLocal.java 2009-01-16 13:29:28 UTC (rev 1032)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linklocal/TextEditorInsertLinkLocal.java 2009-01-19 09:17:59 UTC (rev 1033)
@@ -1,5 +1,7 @@
package org.ourproject.kune.workspace.client.editor.insert.linklocal;
-public interface TextEditorInsertLinkLocal {
+import org.ourproject.kune.workspace.client.editor.insert.abstractlink.TextEditorInsertAbstract;
+public interface TextEditorInsertLinkLocal extends TextEditorInsertAbstract {
+
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linklocal/TextEditorInsertLinkLocalPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linklocal/TextEditorInsertLinkLocalPresenter.java 2009-01-16 13:29:28 UTC (rev 1032)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linklocal/TextEditorInsertLinkLocalPresenter.java 2009-01-19 09:17:59 UTC (rev 1033)
@@ -10,7 +10,4 @@
super(editorInsertElement);
}
- public void init(TextEditorInsertLinkLocalView view) {
- super.init(view);
- }
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsPanel.java 2009-01-16 13:29:28 UTC (rev 1032)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsPanel.java 2009-01-19 09:17:59 UTC (rev 1033)
@@ -137,6 +137,7 @@
private void createDialog() {
dialog = new BasicDialog(dialogId, title, modal, true, width, height, minWidth, minHeight);
+ dialog.setCollapsible(false);
messageErrorBar = new MessageToolbar(images, errorLabelId);
dialog.setBottomToolbar(messageErrorBar.getToolbar());
tabPanel = new TabPanel();
Modified: trunk/src/test/java/org/ourproject/kune/platf/client/ui/TextUtilsTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/client/ui/TextUtilsTest.java 2009-01-16 13:29:28 UTC (rev 1032)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/ui/TextUtilsTest.java 2009-01-19 09:17:59 UTC (rev 1033)
@@ -23,4 +23,21 @@
assertTrue(email.matches(TextUtils.EMAIL_REGEXP));
}
+ @Test
+ public void matchUrlWithHttp() {
+ String gnuUrl = "http://gnu.org";
+ assertTrue(gnuUrl.matches(TextUtils.URL_REGEXP));
+ }
+
+ @Test
+ public void matchUrlWithoutHttp() {
+ String gnuUrl = "gnu.org";
+ assertTrue(!gnuUrl.matches(TextUtils.URL_REGEXP));
+ }
+
+ @Test
+ public void notMatchWrongUrl() {
+ String someWrong = "some at email.com";
+ assertTrue(!someWrong.matches(TextUtils.URL_REGEXP));
+ }
}
More information about the kune-commits
mailing list