diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionPanel.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionPanel.java index a5a3711..8cb06be 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionPanel.java @@ -327,8 +327,6 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel { parent.applyReplaceColumnByExpression(cConditionExpression, value); } else { - UtilsGXT3.alert("Error replace value", - "Insert a valid replace value!"); return; } } @@ -350,20 +348,44 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel { ok = true; break; case Geometry: - RegExp regExp = RegExp.compile(GEOMETRY_REGEXPR); - MatchResult matcher = regExp.exec(value); - boolean matchFound = matcher != null; - if (matchFound) { - ok = true; - } else { - ok = false; + try { + RegExp regExp = RegExp.compile(GEOMETRY_REGEXPR); + MatchResult matcher = regExp.exec(value); + boolean matchFound = matcher != null; + if (matchFound) { + ok = true; + } else { + ok = false; + } + + } catch (Throwable e) { + UtilsGXT3.alert("Error replace value", + "Insert a valid replace value for Geometry type! "); + e.printStackTrace(); + return false; } break; case Integer: - Integer.parseInt(value); + try { + Integer.parseInt(value); + } catch(Throwable e){ + e.printStackTrace(); + UtilsGXT3.alert("Error replace value", + "Insert a valid replace value for Integer type! "); + return false; + } + ok=true; break; case Numeric: - Double.parseDouble(value); + try { + Double.parseDouble(value); + } catch(Throwable e){ + e.printStackTrace(); + UtilsGXT3.alert("Error replace value", + "Insert a valid replace value for Numeric type! "); + return false; + } + ok=true; break; case Text: ok = true; @@ -374,6 +396,10 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel { return ok; } catch (Throwable e) { + e.printStackTrace(); + UtilsGXT3.alert("Error replace value", + "Insert a valid replace value! "+e.getLocalizedMessage()); + return false; } } diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/custom/DefaultAppearance.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/custom/DefaultAppearance.java index c5f937a..34778c2 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/custom/DefaultAppearance.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/custom/DefaultAppearance.java @@ -70,5 +70,7 @@ public class DefaultAppearance implements IconButtonAppearance { public void render(SafeHtmlBuilder sb) { sb.append(template.template(style)); + + } } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/Data.png b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/Data.png new file mode 100644 index 0000000..8a2dac8 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/Data.png differ diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceByExp.html b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceByExp.html new file mode 100644 index 0000000..d1091b1 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceByExp.html @@ -0,0 +1,43 @@ + +
+
+

Replace Column By Expression

+
+
+

Basic Example 1

+

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+
+
+

Regular Expression

+

+ POSIX Regular Expressions Reference +

+
+
\ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceByExpStyle.css b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceByExpStyle.css new file mode 100644 index 0000000..80f3dea --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceByExpStyle.css @@ -0,0 +1,10 @@ +@CHARSET "UTF-8"; + +.HelpReplaceRegexImg { + float: left; +} +.HelpReplaceRegexClear { + clear: both; +} + + diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceColumnByExpression.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceColumnByExpression.java new file mode 100644 index 0000000..37c19a8 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceColumnByExpression.java @@ -0,0 +1,73 @@ +package org.gcube.portlets.user.td.expressionwidget.client.help; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Element; +import com.google.gwt.resources.client.ClientBundle; +import com.google.gwt.resources.client.CssResource; +import com.google.gwt.resources.client.ImageResource; +import com.google.gwt.safehtml.shared.SafeHtml; +import com.google.gwt.safehtml.shared.SafeHtmlBuilder; +import com.google.gwt.user.client.ui.Image; +import com.sencha.gxt.core.client.XTemplates; +import com.sencha.gxt.core.client.dom.XDOM; +import com.sencha.gxt.core.client.dom.XElement; + +public class HelpReplaceColumnByExpression { + public interface HelpReplaceByExpTemplate extends XTemplates { + @XTemplate(source = "HelpReplaceByExp.html") + SafeHtml render(HelpReplaceByExpStyle style); + } + + public interface HelpReplaceByExpStyle extends CssResource { + @ClassName("HelpReplaceRegexImg") + public String getHelpReplaceRegexImg(); + + @ClassName("HelpReplaceRegexClear") + public String getHelpReplaceRegexClear(); + + + @ClassName("DataStyle") + public String getDataStyle(); + } + + private final HelpReplaceByExpStyle style; + private final HelpReplaceByExpTemplate template; + + public interface HelpReplaceByExpResources extends ClientBundle { + public static final HelpReplaceByExpResources INSTANCE = GWT + .create(HelpReplaceByExpResources.class); + + @Source("HelpReplaceByExpStyle.css") + HelpReplaceByExpStyle style(); + + @Source("Data.png") + ImageResource data(); + + + @Source("SimpleConcat.png") + ImageResource simpleConcat(); + + } + + public HelpReplaceColumnByExpression() { + this.style = HelpReplaceByExpResources.INSTANCE.style(); + this.style.ensureInjected(); + + this.template = GWT.create(HelpReplaceByExpTemplate.class); + } + + public void render(SafeHtmlBuilder sb) { + sb.append(template.render(style)); + XElement parent=XDOM.create(sb.toSafeHtml()); + XElement element = parent.selectNode("." + style.getDataStyle()); + Image image = new Image(HelpReplaceByExpResources.INSTANCE.data()); + Element img = image.getElement(); + element.appendChild(img); + + } + + protected void renderImg() { + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceColumnByExpressionDialog.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceColumnByExpressionDialog.java index dd8b4f3..7a05c4d 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceColumnByExpressionDialog.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceColumnByExpressionDialog.java @@ -14,8 +14,8 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; * */ public class HelpReplaceColumnByExpressionDialog extends Window { - protected static final String WIDTH = "800px"; - protected static final String HEIGHT = "600px"; + protected static final String WIDTH = "742px"; + protected static final String HEIGHT = "520px"; protected EventBus eventBus; protected HelpReplaceColumnByExpressionPanel helpReplaceColumnByExpressionPanel; diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceColumnByExpressionPanel.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceColumnByExpressionPanel.java index 0f4855b..2386284 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceColumnByExpressionPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceColumnByExpressionPanel.java @@ -3,6 +3,8 @@ package org.gcube.portlets.user.td.expressionwidget.client.help; import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources; import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.safehtml.shared.SafeHtmlBuilder; +import com.google.gwt.user.client.ui.HTML; import com.google.web.bindery.event.shared.EventBus; import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign; import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode; @@ -12,6 +14,7 @@ import com.sencha.gxt.widget.core.client.button.TextButton; import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData; import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack; import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer; +import com.sencha.gxt.widget.core.client.container.SimpleContainer; import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.HBoxLayoutAlign; import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData; @@ -26,14 +29,16 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; */ public class HelpReplaceColumnByExpressionPanel extends FramedPanel { - protected static final String WIDTH = "698px"; - protected static final String HEIGHT = "454px"; - + protected static final String WIDTH = "700px"; + protected static final String HEIGHT = "404px"; + protected static final String HELP_CONTENT_WIDTH = "700px"; + protected static final String HELP_CONTENT_HEIGHT = "404px"; protected EventBus eventBus; protected HelpReplaceColumnByExpressionDialog parent; private TextButton btnClose; + public HelpReplaceColumnByExpressionPanel( HelpReplaceColumnByExpressionDialog parent, EventBus eventBus) { @@ -58,13 +63,26 @@ public class HelpReplaceColumnByExpressionPanel extends FramedPanel { VerticalLayoutContainer basicLayout = new VerticalLayoutContainer(); basicLayout.setAdjustForScroll(true); basicLayout.setScrollMode(ScrollMode.AUTO); - + // + SimpleContainer helpContent=new SimpleContainer(); + helpContent.setWidth(HELP_CONTENT_WIDTH); + helpContent.setHeight(HELP_CONTENT_HEIGHT); + VerticalLayoutContainer helpContentLayout=new VerticalLayoutContainer(); + helpContent.add(helpContentLayout); + SafeHtmlBuilder safeHelp=new SafeHtmlBuilder(); + HelpReplaceColumnByExpression helpR=new HelpReplaceColumnByExpression(); + helpR.render(safeHelp); + HTML htmlHelp=new HTML(); + htmlHelp.setHTML(safeHelp.toSafeHtml()); + helpContentLayout.add(htmlHelp); + + // HBoxLayoutContainer flowButton = new HBoxLayoutContainer(); flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE); flowButton.setPack(BoxLayoutPack.CENTER); - // + btnClose = new TextButton("Close"); btnClose.setIcon(ExpressionResources.INSTANCE.close()); @@ -80,8 +98,8 @@ public class HelpReplaceColumnByExpressionPanel extends FramedPanel { flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4))); // Add to basic layout - //basicLayout.add(properties, new VerticalLayoutData(-1, -1, new Margins( - // 1))); + basicLayout.add(helpContent, new VerticalLayoutData(-1, -1, new Margins( + 1))); basicLayout.add(flowButton, new VerticalLayoutData(-1, 36, new Margins( 5, 2, 5, 2))); diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpTemplate.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpTemplate.java deleted file mode 100644 index cdd3e58..0000000 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/HelpTemplate.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.gcube.portlets.user.td.expressionwidget.client.help; - - -public class HelpTemplate { - - -} diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/SimpleConcat.png b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/SimpleConcat.png new file mode 100644 index 0000000..788ef53 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/help/SimpleConcat.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/help/Data.png b/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/help/Data.png new file mode 100644 index 0000000..8a2dac8 Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/help/Data.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceByExp.html b/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceByExp.html new file mode 100644 index 0000000..b0158c6 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceByExp.html @@ -0,0 +1,42 @@ + +
+
+

Replace Column By Expression

+
+
+

Basic Example 1

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+
+
+

Regular Expression

+

+ POSIX Regular Expressions Reference +

+
+
\ No newline at end of file diff --git a/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceByExpStyle.css b/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceByExpStyle.css new file mode 100644 index 0000000..80f3dea --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/help/HelpReplaceByExpStyle.css @@ -0,0 +1,10 @@ +@CHARSET "UTF-8"; + +.HelpReplaceRegexImg { + float: left; +} +.HelpReplaceRegexClear { + clear: both; +} + + diff --git a/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/help/SimpleConcat.png b/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/help/SimpleConcat.png new file mode 100644 index 0000000..788ef53 Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/help/SimpleConcat.png differ