Java Code Examples for org.eclipse.core.filesystem.URIUtil

The following examples show how to use org.eclipse.core.filesystem.URIUtil. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: orion.server   Source File: PackagerTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testCFIgnoreRules() throws Exception {

	ZipOutputStream mockZos = mock(ZipOutputStream.class);

	String LOCATION = "testData/packagerTest/01"; //$NON-NLS-1$
	URL entry = ServerTestsActivator.getContext().getBundle().getEntry(LOCATION);
	IFileStore source = EFS.getStore(URIUtil.toURI(FileLocator.toFileURL(entry).getPath()));

	PackageUtils.writeZip(source, mockZos);

	/* what is... */
	verify(mockZos).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry("test2.in")))); //$NON-NLS-1$
	verify(mockZos).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry(".cfignore")))); //$NON-NLS-1$
	verify(mockZos).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry("A")))); //$NON-NLS-1$
	verify(mockZos).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry("inner/test2.in")))); //$NON-NLS-1$
	verify(mockZos).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry("inner/inner2/test3.in")))); //$NON-NLS-1$

	/* ... and what should never be */
	verify(mockZos, never()).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry("test1.in")))); //$NON-NLS-1$
	verify(mockZos, never()).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry("inner/test1.in")))); //$NON-NLS-1$
	verify(mockZos, never()).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry("inner/inner2/inner3/test2.in")))); //$NON-NLS-1$
}
 
Example 2
Source Project: orion.server   Source File: PackagerTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testCFIgnoreNegation() throws Exception {
	ZipOutputStream mockZos = mock(ZipOutputStream.class);

	String LOCATION = "testData/packagerTest/02"; //$NON-NLS-1$
	URL entry = ServerTestsActivator.getContext().getBundle().getEntry(LOCATION);
	IFileStore source = EFS.getStore(URIUtil.toURI(FileLocator.toFileURL(entry).getPath()));

	PackageUtils.writeZip(source, mockZos);

	/* what is... */
	verify(mockZos).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry(".cfignore")))); //$NON-NLS-1$
	verify(mockZos).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry("A/B/.cfignore")))); //$NON-NLS-1$
	verify(mockZos).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry("A/B/test.in")))); //$NON-NLS-1$

	/* ... and what should never be */
	verify(mockZos, never()).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry("A/B/test2.in")))); //$NON-NLS-1$
}
 
Example 3
Source Project: orion.server   Source File: ManifestUtilsTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testSingleInheritancePropagation() throws Exception {
	String MANIFEST_LOCATION = "testData/manifestTest/inheritance/01"; //$NON-NLS-1$
	String manifestName = "prod-manifest.yml"; //$NON-NLS-1$

	URL entry = ServerTestsActivator.getContext().getBundle().getEntry(MANIFEST_LOCATION);
	IFileStore fs = EFS.getStore(URIUtil.toURI(FileLocator.toFileURL(entry).getPath().concat(manifestName)));

	ManifestParseTree manifest = ManifestUtils.parse(fs.getParent(), fs);
	ManifestParseTree applications = manifest.get("applications"); //$NON-NLS-1$
	assertEquals(4, applications.getChildren().size());

	for (ManifestParseTree application : applications.getChildren()) {
		assertTrue(application.has("domain")); //$NON-NLS-1$
		assertTrue(application.has("instances")); //$NON-NLS-1$
		assertTrue(application.has("path")); //$NON-NLS-1$
		assertTrue(application.has("memory")); //$NON-NLS-1$
	}
}
 
Example 4
Source Project: orion.server   Source File: ManifestUtilsTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testSingleRelativeInheritance() throws Exception {
	String MANIFEST_LOCATION = "testData/manifestTest/inheritance/02/inner"; //$NON-NLS-1$
	String manifestName = "prod-manifest.yml"; //$NON-NLS-1$

	URL entry = ServerTestsActivator.getContext().getBundle().getEntry(MANIFEST_LOCATION);
	IFileStore fs = EFS.getStore(URIUtil.toURI(FileLocator.toFileURL(entry).getPath().concat(manifestName)));

	ManifestParseTree manifest = ManifestUtils.parse(fs.getParent().getParent(), fs);
	ManifestParseTree applications = manifest.get("applications"); //$NON-NLS-1$
	assertEquals(2, applications.getChildren().size());

	for (ManifestParseTree application : applications.getChildren()) {
		assertTrue(application.has("domain")); //$NON-NLS-1$
		assertTrue(application.has("instances")); //$NON-NLS-1$
		assertTrue(application.has("path")); //$NON-NLS-1$
		assertTrue(application.has("memory")); //$NON-NLS-1$
	}
}
 
Example 5
Source Project: orion.server   Source File: ManifestUtilsTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testFlatSingleRelativeInheritance() throws Exception {
	String MANIFEST_LOCATION = "testData/manifestTest/inheritance/03"; //$NON-NLS-1$
	String manifestName = "prod-manifest.yml"; //$NON-NLS-1$

	URL entry = ServerTestsActivator.getContext().getBundle().getEntry(MANIFEST_LOCATION);
	IFileStore fs = EFS.getStore(URIUtil.toURI(FileLocator.toFileURL(entry).getPath().concat(manifestName)));

	ManifestParseTree manifest = ManifestUtils.parse(fs.getParent(), fs);

	ManifestParseTree applications = manifest.get("applications"); //$NON-NLS-1$
	assertEquals(1, applications.getChildren().size());

	ManifestParseTree application = applications.get(0);

	assertEquals("512M", application.get("memory").getValue()); //$NON-NLS-1$//$NON-NLS-2$
	assertEquals("2", application.get("instances").getValue()); //$NON-NLS-1$//$NON-NLS-2$
	assertEquals("example.com", application.get("domain").getValue()); //$NON-NLS-1$//$NON-NLS-2$
	assertEquals(".", application.get("path").getValue()); //$NON-NLS-1$//$NON-NLS-2$
}
 
Example 6
Source Project: orion.server   Source File: ManifestUtilsTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testFlatComplexInheritance() throws Exception {
	String MANIFEST_LOCATION = "testData/manifestTest/inheritance/06"; //$NON-NLS-1$
	String manifestName = "final-manifest.yml"; //$NON-NLS-1$

	URL entry = ServerTestsActivator.getContext().getBundle().getEntry(MANIFEST_LOCATION);
	IFileStore fs = EFS.getStore(URIUtil.toURI(FileLocator.toFileURL(entry).getPath().concat(manifestName)));

	ManifestParseTree manifest = ManifestUtils.parse(fs.getParent(), fs);
	ManifestParseTree applications = manifest.get("applications"); //$NON-NLS-1$
	assertEquals(2, applications.getChildren().size());

	for (ManifestParseTree application : applications.getChildren()) {
		assertTrue(application.has("domain")); //$NON-NLS-1$
		assertTrue(application.has("instances")); //$NON-NLS-1$
		assertTrue(application.has("memory")); //$NON-NLS-1$

		if ("A".equals(application.get("name").getValue())) //$NON-NLS-1$ //$NON-NLS-2$
			assertTrue("2".equals(application.get("instances").getValue())); //$NON-NLS-1$ //$NON-NLS-2$
	}
}
 
Example 7
Source Project: orion.server   Source File: ManifestUtilsTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testComplexInheritance() throws Exception {
	String MANIFEST_LOCATION = "testData/manifestTest/inheritance/08/A/inner"; //$NON-NLS-1$
	String manifestName = "final-manifest.yml"; //$NON-NLS-1$

	URL entry = ServerTestsActivator.getContext().getBundle().getEntry(MANIFEST_LOCATION);
	IFileStore fs = EFS.getStore(URIUtil.toURI(FileLocator.toFileURL(entry).getPath().concat(manifestName)));

	ManifestParseTree manifest = ManifestUtils.parse(fs.getParent().getParent().getParent(), fs);
	ManifestParseTree applications = manifest.get("applications"); //$NON-NLS-1$
	assertEquals(2, applications.getChildren().size());

	for (ManifestParseTree application : applications.getChildren()) {
		assertTrue(application.has("domain")); //$NON-NLS-1$
		assertTrue(application.has("instances")); //$NON-NLS-1$
		assertTrue(application.has("memory")); //$NON-NLS-1$

		if ("A".equals(application.get("name").getValue())) //$NON-NLS-1$ //$NON-NLS-2$
			assertTrue("2".equals(application.get("instances").getValue())); //$NON-NLS-1$ //$NON-NLS-2$
	}
}
 
Example 8
Source Project: orion.server   Source File: ManifestUtilsTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testEnvInheritance() throws Exception {
	String MANIFEST_LOCATION = "testData/manifestTest/inheritance/09"; //$NON-NLS-1$
	String manifestName = "prod-manifest.yml"; //$NON-NLS-1$

	URL entry = ServerTestsActivator.getContext().getBundle().getEntry(MANIFEST_LOCATION);
	IFileStore fs = EFS.getStore(URIUtil.toURI(FileLocator.toFileURL(entry).getPath().concat(manifestName)));

	ManifestParseTree manifest = ManifestUtils.parse(fs.getParent(), fs);

	ManifestParseTree applications = manifest.get("applications"); //$NON-NLS-1$
	assertEquals(1, applications.getChildren().size());

	ManifestParseTree env = manifest.get("env"); //$NON-NLS-1$
	assertEquals(2, env.getChildren().size());

	assertEquals("base", env.get("TEST").getValue()); //$NON-NLS-1$//$NON-NLS-2$
	assertEquals("overridden", env.get("TEST2").getValue()); //$NON-NLS-1$//$NON-NLS-2$
}
 
Example 9
Source Project: xds-ide   Source File: LocationSelector.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns the selected workspace container,or <code>null</code>
 */
protected IContainer getContainer() {
    String path = getLocationTxt();
    if (path.length() > 0) {
        IResource res = null;
        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
        if (path.startsWith("${workspace_loc:")) { //$NON-NLS-1$
            try {
                path = VariableUtils.performStringSubstitution(path, false);
                IPath uriPath = new Path(path).makeAbsolute();
                IContainer[] containers = root.findContainersForLocationURI(URIUtil.toURI(uriPath));
                if (containers.length > 0) {
                    res = containers[0];
                }
            } catch (CoreException e) {
            }
        } else {
            res = root.findMember(path);
        }
        if (res instanceof IContainer) {
            return (IContainer) res;
        }
    }
    return (browseProject != null) ? browseProject : ResourcesPlugin.getWorkspace().getRoot();
}
 
Example 10
protected java.net.URI toURI(final URI uri, final List<String> trailingSegments) {
  java.net.URI _xblockexpression = null;
  {
    final IResource resource = this.findMember(uri);
    if ((resource == null)) {
      String _lastSegment = uri.lastSegment();
      trailingSegments.add(_lastSegment);
      return this.toURI(uri.trimSegments(1), trailingSegments);
    }
    final Function2<IPath, String, IPath> _function = (IPath $0, String $1) -> {
      return $0.append($1);
    };
    _xblockexpression = URIUtil.toURI(IterableExtensions.<String, IPath>fold(ListExtensions.<String>reverse(trailingSegments), resource.getLocation(), _function));
  }
  return _xblockexpression;
}
 
Example 11
private void importGWTProjects() throws Exception {
  IWorkspace workspace = ResourcesPlugin.getWorkspace();
  String platform = Util.getPlatformName();
  String gwtDevProjectName = "gwt-dev-" + platform;

  // Get the path to the Eclipse project files for GWT
  IPath gwtProjectsDir = URIUtil.toPath(workspace.getPathVariableManager().getURIValue("GWT_ROOT")).append("eclipse");

  // Import gwt-dev
  IPath gwtDevDir = gwtProjectsDir.append("dev").append(platform);
  importProject(gwtDevProjectName, gwtDevDir);

  // Import gwt-user
  IPath gwtUserDir = gwtProjectsDir.append("user");
  importProject("gwt-user", gwtUserDir);
}
 
Example 12
/**
 * Imports the gwt-dev and gwt-user projects into the workspace.
 *
 * @see #removeGwtSourceProjects()
 */
public static void importGwtSourceProjects() throws CoreException {
  IWorkspace workspace = ResourcesPlugin.getWorkspace();
  String gwtDevProjectName = "gwt-dev";

  // Get the path to the Eclipse project files for GWT
  URI gwtProjectsUri = workspace.getPathVariableManager().getURIValue("GWT_ROOT");
  IPath gwtProjectsDir = URIUtil.toPath(gwtProjectsUri).append("eclipse");

  // Import gwt-dev
  IPath gwtDevDir = gwtProjectsDir.append("dev");
  ProjectUtilities.importProject(gwtDevProjectName, gwtDevDir);

  // Import gwt-user
  IPath gwtUserDir = gwtProjectsDir.append("user");
  ProjectUtilities.importProject("gwt-user", gwtUserDir);
}
 
Example 13
protected IProject createProject(IProgressMonitor monitor) throws CoreException {
  IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
  IProject project = workspaceRoot.getProject(projectName);
  if (!project.exists()) {
    URI uri;
    if (isWorkspaceRootLocationURI(locationURI)) {
      // If you want to put a project in the workspace root then the location
      // needs to be null...
      uri = null;
    } else {
      // Non-default paths need to include the project name
      IPath path = URIUtil.toPath(locationURI).append(projectName);
      uri = URIUtil.toURI(path);
    }

    BuildPathsBlock.createProject(project, uri, monitor);
  }
  return project;
}
 
Example 14
Source Project: gama   Source File: FileUtils.java    License: GNU General Public License v3.0 6 votes vote down vote up
private static IFile createLinkedFile(final String path, final IFile file) {
	java.net.URI resolvedURI = null;
	final java.net.URI javaURI = URIUtil.toURI(path);// new java.io.File(path).toURI();

	try {
		resolvedURI = ROOT.getPathVariableManager().convertToRelative(javaURI, true, null);
	} catch (final CoreException e1) {
		resolvedURI = javaURI;
	}
	try {
		file.createLink(resolvedURI, IResource.NONE, null);
	} catch (final CoreException e) {
		e.printStackTrace();
		return null;
	}
	return file;
}
 
Example 15
Source Project: APICloud-Studio   Source File: UIUtils.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the URI for the specific editor input.
 * 
 * @param input
 *            the editor input
 * @return the URI, or null if none could be determined
 */
public static URI getURI(IEditorInput input)
{
	if (input instanceof IFileEditorInput)
	{
		return ((IFileEditorInput) input).getFile().getLocationURI();
	}
	if (input instanceof IURIEditorInput)
	{
		return ((IURIEditorInput) input).getURI();
	}
	if (input instanceof IPathEditorInput)
	{
		return URIUtil.toURI(((IPathEditorInput) input).getPath());
	}
	return null;
}
 
Example 16
private IPath getPath(IEditorPart otherEditor)
{
	IEditorInput input = otherEditor.getEditorInput();
	try
	{
		if (input instanceof IPathEditorInput)
		{
			return ((IPathEditorInput) input).getPath();
		}

		URI uri = (URI) input.getAdapter(URI.class);
		if (uri != null)
		{
			return new Path(uri.getHost() + Path.SEPARATOR + uri.getPath());
		}
		if (input instanceof IURIEditorInput)
		{
			return URIUtil.toPath(((IURIEditorInput) input).getURI());
		}
	}
	catch (Exception e)
	{
	}
	return null;
}
 
Example 17
/**
 *	Open an appropriate destination browser so that the user can specify a source
 *	to import from
 */
protected void handleDestinationBrowseButtonPressed() {
	FileDialog dialog= new FileDialog(getContainer().getShell(), SWT.SAVE);
	dialog.setFilterExtensions(ArchiveFileFilter.JAR_ZIP_FILTER_EXTENSIONS);

	String currentSourceString= getDestinationValue();
	int lastSeparatorIndex= currentSourceString.lastIndexOf(File.separator);
	if (lastSeparatorIndex != -1) {
		dialog.setFilterPath(currentSourceString.substring(0, lastSeparatorIndex));
		dialog.setFileName(currentSourceString.substring(lastSeparatorIndex + 1, currentSourceString.length()));
	}
	String selectedFileName= dialog.open();
	if (selectedFileName != null) {
		IContainer[] findContainersForLocation= ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(URIUtil.toURI(new Path(selectedFileName).makeAbsolute()));
		if (findContainersForLocation.length > 0) {
			selectedFileName= findContainersForLocation[0].getFullPath().makeRelative().toString();
		}
		fDestinationNamesCombo.setText(selectedFileName);
	}
}
 
Example 18
private IContainer[] getSourceContainers(Element element) {
	String sourcePaths= element.getAttribute(SOURCEPATH);

	if (sourcePaths.endsWith(File.pathSeparator)) {
		sourcePaths += '.';
	}
	IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();

	ArrayList<IContainer> res= new ArrayList<IContainer>();

	String[] strings= sourcePaths.split(File.pathSeparator);
	for (int i= 0; i < strings.length; i++) {
		IPath path= makeAbsolutePathFromRelative(new Path(strings[i].trim()));
		if (path != null) {
			IContainer[] containers= root.findContainersForLocationURI(URIUtil.toURI(path.makeAbsolute()));
			for (int k= 0; k < containers.length; k++) {
				res.add(containers[k]);
			}
		}

	}
	return res.toArray(new IContainer[res.size()]);
}
 
Example 19
public Element createXML(IJavaProject[] projects) throws CoreException {
	if (fAntpath.length() > 0) {
		try {
			IPath filePath= Path.fromOSString(fAntpath);
			IPath directoryPath= filePath.removeLastSegments(1);

			IPath basePath= null;
			IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
			if (root.findFilesForLocationURI(URIUtil.toURI(filePath.makeAbsolute())).length > 0) {
				basePath= directoryPath; // only do relative path if ant file is stored in the workspace
			}
			JavadocWriter writer= new JavadocWriter(basePath, projects);
			return writer.createXML(this);
		} catch (ParserConfigurationException e) {
			String message= JavadocExportMessages.JavadocOptionsManager_createXM_error;
			throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, message, e));
		}
	}
	return null;
}
 
Example 20
/**
 * Returns the target path to be used for the updated classpath entry.
 *
 * @param entry
 *            the classpath entry
 * @return the target path, or <code>null</code>
 * @throws CoreException
 *             if an error occurs
 */
private IPath getTargetPath(final IClasspathEntry entry) throws CoreException {
	final URI location= getLocationURI(entry);
	if (location != null) {
		final URI target= getTargetURI(location);
		if (target != null) {
			IPath path= URIUtil.toPath(target);
			if (path != null) {
				final IPath workspace= ResourcesPlugin.getWorkspace().getRoot().getLocation();
				if (workspace.isPrefixOf(path)) {
					path= path.removeFirstSegments(workspace.segmentCount());
					path= path.setDevice(null);
					path= path.makeAbsolute();
				}
			}
			return path;
		}
	}
	return null;
}
 
Example 21
Source Project: sarl   Source File: StandardSREInstallTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
	this.preferences = new EclipsePreferences();
	this.plugin = spy(new SARLEclipsePlugin());
	SARLEclipsePlugin.setDefault(this.plugin);
	when(this.plugin.getPreferences()).thenReturn(this.preferences);
	this.bundle = mock(Bundle.class);
	when(this.bundle.getSymbolicName()).thenReturn(SARLEclipsePlugin.PLUGIN_ID);
	this.bundleContext = mock(BundleContext.class);
	when(this.bundleContext.getBundle()).thenReturn(this.bundle);
	when(this.bundle.getBundleContext()).thenReturn(this.bundleContext);
	SARLRuntime.setCurrentPreferenceKey(TESTING_PREFERENCE_KEY);
	this.plugin.start(this.bundleContext);
	//
	this.jarFile = Resources.getResource(Foo.class, "/foo/foo2.jar");
	Assume.assumeNotNull(this.jarFile);
	this.id = UUID.randomUUID().toString();
	this.sre = new StandardSREInstall(this.id);
	this.jarFile = FileLocator.toFileURL(this.jarFile);
	URI uri = this.jarFile.toURI();
	this.path = URIUtil.toPath(uri);
	this.sre.setJarFile(this.path);
}
 
Example 22
Source Project: CppStyle   Source File: ClangFormatFormatter.java    License: MIT License 6 votes vote down vote up
private static IPath getSourceFilePathFromEditorInput(IEditorInput editorInput) {
	if (editorInput instanceof IURIEditorInput) {
		URI uri = ((IURIEditorInput) editorInput).getURI();
		if (uri != null) {
			IPath path = URIUtil.toPath(uri);
			if (path != null) {
				  return path;
			}
		}
	}

	if (editorInput instanceof IFileEditorInput) {
		IFile file = ((IFileEditorInput) editorInput).getFile();
		if (file != null) {
			return file.getLocation();
		}
	}

	if (editorInput instanceof ILocationProvider) {
		return ((ILocationProvider) editorInput).getPath(editorInput);
	}

	return null;
}
 
Example 23
Source Project: birt   Source File: IDEFileReportProvider.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public IPath getInputPath( IEditorInput input )
{
	if ( input instanceof IURIEditorInput )
	{
		//return new Path( ( (IURIEditorInput) input ).getURI( ).getPath( ) );
		URI uri = ( (IURIEditorInput) input ).getURI( );
		if(uri == null && input instanceof IFileEditorInput)
			return ((IFileEditorInput)input).getFile( ).getFullPath( );
		IPath localPath = URIUtil.toPath( uri );
		String host = uri.getHost( );
		if ( host != null && localPath == null )
		{
			return new Path( host + uri.getPath( ) ).makeUNC( true );
		}
		return localPath;
	}
	if ( input instanceof IFileEditorInput )
	{
		return ( (IFileEditorInput) input ).getFile( ).getLocation( );
	}
	return null;
}
 
Example 24
Source Project: orion.server   Source File: ManifestUtilsTest.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testInnerSingleRelativeInheritance() throws Exception {
	String MANIFEST_LOCATION = "testData/manifestTest/inheritance/04"; //$NON-NLS-1$
	String manifestName = "prod-manifest.yml"; //$NON-NLS-1$

	URL entry = ServerTestsActivator.getContext().getBundle().getEntry(MANIFEST_LOCATION);
	IFileStore fs = EFS.getStore(URIUtil.toURI(FileLocator.toFileURL(entry).getPath().concat(manifestName)));

	ManifestParseTree manifest = ManifestUtils.parse(fs.getParent(), fs);
	ManifestParseTree applications = manifest.get("applications"); //$NON-NLS-1$
	assertEquals(2, applications.getChildren().size());
}
 
Example 25
Source Project: orion.server   Source File: ManifestUtilsTest.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Test(expected = AnalyzerException.class)
public void testSingleInheritanceOutsideSandbox() throws Exception {
	String MANIFEST_LOCATION = "testData/manifestTest/inheritance/05"; //$NON-NLS-1$
	String manifestName = "prod-manifest.yml"; //$NON-NLS-1$

	URL entry = ServerTestsActivator.getContext().getBundle().getEntry(MANIFEST_LOCATION);
	IFileStore fs = EFS.getStore(URIUtil.toURI(FileLocator.toFileURL(entry).getPath().concat(manifestName)));
	ManifestUtils.parse(fs.getParent(), fs);
}
 
Example 26
Source Project: orion.server   Source File: ManifestUtilsTest.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Test(expected = AnalyzerException.class)
public void testInheritanceCycle() throws Exception {
	String MANIFEST_LOCATION = "testData/manifestTest/inheritance/07"; //$NON-NLS-1$
	String manifestName = "final-manifest.yml"; //$NON-NLS-1$

	URL entry = ServerTestsActivator.getContext().getBundle().getEntry(MANIFEST_LOCATION);
	IFileStore fs = EFS.getStore(URIUtil.toURI(FileLocator.toFileURL(entry).getPath().concat(manifestName)));
	ManifestUtils.parse(fs.getParent(), fs);
}
 
Example 27
/**
 * Returns the selected workspace container,or <code>null</code>
 */
public static IContainer getContainer(String path) {
    if (path.length() > 0) {
        IResource res = null;
        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
        if (path.startsWith("${workspace_loc:")) { //$NON-NLS-1$
            try {
                path = VariableUtils.performStringSubstitution(path, false);
                IPath uriPath = new Path(path).makeAbsolute();
                IContainer[] containers = root.findContainersForLocationURI(URIUtil.toURI(uriPath));
                if (containers.length > 0) {
                    res = containers[0];
                }
            } 
            catch (CoreException e) {
            }
        } 
        else {      
            res = root.findMember(path);
        }
        if (res instanceof IFile) {
            res = ((IFile)res).getParent();
        }
        if (res instanceof IContainer) {
            return (IContainer)res;
        }
    }
    return null;
}
 
Example 28
Source Project: JReFrameworker   Source File: JReFrameworker.java    License: MIT License 5 votes vote down vote up
private static URI getProjectLocation(String projectName, IPath projectPath) {
	URI location = null;
	if (projectPath != null){
		location = URIUtil.toURI(projectPath);
	}
	if (location != null && ResourcesPlugin.getWorkspace().getRoot().getLocationURI().equals(location)) {
		location = null;
	} else {
		location = URIUtil.toURI(URIUtil.toPath(location) + File.separator + projectName);
	}
	return location;
}
 
Example 29
/**
 * @param processReceiver optional, receives the process after it is started
 */
public static void compile(IJavaProject javaProject, IPath warLocation,
    GWTCompileSettings settings, OutputStream consoleOutputStream,
    IProcessReceiver processReceiver) throws IOException,
    InterruptedException, CoreException, OperationCanceledException {
  IProject project = javaProject.getProject();

  if (settings.getEntryPointModules().isEmpty()) {
    // Nothing to compile, so just return.
    return;
  }

  int processStatus = ProcessUtilities.launchProcessAndWaitFor(
      computeCompilerCommandLine(javaProject, warLocation, settings),
      project.getLocation().toFile(), consoleOutputStream, processReceiver);

  /*
   * Do a refresh on the war folder if it's in the workspace. This ensures
   * that Eclipse sees the generated artifacts from the GWT compile, and
   * doesn't complain about stale resources during subsequent file searches.
   */
  if (warLocation != null) {
     for (IContainer warFolder : ResourcesPlugin.getWorkspace().getRoot()
        .findContainersForLocationURI(URIUtil.toURI(warLocation))) {
      warFolder.refreshLocal(IResource.DEPTH_INFINITE, null);
    }
  }

  if (processStatus != 0) {
    if (processReceiver != null && processReceiver.hasDestroyedProcess()) {
      PrintWriter printWriter = new PrintWriter(consoleOutputStream);
      printWriter.println("GWT compilation terminated by the user.");
      printWriter.flush();
      throw new OperationCanceledException();
    } else {
      throw new CoreException(new Status(IStatus.ERROR, GWTPlugin.PLUGIN_ID,
          "GWT compilation failed"));
    }
  }
}
 
Example 30
@Override
public IStatus validate() {
  IWorkspace workspace = ResourcesPlugin.getWorkspace();
  IPathVariableManager pathVariableManager = workspace.getPathVariableManager();
  URI gwtUri = pathVariableManager.getURIValue("GWT_ROOT");
  if (gwtUri == null) {
    return new Status(IStatus.ERROR, GWTPlugin.PLUGIN_ID,
        "Path variable 'GWT_ROOT' is not defined");
  }

  IPath gwtRoot = URIUtil.toPath(gwtUri);
  if (gwtRoot == null) {
    return new Status(IStatus.ERROR, GWTPlugin.PLUGIN_ID,
        "Path variable 'GWT_ROOT' is not defined");
  }

  if (!gwtRoot.toFile().exists()) {
    return new Status(IStatus.ERROR, GWTPlugin.PLUGIN_ID,
        "Path variable 'GWT_ROOT' points to an invalid location");
  }

  if (findDevProject() == null) {
    return new Status(IStatus.ERROR, GWTPlugin.PLUGIN_ID, "Could not find and gwt-dev-* project");
  }

  if (findUserProject() == null) {
    return new Status(IStatus.ERROR, GWTPlugin.PLUGIN_ID, "Could not find the gwt-user project");
  }

  return getGwtDevJarStatus(this);
}