use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.
the class DifferencesDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
if (// $NON-NLS-1$
title == null)
// $NON-NLS-1$
getShell().setText(Policy.bind("DifferencesDialog.compare"));
else
getShell().setText(title);
Composite composite = new Composite(parent, SWT.NULL);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
Group fromGroup = new Group(composite, SWT.NULL);
// $NON-NLS-1$
fromGroup.setText(Policy.bind("ShowDifferencesAsUnifiedDiffDialog.compareFrom"));
fromGroup.setLayout(new GridLayout(3, false));
fromGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
Label fromUrlLabel = new Label(fromGroup, SWT.NONE);
// $NON-NLS-1$
fromUrlLabel.setText(Policy.bind("ShowDifferencesAsUnifiedDiffDialog.url"));
fromUrlText = new Text(fromGroup, SWT.BORDER);
fromUrlText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
if (fromUrl == null) {
fromUrlText.setText(remoteResources[0].getUrl().toString());
} else {
fromUrlText.setText(fromUrl.toString());
}
Button bb = new Button(fromGroup, SWT.PUSH);
// $NON-NLS-1$
bb.setText(Policy.bind("SwitchDialog.browse"));
bb.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ChooseUrlDialog dialog = new ChooseUrlDialog(getShell(), fromResource.getResource());
if ((dialog.open() == ChooseUrlDialog.OK) && (dialog.getUrl() != null)) {
fromUrlText.setText(dialog.getUrl());
}
}
});
Composite fromRevisionGroup = new Composite(fromGroup, SWT.NULL);
GridLayout fromRevisionLayout = new GridLayout();
fromRevisionLayout.numColumns = 3;
fromRevisionLayout.marginWidth = 0;
fromRevisionLayout.marginHeight = 0;
fromRevisionGroup.setLayout(fromRevisionLayout);
fromRevisionGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1));
fromHeadButton = new Button(fromRevisionGroup, SWT.CHECK);
// $NON-NLS-1$
fromHeadButton.setText(Policy.bind("ShowDifferencesAsUnifiedDiffDialog.head"));
GridData data = new GridData();
data.horizontalSpan = 3;
fromHeadButton.setLayoutData(data);
Label fromRevisionLabel = new Label(fromRevisionGroup, SWT.NONE);
fromRevisionLabel.setText(// $NON-NLS-1$
Policy.bind("ShowDifferencesAsUnifiedDiffDialog.revision"));
fromHeadButton.setSelection(true);
fromRevisionText = new Text(fromRevisionGroup, SWT.BORDER);
fromRevisionText.setLayoutData(new GridData(40, SWT.DEFAULT));
fromRevisionText.setEnabled(false);
fromLogButton = new Button(fromRevisionGroup, SWT.PUSH);
// $NON-NLS-1$
fromLogButton.setText(Policy.bind("ShowDifferencesAsUnifiedDiffDialog.showLog"));
fromLogButton.setEnabled(false);
fromLogButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
showLog(e.getSource());
}
});
Group toGroup = new Group(composite, SWT.NULL);
// $NON-NLS-1$
toGroup.setText(Policy.bind("ShowDifferencesAsUnifiedDiffDialog.compareTo"));
toGroup.setLayout(new GridLayout(3, false));
toGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
Label toUrlLabel = new Label(toGroup, SWT.NONE);
// $NON-NLS-1$
toUrlLabel.setText(Policy.bind("ShowDifferencesAsUnifiedDiffDialog.url"));
toUrlText = new Text(toGroup, SWT.BORDER);
toUrlText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
if (toUrl == null) {
if (remoteResources.length < 2 || remoteResources[1] == null)
toUrlText.setText(remoteResources[0].getUrl().toString());
else
toUrlText.setText(remoteResources[1].getUrl().toString());
} else {
toUrlText.setText(toUrl.toString());
}
bb = new Button(toGroup, SWT.PUSH);
// $NON-NLS-1$
bb.setText(Policy.bind("SwitchDialog.browse"));
bb.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
IResource resouce = null;
if (remoteResources.length < 2 || remoteResources[1] == null)
resouce = remoteResources[0].getResource();
else
resouce = remoteResources[1].getResource();
ChooseUrlDialog dialog = new ChooseUrlDialog(getShell(), resouce);
if ((dialog.open() == ChooseUrlDialog.OK) && (dialog.getUrl() != null)) {
toUrlText.setText(dialog.getUrl());
}
}
});
Composite toRevisionGroup = new Composite(toGroup, SWT.NULL);
GridLayout toRevisionLayout = new GridLayout();
toRevisionLayout.numColumns = 3;
toRevisionLayout.marginWidth = 0;
toRevisionLayout.marginHeight = 0;
toRevisionGroup.setLayout(toRevisionLayout);
toRevisionGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1));
toHeadButton = new Button(toRevisionGroup, SWT.CHECK);
// $NON-NLS-1$
toHeadButton.setText(Policy.bind("ShowDifferencesAsUnifiedDiffDialog.toHead"));
data = new GridData();
data.horizontalSpan = 3;
toHeadButton.setLayoutData(data);
Label toRevisionLabel = new Label(toRevisionGroup, SWT.NONE);
toRevisionLabel.setText(// $NON-NLS-1$
Policy.bind("ShowDifferencesAsUnifiedDiffDialog.toRevision"));
toHeadButton.setSelection(true);
toRevisionText = new Text(toRevisionGroup, SWT.BORDER);
toRevisionText.setLayoutData(new GridData(40, SWT.DEFAULT));
toRevisionText.setEnabled(false);
toLogButton = new Button(toRevisionGroup, SWT.PUSH);
// $NON-NLS-1$
toLogButton.setText(Policy.bind("ShowDifferencesAsUnifiedDiffDialog.showToLog"));
toLogButton.setEnabled(false);
toLogButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
showLog(e.getSource());
}
});
if (fromRevision != null) {
fromRevisionText.setText(fromRevision);
fromRevisionText.setEnabled(true);
fromLogButton.setEnabled(true);
fromHeadButton.setSelection(false);
}
if (toRevision == null) {
if (fromResource == toResource) {
if (fromRevision == null) {
ISVNRemoteResource resource = (ISVNRemoteResource) fromResource;
String fromRev = resource.getLastChangedRevision().toString();
int from = Integer.parseInt(fromRev);
from--;
toRevision = Integer.toString(from);
} else {
int from = Integer.parseInt(fromRevision);
from--;
toRevision = Integer.toString(from);
}
} else {
ISVNRemoteResource resource = (ISVNRemoteResource) toResource;
toRevision = resource.getLastChangedRevision().toString();
}
}
if (toRevision != null) {
toRevisionText.setText(toRevision);
toRevisionText.setEnabled(true);
toLogButton.setEnabled(true);
toHeadButton.setSelection(false);
}
Group fileGroup = new Group(composite, SWT.NULL);
// $NON-NLS-1$
fileGroup.setText(Policy.bind("ShowDifferencesAsUnifiedDiffDialog.compareType"));
fileGroup.setLayout(new GridLayout(3, false));
fileGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
compareButton = new Button(fileGroup, SWT.RADIO);
compareButton.setText(// $NON-NLS-1$
Policy.bind("ShowDifferencesAsUnifiedDiffDialog.graphical"));
data = new GridData();
data.horizontalSpan = 3;
compareButton.setLayoutData(data);
diffButton = new Button(fileGroup, SWT.RADIO);
// $NON-NLS-1$
diffButton.setText(Policy.bind("DifferencesDialog.diff"));
compareButton.setSelection(true);
fileText = new Text(fileGroup, SWT.BORDER);
data = new GridData(SWT.FILL, SWT.CENTER, true, false);
data.widthHint = 450;
fileText.setLayoutData(data);
fileText.setEnabled(false);
browseButton = new Button(fileGroup, SWT.PUSH);
// $NON-NLS-1$
browseButton.setText(Policy.bind("ShowDifferencesAsUnifiedDiffDialog.browse"));
browseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
dialog.setText(// $NON-NLS-1$
Policy.bind("ShowDifferencesAsUnifiedDiffDialog.fileDialogText"));
// $NON-NLS-1$
dialog.setFileName("revision.diff");
String outFile = dialog.open();
if (outFile != null)
fileText.setText(outFile);
}
});
ModifyListener modifyListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
setOkButtonStatus();
}
};
SelectionListener selectionListener = new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
fromRevisionText.setEnabled(!fromHeadButton.getSelection());
fromLogButton.setEnabled(!fromHeadButton.getSelection());
toRevisionText.setEnabled(!toHeadButton.getSelection());
toLogButton.setEnabled(!toHeadButton.getSelection());
setOkButtonStatus();
if (e.getSource() == fromHeadButton && !fromHeadButton.getSelection()) {
fromRevisionText.selectAll();
fromRevisionText.setFocus();
}
if (e.getSource() == toHeadButton && !toHeadButton.getSelection()) {
toRevisionText.selectAll();
toRevisionText.setFocus();
}
}
};
SelectionListener compareTypeListener = new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (diffButton.getSelection()) {
fileText.setEnabled(true);
browseButton.setEnabled(true);
fileText.selectAll();
fileText.setFocus();
} else {
fileText.setEnabled(false);
browseButton.setEnabled(false);
}
setOkButtonStatus();
}
};
fileText.addModifyListener(modifyListener);
fromRevisionText.addModifyListener(modifyListener);
toRevisionText.addModifyListener(modifyListener);
fromHeadButton.addSelectionListener(selectionListener);
toHeadButton.addSelectionListener(selectionListener);
compareButton.addSelectionListener(compareTypeListener);
diffButton.addSelectionListener(compareTypeListener);
FocusListener focusListener = new FocusAdapter() {
public void focusGained(FocusEvent e) {
((Text) e.getSource()).selectAll();
}
public void focusLost(FocusEvent e) {
((Text) e.getSource()).setText(((Text) e.getSource()).getText());
}
};
fromRevisionText.addFocusListener(focusListener);
toRevisionText.addFocusListener(focusListener);
fileText.addFocusListener(focusListener);
// Set F1 Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.SHOW_UNIFIED_DIFF_DIALOG);
return composite;
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.
the class BranchTagOperation method execute.
protected void execute(SVNTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws SVNException, InterruptedException {
if (branchCreated)
return;
branchCreated = true;
monitor.beginTask(null, 100);
try {
BranchTagCommand command = new BranchTagCommand(provider.getSVNWorkspaceRoot(), getResources(), sourceUrls, destinationUrl, message, createOnServer, revision);
command.setMakeParents(makeParents);
command.setMultipleTransactions(multipleTransactions);
command.run(Policy.subMonitorFor(monitor, 1000));
if (svnExternals != null) {
List<SVNUrl> copyToUrls = new ArrayList<SVNUrl>();
List<String> fileList = new ArrayList<String>();
Map<String, String> copyToMap = new HashMap<String, String>();
for (SVNExternal svnExternal : svnExternals) {
if (svnExternal.isSelected()) {
if (!fileList.contains(svnExternal.getFile().getAbsolutePath())) {
fileList.add(svnExternal.getFile().getAbsolutePath());
IResource[] localResources = SVNWorkspaceRoot.getResourcesFor(new Path(svnExternal.getFile().getPath()));
ISVNRemoteResource remoteResource = SVNWorkspaceRoot.getBaseResourceFor(localResources[0]);
for (SVNUrl sourceUrl : sourceUrls) {
if (remoteResource.getUrl().toString().startsWith(sourceUrl.toString())) {
SVNUrl copyToUrl = null;
SVNUrl destinationUrl = command.getDestinationUrl(sourceUrl.toString());
if (remoteResource.getUrl().toString().equals(sourceUrl.toString())) {
copyToUrl = destinationUrl;
} else {
try {
copyToUrl = new SVNUrl(destinationUrl + remoteResource.getUrl().toString().substring(sourceUrl.toString().length()));
} catch (MalformedURLException e) {
}
}
if (copyToUrl != null) {
copyToUrls.add(copyToUrl);
copyToMap.put(copyToUrl.toString(), svnExternal.getFile().getAbsolutePath());
}
break;
}
}
}
}
}
if (copyToUrls.size() > 0) {
ISVNClientAdapter svnClient = null;
try {
svnClient = provider.getSVNWorkspaceRoot().getRepository().getSVNClient();
for (SVNUrl copyToUrl : copyToUrls) {
String updatedProperty = getUpdatedSvnExternalsProperty(copyToUrl, copyToMap);
ISVNInfo info = svnClient.getInfo(copyToUrl);
svnClient.propertySet(copyToUrl, info.getRevision(), "svn:externals", updatedProperty, // $NON-NLS-1$
Policy.bind("BranchTagOperation.3"));
}
} catch (Exception e) {
throw SVNException.wrapException(e);
} finally {
provider.getSVNWorkspaceRoot().getRepository().returnSVNClient(svnClient);
}
}
}
SVNUIPlugin.getPlugin().getRepositoryManager().resourceCreated(null, null);
if (newAlias != null)
updateBranchTagProperty(resources[0]);
if (switchAfterTagBranch) {
for (int i = 0; i < sourceUrls.length; i++) {
SVNUrl switchDestinationUrl = command.getDestinationUrl(sourceUrls[i].toString());
// the copy command's destination URL can either be a path to an existing directory
// or a path to a new directory. In the former case the last path segment of the
// source path is automatically created at the destination
GetRemoteResourceCommand getRemoteResourceCommand = new GetRemoteResourceCommand(provider.getSVNWorkspaceRoot().getRepository(), switchDestinationUrl, SVNRevision.HEAD);
try {
getRemoteResourceCommand.run(null);
} catch (SVNException e) {
if (e.getStatus().getCode() == TeamException.UNABLE) {
switchDestinationUrl = destinationUrl;
} else {
throw e;
}
}
resources = getResources();
SwitchToUrlCommand switchToUrlCommand = new SwitchToUrlCommand(provider.getSVNWorkspaceRoot(), resources[i], switchDestinationUrl, SVNRevision.HEAD);
switchToUrlCommand.run(Policy.subMonitorFor(monitor, 100));
}
}
} catch (SVNException e) {
if (e.operationInterrupted()) {
showCancelledMessage();
} else {
collectStatus(e.getStatus());
}
} finally {
monitor.done();
}
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.
the class MergeDialog method showLog.
private void showLog(Text text) {
ISVNRemoteResource remoteResource = null;
if (text == fromRevisionText) {
try {
fromUrl = new SVNUrl(fromUrlCombo.getText());
remoteResource = svnResource.getRepository().getRemoteFile(fromUrl);
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), // $NON-NLS-1$
e.toString());
return;
}
if (remoteResource == null) {
MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), Policy.bind("MergeDialog.urlError") + " " + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
fromUrlCombo.getText());
return;
}
}
if (text == toRevisionText) {
try {
toUrl = new SVNUrl(toUrlCombo.getText());
remoteResource = svnResource.getRepository().getRemoteFile(toUrl);
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), // $NON-NLS-1$
e.toString());
return;
}
if (remoteResource == null) {
MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), Policy.bind("MergeDialog.urlError") + " " + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
toUrlCombo.getText());
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) && useFromUrlButton.getSelection()) {
fromRevisionText.setText(Long.toString(selectedEntries[selectedEntries.length - 1].getRevision().getNumber() - 1));
fromHeadButton.setSelection(false);
toRevisionText.setText(Long.toString(selectedEntries[0].getRevision().getNumber()));
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()));
fromHeadButton.setSelection(false);
fromRevisionText.setEnabled(true);
}
if (text == toRevisionText) {
toRevisionText.setText(Long.toString(selectedEntries[0].getRevision().getNumber()));
toHeadButton.setSelection(false);
toRevisionText.setEnabled(true);
}
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.
the class ShowDifferencesAsUnifiedDiffDialogWC method showLog.
private void showLog(Object sourceButton) {
try {
SVNUrl url = new SVNUrl(toUrlText.getText().trim());
ISVNRemoteResource remoteResource = SVNWorkspaceRoot.getSVNResourceFor(resource).getRepository().getRemoteFile(url);
HistoryDialog dialog = new HistoryDialog(getShell(), remoteResource);
if (dialog.open() == HistoryDialog.CANCEL)
return;
ILogEntry[] selectedEntries = dialog.getSelectedLogEntries();
if (selectedEntries.length == 0)
return;
toRevisionText.setText(Long.toString(selectedEntries[selectedEntries.length - 1].getRevision().getNumber()));
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("HistoryView.showDifferences"), // $NON-NLS-1$
e.getMessage());
}
setOkButtonStatus();
}
Aggregations