Java Code Examples for org.eclipse.core.runtime.FileLocator

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project Archimedes, under directory /br.org.archimedes.core/src/br/org/archimedes/rcp/.

Source file: AbstractFileLocatorActivator.java

  19 
vote

/** 
 * @param path The path to the file relative to this plugin's root
 * @param bundle The bundle containing information as to where is this plugin
 * @return A File pointing to the system file or null if the activator is not set or could notfind the file (this is not a regular RCP run... happens for non-plugins tests)
 * @throws IOException Thrown if there is an error while reading the file
 */
public static File resolveFile(String path,Bundle bundle) throws IOException {
  File file=null;
  if (bundle != null) {
    URL url=FileLocator.find(bundle,new Path(path),Collections.emptyMap());
    if (url != null) {
      URL fileUrl=FileLocator.toFileURL(url);
      try {
        file=new File(fileUrl.toURI());
      }
 catch (      URISyntaxException e) {
        e.printStackTrace();
      }
    }
  }
  return file;
}
 

Example 2

From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.ec2/src/com/amazonaws/eclipse/ec2/.

Source file: PlatformUtils.java

  19 
vote

/** 
 * Opens a shell to the specified host using a platform specific terminal window.
 * @param user The user to connect to the remote host as.
 * @param host The remote host to connect to.
 * @param identityFile The file containing the identity file for the connection.
 * @throws IOException If any problems are encountered opening the remote shell.
 */
public void openShellToRemoteHost(String user,String host,String identityFile) throws IOException, InterruptedException, URISyntaxException {
  IPreferenceStore preferenceStore=Ec2Plugin.getDefault().getPreferenceStore();
  String sshOptions=preferenceStore.getString(PreferenceConstants.P_SSH_OPTIONS);
  String sshCommand=preferenceStore.getString(PreferenceConstants.P_SSH_CLIENT);
  sshCommand+=" " + sshOptions + " -i "+ identityFile+ " "+ user+ "@"+ host;
  if (isMac()) {
    URL locationUrl=FileLocator.find(Ec2Plugin.getDefault().getBundle(),new Path("/"),null);
    URL fileUrl=FileLocator.toFileURL(locationUrl);
    executeAsynchronousCommand(new String[]{"osascript",fileUrl.getFile() + "scripts/openMacTerminalShell.scpt",sshCommand});
  }
 else   if (isLinux()) {
    String terminalCommand=preferenceStore.getString(PreferenceConstants.P_TERMINAL_EXECUTABLE);
    executeAsynchronousCommand(new String[]{terminalCommand,"-e",sshCommand});
  }
 else   if (isWindows()) {
    openRemoteShellFromWindows(user,host,identityFile);
  }
 else {
    String osName=System.getProperty("os.name");
    Status status=new Status(IStatus.ERROR,Ec2Plugin.PLUGIN_ID,"Unable to determine what platform '" + osName + "' is.");
    StatusManager.getManager().handle(status,StatusManager.SHOW | StatusManager.LOG);
  }
}
 

Example 3

From project bioclipse.speclipse, under directory /plugins/net.bioclipse.bibtex.test/src/net/bioclipse/bibtex/test/.

Source file: AbstractBibtexManagerPluginTest.java

  19 
vote

@Test public void testLoadBibliodata_IFile() throws Exception {
  URI uri=getClass().getResource("/testFiles/test.bib").toURI();
  URL url=FileLocator.toFileURL(uri.toURL());
  String path=url.getFile();
  IJabrefBibliodata biblio=bibtexmanager.loadBibliodata(new MockIFile(path));
  Assert.assertEquals(3,biblio.getJabrefDatabase().getEntryCount());
}
 

Example 4

From project bioclipse.vscreen, under directory /net.bioclipse.vscreen.tests/src/net/bioclipse/vscreen/tests/.

Source file: AbstractVScreenManagerPluginTest.java

  19 
vote

@Before public void initialize() throws IOException, CoreException, BioclipseException, URISyntaxException {
  sdb=Activator.getDefault().getStructuredbManager();
  if (sdb.allDatabaseNames().contains(TEST_DB_NAME)) {
    sdb.deleteDatabase(TEST_DB_NAME,new NullProgressMonitor());
  }
  sdb.createDatabase(TEST_DB_NAME);
  IFile file=null;
  URI uri=getClass().getResource(TEST_FILE).toURI();
  URL url=FileLocator.toFileURL(uri.toURL());
  String path=url.getFile();
  file=FileUtil.createLinkedFile(path);
  sdb.addMoleculesFromSDF(TEST_DB_NAME,file);
}
 

Example 5

From project bundlemaker, under directory /main/org.bundlemaker.core.ui.artifact/src/org/bundlemaker/core/ui/artifact/internal/.

Source file: Activator.java

  19 
vote

public String getFile(String path){
  Bundle bundle=Platform.getBundle(PLUGIN_ID);
  Object file=FileLocator.find(bundle,new Path(path),null);
  if (file != null) {
    return file.toString();
  }
 else {
    return null;
  }
}
 

Example 6

From project ccw, under directory /ccw.core/src/java/ccw/launching/.

Source file: ClojureLaunchDelegate.java

  19 
vote

@Override public String getProgramArguments(ILaunchConfiguration configuration) throws CoreException {
  String userProgramArguments=super.getProgramArguments(configuration);
  if (isLaunchREPL(configuration)) {
    String filesToLaunchArguments=LaunchUtils.getFilesToLaunchAsCommandLineList(configuration,false);
    String toolingFile=null;
    try {
      URL toolingFileURL=CCWPlugin.getDefault().getBundle().getResource("ccw/debug/serverrepl.clj");
      toolingFile=FileLocator.toFileURL(toolingFileURL).getFile();
    }
 catch (    IOException e) {
      throw new WorkbenchException("Could not find ccw.debug.serverrepl source file",e);
    }
    String nREPLInit="(require 'clojure.tools.nrepl.server)" + String.format("(do (clojure.tools.nrepl.server/start-server :ack-port %s) nil)",CCWPlugin.getDefault().getREPLServerPort());
    String args=String.format("-i \"%s\" -e \"%s\" %s %s",toolingFile,nREPLInit,filesToLaunchArguments,userProgramArguments);
    CCWPlugin.log("Starting REPL with program args: " + args);
    return args;
  }
 else {
    String filesToLaunchArguments=LaunchUtils.getFilesToLaunchAsCommandLineList(configuration,true);
    return filesToLaunchArguments + " " + userProgramArguments;
  }
}
 

Example 7

From project ceylon-ide-eclipse, under directory /plugins/com.redhat.ceylon.eclipse.ui/src/com/redhat/ceylon/eclipse/code/hover/.

Source file: DocHover.java

  19 
vote

public static URL fileUrl(String icon){
  try {
    return FileLocator.toFileURL(FileLocator.find(CeylonPlugin.getInstance().getBundle(),new Path("icons/").append(icon),null));
  }
 catch (  IOException e) {
    e.printStackTrace();
    return null;
  }
}
 

Example 8

From project cilia-workbench, under directory /cilia-workbench-common/src/fr/liglab/adele/cilia/workbench/common/ui/view/.

Source file: CiliaLabelProvider.java

  19 
vote

private static Image createImageFromPath(String imagePath){
  org.osgi.framework.Bundle bundle=Activator.getInstance().getBundle();
  URL url=FileLocator.find(bundle,new Path(imagePath),null);
  try {
    url=new URL("platform:/plugin/fr.liglab.adele.cilia.workbench.common/" + imagePath);
  }
 catch (  MalformedURLException e) {
    e.printStackTrace();
  }
  ImageDescriptor imageDesc=ImageDescriptor.createFromURL(url);
  return imageDesc.createImage();
}
 

Example 9

From project dawn-common, under directory /org.dawb.common.ui/src/org/dawb/common/ui/util/.

Source file: EclipseUtils.java

  19 
vote

/** 
 * @param bundleUrl 
 * @return bundleUrl
 */
public static URL getAbsoluteUrl(final URL bundleUrl){
  if (bundleUrl == null)   return null;
  if (bundleUrl.toString().startsWith("bundle"))   try {
    return FileLocator.resolve(bundleUrl);
  }
 catch (  IOException e) {
    return bundleUrl;
  }
  return bundleUrl;
}
 

Example 10

From project dawn-isenciaui, under directory /com.isencia.passerelle.workbench.model.ui/src/main/java/com/isencia/passerelle/workbench/model/ui/utils/.

Source file: EclipseUtils.java

  19 
vote

/** 
 * @param bundleUrl
 * @return bundleUrl
 */
public static URL getAbsoluteUrl(final URL bundleUrl){
  if (bundleUrl == null)   return null;
  if (bundleUrl.toString().startsWith("bundle"))   try {
    return FileLocator.resolve(bundleUrl);
  }
 catch (  IOException e) {
    return bundleUrl;
  }
  return bundleUrl;
}
 

Example 11

From project dawn-product, under directory /org.dawnsci.intro/src/org/dawnsci/intro/content/.

Source file: ASinglePerspectiveContentProvider.java

  19 
vote

@Override public void createContent(String id,Element parent){
  System.out.println("AsinglePerspective ID:" + id);
  System.out.println("parent:" + parent.getLocalName());
  Document dom=parent.getOwnerDocument();
  Element div=dom.createElement("div");
  div.setAttribute("class","grid_" + introActions.size());
  parent.appendChild(div);
  Iterator<IConfigurationElement> iter=introActions.iterator();
  while (iter.hasNext()) {
    try {
      IConfigurationElement config=iter.next();
      String name=config.getAttribute(ATT_NAME);
      String classname=config.getAttribute(ATT_CLASS);
      IContributor contrib=config.getContributor();
      String contribName=contrib instanceof RegistryContributor ? ((RegistryContributor)contrib).getActualName() : contrib.getName();
      URL bundleURL=FileLocator.find(Platform.getBundle(contribName),new Path(config.getAttribute(ATT_ICON)),null);
      URL imgURL=null;
      imgURL=FileLocator.toFileURL(bundleURL);
      Element a=dom.createElement("a");
      Element span=dom.createElement("span");
      Element img=dom.createElement("img");
      a.setAttribute("href","http://org.eclipse.ui.intro/runAction?pluginId=org.dawnsci.intro&;class=org.dawnsci.intro.actions.OpenPerspectiveAction&name=" + classname);
      a.setAttribute("class","portfolio_item float alpha");
      span.appendChild(dom.createTextNode(name));
      span.setTextContent("testtest");
      img.setAttribute("class","");
      img.setAttribute("src",imgURL.getPath());
      img.setAttribute("alt","");
      a.appendChild(span);
      a.appendChild(img);
      div.appendChild(a);
    }
 catch (    IOException e) {
      logger.error("TODO put description of error here",e);
    }
  }
}
 

Example 12

From project Diver, under directory /ca.uvic.chisel.javasketch/src/ca/uvic/chisel/javasketch/launching/internal/.

Source file: JavaAgentUtil.java

  19 
vote

public static IPath getJavaAgent(ILaunchConfiguration configuration) throws CoreException {
  String os=Platform.getOS();
  String arch=Platform.getOSArch();
  URL fileUrl=null;
  if ("win32".equals(os) && "x86".equals(arch)) {
    fileUrl=SketchPlugin.getDefault().getBundle().getResource("sketch_win32.dll");
  }
 else   if ("win32".equals(os) && ("amd64".equals(arch) || "x86_64".equals(arch))) {
    fileUrl=SketchPlugin.getDefault().getBundle().getResource("sketch_win64.dll");
  }
 else   if ("linux".equals(os)) {
    fileUrl=SketchPlugin.getDefault().getBundle().getResource("libsketch_linux32.so");
  }
 else {
    throw new CoreException(new Status(Status.ERROR,SketchPlugin.PLUGIN_ID,"Unrecognized operating system: " + os + " with architecture "+ arch));
  }
  if (fileUrl == null) {
    throw new CoreException(new Status(Status.ERROR,SketchPlugin.PLUGIN_ID,"Unable to locate tracing library: OS = " + os + " with architecture "+ arch));
  }
  String fileName=null;
  try {
    fileUrl=FileLocator.toFileURL(fileUrl);
    fileName=fileUrl.getFile();
    File file=new File(fileName);
    if (!file.exists()) {
      fileName=null;
    }
 else {
      fileName=file.getCanonicalPath();
    }
    if (fileName != null) {
      IPath filePath=new Path(fileName);
      return filePath;
    }
  }
 catch (  IOException e) {
    throw new CoreException(new Status(Status.ERROR,SketchPlugin.PLUGIN_ID,"Could not locate tracing agent",e));
  }
  throw new CoreException(new Status(Status.ERROR,SketchPlugin.PLUGIN_ID,"Could not locate tracing agent"));
}
 

Example 13

From project droolsjbpm-tools, under directory /drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/util/.

Source file: DroolsRuntimeManager.java

  19 
vote

private static String getDroolsLocation(){
  try {
    return FileLocator.toFileURL(Platform.getBundle("org.drools.eclipse").getEntry("/")).getFile().toString();
  }
 catch (  IOException e) {
    DroolsEclipsePlugin.log(e);
  }
  return null;
}
 

Example 14

From project e4-rendering, under directory /com.toedter.e4.demo.contacts.generic/src/com/toedter/e4/demo/contacts/generic/model/internal/.

Source file: VCardContactsRepository.java

  19 
vote

private File[] getContacts() throws Exception {
  File[] localContacts=getLocalContacts();
  if (localContacts.length == 0) {
    IPath path=BundleActivatorImpl.getInstance().getStateLocation();
    byte[] buffer=new byte[8192];
    Bundle bundle=Platform.getBundle("com.toedter.e4.demo.contacts.generic");
    for (Enumeration<?> contacts=getStoredContacts(); contacts.hasMoreElements(); ) {
      String bundlePath=(String)contacts.nextElement();
      if (!bundlePath.endsWith(".vcf")) {
        continue;
      }
      InputStream inputStream=FileLocator.openStream(bundle,new Path(bundlePath),false);
      FileOutputStream outputStream=new FileOutputStream(path.append(bundlePath.substring(bundlePath.indexOf('/') + 1)).toFile());
      int read=inputStream.read(buffer);
      while (read != -1) {
        outputStream.write(buffer,0,read);
        read=inputStream.read(buffer);
      }
      inputStream.close();
      outputStream.close();
    }
    return getLocalContacts();
  }
  return localContacts;
}
 

Example 15

From project eclim, under directory /org.eclim/java/org/eclim/eclipse/.

Source file: EclimPlugin.java

  19 
vote

/** 
 * This method is called upon plug-in activation
 * @param context The bundle context.
 */
public void start(BundleContext context) throws Exception {
  super.start(context);
  URL url=FileLocator.toFileURL(getBundle().getResource(PLUGIN_XML));
  String home=url.toString();
  home=home.substring(FILE_PREFIX.length(),home.length() - PLUGIN_XML.length());
  home=home.replaceFirst("^/([A-Za-z]:)","$1");
  System.setProperty("eclim.home",home);
}
 

Example 16

From project Eclipse, under directory /com.mobilesorcery.sdk.importproject.tests/src/com/mobilesorcery/sdk/importproject/.

Source file: ImportTest.java

  19 
vote

private void testLegacyImport(String pathStr,int strategy,Map<String,String> expectedProperties) throws Exception {
  Bundle bundle=Platform.getBundle("com.mobilesorcery.sdk.importproject.tests");
  Path path=new Path(pathStr);
  URL pathURL=FileLocator.find(bundle,path.append(path.lastSegment() + ".zip"),null);
  URL pathFileURL=FileLocator.toFileURL(pathURL);
  File file=new File(pathFileURL.getPath());
  File unzipped=new File(file.getParentFile(),"unzipped");
  Util.unzip(file,unzipped);
  ArrayList<IProject> result=new ArrayList<IProject>();
  ImportProjectsRunnable importer=new ImportProjectsRunnable(new File[]{new File(unzipped,path.lastSegment() + ".mopro")},strategy,result);
  importer.run(null);
  assertProperlyImported(result.get(0),importer,expectedProperties);
}
 

Example 17

From project eclipse-integration-cloudfoundry, under directory /org.cloudfoundry.ide.eclipse.server.core/src/org/cloudfoundry/ide/eclipse/internal/server/core/.

Source file: CloudFoundryRuntimeClasspathProvider.java

  19 
vote

public IClasspathEntry[] resolveClasspathContainer(IProject project,IRuntime runtime){
  List<IClasspathEntry> cp=new ArrayList<IClasspathEntry>(2);
  for (  String id : CP_BUNDLES) {
    Bundle bundle=Platform.getBundle(id);
    try {
      File file=FileLocator.getBundleFile(bundle);
      Path path=new Path(file.getCanonicalPath());
      cp.add(JavaCore.newLibraryEntry(path,null,null));
    }
 catch (    IOException e) {
    }
  }
  return cp.toArray(new IClasspathEntry[0]);
}
 

Example 18

From project eclipse-integration-commons, under directory /org.springsource.ide.eclipse.commons.configurator/src/org/springsource/ide/eclipse/commons/internal/configurator/.

Source file: InstallableItem.java

  19 
vote

private File getSourceLocation() throws CoreException {
  Bundle bundle=Platform.getBundle(element.getContributor().getName());
  try {
    return FileLocator.getBundleFile(bundle);
  }
 catch (  IOException e) {
    throw new CoreException(new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Failed to determine install location",e));
  }
}
 

Example 19

From project eclipse-integration-gradle, under directory /org.springsource.ide.eclipse.gradle.core/src/org/springsource/ide/eclipse/gradle/core/dsld/.

Source file: GradleDSLDClasspathContainer.java

  19 
vote

private void addDSLDFolder(ArrayList<IClasspathEntry> entryList){
  try {
    Bundle bundle=Platform.getBundle(GradleCore.PLUGIN_ID);
    File bundleFile=FileLocator.getBundleFile(bundle);
    if (bundleFile != null && bundleFile.exists() && bundleFile.isDirectory()) {
      File dslSupport=new File(bundleFile,"dslSupport");
      if (dslSupport.exists() && dslSupport.isDirectory()) {
        entryList.add(JavaCore.newLibraryEntry(new Path(dslSupport.toString()),null,null,false));
      }
 else {
        GradleCore.log("Couldn't find: '" + dslSupport + "'");
      }
    }
 else {
      GradleCore.log("Trouble accessing the bundle: '" + GradleCore.PLUGIN_ID + " as a directory. check that it is packaged as an 'explodedBundle'");
    }
  }
 catch (  IOException e) {
    GradleCore.log(e);
  }
}
 

Example 20

From project eclipse.pde.build, under directory /org.eclipse.pde.build.tests/src/org/eclipse/pde/build/internal/tests/ant/.

Source file: AntUtils.java

  19 
vote

static private void setupClasspath(){
  URL[] antClasspath=AntCorePlugin.getPlugin().getPreferences().getURLs();
  StringBuffer buff=new StringBuffer();
  File file=null;
  for (int i=0; i < antClasspath.length; i++) {
    try {
      file=new File(FileLocator.toFileURL(antClasspath[i]).getPath());
    }
 catch (    IOException e) {
      continue;
    }
    buff.append(file.getAbsolutePath());
    buff.append("; ");
  }
  org.apache.tools.ant.types.Path systemClasspath=new org.apache.tools.ant.types.Path(null,buff.substring(0,buff.length() - 2));
  org.apache.tools.ant.types.Path.systemClasspath=systemClasspath;
}
 

Example 21

From project eclipse.platform.runtime, under directory /tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/.

Source file: ConfigurationSessionTestSuite.java

  19 
vote

private List getURLs(String id){
  List result=new ArrayList();
  String suffix="";
  int atIndex=id.indexOf("@");
  if (atIndex >= 0) {
    suffix=id.substring(atIndex);
    id=id.substring(0,atIndex);
  }
  Bundle[] allVersions=Platform.getBundles(id,null);
  Assert.assertNotNull("0.0.1." + id,allVersions);
  for (int i=0; i < allVersions.length; i++) {
    Bundle bundle=allVersions[i];
    Assert.assertNotNull("0.1 " + id,bundle);
    URL url=bundle.getEntry("/");
    Assert.assertNotNull("0.2 " + id,url);
    try {
      url=FileLocator.resolve(url);
    }
 catch (    IOException e) {
      CoreTest.fail("0.3 " + url,e);
    }
    String externalForm;
    if (url.getProtocol().equals("jar")) {
      String path=url.getPath();
      externalForm=path.substring(0,path.length() - 2);
    }
 else     externalForm=url.toExternalForm();
    externalForm="reference:" + externalForm;
    result.add(externalForm + suffix);
  }
  return result;
}
 

Example 22

From project eik, under directory /plugins/info.evanchik.eclipse.karaf.core/src/main/java/info/evanchik/eclipse/karaf/core/internal/.

Source file: PluginLocVariableResolver.java

  19 
vote

public String resolveValue(IDynamicVariable variable,String argument) throws CoreException {
  if (argument == null) {
    final String message="The plugin_loc variable requires the symbolic name of a bundle as an argument";
    throw new CoreException(new Status(IStatus.ERROR,KarafCorePluginActivator.PLUGIN_ID,IStatus.OK,message,null));
  }
  final Bundle b=Platform.getBundle(argument);
  if (b == null) {
    return null;
  }
  try {
    final File bundleFile=FileLocator.getBundleFile(b);
    return bundleFile.getAbsolutePath();
  }
 catch (  IOException e) {
    final String message="Unable to resolve bundle to absolute filesystem path: " + argument;
    throw new CoreException(new Status(IStatus.ERROR,KarafCorePluginActivator.PLUGIN_ID,IStatus.OK,message,null));
  }
}
 

Example 23

From project gda-common-rcp, under directory /uk.ac.gda.common.rcp/src/uk/ac/gda/common/rcp/util/.

Source file: EclipseUtils.java

  19 
vote

/** 
 * @param bundleUrl 
 * @return bundleUrl
 */
public static URL getAbsoluteUrl(final URL bundleUrl){
  if (bundleUrl == null)   return null;
  if (bundleUrl.toString().startsWith("bundle"))   try {
    return FileLocator.resolve(bundleUrl);
  }
 catch (  IOException e) {
    return bundleUrl;
  }
  return bundleUrl;
}
 

Example 24

From project grails-ide, under directory /org.grails.ide.eclipse.core/src/org/grails/ide/eclipse/core/internal/classpath/.

Source file: GrailsClasspathContainer.java

  19 
vote

/** 
 * Returns the classpath entry corresponding to the external location where the grails.dsld is located.  This is in the c.s.s.grails.resources plugin
 * @return the classpath entry or null if it does not exist
 */
private IClasspathEntry findGrailsDsld(){
  IGrailsInstall install=GrailsVersion.getEclipseGrailsVersion(javaProject.getProject()).getInstall();
  if (install != null && install.getVersion().compareTo(GrailsVersion.V_1_3_7) > 0) {
    Bundle b=Platform.getBundle(GrailsCoreActivator.GRAILS_RESOURCES_PLUGIN_ID);
    if (b != null) {
      URL entry=b.getEntry(DSL_SUPPORT_FOLDER);
      URL resolvedEntry;
      try {
        resolvedEntry=FileLocator.resolve(entry);
        IPath jarPath=new Path(resolvedEntry.getPath());
        return JavaCore.newLibraryEntry(jarPath,null,null);
      }
 catch (      IOException e) {
        GrailsCoreActivator.log(e);
      }
    }
  }
  return null;
}
 

Example 25

From project hackergarten-moreunit, under directory /org.moreunit.test.dependencies/src/org/moreunit/test/workspace/.

Source file: WorkspaceHelper.java

  19 
vote

private static Path createPathForFilename(String filename) throws IOException {
  Location location=Platform.getInstallLocation();
  URL pluginURL=location.getURL();
  URL jarURL=new URL(pluginURL,filename);
  URL localJarURL=FileLocator.toFileURL(jarURL);
  return new Path(localJarURL.getPath());
}
 

Example 26

From project koneki.ldt, under directory /plugins/com.naef.jnlua/src/com/naef/jnlua/eclipse/.

Source file: AbstractLuaModule.java

  19 
vote

/** 
 * return the folder in the bundle (pluginID) at the relative path
 */
protected File getScriptFolder(String relativepath){
  File folder=foldersCache.get(relativepath);
  if (folder == null) {
    try {
      URL folderUrl=FileLocator.toFileURL(Platform.getBundle(getPluginID()).getEntry(relativepath));
      folder=new File(folderUrl.getFile());
      foldersCache.put(relativepath,folder);
    }
 catch (    IOException e) {
      log(IStatus.ERROR,"Unable to get entry " + relativepath + " in the plugin "+ getPluginID(),e);
    }
  }
  return folder;
}
 

Example 27

From project m2eclipse-hudson, under directory /org.sonatype.m2e.hudson.ui/src/main/java/com/sonatype/buildserver/eclipse/ui/.

Source file: StatusNotification.java

  19 
vote

private static Image[] loadAnimatedGIF(Display display,String imagePath) throws IOException {
  URL url=FileLocator.find(HudsonUIActivator.getDefault().getBundle(),new Path(imagePath),null);
  ImageLoader imageLoader=new ImageLoader();
  imageLoader.load(url.openStream());
  Image[] images=new Image[imageLoader.data.length];
  for (int i=0; i < imageLoader.data.length; ++i) {
    ImageData nextFrameData=imageLoader.data[i];
    images[i]=new Image(display,nextFrameData);
  }
  return images;
}
 

Example 28

From project m2eclipse-webby, under directory /org.sonatype.m2e.webby/src/org/sonatype/m2e/webby/internal/launch/.

Source file: WebbyLaunchDelegate.java

  19 
vote

private String[] getEmbeddeClasspath(String containerId) throws CoreException {
  List<String> paths=new ArrayList<String>();
  try {
    File webbyJar=FileLocator.getBundleFile(WebbyPlugin.getDefault().getBundle());
    if (webbyJar.isDirectory()) {
      File classesDir=new File(webbyJar,"target/classes");
      if (classesDir.isDirectory()) {
        webbyJar=classesDir;
      }
    }
    paths.add(webbyJar.getAbsolutePath());
    addJars(paths,"jars/cargo");
    addJars(paths,"jars/" + containerId);
  }
 catch (  Exception e) {
    throw WebbyPlugin.newError("Failed to create container classpath",e);
  }
  return paths.toArray(new String[paths.size()]);
}
 

Example 29

From project makegood, under directory /com.piece_framework.makegood.stagehandtestrunner/src/com/piece_framework/makegood/stagehandtestrunner/.

Source file: StagehandTestRunner.java

  19 
vote

public static String getBundleIncludePath(){
  URL url;
  try {
    url=FileLocator.resolve(Platform.getBundle(Activator.PLUGIN_ID).getEntry(PHP_DIR));
  }
 catch (  IOException e) {
    Activator.getDefault().getLog().log(new Status(IStatus.ERROR,Activator.PLUGIN_ID,e.getMessage(),e));
    return null;
  }
  return new File(url.getPath()).getAbsolutePath();
}
 

Example 30

From project Mura-Tools-for-Eclipse-Core, under directory /src/com/muratools/eclipse/wizard/newTheme/.

Source file: NewThemePage.java

  19 
vote

private ArrayList<MuraTheme> loadThemes(){
  ArrayList<MuraTheme> themes=new ArrayList<MuraTheme>();
  Bundle bundle=Platform.getBundle("com.muratools.eclipse");
  File themeXML=null;
  URL fileURL=bundle.getEntry("static/MuraThemes.xml");
  ;
  try {
    themeXML=new File(FileLocator.resolve(fileURL).toURI());
  }
 catch (  URISyntaxException e1) {
    e1.printStackTrace();
  }
catch (  IOException e1) {
    e1.printStackTrace();
  }
  Builder parser=new Builder();
  Document doc=null;
  try {
    doc=parser.build(themeXML);
  }
 catch (  ParsingException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
  if (doc != null) {
    Element root=doc.getRootElement();
    Elements themeElements=root.getChildElements("theme");
    for (int i=0; i < themeElements.size(); i++) {
      Element themeElement=themeElements.get(i);
      Attribute name=themeElement.getAttribute("name");
      Attribute fileName=themeElement.getAttribute("fileName");
      Attribute url=themeElement.getAttribute("url");
      MuraTheme theme=new MuraTheme(name.getValue(),url.getValue(),fileName.getValue());
      themes.add(theme);
    }
  }
  return themes;
}
 

Example 31

From project mwe, under directory /plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/.

Source file: MWEPlugin.java

  19 
vote

/** 
 * Use the platform to convert to a local URI.
 */
protected static URI asLocalURI(final URI uri){
  try {
    final String fragment=uri.fragment();
    final URL url=FileLocator.toFileURL(new URL(uri.trimFragment().toString()));
    return fix(url,fragment);
  }
 catch (  final IOException exception) {
  }
  return uri;
}
 

Example 32

From project mylyn.context, under directory /org.eclipse.mylyn.context.sdk.java/src/org/eclipse/mylyn/context/sdk/java/.

Source file: TestJavaProject.java

  19 
vote

private Path findFileInPlugin(Plugin plugin,String file) throws MalformedURLException, IOException {
  URL pluginURL=plugin.getBundle().getEntry("/");
  URL jarURL=new URL(pluginURL,file);
  URL localJarURL=FileLocator.toFileURL(jarURL);
  return new Path(localJarURL.getPath());
}
 

Example 33

From project mylyn.docs, under directory /org.eclipse.mylyn.htmltext.ui/src/org/eclipse/mylyn/htmltext/.

Source file: HtmlComposer.java

  19 
vote

/** 
 * Constructs a new instance of a  {@link Browser} and includes a ckeditorinstance.
 * @param parent a composite control which will be the parent of the new instance (cannot be null)
 * @param style the style of control to construct
 * @param config the configuration for the html-widget
 * @see Browser#Browser(Composite,int)
 * @since 0.8
 */
public HtmlComposer(final Composite parent,final int style,Configuration config){
  browser=new Browser(parent,style);
  browser.setMenu(new Menu(browser));
  new RenderCompleteFunction(browser);
  URL baseUrl;
  try {
    baseUrl=FileLocator.resolve(FileLocator.find(HtmlTextActivator.getDefault().getBundle(),new Path("/eclipsebridge/base.html"),Collections.EMPTY_MAP));
    browser.setUrl(baseUrl.toString() + (config != null ? "?" + config.toQuery() : ""));
    browser.addProgressListener(new ProgressAdapter(){
      @Override public void completed(      ProgressEvent event){
        browser.execute("integration.eclipseRunning = true;");
        browser.removeProgressListener(this);
      }
    }
);
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
 

Example 34

From project mylyn.docs.intent.main, under directory /plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/services/.

Source file: CopyImageUtils.java

  19 
vote

/** 
 * Determines the image associated to the given EObject, copies it inside the exported documentation and
 * @param any the eobject to get the image from
 * @param repositoryAdapter the repository adapter to use to access to informations (traceability index...)
 * @param outputFolder
 * @return the image associated to the given EObject
 */
public static String copyImageAndGetImageID(EObject any,RepositoryAdapter repositoryAdapter,File outputFolder){
  String qualifiedImageID="";
  Object imageURL=getImageURL(any);
  if (imageURL instanceof URL) {
    try {
      URL resolvedURL=FileLocator.resolve((URL)imageURL);
      if (resolvedURL.toString().contains("org.eclipse.emf.edit") && resolvedURL.toString().endsWith("/icons/full/obj16/Item.gif")) {
        if ((imageURL=getImageFromWorkspace((EClassifier)any,repositoryAdapter)) != null) {
          resolvedURL=(URL)imageURL;
        }
      }
      qualifiedImageID=copyImageIfNeeded((EClassifier)any,outputFolder,resolvedURL,resolvedURL.openStream());
    }
 catch (    IOException e) {
      IntentUiLogger.logError(e);
    }
  }
  return qualifiedImageID;
}
 

Example 35

From project Newsreader, under directory /bundles/org.eclipse.ecf.salvo.ui/src/org/eclipse/ecf/salvo/ui/tools/.

Source file: ImageUtils.java

  19 
vote

/** 
 * Create image descriptors 
 * @param imageName image file name with extension
 * @return
 */
private ImageDescriptor createImageDescriptor(String imageName){
  if (imageName == null)   return null;
  ImageDescriptor imageDescriptor=null;
  IPath path=new Path(getImageLocation() + imageName);
  URL gifImageURL=FileLocator.find(getBundle(),path,null);
  if (gifImageURL != null) {
    imageDescriptor=ImageDescriptor.createFromURL(gifImageURL);
  }
  return imageDescriptor;
}
 

Example 36

From project org.openscada.dakara, under directory /org.openscada.vi.ui.user/src/org/openscada/vi/ui/user/.

Source file: Activator.java

  19 
vote

private static URI makeUri(final String contributerId,final String resource,final String uri) throws URISyntaxException {
  if (uri != null && !uri.isEmpty()) {
    return new URI(uri);
  }
  final Bundle bundle=Platform.getBundle(contributerId);
  return FileLocator.find(bundle,new Path(resource),new HashMap<String,String>()).toURI();
}
 

Example 37

From project org.ops4j.pax.runner, under directory /pax-runner-eclipse/pax-runner-eclipse-core/src/main/java/org/ops4j/pax/cursor/.

Source file: LaunchConfiguration.java

  19 
vote

/** 
 * Returns the classpath for Pax Runner Eclipse Plugin. First it looks for Pax Runner Eclipse plugin into the target platform. If not found will fallback to finding the plugin into the platform itself. If still not found a core exception is thrown to indicate to user that Pax Runner Eclipse Plugin is not available.
 * @return classpath for Pax Runner Eclipse Plugin
 * @throws org.eclipse.core.runtime.CoreException - If claspath cannopt be determined
 */
private String getPaxCursorClasspath() throws CoreException {
  String classpath=null;
  final IPluginModelBase plugin=PluginRegistry.findModel(Utils.PLUGIN_ID);
  if (plugin != null) {
    classpath=plugin.getInstallLocation();
  }
 else {
    final Bundle bundle=Platform.getBundle(Utils.PLUGIN_ID);
    if (bundle != null) {
      try {
        URL url=FileLocator.toFileURL(FileLocator.resolve(bundle.getEntry("/")));
        classpath=url.getFile();
        if (classpath.startsWith("file:")) {
          classpath=classpath.substring(5);
        }
        classpath=new File(classpath).getAbsolutePath();
        if (classpath.endsWith("!")) {
          classpath=classpath.substring(0,classpath.length() - 1);
        }
      }
 catch (      IOException e) {
      }
    }
  }
  if (classpath == null) {
    throw new CoreException(LauncherUtils.createErrorStatus(PDEUIMessages.WorkbenchLauncherConfigurationDelegate_noStartup));
  }
  return classpath;
}
 

Example 38

From project phing-eclipse, under directory /org.ganoro.phing.core/src/org/ganoro/phing/core/.

Source file: AntCorePreferences.java

  19 
vote

private URL getClasspathEntryURL(Bundle bundle,String library) throws IOException {
  File urlFile;
  if (library.equals("/")) {
    urlFile=FileLocator.getBundleFile(bundle);
  }
 else {
    urlFile=new File(FileLocator.toFileURL(bundle.getEntry(library)).getPath());
  }
  if (!urlFile.exists())   return null;
  String path=urlFile.getAbsolutePath();
  return new URL(IPhingCoreConstants.FILE_PROTOCOL + (urlFile.isDirectory() ? path + "/" : path));
}
 

Example 39

From project phresco-eclipse, under directory /com.photon.phresco.ui/src/com/photon/phresco/ui/wizards/.

Source file: PhrescoProjectWizard.java

  19 
vote

@Override public void init(IWorkbench workbench,IStructuredSelection selection){
  ImageDescriptor myImage=ImageDescriptor.createFromURL(FileLocator.find(Activator.getDefault().getBundle(),new Path("icons/phresco.png"),null));
  super.setDefaultPageImageDescriptor(myImage);
  super.setNeedsProgressMonitor(true);
  super.setWindowTitle("Phresco");
  try {
    doLogin();
  }
 catch (  PhrescoException e) {
    e.printStackTrace();
  }
}
 

Example 40

From project radrails, under directory /plugins/com.aptana.radrails.intro/src/com/aptana/radrails/intro/editors/.

Source file: MyRadRailsPageLoader.java

  19 
vote

public static String getURLLocation(){
  try {
    if (OnlineDetectionService.isAvailable(new URL(REMOTE_FILE_URL))) {
      Job job=new Job("Caching My RadRails Page"){
        protected IStatus run(        IProgressMonitor monitor){
          try {
            InputStream in=(InputStream)getRemoteFileURL().getContent();
            saveCache(in);
          }
 catch (          IOException e) {
            error(e);
          }
          return Status.OK_STATUS;
        }
      }
;
      job.setSystem(true);
      job.setPriority(Job.BUILD);
      job.schedule();
      return REMOTE_FILE_URL;
    }
  }
 catch (  MalformedURLException e) {
  }
  File file=getLocalCacheFile();
  if (file.exists()) {
    return file.getAbsolutePath();
  }
  URL rootPath=Activator.getDefault().getBundle().getEntry(LOCAL_URL);
  try {
    rootPath=FileLocator.toFileURL(rootPath);
    return rootPath.getPath();
  }
 catch (  IOException e) {
    error(e);
  }
  return REMOTE_FILE_URL;
}
 

Example 41

From project rascal-eclipse, under directory /src/org/rascalmpl/eclipse/nature/.

Source file: ProjectEvaluatorFactory.java

  19 
vote

private String jarForPlugin(String pluginName) throws IOException {
  URL rascalURI=FileLocator.resolve(Platform.getBundle(pluginName).getEntry("/"));
  try {
    if (rascalURI.getProtocol().equals("jar")) {
      String path=rascalURI.toURI().toASCIIString();
      return path.substring(path.indexOf("/"),path.indexOf('!'));
    }
 else {
      String path=rascalURI.getPath();
      File folder=new File(path);
      if (folder.isDirectory()) {
        File[] list=folder.listFiles();
        for (        File f : list) {
          if (f.getName().startsWith(pluginName) && f.getName().endsWith(".jar")) {
            return f.getAbsolutePath();
          }
        }
      }
      return path;
    }
  }
 catch (  URISyntaxException e) {
    throw new IOException(e);
  }
}
 

Example 42

From project recommenders, under directory /plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/rcp/.

Source file: SnipMatchPlugin.java

  19 
vote

protected void initializeImageRegistry(ImageRegistry imageRegistry){
  super.initializeImageRegistry(imageRegistry);
  Bundle bundle=Platform.getBundle(PLUGIN_ID);
  ImageDescriptor imgDesc=ImageDescriptor.createFromURL(FileLocator.find(bundle,new Path("images/warning.gif"),null));
  imageRegistry.put("warning",imgDesc);
  imgDesc=ImageDescriptor.createFromURL(FileLocator.find(bundle,new Path("images/thumbs_up.gif"),null));
  imageRegistry.put("thumbs_up",imgDesc);
  imgDesc=ImageDescriptor.createFromURL(FileLocator.find(bundle,new Path("images/thumbs_down.gif"),null));
  imageRegistry.put("thumbs_down",imgDesc);
  imgDesc=ImageDescriptor.createFromURL(FileLocator.find(bundle,new Path("images/flag.gif"),null));
  imageRegistry.put("flag",imgDesc);
  imgDesc=ImageDescriptor.createFromURL(FileLocator.find(bundle,new Path("images/comment.gif"),null));
  imageRegistry.put("comment",imgDesc);
}
 

Example 43

From project rj-core, under directory /de.walware.rj.server/srcEExtensions/de/walware/rj/rsetups/.

Source file: RSetupUtil.java

  19 
vote

private static String getLocation(final IConfigurationElement element,final Map<String,String> filter) throws Exception {
  final Bundle bundle=Platform.getBundle(element.getContributor().getName());
  final String path=element.getAttribute(LOCATION_ATTRIBUTE_NAME);
  if (bundle != null && path != null && path.length() > 0) {
    final URL[] bundleURLs=FileLocator.findEntries(bundle,new Path(path),filter);
    for (int i=0; i < bundleURLs.length; i++) {
      final URI fileURI=URIUtil.toURI(FileLocator.toFileURL(bundleURLs[i]));
      if (fileURI.getScheme().equals("file")) {
        final File file=new File(fileURI);
        if (file.exists() && file.isDirectory() && file.list().length > 0) {
          return file.getAbsolutePath();
        }
      }
    }
  }
  return null;
}
 

Example 44

From project rj-servi, under directory /de.walware.rj.servi/srcEExtensions/de/walware/rj/servi/pool/.

Source file: RServiImplE.java

  19 
vote

public static final String getLocalhostPolicyFile() throws RjInvalidConfigurationException {
  try {
    final Bundle bundle=Platform.getBundle(RJ_SERVER_ID);
    if (bundle == null) {
      throw new RjInvalidConfigurationException("RJ Server bundle ('" + RJ_SERVER_ID + "') is missing.");
    }
    final URL intern=bundle.getEntry("/localhost.policy");
    final URL java=FileLocator.resolve(intern);
    final String path=java.toExternalForm();
    return path;
  }
 catch (  final IOException e) {
    throw new RjInvalidConfigurationException("Failed to resolve path to 'localhost.policy'.",e);
  }
}
 

Example 45

From project scisoft-icat, under directory /uk.ac.diamond.scisoft.icatexplorer.rcp/src/uk/ac/diamond/scisoft/icatexplorer/rcp/preferences/.

Source file: ICATPreferenceInitializer.java

  19 
vote

private File getPluginsDirectory(){
  Bundle b=Platform.getBundle(ICATExplorerActivator.PLUGIN_ID);
  logger.debug("Bundle: {}",b);
  try {
    File f=FileLocator.getBundleFile(b);
    logger.debug("Bundle location: {}",f.getParent());
    return f.getParentFile();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  return null;
}
 

Example 46

From project scisoft-ui, under directory /uk.ac.diamond.scisoft/src/uk/ac/diamond/scisoft/.

Source file: JythonCreator.java

  19 
vote

private File getPluginsDirectory(){
  Bundle b=Platform.getBundle(Activator.PLUGIN_ID);
  logger.debug("Bundle: {}",b);
  try {
    File f=FileLocator.getBundleFile(b).getParentFile();
    logger.debug("Bundle location: {}",f.getAbsolutePath());
    if (isRunningInEclipse) {
      File gitws=f.getParentFile().getParentFile();
      File parent=gitws.getParentFile();
      String wsName=gitws.getName().replace(GIT_SUFFIX,"");
      File plugins=new File(new File(parent,wsName),"plugins");
      if (plugins.isDirectory()) {
        logger.debug("Plugins location: {}",plugins);
        return plugins;
      }
    }
    return f;
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  return null;
}
 

Example 47

From project studio2-rcp, under directory /plugins/com.aptana.ide.rcp/src/com/aptana/ide/rcp/.

Source file: AptanaCheatSheetViewer.java

  19 
vote

private String getContent(CheatSheetElement element){
  contentElement=element;
  contentURL=null;
  if (element != null) {
    Bundle bundle=null;
    if (element != null && element.getConfigurationElement() != null) {
      try {
        String pluginId=element.getConfigurationElement().getContributor().getName();
        bundle=Platform.getBundle(pluginId);
      }
 catch (      Exception e) {
      }
    }
    if (bundle != null) {
      contentURL=FileLocator.find(bundle,new Path(element.getContentFile()),null);
    }
    if (contentURL == null) {
      URL checker;
      try {
        checker=new URL(element.getContentFile());
        if (checker.getProtocol().equalsIgnoreCase("http")) {
          contentURL=checker;
        }
      }
 catch (      MalformedURLException mue) {
      }
    }
  }
  return readFile();
}
 

Example 48

From project studio3-ruby, under directory /plugins/com.aptana.ruby.core/src/com/aptana/ruby/internal/core/index/.

Source file: CoreStubber.java

  19 
vote

protected void generateCoreStubs(IPath rubyExe,File outputDir,File finishMarker) throws IOException {
  URL url=FileLocator.find(RubyCorePlugin.getDefault().getBundle(),new Path(CORE_STUBBER_PATH),null);
  File stubberScript=ResourceUtil.resourcePathToFile(url);
  Map<String,String> env=null;
  if (!Platform.OS_WIN32.equals(Platform.getOS())) {
    env=ShellExecutable.getEnvironment();
  }
  IStatus stubberResult=ProcessUtil.runInBackground((rubyExe == null) ? "ruby" : rubyExe.toOSString(),null,env,stubberScript.getAbsolutePath(),outputDir.getAbsolutePath());
  if (stubberResult == null || !stubberResult.isOK()) {
    RubyCorePlugin.getDefault().getLog().log(new Status(IStatus.ERROR,RubyCorePlugin.PLUGIN_ID,(stubberResult == null) ? StringUtil.EMPTY : stubberResult.getMessage(),null));
  }
 else {
    finishMarker.createNewFile();
  }
}
 

Example 49

From project substeps-eclipse-plugin, under directory /com.technophobia.substeps.testlauncher/src/main/java/com/technophobia/substeps/junit/launcher/.

Source file: ClasspathLocalizer.java

  19 
vote

private String localURL(final SubstepsRuntimeClasspathEntry jar) throws IOException, MalformedURLException {
  final Bundle bundle=FeatureRunnerPlugin.instance().getBundle(jar.getPluginId());
  URL url;
  if (jar.getPluginRelativePath() == null)   url=bundle.getEntry("/");
 else   url=bundle.getEntry(jar.getPluginRelativePath());
  if (url == null)   throw new IOException();
  return FileLocator.toFileURL(url).getFile();
}
 

Example 50

From project sveditor, under directory /sveditor/plugins/net.sf.sveditor.core/src/net/sf/sveditor/core/.

Source file: SVCorePlugin.java

  19 
vote

public static StringBuilder readResourceFile(IConfigurationElement element,String attr){
  Bundle bundle=Platform.getBundle(element.getContributor().getName());
  String filePath=element.getAttribute(attr);
  if (filePath != null) {
    URL fileURL=FileLocator.find(bundle,new Path(filePath),null);
    if (fileURL != null) {
      try {
        StringBuilder sb=new StringBuilder();
        InputStream in=fileURL.openStream();
        byte tmp[]=new byte[1024 * 8];
        int sz;
        while ((sz=in.read(tmp,0,tmp.length)) > 0) {
          for (int i=0; i < sz; i++) {
            sb.append(tmp[i]);
          }
        }
        in.close();
        return sb;
      }
 catch (      IOException e) {
      }
    }
  }
  return null;
}
 

Example 51

From project swtbot, under directory /org.eclipse.ui.forms.examples/src/org/eclipse/ui/forms/examples/internal/.

Source file: ExamplesPlugin.java

  19 
vote

private void registerImage(ImageRegistry registry,String key,String fileName){
  try {
    IPath path=new Path("icons/" + fileName);
    URL url=FileLocator.find(getBundle(),path,null);
    if (url != null) {
      ImageDescriptor desc=ImageDescriptor.createFromURL(url);
      registry.put(key,desc);
    }
  }
 catch (  Exception e) {
  }
}
 

Example 52

From project UML-Java-Generation, under directory /tests/org.obeonetwork.pim.uml2.gen.java.ui.tests/src/org/obeonetwork/pim/uml2/gen/java/ui/tests/.

Source file: AbstractSWTBotTests.java

  19 
vote

private static File createFile(String pathName){
  try {
    String fileLocation=FileLocator.resolve(bundle.getEntry(pathName)).getPath();
    return new File(fileLocation);
  }
 catch (  IOException e) {
    throw new AssertionFailedError(e.getMessage());
  }
catch (  NullPointerException e) {
    throw new AssertionFailedError(e.getMessage());
  }
}
 

Example 53

From project Vega, under directory /platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/info/.

Source file: AlertRenderer.java

  19 
vote

private String findImage(String imagePath){
  Bundle b=Activator.getDefault().getBundle();
  IPath relativePagePath=new Path(imagePath);
  URL fileInPlugin=FileLocator.find(b,relativePagePath,null);
  try {
    URL pageUrl=FileLocator.toFileURL(fileInPlugin);
    return pageUrl.toString();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  return null;
}
 

Example 54

From project warlock2, under directory /core/cc.warlock.rcp/src/cc/warlock/rcp/application/.

Source file: WarlockUpdates.java

  19 
vote

protected static Properties getUpdateProperties(){
  if (updateProperties == null) {
    updateProperties=new Properties();
    try {
      InputStream stream=FileLocator.openStream(Warlock2Plugin.getDefault().getBundle(),new Path("warlock-updates.properties"),false);
      updateProperties.load(stream);
      stream.close();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
  return updateProperties;
}
 

Example 55

From project xwiki-eclipse, under directory /plugins/org.xwiki.eclipse.test/src/main/java/org/xwiki/eclipse/rest/.

Source file: XWikiRESTClientTest.java

  19 
vote

@Test public void testUploadAttachment(){
  String serverUrl="http://localhost:8080/xwiki/rest";
  String attachmentName="notice.html";
  String attachmentURL="http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/myspace/pages/WebHome/attachments/" + attachmentName;
  String username="XWiki.Admin";
  String password="admin";
  XWikiRestClient client=new XWikiRestClient(serverUrl,username,password);
  try {
    URL url=FileLocator.find(bundle,new Path("src/main/resources/notice.html"),null);
    System.out.println("url = " + url.toString());
    URL fileUrl=FileLocator.toFileURL(url);
    URI fileUri=FileLocator.toFileURL(url).toURI();
    System.out.println("uri = " + fileUri);
    URI attachmentURI=new URI(attachmentURL);
    client.uploadAttachment(attachmentURI,attachmentName,fileUrl);
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
catch (  URISyntaxException e) {
    e.printStackTrace();
  }
}
 

Example 56

From project zest, under directory /org.eclipse.zest.dot.export/src/org/eclipse/zest/internal/dot/.

Source file: DotFileUtils.java

  19 
vote

/** 
 * @param url The URL to resolve (can be workspace-relative)
 * @return The file corresponding to the given URL
 */
public static File resolve(final URL url){
  File resultFile=null;
  URL resolved=url;
  if (!url.getProtocol().equals("file")) {
    try {
      resolved=FileLocator.resolve(resolved);
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
  try {
    resultFile=new File(resolved.toURI());
  }
 catch (  URISyntaxException e) {
    e.printStackTrace();
  }
  return resultFile;
}