use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.
the class SvnWizardConfigureTagsPage method createControls.
public void createControls(Composite parent) {
Composite composite = new Composite(parent, SWT.NULL);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite urlGroup = new Composite(composite, SWT.NONE);
GridLayout urlLayout = new GridLayout();
urlLayout.numColumns = 2;
urlGroup.setLayout(urlLayout);
urlGroup.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
Label urlLabel = new Label(urlGroup, SWT.NONE);
// $NON-NLS-1$
urlLabel.setText(Policy.bind("ConfigureTagsDialog.url"));
Text urlText = new Text(urlGroup, SWT.BORDER);
GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
urlText.setLayoutData(data);
urlText.setEditable(false);
try {
if (svnResources.length == 1) {
urlText.setText(svnResources[0].getStatus().getUrlString());
} else {
// $NON-NLS-1$
urlText.setText(Policy.bind("SvnWizardConfigureTagsPage.0"));
}
svnClient = svnResources[0].getRepository().getSVNClient();
} catch (SVNException e) {
}
getBranchesAndTags();
treeViewer = new TreeViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
treeViewer.setContentProvider(new TagsContentProvider(svnResources[0].getResource()));
treeViewer.setLabelProvider(new TagsLabelProvider());
treeViewer.setInput(svnResources[0]);
data = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
data.heightHint = LIST_HEIGHT_HINT;
data.widthHint = LIST_WIDTH_HINT;
treeViewer.getControl().setLayoutData(data);
tagGroup = new Group(composite, SWT.NONE);
GridLayout tagLayout = new GridLayout();
tagLayout.numColumns = 3;
tagGroup.setLayout(tagLayout);
tagGroup.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
revisionLabel = new Label(tagGroup, SWT.NONE);
// $NON-NLS-1$
revisionLabel.setText(Policy.bind("ConfigureTagsDialog.revision"));
revisionText = new Text(tagGroup, SWT.BORDER);
data = new GridData();
data.widthHint = 50;
data.horizontalSpan = 2;
revisionText.setLayoutData(data);
nameLabel = new Label(tagGroup, SWT.NONE);
// $NON-NLS-1$
nameLabel.setText(Policy.bind("ConfigureTagsDialog.name"));
nameText = new Text(tagGroup, SWT.BORDER);
data = new GridData();
data.widthHint = 300;
data.horizontalSpan = 2;
nameText.setLayoutData(data);
pathLabel = new Label(tagGroup, SWT.NONE);
// $NON-NLS-1$
pathLabel.setText(Policy.bind("ConfigureTagsDialog.path"));
pathText = new Text(tagGroup, SWT.BORDER);
data = new GridData();
data.widthHint = 300;
pathText.setLayoutData(data);
browseButton = new Button(tagGroup, SWT.PUSH);
// $NON-NLS-1$
browseButton.setText(Policy.bind("ConfigureTagsDialog.browse"));
browseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ChooseUrlDialog dialog = new ChooseUrlDialog(getShell(), svnResources[0].getResource());
dialog.setIncludeBranchesAndTags(false);
dialog.setFoldersOnly(true);
if (dialog.open() == ChooseUrlDialog.CANCEL)
return;
final String url = dialog.getUrl();
if (url != null) {
nameText.setText(dialog.getName());
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
try {
SVNUrl svnUrl = new SVNUrl(url);
ISVNInfo svnInfo = svnClient.getInfo(svnUrl);
revisionText.setText(svnInfo.getLastChangedRevision().toString());
String repositoryUrl = svnResources[0].getRepository().getUrl().toString();
pathText.setText(url.substring(repositoryUrl.length()));
} catch (Exception e1) {
MessageDialog.openError(getShell(), Policy.bind("ConfigureTagsDialog.title"), // $NON-NLS-1$
e1.getMessage());
}
}
});
}
}
});
branchButton = new Button(tagGroup, SWT.CHECK);
// $NON-NLS-1$
branchButton.setText(Policy.bind("ConfigureTagsDialog.branch"));
data = new GridData();
data.horizontalSpan = 3;
branchButton.setLayoutData(data);
setTagGroupEnablement(false);
treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
if (tagUpdatePending) {
if (MessageDialog.openQuestion(getShell(), // $NON-NLS-1$
Policy.bind("ConfigureTagsDialog.title"), Policy.bind("ConfigureTagsDialog.pendingUpdate"))) {
// $NON-NLS-1$
new UpdateAction(previousAlias).run();
}
tagUpdatePending = false;
}
applyButton.setEnabled(false);
IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
boolean deleteEnabled = false;
Iterator iter = selection.iterator();
while (iter.hasNext()) {
if (iter.next() instanceof Alias) {
deleteEnabled = true;
break;
}
}
deleteButton.setEnabled(deleteEnabled);
if (selection.size() == 1 && selection.getFirstElement() instanceof Alias) {
Alias alias = (Alias) selection.getFirstElement();
previousAlias = alias;
if (alias.isBranch()) {
// $NON-NLS-1$
tagGroup.setText(Policy.bind("ConfigureTagsDialog.branchHeader"));
branchButton.setSelection(true);
} else {
// $NON-NLS-1$
tagGroup.setText(Policy.bind("ConfigureTagsDialog.tagHeader"));
branchButton.setSelection(false);
}
revisionText.setText(Integer.toString(alias.getRevision()));
nameText.setText(alias.getName());
if (// $NON-NLS-1$
alias.getRelativePath() == null)
// $NON-NLS-1$
pathText.setText("");
else
pathText.setText(alias.getRelativePath());
setTagGroupEnablement(true);
} else {
// $NON-NLS-1$
tagGroup.setText("");
// $NON-NLS-1$
revisionText.setText("");
// $NON-NLS-1$
nameText.setText("");
// $NON-NLS-1$
pathText.setText("");
branchButton.setSelection(false);
setTagGroupEnablement(false);
}
}
});
ModifyListener modifyListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
applyButton.setEnabled(canUpdate());
if (applyButton.isEnabled())
tagUpdatePending = true;
else
tagUpdatePending = false;
}
};
revisionText.addModifyListener(modifyListener);
nameText.addModifyListener(modifyListener);
pathText.addModifyListener(modifyListener);
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());
}
};
revisionText.addFocusListener(focusListener);
nameText.addFocusListener(focusListener);
pathText.addFocusListener(focusListener);
branchButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
applyButton.setEnabled(canUpdate());
if (applyButton.isEnabled())
tagUpdatePending = true;
else
tagUpdatePending = false;
}
});
MenuManager menuMgr = new MenuManager();
Tree tree = treeViewer.getTree();
Menu menu = menuMgr.createContextMenu(tree);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
Iterator iter = selection.iterator();
boolean deleteAdded = false;
boolean addAdded = false;
while (iter.hasNext()) {
Object selectedItem = iter.next();
if (!deleteAdded && selectedItem instanceof Alias) {
manager.add(deleteAction);
deleteAdded = true;
}
if (!addAdded && selectedItem instanceof ISVNRemoteFolder) {
manager.add(addBranchAction);
manager.add(addTagAction);
addAdded = true;
}
if (deleteAdded && addAdded)
break;
}
}
});
menuMgr.setRemoveAllWhenShown(true);
tree.setMenu(menu);
// set F1 help
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.CONFIGURE_TAGS_DIALOG);
}
use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.
the class ReplaceWithBranchTagWizardMainPage method showLog.
protected void showLog() {
ISVNRemoteResource remoteResource = null;
try {
remoteResource = SVNWorkspaceRoot.getSVNResourceFor(resources[0]).getRepository().getRemoteFile(new SVNUrl(urlCombo.getText()));
} 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$
urlCombo.getText());
return;
}
HistoryDialog dialog = new HistoryDialog(getShell(), remoteResource);
if (dialog.open() == HistoryDialog.CANCEL)
return;
ILogEntry[] selectedEntries = dialog.getSelectedLogEntries();
if (selectedEntries.length == 0)
return;
revisionText.setText(Long.toString(selectedEntries[selectedEntries.length - 1].getRevision().getNumber()));
setPageComplete(canFinish());
}
use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.
the class SVNRepositoryLocation method fromProperties.
/*
* Create a repository location instance from the given properties.
* The supported properties are:
* user The username for the connection (optional)
* password The password used for the connection (optional)
* url The url where the repository resides
* rootUrl The repository root url
*/
public static SVNRepositoryLocation fromProperties(Properties configuration) throws SVNException {
// We build a string to allow validation of the components that are provided to us
// $NON-NLS-1$
String user = configuration.getProperty("user");
if ((user == null) || (user.length() == 0))
user = null;
// $NON-NLS-1$
String password = configuration.getProperty("password");
if (user == null)
password = null;
// $NON-NLS-1$
String rootUrl = configuration.getProperty("rootUrl");
if ((rootUrl == null) || (rootUrl.length() == 0))
rootUrl = null;
// $NON-NLS-1$
String url = configuration.getProperty("url");
if (url == null)
throw new SVNException(new Status(IStatus.ERROR, SVNProviderPlugin.ID, TeamException.UNABLE, Policy.bind("SVNRepositoryLocation.hostRequired"), // $NON-NLS-1$
null));
SVNUrl urlURL = null;
try {
urlURL = new SVNUrl(url);
} catch (MalformedURLException e) {
throw new SVNException(e.getMessage());
}
SVNUrl rootUrlURL = null;
if (rootUrl != null) {
try {
rootUrlURL = new SVNUrl(rootUrl);
} catch (MalformedURLException e) {
throw new SVNException(e.getMessage());
}
}
return new SVNRepositoryLocation(user, password, urlURL, rootUrlURL);
}
use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.
the class BranchTagCommand method run.
public void run(IProgressMonitor monitor) throws SVNException {
boolean clientPassed = svnClient != null;
try {
monitor.beginTask(null, 100);
if (!clientPassed) {
svnClient = root.getRepository().getSVNClient();
}
OperationManager.getInstance().beginOperation(svnClient, new OperationProgressNotifyListener(monitor, svnClient));
if (createOnServer) {
boolean copyAsChild = sourceUrls.length > 1;
String commonRoot = null;
if (copyAsChild) {
commonRoot = getCommonRoot();
}
if (!multipleTransactions || !copyAsChild || destinationUrl.toString().startsWith(commonRoot)) {
svnClient.copy(sourceUrls, destinationUrl, message, revision, copyAsChild, makeParents);
multipleTransactions = false;
} else {
for (SVNUrl sourceUrl : sourceUrls) {
String fromUrl = sourceUrl.toString();
String uncommonPortion = fromUrl.substring(commonRoot.length());
String toUrl = destinationUrl.toString() + uncommonPortion;
SVNUrl destination = new SVNUrl(toUrl);
SVNUrl[] source = { sourceUrl };
urlMap.put(fromUrl, destination);
svnClient.copy(source, destination, message, revision, copyAsChild, makeParents);
}
}
} else {
File[] files = new File[resources.length];
for (int i = 0; i < resources.length; i++) {
files[i] = resources[i].getLocation().toFile();
}
boolean copyAsChild = files.length > 1;
String commonRoot = null;
if (copyAsChild) {
commonRoot = getCommonRoot();
}
if (!multipleTransactions || !copyAsChild || destinationUrl.toString().startsWith(commonRoot))
try {
svnClient.copy(files, destinationUrl, message, copyAsChild, makeParents);
multipleTransactions = false;
} catch (IllegalArgumentException ex) {
// Ignore. Bug in JavaHL results in this error when parent directories are created,
// even though copy succeeds.
}
else {
for (int i = 0; i < sourceUrls.length; i++) {
String fromUrl = sourceUrls[i].toString();
String uncommonPortion = fromUrl.substring(commonRoot.length());
String toUrl = destinationUrl.toString() + uncommonPortion;
SVNUrl destination = new SVNUrl(toUrl);
File[] source = { files[i] };
try {
urlMap.put(fromUrl, destination);
svnClient.copy(source, destination, message, copyAsChild, makeParents);
} catch (IllegalArgumentException ex) {
// Ignore. Bug in JavaHL results in this error when parent directories are created,
// even though copy succeeds.
}
}
}
}
monitor.worked(100);
} catch (Exception e) {
throw SVNException.wrapException(e);
} finally {
if (!clientPassed) {
root.getRepository().returnSVNClient(svnClient);
}
OperationManager.getInstance().endOperation();
monitor.done();
}
}
use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.
the class CheckoutCommand method checkoutProject.
/**
* @param pm
* @param resource
* @param svnClient
* @param destPath
* @throws SVNException
*/
private void checkoutProject(final IProgressMonitor pm, ISVNRemoteFolder resource, ISVNClientAdapter svnClient, File destPath) throws SVNException {
final IProgressMonitor subPm = Policy.infiniteSubMonitorFor(pm, 800);
try {
subPm.beginTask("", Policy.INFINITE_PM_GUESS_FOR_CHECKOUT);
// If checking out a specific revision, check to see if the location has changed in the
// repository and adjust the URL if it has.
SVNUrl url;
if (svnRevision instanceof SVNRevision.Number) {
url = Util.getUrlForRevision(resource, (SVNRevision.Number) svnRevision, subPm);
} else {
url = resource.getUrl();
}
svnClient.checkout(url, destPath, svnRevision, depth, ignoreExternals, force);
} catch (SVNClientException e) {
throw new SVNException("cannot checkout", e.operationInterrupted());
} finally {
subPm.done();
}
}
Aggregations