use of org.talend.designer.core.ui.projectsetting.ImplicitContextLoadElement in project tdi-studio-se by Talend.
the class TextController method createControl.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
*/
@Override
public Control createControl(final Composite subComposite, final IElementParameter param, final int numInRow, final int nbInRow, final int top, final Control lastControl) {
this.curParameter = param;
this.paramFieldType = param.getFieldType();
FormData data;
final DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new SelectAllTextControlCreator());
if (param.isRequired()) {
FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
}
if (canAddRepositoryDecoration(param)) {
FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
//$NON-NLS-1$
decoration.setDescription(Messages.getString("TextController.decoration.description"));
dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
}
Control cLayout = dField.getLayoutControl();
Text labelText = (Text) dField.getControl();
labelText.setData(PARAMETER_NAME, param.getName());
editionControlHelper.register(param.getName(), labelText);
cLayout.setBackground(subComposite.getBackground());
if (elem instanceof Node) {
labelText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
}
if (!isReadOnly()) {
if (param.isRepositoryValueUsed() && !(elem instanceof org.talend.designer.core.ui.editor.process.Process || elem instanceof StatsAndLogsElement || elem instanceof ImplicitContextLoadElement)) {
addRepositoryPropertyListener(labelText);
}
if (param.isRequired()) {
labelText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
checkTextError(param, labelText, labelText.getText());
}
});
}
boolean editable = !param.isReadOnly() && (elem instanceof FakeElement || !param.isRepositoryValueUsed());
labelText.setEditable(editable);
} else {
labelText.setEditable(false);
}
addDragAndDropTarget(labelText);
CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
data = new FormData();
if (lastControl != null) {
data.left = new FormAttachment(lastControl, 0);
} else {
data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
}
data.top = new FormAttachment(0, top);
labelLabel.setLayoutData(data);
// *********************
data = new FormData();
int currentLabelWidth = STANDARD_LABEL_WIDTH;
GC gc = new GC(labelLabel);
Point labelSize = gc.stringExtent(param.getDisplayName());
gc.dispose();
if ((labelSize.x + (ITabbedPropertyConstants.HSPACE * 2)) > currentLabelWidth) {
currentLabelWidth = labelSize.x + (ITabbedPropertyConstants.HSPACE * 2);
}
if (numInRow == 1) {
if (lastControl != null) {
data.left = new FormAttachment(lastControl, currentLabelWidth);
} else {
data.left = new FormAttachment(0, currentLabelWidth);
}
} else {
data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
}
data.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
data.top = new FormAttachment(0, top);
cLayout.setLayoutData(data);
// **********************
hashCurControls.put(param.getName(), labelText);
Point initialSize = cLayout.computeSize(SWT.DEFAULT, SWT.DEFAULT);
// curRowSize = initialSize.y + ITabbedPropertyConstants.VSPACE;
dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
if (isInWizard()) {
labelLabel.setAlignment(SWT.RIGHT);
if (lastControl != null) {
data.right = new FormAttachment(lastControl, 0);
} else {
data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
}
data.left = new FormAttachment((((nbInRow - numInRow) * MAX_PERCENT) / nbInRow), currentLabelWidth + ITabbedPropertyConstants.HSPACE);
data = (FormData) labelLabel.getLayoutData();
data.right = new FormAttachment(cLayout, 0);
data.left = new FormAttachment((((nbInRow - numInRow) * MAX_PERCENT) / nbInRow), 0);
return labelLabel;
}
return cLayout;
}
use of org.talend.designer.core.ui.projectsetting.ImplicitContextLoadElement in project tdi-studio-se by Talend.
the class PropertyTypeController method createButtonCommand.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties.controllers.AbstractRepositoryController#createControl(org.eclipse
* .swt.widgets.Composite, org.talend.core.model.process.IElementParameter, int, int, int,
* org.eclipse.swt.widgets.Control)
*/
@Override
protected Command createButtonCommand(Button button) {
// hwang add for feature 6484
FileItem repositoryFileItem = null;
LinkRulesItem linkItem = null;
Map<String, FileItem> repositoryFileItemMap = null;
Map<String, LinkRulesItem> repositoryLinkRulesItemMap = null;
String paramName = (String) button.getData(PARAMETER_NAME);
IElementParameter param = elem.getElementParameter(paramName);
Object data = button.getData(NAME);
if (data != null && data.equals(REPOSITORY_CHOICE)) {
IElementParameter dbTypeParam = null;
if (elem instanceof org.talend.designer.core.ui.editor.process.Process || elem instanceof StatsAndLogsElement || elem instanceof ImplicitContextLoadElement) {
if (EParameterName.PROPERTY_TYPE.getName().equals(paramName)) {
dbTypeParam = elem.getElementParameter(EParameterName.DB_TYPE.getName());
} else if (JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()).equals(paramName)) {
dbTypeParam = elem.getElementParameter(JobSettingsConstants.getExtraParameterName(EParameterName.DB_TYPE.getName()));
}
}
Item item = null;
String id = null;
RepositoryNode selectNode = null;
if (id == null) {
RepositoryReviewDialog dialog = null;
if (dbTypeParam != null) {
String[] listRepositoryItems = dbTypeParam.getListRepositoryItems();
dialog = new RepositoryReviewDialog(Display.getCurrent().getActiveShell(), ERepositoryObjectType.METADATA, param.getRepositoryValue(), listRepositoryItems);
} else {
// Added TDQ-11688
ITDQPatternService service = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQPatternService.class)) {
service = (ITDQPatternService) GlobalServiceRegister.getDefault().getService(ITDQPatternService.class);
}
if (service != null && service.isSinglePatternNode(elem)) {
return processPattern(elem);
}
// ~
dialog = new RepositoryReviewDialog(Display.getCurrent().getActiveShell(), ERepositoryObjectType.METADATA, elem, param);
}
if (dialog.open() == RepositoryReviewDialog.OK) {
selectNode = dialog.getResult();
id = selectNode.getObject().getId();
}
}
if (id != null && !"".equals(id)) {
//$NON-NLS-1$
IElementParameter repositoryParam = param.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
//$NON-NLS-1$
String fullParamName = paramName + ":" + getRepositoryChoiceParamName();
Connection repositoryConnection = null;
// Map<String, ConnectionItem> repositoryConnectionItemMap =
// dynamicProperty.getRepositoryConnectionItemMap();
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
IRepositoryViewObject repobj = factory.getLastVersion(id);
if (repobj != null) {
Property property = repobj.getProperty();
if (property != null) {
item = property.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null) {
if (item instanceof ConnectionItem) {
repositoryConnection = ((ConnectionItem) item).getConnection();
}
} else {
repositoryConnection = null;
if (repositoryParam != null) {
item = selectNode.getObject().getProperty().getItem();
if (item instanceof ConnectionItem) {
repositoryConnection = ((ConnectionItem) item).getConnection();
}
}
}
if (repositoryConnection != null) {
CompoundCommand compoundCommand = new CompoundCommand();
ChangeValuesFromRepository changeValuesFromRepository = null;
if (selectNode.getObjectType() == ERepositoryObjectType.SERVICESOPERATION && GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
IESBService service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
IProcess2 process = (IProcess2) RepositoryPlugin.getDefault().getDesignerCoreService().getCurrentProcess();
String currentJobId = process.getProperty().getId();
String serviceId = item.getProperty().getId();
String portId = selectNode.getParent().getObject().getId();
String operationId = selectNode.getObject().getId();
changeValuesFromRepository = new ChangeValuesFromRepository(elem, repositoryConnection, param.getName() + ":" + //$NON-NLS-1$
EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$ //$NON-NLS-2$
serviceId + " - " + portId + " - " + operationId);
service.deleteOldRelation(currentJobId);
//$NON-NLS-1$ //$NON-NLS-2$
service.updateOperation((INode) elem, serviceId + " - " + portId + " - " + operationId, selectNode);
} else {
changeValuesFromRepository = new ChangeValuesFromRepository(elem, repositoryConnection, fullParamName, id);
}
if (changeValuesFromRepository != null) {
compoundCommand.add(changeValuesFromRepository);
}
updateDBType(compoundCommand, repositoryConnection);
return compoundCommand;
}
// for ruleItem,hywang add
if (dynamicProperty instanceof MultipleThreadDynamicComposite) {
repositoryFileItemMap = ((MultipleThreadDynamicComposite) dynamicProperty).getRepositoryFileItemMap();
repositoryLinkRulesItemMap = ((MultipleThreadDynamicComposite) dynamicProperty).getRepositoryLinkRulesItemMap();
}
if (repositoryFileItemMap.containsKey(id)) {
repositoryFileItem = repositoryFileItemMap.get(id);
} else if (repositoryLinkRulesItemMap.containsKey(id)) {
linkItem = repositoryLinkRulesItemMap.get(id);
} else {
if (!repositoryFileItemMap.isEmpty()) {
repositoryFileItem = repositoryFileItemMap.values().iterator().next();
} else {
repositoryFileItem = null;
}
}
if (repositoryFileItem == null && item instanceof FileItem) {
repositoryFileItem = (FileItem) item;
}
if (repositoryFileItem != null) {
CompoundCommand compoundCommand = new CompoundCommand();
final String showId = repositoryFileItem.getProperty().getId();
Command command = new PropertyChangeCommand(elem, EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), showId);
compoundCommand.add(command);
return compoundCommand;
}
if (linkItem != null) {
CompoundCommand compoundCommand = new CompoundCommand();
final String showId = linkItem.getProperty().getId();
Command command = new PropertyChangeCommand(elem, EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), showId);
compoundCommand.add(command);
return compoundCommand;
}
}
} else {
// 1. open wizard
if (elem instanceof INode) {
INode node = (INode) elem;
final IRepositoryService repositoryService = CorePlugin.getDefault().getRepositoryService();
if (param != null) {
RepositoryNode realNode = null;
String repositoryValue = param.getRepositoryValue();
if (repositoryValue != null && repositoryValue.startsWith(ERepositoryCategoryType.DATABASE.getName())) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_CONNECTIONS);
} else // file delimited
if (ERepositoryCategoryType.DELIMITED.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_DELIMITED);
}
// file positional
if (ERepositoryCategoryType.POSITIONAL.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_POSITIONAL);
}
// file regexp
if (ERepositoryCategoryType.REGEX.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_REGEXP);
}
// file xml
if (ERepositoryCategoryType.XML.getName().equals(repositoryValue) || // bug 18012
repositoryValue.startsWith(ERepositoryCategoryType.XML.getName())) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_XML);
}
// file ldif
if (ERepositoryCategoryType.LDIF.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_LDIF);
}
// excel
if (ERepositoryCategoryType.EXCEL.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_EXCEL);
}
// generic schema
if (ERepositoryCategoryType.GENERIC.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_GENERIC_SCHEMA);
}
// ldap
if (ERepositoryCategoryType.LDAP.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_LDAP_SCHEMA);
}
// wsdl
if (ERepositoryCategoryType.WSDL.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_WSDL_SCHEMA);
}
if (ERepositoryCategoryType.WEBSERVICE.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_WSDL_SCHEMA);
}
// salesforce
if (ERepositoryCategoryType.SALESFORCE.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA);
}
// ebcdic
if (ERepositoryCategoryType.EBCDIC.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_EBCDIC);
}
// mdm
if (ERepositoryCategoryType.MDM.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_MDMCONNECTION);
}
// sap
if (ERepositoryCategoryType.SAP.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_SAPCONNECTIONS);
}
// sapIDoc
if (ERepositoryCategoryType.SAPIDOC.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_SAP_IDOC);
}
if (ERepositoryCategoryType.HEADERFOOTER.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_HEADER_FOOTER);
}
// brms
if (ERepositoryCategoryType.BRMS.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_BRMS);
}
// hl7
if (ERepositoryCategoryType.HL7.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_HL7);
}
// last resort we assume that the repository value was named after the root component type key
if (realNode == null) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.getTypeFromKey(repositoryValue));
}
if (realNode != null) {
final IMetadataService metadataService = CorePlugin.getDefault().getMetadataService();
if (metadataService != null) {
ConnectionItem connItem = metadataService.openMetadataConnection(true, realNode, node);
if (connItem != null) {
IElementParameter propertyParam = elem.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
// 2. commnd
Command cmd = new ChangeValuesFromRepository(node, connItem.getConnection(), //$NON-NLS-1$
propertyParam.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), connItem.getProperty().getId());
executeCommand(cmd);
// see bug in feature 5998.refresh repositoryList.
if (dynamicProperty instanceof MultipleThreadDynamicComposite) {
((MultipleThreadDynamicComposite) dynamicProperty).updateRepositoryList();
}
}
}
}
}
}
}
return null;
}
Aggregations