use of org.tigris.subversion.subclipse.ui.subscriber.SVNSynchronizeParticipant in project subclipse by subclipse.
the class SharingWizard method performFinish.
/*
* @see IWizard#performFinish
*/
public boolean performFinish() {
shareCanceled = false;
if (!WorkspacePathValidator.validateWorkspacePath())
return true;
final boolean[] result = new boolean[] { true };
try {
final boolean[] doSync = new boolean[] { false };
getContainer().run(true, /* fork */
true, /* cancel */
new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
// $NON-NLS-1$
monitor.beginTask("", 100);
if (autoconnectPage != null && (projectStatus != null)) {
// Autoconnect to the repository using svn/ directories
// Get the repository location (the get will add the locatin to the provider)
boolean isPreviouslyKnown = SVNProviderPlugin.getPlugin().getRepositories().isKnownRepository(projectStatus.getUrlString(), false);
// Validate the connection if the user wants to
boolean validate = autoconnectPage.getValidate();
if (validate && !isPreviouslyKnown) {
ISVNRepositoryLocation location = SVNProviderPlugin.getPlugin().getRepository(projectStatus.getUrlString());
// Do the validation
try {
location.validateConnection(new SubProgressMonitor(monitor, 50));
} catch (final TeamException e) {
// Exception validating. We can continue if the user wishes.
final boolean[] keep = new boolean[] { false };
getShell().getDisplay().syncExec(new Runnable() {
public void run() {
keep[0] = MessageDialog.openQuestion(getContainer().getShell(), Policy.bind(// $NON-NLS-1$
"SharingWizard.validationFailedTitle"), Policy.bind("SharingWizard.validationFailedText", new Object[] { e.getStatus().getMessage() }));
// $NON-NLS-1$
}
});
if (!keep[0]) {
// Remove the root
try {
if (!isPreviouslyKnown) {
SVNProviderPlugin.getPlugin().getRepositories().disposeRepository(location);
}
} catch (TeamException e1) {
SVNUIPlugin.openError(getContainer().getShell(), Policy.bind("exception"), null, e1, // $NON-NLS-1$
SVNUIPlugin.PERFORM_SYNC_EXEC);
}
result[0] = false;
return;
}
// They want to keep the connection anyway. Fall through.
}
}
// Set the sharing
SVNWorkspaceRoot.setSharing(project, new SubProgressMonitor(monitor, 50));
} else {
// No svn directory : Share the project
doSync[0] = true;
// Check if the directory exists on the server
ISVNRepositoryLocation location = null;
boolean isKnown = false;
boolean createDirectory = true;
try {
location = getLocation();
isKnown = SVNProviderPlugin.getPlugin().getRepositories().isKnownRepository(location.getLocation(), false);
// Purge any svn folders that may exists in subfolders
SVNWorkspaceRoot.getSVNFolderFor(project).unmanage(null);
// check if the remote directory already exist
String remoteDirectoryName = getRemoteDirectoryName();
ISVNRemoteFolder folder = location.getRemoteFolder(remoteDirectoryName);
if (folder.exists(new SubProgressMonitor(monitor, 50))) {
if (autoconnectPage == null) {
getShell().getDisplay().syncExec(new Runnable() {
public void run() {
if (!MessageDialog.openQuestion(getShell(), Policy.bind("SharingWizard.couldNotImport"), Policy.bind("SharingWizard.couldNotImportLong"))) {
// $NON-NLS-1$ //$NON-NLS-2$
shareCanceled = true;
return;
}
}
});
if (shareCanceled)
return;
}
createDirectory = false;
}
} catch (TeamException e) {
SVNUIPlugin.openError(getShell(), null, null, e, SVNUIPlugin.PERFORM_SYNC_EXEC);
result[0] = false;
doSync[0] = false;
return;
}
// Add the location to the provider if it is new
if (!isKnown) {
SVNProviderPlugin.getPlugin().getRepositories().addOrUpdateRepository(location);
}
// Create the remote module for the project
SVNWorkspaceRoot.shareProject(location, project, getRemoteDirectoryName(), finishPage.getComment(), createDirectory, new SubProgressMonitor(monitor, 50));
try {
project.refreshLocal(IProject.DEPTH_INFINITE, new SubProgressMonitor(monitor, 50));
} catch (CoreException ce) {
throw new TeamException(ce.getStatus());
}
// Map any nested projects to repository provider.
Collection<File> files = new ArrayList<File>();
collectProjectFilesFromDirectory(files, project.getLocation().toFile(), null, monitor);
for (File file : files) {
IResource resource = File2Resource.getResource(file.getParentFile());
IProject childProject = resource.getProject();
if (!childProject.equals(project)) {
RepositoryProvider.map(childProject, SVNProviderPlugin.getTypeId());
}
}
}
} catch (TeamException e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
}
});
if (shareCanceled)
return false;
if (doSync[0]) {
final List syncList = new ArrayList();
syncList.add(project);
try {
ISynchronizeParticipantReference[] references = TeamUI.getSynchronizeManager().getSynchronizeParticipants();
if (references != null) {
for (int i = 0; i < references.length; i++) {
ISynchronizeParticipantReference reference = references[i];
ISynchronizeParticipant participant = reference.getParticipant();
if (participant instanceof SVNSynchronizeParticipant) {
SVNSynchronizeParticipant svnParticipant = (SVNSynchronizeParticipant) participant;
IResource[] resources = svnParticipant.getResources();
if (resources != null) {
for (int j = 0; j < resources.length; j++) {
IResource resource = resources[j];
if (!resource.equals(project)) {
syncList.add(resource);
}
}
}
break;
}
}
}
} catch (Exception e) {
}
SynchronizeAction synchronizeAction = new SynchronizeAction() {
protected IResource[] getSelectedResources() {
IResource[] selection = new IResource[syncList.size()];
syncList.toArray(selection);
return selection;
}
};
synchronizeAction.run(null);
}
} catch (InterruptedException e) {
return true;
} catch (InvocationTargetException e) {
SVNUIPlugin.openError(getContainer().getShell(), null, null, e);
return false;
}
return result[0];
}
use of org.tigris.subversion.subclipse.ui.subscriber.SVNSynchronizeParticipant in project subclipse by subclipse.
the class SynchronizeWizard method performFinish.
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.IWizard#performFinish()
*/
public boolean performFinish() {
if (importWizard != null) {
return importWizard.performFinish();
} else {
IResource[] resources = selectionPage.getRootResources();
if (resources != null && resources.length > 0) {
SubscriberParticipant participant = new SVNSynchronizeParticipant(selectionPage.getSynchronizeScope());
TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[] { participant });
// We don't know in which site to show progress because a participant could actually be
// shown in multiple sites.
participant.run(null);
}
return true;
}
}
use of org.tigris.subversion.subclipse.ui.subscriber.SVNSynchronizeParticipant in project subclipse by subclipse.
the class SynchronizeAction method execute.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void execute(IAction action) throws InterruptedException, InvocationTargetException {
if (action != null && !action.isEnabled()) {
action.setEnabled(true);
} else {
IResource[] resources = getSelectedResources();
// First check if there is an existing matching participant
SVNSynchronizeParticipant participant = (SVNSynchronizeParticipant) SubscriberParticipant.getMatchingParticipant(SVNSynchronizeParticipant.ID, resources);
// If there isn't, create one and add to the manager
if (participant == null) {
participant = new SVNSynchronizeParticipant(new ResourceScope(resources));
TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[] { participant });
}
// If called by the accelerator key, for some reason targetPart is null, thus the check
if (getTargetPart() == null) {
// System.out.println("site:null"+ SVNUIPlugin.getActivePage().getActivePart().getSite());
participant.refresh(resources, "Synchronizing", "Synchronizing " + participant.getName(), SVNUIPlugin.getActivePage().getActivePart().getSite());
} else {
participant.refresh(resources, "Synchronizing", "Synchronizing " + participant.getName(), getTargetPart().getSite());
}
}
}
Aggregations