Search in sources :

Example 11 with SVNException

use of org.tigris.subversion.subclipse.core.SVNException 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 12 with SVNException

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

the class SharingWizardFinishPage method createControl.

/*
   * @see IDialogPage#createControl(Composite)
   */
public void createControl(Composite parent) {
    Composite composite = createComposite(parent, 1);
    // set F1 help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.SHARING_FINISH_PAGE);
    Label label = new Label(composite, SWT.LEFT | SWT.WRAP);
    // $NON-NLS-1$
    label.setText(Policy.bind("SharingWizardFinishPage.message"));
    GridData data = new GridData();
    data.widthHint = 350;
    label.setLayoutData(data);
    IProject project = repositoryLocationProvider.getProject();
    try {
        commentProperties = CommentProperties.getCommentProperties(project);
    } catch (SVNException e) {
    }
    // $NON-NLS-1$
    commitCommentArea = new CommitCommentArea(null, null, commentProperties);
    // $NON-NLS-1$
    commitCommentArea.setProposedComment(Policy.bind("SharingWizard.initialImport"));
    if ((commentProperties != null) && (commentProperties.getMinimumLogMessageSize() != 0)) {
        ModifyListener modifyListener = new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                setPageComplete(commitCommentArea.getCommentLength() >= commentProperties.getMinimumLogMessageSize());
            }
        };
        commitCommentArea.setModifyListener(modifyListener);
    }
    commitCommentArea.createArea(composite);
    setControl(composite);
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) SVNException(org.tigris.subversion.subclipse.core.SVNException) CommitCommentArea(org.tigris.subversion.subclipse.ui.comments.CommitCommentArea) IProject(org.eclipse.core.resources.IProject)

Example 13 with SVNException

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

the class CheckinResourcesCommand method run.

/* (non-Javadoc)
   * @see org.tigris.subversion.subclipse.core.commands.ISVNCommand#run(org.eclipse.core.runtime.IProgressMonitor)
   */
public void run(IProgressMonitor monitor) throws SVNException {
    commitError = false;
    postCommitError = null;
    final ISVNClientAdapter svnClient = root.getRepository().getSVNClient();
    OperationManager.getInstance().beginOperation(svnClient, new OperationProgressNotifyListener(monitor, svnClient));
    try {
        // Prepare the parents list
        // we will Auto-commit parents if they are not already commited
        List<IContainer> parentsList = new ArrayList<IContainer>();
        List<IProject> projectList = new ArrayList<IProject>();
        for (IResource currentResource : resources) {
            IProject project = currentResource.getProject();
            if (!projectList.contains(project)) {
                projectList.add(project);
            }
            IContainer parent = currentResource.getParent();
            ISVNLocalResource svnParentResource = SVNWorkspaceRoot.getSVNResourceFor(parent);
            while (parent.getType() != IResource.ROOT && parent.getType() != IResource.PROJECT && !svnParentResource.hasRemote()) {
                if (!inCommitList(parent))
                    parentsList.add(parent);
                parent = parent.getParent();
                svnParentResource = svnParentResource.getParent();
            }
        }
        // convert parents and resources to an array of File
        int parents = parentsList.size();
        // change commit to non-recursive!!
        if (parents > 0)
            depth = IResource.DEPTH_ZERO;
        final File[] resourceFiles = new File[parents + resources.length];
        for (int i = 0; i < parents; i++) {
            resourceFiles[i] = ((IResource) parentsList.get(i)).getLocation().toFile();
        }
        for (int i = 0, j = parents; i < resources.length; i++, j++) {
            resourceFiles[j] = resources[i].getLocation().toFile();
        }
        IProject[] projects = new IProject[projectList.size()];
        projectList.toArray(projects);
        ISchedulingRule rule = MultiRule.combine(projects);
        SVNProviderPlugin.run(new ISVNRunnable() {

            public void run(final IProgressMonitor pm) throws SVNException {
                try {
                    notifyListener = new ISVNNotifyListener() {

                        public void logCommandLine(String commandLine) {
                        }

                        public void logCompleted(String message) {
                        }

                        public void logError(String message) {
                        }

                        public void logMessage(String message) {
                            if (message.startsWith("Transmitting file data"))
                                pm.subTask(message);
                        }

                        public void logRevision(long revision, String path) {
                        }

                        public void onNotify(File path, SVNNodeKind kind) {
                        }

                        public void setCommand(int command) {
                        }
                    };
                    pm.beginTask(null, resourceFiles.length);
                    pm.setTaskName("Checking in...");
                    svnClient.addNotifyListener(operationResourceCollector);
                    svnClient.addNotifyListener(notifyListener);
                    // then the resources the user has requested to commit
                    if (svnClient.canCommitAcrossWC())
                        svnClient.commitAcrossWC(resourceFiles, message, depth == IResource.DEPTH_INFINITE, keepLocks, true);
                    else
                        svnClient.commit(resourceFiles, message, depth == IResource.DEPTH_INFINITE, keepLocks);
                    postCommitError = svnClient.getPostCommitError();
                } catch (SVNClientException e) {
                    commitError = true;
                    throw SVNException.wrapException(e);
                } finally {
                    pm.done();
                    if (svnClient != null) {
                        svnClient.removeNotifyListener(operationResourceCollector);
                        svnClient.removeNotifyListener(notifyListener);
                        root.getRepository().returnSVNClient(svnClient);
                    }
                }
            }
        }, rule, Policy.monitorFor(monitor));
    } finally {
        OperationManager.getInstance().endOperation(true, operationResourceCollector.getOperationResources(), !commitError);
    }
}
Also used : ISVNRunnable(org.tigris.subversion.subclipse.core.ISVNRunnable) ArrayList(java.util.ArrayList) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IProject(org.eclipse.core.resources.IProject) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SVNNodeKind(org.tigris.subversion.svnclientadapter.SVNNodeKind) ISVNNotifyListener(org.tigris.subversion.svnclientadapter.ISVNNotifyListener) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) IContainer(org.eclipse.core.resources.IContainer) File(java.io.File) IResource(org.eclipse.core.resources.IResource) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter) OperationProgressNotifyListener(org.tigris.subversion.subclipse.core.client.OperationProgressNotifyListener)

Example 14 with SVNException

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

the class CheckoutCommand method refreshProject.

/*
   * Bring the provided projects into the workspace
   */
private void refreshProject(IProject project, IProgressMonitor monitor) throws SVNException {
    if (monitor != null) {
        // $NON-NLS-1$
        monitor.beginTask("", 100);
        monitor.subTask(Policy.bind("SVNProvider.Creating_project_1", project.getName()));
    }
    try {
        // Register the project with Team
        RepositoryProvider.map(project, SVNProviderPlugin.getTypeId());
        RepositoryProvider.getProvider(project, SVNProviderPlugin.getTypeId());
    } catch (TeamException e) {
        throw new SVNException("Cannot map the project with svn provider", e);
    } finally {
        if (monitor != null) {
            monitor.subTask(" ");
            monitor.done();
        }
    }
}
Also used : TeamException(org.eclipse.team.core.TeamException) SVNException(org.tigris.subversion.subclipse.core.SVNException)

Example 15 with SVNException

use of org.tigris.subversion.subclipse.core.SVNException 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

SVNException (org.tigris.subversion.subclipse.core.SVNException)162 IResource (org.eclipse.core.resources.IResource)68 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)68 ArrayList (java.util.ArrayList)39 CoreException (org.eclipse.core.runtime.CoreException)25 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)25 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)23 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)21 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)19 Iterator (java.util.Iterator)18 TeamException (org.eclipse.team.core.TeamException)18 InvocationTargetException (java.lang.reflect.InvocationTargetException)17 IContainer (org.eclipse.core.resources.IContainer)16 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)16 File (java.io.File)15 IProject (org.eclipse.core.resources.IProject)15 ISynchronizeModelElement (org.eclipse.team.ui.synchronize.ISynchronizeModelElement)14 IFile (org.eclipse.core.resources.IFile)13 GridData (org.eclipse.swt.layout.GridData)13 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)13