Search in sources :

Example 6 with Alias

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);
    }
}
Also used : BranchTagPropertyUpdateDialog(org.tigris.subversion.subclipse.ui.dialogs.BranchTagPropertyUpdateDialog) Alias(org.tigris.subversion.subclipse.core.history.Alias) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) ISVNProperty(org.tigris.subversion.svnclientadapter.ISVNProperty) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 7 with Alias

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;
}
Also used : Alias(org.tigris.subversion.subclipse.core.history.Alias) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 8 with Alias

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);
}
Also used : AliasManager(org.tigris.subversion.subclipse.core.history.AliasManager) Alias(org.tigris.subversion.subclipse.core.history.Alias) Branches(org.tigris.subversion.subclipse.core.history.Branches) Tags(org.tigris.subversion.subclipse.core.history.Tags)

Example 9 with Alias

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);
}
Also used : Group(org.eclipse.swt.widgets.Group) FocusAdapter(org.eclipse.swt.events.FocusAdapter) ModifyListener(org.eclipse.swt.events.ModifyListener) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) SVNException(org.tigris.subversion.subclipse.core.SVNException) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) FocusEvent(org.eclipse.swt.events.FocusEvent) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder) ChooseUrlDialog(org.tigris.subversion.subclipse.ui.dialogs.ChooseUrlDialog) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) Tree(org.eclipse.swt.widgets.Tree) Menu(org.eclipse.swt.widgets.Menu) Composite(org.eclipse.swt.widgets.Composite) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Text(org.eclipse.swt.widgets.Text) SVNException(org.tigris.subversion.subclipse.core.SVNException) IMenuListener(org.eclipse.jface.action.IMenuListener) Alias(org.tigris.subversion.subclipse.core.history.Alias) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) IMenuManager(org.eclipse.jface.action.IMenuManager) FocusListener(org.eclipse.swt.events.FocusListener)

Example 10 with Alias

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);
        }
    }
}
Also used : BranchTagPropertyUpdateDialog(org.tigris.subversion.subclipse.ui.dialogs.BranchTagPropertyUpdateDialog) Alias(org.tigris.subversion.subclipse.core.history.Alias) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) ISVNProperty(org.tigris.subversion.svnclientadapter.ISVNProperty) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Aggregations

Alias (org.tigris.subversion.subclipse.core.history.Alias)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 SVNException (org.tigris.subversion.subclipse.core.SVNException)3 AliasManager (org.tigris.subversion.subclipse.core.history.AliasManager)3 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)3 ISVNInfo (org.tigris.subversion.svnclientadapter.ISVNInfo)3 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)3 Iterator (java.util.Iterator)2 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)2 Branches (org.tigris.subversion.subclipse.core.history.Branches)2 Tags (org.tigris.subversion.subclipse.core.history.Tags)2 BranchTagPropertyUpdateDialog (org.tigris.subversion.subclipse.ui.dialogs.BranchTagPropertyUpdateDialog)2 ISVNProperty (org.tigris.subversion.svnclientadapter.ISVNProperty)2 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)2 ArrayList (java.util.ArrayList)1 IResource (org.eclipse.core.resources.IResource)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 ISelection (org.eclipse.jface.viewers.ISelection)1