use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.
the class TalendEditorComponentCreationAssist method acceptProposal.
/**
* create component at current position, according to select proposal label DOC talend2 Comment method
* "createComponent".
*
* @param componentName
* @param location
*/
protected void acceptProposal() {
String componentName = assistText.getText().trim();
Iterator<IContentProposal> iter = proposalList.iterator();
IComponent component = null;
while (iter.hasNext()) {
IContentProposal proposal = iter.next();
if (proposal instanceof ComponentContentProposal && componentName.equals(proposal.getLabel())) {
component = ((ComponentContentProposal) proposal).getComponent();
break;
}
}
acceptProposal(component);
}
use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.
the class TalendEditorComponentLabelProvider method getImage.
/*
* return the icon of each proposal(non-Javadoc)
*
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
*/
@Override
public Image getImage(Object element) {
if (element != null && element instanceof ComponentContentProposal) {
ComponentContentProposal proposal = (ComponentContentProposal) element;
IComponent iComponent = proposal.getComponent();
if (iComponent != null && iComponent.getIcon16() != null) {
return CoreImageProvider.getComponentImageFromDesc(iComponent.getIcon16());
}
}
return super.getImage(element);
}
use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.
the class AbstractComponent method equals.
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof IComponent)) {
return false;
}
final IComponent other = (IComponent) obj;
String thisName = this.getName();
String otherName = other.getName();
if (thisName == null) {
if (otherName != null) {
return false;
}
} else if (!thisName.equals(otherName)) {
return false;
} else if (paletteType == null) {
if (other.getPaletteType() != null) {
return false;
}
} else if (!paletteType.equals(other.getPaletteType())) {
return false;
}
return true;
}
use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.
the class ComponentSettingsView method createDynamicComposite.
/**
* yzhang Comment method "createDynamicComposite".
*
* @param parent
* @param element
* @param category
*/
private void createDynamicComposite(final Composite parent, Element element, EComponentCategory category) {
// DynamicComposite dc = null;
getParentMap().put(ComponentSettingsView.PARENT, parent);
getCategoryMap().put(ComponentSettingsView.CATEGORY, category);
if (element instanceof Node) {
IComponent component = ((Node) element).getComponent();
IGenericWizardService wizardService = null;
boolean generic = false;
if (EComponentType.GENERIC.equals(component.getComponentType())) {
generic = true;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
wizardService = (IGenericWizardService) GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
}
}
tabFactory.getTabbedPropertyComposite().setCompactViewVisible(false);
if (category == EComponentCategory.BASIC) {
// getElementMap().put(ComponentSettingsView.ELEMENT, element);
createButtonListener();
boolean isCompactView = true;
if (ComponentSettingsView.TABLEVIEW.equals(getPreference().getString(TalendDesignerPrefConstants.VIEW_OPTIONS))) {
isCompactView = false;
}
tabFactory.getTabbedPropertyComposite().setCompactViewVisible(true);
tabFactory.getTabbedPropertyComposite().setCompactView(isCompactView);
// Generic
if (generic && wizardService != null) {
Composite composite = wizardService.creatDynamicComposite(parent, element, EComponentCategory.BASIC, true);
if (composite instanceof MultipleThreadDynamicComposite) {
dc = (MultipleThreadDynamicComposite) composite;
}
} else {
dc = new MissingSettingsMultiThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, isCompactView);
}
} else if (category == EComponentCategory.DYNAMICS_SETTINGS) {
dc = new AdvancedContextComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, element);
} else if (category == EComponentCategory.SQL_PATTERN) {
dc = new SQLPatternComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, element);
} else if (category == EComponentCategory.ADVANCED) {
dc = new MissingSettingsMultiThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, true);
// Generic
if (generic && wizardService != null) {
Composite composite = wizardService.creatDynamicComposite(parent, element, EComponentCategory.ADVANCED, true);
if (composite instanceof MultipleThreadDynamicComposite) {
dc = (MultipleThreadDynamicComposite) composite;
}
}
} else {
dc = new MultipleThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, true);
}
} else if (element instanceof Connection) {
dc = new MainConnectionComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element);
} else if (element instanceof Note) {
if (category == EComponentCategory.BASIC) {
if (parent.getLayout() instanceof FillLayout) {
FillLayout layout = (FillLayout) parent.getLayout();
layout.type = SWT.VERTICAL;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.spacing = 0;
}
ScrolledComposite scrolled = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
scrolled.setExpandHorizontal(true);
scrolled.setExpandVertical(true);
scrolled.setMinWidth(600);
scrolled.setMinHeight(400);
Composite composite = tabFactory.getWidgetFactory().createComposite(scrolled);
scrolled.setContent(composite);
composite.setLayout(new FormLayout());
FormData d = new FormData();
d.left = new FormAttachment(0, 0);
d.right = new FormAttachment(100, 0);
d.top = new FormAttachment(0, 0);
d.bottom = new FormAttachment(100, 0);
composite.setLayoutData(d);
AbstractNotePropertyComposite c1 = new BasicNotePropertyComposite(composite, (Note) element, tabFactory);
// AbstractNotePropertyComposite c2 = new TextNotePropertyComposite(composite, (Note) element,
// tabFactory);
// FormData data = new FormData();
// data.top = new FormAttachment(c1.getComposite(), 20, SWT.DOWN);
// data.left = new FormAttachment(0, 0);
// data.right = new FormAttachment(100, 0);
// c2.getComposite().setLayoutData(data);
parent.layout();
}
} else if (element instanceof SubjobContainer) {
if (category == EComponentCategory.BASIC) {
dc = new SubjobBasicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, element);
}
} else {
tabFactory.getTabbedPropertyComposite().setCompactViewVisible(false);
dc = new MultipleThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, true);
}
if (parent.getChildren().length == 0) {
if (parent.getLayout() instanceof FillLayout) {
FillLayout layout = (FillLayout) parent.getLayout();
layout.type = SWT.VERTICAL;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.spacing = 0;
}
Composite composite = tabFactory.getWidgetFactory().createComposite(parent);
composite.setLayout(new FormLayout());
FormData d = new FormData();
d.left = new FormAttachment(2, 0);
d.right = new FormAttachment(100, 0);
d.top = new FormAttachment(5, 0);
d.bottom = new FormAttachment(100, 0);
composite.setLayoutData(d);
Label alertText = new Label(composite, SWT.NONE);
//$NON-NLS-1$
alertText.setText(Messages.getString("ComponentSettingsView.noAdvancedSetting"));
alertText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
parent.layout();
}
if (dc != null) {
dc.refresh();
}
}
use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.
the class StatsAndLogsManager method getStatsAndLogsNodes.
public static List<DataNode> getStatsAndLogsNodes(IProcess process) {
List<DataNode> nodeList = new ArrayList<DataNode>();
String dbOutput = null;
boolean dbFlag = ((Boolean) process.getElementParameter(EParameterName.ON_DATABASE_FLAG.getName()).getValue()) && process.getElementParameter(EParameterName.ON_DATABASE_FLAG.getName()).isShow(process.getElementParameters());
if (!dbFlag) {
dbOutput = null;
} else {
dbOutput = (String) process.getElementParameter(EParameterName.DB_TYPE.getName()).getValue();
dbOutput = OracleComponentHelper.filterOracleComponentName(dbOutput);
if (dbOutput == null || dbOutput.equals("")) {
//$NON-NLS-1$
dbOutput = null;
dbFlag = false;
}
}
boolean file = ((Boolean) process.getElementParameter(EParameterName.ON_FILES_FLAG.getName()).getValue()) && process.getElementParameter(EParameterName.ON_FILES_FLAG.getName()).isShow(process.getElementParameters());
boolean console = ((Boolean) process.getElementParameter(EParameterName.ON_CONSOLE_FLAG.getName()).getValue()) && process.getElementParameter(EParameterName.ON_CONSOLE_FLAG.getName()).isShow(process.getElementParameters());
if (!file && !dbFlag && !console) {
return nodeList;
}
boolean useStats = ((Boolean) process.getElementParameter(EParameterName.ON_STATCATCHER_FLAG.getName()).getValue()) && process.getElementParameter(EParameterName.ON_STATCATCHER_FLAG.getName()).isShow(process.getElementParameters());
boolean useLogs = ((Boolean) process.getElementParameter(EParameterName.ON_LOGCATCHER_FLAG.getName()).getValue()) && process.getElementParameter(EParameterName.ON_LOGCATCHER_FLAG.getName()).isShow(process.getElementParameters());
boolean useMetter = ((Boolean) process.getElementParameter(EParameterName.ON_METERCATCHER_FLAG.getName()).getValue()) && process.getElementParameter(EParameterName.ON_METERCATCHER_FLAG.getName()).isShow(process.getElementParameters());
String basePath = (String) process.getElementParameter(EParameterName.FILE_PATH.getName()).getValue();
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
basePath = basePath.replace("\\", "/") + "+ \"/\" +";
DataNode connectionNode = null;
// String connectionUID = "connectionStatsLogs";//$NON-NLS-1$
DataNode commitNode = null;
String connectionUID2;
IComponent commitComponent = null;
String subString = null;
/*
* maybe, need create every of committing node for log/stat/metter.
*/
// for bug 10453
boolean isNotInformixDB = true;
if (dbFlag) {
String[] javaDbComponents = StatsAndLogsConstants.DB_OUTPUT_COMPONENTS;
for (String dbComponent : javaDbComponents) {
String commitComponentName = null;
if (OracleComponentHelper.filterOracleConnectionType((String) process.getElementParameter(EParameterName.DB_TYPE.getName()).getValue()).equals(dbComponent)) {
if (dbComponent.endsWith("Output")) {
//$NON-NLS-1$
//$NON-NLS-1$
subString = dbComponent.substring(0, dbComponent.lastIndexOf("Output"));
//$NON-NLS-1$
commitComponentName = subString + "Commit";
} else {
//$NON-NLS-1$
commitComponentName = "tOracleCommit";
}
commitComponent = ComponentsFactoryProvider.getInstance().get(commitComponentName, ComponentCategory.CATEGORY_4_DI.getName());
if (commitComponentName.indexOf("Informix") != -1) {
isNotInformixDB = false;
}
if (commitComponent != null) {
//$NON-NLS-1$
connectionUID2 = CONNECTION_UID + "_Commit";
commitNode = new DataNode(commitComponent, connectionUID2);
commitNode.setSubProcessStart(true);
commitNode.setActivate(true);
commitNode.getElementParameter(EParameterName.CONNECTION.getName()).setValue(CONNECTION_UID);
IElementParameter elementParameter = commitNode.getElementParameter("CLOSE");
if (elementParameter != null) {
elementParameter.setValue(Boolean.FALSE);
}
commitNode.setProcess(process);
nodeList.add(commitNode);
}
}
}
}
if (useLogs) {
DataNode logsNode = createLogsNode(file, console, dbOutput);
if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.PERL)) {
//$NON-NLS-1$
logsNode.getElementParameter("FILENAME").setValue(//$NON-NLS-1$ //$NON-NLS-2$
"File::Spec->catfile(" + basePath + "," + process.getElementParameter(EParameterName.FILENAME_LOGS.getName()).getValue() + //$NON-NLS-1$
")");
} else {
//$NON-NLS-1$
logsNode.getElementParameter("FILENAME").setValue(basePath + process.getElementParameter(EParameterName.FILENAME_LOGS.getName()).getValue());
}
if (dbFlag) {
if (commitNode != null && isNotInformixDB) {
connectionNode = addConnection(connectionNode, process, CONNECTION_UID, logsNode, nodeList, commitNode);
} else {
useNoConnectionComponentDB(logsNode, process, CONNECTION_UID);
}
//$NON-NLS-1$
logsNode.getElementParameter("TABLE").setValue(process.getElementParameter(EParameterName.TABLE_LOGS.getName()).getValue());
}
if (file) {
IElementParameter encodingParameter = process.getElementParameter(EParameterName.ENCODING.getName());
if (encodingParameter != null) {
Object value = encodingParameter.getValue();
if (value != null && !"".equals(value)) {
IElementParameter elementParameter = logsNode.getElementParameter(EParameterName.ENCODING.getName());
if (elementParameter != null) {
String encoding = value.toString();
if (!value.toString().startsWith(TalendTextUtils.getQuoteChar())) {
encoding = TalendTextUtils.addQuotes(encoding);
}
elementParameter.setValue(encoding);
}
}
}
}
logsNode.getElementParameter(EParameterName.CATCH_RUNTIME_ERRORS.getName()).setValue(process.getElementParameter(EParameterName.CATCH_RUNTIME_ERRORS.getName()).getValue());
logsNode.getElementParameter(EParameterName.CATCH_USER_ERRORS.getName()).setValue(process.getElementParameter(EParameterName.CATCH_USER_ERRORS.getName()).getValue());
logsNode.getElementParameter(EParameterName.CATCH_USER_WARNING.getName()).setValue(process.getElementParameter(EParameterName.CATCH_USER_WARNING.getName()).getValue());
logsNode.setProcess(process);
nodeList.add(logsNode);
}
if (useStats) {
DataNode statsNode = createStatsNode(file, console, dbOutput);
if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.PERL)) {
//$NON-NLS-1$
statsNode.getElementParameter("FILENAME").setValue(//$NON-NLS-1$ //$NON-NLS-2$
"File::Spec->catfile(" + basePath + "," + process.getElementParameter(EParameterName.FILENAME_STATS.getName()).getValue() + //$NON-NLS-1$
")");
} else {
//$NON-NLS-1$
statsNode.getElementParameter("FILENAME").setValue(basePath + process.getElementParameter(EParameterName.FILENAME_STATS.getName()).getValue());
}
if (dbFlag) {
if (commitNode != null && isNotInformixDB) {
connectionNode = addConnection(connectionNode, process, CONNECTION_UID, statsNode, nodeList, commitNode);
} else {
useNoConnectionComponentDB(statsNode, process, CONNECTION_UID);
}
//$NON-NLS-1$
statsNode.getElementParameter("TABLE").setValue(process.getElementParameter(EParameterName.TABLE_STATS.getName()).getValue());
}
if (file) {
IElementParameter encodingParameter = process.getElementParameter(EParameterName.ENCODING.getName());
if (encodingParameter != null) {
Object value = encodingParameter.getValue();
if (value != null && !"".equals(value)) {
IElementParameter elementParameter = statsNode.getElementParameter(EParameterName.ENCODING.getName());
if (elementParameter != null) {
String encoding = value.toString();
if (!value.toString().startsWith(TalendTextUtils.getQuoteChar())) {
encoding = TalendTextUtils.addQuotes(encoding);
}
elementParameter.setValue(encoding);
}
}
}
}
statsNode.setProcess(process);
nodeList.add(statsNode);
}
if (useMetter) {
DataNode meterNode = createMetterNode(file, console, dbOutput);
if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.PERL)) {
//$NON-NLS-1$
meterNode.getElementParameter("FILENAME").setValue(//$NON-NLS-1$ //$NON-NLS-2$
"File::Spec->catfile(" + basePath + "," + process.getElementParameter(EParameterName.FILENAME_METTER.getName()).getValue() + //$NON-NLS-1$
")");
} else {
//$NON-NLS-1$
meterNode.getElementParameter("FILENAME").setValue(basePath + process.getElementParameter(EParameterName.FILENAME_METTER.getName()).getValue());
}
if (dbFlag) {
if (commitNode != null && isNotInformixDB) {
connectionNode = addConnection(connectionNode, process, CONNECTION_UID, meterNode, nodeList, commitNode);
} else {
useNoConnectionComponentDB(meterNode, process, CONNECTION_UID);
}
//$NON-NLS-1$
meterNode.getElementParameter("TABLE").setValue(process.getElementParameter(EParameterName.TABLE_METER.getName()).getValue());
}
if (file) {
IElementParameter encodingParameter = process.getElementParameter(EParameterName.ENCODING.getName());
if (encodingParameter != null) {
Object value = encodingParameter.getValue();
if (value != null && !"".equals(value)) {
IElementParameter elementParameter = meterNode.getElementParameter(EParameterName.ENCODING.getName());
if (elementParameter != null) {
String encoding = value.toString();
if (!value.toString().startsWith(TalendTextUtils.getQuoteChar())) {
encoding = TalendTextUtils.addQuotes(encoding);
}
elementParameter.setValue(encoding);
}
}
}
}
meterNode.setProcess(process);
nodeList.add(meterNode);
}
return nodeList;
}
Aggregations