use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.
the class DynamicTabbedPropertySection method addComponents.
/**
* Initialize all components for the defined section for this node.
*/
public void addComponents(boolean forceRedraw, boolean reInitialize) {
registerListenerForRefreshingSection();
checkErrorsWhenViewRefreshed = true;
int heightSize = 0, maxRowSize = 0, nbInRow, numInRow;
int maxRow;
List<? extends IElementParameter> listParam = elem.getElementParameters();
oldQueryStoreType = (String) elem.getPropertyValue(EParameterName.QUERYSTORE_TYPE.getName());
if (oldQueryStoreType != null) {
if (oldQueryStoreType.equals(EmfComponent.REPOSITORY)) {
showQueryStoreRepositoryList(true);
updateRepositoryList();
} else {
showQueryStoreRepositoryList(false);
}
}
IElementParameter param = elem.getElementParameter(EParameterName.PROPERTY_TYPE.getName());
if (param != null) {
oldPropertyType = (String) param.getValue();
if (param.isShow(elem.getElementParameters())) {
if (oldPropertyType.equals(EmfComponent.REPOSITORY)) {
showPropertyRepositoryList(true, false);
updateRepositoryList();
} else {
showPropertyRepositoryList(false, false);
}
} else {
showPropertyRepositoryList(false, false);
}
}
// param = elem.getElementParameter(extraPropertyTypeName);
if (param != null) {
oldPropertyType = (String) param.getValue();
if (param.isShow(elem.getElementParameters())) {
if (oldPropertyType.equals(EmfComponent.REPOSITORY)) {
showPropertyRepositoryList(true, true);
updateRepositoryList();
} else {
showPropertyRepositoryList(false, true);
}
} else {
showPropertyRepositoryList(false, true);
}
}
oldProcessType = (String) elem.getPropertyValue(EParameterName.PROCESS_TYPE_PROCESS.getName());
if (oldProcessType != null) {
String[] list = elem.getElementParameter(EParameterName.PROCESS_TYPE_PROCESS.getName()).getListItemsDisplayName();
if ((oldProcessType.equals("NO_PROCESS") || (list.length == 0))) {
//$NON-NLS-1$
updateProcessList();
updateContextList();
if (elem instanceof Node) {
((Node) elem).checkAndRefreshNode();
}
}
}
if (!forceRedraw) {
boolean needRedraw = false;
for (IElementParameter elementParameter : elem.getElementParametersWithChildrens()) {
if (elementParameter.getCategory().equals(section) && (elementParameter.getFieldType() != EParameterFieldType.SCHEMA_TYPE) && (elementParameter.getFieldType() != EParameterFieldType.SCHEMA_REFERENCE) && (elementParameter.getFieldType() != EParameterFieldType.QUERYSTORE_TYPE)) {
// if the component must be displayed, then check if the
// control exists or not.
boolean show = elementParameter.isShow(elem.getElementParameters());
Object control;
if (elementParameter.getParentParameter() == null) {
control = this.hashCurControls.get(elementParameter.getName());
} else {
control = this.hashCurControls.get(//$NON-NLS-1$
elementParameter.getParentParameter().getName() + ":" + elementParameter.getName());
}
if ((control == null && show) || (control != null && !show)) {
needRedraw = true;
break;
// System.out.println(elementParameter.getName() + "
// need redraw");
}
}
}
if (!needRedraw) {
// System.out.println("no need redraw");
return;
}
}
Control lastControl = null;
if (reInitialize) {
if (currentComponent != null && composite != null) {
Control[] ct = composite.getChildren();
for (Control element : ct) {
element.dispose();
}
}
} else {
// Control[] ct = composite.getChildren();
// int curY = 0, maxY = 0;
// for (int i = 0; i < ct.length; i++) {
// curY = ct[i].getLocation().y + ct[i].computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
// if (curY > maxY) {
// maxY = curY;
// }
// }
heightSize = curRowSize;
}
hashCurControls = new DualHashBidiMap();
maxRow = 0;
for (int i = 0; i < listParam.size(); i++) {
if (listParam.get(i).getCategory() == section) {
if (listParam.get(i).getNumRow() > maxRow && listParam.get(i).isShow(listParam)) {
maxRow = listParam.get(i).getNumRow();
}
}
}
generator.initController(this);
// System.out.println("********************** NEW ADDCOMPONENTS
// **********************");
TabbedPropertyComposite tabbedPropertyComposite = this.getTabbedPropertyComposite();
int additionalHeightSize = 0;
if (tabbedPropertyComposite != null && (!(elem instanceof org.talend.designer.core.ui.editor.connections.Connection))) {
boolean hasDynamicRow = false;
for (int i = 0; i < listParam.size(); i++) {
IElementParameter curParam = listParam.get(i);
if (curParam.getCategory() == section) {
if (curParam.getFieldType() != EParameterFieldType.TECHNICAL) {
if (curParam.isShow(listParam)) {
AbstractElementPropertySectionController controller = generator.getController(curParam.getFieldType(), this);
if (controller == null) {
continue;
}
if (controller.hasDynamicRowSize()) {
hasDynamicRow = true;
break;
}
}
}
}
}
if (hasDynamicRow) {
additionalHeightSize = estimatePropertyHeightSize(maxRow, listParam, tabbedPropertyComposite);
}
}
//$NON-NLS-1$
long lastTime = TimeMeasure.timeSinceBegin("DTP:refresh:" + getCurrentComponent());
curRowSize = 0;
for (int curRow = 1; curRow <= maxRow; curRow++) {
maxRowSize = 0;
nbInRow = 0;
for (int i = 0; i < listParam.size(); i++) {
IElementParameter curParam = listParam.get(i);
if (curParam.getCategory() == section) {
if (curParam.getNumRow() == curRow && curParam.isShow(listParam) && (curParam.getFieldType() != EParameterFieldType.TECHNICAL)) {
nbInRow++;
}
}
}
numInRow = 0;
lastControl = null;
for (int i = 0; i < listParam.size(); i++) {
IElementParameter curParam = listParam.get(i);
if (curParam.getCategory() == section) {
if (curParam.getNumRow() == curRow && (curParam.getFieldType() != EParameterFieldType.TECHNICAL)) {
// field:"+curParam.getField());
if (curParam.isShow(listParam)) {
// System.out.println("show:" + curParam.getName()+
// " field:"+curParam.getField());
numInRow++;
AbstractElementPropertySectionController controller = generator.getController(curParam.getFieldType(), this);
if (controller == null) {
continue;
}
if (controller.hasDynamicRowSize()) {
controller.setAdditionalHeightSize(additionalHeightSize);
}
lastControl = controller.createControl(composite, curParam, numInRow, nbInRow, heightSize, lastControl);
//$NON-NLS-1$
lastTime = TimeMeasure.timeSinceBegin("DTP:refresh:" + getCurrentComponent()) - lastTime;
if ((DynamicTabbedPropertySection.DEBUG_TIME) && !getCurrentComponent().equals("Job")) {
//$NON-NLS-1$
System.out.println(//$NON-NLS-1$ //$NON-NLS-2$
"DTP;create:" + curParam.getFieldType().getName() + ";" + getCurrentComponent() + ";" + //$NON-NLS-1$
lastTime);
}
if (curRowSize > maxRowSize) {
maxRowSize = curRowSize;
}
}
}
}
}
heightSize += maxRowSize;
}
resizeScrolledComposite();
}
use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.
the class DynamicTabbedPropertySection method updateRepositoryList.
/**
* ftang Comment method "updateRepositoryList".
*/
@SuppressWarnings("unchecked")
public void updateRepositoryList() {
IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
tableIdAndDbTypeMap = new HashMap<String, String>();
tableIdAndDbSchemaMap = new HashMap<String, String>();
List<ConnectionItem> metadataConnectionsItem = null;
String[] repositoryTableNameList = new String[] {};
String[] repositoryTableValueList = new String[] {};
String[] repositoryConnectionNameList = new String[] {};
String[] repositoryConnectionValueList = new String[] {};
String[] repositoryQueryNameList = new String[] {};
String[] repositoryQueryValueList = new String[] {};
try {
metadataConnectionsItem = factory.getMetadataConnectionsItem();
} catch (PersistenceException e) {
throw new RuntimeException(e);
}
if (metadataConnectionsItem != null) {
repositoryTableMap.clear();
repositoryQueryStoreMap.clear();
repositoryConnectionItemMap.clear();
tablesMap.clear();
queriesMap.clear();
List<String> tableNamesList = new ArrayList<String>();
List<String> tableValuesList = new ArrayList<String>();
List<String> queryStoreNameList = new ArrayList<String>();
List<String> queryStoreValuesList = new ArrayList<String>();
for (ConnectionItem connectionItem : metadataConnectionsItem) {
Connection connection = connectionItem.getConnection();
if (!connection.isReadOnly()) {
//$NON-NLS-1$
repositoryConnectionItemMap.put(connectionItem.getProperty().getId() + "", connectionItem);
for (Object tableObj : ConnectionHelper.getTables(connection)) {
org.talend.core.model.metadata.builder.connection.MetadataTable table;
table = (org.talend.core.model.metadata.builder.connection.MetadataTable) tableObj;
if (factory.getStatus(connectionItem) != ERepositoryStatus.DELETED) {
if (!factory.isDeleted(table)) {
String name = //$NON-NLS-1$
getRepositoryAliasName(connectionItem) + ":" + connectionItem.getProperty().getLabel() + " - " + //$NON-NLS-1$
table.getLabel();
//$NON-NLS-1$
String value = connectionItem.getProperty().getId() + " - " + table.getLabel();
IMetadataTable newTable = ConvertionHelper.convert(table);
repositoryTableMap.put(value, newTable);
if (connection instanceof DatabaseConnection) {
String dbType = ((DatabaseConnection) connection).getDatabaseType();
String schema = ((DatabaseConnection) connection).getUiSchema();
tableIdAndDbTypeMap.put(newTable.getId(), dbType);
if (schema != null && !schema.equals("")) {
//$NON-NLS-1$
tableIdAndDbSchemaMap.put(newTable.getId(), schema);
}
}
addOrderDisplayNames(tableValuesList, tableNamesList, value, name);
// tableNamesList.add(name);
// tableValuesList.add(value);
}
}
}
}
tablesMap.put(connectionItem.getProperty().getId(), tableValuesList);
if (connection instanceof DatabaseConnection && !connection.isReadOnly()) {
DatabaseConnection dbConnection = (DatabaseConnection) connection;
QueriesConnection queriesConnection = dbConnection.getQueries();
if (queriesConnection != null) {
List<Query> qs = queriesConnection.getQuery();
for (Query query : qs) {
String name = //$NON-NLS-1$
getRepositoryAliasName(connectionItem) + ":" + connectionItem.getProperty().getLabel() + " - " + //$NON-NLS-1$
query.getLabel();
//$NON-NLS-1$
String value = connectionItem.getProperty().getId() + " - " + query.getLabel();
repositoryQueryStoreMap.put(value, query);
addOrderDisplayNames(queryStoreValuesList, queryStoreNameList, value, name);
// queryStoreNameList.add(name);
// queryStoreValuesList.add(value);
}
}
}
queriesMap.put(connectionItem.getProperty().getId(), queryStoreValuesList);
}
repositoryTableNameList = tableNamesList.toArray(new String[0]);
repositoryTableValueList = tableValuesList.toArray(new String[0]);
repositoryQueryNameList = queryStoreNameList.toArray(new String[0]);
repositoryQueryValueList = queryStoreValuesList.toArray(new String[0]);
}
initMaps();
for (int i = 0; i < elem.getElementParameters().size(); i++) {
IElementParameter param = elem.getElementParameters().get(i);
if (param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE) || param.getFieldType().equals(EParameterFieldType.SCHEMA_REFERENCE)) {
IElementParameter repositorySchemaType = param.getChildParameters().get(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
repositorySchemaType.setListItemsDisplayName(repositoryTableNameList);
repositorySchemaType.setListItemsValue(repositoryTableValueList);
if (!repositoryTableMap.keySet().contains(repositorySchemaType.getValue())) {
List<String> list2 = tablesMap.get(elem.getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()));
boolean isNeeded = list2 != null && !list2.isEmpty();
if (repositoryTableNameList.length > 0 && repositoryConnectionValueList.length > 0 && isNeeded) {
repositorySchemaType.setValue(getDefaultRepository(param, true, repositoryConnectionValueList[0]));
// elem.setPropertyValue(EParameterName.REPOSITORY_SCHEMA_TYPE.getName(),
// getDefaultRepository(
// true, repositoryConnectionValueList[0]));
}
}
}
if (param.getName().equals(EParameterName.REPOSITORY_QUERYSTORE_TYPE.getName())) {
param.setListItemsDisplayName(repositoryQueryNameList);
param.setListItemsValue(repositoryQueryValueList);
if (!repositoryQueryStoreMap.keySet().contains(param.getValue())) {
List<String> list2 = queriesMap.get(elem.getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()));
boolean isNeeded = list2 != null && !list2.isEmpty();
if (repositoryQueryNameList.length > 0 && repositoryConnectionValueList.length > 0 && isNeeded) {
elem.setPropertyValue(EParameterName.REPOSITORY_QUERYSTORE_TYPE.getName(), getDefaultRepository(elem.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE), false, repositoryConnectionValueList[0]));
}
}
}
if (param.getName().equals(EParameterName.REPOSITORY_PROPERTY_TYPE.getName())) {
updateRepositoryListExtra(param, repositoryConnectionNameList, repositoryConnectionValueList, false);
}
// // for job settings extra (feature 2710)
// if (param.getName().equals(extraRepositoryPropertyTypeName)) {
// updateRepositoryListExtra(param, repositoryConnectionNameList, repositoryConnectionValueList, true);
// }
}
updateQuery();
}
use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.
the class TableByRowController method updateConnectionList.
private void updateConnectionList(IElementParameter param) {
// update table values
TableViewerCreator tableViewerCreator = (TableViewerCreator) hashCurControls.get(param.getName());
Object[] itemsValue = param.getListItemsValue();
if (tableViewerCreator != null && itemsValue != null) {
List colList = tableViewerCreator.getColumns();
for (int j = 0; j < itemsValue.length; j++) {
if ((j + 1) >= colList.size()) {
break;
}
if (itemsValue[j] instanceof IElementParameter) {
IElementParameter tmpParam = (IElementParameter) itemsValue[j];
if (tmpParam.getFieldType() == EParameterFieldType.CONNECTION_LIST) {
String[] contextParameterNames = null;
ConnectionListController.updateConnectionList(elem, tmpParam);
contextParameterNames = tmpParam.getListItemsDisplayName();
tmpParam.setListItemsDisplayCodeName(contextParameterNames);
// tmpParam.setListItemsValue(contextParameterNames);
if (contextParameterNames.length > 0) {
tmpParam.setDefaultClosedListValue(contextParameterNames[0]);
} else {
//$NON-NLS-1$
tmpParam.setDefaultClosedListValue("");
}
// j + 1 because first column is masked
TableViewerCreatorColumnNotModifiable column = (TableViewerCreatorColumnNotModifiable) colList.get(j + 1);
CCombo combo = (CCombo) column.getCellEditor().getControl();
String[] oldItems = combo.getItems();
combo.setItems(contextParameterNames);
List<Map<String, Object>> paramValues = (List<Map<String, Object>>) param.getValue();
String[] items = param.getListItemsDisplayCodeName();
for (int currentIndex = 0; currentIndex < paramValues.size(); currentIndex++) {
Map<String, Object> currentLine = paramValues.get(currentIndex);
Object o = currentLine.get(items[j]);
if (o instanceof Integer) {
Integer nb = (Integer) o;
if ((nb >= oldItems.length) || (nb == -1)) {
nb = new Integer(tmpParam.getIndexOfItemFromList((String) tmpParam.getDefaultClosedListValue()));
currentLine.put(items[j], nb);
} else {
nb = new Integer(tmpParam.getIndexOfItemFromList(oldItems[nb]));
currentLine.put(items[j], nb);
}
}
}
}
}
}
}
}
use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.
the class TableByRowController method overideDQPatternList.
/**
* Overide default pattern list value by them which comes from DQ repository view
*
* @param param the element parameter
* @param dqPatternService extended service for DQ pattern retrievement.
* @return
*/
private void overideDQPatternList(IElementParameter param) {
// For dq patterns
if (isDQPatternList(param)) {
if (dqPatternService == null) {
// get pattern service
dqPatternService = getDQPatternService();
}
if (dqPatternService != null && elem instanceof Node) {
Node node = (Node) elem;
//$NON-NLS-1$
IElementParameter typeParam = node.getElementParameter("TYPE");
// Customized value
Object[] customizedValue = param.getListItemsValue();
String[] customizedDisplayCodeName = param.getListItemsDisplayCodeName();
String[] customizedDisplayName = param.getListItemsDisplayName();
String[] customizedNotShowIfs = param.getListItemsNotShowIf();
String[] customizedShowIfs = param.getListItemsShowIf();
dqPatternService.overridePatternList(typeParam, param);
// Add the customized value:
param.setListItemsValue(ArrayUtils.addAll(param.getListItemsValue(), customizedValue));
param.setListItemsDisplayCodeName((String[]) ArrayUtils.addAll(param.getListItemsDisplayCodeName(), customizedDisplayCodeName));
param.setListItemsDisplayName((String[]) ArrayUtils.addAll(param.getListItemsDisplayName(), customizedDisplayName));
param.setListItemsNotShowIf((String[]) ArrayUtils.addAll(new String[param.getListItemsShowIf().length], customizedNotShowIfs));
param.setListItemsShowIf((String[]) ArrayUtils.addAll(new String[param.getListItemsShowIf().length], customizedShowIfs));
}
}
}
use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.
the class TableByRowController method updateColumnList.
private void updateColumnList(IElementParameter param) {
if (elem instanceof Node) {
ColumnListController.updateColumnList((Node) elem, null);
} else if (elem instanceof Connection) {
ColumnListController.updateColumnList(((Connection) elem).getSource(), null);
}
TableViewerCreator tableViewerCreator = (TableViewerCreator) hashCurControls.get(param.getName());
Object[] itemsValue = param.getListItemsValue();
if (tableViewerCreator != null && itemsValue != null) {
List colList = tableViewerCreator.getColumns();
for (int j = 0; j < itemsValue.length; j++) {
if (itemsValue[j] instanceof IElementParameter) {
IElementParameter tmpParam = (IElementParameter) itemsValue[j];
if (tmpParam.getFieldType() == EParameterFieldType.COLUMN_LIST || tmpParam.getFieldType() == EParameterFieldType.PREV_COLUMN_LIST || tmpParam.getFieldType() == EParameterFieldType.LOOKUP_COLUMN_LIST) {
if ((j + 1) >= colList.size()) {
break;
}
TableViewerCreatorColumnNotModifiable column = (TableViewerCreatorColumnNotModifiable) colList.get(j + 1);
CellEditor cellEditor = column.getCellEditor();
String[] oldItems = null;
if (cellEditor instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) cellEditor.getControl();
oldItems = combo.getItems();
combo.setItems(tmpParam.getListItemsDisplayName());
}
List<Map<String, Object>> paramValues = (List<Map<String, Object>>) param.getValue();
String[] items = param.getListItemsDisplayCodeName();
for (int currentIndex = 0; currentIndex < paramValues.size(); currentIndex++) {
Map<String, Object> currentLine = paramValues.get(currentIndex);
Object o = currentLine.get(items[j]);
if (o instanceof Integer) {
Integer nb = (Integer) o;
if ((nb >= oldItems.length) || (nb == -1)) {
nb = new Integer(tmpParam.getIndexOfItemFromList((String) tmpParam.getDefaultClosedListValue()));
currentLine.put(items[j], nb);
} else {
nb = new Integer(tmpParam.getIndexOfItemFromList(oldItems[nb]));
currentLine.put(items[j], nb);
}
}
}
}
}
}
}
}
Aggregations