コード例 #1
0
 public void testLoadWindowsFile() throws Exception {
   setUpProject();
   WARProductModel model = new WARProductModel();
   String separator = File.separator;
   String fileName = separator + "testWin.warproduct";
   ClassLoader classLoader = getClass().getClassLoader();
   model.load(classLoader.getResourceAsStream(fileName), false);
   IWARProduct product = (IWARProduct) model.getProduct();
   IPath webXml = product.getWebXml();
   IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
   IPath absolutWebXmlPath = wsRoot.getLocation().append(webXml);
   File file = new File(absolutWebXmlPath.toOSString());
   assertTrue(file.exists());
 }
コード例 #2
0
  /**
   * The worker method. It will find the container, create the file if missing or just replace its
   * contents, and open the editor on the newly created file.
   */
  private void doFinish(String containerName, String fileName, IProgressMonitor monitor)
      throws CoreException {
    // create a sample file
    monitor.beginTask("Creating " + fileName, 2);
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IResource resource = root.findMember(new Path(containerName));

    // if (!(resource.exists()) || !(resource instanceof IContainer)) {
    if (resource == null || !(resource.exists()) || !(resource instanceof IContainer)) {
      // throwCoreException("Container \"" + containerName +
      // "\" does not exist.");
      IProject datamapperProject = root.getProject(containerName);
      datamapperProject.create(null);
      datamapperProject.open(null);
      // datamapperProject.
    }
    IContainer container = (IContainer) resource;
    //
    //
    // final IFile file = container.getFile(new Path(fileName));
    // try {
    // InputStream stream = openContentStream();
    // if (file.exists()) {
    // // file.setContents(null, true, true, monitor);
    // } else {
    // file.create(null, true, monitor);
    //
    // }
    // stream.close();`
    // } catch (IOException e) {
    // }
    // monitor.worked(1);
    // monitor.setTaskName("Opening file for editing...");
    // getShell().getDisplay().asyncExec(new Runnable() {
    // public void run() {
    // IWorkbenchPage page =
    // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    // try {
    // IDE.openEditor(page, file);
    // } catch (PartInitException e) {
    // }
    // }
    // });
    // monitor.worked(1);
  }
コード例 #3
0
 private static void setUpProject() throws Exception {
   IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
   IProject project = root.getProject("test.rap");
   if (!project.exists()) {
     project.create(null);
     project.open(null);
   }
   IFolder webInf = project.getFolder("WEB-INF");
   if (!webInf.exists()) {
     webInf.create(true, true, null);
   }
   IFile file = webInf.getFile("web.xml");
   if (!file.exists()) {
     File tempFile = File.createTempFile("test", ".xml");
     FileInputStream stream = new FileInputStream(tempFile);
     file.create(stream, true, null);
   }
 }
コード例 #4
0
ファイル: ValidatorTest.java プロジェクト: kaloyan-raev/libra
 public void testContainsServletBridgeLibrary() throws Exception {
   IWARProduct product = createBasicProduct();
   IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
   IProject project = wsRoot.getProject("warProduct");
   if (!project.exists()) {
     project.create(null);
     project.open(null);
   }
   IFile jar = project.getFile(SERVLETBRIDGE + ".jar");
   if (!jar.exists()) {
     File bridge = File.createTempFile(SERVLETBRIDGE, ".jar");
     FileInputStream stream = new FileInputStream(bridge);
     jar.create(stream, true, null);
   }
   product.addLibrary(jar.getFullPath(), false);
   Validator validator = new Validator(product);
   Validation validation = validator.validate();
   assertTrue(validation.isValid());
 }
コード例 #5
0
ファイル: CoffeeWizard.java プロジェクト: bndtools/aQute
 /**
  * The worker method. It will find the container, create the file if missing or just replace its
  * contents, and open the editor on the newly created file.
  */
 private void doFinish(String containerName, String fileName, IProgressMonitor monitor)
     throws CoreException {
   // create a sample file
   monitor.beginTask("Creating " + fileName, 2);
   IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
   IResource resource = root.findMember(new Path(containerName));
   if (!resource.exists() || !(resource instanceof IContainer)) {
     throwCoreException("Container \"" + containerName + "\" does not exist.");
   }
   IContainer container = (IContainer) resource;
   final IFile file = container.getFile(new Path(fileName));
   try {
     InputStream stream = openContentStream();
     if (file.exists()) {
       file.setContents(stream, true, true, monitor);
     } else {
       file.create(stream, true, monitor);
     }
     stream.close();
   } catch (IOException e) {
   }
   monitor.worked(1);
   monitor.setTaskName("Opening file for editing...");
   getShell()
       .getDisplay()
       .asyncExec(
           new Runnable() {
             public void run() {
               IWorkbenchPage page =
                   PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
               try {
                 IDE.openEditor(page, file, true);
               } catch (PartInitException e) {
               }
             }
           });
   monitor.worked(1);
 }
コード例 #6
0
ファイル: ValidatorTest.java プロジェクト: kaloyan-raev/libra
 private IWARProduct createBasicProductWithLibraries() throws Exception {
   IWARProduct product = createBasicProduct();
   IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
   IProject project = wsRoot.getProject("warProduct");
   if (!project.exists()) {
     project.create(null);
     project.open(null);
   }
   IFile jar = project.getFile("test.jar");
   if (!jar.exists()) {
     File testJar = File.createTempFile("test", ".jar");
     FileInputStream stream = new FileInputStream(testJar);
     jar.create(stream, true, null);
   }
   product.addLibrary(jar.getFullPath(), false);
   IFile bridge = project.getFile(SERVLETBRIDGE + ".jar");
   if (!bridge.exists()) {
     File bridgeJar = File.createTempFile(SERVLETBRIDGE, ".jar");
     FileInputStream stream = new FileInputStream(bridgeJar);
     bridge.create(stream, true, null);
   }
   product.addLibrary(bridge.getFullPath(), false);
   return product;
 }