From 8e15a94c3a0a2d0e51f108659c5721330628e281 Mon Sep 17 00:00:00 2001 From: gpawel <gpawel> Date: Wed, 8 Jun 2011 07:50:08 +0000 Subject: [PATCH] [LMS-2281] Multiline html editing SVN: 21635 --- .../ui/grid/ColumnDefsAndConfigs.java | 2 +- .../application/ui/grid/ColumnUtils.java | 30 ++++++++++++++---- .../ui/script/ScriptExecutionFramework.java | 4 +-- .../application/ui/widget/MultilineHTML.java | 8 ++--- .../cisd/openbis/public/images/plus-icon.png | Bin 0 -> 491 bytes 5 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/public/images/plus-icon.png diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/ColumnDefsAndConfigs.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/ColumnDefsAndConfigs.java index c58b554f198..0d79fe70d62 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/ColumnDefsAndConfigs.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/ColumnDefsAndConfigs.java @@ -120,7 +120,7 @@ public class ColumnDefsAndConfigs<T> if (column.isEditable() && ClientStaticState.isSimpleMode() == false) { toolTip += " This is an editibale column. Just double-click on a cell."; - CellEditor editor = new CellEditor(ColumnUtils.createCellEditorField(column.tryToGetDataType())); + CellEditor editor = ColumnUtils.createCellEditor(column.tryToGetDataType()); columnConfig.setEditor(editor); } columnConfig.setToolTip(toolTip); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/ColumnUtils.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/ColumnUtils.java index 2c01b7d7738..87b4d5b99ed 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/ColumnUtils.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/ColumnUtils.java @@ -16,28 +16,44 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid; -import com.extjs.gxt.ui.client.widget.form.Field; +import com.extjs.gxt.ui.client.event.FieldEvent; import com.extjs.gxt.ui.client.widget.grid.CellEditor; +import com.google.gwt.event.dom.client.KeyCodes; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataTypeCode; /** * Utility methods for columns. - * + * * @author Franz-Josef Elmer */ public class ColumnUtils { /** - * Creates a field for {@link CellEditor} based on specified data type. + * Creates a {@link CellEditor} based on specified data type. */ - public static Field<? extends Object> createCellEditorField(DataTypeCode dataTypeOrNull) + public static CellEditor createCellEditor(DataTypeCode dataTypeOrNull) { + CellEditor editor; switch (dataTypeOrNull) { - case MULTILINE_VARCHAR: return new MultiLineCellEditorField(); - default: return new DefaultCellEditorField(); + case MULTILINE_VARCHAR: + editor = new CellEditor(new MultiLineCellEditorField()) + { + // WORKAROUND to allow use enter key in table editing + @Override + protected void onSpecialKey(FieldEvent fe) + { + if (fe.getKeyCode() != KeyCodes.KEY_ENTER) + { + super.onSpecialKey(fe); + } + } + }; + return editor; + default: + editor = new CellEditor(new DefaultCellEditorField()); + return editor; } } - } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/script/ScriptExecutionFramework.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/script/ScriptExecutionFramework.java index 69a3b1331c9..55a74589e71 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/script/ScriptExecutionFramework.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/script/ScriptExecutionFramework.java @@ -173,7 +173,7 @@ public class ScriptExecutionFramework private void reset() { panel.reset(); - html.setHTML(""); + html.setMultilineHTML(""); evaluationResultPanel.setVisible(false); } @@ -346,7 +346,7 @@ public class ScriptExecutionFramework private void updateEvaluationResultField(String result) { - html.setHTML(result == null ? "(null)" : result); + html.setMultilineHTML(result == null ? "(null)" : result); } private static void updateVisibleEntityLink(boolean visible, Field<?> entityLink) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/MultilineHTML.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/MultilineHTML.java index 54eaa759f65..67cee7986a5 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/MultilineHTML.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/MultilineHTML.java @@ -44,10 +44,9 @@ public final class MultilineHTML extends HTML super(preserveWhitespace(html)); } - @Override - public void setHTML(String html) + public void setMultilineHTML(String html) { - super.setHTML(preserveWhitespace(html)); + setHTML(preserveWhitespace(html)); } private static final String BR = DOM.toString(DOM.createElement("br")); @@ -64,7 +63,8 @@ public final class MultilineHTML extends HTML result = result.replaceAll("[\t]", " "); result = result.replaceAll(" ", " "); // result will not be wrapped in AbstractBrowserGrid so we wrap it up in div with tooltip - return wrapUpInDivWithTooltip(result, html); + // WORKAROUND HTML tooltips don't support <br/> :( + return wrapUpInDivWithTooltip(result, result.replaceAll(BR, " ")); } public static String wrapUpInDivWithTooltip(String text, String tooltip) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/images/plus-icon.png b/openbis/source/java/ch/systemsx/cisd/openbis/public/images/plus-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..79f062aa94e5c5cff258bb52c2ff79fa1387b6c2 GIT binary patch literal 491 zcmV<H0Tlj;P)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00059Nkl<Zc-muR zzykV@@cl;@E42B<h)pdcE(0=5pEEpSn9U%^kjgOQv?S>Us4F=#eEIs4L4Z$|;p*+3 zq#K|jZ_V)a+ZzTxUP*?V_YRO|K<^=e|BABu3_pK;X5i)&Ww?F+Btx<N2kZuP?GyeF zGl~(&f`y*Ej55RTzdso`+4&gmKDdTrBTP-1(_2Qy_Fdxt3+(TK0}KX00k`hH6~o`Z ze;AmUm>GhVj$_DAIH<%>>GqP5v3Z;He<gWYhF|~RgUyDxf)T|<$hLymY)oPdcOTwk zsP%fv$XLHo@xPK1FT<aIUyxM7bTdN5pvHhh;XeaAlL*7@yRR7<{qHj}R<BY0kLo!_ z21cM}dF5YF+y65>xXTVv@Sg$6Ees5;A-5T^hHUu?t^bN@A0Ql{`UkfK7&;=Zp{Q-$ zq9<GJbLlZw14@?Y{a4g@3AP;s?%j}J=!v;Rd^#vxVDw*E`ytrtAO&}?%QN)HpCjIY z{COt-Ei5_U{1eB2FicE3L$m>+Km%T(3jz%g@JMF=3S=??@t+-YfBwT}fH)8f05LZZ h^P$Pzg3`~B1p%Q@rV#+WrRx9y002ovPDHLkV1j^q;v)b6 literal 0 HcmV?d00001 -- GitLab