Search in sources :

Example 1 with ISVNRepositorySourceProvider

use of org.tigris.subversion.subclipse.ui.ISVNRepositorySourceProvider 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 2 with ISVNRepositorySourceProvider

use of org.tigris.subversion.subclipse.ui.ISVNRepositorySourceProvider in project subclipse by subclipse.

the class CheckoutWizard method addPages.

public void addPages() {
    setNeedsProgressMonitor(true);
    if (remoteFolders == null) {
        locationPage = new CheckoutWizardLocationPage(// $NON-NLS-1$
        "locationPage", // $NON-NLS-1$
        Policy.bind("CheckoutWizardLocationPage.heading"), SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_WIZBAN_SHARE));
        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(// $NON-NLS-1$
        "createLocationPage", // $NON-NLS-1$
        Policy.bind("CheckoutWizardLocationPage.heading"), SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_WIZBAN_SHARE));
        addPage(createLocationPage);
        selectionPage = new CheckoutWizardSelectionPage(// $NON-NLS-1$
        "selectionPage", // $NON-NLS-1$
        Policy.bind("CheckoutWizardSelectionPage.heading"), SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_WIZBAN_SHARE));
        addPage(selectionPage);
    }
    if (remoteFolders == null || remoteFolders.length > 1) {
        checkoutAsMultiplePage = new CheckoutWizardCheckoutAsMultiplePage(// $NON-NLS-1$
        "checkoutAsMultiplePage", // $NON-NLS-1$
        Policy.bind("CheckoutWizardCheckoutAsPage.heading"), SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_WIZBAN_SHARE));
        addPage(checkoutAsMultiplePage);
    }
    if (remoteFolders == null || remoteFolders.length == 1) {
        if (remoteFolders == null || hasProjectFile) {
            checkoutAsWithProjectFilePage = new CheckoutWizardCheckoutAsWithProjectFilePage(// $NON-NLS-1$
            "checkoutAsWithProjectFilePage", // $NON-NLS-1$
            Policy.bind("CheckoutWizardCheckoutAsPage.heading"), SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_WIZBAN_SHARE));
            addPage(checkoutAsWithProjectFilePage);
            if (remoteFolders != null && remoteFolders.length == 1) {
                if (project != null)
                    checkoutAsWithProjectFilePage.setProjectName(project.getName());
            }
        }
        if (remoteFolders == null || !hasProjectFile) {
            checkoutAsWithoutProjectFilePage = new CheckoutWizardCheckoutAsWithoutProjectFilePage(// $NON-NLS-1$
            "checkoutAsWithoutProjectFilePage", // $NON-NLS-1$
            Policy.bind("CheckoutWizardCheckoutAsPage.heading"), SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_WIZBAN_SHARE));
            addPage(checkoutAsWithoutProjectFilePage);
        }
    }
    projectPage = new CheckoutWizardProjectPage(// $NON-NLS-1$
    "projectPage", // $NON-NLS-1$
    Policy.bind("CheckoutWizardProjectPage.heading"), SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_WIZBAN_SHARE));
    addPage(projectPage);
}
Also used : ISVNRepositorySourceProvider(org.tigris.subversion.subclipse.ui.ISVNRepositorySourceProvider) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException)

Example 3 with ISVNRepositorySourceProvider

use of org.tigris.subversion.subclipse.ui.ISVNRepositorySourceProvider in project subclipse by subclipse.

the class CheckoutWizard method createLocation.

private ISVNRepositoryLocation createLocation() {
    createLocationPage.finish(new NullProgressMonitor());
    Properties properties = createLocationPage.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());
            }
        }
    }
    String url = properties.getProperty("url");
    if (createdRepositoryUrls.contains(url)) {
        return null;
    }
    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);
                    }
                }
            });
            createdRepositoryUrls.add(url);
        } catch (InterruptedException e) {
            return null;
        } 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 null;
        } 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 null;
            }
            if (keep)
                return root[0];
        }
    }
    return root[0];
}
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)

Example 4 with ISVNRepositorySourceProvider

use of org.tigris.subversion.subclipse.ui.ISVNRepositorySourceProvider in project subclipse by subclipse.

the class CheckoutWizard method getNextPage.

public IWizardPage getNextPage(IWizardPage page, boolean aboutToShow) {
    if (page == repositorySourceProviderPage) {
        ISVNRepositorySourceProvider selectedRepositorySourceProvider = repositorySourceProviderPage.getSelectedRepositorySourceProvider();
        if (selectedRepositorySourceProvider != null) {
            return wizardPageMap.get(selectedRepositorySourceProvider);
        } else {
            return createLocationPage;
        }
    }
    if (page instanceof SVNRepositoryProviderWizardPage) {
        if (aboutToShow) {
            ISVNRepositoryLocation newLocation = createLocation();
            if (newLocation != null) {
                locationPage.refreshLocations();
                selectionPage.setLocation(newLocation);
            }
        }
        return selectionPage;
    }
    if (page == locationPage) {
        if (locationPage.createNewLocation()) {
            if (repositorySourceProviderPage == null) {
                return createLocationPage;
            } else {
                return repositorySourceProviderPage;
            }
        } else {
            if (aboutToShow)
                selectionPage.setLocation(repositoryLocation);
            return selectionPage;
        }
    }
    if (page == createLocationPage) {
        if (aboutToShow) {
            ISVNRepositoryLocation newLocation = createLocation();
            if (newLocation != null) {
                locationPage.refreshLocations();
                selectionPage.setLocation(newLocation);
            }
        }
        return selectionPage;
    }
    if (page == selectionPage) {
        if (aboutToShow) {
            if (remoteFolders.length == 1) {
                BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

                    public void run() {
                        checkForProjectFile();
                        if (hasProjectFile) {
                            if (checkoutAsWithProjectFilePage != null) {
                                checkoutAsWithProjectFilePage.setText(Policy.bind("CheckoutWizardCheckoutAsPage.single", // $NON-NLS-1$
                                remoteFolders[0].getName()));
                                if (project == null) {
                                    try {
                                        project = SVNWorkspaceRoot.getProject(remoteFolders[0], null);
                                    } catch (Exception e) {
                                        project = SVNWorkspaceRoot.getProject(remoteFolders[0].getName());
                                    }
                                }
                                if (project != null)
                                    checkoutAsWithProjectFilePage.setProject(project.getName());
                            }
                        } else {
                            if (checkoutAsWithoutProjectFilePage != null) {
                                checkoutAsWithoutProjectFilePage.setText(Policy.bind("CheckoutWizardCheckoutAsPage.single", // $NON-NLS-1$
                                remoteFolders[0].getName()));
                                IProject project = null;
                                try {
                                    project = SVNWorkspaceRoot.getProject(remoteFolders[0], null);
                                } catch (Exception e) {
                                    project = SVNWorkspaceRoot.getProject(remoteFolders[0].getName());
                                }
                                checkoutAsWithoutProjectFilePage.setProject(project.getName());
                            // 
                            // checkoutAsWithoutProjectFilePage.setProject(remoteFolders[0].getName());
                            }
                        }
                    }
                });
            } else {
                if (checkoutAsMultiplePage != null)
                    checkoutAsMultiplePage.setText(Policy.bind("CheckoutWizardCheckoutAsPage.multiple", // $NON-NLS-1$
                    Integer.toString(remoteFolders.length)));
            }
        }
        if (remoteFolders.length > 1)
            return checkoutAsMultiplePage;
        else {
            if (hasProjectFile)
                return checkoutAsWithProjectFilePage;
            else
                return checkoutAsWithoutProjectFilePage;
        }
    }
    if (page == checkoutAsWithoutProjectFilePage) {
        if (checkoutAsWithoutProjectFilePage.useWizard())
            return null;
        else
            return projectPage;
    }
    if (page == checkoutAsMultiplePage || page == checkoutAsWithProjectFilePage)
        return projectPage;
    return super.getNextPage(page);
}
Also used : ISVNRepositorySourceProvider(org.tigris.subversion.subclipse.ui.ISVNRepositorySourceProvider) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) IProject(org.eclipse.core.resources.IProject)

Example 5 with ISVNRepositorySourceProvider

use of org.tigris.subversion.subclipse.ui.ISVNRepositorySourceProvider in project subclipse by subclipse.

the class SharingWizard method getLocation.

/**
 * Return an ISVNRepositoryLocation
 */
protected ISVNRepositoryLocation getLocation() throws TeamException {
    // If there is an autoconnect page then it has the location
    if (autoconnectPage != null) {
        return autoconnectPage.getLocation();
    }
    // If the import page has a location, use it.
    if (locationPage != null) {
        ISVNRepositoryLocation location = locationPage.getLocation();
        if (location != null)
            return location;
    }
    // Otherwise, get the location from the create location page
    getShell().getDisplay().syncExec(new Runnable() {

        public void run() {
            createLocationPage.finish(new NullProgressMonitor());
        }
    });
    final Properties properties = createLocationPage.getProperties();
    if (repositorySourceProviderPage != null) {
        ISVNRepositorySourceProvider selectedRepositorySourceProvider = repositorySourceProviderPage.getSelectedRepositorySourceProvider();
        if (selectedRepositorySourceProvider != null) {
            final SVNRepositoryProviderWizardPage wizardPage = wizardPageMap.get(selectedRepositorySourceProvider);
            if (wizardPage != null) {
                getShell().getDisplay().syncExec(new Runnable() {

                    public void run() {
                        // $NON-NLS-1$
                        properties.setProperty("url", wizardPage.getSelectedUrl());
                    }
                });
            }
        }
    }
    ISVNRepositoryLocation location = SVNProviderPlugin.getPlugin().getRepositories().createRepository(properties);
    return location;
}
Also used : ISVNRepositorySourceProvider(org.tigris.subversion.subclipse.ui.ISVNRepositorySourceProvider) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNRepositoryProviderWizardPage(org.tigris.subversion.subclipse.ui.wizards.SVNRepositoryProviderWizardPage) Properties(java.util.Properties)

Aggregations

ISVNRepositorySourceProvider (org.tigris.subversion.subclipse.ui.ISVNRepositorySourceProvider)8 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 TeamException (org.eclipse.team.core.TeamException)6 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)5 Properties (java.util.Properties)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)3 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)3 IProject (org.eclipse.core.resources.IProject)2 IStatus (org.eclipse.core.runtime.IStatus)2 SVNProviderPlugin (org.tigris.subversion.subclipse.core.SVNProviderPlugin)2 SVNRepositoryProviderWizardPage (org.tigris.subversion.subclipse.ui.wizards.SVNRepositoryProviderWizardPage)2 IOException (java.io.IOException)1 CoreException (org.eclipse.core.runtime.CoreException)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1