use of org.talend.core.model.components.IComponentsFactory in project tdi-studio-se by Talend.
the class TalendEditorPaletteFactoryTest method testFullMatch.
@Test
public void testFullMatch() {
IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
String keyword = "tjava";
List<IComponent> componentHits = TalendEditorPaletteFactory.getRelatedComponents(componentsFactory, keyword);
/**
* NOTE: the expect result may change if we add/change some new components in someday
*/
assert (componentHits.get(0).getName().equals(TJAVA));
assert (1 < componentHits.size());
}
use of org.talend.core.model.components.IComponentsFactory in project tdi-studio-se by Talend.
the class TestComponentsAction method initialize.
public void initialize() {
Job job = new //$NON-NLS-1$
Job(//$NON-NLS-1$
"Component Test") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
// IProgressMonitor monitorWrap = new CodeGeneratorProgressMonitor(monitor);
//$NON-NLS-1$
monitor.beginTask("Component Test Running", 1100);
IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
Set<IComponent> components = componentsFactory.getComponents();
monitor.worked(100);
RepositoryContext repositoryContext = (RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
ECodeLanguage codeLanguage = repositoryContext.getProject().getLanguage();
String path = getPath();
// TODO
int taskTotal = components.size();
for (IComponent component : components) {
String templateURI = path + File.separatorChar + component.getName() + File.separatorChar + TestParameter.GENERATE_TEST;
File templateFile = new File(templateURI);
// System.out.println(templateFile + " " + templateFile.exists());
if (templateFile.exists()) {
File[] fileArray = getFile(templateFile, codeLanguage);
//$NON-NLS-1$ //$NON-NLS-2$
generateCode(fileArray, templateURI.replace("\\", "/"));
}
monitor.worked(1 * 1000 / taskTotal);
}
} catch (Exception e) {
//$NON-NLS-1$
log.error("Exception during test Initialization", e);
}
monitor.done();
return Status.OK_STATUS;
}
};
job.schedule();
}
use of org.talend.core.model.components.IComponentsFactory 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.IComponentsFactory in project tdi-studio-se by Talend.
the class JetSkeletonManager method updateSkeletonPersistenceData.
/**
* DOC xtan
* <p>
* check the skeleton file whether changed or not, and save the SkeletonUpdateCache file again.
* </p>
*
* @return true if there is one skeleton file changed.
*/
public static boolean updateSkeletonPersistenceData() {
boolean doUpdate = false;
JetSkeletonManager localInstance = JetSkeletonManager.getInstance();
localInstance.load();
IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
List<String> skeletons = new ArrayList<String>();
List<String> systemSkeletons = getSystemSkeletons();
List<String> componentSkeletons = componentsFactory.getSkeletons();
if (systemSkeletons != null && !systemSkeletons.isEmpty()) {
skeletons.addAll(systemSkeletons);
}
if (componentSkeletons != null && !componentSkeletons.isEmpty()) {
skeletons.addAll(componentSkeletons);
}
for (String jetSkeleton : skeletons) {
// System.out.println(jetSkeleton);
try {
File file = new File(jetSkeleton);
if (localInstance.checkAndUpdateCache(file)) {
doUpdate = true;
// System.out.println("need check:" + jetSkeleton);
}
} catch (Exception e) {
IStatus status = new Status(IStatus.WARNING, CodeGeneratorActivator.PLUGIN_ID, Messages.getString("JetSkeletonManager.updateProblem"), //$NON-NLS-1$
e);
CodeGeneratorActivator.getDefault().getLog().log(status);
localInstance.save();
return true;
}
}
localInstance.save();
return doUpdate;
}
use of org.talend.core.model.components.IComponentsFactory 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