Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 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());
 }
Ejemplo n.º 3
0
    @Override
    public boolean visit(IResourceDelta delta) throws CoreException {
      if (delta == null) {
        return false;
      }

      IFile file = getFile();
      if (file == null) {
        return false;
      }

      delta = delta.findMember(file.getFullPath());

      if (delta == null) {
        return false;
      }

      Runnable runnable = null;

      switch (delta.getKind()) {
        case IResourceDelta.CHANGED:
          FileInfo info = (FileInfo) getElementInfo(fileEditorInput);
          if (info == null || !canRefreshFromFile(info)) {
            break;
          }

          boolean isSynchronized = computeModificationStamp(file) == info.modificationStamp;
          if ((IResourceDelta.ENCODING & delta.getFlags()) != 0 && isSynchronized) {
            runnable =
                new SafeChange(fileEditorInput) {
                  @Override
                  protected void execute(IEditorInput input) throws Exception {
                    handleElementContentChanged(input);
                  }
                };
          }

          if (runnable == null
              && (IResourceDelta.CONTENT & delta.getFlags()) != 0
              && !isSynchronized) {
            runnable =
                new SafeChange(fileEditorInput) {
                  @Override
                  protected void execute(IEditorInput input) throws Exception {
                    handleElementContentChanged(input);
                  }
                };
          }
          break;

        case IResourceDelta.REMOVED:
          if ((IResourceDelta.MOVED_TO & delta.getFlags()) != 0) {
            final IPath path = delta.getMovedToPath();
            runnable =
                new SafeChange(fileEditorInput) {
                  @Override
                  protected void execute(IEditorInput input) throws Exception {
                    handleElementMoved(input, path);
                  }
                };
          } else {
            info = (FileInfo) getElementInfo(fileEditorInput);
            if (info != null && canRefreshFromFile(info)) {
              runnable =
                  new SafeChange(fileEditorInput) {
                    @Override
                    protected void execute(IEditorInput input) throws Exception {
                      handleElementDeleted(input);
                    }
                  };
            }
          }
          break;
      }

      if (runnable != null) {
        update(runnable);
      }

      return false;
    }