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];
}
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);
}
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);
}
}
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();
}
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;
}
Aggregations