Search in sources :

Example 21 with ISVNInfo

use of org.tigris.subversion.svnclientadapter.ISVNInfo in project subclipse by subclipse.

the class SetCommitPropertiesAction method run.

public void run() {
    try {
        IResource resource = ((RevisionGraphEditorInput) editor.getEditorInput()).getResource();
        ISVNRemoteResource remoteResource = ((RevisionGraphEditorInput) editor.getEditorInput()).getRemoteResource();
        ISVNInfo info = ((RevisionGraphEditorInput) editor.getEditorInput()).getInfo();
        final ProjectProperties projectProperties = (resource != null) ? ProjectProperties.getProjectProperties(resource) : ProjectProperties.getProjectProperties(remoteResource);
        SVNRevision.Number revision = new SVNRevision.Number(node.getRevision());
        SetCommitPropertiesDialog dialog = new SetCommitPropertiesDialog(Display.getDefault().getActiveShell(), revision, resource, projectProperties);
        dialog.setOldAuthor(node.getAuthor());
        dialog.setOldComment(node.getMessage());
        if (dialog.open() == SetCommitPropertiesDialog.OK) {
            final String author;
            final String commitComment;
            if (node.getAuthor().equals(dialog.getAuthor()))
                author = null;
            else
                author = dialog.getAuthor();
            if (node.getMessage().equals(dialog.getComment()))
                commitComment = null;
            else
                commitComment = dialog.getComment();
            ISVNRepositoryLocation repository = SVNProviderPlugin.getPlugin().getRepository(info.getRepository().toString());
            final ChangeCommitPropertiesCommand command = new ChangeCommitPropertiesCommand(repository, revision, commitComment, author);
            PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() {

                public void run(IProgressMonitor monitor) throws InvocationTargetException {
                    try {
                        command.run(monitor);
                    } catch (SVNException e) {
                        throw new InvocationTargetException(e);
                    } finally {
                        if (command.isAuthorChanged())
                            node.setAuthor(author);
                        if (command.isLogMessageChanged())
                            node.setMessage(commitComment);
                        if (command.isAuthorChanged() || command.isLogMessageChanged()) {
                            nodeFigure.setToolTip(new NodeTooltipFigure(node));
                        }
                    }
                }
            });
        }
    } catch (Exception e) {
        SVNUIPlugin.openError(Display.getDefault().getActiveShell(), null, null, e, SVNUIPlugin.LOG_TEAM_EXCEPTIONS);
    }
}
Also used : NodeTooltipFigure(org.tigris.subversion.subclipse.graph.editors.NodeTooltipFigure) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) ProjectProperties(org.tigris.subversion.subclipse.ui.settings.ProjectProperties) SVNException(org.tigris.subversion.subclipse.core.SVNException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SVNException(org.tigris.subversion.subclipse.core.SVNException) ChangeCommitPropertiesCommand(org.tigris.subversion.subclipse.core.commands.ChangeCommitPropertiesCommand) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) SetCommitPropertiesDialog(org.tigris.subversion.subclipse.ui.dialogs.SetCommitPropertiesDialog) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RevisionGraphEditorInput(org.tigris.subversion.subclipse.graph.editors.RevisionGraphEditorInput) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) IResource(org.eclipse.core.resources.IResource)

Example 22 with ISVNInfo

use of org.tigris.subversion.svnclientadapter.ISVNInfo in project subclipse by subclipse.

the class ResolveTreeConflictWizard method getLocalCopiedTo.

public ISVNStatus getLocalCopiedTo(boolean getAll) throws SVNException, SVNClientException {
    String endsWithCheck = treeConflict.getConflictDescriptor().getSrcRightVersion().getPathInRepos();
    IProject project = svnResource.getResource().getProject();
    if (project != null) {
        // $NON-NLS-1$ //$NON-NLS-2$
        int index = endsWithCheck.indexOf("/" + project.getName() + "/");
        if (index != -1)
            endsWithCheck = endsWithCheck.substring(index);
    }
    if (copiedTo == null && !copiedToRetrieved) {
        statuses = getStatuses(getAll);
        ISVNClientAdapter svnClient = svnResource.getRepository().getSVNClient();
        for (int i = 0; i < statuses.length; i++) {
            if (statuses[i].isCopied() && statuses[i].getTextStatus().equals(SVNStatusKind.ADDED)) {
                ISVNInfo info = svnClient.getInfoFromWorkingCopy(statuses[i].getFile());
                if (info.getCopyUrl() != null) {
                    if ((svnResource.getUrl() != null && info.getCopyUrl().toString().equals(svnResource.getUrl().toString())) || (info.getCopyUrl().toString().endsWith(endsWithCheck))) {
                        copiedTo = statuses[i];
                        break;
                    }
                }
            }
        }
        svnResource.getRepository().returnSVNClient(svnClient);
    }
    copiedToRetrieved = true;
    return copiedTo;
}
Also used : ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) IProject(org.eclipse.core.resources.IProject) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 23 with ISVNInfo

use of org.tigris.subversion.svnclientadapter.ISVNInfo 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 24 with ISVNInfo

use of org.tigris.subversion.svnclientadapter.ISVNInfo 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 25 with ISVNInfo

use of org.tigris.subversion.svnclientadapter.ISVNInfo 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

ISVNInfo (org.tigris.subversion.svnclientadapter.ISVNInfo)26 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)19 SVNException (org.tigris.subversion.subclipse.core.SVNException)13 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)12 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)8 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)7 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)5 IResource (org.eclipse.core.resources.IResource)4 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)4 File (java.io.File)3 MalformedURLException (java.net.MalformedURLException)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 Alias (org.tigris.subversion.subclipse.core.history.Alias)3 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)3 RevisionGraphEditorInput (org.tigris.subversion.subclipse.graph.editors.RevisionGraphEditorInput)3 ISVNProperty (org.tigris.subversion.svnclientadapter.ISVNProperty)3 ArrayList (java.util.ArrayList)2 CoreException (org.eclipse.core.runtime.CoreException)2 ISVNRemoteFile (org.tigris.subversion.subclipse.core.ISVNRemoteFile)2 LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)2