use of org.osgi.framework.Bundle in project tdi-studio-se by Talend.
the class TosBrandingService method getLicenseFile.
@Override
public URL getLicenseFile() throws IOException {
final Bundle b = Platform.getBundle(Activator.PLUGIN_ID);
//$NON-NLS-1$
final URL url = FileLocator.toFileURL(FileLocator.find(b, new Path("resources/license.txt"), null));
return url;
}
use of org.osgi.framework.Bundle in project tdi-studio-se by Talend.
the class ImportDemoProjectItemsPage method getFullImagePath.
/**
* getFullImagePath.
*
* @param languageName
* @return
*/
private Image getFullImagePath(DemoProjectBean node) {
URL url = null;
String pluginPath = null;
String relatedImagePath = null;
Bundle bundle = null;
if (node != null) {
// ;
relatedImagePath = node.getIconUrl();
bundle = Platform.getBundle(node.getPluginId());
}
try {
if (FileLocator.find(bundle, new Path(relatedImagePath), null) != null) {
url = FileLocator.toFileURL(FileLocator.find(bundle, new Path(relatedImagePath), null));
pluginPath = new Path(url.getFile()).toOSString();
} else {
url = FileLocator.find(bundle, new Path(DEFAUTL_DEMO_ICON), null);
pluginPath = new Path(url.getFile()).toOSString();
}
} catch (IOException e1) {
// nothing to do
}
return new Image(null, pluginPath);
}
use of org.osgi.framework.Bundle in project tdi-studio-se by Talend.
the class BDJobReArchieveCreator method getLibPath.
/**
*
* maybe, should be same result with JobJavaScriptsManager.getLibPath
*/
public List<File> getLibPath(File zipTmpFolder, boolean isSpecialMR) {
List<File> neededLibFiles = new ArrayList<File>();
File libFolder = new File(zipTmpFolder, JavaUtils.JAVA_LIB_DIRECTORY);
Set<String> compiledModulesSet = new HashSet<String>(100);
Set<ModuleNeeded> neededModules = LastGenerationInfo.getInstance().getModulesNeededWithSubjobPerJob(processItem.getProperty().getId(), processItem.getProperty().getVersion());
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
IDesignerCoreService designerCoreService = (IDesignerCoreService) GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
IProcess process = designerCoreService.getProcessFromProcessItem(processItem);
compiledModulesSet.addAll(PomUtil.getCodesExportJars(process));
if (neededModules.isEmpty()) {
neededModules = process.getNeededModules(true);
}
}
for (ModuleNeeded module : neededModules) {
if (((isSpecialMR || isSparkWithHDInsight) && module.isMrRequired()) || (!isSpecialMR && !isSparkWithHDInsight)) {
compiledModulesSet.add(module.getModuleName());
}
}
Set<String> jarNames = new HashSet<String>();
try {
// from org.talend.libraries.apache.storm/lib
Bundle bundle = Platform.getBundle(PLUGIN_ID);
if (bundle != null) {
//$NON-NLS-1$
URL stormLibUrl = FileLocator.toFileURL(FileLocator.find(bundle, new Path("lib"), null));
if (stormLibUrl != null) {
File file = new File(stormLibUrl.getFile());
File[] jars = file.listFiles();
for (File f : jars) {
jarNames.add(f.getName());
}
}
}
} catch (IOException e) {
ExceptionHandler.process(e);
}
for (String jarName : compiledModulesSet) {
File jarFile = new File(libFolder, jarName);
if (jarFile.exists()) {
if (!isSpecialMR && !jarNames.isEmpty()) {
// for storm not include the jar from libraries.apache.strom
if (!jarNames.contains(jarName)) {
neededLibFiles.add(jarFile);
}
} else {
neededLibFiles.add(jarFile);
}
}
}
return neededLibFiles;
}
use of org.osgi.framework.Bundle in project tdi-studio-se by Talend.
the class DemoImportTestUtil method getResourceManager.
public static ResourcesManager getResourceManager(DemoProjectBean checkedProjectBean) {
ResourcesManager resManager = null;
try {
Bundle bundle = Platform.getBundle(checkedProjectBean.getPluginId());
URL demoURL = FileLocator.find(bundle, new Path(checkedProjectBean.getDemoProjectFilePath()), null);
demoURL = FileLocator.toFileURL(demoURL);
String filePath = new Path(demoURL.getFile()).toOSString();
File srcFile = new File(filePath);
FileResourcesUnityManager fileUnityManager = ResourcesManagerFactory.getInstance().createFileUnityManager(srcFile);
resManager = fileUnityManager.doUnify();
} catch (ZipException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (TarException e) {
e.printStackTrace();
}
return resManager;
}
use of org.osgi.framework.Bundle in project tdi-studio-se by Talend.
the class AutoConvertTypesUtilsTest method init.
@Before
public void init() throws Exception {
//$NON-NLS-1$
Bundle b = Platform.getBundle("org.talend.repository.test");
//$NON-NLS-1$
URL url = FileLocator.toFileURL(FileLocator.find(b, new Path("AutoConversionTypesTest.xml"), null));
Assert.assertNotNull(url);
testFile = new File(url.getPath());
Assert.assertTrue(testFile.exists());
//
AutoConversionType bean = new AutoConversionType();
bean.setSourceDataType(JavaTypesManager.getDefaultJavaType().getId());
bean.setTargetDataType(JavaTypesManager.INTEGER.getId());
//$NON-NLS-1$
bean.setConversionFunction("Integer.parseInt(${0})");
testBeanList.add(bean);
}
Aggregations