Search in sources :

Example 6 with SVNProviderPlugin

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

the class NewLocationWizard method performFinish.

/*
   * @see IWizard#performFinish
   */
public boolean performFinish() {
    mainPage.finish(new NullProgressMonitor());
    Properties properties = mainPage.getProperties();
    if (repositorySourceProviderPage != null) {
        ISVNRepositorySourceProvider selectedRepositorySourceProvider = repositorySourceProviderPage.getSelectedRepositorySourceProvider();
        if (selectedRepositorySourceProvider != null) {
            SVNRepositoryProviderWizardPage wizardPage = wizardPageMap.get(selectedRepositorySourceProvider);
            if (wizardPage != null) {
                // $NON-NLS-1$
                properties.setProperty("url", wizardPage.getSelectedUrl());
            }
        }
    }
    final ISVNRepositoryLocation[] root = new ISVNRepositoryLocation[1];
    SVNProviderPlugin provider = SVNProviderPlugin.getPlugin();
    try {
        root[0] = provider.getRepositories().createRepository(properties);
        // Validate the connection info.  This process also determines the rootURL
        try {
            new ProgressMonitorDialog(getShell()).run(true, true, new IRunnableWithProgress() {

                public void run(IProgressMonitor monitor) throws InvocationTargetException {
                    try {
                        root[0].validateConnection(monitor);
                    } catch (TeamException e) {
                        throw new InvocationTargetException(e);
                    }
                }
            });
        } catch (InterruptedException e) {
            return false;
        } catch (InvocationTargetException e) {
            Throwable t = e.getTargetException();
            if (t instanceof TeamException) {
                throw (TeamException) t;
            }
        }
        provider.getRepositories().addOrUpdateRepository(root[0]);
    } catch (TeamException e) {
        if (root[0] == null) {
            // Exception creating the root, we cannot continue
            SVNUIPlugin.openError(getContainer().getShell(), Policy.bind("NewLocationWizard.exception"), null, // $NON-NLS-1$
            e);
            return false;
        } else {
            // Exception validating. We can continue if the user wishes.
            IStatus error = e.getStatus();
            if (error.isMultiStatus() && error.getChildren().length == 1) {
                error = error.getChildren()[0];
            }
            boolean keep = false;
            if (error.isMultiStatus()) {
                SVNUIPlugin.openError(getContainer().getShell(), Policy.bind("NewLocationWizard.validationFailedTitle"), null, // $NON-NLS-1$
                e);
            } else {
                keep = MessageDialog.openQuestion(getContainer().getShell(), // $NON-NLS-1$
                Policy.bind("NewLocationWizard.validationFailedTitle"), Policy.bind("NewLocationWizard.validationFailedText", // $NON-NLS-1$
                new Object[] { error.getMessage() }));
            }
            try {
                if (keep) {
                    provider.getRepositories().addOrUpdateRepository(root[0]);
                } else {
                    provider.getRepositories().disposeRepository(root[0]);
                }
            } catch (TeamException e1) {
                SVNUIPlugin.openError(getContainer().getShell(), Policy.bind("exception"), null, // $NON-NLS-1$
                e1);
                return false;
            }
            return keep;
        }
    }
    return true;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) SVNProviderPlugin(org.tigris.subversion.subclipse.core.SVNProviderPlugin) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) Properties(java.util.Properties) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ISVNRepositorySourceProvider(org.tigris.subversion.subclipse.ui.ISVNRepositorySourceProvider) TeamException(org.eclipse.team.core.TeamException) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)

Aggregations

SVNProviderPlugin (org.tigris.subversion.subclipse.core.SVNProviderPlugin)6 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)4 Properties (java.util.Properties)3 File (java.io.File)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)2 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)2 TeamException (org.eclipse.team.core.TeamException)2 SVNClientManager (org.tigris.subversion.subclipse.core.SVNClientManager)2 ISVNRepositorySourceProvider (org.tigris.subversion.subclipse.ui.ISVNRepositorySourceProvider)2 ArrayList (java.util.ArrayList)1 IProject (org.eclipse.core.resources.IProject)1 RepositoryProvider (org.eclipse.team.core.RepositoryProvider)1 ISVNClientWrapper (org.tigris.subversion.clientadapter.ISVNClientWrapper)1 SVNException (org.tigris.subversion.subclipse.core.SVNException)1 SVNTeamProvider (org.tigris.subversion.subclipse.core.SVNTeamProvider)1 UnsupportedPasswordStoresDialog (org.tigris.subversion.subclipse.ui.dialogs.UnsupportedPasswordStoresDialog)1