use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class ShowDifferencesAsUnifiedDiffActionWC method execute.
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
IResource[] resources = getSelectedResources();
boolean refreshFile = false;
for (int i = 0; i < resources.length; i++) {
if (resources[i] instanceof IFile && !resources[i].isSynchronized(Depth.immediates)) {
if (refreshFile || MessageDialog.openQuestion(getShell(), Policy.bind("DifferencesDialog.compare"), Policy.bind("CompareWithRemoteAction.fileChanged"))) {
refreshFile = true;
try {
resources[i].refreshLocal(Depth.immediates, new NullProgressMonitor());
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
} else {
break;
}
}
}
if (resources.length > 1) {
SvnWizardCompareMultipleResourcesWithBranchTagPage comparePage = new SvnWizardCompareMultipleResourcesWithBranchTagPage(resources);
SvnWizard wizard = new SvnWizard(comparePage);
SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
if (dialog.open() == SvnWizardDialog.OK) {
ISVNLocalResource[] localResources = new ISVNLocalResource[resources.length];
for (int i = 0; i < resources.length; i++) {
localResources[i] = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
}
try {
SVNLocalBranchTagCompareInput compareInput = new SVNLocalBranchTagCompareInput(localResources, comparePage.getUrls(), comparePage.getRevision(), getTargetPart());
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
} catch (SVNException e) {
MessageDialog.openError(getShell(), Policy.bind("ShowDifferencesAsUnifiedDiffDialog.branchTag"), e.getMessage());
}
}
return;
}
ShowDifferencesAsUnifiedDiffDialogWC dialog = new ShowDifferencesAsUnifiedDiffDialogWC(getShell(), resources[0], getTargetPart());
if (dialog.open() == ShowDifferencesAsUnifiedDiffDialogWC.OK) {
try {
if (dialog.isDiffToOutputFile())
dialog.getOperation().run();
if (!dialog.isDiffToOutputFile()) {
SVNRevision pegRevision = dialog.getPegRevision();
if (pegRevision == null) {
pegRevision = SVNRevision.HEAD;
}
if (resources[0] instanceof IContainer) {
ISVNRemoteFolder remoteFolder = new RemoteFolder(dialog.getSvnResource().getRepository(), dialog.getToUrl(), dialog.getToRevision());
((RemoteFolder) remoteFolder).setPegRevision(pegRevision);
SVNLocalCompareInput compareInput = new SVNLocalCompareInput(dialog.getSvnResource(), remoteFolder, pegRevision);
compareInput.setDiffOperation(dialog.getOperation());
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
} else {
ISVNRemoteFile remoteFile = new RemoteFile(dialog.getSvnResource().getRepository(), dialog.getToUrl(), dialog.getToRevision());
((RemoteFile) remoteFile).setPegRevision(pegRevision);
SVNLocalCompareInput compareInput = new SVNLocalCompareInput(dialog.getSvnResource(), remoteFile, pegRevision);
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
}
}
} catch (SVNException e) {
MessageDialog.openError(getShell(), Policy.bind("ShowDifferencesAsUnifiedDiffDialog.branchTag"), e.getMessage());
}
}
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource 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.core.ISVNLocalResource in project subclipse by subclipse.
the class CommitAction method getModifiedResources.
/**
* get the modified and unadded resources in resources parameter
*/
protected IResource[] getModifiedResources(IResource[] resources, IProgressMonitor iProgressMonitor) throws SVNException {
boolean ignoreHiddenChanges = SVNProviderPlugin.getPlugin().getPluginPreferences().getBoolean(ISVNCoreConstants.PREF_IGNORE_HIDDEN_CHANGES);
IResource[] allResources = getSelectedResources(true);
List allSelections = new ArrayList();
for (int i = 0; i < allResources.length; i++) allSelections.add(allResources[i]);
List conflictFiles = new ArrayList();
final List modified = new ArrayList();
List unversionedFolders = new ArrayList();
hasUnaddedResources = false;
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
// This check is for when the action is called with unmanaged resources
if (svnResource.getRepository() == null) {
continue;
}
// if only one resource selected, get url. Commit dialog displays this.
if (resources.length == 1) {
url = svnResource.getStatus().getUrlString();
if ((url == null) || (resource.getType() == IResource.FILE))
url = Util.getParentUrl(svnResource);
}
boolean descend = true;
if (resource instanceof IContainer) {
outer: for (int j = 0; j < allResources.length; j++) {
if (allResources[j] == resource)
continue;
IContainer parent = allResources[j].getParent();
while (parent != null) {
if (parent.equals(resource)) {
descend = false;
break outer;
}
parent = parent.getParent();
}
}
}
// get adds, deletes, updates and property updates.
GetStatusCommand command = new GetStatusCommand(svnResource, descend, false);
command.run(iProgressMonitor);
ISVNStatus[] statuses = command.getStatuses();
boolean switched = false;
for (int j = 0; j < statuses.length; j++) {
if (SVNStatusUtils.isReadyForCommit(statuses[j]) || SVNStatusUtils.isMissing(statuses[j])) {
IResource currentResource = SVNWorkspaceRoot.getResourceFor(resource, statuses[j]);
if (currentResource != null && (descend == true || allSelections.contains(currentResource))) {
SVNProviderPlugin.getPlugin().getStatusCacheManager().updateCache(currentResource, statuses[j]);
ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(currentResource);
if (!localResource.isIgnored()) {
if (!SVNStatusUtils.isManaged(statuses[j])) {
if (!Util.isHidden(currentResource)) {
hasUnaddedResources = true;
if ((currentResource.getType() != IResource.FILE) && !isSymLink(currentResource))
unversionedFolders.add(currentResource);
else {
if (!modified.contains(currentResource)) {
modified.add(currentResource);
if (currentResource instanceof IContainer)
statusMap.put(currentResource, statuses[j].getPropStatus());
else
statusMap.put(currentResource, statuses[j].getTextStatus());
}
}
}
} else if (!ignoreHiddenChanges || !Util.isHidden(currentResource)) {
if (!modified.contains(currentResource)) {
if (statuses[j].isSwitched()) {
switched = true;
url = statuses[j].getUrlString();
}
modified.add(currentResource);
if (currentResource instanceof IContainer)
statusMap.put(currentResource, statuses[j].getPropStatus());
else {
statusMap.put(currentResource, statuses[j].getTextStatus());
if (SVNStatusUtils.isTextConflicted(statuses[j])) {
IFile conflictNewFile = (IFile) File2Resource.getResource(statuses[j].getConflictNew());
if (conflictNewFile != null)
conflictFiles.add(conflictNewFile);
IFile conflictOldFile = (IFile) File2Resource.getResource(statuses[j].getConflictOld());
if (conflictOldFile != null)
conflictFiles.add(conflictOldFile);
IFile conflictWorkingFile = (IFile) File2Resource.getResource(statuses[j].getConflictWorking());
if (conflictWorkingFile != null)
conflictFiles.add(conflictWorkingFile);
}
}
}
}
}
}
}
}
if (switched && modified.size() > 1) {
url = null;
}
}
IResource[] unaddedResources = getUnaddedResources(unversionedFolders, iProgressMonitor);
for (int i = 0; i < unaddedResources.length; i++) if (!modified.contains(unaddedResources[i]))
modified.add(unaddedResources[i]);
Iterator iter = conflictFiles.iterator();
while (iter.hasNext()) {
IFile conflictFile = (IFile) iter.next();
modified.remove(conflictFile);
statusMap.remove(conflictFile);
}
return (IResource[]) modified.toArray(new IResource[modified.size()]);
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class CompareWithRemoteAction method execute.
public void execute(IAction action) {
refresh = false;
fileSelected = false;
final IResource[] resources = getSelectedResources();
if (resources.length != 1 && !SVNRevision.BASE.equals(revision) && !SVNRevision.HEAD.equals(revision)) {
return;
}
for (int i = 0; i < resources.length; i++) {
if (resources[i] instanceof IFile) {
fileSelected = true;
if (!resources[i].isSynchronized(Depth.immediates)) {
refresh = MessageDialog.openQuestion(getShell(), Policy.bind("DifferencesDialog.compare"), Policy.bind("CompareWithRemoteAction.fileChanged"));
break;
}
}
}
try {
final ISVNLocalResource[] localResources = new ISVNLocalResource[resources.length];
for (int i = 0; i < resources.length; i++) {
localResources[i] = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
}
final ISVNLocalResource localResource = localResources[0];
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
try {
if (refresh) {
for (int i = 0; i < localResources.length; i++) {
if (resources[i] instanceof IFile) {
localResources[i].getResource().refreshLocal(Depth.immediates, monitor);
}
}
}
if (SVNRevision.BASE.equals(revision)) {
if (localResources.length == 1 && localResource.getResource() instanceof IFile) {
SVNLocalCompareInput compareInput = new SVNLocalCompareInput(localResource, revision);
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
} else {
SVNLocalBaseCompareInput compareInput = new SVNLocalBaseCompareInput(localResources, revision);
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
}
} else {
if (!fileSelected) {
SVNLocalCompareSummaryInput compareInput = new SVNLocalCompareSummaryInput(localResources, revision);
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
} else {
ISVNRemoteFile remoteFile = new RemoteFile(localResource.getRepository(), localResource.getUrl(), revision);
((RemoteFile) remoteFile).setPegRevision(revision);
SVNLocalCompareInput compareInput = new SVNLocalCompareInput(localResource, remoteFile);
ShowDifferencesAsUnifiedDiffOperationWC operation = null;
if (SVNRevision.HEAD.equals(revision)) {
File file = File.createTempFile("revision", ".diff");
file.deleteOnExit();
operation = new ShowDifferencesAsUnifiedDiffOperationWC(getTargetPart(), localResource.getFile(), localResource.getUrl(), SVNRevision.HEAD, file);
operation.setGraphicalCompare(true);
operation.run();
}
compareInput.setDiffOperation(operation);
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
}
}
} catch (Exception e) {
handle(e, null, null);
}
}
}, false, /* cancelable */
PROGRESS_BUSYCURSOR);
} catch (Exception e) {
handle(e, null, null);
}
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class ConfigureTagsAction method execute.
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
IResource[] resources = getSelectedResources();
ISVNLocalResource[] svnResources = new ISVNLocalResource[resources.length];
ISVNProperty lastProperty = null;
for (int i = 0; i < resources.length; i++) {
svnResources[i] = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
try {
// $NON-NLS-1$
ISVNProperty property = svnResources[i].getSvnProperty("subclipse:tags");
if (i > 0 && !propertiesEqual(property, lastProperty)) {
MessageDialog.openError(getShell(), Messages.ConfigureTagsAction_1, Messages.ConfigureTagsAction_2);
return;
}
lastProperty = property;
} catch (SVNException e) {
}
}
SvnWizardConfigureTagsPage configureTagsPage = new SvnWizardConfigureTagsPage(svnResources);
SvnWizard wizard = new SvnWizard(configureTagsPage);
SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
wizard.setParentDialog(dialog);
dialog.open();
}
Aggregations