diff --git a/code/datastudio/src/org.opengauss.mppdbide.presentation/src/org/opengauss/mppdbide/presentation/edittabledata/IEditTableExecuteQuery.java b/code/datastudio/src/org.opengauss.mppdbide.presentation/src/org/opengauss/mppdbide/presentation/edittabledata/IEditTableExecuteQuery.java index 401626d0b7bd9481d2825d230a38e24d7ad2a145..d2dcc74ecda42fe7db1c6000bd11f5a2c40d04f9 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.presentation/src/org/opengauss/mppdbide/presentation/edittabledata/IEditTableExecuteQuery.java +++ b/code/datastudio/src/org.opengauss.mppdbide.presentation/src/org/opengauss/mppdbide/presentation/edittabledata/IEditTableExecuteQuery.java @@ -303,14 +303,18 @@ public interface IEditTableExecuteQuery { */ static Blob convertToBlob(Connection con, Object value) { - if (null == value || !(value instanceof byte[])) { + if (value == null || !(value instanceof byte[] || value instanceof String)) { return null; } Blob createBlob = null; try { createBlob = con.createBlob(); - createBlob.setBytes(1, (byte[]) value); + if (value instanceof byte[]) { + createBlob.setBytes(1, (byte[]) value); + } else { + createBlob.setBytes(1, ((String) value).getBytes()); + } } catch (SQLException exception) { MPPDBIDELoggerUtility.error("Failed to convert bytes to blob object", exception); } diff --git a/code/datastudio/src/org.opengauss.mppdbide.utils/src/org/opengauss/mppdbide/utils/MPPDBIDEConstants.java b/code/datastudio/src/org.opengauss.mppdbide.utils/src/org/opengauss/mppdbide/utils/MPPDBIDEConstants.java index f4d8566b89e4510e16a163988f6d52bc4e9b19c6..8e9c4486614eaeb340e5ed31598da22da73ea06d 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.utils/src/org/opengauss/mppdbide/utils/MPPDBIDEConstants.java +++ b/code/datastudio/src/org.opengauss.mppdbide.utils/src/org/opengauss/mppdbide/utils/MPPDBIDEConstants.java @@ -412,6 +412,18 @@ public interface MPPDBIDEConstants { String BLOB = "BLOB"; String BLOB_WATERMARK = "[BLOB]"; + + String TINYBLOB = "TINYBLOB"; + + String TINYBLOB_WATERMARK = "[TINYBLOB]"; + + String MEDIUMBLOB = "MEDIUMBLOB"; + + String MEDIUMBLOB_WATERMARK = "[MEIDUMBLOB]"; + + String LONGBLOB = "LONGBLOB"; + + String LONGBLOB_WATERMARK = "[LONGBLOB]"; String BYTEA = "bytea"; diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/DSGridToolTipProvider.java b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/DSGridToolTipProvider.java index a6daeb8e412f7e6bef946121d7a199fb8a630be0..0824313901c6025ff7b6bbb17b6022129380365e 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/DSGridToolTipProvider.java +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/DSGridToolTipProvider.java @@ -149,8 +149,19 @@ public class DSGridToolTipProvider extends NatTableContentTooltip { String convertedDataType = CellDisplayConversionUtils.convertDataType(cell, getToolTipConfigRegistry()); String columnDataType = dataProvider.getColumnDataProvider().getColumnDataTypeName(cell.getColumnIndex()); - if (MPPDBIDEConstants.BLOB.equalsIgnoreCase(columnDataType) && !convertedDataType.isEmpty()) { - return MPPDBIDEConstants.BLOB_WATERMARK; + if (!convertedDataType.isEmpty()) { + if (MPPDBIDEConstants.BLOB.equalsIgnoreCase(columnDataType)) { + return MPPDBIDEConstants.BLOB_WATERMARK; + } + if (MPPDBIDEConstants.TINYBLOB.equalsIgnoreCase(columnDataType)) { + return MPPDBIDEConstants.TINYBLOB_WATERMARK; + } + if (MPPDBIDEConstants.MEDIUMBLOB.equalsIgnoreCase(columnDataType)) { + return MPPDBIDEConstants.MEDIUMBLOB_WATERMARK; + } + if (MPPDBIDEConstants.LONGBLOB.equalsIgnoreCase(columnDataType)) { + return MPPDBIDEConstants.LONGBLOB_WATERMARK; + } } Object cellValue = cell.getDataValue(); int dataType = dataProvider.getColumnDataProvider().getColumnDatatype(cell.getColumnIndex()); @@ -199,13 +210,24 @@ public class DSGridToolTipProvider extends NatTableContentTooltip { } private String getToolTipForLabelAsBody(String convertedDataType, String columnDataType) { - if (MPPDBIDEConstants.BLOB.equalsIgnoreCase(columnDataType) && !convertedDataType.isEmpty()) { - return MPPDBIDEConstants.BLOB_WATERMARK; - } else if (MPPDBIDEConstants.BYTEA.equalsIgnoreCase(columnDataType) && !convertedDataType.isEmpty()) { - return MPPDBIDEConstants.BYTEA_WATERMARK; - } else { - return getConvertedColumnData(convertedDataType, columnDataType); + if (!convertedDataType.isEmpty()) { + if (MPPDBIDEConstants.BLOB.equalsIgnoreCase(columnDataType)) { + return MPPDBIDEConstants.BLOB_WATERMARK; + } + if (MPPDBIDEConstants.TINYBLOB.equalsIgnoreCase(columnDataType)) { + return MPPDBIDEConstants.TINYBLOB_WATERMARK; + } + if (MPPDBIDEConstants.MEDIUMBLOB.equalsIgnoreCase(columnDataType)) { + return MPPDBIDEConstants.MEDIUMBLOB_WATERMARK; + } + if (MPPDBIDEConstants.LONGBLOB.equalsIgnoreCase(columnDataType)) { + return MPPDBIDEConstants.LONGBLOB_WATERMARK; + } + if (MPPDBIDEConstants.BYTEA.equalsIgnoreCase(columnDataType)) { + return MPPDBIDEConstants.BYTEA_WATERMARK; + } } + return getConvertedColumnData(convertedDataType, columnDataType); } private String getExplainAnalyzePlanTooltip(ILayerCell cell, LabelStack cellLabels) { diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/DSHtmlEscapedMarkupDisplayConverter.java b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/DSHtmlEscapedMarkupDisplayConverter.java index eb8c76b328de8a91d7a249d4e2a8224b14e02d41..e750830306c1e1493698116d1a0594dbbe2b5970 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/DSHtmlEscapedMarkupDisplayConverter.java +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/DSHtmlEscapedMarkupDisplayConverter.java @@ -69,22 +69,29 @@ public class DSHtmlEscapedMarkupDisplayConverter extends MarkupDisplayConverter Object canonicalValue = canonicalValueParam; IDSGridDataProvider dataProvider = dataGridContext.getDataProvider(); - if (Types.OTHER == dataProvider.getColumnDataProvider() - .getColumnDatatype(dataProvider.getColumnDataProvider().getColumnCount() - 1) - && canonicalValueParam != null && canonicalValue instanceof List) { - return MPPDBIDEConstants.CURSOR_WATERMARK; + if (canonicalValueParam != null) { + if (Types.OTHER == dataProvider.getColumnDataProvider() + .getColumnDatatype(dataProvider.getColumnDataProvider().getColumnCount() - 1) + && canonicalValue instanceof List) { + return MPPDBIDEConstants.CURSOR_WATERMARK; - } - - if (MPPDBIDEConstants.BLOB - .equalsIgnoreCase(dataProvider.getColumnDataProvider().getColumnDataTypeName(cell.getColumnIndex())) - && canonicalValueParam != null) { - return MPPDBIDEConstants.BLOB_WATERMARK; - } - if (MPPDBIDEConstants.BYTEA - .equalsIgnoreCase(dataProvider.getColumnDataProvider().getColumnDataTypeName(cell.getColumnIndex())) - && canonicalValueParam != null) { - return MPPDBIDEConstants.BYTEA_WATERMARK; + } + String colTypeName = dataProvider.getColumnDataProvider().getColumnDataTypeName(cell.getColumnIndex()); + if (MPPDBIDEConstants.BLOB.equalsIgnoreCase(colTypeName)) { + return MPPDBIDEConstants.BLOB_WATERMARK; + } + if (MPPDBIDEConstants.TINYBLOB.equalsIgnoreCase(colTypeName)) { + return MPPDBIDEConstants.TINYBLOB_WATERMARK; + } + if (MPPDBIDEConstants.MEDIUMBLOB.equalsIgnoreCase(colTypeName)) { + return MPPDBIDEConstants.MEDIUMBLOB_WATERMARK; + } + if (MPPDBIDEConstants.LONGBLOB.equalsIgnoreCase(colTypeName)) { + return MPPDBIDEConstants.LONGBLOB_WATERMARK; + } + if (MPPDBIDEConstants.BYTEA.equalsIgnoreCase(colTypeName)) { + return MPPDBIDEConstants.BYTEA_WATERMARK; + } } if (dataProvider instanceof DSObjectPropertiesGridDataProvider && canonicalValue == null) { diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/EditTableGridStyleConfiguration.java b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/EditTableGridStyleConfiguration.java index dbfc8aae6268f39cfbb9af0b92cafacc745b468d..b817d2bf3d8329ae79caa481a9f50843d1a5c242 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/EditTableGridStyleConfiguration.java +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/EditTableGridStyleConfiguration.java @@ -77,6 +77,7 @@ public class EditTableGridStyleConfiguration extends AbstractRegistryConfigurati implements IEditTableGridStyleLabelFactory { private static final String COL_LABEL_TIMESTAMP = "TIMESTAMP"; private static HashSet extraTypes = new HashSet<>(); + private static HashMap typeCell = new HashMap<>(); static { @@ -93,6 +94,10 @@ public class EditTableGridStyleConfiguration extends AbstractRegistryConfigurati extraTypes.add("point"); extraTypes.add("polygon"); extraTypes.add("binary"); + + typeCell.put(MPPDBIDEConstants.TINYBLOB, COL_LABEL_TINYBLOB_TYPE_CELL); + typeCell.put(MPPDBIDEConstants.MEDIUMBLOB, COL_LABEL_MEDIUMBLOB_TYPE_CELL); + typeCell.put(MPPDBIDEConstants.LONGBLOB, COL_LABEL_LONGBLOB_TYPE_CELL); } /** * Configure registry. @@ -385,7 +390,7 @@ public class EditTableGridStyleConfiguration extends AbstractRegistryConfigurati private void handleCommonColumnConfigureForBlob(IConfigRegistry configRegistry, IDSGridDataProvider dataProvider, int i) { if (MPPDBIDEConstants.BLOB.equals(dataProvider.getColumnDataProvider().getColumnDataTypeName(i))) { - blobConfiguration(configRegistry, dataProvider); + blobConfiguration(configRegistry, dataProvider, COL_LABEL_BLOB_TYPE_CELL); } else { configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new DSTextCellEditor(), DisplayMode.NORMAL, COL_LABEL_COPY_READONLY_CELL); @@ -395,6 +400,11 @@ public class EditTableGridStyleConfiguration extends AbstractRegistryConfigurati private void handleCommonColumnConfigureForOther(IConfigRegistry configRegistry, IDSGridDataProvider dataProvider, HashMap dolphinTypes, int i) { String colDatatypeName = dataProvider.getColumnDataProvider().getColumnDataTypeName(i); + String cell = typeCell.get(colDatatypeName); + if (cell != null) { + blobConfiguration(configRegistry, dataProvider, cell); + return; + } if (extraTypes.contains(colDatatypeName) || (dolphinTypes != null && dolphinTypes.containsKey(colDatatypeName))) { configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new DSTextCellEditor(), @@ -422,11 +432,13 @@ public class EditTableGridStyleConfiguration extends AbstractRegistryConfigurati * * @param configRegistry the config registry * @param dataProvider the data provider + * @param cell the data label */ - public static void blobConfiguration(IConfigRegistry configRegistry, IDSGridDataProvider dataProvider) { + public static void blobConfiguration(IConfigRegistry configRegistry, IDSGridDataProvider dataProvider, + String cell) { configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new DSBlobCellEditor(), - DisplayMode.NORMAL, COL_LABEL_BLOB_TYPE_CELL); - linkStyleConfiguration(configRegistry, COL_LABEL_BLOB_TYPE_CELL); + DisplayMode.NORMAL, cell); + linkStyleConfiguration(configRegistry, cell); } /** diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/GridSelectionLayerPortData.java b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/GridSelectionLayerPortData.java index 14875ba1daf03142a9562598418ae02a8b40fe51..96a7c4b7bafef5b4c0a6407f7dd78599b8cf9abc 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/GridSelectionLayerPortData.java +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/GridSelectionLayerPortData.java @@ -193,6 +193,18 @@ public class GridSelectionLayerPortData { cellDataValue[i + 1] = MPPDBIDEConstants.BLOB_WATERMARK; continue; } + case MPPDBIDEConstants.TINYBLOB: { + cellDataValue[i + 1] = MPPDBIDEConstants.TINYBLOB_WATERMARK; + continue; + } + case MPPDBIDEConstants.MEDIUMBLOB: { + cellDataValue[i + 1] = MPPDBIDEConstants.MEDIUMBLOB_WATERMARK; + continue; + } + case MPPDBIDEConstants.LONGBLOB: { + cellDataValue[i + 1] = MPPDBIDEConstants.LONGBLOB_WATERMARK; + continue; + } case MPPDBIDEConstants.BYTEA: { cellDataValue[i + 1] = MPPDBIDEConstants.BYTEA_WATERMARK; continue; diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/GridViewPortData.java b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/GridViewPortData.java index 513055ad70cebd864862cedb9ff23356c26397e4..293a9e21746a8d24984bf199c1b3609b8bcbb4c6 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/GridViewPortData.java +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/GridViewPortData.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.NoSuchElementException; import org.eclipse.nebula.widgets.nattable.layer.ILayer; +import org.eclipse.nebula.widgets.nattable.layer.LabelStack; import org.eclipse.nebula.widgets.nattable.print.command.TurnViewportOffCommand; import org.eclipse.nebula.widgets.nattable.print.command.TurnViewportOnCommand; import org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider; @@ -147,29 +148,44 @@ public class GridViewPortData implements Iterable { // As we operate on Grid Layer, Skip the row number column for (int i = 1; i < this.colCount; i++) { - // If the datatype is Blob, [BLOB] watermark is added - // instead of the content since it can be huge - if (this.viewport.getConfigLabelsByPosition(i, this.dataReadIndex) - .hasLabel(IEditTableGridStyleLabelFactory.COL_LABEL_BLOB_TYPE_CELL) - && this.viewport.getDataValueByPosition(i, this.dataReadIndex) != null) { - rowData[i - 1] = MPPDBIDEConstants.BLOB_WATERMARK; - continue; - } + Object dataValue = this.viewport.getDataValueByPosition(i, this.dataReadIndex); + if (dataValue != null) { + LabelStack stack = this.viewport.getConfigLabelsByPosition(i, this.dataReadIndex); + + // If the datatype is Blob, [BLOB] watermark is added + // instead of the content since it can be huge + if (stack.hasLabel(IEditTableGridStyleLabelFactory.COL_LABEL_BLOB_TYPE_CELL)) { + rowData[i - 1] = MPPDBIDEConstants.BLOB_WATERMARK; + continue; + } - if (this.viewport.getConfigLabelsByPosition(i, this.dataReadIndex) - .hasLabel(IEditTableGridStyleLabelFactory.COL_LABEL_CURSOR_TYPE_CELL) - && this.viewport.getDataValueByPosition(i, this.dataReadIndex) != null - && this.viewport.getDataValueByPosition(i, this.dataReadIndex) instanceof List) { - rowData[i - 1] = MPPDBIDEConstants.CURSOR_WATERMARK; - continue; - } - if (this.viewport.getConfigLabelsByPosition(i, this.dataReadIndex) - .hasLabel(IEditTableGridStyleLabelFactory.COL_LABEL_BYTEA_TYPE_CELL) - && this.viewport.getDataValueByPosition(i, this.dataReadIndex) != null) { - rowData[i - 1] = MPPDBIDEConstants.BYTEA_WATERMARK; - continue; + if (stack.hasLabel(IEditTableGridStyleLabelFactory.COL_LABEL_TINYBLOB_TYPE_CELL)) { + rowData[i - 1] = MPPDBIDEConstants.TINYBLOB_WATERMARK; + continue; + } + + if (stack.hasLabel(IEditTableGridStyleLabelFactory.COL_LABEL_MEDIUMBLOB_TYPE_CELL)) { + rowData[i - 1] = MPPDBIDEConstants.MEDIUMBLOB_WATERMARK; + continue; + } + + if (stack.hasLabel(IEditTableGridStyleLabelFactory.COL_LABEL_LONGBLOB_TYPE_CELL)) { + rowData[i - 1] = MPPDBIDEConstants.LONGBLOB_WATERMARK; + continue; + } + + if (stack.hasLabel(IEditTableGridStyleLabelFactory.COL_LABEL_CURSOR_TYPE_CELL) + && dataValue instanceof List) { + rowData[i - 1] = MPPDBIDEConstants.CURSOR_WATERMARK; + continue; + } + + if (stack.hasLabel(IEditTableGridStyleLabelFactory.COL_LABEL_BYTEA_TYPE_CELL)) { + rowData[i - 1] = MPPDBIDEConstants.BYTEA_WATERMARK; + continue; + } } - rowData[i - 1] = getObjectString(this.viewport.getDataValueByPosition(i, this.dataReadIndex)); + rowData[i - 1] = getObjectString(dataValue); } this.dataReadIndex++; return rowData; diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/IEditTableGridStyleLabelFactory.java b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/IEditTableGridStyleLabelFactory.java index 74e3f9c78e3b798024e1526a046282b27091b5e7..6fbe1990abb2d81ab41a3c5a1b972f930fe7026f 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/IEditTableGridStyleLabelFactory.java +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/component/grid/IEditTableGridStyleLabelFactory.java @@ -159,6 +159,21 @@ public interface IEditTableGridStyleLabelFactory { */ String COL_LABEL_BLOB_TYPE_CELL = "COL_LABEL_BLOB_TYPE_CELL"; + /** + * The col label tinyblob type cell. + */ + String COL_LABEL_TINYBLOB_TYPE_CELL = "COL_LABEL_TINYBLOB_TYPE_CELL"; + + /** + * The col label mediumblob type cell. + */ + String COL_LABEL_MEDIUMBLOB_TYPE_CELL = "COL_LABEL_MEDIUMBLOB_TYPE_CELL"; + + /** + * The col label longblob type cell. + */ + String COL_LABEL_LONGBLOB_TYPE_CELL = "COL_LABEL_LONGBLOB_TYPE_CELL"; + /** * The col label cursor type cell. */