use of org.tigris.subversion.subclipse.core.history.Alias in project subclipse by subclipse.
the class SvnWizardBranchTagPage method updateTagsProperty.
private void updateTagsProperty(SVNUrl toUrl) {
ISVNClientAdapter svnClient = null;
try {
ISVNProperty property = null;
// $NON-NLS-1$
property = svnResource.getSvnProperty("subclipse:tags");
if (property == null)
return;
newAlias = new Alias();
// $NON-NLS-1$
newAlias.setBranch(toUrl.toString().toUpperCase().indexOf("TAGS") == -1);
String relativePath = toUrl.toString().substring(svnResource.getRepository().getUrl().toString().length());
newAlias.setRelativePath(relativePath);
SVNRevision revision = null;
if (revisionButton.getSelection())
revision = SVNRevision.getRevision(revisionText.getText().trim());
else {
svnClient = svnResource.getRepository().getSVNClient();
ISVNInfo svnInfo = svnClient.getInfo(url);
revision = SVNRevision.getRevision(svnInfo.getRevision().toString());
}
newAlias.setRevision(Integer.parseInt(revision.toString()));
newAlias.setName(toUrl.getLastPathSegment());
BranchTagPropertyUpdateDialog dialog = new BranchTagPropertyUpdateDialog(getShell(), resource, newAlias, // $NON-NLS-1$
"BranchTagPropertyUpdateDialog");
if (dialog.open() == BranchTagPropertyUpdateDialog.OK)
newAlias = dialog.getNewAlias();
else
newAlias = null;
} catch (Exception e) {
} finally {
svnResource.getRepository().returnSVNClient(svnClient);
}
}
use of org.tigris.subversion.subclipse.core.history.Alias in project subclipse by subclipse.
the class SvnWizardConfigureTagsPage method canUpdate.
private boolean canUpdate() {
if (revisionText.getText().trim().length() == 0 || nameText.getText().trim().length() == 0)
return false;
IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
Alias alias = (Alias) selection.getFirstElement();
if (revisionText.getText().trim().equals(Integer.toString(alias.getRevision())) && nameText.getText().trim().equals(alias.getName()) && pathText.getText().trim().equals(alias.getRelativePath()) && branchButton.getSelection() == alias.isBranch())
return false;
return true;
}
use of org.tigris.subversion.subclipse.core.history.Alias in project subclipse by subclipse.
the class SvnWizardConfigureTagsPage method getBranchesAndTags.
private void getBranchesAndTags() {
AliasManager aliasManager = new AliasManager(svnResources[0].getResource(), false);
Alias[] branchAliases = aliasManager.getBranches();
branches = new Branches(branchAliases);
Alias[] tagAliases = aliasManager.getTags();
tags = new Tags(tagAliases);
}
use of org.tigris.subversion.subclipse.core.history.Alias 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.subclipse.core.history.Alias in project subclipse by subclipse.
the class BranchTagWizard method updateTagsProperty.
private void updateTagsProperty(SVNUrl toUrl) {
ISVNClientAdapter svnClient = null;
try {
if (resources.length > 1)
return;
ISVNProperty property = null;
// $NON-NLS-1$
property = repositoryPage.getSvnResource().getSvnProperty("subclipse:tags");
if (property == null)
return;
newAlias = new Alias();
// $NON-NLS-1$
newAlias.setBranch(toUrl.toString().toUpperCase().indexOf("TAGS") == -1);
String relativePath = toUrl.toString().substring(repositoryPage.getSvnResource().getRepository().getUrl().toString().length());
newAlias.setRelativePath(relativePath);
SVNRevision revision = null;
if (copyPage.revisionButton.getSelection())
revision = SVNRevision.getRevision(copyPage.getRevision());
else {
svnClient = repositoryPage.getSvnResource().getRepository().getSVNClient();
ISVNInfo svnInfo = svnClient.getInfo(repositoryPage.getUrl());
revision = SVNRevision.getRevision(svnInfo.getRevision().toString());
}
newAlias.setRevision(Integer.parseInt(revision.toString()));
newAlias.setName(toUrl.getLastPathSegment());
BranchTagPropertyUpdateDialog dialog = new BranchTagPropertyUpdateDialog(getShell(), getResource(), newAlias, // $NON-NLS-1$
"BranchTagPropertyUpdateDialog");
if (dialog.open() == BranchTagPropertyUpdateDialog.OK)
newAlias = dialog.getNewAlias();
else
newAlias = null;
} catch (Exception e) {
} finally {
if (svnClient != null) {
repositoryPage.getSvnResource().getRepository().returnSVNClient(svnClient);
}
}
}
Aggregations