Java 类org.eclipse.core.runtime.FileLocator 实例源码

项目:AgentWorkbench    文件:BundleEvaluator.java   
/**
 * 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;
}
项目:eclipse-batch-editor    文件:EclipseUtil.java   
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;
}
项目:eclipse-bash-editor    文件:EclipseUtil.java   
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;
}
项目:camel-language-server    文件:CamelLSPStreamConnectionProvider.java   
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;
}
项目:library-training    文件:NewChildTest.java   
/**
 * 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);
                    }
             }
        }
    }
}
项目:egradle    文件:EclipseUtil.java   
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;
}
项目:gemfirexd-oss    文件:DerbyClasspathContainer.java   
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);
}
项目:DarwinSPL    文件:DwprofileNewProjectWizard.java   
/**
 * <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);
}
项目:DarwinSPL    文件:DwprofileNewProjectWizardLogic.java   
/**
 * <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();
    }
}
项目:DarwinSPL    文件:DwprofileImageProvider.java   
/**
 * <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;
}
项目:DarwinSPL    文件:HyexpressionNewProjectWizardLogic.java   
/**
 * <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();
    }
}
项目:DarwinSPL    文件:HyexpressionNewProjectWizard.java   
/**
 * <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);
}
项目:DarwinSPL    文件:HyexpressionImageProvider.java   
/**
 * <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;
}
项目:DarwinSPL    文件:HyvalidityformulaNewProjectWizard.java   
/**
 * <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);
}
项目:DarwinSPL    文件:HyvalidityformulaImageProvider.java   
/**
 * <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;
}
项目:DarwinSPL    文件:HyvalidityformulaNewProjectWizardLogic.java   
/**
 * <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();
    }
}
项目:DarwinSPL    文件:HydatavalueNewProjectWizard.java   
/**
 * <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);
}
项目:DarwinSPL    文件:HydatavalueNewProjectWizardLogic.java   
/**
 * <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();
    }
}
项目:DarwinSPL    文件:HydatavalueImageProvider.java   
/**
 * <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;
}
项目:DarwinSPL    文件:HymappingNewProjectWizardLogic.java   
/**
 * <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();
    }
}
项目:DarwinSPL    文件:HymappingNewProjectWizard.java   
/**
 * <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);
}
项目:DarwinSPL    文件:HymappingImageProvider.java   
/**
 * <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;
}
项目:DarwinSPL    文件:DwFeatureModelSVGGenerator.java   
/**
 * 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;
}
项目:DarwinSPL    文件:DwFeatureModelOverviewGenerator.java   
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;
}
项目:DarwinSPL    文件:HyconstraintsImageProvider.java   
/**
 * <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;
}
项目:DarwinSPL    文件:HyconstraintsNewProjectWizard.java   
/**
 * <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);
}
项目:DarwinSPL    文件:HyconstraintsNewProjectWizardLogic.java   
/**
 * <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();
    }
}
项目:DarwinSPL    文件:HymanifestNewProjectWizardLogic.java   
/**
 * <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();
    }
}
项目:DarwinSPL    文件:HymanifestNewProjectWizard.java   
/**
 * <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);
}
项目:DarwinSPL    文件:HymanifestImageProvider.java   
/**
 * <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;
}
项目:cheetah    文件:Activator.java   
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();
    }
}
项目:cheetah    文件:PermissionMethodParserJIT.java   
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();
    }
}
项目:lsp4e-php    文件:PHPLanguageServer.java   
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()) {
        };
    }
}
项目:org.lovian.eaxmireader    文件:EAFilePreProcessorModule.java   
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();
}
项目:org.lovian.eaxmireader    文件:EAFilePreProcessorModule.java   
/**
 * 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;
}
项目:turnus.orcc    文件:RuntimeUtils.java   
/**
 * 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;
}
项目:xstreamer    文件:Activator.java   
@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);
}
项目:dsl-devkit    文件:TestConfiguration.java   
/**
 * 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);
  }
}
项目:tlaplus    文件:RCPNameToFileIStream.java   
/**
 * 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();
    }

}
项目:hadoop-2.6.0-cdh5.4.3    文件:ImageLibrary.java   
/**
 * 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;
}