/** * Return the bundle directory. * * @param bundle the bundle * @return the bundle directory */ public String getBundleDirectory(Bundle bundle) { if (bundle == null) return null; // --- Get File URL of bundle --------------------- URL pluginURL = null; try { pluginURL = FileLocator.resolve(bundle.getEntry("/")); } catch (IOException e) { throw new RuntimeException("Could not get installation directory of the plugin: " + bundle.getSymbolicName()); } // --- Clean up the directory path ---------------- String pluginInstallDir = pluginURL.getFile().trim(); if (pluginInstallDir.length()==0) { throw new RuntimeException("Could not get installation directory of the plugin: " + bundle.getSymbolicName()); } // --- Corrections, if we are under windows ------- if (Platform.getOS().compareTo(Platform.OS_WIN32) == 0) { //pluginInstallDir = pluginInstallDir.substring(1); } return pluginInstallDir; }
public static ImageDescriptor createImageDescriptor(String path, String pluginId) { if (path == null) { /* fall back if path null , so avoid NPE in eclipse framework */ return ImageDescriptor.getMissingImageDescriptor(); } if (pluginId == null) { /* fall back if pluginId null , so avoid NPE in eclipse framework */ return ImageDescriptor.getMissingImageDescriptor(); } Bundle bundle = Platform.getBundle(pluginId); if (bundle == null) { /* * fall back if bundle not available, so avoid NPE in eclipse * framework */ return ImageDescriptor.getMissingImageDescriptor(); } URL url = FileLocator.find(bundle, new Path(path), null); ImageDescriptor imageDesc = ImageDescriptor.createFromURL(url); return imageDesc; }
private static String computeCamelLanguageServerJarPath() { String camelLanguageServerJarPath = ""; Bundle bundle = Platform.getBundle(ActivatorCamelLspClient.ID); URL fileURL = bundle.findEntries("/libs", "camel-lsp-server-*.jar", false).nextElement(); try { File file = new File(FileLocator.resolve(fileURL).toURI()); if(Platform.OS_WIN32.equals(Platform.getOS())) { camelLanguageServerJarPath = "\"" + file.getAbsolutePath() + "\""; } else { camelLanguageServerJarPath = file.getAbsolutePath(); } } catch (URISyntaxException | IOException exception) { ActivatorCamelLspClient.getInstance().getLog().log(new Status(IStatus.ERROR, ActivatorCamelLspClient.ID, "Cannot get the Camel LSP Server jar.", exception)); //$NON-NLS-1$ } return camelLanguageServerJarPath; }
/** * Check that referenced element type are in the registry */ @Test public void checkMenuNewChildElementTypeIdRefs() { URI createPlatformPluginURI = URI.createPlatformPluginURI(NEW_CHILD_MENU_PATH, true); ResourceSetImpl resourceSetImpl = new ResourceSetImpl(); Resource resource = resourceSetImpl.getResource(createPlatformPluginURI, true); TreeIterator<EObject> allContents = resource.getAllContents(); while (allContents.hasNext()) { EObject eObject = (EObject) allContents.next(); if (eObject instanceof CreationMenu) { String iconPath = ((CreationMenu) eObject).getIcon(); if (iconPath != null && !"".equals(iconPath)){ try { Assert.assertNotNull("The icon "+iconPath+" can't be found", FileLocator.find(new URL(iconPath))); } catch (MalformedURLException e) { Assert.fail("The new child menu is refering to a malformed url "+iconPath); } } } } }
public DerbyClasspathContainer() { List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>(); Bundle bundle = Platform.getBundle(CommonNames.CORE_PATH); Enumeration en = bundle.findEntries("/", "*.jar", true); String rootPath = null; try { rootPath = FileLocator.resolve(FileLocator.find(bundle, new Path("/"), null)).getPath(); } catch(IOException e) { Logger.log(e.getMessage(), IStatus.ERROR); } while(en.hasMoreElements()) { IClasspathEntry cpe = JavaCore.newLibraryEntry(new Path(rootPath+'/'+((URL)en.nextElement()).getFile()), null, null); entries.add(cpe); } IClasspathEntry[] cpes = new IClasspathEntry[entries.size()]; _entries = (IClasspathEntry[])entries.toArray(cpes); }
/** * <p> * Creates the sole wizard page contributed by this base implementation; the * standard Eclipse WizardNewProjectCreationPage. * </p> * * @see WizardNewProjectCreationPage#WizardNewProjectCreationPage(String) */ public void init(IWorkbench workbench, IStructuredSelection selection) { // Set default image for all wizard pages IPath path = new Path(de.darwinspl.preferences.resource.dwprofile.ui.DwprofileUIResourceBundle.NEW_PROJECT_WIZARD_PAGE_ICON); Bundle bundle = de.darwinspl.preferences.resource.dwprofile.ui.DwprofileUIPlugin.getDefault().getBundle(); URL url = FileLocator.find(bundle, path, null); ImageDescriptor descriptor = ImageDescriptor.createFromURL(url); setDefaultPageImageDescriptor(descriptor); wizardNewProjectCreationPage = new WizardNewProjectCreationPage(pageName); wizardNewProjectCreationPage.setTitle(pageTitle); wizardNewProjectCreationPage.setDescription(pageDescription); wizardNewProjectCreationPage.setInitialProjectName(pageProjectName); this.addPage(wizardNewProjectCreationPage); setWindowTitle(de.darwinspl.preferences.resource.dwprofile.ui.DwprofileUIResourceBundle.NEW_PROJECT_WIZARD_WINDOW_TITLE); }
/** * <p> * Unzip the project archive to the specified folder * </p> * * @param projectFolderFile The folder where to unzip the project archive * @param monitor Monitor to display progress and/or cancel operation * * @throws IOException * * @throws InterruptedException * * @throws FileNotFoundException */ private void extractProject(File projectFolderFile, URL url, IProgressMonitor monitor) throws FileNotFoundException, IOException, InterruptedException { // Get project archive URL urlZipLocal = FileLocator.toFileURL(url); // Walk each element and unzip ZipFile zipFile = new ZipFile(urlZipLocal.getPath()); try { // Allow for a hundred work units monitor.beginTask("Extracting Project", zipFile.size()); unzip(zipFile, projectFolderFile, monitor); } finally { zipFile.close(); monitor.done(); } }
/** * <p> * Returns the image for the given key. Possible keys are: * </p> * <p> * <ul> * </p> * <p> * <li>platform:/plugin/your.plugin/icons/yourIcon.png</li> * </p> * <p> * <li>bundleentry://557.fwk3560063/icons/yourIcon.png</li> * </p> * <p> * </ul> * </p> */ public ImageDescriptor getImageDescriptor(String key) { IPath path = new Path(key); de.darwinspl.preferences.resource.dwprofile.ui.DwprofileUIPlugin plugin = de.darwinspl.preferences.resource.dwprofile.ui.DwprofileUIPlugin.getDefault(); if (plugin == null) { return null; } ImageDescriptor descriptor = ImageDescriptor.createFromURL(FileLocator.find(plugin.getBundle(), path, null)); if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) { // try loading image from any bundle try { URL pluginUrl = new URL(key); descriptor = ImageDescriptor.createFromURL(pluginUrl); if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) { return null; } } catch (MalformedURLException mue) { de.darwinspl.preferences.resource.dwprofile.ui.DwprofileUIPlugin.logError("IconProvider can't load image (URL is malformed).", mue); } } return descriptor; }
/** * <p> * Creates the sole wizard page contributed by this base implementation; the * standard Eclipse WizardNewProjectCreationPage. * </p> * * @see WizardNewProjectCreationPage#WizardNewProjectCreationPage(String) */ public void init(IWorkbench workbench, IStructuredSelection selection) { // Set default image for all wizard pages IPath path = new Path(eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionUIResourceBundle.NEW_PROJECT_WIZARD_PAGE_ICON); Bundle bundle = eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionUIPlugin.getDefault().getBundle(); URL url = FileLocator.find(bundle, path, null); ImageDescriptor descriptor = ImageDescriptor.createFromURL(url); setDefaultPageImageDescriptor(descriptor); wizardNewProjectCreationPage = new WizardNewProjectCreationPage(pageName); wizardNewProjectCreationPage.setTitle(pageTitle); wizardNewProjectCreationPage.setDescription(pageDescription); wizardNewProjectCreationPage.setInitialProjectName(pageProjectName); this.addPage(wizardNewProjectCreationPage); setWindowTitle(eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionUIResourceBundle.NEW_PROJECT_WIZARD_WINDOW_TITLE); }
/** * <p> * Returns the image for the given key. Possible keys are: * </p> * <p> * <ul> * </p> * <p> * <li>platform:/plugin/your.plugin/icons/yourIcon.png</li> * </p> * <p> * <li>bundleentry://557.fwk3560063/icons/yourIcon.png</li> * </p> * <p> * </ul> * </p> */ public ImageDescriptor getImageDescriptor(String key) { IPath path = new Path(key); eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionUIPlugin plugin = eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionUIPlugin.getDefault(); if (plugin == null) { return null; } ImageDescriptor descriptor = ImageDescriptor.createFromURL(FileLocator.find(plugin.getBundle(), path, null)); if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) { // try loading image from any bundle try { URL pluginUrl = new URL(key); descriptor = ImageDescriptor.createFromURL(pluginUrl); if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) { return null; } } catch (MalformedURLException mue) { eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionUIPlugin.logError("IconProvider can't load image (URL is malformed).", mue); } } return descriptor; }
/** * <p> * Creates the sole wizard page contributed by this base implementation; the * standard Eclipse WizardNewProjectCreationPage. * </p> * * @see WizardNewProjectCreationPage#WizardNewProjectCreationPage(String) */ public void init(IWorkbench workbench, IStructuredSelection selection) { // Set default image for all wizard pages IPath path = new Path(eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaUIResourceBundle.NEW_PROJECT_WIZARD_PAGE_ICON); Bundle bundle = eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaUIPlugin.getDefault().getBundle(); URL url = FileLocator.find(bundle, path, null); ImageDescriptor descriptor = ImageDescriptor.createFromURL(url); setDefaultPageImageDescriptor(descriptor); wizardNewProjectCreationPage = new WizardNewProjectCreationPage(pageName); wizardNewProjectCreationPage.setTitle(pageTitle); wizardNewProjectCreationPage.setDescription(pageDescription); wizardNewProjectCreationPage.setInitialProjectName(pageProjectName); this.addPage(wizardNewProjectCreationPage); setWindowTitle(eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaUIResourceBundle.NEW_PROJECT_WIZARD_WINDOW_TITLE); }
/** * <p> * Returns the image for the given key. Possible keys are: * </p> * <p> * <ul> * </p> * <p> * <li>platform:/plugin/your.plugin/icons/yourIcon.png</li> * </p> * <p> * <li>bundleentry://557.fwk3560063/icons/yourIcon.png</li> * </p> * <p> * </ul> * </p> */ public ImageDescriptor getImageDescriptor(String key) { IPath path = new Path(key); eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaUIPlugin plugin = eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaUIPlugin.getDefault(); if (plugin == null) { return null; } ImageDescriptor descriptor = ImageDescriptor.createFromURL(FileLocator.find(plugin.getBundle(), path, null)); if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) { // try loading image from any bundle try { URL pluginUrl = new URL(key); descriptor = ImageDescriptor.createFromURL(pluginUrl); if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) { return null; } } catch (MalformedURLException mue) { eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaUIPlugin.logError("IconProvider can't load image (URL is malformed).", mue); } } return descriptor; }
/** * <p> * Creates the sole wizard page contributed by this base implementation; the * standard Eclipse WizardNewProjectCreationPage. * </p> * * @see WizardNewProjectCreationPage#WizardNewProjectCreationPage(String) */ public void init(IWorkbench workbench, IStructuredSelection selection) { // Set default image for all wizard pages IPath path = new Path(eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueUIResourceBundle.NEW_PROJECT_WIZARD_PAGE_ICON); Bundle bundle = eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueUIPlugin.getDefault().getBundle(); URL url = FileLocator.find(bundle, path, null); ImageDescriptor descriptor = ImageDescriptor.createFromURL(url); setDefaultPageImageDescriptor(descriptor); wizardNewProjectCreationPage = new WizardNewProjectCreationPage(pageName); wizardNewProjectCreationPage.setTitle(pageTitle); wizardNewProjectCreationPage.setDescription(pageDescription); wizardNewProjectCreationPage.setInitialProjectName(pageProjectName); this.addPage(wizardNewProjectCreationPage); setWindowTitle(eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueUIResourceBundle.NEW_PROJECT_WIZARD_WINDOW_TITLE); }
/** * <p> * Returns the image for the given key. Possible keys are: * </p> * <p> * <ul> * </p> * <p> * <li>platform:/plugin/your.plugin/icons/yourIcon.png</li> * </p> * <p> * <li>bundleentry://557.fwk3560063/icons/yourIcon.png</li> * </p> * <p> * </ul> * </p> */ public ImageDescriptor getImageDescriptor(String key) { IPath path = new Path(key); eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueUIPlugin plugin = eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueUIPlugin.getDefault(); if (plugin == null) { return null; } ImageDescriptor descriptor = ImageDescriptor.createFromURL(FileLocator.find(plugin.getBundle(), path, null)); if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) { // try loading image from any bundle try { URL pluginUrl = new URL(key); descriptor = ImageDescriptor.createFromURL(pluginUrl); if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) { return null; } } catch (MalformedURLException mue) { eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueUIPlugin.logError("IconProvider can't load image (URL is malformed).", mue); } } return descriptor; }
/** * <p> * Creates the sole wizard page contributed by this base implementation; the * standard Eclipse WizardNewProjectCreationPage. * </p> * * @see WizardNewProjectCreationPage#WizardNewProjectCreationPage(String) */ public void init(IWorkbench workbench, IStructuredSelection selection) { // Set default image for all wizard pages IPath path = new Path(eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingUIResourceBundle.NEW_PROJECT_WIZARD_PAGE_ICON); Bundle bundle = eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingUIPlugin.getDefault().getBundle(); URL url = FileLocator.find(bundle, path, null); ImageDescriptor descriptor = ImageDescriptor.createFromURL(url); setDefaultPageImageDescriptor(descriptor); wizardNewProjectCreationPage = new WizardNewProjectCreationPage(pageName); wizardNewProjectCreationPage.setTitle(pageTitle); wizardNewProjectCreationPage.setDescription(pageDescription); wizardNewProjectCreationPage.setInitialProjectName(pageProjectName); this.addPage(wizardNewProjectCreationPage); setWindowTitle(eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingUIResourceBundle.NEW_PROJECT_WIZARD_WINDOW_TITLE); }
/** * <p> * Returns the image for the given key. Possible keys are: * </p> * <p> * <ul> * </p> * <p> * <li>platform:/plugin/your.plugin/icons/yourIcon.png</li> * </p> * <p> * <li>bundleentry://557.fwk3560063/icons/yourIcon.png</li> * </p> * <p> * </ul> * </p> */ public ImageDescriptor getImageDescriptor(String key) { IPath path = new Path(key); eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingUIPlugin plugin = eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingUIPlugin.getDefault(); if (plugin == null) { return null; } ImageDescriptor descriptor = ImageDescriptor.createFromURL(FileLocator.find(plugin.getBundle(), path, null)); if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) { // try loading image from any bundle try { URL pluginUrl = new URL(key); descriptor = ImageDescriptor.createFromURL(pluginUrl); if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) { return null; } } catch (MalformedURLException mue) { eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingUIPlugin.logError("IconProvider can't load image (URL is malformed).", mue); } } return descriptor; }
/** * Configures freemarker for usage. * @return * @throws URISyntaxException * @throws TemplateNotFoundException * @throws MalformedTemplateNameException * @throws ParseException * @throws IOException * @throws TemplateException */ private Configuration initializeConfiguration() throws URISyntaxException, TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException{ Configuration cfg = new Configuration(Configuration.VERSION_2_3_23); cfg.setClassForTemplateLoading(DwFeatureModelSVGGenerator.class, "templates"); cfg.setDefaultEncoding("UTF-8"); cfg.setLocale(Locale.US); cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); Bundle bundle = Platform.getBundle("de.darwinspl.feature.graphical.editor"); URL fileURL = bundle.getEntry("templates/"); File file = new File(FileLocator.resolve(fileURL).toURI()); cfg.setDirectoryForTemplateLoading(file); Map<String, TemplateNumberFormatFactory> customNumberFormats = new HashMap<String, TemplateNumberFormatFactory>(); customNumberFormats.put("hex", DwHexTemplateNumberFormatFactory.INSTANCE); cfg.setCustomNumberFormats(customNumberFormats); return cfg; }
private Configuration initializeConfiguration() throws URISyntaxException, TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException{ Configuration cfg = new Configuration(Configuration.VERSION_2_3_23); cfg.setClassForTemplateLoading(DwFeatureModelOverviewGenerator.class, "templates"); cfg.setDefaultEncoding("UTF-8"); cfg.setLocale(Locale.US); cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); Map<String, TemplateDateFormatFactory> customDateFormats = new HashMap<String, TemplateDateFormatFactory>(); customDateFormats.put("simple", DwSimpleTemplateDateFormatFactory.INSTANCE); cfg.setCustomDateFormats(customDateFormats); cfg.setDateTimeFormat("@simle"); Bundle bundle = Platform.getBundle("eu.hyvar.feature.graphical.editor"); URL fileURL = bundle.getEntry("templates/"); File file = new File(FileLocator.resolve(fileURL).toURI()); cfg.setDirectoryForTemplateLoading(file); return cfg; }
/** * <p> * Returns the image for the given key. Possible keys are: * </p> * <p> * <ul> * </p> * <p> * <li>platform:/plugin/your.plugin/icons/yourIcon.png</li> * </p> * <p> * <li>bundleentry://557.fwk3560063/icons/yourIcon.png</li> * </p> * <p> * </ul> * </p> */ public ImageDescriptor getImageDescriptor(String key) { IPath path = new Path(key); eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsUIPlugin plugin = eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsUIPlugin.getDefault(); if (plugin == null) { return null; } ImageDescriptor descriptor = ImageDescriptor.createFromURL(FileLocator.find(plugin.getBundle(), path, null)); if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) { // try loading image from any bundle try { URL pluginUrl = new URL(key); descriptor = ImageDescriptor.createFromURL(pluginUrl); if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) { return null; } } catch (MalformedURLException mue) { eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsUIPlugin.logError("IconProvider can't load image (URL is malformed).", mue); } } return descriptor; }
/** * <p> * Creates the sole wizard page contributed by this base implementation; the * standard Eclipse WizardNewProjectCreationPage. * </p> * * @see WizardNewProjectCreationPage#WizardNewProjectCreationPage(String) */ public void init(IWorkbench workbench, IStructuredSelection selection) { // Set default image for all wizard pages IPath path = new Path(eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsUIResourceBundle.NEW_PROJECT_WIZARD_PAGE_ICON); Bundle bundle = eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsUIPlugin.getDefault().getBundle(); URL url = FileLocator.find(bundle, path, null); ImageDescriptor descriptor = ImageDescriptor.createFromURL(url); setDefaultPageImageDescriptor(descriptor); wizardNewProjectCreationPage = new WizardNewProjectCreationPage(pageName); wizardNewProjectCreationPage.setTitle(pageTitle); wizardNewProjectCreationPage.setDescription(pageDescription); wizardNewProjectCreationPage.setInitialProjectName(pageProjectName); this.addPage(wizardNewProjectCreationPage); setWindowTitle(eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsUIResourceBundle.NEW_PROJECT_WIZARD_WINDOW_TITLE); }
/** * <p> * Creates the sole wizard page contributed by this base implementation; the * standard Eclipse WizardNewProjectCreationPage. * </p> * * @see WizardNewProjectCreationPage#WizardNewProjectCreationPage(String) */ public void init(IWorkbench workbench, IStructuredSelection selection) { // Set default image for all wizard pages IPath path = new Path(eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestUIResourceBundle.NEW_PROJECT_WIZARD_PAGE_ICON); Bundle bundle = eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestUIPlugin.getDefault().getBundle(); URL url = FileLocator.find(bundle, path, null); ImageDescriptor descriptor = ImageDescriptor.createFromURL(url); setDefaultPageImageDescriptor(descriptor); wizardNewProjectCreationPage = new WizardNewProjectCreationPage(pageName); wizardNewProjectCreationPage.setTitle(pageTitle); wizardNewProjectCreationPage.setDescription(pageDescription); wizardNewProjectCreationPage.setInitialProjectName(pageProjectName); this.addPage(wizardNewProjectCreationPage); setWindowTitle(eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestUIResourceBundle.NEW_PROJECT_WIZARD_WINDOW_TITLE); }
/** * <p> * Returns the image for the given key. Possible keys are: * </p> * <p> * <ul> * </p> * <p> * <li>platform:/plugin/your.plugin/icons/yourIcon.png</li> * </p> * <p> * <li>bundleentry://557.fwk3560063/icons/yourIcon.png</li> * </p> * <p> * </ul> * </p> */ public ImageDescriptor getImageDescriptor(String key) { IPath path = new Path(key); eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestUIPlugin plugin = eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestUIPlugin.getDefault(); if (plugin == null) { return null; } ImageDescriptor descriptor = ImageDescriptor.createFromURL(FileLocator.find(plugin.getBundle(), path, null)); if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) { // try loading image from any bundle try { URL pluginUrl = new URL(key); descriptor = ImageDescriptor.createFromURL(pluginUrl); if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) { return null; } } catch (MalformedURLException mue) { eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestUIPlugin.logError("IconProvider can't load image (URL is malformed).", mue); } } return descriptor; }
public void loadAndroidCallbacks() throws IOException { this.androidCallbacks = new HashSet<String>(); String line; InputStream is = null; BufferedReader br = null; try { is = FileLocator.openStream(Activator.getDefault().getBundle(), new Path(Config.callbacks), false); br = new BufferedReader(new InputStreamReader(is)); while ((line = br.readLine()) != null) androidCallbacks.add(line); } finally { if (br != null) br.close(); if (is != null) is.close(); } }
private void readFile(String fileName) throws IOException { String line; this.data = new ArrayList<String>(); InputStream is = null; BufferedReader br = null; try { is = FileLocator.openStream(Activator.getDefault().getBundle(), new Path(fileName), false); br = new BufferedReader(new InputStreamReader(is)); while ((line = br.readLine()) != null) this.data.add(line); } finally { if (br != null) br.close(); if (is != null) is.close(); } }
public PHPLanguageServer() { List<String> commands = new ArrayList<>(); commands.add("php"); Bundle bundle = Activator.getContext().getBundle(); Path workingDir = Path.EMPTY; try { workingDir = new Path(FileLocator.toFileURL(FileLocator.find(bundle, new Path("vendor"), null)).getPath()); commands.add(workingDir.append("/felixfbecker/language-server/bin/php-language-server.php").toOSString()); } catch (IOException e) { LanguageServerPlugin.logError(e); } if (Platform.getOS().equals(Platform.OS_WIN32)) { commands.add("--tcp=127.0.0.1:" + CONNECTION_PORT); provider = new ProcessOverSocketStreamConnectionProvider(commands, workingDir.toOSString(), CONNECTION_PORT) { }; } else { provider = new ProcessStreamConnectionProvider(commands, workingDir.toOSString()) { }; } }
public void perProcessEAFile(Document inputFileDoc, ArrayList<File> additionalSysMLFileList) throws ParserConfigurationException, SAXException, IOException { // Add the documents to the fileList String extensionPath = FileLocator .toFileURL(Activator.getDefault().getBundle().getEntry(EXTENSION_FILE_PATH_IN_RESOURCE)).getPath(); File extensionFile = FileHandler.loadFileFromPath(extensionPath); additionalSysMLFileList.add(extensionFile); // Merge documents loopInputFileDoc(inputFileDoc); for (File file : additionalSysMLFileList) { Document additionDoc = parseFileToGetDomDocument(file); appenedNewNodeInDom(inputFileDoc, additionDoc); } // Remove the illegal connector end findIllegalConnector(); }
/** * This method will read the properties file automatically, and store all * the special error nodes into list. The properties file gives the name of * nodes which will cause error. * * @throws IOException */ private ArrayList<String> readErrorPropertiesFile() throws IOException { ArrayList<String> dupIdErrorNodeNameList = new ArrayList<String>(); String errorNodeConfigPath = FileLocator .toFileURL(Activator.getDefault().getBundle().getEntry(DUP_ID_ERROR_CONFIG_FILE_PAHT)).getPath(); File errorNodeConfigFile = new File(errorNodeConfigPath); Properties properties = new Properties(); properties.load(new FileInputStream(errorNodeConfigFile)); for (String key : properties.stringPropertyNames()) { String value = properties.getProperty(key); dupIdErrorNodeNameList.add(value); } return dupIdErrorNodeNameList; }
/** * Copy the runtime files to the output path * * @param path * the root path of the runtime * @param outputDirectory * @return <code>true</code> if the copy is successful, <code>false</code> * otherwise */ public static boolean copyRuntimeFiles(String path, File outputDirectory) { try { if (path == null) { path = ""; } URL url = Activator.getDefault().getBundle().getEntry("/runtime/" + path); if (url == null) { Logger.debug("copy runtime error: malformed url for the path %s", path); return false; } else { File source = new File(FileLocator.resolve(url).toURI().normalize()); FileUtils.copyRecursively(source, outputDirectory); } return true; } catch (Exception e) { Logger.debug("copy runtime error: %s", e.getMessage()); } return false; }
@Override public void start(BundleContext context) throws Exception { Activator.context = context; Bundle dataBundle = Platform.getBundle("us.nineworlds.xstreamer.ia.data"); IPath deploymentsPath = new Path("deployments/deployments.json"); IPath commandCardsPath = new Path("commandCards/commandcards.json"); IPath mapsPath = new Path("iaskirmishMaps/ia_skirmish_maps.json"); URL deploymentsUrl = FileLocator.find(dataBundle, deploymentsPath, null); URL commandCardsUrl = FileLocator.find(dataBundle, commandCardsPath, null); URL mapsUrl = FileLocator.find(dataBundle, mapsPath, null); DeploymentsDB deploymentsDB = new DepoymentsDBLoader().load(deploymentsUrl); CommandCardDB commandCardsDB = new CommandCardsDBLoader().load(commandCardsUrl); Maps skirmishMaps = new SkirmishMapsLoader().loadSkirmishMaps(mapsUrl.openStream()); skirmishMapsLookup = SkirmishMapsLookup.newInstance(skirmishMaps); commandCardLookup = CommandCardLookup.newInstance(commandCardsDB); deploymentsLookup = DeploymentsLookup.newInstance(deploymentsDB); }
/** * Load properties. */ private static void loadProperties() { URL pluginUrl = null; String absolutePath; String completePath; BufferedInputStream stream; try { pluginUrl = FileLocator.toFileURL(Activator.getInstallURL()); absolutePath = new File(pluginUrl.getPath()).getAbsolutePath(); completePath = absolutePath + SEPARATOR + FILE_NAME; stream = new BufferedInputStream(new FileInputStream(completePath)); PROPERTIES.load(stream); stream.close(); } catch (IOException e) { throw new WrappedException("Error during loading properties", e); } }
/** * Initialization of RCP internal location of standard modules */ private void initInternalLibraryPath() { try { Enumeration installedInternalModules = Activator.getDefault().getBundle().findEntries(File.separator, STANDARD_MODULES, true); Vector paths = new Vector(); while (installedInternalModules.hasMoreElements()) { URL library = (URL) installedInternalModules.nextElement(); if (library != null) { // add external (resolved) URL paths.addElement(FileLocator.resolve(library).getPath()); } } libraryPathEntries.addAll(paths); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
/** * Load and register a new image. If the image resource does not exist or * fails to load, a default "error" resource is supplied. * * @param name name of the image * @param filename name of the file containing the image * @return whether the image has correctly been loaded */ private boolean newImage(String name, String filename) { ImageDescriptor id; boolean success; try { URL fileURL = FileLocator.find(bundle, new Path(RESOURCE_DIR + filename), null); id = ImageDescriptor.createFromURL(FileLocator.toFileURL(fileURL)); success = true; } catch (Exception e) { e.printStackTrace(); id = ImageDescriptor.getMissingImageDescriptor(); // id = getSharedByName(ISharedImages.IMG_OBJS_ERROR_TSK); success = false; } descMap.put(name, id); imageMap.put(name, id.createImage(true)); return success; }