Compare commits

...

3 Commits

Author SHA1 Message Date
kjwang
8c659ce305 Fix TUP-38298 Can't edit the two default contexts in testcase (#6046) (#6047)
* Fix TUP-38298 Can't edit the two default contexts in testcase
https://jira.talendforge.org/browse/TUP-38298
2023-03-10 17:43:36 +08:00
dicarcab
3ae34fc024 Revert "fix(TBD-14951):OracleDB Migration task affecting DI Jobs (#6042)" (#6043) 2023-03-09 16:03:17 +01:00
dicarcab
0d0b14b3f6 fix(TBD-14951):OracleDB Migration task affecting DI Jobs (#6042) 2023-03-09 15:57:25 +01:00
6 changed files with 39 additions and 46 deletions

View File

@@ -274,7 +274,7 @@ public class ContextTreeTable {
final GridLayer gridLayer = new GridLayer(viewportLayer, sortHeaderLayer, rowHeaderLayer, cornerLayer);
// config the column edit configuration
ContextValueLabelAccumulator labelAccumulator = new ContextValueLabelAccumulator(bodyDataLayer, bodyDataProvider);
ContextValueLabelAccumulator labelAccumulator = new ContextValueLabelAccumulator(bodyDataLayer, bodyDataProvider, manager.getContextManager(), columnGroupModel);
bodyDataLayer.setConfigLabelAccumulator(labelAccumulator);
registerColumnLabels(labelAccumulator, ContextRowDataListFixture.getContexts(manager.getContextManager()));

View File

@@ -137,7 +137,6 @@ public class ContextNatTableConfiguration extends AbstractRegistryConfiguration
Style cellStyleSelect = new Style();
cellStyleSelect.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, GUIHelper.COLOR_TITLE_INACTIVE_BACKGROUND);
cellStyleSelect.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, GUIHelper.COLOR_RED);
cellStyleSelect.setAttributeValue(CellStyleAttributes.FONT, GUIHelper.DEFAULT_FONT);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyleSelect, DisplayMode.SELECT,
ContextTableConstants.COLUMN_TYPE_PROPERTY);
@@ -162,7 +161,7 @@ public class ContextNatTableConfiguration extends AbstractRegistryConfiguration
configRegistry.registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR,
new EventDataValidator(dataProvider, manager), DisplayMode.EDIT, ContextTableConstants.COLUMN_NAME_PROPERTY);
configRegistry.registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR,
new EventDataValueValidator(dataProvider, manager), DisplayMode.EDIT, ContextTableConstants.COLUMN_CONTEXT_VALUE);
new EventDataValueValidator(dataProvider, manager, columnGroupModel), DisplayMode.EDIT, ContextTableConstants.COLUMN_CONTEXT_VALUE);
}
private void registerErrorHandlingStrategies(IConfigRegistry configRegistry) {

View File

@@ -77,6 +77,7 @@ public class ContextNatTableStyleConfiguration extends AbstractRegistryConfigura
Style cellStyleValueError = new Style();
cellStyleValueError.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, ColorConstants.ERROR_FONT_COLOR);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyleValueError, DisplayMode.NORMAL, ContextTableConstants.LABEL_VALUE_NOT_MATCH_TYPE);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyleValueError, DisplayMode.SELECT, ContextTableConstants.LABEL_VALUE_NOT_MATCH_TYPE);
Style cellStyleChangedForceGround = new Style();
cellStyleChangedForceGround.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, GUIHelper.COLOR_WIDGET_DARK_SHADOW);

View File

@@ -203,34 +203,6 @@ public class ContextNatTableUtils {
return ((ContextTableTabChildModel) element).getContextParameter().getName();
}
}
private static IContextParameter getContextParameter(Object element, int index) {
if (element instanceof ContextTableTabParentModel) {
ContextTableTabParentModel parentMode = (ContextTableTabParentModel) element;
if (parentMode.getContextParameter() != null && parentMode.getContextParameter().getContext() != null) {
return parentMode.getContextParameter().getContext().getContextParameter(parentMode.getContextParameter().getName());
}
} else if (element instanceof ContextTableTabChildModel) {
return ((ContextTableTabChildModel) element).getContextParameter();
}
return null;
}
public static String getCurrentContextDataType(Object element, int index) {
IContextParameter contextParameter = getContextParameter(element, index);
if (contextParameter != null) {
return contextParameter.getType();
}
return null;
}
public static String getCurrentContextValue(Object element, int index) {
IContextParameter contextParameter = getContextParameter(element, index);
if (contextParameter != null) {
return contextParameter.getValue();
}
return null;
}
public static String getSpecialTypeDisplayValue(String parameterType, String parameterValue) {
if (isResourceType(parameterType)) {

View File

@@ -14,9 +14,12 @@ package org.talend.core.ui.context.nattableTree;
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsDataProvider;
import org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel;
import org.eclipse.nebula.widgets.nattable.layer.ILayer;
import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
import org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator;
import org.talend.core.model.process.IContextManager;
import org.talend.core.model.process.IContextParameter;
import org.talend.core.ui.context.ContextTreeTable.ContextTreeNode;
import org.talend.core.ui.context.model.ContextTabChildModel;
import org.talend.core.ui.context.model.table.ContextTableConstants;
@@ -27,10 +30,14 @@ import org.talend.core.ui.utils.ContextTypeValidator;
public class ContextValueLabelAccumulator extends ColumnOverrideLabelAccumulator {
private IDataProvider dataProvider;
public ContextValueLabelAccumulator(ILayer layer, IDataProvider dataProvider) {
private ColumnGroupModel columnGroupModel;
private IContextManager manager;
public ContextValueLabelAccumulator(ILayer layer, IDataProvider dataProvider, IContextManager manager, ColumnGroupModel columnGroupModel) {
super(layer);
this.dataProvider = dataProvider;
this.manager = manager;
this.columnGroupModel = columnGroupModel;
}
@@ -40,14 +47,18 @@ public class ContextValueLabelAccumulator extends ColumnOverrideLabelAccumulator
boolean isAddedValueNotMatchStyle = false;
ContextTreeNode rowNode = ((GlazedListsDataProvider<ContextTreeNode>) dataProvider).getList().get(rowPosition);
if (configLabels.contains(ContextTableConstants.COLUMN_CONTEXT_VALUE)) {
String dataType = ContextNatTableUtils.getCurrentContextDataType(rowNode.getTreeData(), rowPosition);
String value = ContextNatTableUtils.getCurrentContextValue(rowNode.getTreeData(), rowPosition);
boolean isValid = ContextTypeValidator.isMatchType(dataType, value);
if (isValid) {
configLabels.remove(ContextTableConstants.LABEL_VALUE_NOT_MATCH_TYPE);
} else {
configLabels.addLabel(ContextTableConstants.LABEL_VALUE_NOT_MATCH_TYPE);
isAddedValueNotMatchStyle = true;
if (columnGroupModel != null && columnGroupModel.isPartOfAGroup(columnPosition)) {
String columnGroupName = columnGroupModel.getColumnGroupByIndex(columnPosition).getName();
IContextParameter realPara = ContextNatTableUtils.getRealParameter(manager, columnGroupName, rowNode.getTreeData());
if (realPara != null) {
boolean isValid = ContextTypeValidator.isMatchType(realPara.getType(), realPara.getValue());
if (isValid) {
configLabels.remove(ContextTableConstants.LABEL_VALUE_NOT_MATCH_TYPE);
} else {
configLabels.addLabel(ContextTableConstants.LABEL_VALUE_NOT_MATCH_TYPE);
isAddedValueNotMatchStyle = true;
}
}
}
}

View File

@@ -16,29 +16,39 @@ import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
import org.eclipse.nebula.widgets.nattable.data.validate.DataValidator;
import org.eclipse.nebula.widgets.nattable.data.validate.ValidationFailedException;
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsDataProvider;
import org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel;
import org.talend.core.model.process.IContextManager;
import org.talend.core.model.process.IContextParameter;
import org.talend.core.ui.context.ContextTreeTable.ContextTreeNode;
import org.talend.core.ui.i18n.Messages;
import org.talend.core.ui.utils.ContextTypeValidator;
public class EventDataValueValidator extends DataValidator {
private ColumnGroupModel columnGroupModel;
private IDataProvider dataProvider;
private IContextManager manager;
EventDataValueValidator(IDataProvider bodyDataProvider, IContextManager manager) {
EventDataValueValidator(IDataProvider bodyDataProvider, IContextManager manager, ColumnGroupModel columnGroupModel) {
this.dataProvider = bodyDataProvider;
this.manager = manager;
this.columnGroupModel = columnGroupModel;
}
@Override
public boolean validate(int columnIndex, int rowIndex, Object newValue) {
boolean isValid = true;
ContextTreeNode rowNode = ((GlazedListsDataProvider<ContextTreeNode>) dataProvider).getList().get(rowIndex);
String dataType = ContextNatTableUtils.getCurrentContextDataType(rowNode.getTreeData(), rowIndex);
boolean isValid = ContextTypeValidator.isMatchType(dataType, newValue);
if (!isValid) {
throw new ValidationFailedException(Messages.getString("ContextValidator.ParameterValueNotMatch")); //$NON-NLS-1$
if (columnGroupModel != null && columnGroupModel.isPartOfAGroup(columnIndex)) {
String columnGroupName = columnGroupModel.getColumnGroupByIndex(columnIndex).getName();
IContextParameter realPara = ContextNatTableUtils.getRealParameter(manager, columnGroupName, rowNode.getTreeData());
if (realPara != null) {
isValid = ContextTypeValidator.isMatchType(realPara.getType(), newValue);
if (!isValid) {
throw new ValidationFailedException(Messages.getString("ContextValidator.ParameterValueNotMatch")); //$NON-NLS-1$
}
}
}
return isValid;
}