Java Code Examples for org.eclipse.core.filesystem.IFileStore#move()

The following examples show how to use org.eclipse.core.filesystem.IFileStore#move() . 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: PlatformUtil.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public static void move(final File fileToMove, final File toDir, final IProgressMonitor monitor) {
    if (fileToMove == null || !fileToMove.exists()) {
        return;
    }

    if (fileSystem == null) {
        fileSystem = EFS.getLocalFileSystem();
    }

    final IFileStore fileToMoveStore = fileSystem.fromLocalFile(fileToMove);
    final IFileStore dest = fileSystem.fromLocalFile(toDir);
    try {
        fileToMoveStore.move(dest.getChild(fileToMoveStore.getName()), EFS.OVERWRITE, new NullProgressMonitor());
        monitor.worked(1);
    } catch (final CoreException e) {
        BonitaStudioLog.error(e);
    }

}
 
Example 2
Source File: PackageTests.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
public void testModelPath() throws CoreException, IOException {

        String librarySource = "";
        librarySource += "model library;\n";
        librarySource += "class BaseClass end;\n";
        librarySource += "end.";
        parseAndCheck(librarySource);

        IFileStore originalLocation = getRepositoryDir();
        IFileStore destination = originalLocation.getParent().getChild(getName() + "_library");
        originalLocation.move(destination, EFS.NONE, null);
        
        IFileStore loadedModelLocation = destination.getChild("library.uml");
		assertTrue(loadedModelLocation.fetchInfo().exists());
        
        IFileStore projectRoot = originalLocation;

        Properties settings = createDefaultSettings();
        settings.put(IRepository.LOADED_PACKAGES, loadedModelLocation.toURI().toString());
		saveSettings(projectRoot, settings);
        String source = "";
        source += "model someModel;\n";
        source += "import  library;\n";
        source += "class MyClass specializes library::BaseClass end;\n";
        source += "end.";
        parseAndCheck(source);

        assertTrue(originalLocation.getChild("someModel.uml").fetchInfo().exists());
        assertFalse(originalLocation.getChild("library.uml").fetchInfo().exists());

        assertNotNull(getRepository().findPackage("someModel", IRepository.PACKAGE.getModel()));
        assertNotNull(getRepository().findNamedElement("library::BaseClass", IRepository.PACKAGE.getClass_(), null));

        Package someModel = getRepository().findPackage("someModel", null);
        Package library = getRepository().findPackage("library", null);

        assertTrue(someModel.getImportedPackages().contains(library));

    }
 
Example 3
Source File: PackageTests.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
public void testLoadAnotherPackage() throws CoreException {

        String librarySource = "";
        librarySource += "model library;\n";
        librarySource += "class BaseClass end;\n";
        librarySource += "end.";
        parseAndCheck(librarySource);

        IFileStore originalLocation = getRepositoryDir();
        IFileStore destination = originalLocation.getParent().getChild(getName() + "_library");
        originalLocation.move(destination, EFS.NONE, null);

        assertTrue(destination.getChild("library.uml").fetchInfo().exists());

        String source = "";
        source += "model someModel;\n";
        source += "load <<" + destination.getChild("library.uml").toURI() + ">>;";
        source += "class MyClass specializes library::BaseClass end;\n";
        source += "end.";
        parseAndCheck(source);

        assertTrue(originalLocation.getChild("someModel.uml").fetchInfo().exists());
        assertFalse(originalLocation.getChild("library.uml").fetchInfo().exists());

        assertNotNull(getRepository().findPackage("someModel", IRepository.PACKAGE.getModel()));
        assertNotNull(getRepository().findNamedElement("library::BaseClass", IRepository.PACKAGE.getClass_(), null));

        Package someModel = getRepository().findPackage("someModel", null);
        Package library = getRepository().findPackage("library", null);

        assertTrue(someModel.getImportedPackages().contains(library));

    }