use of org.talend.core.ui.component.TalendCreationToolEntry in project tdi-studio-se by Talend.
the class TalendEditorComponentProposalProvider method getProposals.
/**
* Return an array of Objects representing the valid content proposals for a field.
*
* @param contents the current contents of the field (only consulted if filtering is set to <code>true</code>)
* @param position the current cursor position within the field (ignored)
* @return the array of Objects that represent valid proposals for the field given its current content.
*/
@Override
public IContentProposal[] getProposals(String contents, int position) {
List<IComponent> relatedComponent = TalendEditorPaletteFactory.getRelatedComponents(componentsFactory, contents);
if (componentAssistant != null) {
relatedComponent = componentAssistant.filterComponents(relatedComponent);
}
proposalList.clear();
// add joblet components in joblet editor.
List<PaletteEntry> extraPaletteEntry = ComponentPaletteUtilities.getExtraPaletteEntry();
if (extraPaletteEntry != null) {
for (PaletteEntry entry : extraPaletteEntry) {
if (entry != null && entry.isVisible() && entry instanceof TalendCreationToolEntry) {
TalendCreationToolEntry tool = (TalendCreationToolEntry) entry;
CreationFactory creationFactory = tool.getFactory();
if (creationFactory != null && creationFactory instanceof PaletteComponentFactory) {
PaletteComponentFactory componentFactory = (PaletteComponentFactory) creationFactory;
proposalList.add(new ComponentContentProposal(componentFactory.getComponent()));
}
}
}
}
if (relatedComponent != null && !relatedComponent.isEmpty()) {
Iterator<IComponent> iter = relatedComponent.iterator();
while (iter.hasNext()) {
IComponent component = iter.next();
// proposalList.add(new ComponentContentProposal(component.getName(), component.getLongName(),
// component));
proposalList.add(new ComponentContentProposal(component));
}
}
/**
* Always add Note
*/
//$NON-NLS-1$
DummyComponent noteComponent = new DummyComponent("Note");
noteComponent.setIcon16(ImageProvider.getImageDesc(ECoreImage.NOTE_SMALL_ICON));
//$NON-NLS-1$
noteComponent.setOriginalFamilyName("Misc");
proposalList.add(new ComponentContentProposal(noteComponent));
return proposalList.toArray(new IContentProposal[0]);
}
Aggregations