Exemple #1
0
 private Cursor loadMouseCursor(
     String image, String mask, int hotspotX, int hotspotY, int fallbackCursorID) {
   URL imageUrl = null;
   try {
     imageUrl = Platform.asLocalURL(WorldPlugin.getDefault().find(new Path(image)));
     ImageData cursorZoomInImage = new ImageData(imageUrl.openConnection().getInputStream());
     imageUrl = Platform.asLocalURL(WorldPlugin.getDefault().find(new Path(mask)));
     ImageData cursorZoomInMask = new ImageData(imageUrl.openConnection().getInputStream());
     return new Cursor(
         Display.getCurrent(), cursorZoomInImage, cursorZoomInMask, hotspotX, hotspotY);
   } catch (Exception e) {
     return new Cursor(Display.getCurrent(), fallbackCursorID);
   }
 }
Exemple #2
0
  /**
   * Copies the gold folder to the runtime workspace CONTRACT: folder exists in the devspace,
   * goldFolder has been set In this implementation, the gold folder is copied from
   * bin/test/GoldFolder
   */
  public static void copyGoldFolder() {
    /* goldFolder (location where goldfolder should go in runspace) must not be null */
    Assert.assertTrue(goldFolder != null);

    Bundle model2testsBundle = EclipsePlugin.getDefault().getBundle();
    /* this is the source for our goldfolder in the devspace that we're copying to the runspace */
    URL gfURL = model2testsBundle.getEntry("/");

    /* devspace GoldFolder must exist */
    // Assert.assertTrue(goldFolder.exists());
    // Assert.assertTrue(gf.exists());
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot workspaceRoot = workspace.getRoot();
    IPath rootPath = workspaceRoot.getLocation();
    try {
      gfURL = Platform.asLocalURL(gfURL);
    } catch (IOException e) {
      e.printStackTrace();
    }
    System.out.println("URL path: " + gfURL.getPath());
    System.out.println("URL file: " + gfURL.getFile());
    System.out.println("URL ref: " + gfURL.getRef());
    File srcDir = new File(gfURL.getPath(), "GoldFolder");
    Path p = new Path(gfURL.getPath());
    IResource igf = ((Workspace) workspace).newResource(p, IResource.FOLDER);
    IPath gfpath = goldFolder.getFullPath();
    File destDir = new File(gfpath.toOSString());
    /* Make sure both of these directories exist */
    System.out.println("Source directory exists: " + srcDir.exists());
    /* destination directory shouldn't exist because we're going to create it */
    // System.out.println ("Dest directory exists: " + destDir.exists());
    /* Since assert isn't working for the moment... */
    if (!srcDir.exists()) {
      System.out.println("GoldFolder not found");
      Log.log("GoldFolder not found");
      Assert.fail("GoldFolder not found");
    }
    //		Assert.assertTrue("Source goldfolder does not exist", srcDir.exists());
    //		Assert.assertTrue("Destination goldfolder does not exist", destDir.exists());
    copyFolder(srcDir, destDir);
  }