org.eclipse.core.filesystem.URIUtil Java Examples

The following examples show how to use org.eclipse.core.filesystem.URIUtil. 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 File: GwtRuntimeTestUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 #2
Source File: AbstractJarDestinationWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 *	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 #3
Source File: JavadocOptionsManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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 #4
Source File: JavadocOptionsManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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 #5
Source File: JarImportWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 #6
Source File: StandardSREInstallTest.java    From sarl with 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 #7
Source File: FilenameDifferentiator.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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 #8
Source File: UIUtils.java    From APICloud-Studio with 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 #9
Source File: FileUtils.java    From gama with 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 #10
Source File: WebAppProjectCreator.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
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 #11
Source File: ClangFormatFormatter.java    From CppStyle with 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 #12
Source File: AbstractGWTPluginTestCase.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
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 #13
Source File: EclipseFileSystemSupportImpl.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
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 #14
Source File: PackagerTest.java    From orion.server with 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 #15
Source File: LocationSelector.java    From xds-ide with 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 #16
Source File: ManifestUtilsTest.java    From orion.server with 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 #17
Source File: ManifestUtilsTest.java    From orion.server with 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 #18
Source File: ManifestUtilsTest.java    From orion.server with 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 #19
Source File: ManifestUtilsTest.java    From orion.server with 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 #20
Source File: ManifestUtilsTest.java    From orion.server with 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 #21
Source File: ManifestUtilsTest.java    From orion.server with 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 #22
Source File: IDEFileReportProvider.java    From birt with 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 #23
Source File: PackagerTest.java    From orion.server with 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 #24
Source File: AddOrEditCatalogDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 选择文件 ;
 */
public void browseFiles() {
	FileFolderSelectionDialog dialog = new FileFolderSelectionDialog(getShell(), false, IResource.FILE);
	dialog.setMessage(Messages.getString("dialogs.AddOrEditCatalogDialog.dialogMsg"));
	dialog.setDoubleClickSelects(true);

	try {
		dialog.setInput(EFS.getStore(URIUtil.toURI(root.getLocation().append(ADConstants.cataloguePath))));

	} catch (CoreException e1) {
		e1.printStackTrace();
	}
	dialog.create();
	dialog.getShell().setText(Messages.getString("dialogs.AddOrEditCatalogDialog.dialogTitle"));
	dialog.open();
	if (dialog.getFirstResult() != null) {
		Object object = dialog.getFirstResult();
		if (object instanceof LocalFile) {
			LocalFile localFile = (LocalFile) object;
			String location = localFile.toString();
			String catalogurePath = root.getLocation().append(ADConstants.cataloguePath).toOSString();
			String uriStr = "";
			if (location.indexOf(catalogurePath) != -1) {
				uriStr = location.substring(location.indexOf(catalogurePath) + catalogurePath.length(), location.length());
			}
			uriStr = uriStr.substring(1, uriStr.length());
			urlTxt.setText(uriStr);
		}
	}
}
 
Example #25
Source File: CompilationUnitDocumentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a fake compilation unit.
 *
 * @param editorInput the URI editor input
 * @return the fake compilation unit
 * @since 3.3
 */
private ICompilationUnit createFakeCompiltationUnit(IURIEditorInput editorInput) {
	try {
		final URI uri= editorInput.getURI();
		final IFileStore fileStore= EFS.getStore(uri);
		final IPath path= URIUtil.toPath(uri);
		String fileStoreName= fileStore.getName();
		if (fileStoreName == null || path == null)
			return null;

		WorkingCopyOwner woc= new WorkingCopyOwner() {
			/*
			 * @see org.eclipse.jdt.core.WorkingCopyOwner#createBuffer(org.eclipse.jdt.core.ICompilationUnit)
			 * @since 3.2
			 */
			@Override
			public IBuffer createBuffer(ICompilationUnit workingCopy) {
				return new DocumentAdapter(workingCopy, fileStore, path);
			}
		};

		IClasspathEntry[] cpEntries= null;
		IJavaProject jp= findJavaProject(path);
		if (jp != null)
			cpEntries= jp.getResolvedClasspath(true);

		if (cpEntries == null || cpEntries.length == 0)
			cpEntries= new IClasspathEntry[] { JavaRuntime.getDefaultJREContainerEntry() };

		final ICompilationUnit cu= woc.newWorkingCopy(fileStoreName, cpEntries, getProgressMonitor());

		if (!isModifiable(editorInput))
			JavaModelUtil.reconcile(cu);

		return cu;
	} catch (CoreException ex) {
		return null;
	}
}
 
Example #26
Source File: MainProjectWizardPage.java    From sarl with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the current project location path as entered by the user, or {@code null} if
 * the project should be created in the workspace.
 *
 * @return the project location path or its anticipated initial value.
 */
public URI getProjectLocationURI() {
	if (this.locationGroup.isUseDefaultSelected()) {
		return null;
	}
	return URIUtil.toURI(this.locationGroup.getLocation());
}
 
Example #27
Source File: XLFValidator.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public static boolean validateXliffFile(String fileLocalPath) {
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	IFile file = root.getFileForLocation(URIUtil.toPath(new File(fileLocalPath).toURI()));
	if (file == null) {
		Shell shell = Display.getDefault().getActiveShell();
		MessageDialog.openError(shell, Messages.getString("file.XLFValidator.msgTitle"),
				Messages.getString("file.XLFValidator.msg9"));
		return false;
	}
	return validateXliffFile(file);
}
 
Example #28
Source File: XLFValidator.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public static boolean validateXliffFile(File file) {
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	IFile ifile = root.getFileForLocation(URIUtil.toPath(file.toURI()));
	if (ifile == null) {
		Shell shell = Display.getDefault().getActiveShell();
		MessageDialog.openError(shell, Messages.getString("file.XLFValidator.msgTitle"),
				Messages.getString("file.XLFValidator.msg9"));
		return false;
	}
	return validateXliffFile(ifile);
}
 
Example #29
Source File: XLFValidator.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public static boolean validateXliffFile(String fileLocalPath) {
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	IFile file = root.getFileForLocation(URIUtil.toPath(new File(fileLocalPath).toURI()));
	if (file == null) {
		Shell shell = Display.getDefault().getActiveShell();
		MessageDialog.openError(shell, Messages.getString("file.XLFValidator.msgTitle"),
				Messages.getString("file.XLFValidator.msg9"));
		return false;
	}
	return validateXliffFile(file);
}
 
Example #30
Source File: XLFValidator.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public static boolean validateXliffFile(File file) {
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	IFile ifile = root.getFileForLocation(URIUtil.toPath(file.toURI()));
	if (ifile == null) {
		Shell shell = Display.getDefault().getActiveShell();
		MessageDialog.openError(shell, Messages.getString("file.XLFValidator.msgTitle"),
				Messages.getString("file.XLFValidator.msg9"));
		return false;
	}
	return validateXliffFile(ifile);
}