use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.
the class MergeWizardUnblockRevisionsPage method refresh.
private void refresh() {
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
monitor.setTaskName(Messages.MergeWizardUnblockRevisionsPage_retrievingRemoteResource);
monitor.beginTask(Messages.MergeWizardUnblockRevisionsPage_retrievingRemoteResource, 2);
monitor.worked(1);
remoteResource = repositoryLocation.getRemoteFile(new SVNUrl(fromUrl));
monitor.worked(1);
monitor.done();
} catch (Exception e) {
Activator.handleError(e);
}
}
};
setPageComplete(false);
setErrorMessage(null);
fromUrl = standardPage.getFromUrl();
ISVNMergeInfo mergeInfo = standardPage.getMergeInfo();
if (mergeInfo == null) {
entries = new ILogEntry[0];
return;
}
revisionRanges = mergeInfo.getRevisionRange(fromUrl);
remoteResource = null;
try {
getContainer().run(false, false, runnable);
if (remoteResource == null) {
setErrorMessage(Messages.MergeWizardUnblockRevisionsPage_errorRetrievingRemoteResource);
entries = new ILogEntry[0];
} else
getLogEntries();
} catch (Exception e) {
setErrorMessage(e.getMessage());
entries = new ILogEntry[0];
}
if (tableHistoryViewer.getInput() == null)
tableHistoryViewer.setInput(fromUrl);
else
tableHistoryViewer.refresh();
setPageComplete(canFinish());
}
use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.
the class MergeWizardAdvancedPage method showLog.
private void showLog(Text text) {
ISVNRemoteResource remoteResource = null;
if (text == fromRevisionText) {
try {
fromUrl = new SVNUrl(getUrl(getFrom()));
remoteResource = svnResource.getRepository().getRemoteFile(fromUrl);
} catch (Exception e) {
Activator.handleError(Messages.MergeWizardAdvancedPage_showLogError, e);
MessageDialog.openError(getShell(), Messages.MergeWizardAdvancedPage_showLog, e.toString());
return;
}
if (remoteResource == null) {
MessageDialog.openError(getShell(), Messages.MergeWizardAdvancedPage_showLog, Messages.MergeWizardAdvancedPage_invalidUrl + getFrom());
return;
}
}
if (text == toRevisionText) {
try {
toUrl = new SVNUrl(getUrl(getTo()));
remoteResource = svnResource.getRepository().getRemoteFile(toUrl);
} catch (Exception e) {
Activator.handleError(Messages.MergeWizardAdvancedPage_showLogError, e);
MessageDialog.openError(getShell(), Messages.MergeWizardAdvancedPage_showLog, e.toString());
return;
}
if (remoteResource == null) {
MessageDialog.openError(getShell(), Messages.MergeWizardAdvancedPage_showLog, Messages.MergeWizardAdvancedPage_invalidUrl + getTo());
return;
}
}
HistoryDialog dialog = null;
if ((text == fromRevisionText) || (text == toRevisionText))
dialog = new HistoryDialog(getShell(), remoteResource);
else
dialog = new HistoryDialog(getShell(), resource);
if (dialog.open() == HistoryDialog.CANCEL)
return;
ILogEntry[] selectedEntries = dialog.getSelectedLogEntries();
if (selectedEntries.length == 0)
return;
if ((text != null) && useFromButton.getSelection()) {
fromRevisionText.setText(Long.toString(selectedEntries[selectedEntries.length - 1].getRevision().getNumber() - 1));
fromRevisionButton.setSelection(true);
fromHeadButton.setSelection(false);
toRevisionText.setText(Long.toString(selectedEntries[0].getRevision().getNumber()));
toRevisionButton.setSelection(true);
toHeadButton.setSelection(false);
fromRevisionText.setEnabled(true);
toRevisionText.setEnabled(true);
return;
}
if ((text == fromRevisionText) || ((text == null) && (fromRevisionText.getText().trim().length() == 0))) {
fromRevisionText.setText(Long.toString(selectedEntries[0].getRevision().getNumber()));
fromRevisionButton.setSelection(true);
fromHeadButton.setSelection(false);
fromRevisionText.setEnabled(true);
}
if (text == toRevisionText) {
toRevisionText.setText(Long.toString(selectedEntries[0].getRevision().getNumber()));
toRevisionButton.setSelection(true);
toHeadButton.setSelection(false);
toRevisionText.setEnabled(true);
}
}
use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.
the class MergeWizardAdvancedPage method initializeLocations.
private void initializeLocations() {
combosInitialized = true;
MergeWizard wizard = (MergeWizard) getWizard();
resource = wizard.getResource();
resources = wizard.getResources();
svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
mergeInfoPaths = null;
repositoryLocation = svnResource.getRepository().getLocation();
if (((MergeWizard) getWizard()).suggestMergeSources()) {
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.setTaskName(Messages.MergeWizardStandardPage_retrievingMergeSourceInfo);
monitor.beginTask(Messages.MergeWizardStandardPage_retrievingMergeSourceInfo, IProgressMonitor.UNKNOWN);
// $NON-NLS-1$
monitor.subTask("");
ISVNClientAdapter svnClient = null;
try {
svnClient = svnResource.getRepository().getSVNClient();
try {
mergeInfoPaths = svnClient.suggestMergeSources(new SVNUrl(commonRoot), SVNRevision.HEAD);
} catch (Exception e1) {
}
} catch (Exception e) {
Activator.handleError(e);
} finally {
svnResource.getRepository().returnSVNClient(svnClient);
}
monitor.done();
}
};
try {
getContainer().run(true, false, runnable);
} catch (Exception e2) {
Activator.handleError(e2);
}
}
boolean valueAdded = false;
List<String> fromUrls = new ArrayList<String>();
if (mergeInfoPaths != null) {
for (int i = 0; i < mergeInfoPaths.length; i++) {
String url = mergeInfoPaths[i].substring(repositoryLocation.length());
if (!fromUrls.contains(url))
fromUrls.add(url);
valueAdded = true;
}
}
String previousFromUrls = null;
String previousFromUrl = null;
try {
previousFromUrls = Activator.getDefault().getDialogSettings().get("mergeFromUrls_" + commonRoot);
} catch (Exception e) {
}
if (previousFromUrls != null) {
String[] urls = previousFromUrls.split("\\,");
for (String url : urls) {
if (!fromUrls.contains(url))
fromUrls.add(url);
valueAdded = true;
}
if (urls.length > 0)
previousFromUrl = urls[0];
}
if (!valueAdded && commonRoot != null) {
fromUrls.add(commonRoot.substring(repositoryLocation.length()));
}
for (String url : fromUrls) {
fromCombo.add(url);
toCombo.add(url);
}
if (previousFromUrl != null)
fromCombo.setText(previousFromUrl);
else if (fromCombo.getItemCount() > 0)
fromCombo.setText(fromCombo.getItem(0));
if (fromCombo.getText() != null && fromCombo.getText().length() > 0) {
try {
String previousToUrl = Activator.getDefault().getDialogSettings().get("mergeToUrl_" + fromCombo.getText());
if (previousToUrl != null) {
if (toCombo.indexOf(previousToUrl) == -1) {
toCombo.add(previousToUrl);
}
try {
boolean useFromDeselected = Activator.getDefault().getDialogSettings().getBoolean("mergeUseFromDeselected_" + fromCombo.getText());
if (useFromDeselected) {
useFromButton.setSelection(false);
}
} catch (Exception e) {
}
if (!useFromButton.getSelection()) {
toCombo.setVisible(true);
toCombo.setText(previousToUrl);
}
}
} catch (Exception e) {
}
}
}
use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.
the class MergeResultsView method createPartControl.
public void createPartControl(Composite parent) {
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.verticalSpacing = 2;
layout.marginWidth = 0;
layout.marginHeight = 2;
parent.setLayout(layout);
treeViewer = new TreeViewer(parent);
treeViewer.setLabelProvider(labelProvider);
treeViewer.setContentProvider(new MergeResultsViewContentProvider());
treeViewer.setUseHashlookup(true);
GridData layoutData = new GridData();
layoutData.grabExcessHorizontalSpace = true;
layoutData.grabExcessVerticalSpace = true;
layoutData.horizontalAlignment = GridData.FILL;
layoutData.verticalAlignment = GridData.FILL;
treeViewer.getControl().setLayoutData(layoutData);
treeViewer.setInput(this);
treeViewer.addOpenListener(new IOpenListener() {
public void open(OpenEvent event) {
treeConflict = null;
IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
Object selectedItem = selection.getFirstElement();
MergeResult mergeResult = null;
if (selectedItem instanceof AdaptableMergeResult)
mergeResult = (MergeResult) selectedItem;
if (selectedItem instanceof AdaptableMergeResultsFolder) {
MergeResultsFolder mergeResultsFolder = (MergeResultsFolder) selectedItem;
mergeResult = mergeResultsFolder.getMergeResult();
}
if (mergeResult != null) {
if (mergeResult.getResource() instanceof IFile && mergeResult.isConflicted() && !mergeResult.isResolved()) {
editConflicts(mergeResult);
return;
}
if (mergeResult.getResource() instanceof IFile && mergeResult.hasTreeConflict() && !mergeResult.isTreeConflictResolved()) {
boolean addAddConflict = false;
if (mergeResult.getResource() != null && mergeResult.getResource().exists()) {
treeConflict = getTreeConflict(mergeResult.getResource());
if (treeConflict != null && treeConflict.getDescription() != null && treeConflict.getDescription().contains("local add") && treeConflict.getDescription().contains("incoming add")) {
// $NON-NLS-1$ //$NON-NLS-2$
addAddConflict = true;
}
if (!addAddConflict) {
openAction.run();
}
}
if (!addAddConflict) {
return;
}
}
if (!mergeResult.getAction().equals(MergeResult.ACTION_DELETE)) {
final ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(mergeResult.getResource());
if (!localResource.exists()) {
return;
}
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
try {
if (treeConflict != null) {
if (!localResource.isFolder()) {
SVNConflictDescriptor descriptor = treeConflict.getConflictDescriptor();
SVNConflictVersion rightVersion = descriptor.getSrcRightVersion();
try {
ISVNRemoteFile remoteFile = new RemoteFile(localResource.getRepository(), new SVNUrl(rightVersion.getReposURL() + "/" + rightVersion.getPathInRepos()), new SVNRevision.Number(rightVersion.getPegRevision()));
SVNLocalCompareInput compareInput = new SVNLocalCompareInput(localResource, remoteFile);
CompareUI.openCompareEditorOnPage(compareInput, getSite().getPage());
} catch (Exception e) {
}
}
return;
}
CompareUI.openCompareEditorOnPage(new SVNLocalCompareInput(localResource, SVNRevision.BASE), getSite().getPage());
} catch (SVNException e) {
if (!e.operationInterrupted()) {
Activator.handleError(Messages.MergeResultsView_compareError, e);
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.MergeResultsView_compareWithLatest, e.getLocalizedMessage());
}
} catch (SVNClientException e) {
Activator.handleError(Messages.MergeResultsView_compareError, e);
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.MergeResultsView_compareWithLatest, e.getLocalizedMessage());
}
}
});
}
}
}
});
treeViewer.getTree().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
boolean mergeOutputSelected = false;
IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
Iterator iter = selection.iterator();
while (iter.hasNext()) {
if (iter.next() instanceof MergeOutput) {
mergeOutputSelected = true;
break;
}
}
removeAction.setEnabled(mergeOutputSelected);
}
});
createMenus();
createToolbar();
getSite().setSelectionProvider(treeViewer);
if (Activator.getDefault().getPreferenceStore().getBoolean(CONFLICTS_ONLY_PREFERENCE))
setContentDescription(Messages.MergeResultsView_conflictsMode);
}
use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.
the class ShowRemoteHistoryAction method getSelectedRemoteResources.
protected ISVNRemoteResource[] getSelectedRemoteResources() {
MergeOutput mergeOutput = null;
ISVNRemoteResource remoteResource = null;
Iterator iter = fSelection.iterator();
while (iter.hasNext()) {
Object object = iter.next();
if (object instanceof MergeResult) {
MergeResult mergeResult = (MergeResult) object;
IResource resource = mergeResult.getResource();
mergeOutput = mergeResult.getMergeOutput();
MergeOptions mergeOptions = mergeOutput.getMergeOptions();
SVNUrl svnUrl = mergeOptions.getFromUrl();
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
try {
String resourceSubString = resource.getFullPath().toOSString().substring(mergeOutput.getTarget().length() + 1);
if (!resourceSubString.startsWith("/"))
// $NON-NLS-1$ //$NON-NLS-2$
resourceSubString = "/" + resourceSubString;
SVNUrl remoteResourceUrl = new SVNUrl(svnUrl.toString() + // $NON-NLS-1$ //$NON-NLS-2$
resourceSubString.replaceAll("\\\\", "/"));
remoteResource = svnResource.getRepository().getRemoteFile(remoteResourceUrl);
} catch (Exception e) {
Activator.handleError(Messages.ShowRemoteHistoryAction_error, e);
MessageDialog.openError(getShell(), Messages.ShowRemoteHistoryAction_title, e.getLocalizedMessage());
}
break;
}
if (object instanceof MergeResultsFolder) {
MergeResultsFolder mergeResultsFolder = (MergeResultsFolder) object;
IContainer folder = mergeResultsFolder.getFolder();
mergeOutput = mergeResultsFolder.getMergeOutput();
MergeOptions mergeOptions = mergeOutput.getMergeOptions();
SVNUrl svnUrl = mergeOptions.getFromUrl();
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(folder);
try {
String resourceSubString = folder.getFullPath().toOSString().substring(mergeOutput.getTarget().length() + 1);
if (!resourceSubString.startsWith("/"))
// $NON-NLS-1$ //$NON-NLS-2$
resourceSubString = "/" + resourceSubString;
SVNUrl remoteResourceUrl = new SVNUrl(svnUrl.toString() + // $NON-NLS-1$ //$NON-NLS-2$
resourceSubString.replaceAll("\\\\", "/"));
remoteResource = svnResource.getRepository().getRemoteFile(remoteResourceUrl);
} catch (Exception e) {
Activator.handleError(Messages.ShowRemoteHistoryAction_error, e);
MessageDialog.openError(getShell(), Messages.ShowRemoteHistoryAction_title, e.getLocalizedMessage());
}
break;
}
}
if (remoteResource != null) {
ISVNRemoteResource[] selectedResource = { remoteResource };
SVNRevision.Number startRevision = null;
try {
startRevision = (SVNRevision.Number) SVNRevision.getRevision(Long.toString(mergeOutput.getLowerRevision()));
} catch (ParseException e) {
}
SVNRevision.Number endRevision = null;
if (mergeOutput.getUpperRevision() > 0) {
try {
endRevision = (SVNRevision.Number) SVNRevision.getRevision(Long.toString(mergeOutput.getUpperRevision()));
} catch (ParseException e) {
}
}
HistorySearchViewerFilter historySearchViewerFilter = new HistorySearchViewerFilter(null, null, null, null, true, startRevision, endRevision);
SVNHistoryPage.setHistorySearchViewerFilter(historySearchViewerFilter);
return selectedResource;
}
return new ISVNRemoteResource[0];
}
Aggregations