use of org.tigris.subversion.subclipse.ui.operations.CommitOperation in project subclipse by subclipse.
the class CommitAction method execute.
/*
* get non added resources and prompts for resources to be added
* prompts for comments
* add non added files
* commit selected files
* @see SVNAction#execute(IAction)
*/
public void execute(IAction action) throws InvocationTargetException, InterruptedException {
statusMap = new HashMap();
final IResource[] resources = getSelectedResources();
final List resourcesToBeAdded = new ArrayList();
final List resourcesToBeDeleted = new ArrayList();
if (action != null && !action.isEnabled()) {
action.setEnabled(true);
} else {
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
// search for modified or added, non-ignored resources in the selection.
IResource[] modified = getChangeSetResources(getModifiedResources(resources, monitor));
// if no changes since last commit, do not show commit dialog.
if (modified.length == 0) {
MessageDialog.openInformation(getShell(), Policy.bind("CommitDialog.title"), // $NON-NLS-1$ //$NON-NLS-2$
Policy.bind("CommitDialog.noChanges"));
commit = false;
} else {
ProjectProperties projectProperties = ProjectProperties.getProjectProperties(modified[0]);
commit = confirmCommit(modified, projectProperties);
}
// resources that were selected.
if (commit) {
for (int i = 0; i < resourcesToCommit.length; i++) {
IResource resource = resourcesToCommit[i];
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
if (svnResource.exists() && !svnResource.isManaged())
resourcesToBeAdded.add(resource);
if (svnResource.getStatus().isMissing())
resourcesToBeDeleted.add(resource);
}
}
} catch (TeamException e) {
throw new InvocationTargetException(e);
}
}
}, true, /* cancelable */
PROGRESS_BUSYCURSOR);
if (!commit) {
// user canceled
return;
}
CommitOperation commitOperation = new CommitOperation(getTargetPart(), resources, (IResource[]) resourcesToBeAdded.toArray(new IResource[resourcesToBeAdded.size()]), (IResource[]) resourcesToBeDeleted.toArray(new IResource[resourcesToBeDeleted.size()]), resourcesToCommit, commitComment, keepLocks);
commitOperation.setCanRunAsJob(canRunAsJob);
commitOperation.run();
}
}
use of org.tigris.subversion.subclipse.ui.operations.CommitOperation in project subclipse by subclipse.
the class CommitSynchronizeOperation method run.
/* (non-Javadoc)
* @see org.eclipse.team.examples.filesystem.ui.FileSystemSynchronizeOperation#run(org.eclipse.team.examples.filesystem.FileSystemProvider, org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor)
*/
protected void run(SVNTeamProvider provider, SyncInfoSet set, IProgressMonitor monitor) {
if (set.hasConflicts() || set.hasIncomingChanges()) {
switch(promptForConflicts(getShell(), set)) {
case 0:
// Yes, commit non-conflicts
set.removeConflictingNodes();
set.removeIncomingNodes();
break;
case 1:
// No, stop here
return;
default:
return;
}
}
if (confirmCommit(set)) {
final IResource[][] resourcesToBeAdded = new IResource[][] { null };
final IResource[][] resourcesToBeDeleted = new IResource[][] { null };
List toBeAddedList = new ArrayList();
List toBeDeletedList = new ArrayList();
for (int i = 0; i < resourcesToCommit.length; i++) {
IResource resource = resourcesToCommit[i];
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
try {
if (!svnResource.isManaged())
toBeAddedList.add(resource);
if (svnResource.getStatus().isMissing())
toBeDeletedList.add(resource);
} catch (SVNException e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
}
}
resourcesToBeAdded[0] = new IResource[toBeAddedList.size()];
toBeAddedList.toArray(resourcesToBeAdded[0]);
resourcesToBeDeleted[0] = new IResource[toBeDeletedList.size()];
toBeDeletedList.toArray(resourcesToBeDeleted[0]);
try {
CommitOperation commit = new CommitOperation(getPart(), resourcesToCommit, resourcesToBeAdded[0], resourcesToBeDeleted[0], resourcesToCommit, commitComment, keepLocks);
commit.run();
} catch (InvocationTargetException e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
} catch (InterruptedException e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
}
}
}
Aggregations