Search in sources :

Example 21 with ISVNRepositoryLocation

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

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

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

the class CheckoutWizardLocationPage method refreshLocations.

public void refreshLocations() {
    ISVNRepositoryLocation[] locations = SVNUIPlugin.getPlugin().getRepositoryManager().getKnownRepositoryLocations(null);
    Arrays.sort(locations, new RepositoryComparator());
    AdaptableList input = new AdaptableList(locations);
    table.setInput(input);
    if (locations.length == 0) {
        newButton.setSelection(true);
        existingButton.setSelection(false);
        table.getTable().setEnabled(false);
        setPageComplete(true);
    } else {
        existingButton.setSelection(true);
        newButton.setSelection(false);
        table.getTable().setEnabled(true);
    }
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) AdaptableList(org.tigris.subversion.subclipse.ui.util.AdaptableList) RepositoryComparator(org.tigris.subversion.subclipse.core.repo.RepositoryComparator)

Example 24 with ISVNRepositoryLocation

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

the class CheckoutWizardLocationPage method createControl.

public void createControl(Composite parent) {
    final CheckoutWizard wizard = (CheckoutWizard) getWizard();
    Composite outerContainer = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    outerContainer.setLayout(layout);
    outerContainer.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
    newButton = new Button(outerContainer, SWT.RADIO);
    // $NON-NLS-1$
    newButton.setText(Policy.bind("CheckoutWizardLocationPage.new"));
    existingButton = new Button(outerContainer, SWT.RADIO);
    // $NON-NLS-1$
    existingButton.setText(Policy.bind("CheckoutWizardLocationPage.existing"));
    table = createTable(outerContainer, 1);
    table.setContentProvider(new WorkbenchContentProvider());
    table.setLabelProvider(new WorkbenchLabelProvider());
    table.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            result = (ISVNRepositoryLocation) ((IStructuredSelection) table.getSelection()).getFirstElement();
            wizard.setLocation(result);
            setPageComplete(true);
        }
    });
    existingButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            if (newButton.getSelection()) {
                table.getTable().setEnabled(false);
                result = null;
            } else {
                table.getTable().setEnabled(true);
                result = (ISVNRepositoryLocation) ((IStructuredSelection) table.getSelection()).getFirstElement();
                wizard.setLocation(result);
            }
            setPageComplete(newButton.getSelection() || !table.getSelection().isEmpty());
        }
    });
    // $NON-NLS-1$
    setMessage(Policy.bind("CheckoutWizardLocationPage.text"));
    setControl(outerContainer);
    refreshLocations();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider)

Example 25 with ISVNRepositoryLocation

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

the class UpdateSynchronizeOperation method groupByRepository.

/**
 * This takes the items we are going to update and groups them by repository We need to do this in
 * case a project uses svn:externals to point to a different repository. If we do not do this,
 * then later when we find the highest revision number to update to, we can have a set of
 * resources that span multiple repositories (each with their own revision numbers)
 *
 * @param resourceArray - Complete list of resources we will update
 * @param set - The set of selected items in the synch view
 * @return Map - the resources grouped by ISVNRepositoryLocation
 */
private Map<ISVNRepositoryLocation, List<IResource>> groupByRepository(IResource[] resourceArray, SyncInfoSet set) {
    Map<ISVNRepositoryLocation, List<IResource>> resourceMap = new HashMap<ISVNRepositoryLocation, List<IResource>>();
    final SyncInfo[] syncInfos = set.getSyncInfos();
    for (int i = 0; i < syncInfos.length; i++) {
        SVNStatusSyncInfo syncInfo = (SVNStatusSyncInfo) syncInfos[i];
        IResource local = syncInfo.getLocal();
        resourceLoop: for (int j = 0; j < resourceArray.length; j++) {
            if (resourceArray[j].equals(local)) {
                IResourceVariant remote = syncInfo.getRemote();
                if (remote != null && remote instanceof ISVNRemoteResource) {
                    if (syncInfo.getRemoteResourceStatus() != null) {
                        ISVNRepositoryLocation repos = syncInfo.getRemoteResourceStatus().getRepository();
                        List<IResource> resList = (List<IResource>) resourceMap.get(repos);
                        if (resList == null)
                            resList = new ArrayList<IResource>(resourceArray.length);
                        resList.add(resourceArray[j]);
                        resourceMap.put(repos, resList);
                    }
                }
                break resourceLoop;
            }
        }
    }
    return resourceMap;
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNStatusSyncInfo(org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo) HashMap(java.util.HashMap) SVNStatusSyncInfo(org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo) SyncInfo(org.eclipse.team.core.synchronize.SyncInfo) ArrayList(java.util.ArrayList) List(java.util.List) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) IResource(org.eclipse.core.resources.IResource) IResourceVariant(org.eclipse.team.core.variants.IResourceVariant)

Aggregations

ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)69 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)20 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 IResource (org.eclipse.core.resources.IResource)15 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)15 TeamException (org.eclipse.team.core.TeamException)14 ArrayList (java.util.ArrayList)13 SVNException (org.tigris.subversion.subclipse.core.SVNException)13 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)13 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)12 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11 File (java.io.File)10 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)9 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)8 LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)8 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)8 Iterator (java.util.Iterator)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 ISVNRemoteFolder (org.tigris.subversion.subclipse.core.ISVNRemoteFolder)7 List (java.util.List)6