Search in sources :

Example 1 with ISVNLocalFolder

use of org.tigris.subversion.subclipse.core.ISVNLocalFolder in project subclipse by subclipse.

the class SVNMoveDeleteHook method deleteFolder.

public boolean deleteFolder(IResourceTree tree, IFolder folder, int updateFlags, IProgressMonitor monitor) {
    if (SVNWorkspaceRoot.isLinkedResource(folder))
        return false;
    ISVNLocalFolder resource = new LocalFolder(folder);
    try {
        if (!resource.isManaged()) {
            return false;
        }
        monitor.beginTask(null, 1000);
        deleteResource(resource);
        tree.deletedFolder(folder);
    } catch (SVNException e) {
        tree.failed(e.getStatus());
    } finally {
        monitor.done();
    }
    return true;
}
Also used : ISVNLocalFolder(org.tigris.subversion.subclipse.core.ISVNLocalFolder) ISVNLocalFolder(org.tigris.subversion.subclipse.core.ISVNLocalFolder) SVNException(org.tigris.subversion.subclipse.core.SVNException)

Example 2 with ISVNLocalFolder

use of org.tigris.subversion.subclipse.core.ISVNLocalFolder in project subclipse by subclipse.

the class SVNMoveDeleteHook method deleteProject.

/* (non-Javadoc)
   * @see org.eclipse.core.resources.team.IMoveDeleteHook#deleteProject(org.eclipse.core.resources.team.IResourceTree, org.eclipse.core.resources.IProject, int, org.eclipse.core.runtime.IProgressMonitor)
   */
public boolean deleteProject(IResourceTree tree, IProject project, int updateFlags, IProgressMonitor monitor) {
    ISVNLocalFolder resource = new LocalFolder(project);
    try {
        // If contents are not being deleted, let Eclipse handle.
        if ((updateFlags & IResource.NEVER_DELETE_PROJECT_CONTENT) == IResource.NEVER_DELETE_PROJECT_CONTENT) {
            return false;
        }
        // If not managed, let Eclipse handle.
        if (!resource.isManaged())
            return false;
        File projectDirectory = new File(project.getLocationURI());
        // If meta directory does not exist, let Eclipse handle.
        // $NON-NLS-1$
        File metaFolder = new File(projectDirectory, ".svn");
        if (!metaFolder.exists()) {
            return false;
        }
        // If database file does not exist, let Eclipse handle.
        // $NON-NLS-1$
        File databaseFile = new File(metaFolder, "wc.db");
        if (!databaseFile.exists()) {
            return false;
        }
        // If we can delete database file, let Eclipse handle project deletion.
        if (databaseFile.delete()) {
            return false;
        }
        // Show message dialog in UI thread and cancel deletion.
        SVNProviderPlugin.handleMessage(Policy.bind("SVNMoveDeleteHook.4"), Policy.bind("SVNMoveDeleteHook.5") + project.getName() + Policy.bind("SVNMoveDeleteHook.6"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        IMessageHandler.ERROR);
        return true;
    } catch (Exception e) {
        // Let Eclipse try to handle it.
        return false;
    }
}
Also used : ISVNLocalFolder(org.tigris.subversion.subclipse.core.ISVNLocalFolder) ISVNLocalFolder(org.tigris.subversion.subclipse.core.ISVNLocalFolder) IFile(org.eclipse.core.resources.IFile) ISVNLocalFile(org.tigris.subversion.subclipse.core.ISVNLocalFile) File(java.io.File) CoreException(org.eclipse.core.runtime.CoreException) SVNException(org.tigris.subversion.subclipse.core.SVNException) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) TeamException(org.eclipse.team.core.TeamException)

Example 3 with ISVNLocalFolder

use of org.tigris.subversion.subclipse.core.ISVNLocalFolder in project subclipse by subclipse.

the class RevertResourceManager method processResources.

/**
 * Revert previously deleted resources that are added again. When a file is reverted, it's parent
 * directories are also reverted. When new files are added in folders that are scheduled for
 * deletion, the parent folder tree is reverted.
 *
 * @param resources
 */
private ISVNLocalResource[] processResources(IResourceDelta[] resources) throws CoreException {
    List<ISVNLocalResource> revertedResources = new ArrayList<ISVNLocalResource>();
    for (IResourceDelta resourceDelta : resources) {
        IResource resource = resourceDelta.getResource();
        if (resource.getType() == IResource.FILE) {
            ISVNLocalFile res = SVNWorkspaceRoot.getSVNFileFor((IFile) resource);
            if (res.getFile().exists()) {
                boolean deleted;
                if (resourceDelta.getKind() == IResourceDelta.ADDED)
                    deleted = res.getStatusFromCache().isDeleted();
                else {
                    deleted = SVNMoveDeleteHook.isDeleted((IFile) resource);
                    if (deleted)
                        SVNMoveDeleteHook.removeFromDeletedFileList((IFile) resource);
                }
                if (deleted) {
                    revertedResources.add(res);
                }
                ISVNLocalFolder parentFolder = res.getParent();
                while (parentFolder != null) {
                    if (parentFolder.getStatusFromCache().isDeleted() && !parentFolder.getResource().exists() && !revertedResources.contains(parentFolder)) {
                        revertedResources.add(parentFolder);
                    } else {
                        break;
                    }
                    if (parentFolder.getParent() == null) {
                        break;
                    }
                    parentFolder = parentFolder.getParent();
                }
            }
        }
    }
    return (ISVNLocalResource[]) revertedResources.toArray(new ISVNLocalResource[revertedResources.size()]);
}
Also used : ISVNLocalFolder(org.tigris.subversion.subclipse.core.ISVNLocalFolder) IFile(org.eclipse.core.resources.IFile) ArrayList(java.util.ArrayList) ISVNLocalFile(org.tigris.subversion.subclipse.core.ISVNLocalFile) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource) IResourceDelta(org.eclipse.core.resources.IResourceDelta)

Example 4 with ISVNLocalFolder

use of org.tigris.subversion.subclipse.core.ISVNLocalFolder in project subclipse by subclipse.

the class SharingWizard method addPages.

/**
 * add pages
 */
public void addPages() {
    ImageDescriptor sharingImage = SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_WIZBAN_SHARE);
    if (project.getLocation() == null) {
        CannotSharePage cannotSharePage = new CannotSharePage("cannotSharePage", Policy.bind("SharingWizard.importTitle"), sharingImage, // $NON-NLS-1$ //$NON-NLS-2$
        project);
        addPage(cannotSharePage);
    } else if (doesSVNDirectoryExist()) {
        // if .svn directory exists, we add the autoconnect page
        autoconnectPage = new ConfigurationWizardAutoconnectPage("autoconnectPage", Policy.bind("SharingWizard.autoConnectTitle"), sharingImage, // $NON-NLS-1$ //$NON-NLS-2$
        projectStatus);
        autoconnectPage.setProject(project);
        autoconnectPage.setDescription(// $NON-NLS-1$
        Policy.bind("SharingWizard.autoConnectTitleDescription"));
        addPage(autoconnectPage);
    } else {
        try {
            ISVNLocalFolder localFolder = SVNWorkspaceRoot.getSVNFolderFor(project);
            if (localFolder instanceof LocalFolder) {
                IFolder[] svnFolders = ((LocalFolder) localFolder).getSVNFolders(null, false);
                if (svnFolders.length > 0) {
                    warningPage = new SvnFoldersExistWarningPage("warningPage", Policy.bind("SharingWizard.importTitle"), sharingImage, // $NON-NLS-1$ //$NON-NLS-2$
                    svnFolders);
                    // $NON-NLS-1$
                    warningPage.setDescription(Policy.bind("SharingWizard.svnFolderExists"));
                    addPage(warningPage);
                // Remember to update getNextPage.
                }
            }
        } catch (SVNException e) {
            SVNUIPlugin.openError(getShell(), null, null, e, SVNUIPlugin.PERFORM_SYNC_EXEC);
        }
        // otherwise we add :
        // - the repository selection page
        // - any contributed repository source pages
        // - the create location page
        // - the module selection page
        // - the finish page
        IRunnableWithProgress runnable = new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                locations = SVNUIPlugin.getPlugin().getRepositoryManager().getKnownRepositoryLocations(monitor);
            }
        };
        try {
            new ProgressMonitorDialog(getShell()).run(true, false, runnable);
        } catch (Exception e) {
            SVNUIPlugin.openError(getShell(), null, null, e, SVNUIPlugin.LOG_TEAM_EXCEPTIONS);
        }
        locationPage = new RepositorySelectionPage("importPage", Policy.bind("SharingWizard.importTitle"), // $NON-NLS-1$ //$NON-NLS-2$
        sharingImage);
        locationPage.setDescription(// $NON-NLS-1$
        Policy.bind("SharingWizard.importTitleDescription"));
        addPage(locationPage);
        ISVNRepositorySourceProvider[] repositorySourceProviders = null;
        try {
            repositorySourceProviders = SVNUIPlugin.getRepositorySourceProviders();
        } catch (Exception e) {
        }
        if (repositorySourceProviders != null && repositorySourceProviders.length > 0) {
            repositorySourceProviderPage = new ConfigurationWizardRepositorySourceProviderPage("source", Policy.bind("NewLocationWizard.heading"), SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_WIZBAN_NEW_LOCATION), // $NON-NLS-1$ //$NON-NLS-2$
            repositorySourceProviders);
            repositorySourceProviderPage.setDescription(// $NON-NLS-1$
            Policy.bind("NewLocationWizard.0"));
            addPage(repositorySourceProviderPage);
            for (ISVNRepositorySourceProvider repositorySourceProvider : repositorySourceProviders) {
                SVNRepositoryProviderWizardPage wizardPage = repositorySourceProvider.getWizardPage();
                addPage(wizardPage);
                wizardPageMap.put(repositorySourceProvider, wizardPage);
            }
        }
        createLocationPage = new ConfigurationWizardMainPage("createLocationPage", Policy.bind("SharingWizard.enterInformation"), // $NON-NLS-1$ //$NON-NLS-2$
        sharingImage);
        createLocationPage.setDescription(// $NON-NLS-1$
        Policy.bind("SharingWizard.enterInformationDescription"));
        addPage(createLocationPage);
        createLocationPage.setDialogSettings(getDialogSettings());
        ISVNRepositoryLocationProvider repositoryLocationProvider = new ISVNRepositoryLocationProvider() {

            public ISVNRepositoryLocation getLocation() throws TeamException {
                return SharingWizard.this.getLocation();
            }

            public IProject getProject() {
                return SharingWizard.this.getProject();
            }
        };
        directoryPage = new DirectorySelectionPage("modulePage", Policy.bind("SharingWizard.enterModuleName"), sharingImage, // $NON-NLS-1$ //$NON-NLS-2$
        repositoryLocationProvider);
        directoryPage.setDescription(// $NON-NLS-1$
        Policy.bind("SharingWizard.enterModuleNameDescription"));
        addPage(directoryPage);
        finishPage = new SharingWizardFinishPage("finishPage", Policy.bind("SharingWizard.readyToFinish"), sharingImage, // $NON-NLS-1$ //$NON-NLS-2$
        repositoryLocationProvider);
        finishPage.setDescription(// $NON-NLS-1$
        Policy.bind("SharingWizard.readyToFinishDescription"));
        addPage(finishPage);
    }
}
Also used : ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ConfigurationWizardMainPage(org.tigris.subversion.subclipse.ui.wizards.ConfigurationWizardMainPage) SVNException(org.tigris.subversion.subclipse.core.SVNException) SVNRepositoryProviderWizardPage(org.tigris.subversion.subclipse.ui.wizards.SVNRepositoryProviderWizardPage) ConfigurationWizardRepositorySourceProviderPage(org.tigris.subversion.subclipse.ui.wizards.ConfigurationWizardRepositorySourceProviderPage) InvocationTargetException(java.lang.reflect.InvocationTargetException) CoreException(org.eclipse.core.runtime.CoreException) SVNException(org.tigris.subversion.subclipse.core.SVNException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) IOException(java.io.IOException) IProject(org.eclipse.core.resources.IProject) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ISVNLocalFolder(org.tigris.subversion.subclipse.core.ISVNLocalFolder) ISVNLocalFolder(org.tigris.subversion.subclipse.core.ISVNLocalFolder) LocalFolder(org.tigris.subversion.subclipse.core.resources.LocalFolder) ISVNRepositorySourceProvider(org.tigris.subversion.subclipse.ui.ISVNRepositorySourceProvider) TeamException(org.eclipse.team.core.TeamException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)

Example 5 with ISVNLocalFolder

use of org.tigris.subversion.subclipse.core.ISVNLocalFolder in project subclipse by subclipse.

the class CheckoutCommand method basicRun.

protected void basicRun(final IProject project, ISVNRemoteFolder resource, final IProgressMonitor pm) throws SVNException {
    ISVNClientAdapter svnClient = null;
    if (pm != null) {
        pm.beginTask(null, 1000);
    }
    try {
        // Perform the checkout
        boolean createProject = false;
        svnClient = resource.getRepository().getSVNClient();
        OperationManager.getInstance().beginOperation(svnClient, new OperationProgressNotifyListener(pm, svnClient));
        // Prepare the target projects to receive resources
        scrubProject(resource, project, (pm != null) ? Policy.subMonitorFor(pm, 100) : null);
        File destPath;
        if (project.getLocation() == null) {
            // not exist in the workspace
            if (projectRoot == null) {
                ISVNLocalFolder root = SVNWorkspaceRoot.getSVNFolderFor(ResourcesPlugin.getWorkspace().getRoot());
                destPath = new File(root.getIResource().getLocation().toFile(), project.getName());
            } else {
                destPath = new File(projectRoot.toFile(), project.getName());
            }
            if (!destPath.exists()) {
                destPath.mkdirs();
            }
            createProject = true;
        } else {
            if (projectRoot != null) {
                try {
                    destPath = new File(projectRoot.toFile(), project.getName());
                    setProjectToRoot(project, destPath);
                } catch (CoreException e) {
                    throw new SVNException("Cannot create project to checkout to", e);
                }
            } else {
                destPath = project.getLocation().toFile();
            }
        }
        if (createProject) {
            createProjectList.add(project);
        }
        checkoutProject(pm, resource, svnClient, destPath);
        SVNWorkspaceRoot.setManagedBySubclipse(project);
        if (refreshProjects) {
            try {
                project.create(null);
                project.open(null);
            } catch (CoreException e1) {
                throw new SVNException("Cannot create project to checkout to", e1);
            }
            refreshProject(project, (pm != null) ? Policy.subMonitorFor(pm, 100) : null);
        } else {
            manageProjectList.add(project);
        }
    } finally {
        resource.getRepository().returnSVNClient(svnClient);
        if (pm != null) {
            pm.done();
        }
    }
}
Also used : ISVNLocalFolder(org.tigris.subversion.subclipse.core.ISVNLocalFolder) CoreException(org.eclipse.core.runtime.CoreException) SVNException(org.tigris.subversion.subclipse.core.SVNException) File(java.io.File) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter) OperationProgressNotifyListener(org.tigris.subversion.subclipse.core.client.OperationProgressNotifyListener)

Aggregations

ISVNLocalFolder (org.tigris.subversion.subclipse.core.ISVNLocalFolder)9 SVNException (org.tigris.subversion.subclipse.core.SVNException)5 CoreException (org.eclipse.core.runtime.CoreException)4 TeamException (org.eclipse.team.core.TeamException)3 File (java.io.File)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IFile (org.eclipse.core.resources.IFile)2 IResource (org.eclipse.core.resources.IResource)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 ISVNLocalFile (org.tigris.subversion.subclipse.core.ISVNLocalFile)2 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)2 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)2 SVNTeamProvider (org.tigris.subversion.subclipse.core.SVNTeamProvider)2 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)2 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Hashtable (java.util.Hashtable)1 Iterator (java.util.Iterator)1 List (java.util.List)1