use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.
the class DownloadComponenentsAction method confirmInstallation.
private void confirmInstallation() {
IComponent emfcomponent = null;
FileFilter propertiesFilter = new FileFilter() {
// gcui:search xml file.
@Override
public boolean accept(File file) {
//$NON-NLS-1$
return file.getName().endsWith("_java.xml");
}
};
String location = getComponentsFolder().getAbsolutePath();
File folder = ExchangeComponentsProvider.searchComponentFolder(new File(location));
File[] files = folder.listFiles(propertiesFilter);
if (files == null || files.length == 0) {
return;
}
IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
emfcomponent = componentsFactory.get(files[0].getParentFile().getName());
if (emfcomponent == null) {
return;
}
String componentName = null;
StringBuilder message = new StringBuilder();
String name = null;
String family = null;
if (emfcomponent != null) {
name = emfcomponent.getName();
family = emfcomponent.getOriginalFamilyName();
}
//String family = prop.getProperty("FAMILY"); //$NON-NLS-1$
if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(family)) {
componentName = name;
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
message.append("Component ").append(name).append(" installed at ").append(family).append(".\n");
}
if (componentName != null) {
// see 0005051: [exchange view] select component in the palette once component is installed
selectPaletteEntry(componentName);
}
MessageDialog.openInformation(null, Messages.getString("DownloadComponenentsAction.installExchange"), //$NON-NLS-1$ //$NON-NLS-2$
Messages.getString("ExchangeWebService.downloadingExtensionSuccessful"));
ComponentManager.saveResource();
}
use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.
the class JobSettingsManager method createExtraContextLoadNodes.
public static List<DataNode> createExtraContextLoadNodes(IProcess process) {
List<DataNode> nodeList = new ArrayList<DataNode>();
String paramName = EParameterName.IMPLICIT_TCONTEXTLOAD.getName();
boolean useContextLoad = ((Boolean) process.getElementParameter(paramName).getValue()) && process.getElementParameter(paramName).isShow(process.getElementParameters());
if (!useContextLoad) {
// not used
return Collections.emptyList();
}
// file
paramName = JobSettingsConstants.getExtraParameterName(EParameterName.FROM_FILE_FLAG.getName());
boolean fileFlag = ((Boolean) process.getElementParameter(paramName).getValue()) && process.getElementParameter(paramName).isShow(process.getElementParameters());
// db
String dbInput = null;
paramName = JobSettingsConstants.getExtraParameterName(EParameterName.FROM_DATABASE_FLAG.getName());
boolean dbFlag = ((Boolean) process.getElementParameter(paramName).getValue()) && process.getElementParameter(paramName).isShow(process.getElementParameters());
if (!dbFlag) {
dbInput = null;
} else {
dbInput = (String) process.getElementParameter(JobSettingsConstants.getExtraParameterName(EParameterName.DB_TYPE.getName())).getValue();
dbInput = OracleComponentHelper.filterOracleComponentName(dbInput);
if (dbInput == null || dbInput.equals("")) {
//$NON-NLS-1$
dbInput = null;
dbFlag = false;
}
}
if (!fileFlag && !dbFlag) {
// not used
return Collections.emptyList();
}
IComponent tContextLoadComponent = new JobContextLoadComponent(fileFlag, dbInput);
//$NON-NLS-1$
final String uniqueName = "Implicit_Context";
DataNode tContextLoadNode = new DataNode(tContextLoadComponent, uniqueName);
tContextLoadNode.setStart(true);
tContextLoadNode.setSubProcessStart(true);
tContextLoadNode.setActivate(true);
IMetadataTable table = getSchemaTablefromComponent(JobContextLoadComponent.CONTEXTLOAD_COMPONENT, uniqueName);
if (table != null) {
tContextLoadNode.getMetadataList().clear();
tContextLoadNode.getMetadataList().add(table);
}
// set parameters
IElementParameter param = null;
if (fileFlag) {
// is file
String inputFile = (String) process.getElementParameter(EParameterName.IMPLICIT_TCONTEXTLOAD_FILE.getName()).getValue();
String fileSparator = (String) process.getElementParameter(EParameterName.FIELDSEPARATOR.getName()).getValue();
tContextLoadNode.getElementParameter(EParameterName.IMPLICIT_TCONTEXTLOAD_FILE.getName()).setValue(inputFile);
String regex = FileSeparator.getSeparatorsRegexp(TalendQuoteUtils.removeQuotes(fileSparator));
tContextLoadNode.getElementParameter(JobSettingsConstants.IMPLICIT_TCONTEXTLOAD_REGEX).setValue(regex);
} else {
// is db
paramName = JobSettingsConstants.getExtraParameterName(EParameterName.URL.getName());
param = process.getElementParameter(paramName);
if (param != null) {
tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
}
paramName = JobSettingsConstants.getExtraParameterName(EParameterName.DRIVER_JAR.getName());
param = process.getElementParameter(paramName);
if (param != null) {
tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
}
paramName = JobSettingsConstants.getExtraParameterName(EParameterName.DRIVER_CLASS.getName());
param = process.getElementParameter(paramName);
if (param != null) {
tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
}
paramName = JobSettingsConstants.getExtraParameterName(EParameterName.HOST.getName());
tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
paramName = JobSettingsConstants.getExtraParameterName(EParameterName.PORT.getName());
tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
paramName = JobSettingsConstants.getExtraParameterName(EParameterName.DBNAME.getName());
tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
paramName = JobSettingsConstants.getExtraParameterName(EParameterName.DB_VERSION.getName());
tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
paramName = JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTIES.getName());
param = process.getElementParameter(paramName);
if (param != null) {
tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
}
paramName = JobSettingsConstants.getExtraParameterName(EParameterName.SCHEMA_DB.getName());
param = process.getElementParameter(paramName);
if (param != null) {
tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
}
String schema = (String) process.getElementParameter(paramName).getValue();
if (schema != null) {
schema = TalendTextUtils.removeQuotes(schema);
}
paramName = JobSettingsConstants.getExtraParameterName(EParameterName.USER.getName());
tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
paramName = JobSettingsConstants.getExtraParameterName(EParameterName.PASS.getName());
tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
paramName = JobSettingsConstants.getExtraParameterName(EParameterName.CONNECTION_TYPE.getName());
tContextLoadNode.getElementParameter(paramName).setValue(OracleComponentHelper.filterOracleConnectionType((String) process.getElementParameter(JobSettingsConstants.getExtraParameterName(EParameterName.DB_TYPE.getName())).getValue()));
paramName = JobSettingsConstants.getExtraParameterName(EParameterName.DBTABLE.getName());
tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
// query
String dbTableName = (String) process.getElementParameter(paramName).getValue();
String realTableName = getCurrentTableName(dbTableName);
if (realTableName == null) {
realTableName = QueryUtil.DEFAULT_TABLE_NAME;
}
String dbType = getDatabaseTypeFromParameter(process);
if (dbType != null) {
// TDI-18161:the SQL script's syntax is not right because of the implicit context of General JDBC.
if (dbType.equals(EDatabaseTypeName.GENERAL_JDBC.getDisplayName())) {
dbType = findRealDbTypeForJDBC(process, dbType);
}
EDatabaseTypeName dbTypeName = EDatabaseTypeName.getTypeFromDbType(dbType);
if (EDatabaseTypeName.ORACLE_OCI.equals(dbTypeName) || EDatabaseTypeName.ORACLEFORSID.equals(dbTypeName) || EDatabaseTypeName.ORACLESN.equals(dbTypeName)) {
for (IMetadataColumn column : table.getListColumns()) {
column.setOriginalDbColumnName(column.getOriginalDbColumnName().toUpperCase());
}
}
if (realTableName.startsWith(TalendTextUtils.QUOTATION_MARK) && realTableName.endsWith(TalendTextUtils.QUOTATION_MARK) && realTableName.length() > 2) {
realTableName = realTableName.substring(1, realTableName.length() - 1);
}
String query = TalendTextUtils.addSQLQuotes(QueryUtil.generateNewQuery(null, table, dbType, schema, realTableName));
paramName = JobSettingsConstants.getExtraParameterName(EParameterName.QUERY_CONDITION.getName());
String conditionStatement = (String) process.getElementParameter(paramName).getValue();
if (conditionStatement != null) {
String tmp = TalendTextUtils.removeQuotes(conditionStatement);
if (!"".equals(tmp)) {
//$NON-NLS-1$
//$NON-NLS-1$
query = query + CONNECTOR + QUOTE + " WHERE " + QUOTE + CONNECTOR + conditionStatement;
}
}
final String quoteByDBType = TalendTextUtils.getQuoteByDBType(dbType, false);
if (dbTypeName == EDatabaseTypeName.MSSQL) {
query = //$NON-NLS-1$
query.replaceAll(//$NON-NLS-1$
"(?i)\bkey\b", //$NON-NLS-1$ //$NON-NLS-2$
"\\\\" + quoteByDBType + "key\\\\" + quoteByDBType);
}
tContextLoadNode.getElementParameter(JobSettingsConstants.QUERY).setValue(query);
}
}
// tContextLoad
paramName = EParameterName.LOAD_NEW_VARIABLE.getName();
param = process.getElementParameter(paramName);
if (param != null) {
tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
}
paramName = EParameterName.NOT_LOAD_OLD_VARIABLE.getName();
param = process.getElementParameter(paramName);
if (param != null) {
tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
}
paramName = EParameterName.PRINT_OPERATIONS.getName();
tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
paramName = EParameterName.DISABLE_ERROR.getName();
param = process.getElementParameter(paramName);
if (param != null) {
tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
}
paramName = EParameterName.DISABLE_INFO.getName();
param = process.getElementParameter(paramName);
if (param != null) {
tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
}
paramName = EParameterName.DISABLE_WARNINGS.getName();
tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
tContextLoadNode.setProcess(process);
nodeList.add(tContextLoadNode);
return nodeList;
}
use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.
the class FOXMain method createUI.
/**
* qzhang Comment method "createUI".
*
* @param display
* @return
*/
public Shell createUI(Display display) {
Shell shell = new Shell(display, SWT.APPLICATION_MODAL | SWT.BORDER | SWT.RESIZE | SWT.CLOSE | SWT.MIN | SWT.MAX | SWT.TITLE);
IComponent component = connector.getComponent();
Image createImage = CoreImageProvider.getComponentIcon(component, ICON_SIZE.ICON_32);
shell.setImage(createImage);
shell.setText(connector.getUniqueName());
Rectangle boundsRG = new Rectangle(50, 50, 800, 600);
shell.setBounds(boundsRG);
createUI(shell);
if (!shell.isDisposed()) {
shell.open();
}
return shell;
}
use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.
the class RowGenMain method createUI.
/**
* qzhang Comment method "createUI".
*
* @param display
* @return
*/
public Shell createUI(Display display) {
Shell shell = new Shell(display, SWT.APPLICATION_MODAL | SWT.BORDER | SWT.RESIZE | SWT.CLOSE | SWT.MIN | SWT.MAX | SWT.TITLE);
IComponent component = connector.getComponent();
shell.setImage(CoreImageProvider.getComponentIcon(component, ICON_SIZE.ICON_32));
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
String productName = brandingService.getFullProductName();
//$NON-NLS-1$
shell.setText(Messages.getString("RowGenMain.ShellTitle", productName, connector.getUniqueName()));
Rectangle boundsRG = ExternalRowGeneratorUiProperties.getBoundsRowGen();
if (ExternalRowGeneratorUiProperties.isShellMaximized()) {
shell.setMaximized(ExternalRowGeneratorUiProperties.isShellMaximized());
} else {
boundsRG = ExternalRowGeneratorUiProperties.getBoundsRowGen();
if (boundsRG.x < 0) {
boundsRG.x = 0;
}
if (boundsRG.y < 0) {
boundsRG.y = 0;
}
shell.setBounds(boundsRG);
}
createUI(shell, false);
updateComponentsSize();
updateTableTitleColumn();
shell.open();
shell.addControlListener(new ControlListener() {
public void controlMoved(ControlEvent e) {
generatorUI.getDataTableView().attachLabelPosition();
}
public void controlResized(ControlEvent e) {
generatorUI.getDataTableView().attachLabelPosition();
generatorUI.getDataTableView().fixedLabelSize();
}
});
addAllControlForKeyListener(shell);
// shell.moveAbove(null);
generatorUI.getDataTableView().updateHeader(ExternalRowGeneratorUiProperties.getShowColumnsList());
return shell;
}
use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.
the class TalendEditorComponentCreationUtil method readComponentsInCategory.
/**
* read all components belongs to some category (DI, CAMEL etc.) then store it into a map which can be reused
*
* @param categoryName
* @param entries
*/
/*
* TODO this can be improved after refactoring org.talend.core.model.components.IComponentsHandler implementation in
* each editor
*/
private static void readComponentsInCategory(String categoryName, Map<String, IComponent> entries) {
IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
Set<IComponent> allComponents = componentsFactory.getComponents();
for (IComponent component : allComponents) {
String compType = component.getPaletteType();
if (!component.isTechnical() && compType != null && categoryName.equals(compType)) {
entries.put(component.getName(), component);
}
}
DummyComponent noteComponent = new DummyComponent("Note");
noteComponent.setIcon16(ImageProvider.getImageDesc(ECoreImage.CODE_ICON));
noteComponent.setOriginalFamilyName("Misc");
entries.put("Note", noteComponent);
}
Aggregations