Search in sources :

Example 26 with ISVNRepositoryLocation

use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.

the class UpdateSynchronizeOperation method run.

protected void run(SVNTeamProvider provider, SyncInfoSet set, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    IResource[] resourceArray = extractResources(resources, set);
    Map<ISVNRepositoryLocation, List<IResource>> items = groupByRepository(resourceArray, set);
    Set<ISVNRepositoryLocation> keys = items.keySet();
    for (Iterator<ISVNRepositoryLocation> iterator = keys.iterator(); iterator.hasNext(); ) {
        ISVNRepositoryLocation repos = iterator.next();
        List<IResource> resourceList = items.get(repos);
        resourceArray = new IResource[resourceList.size()];
        resourceList.toArray(resourceArray);
        SVNRevision revision = getRevisionForUpdate(resourceArray, set);
        IResource[] resourcesToUpdate = changeSetSelected ? resourceArray : trimResources(resourceArray);
        doUpdate(provider, monitor, resourcesToUpdate, revision);
        if (SVNProviderPlugin.getPlugin().getPluginPreferences().getBoolean(ISVNCoreConstants.PREF_SHOW_OUT_OF_DATE_FOLDERS) && resourcesToUpdate.length != resourceArray.length) {
            try {
                SVNWorkspaceSubscriber.getInstance().refresh(resourceArray, IResource.DEPTH_INFINITE, monitor);
            } catch (TeamException e) {
            }
        }
    }
}
Also used : TeamException(org.eclipse.team.core.TeamException) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) ArrayList(java.util.ArrayList) List(java.util.List) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) IResource(org.eclipse.core.resources.IResource)

Example 27 with ISVNRepositoryLocation

use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.

the class BranchTagWizard method performFinish.

public boolean performFinish() {
    if (confirmUserData() == false) {
        return false;
    }
    svnExternals = copyPage.getSvnExternals();
    comment = commentPage.getComment();
    repositoryPage.saveUrl();
    createOnServer = !copyPage.workingCopyButton.getSelection();
    makeParents = repositoryPage.makeParentsButton.getSelection();
    sameStructure = repositoryPage.sameStructureButton != null && repositoryPage.sameStructureButton.getSelection();
    if (commentPage.switchAfterBranchTagCheckBox != null) {
        switchAfterBranchTag = commentPage.switchAfterBranchTagCheckBox.getSelection();
    }
    if (copyPage.serverButton.getSelection())
        revision = SVNRevision.HEAD;
    try {
        toUrl = new SVNUrl(repositoryPage.getToUrl());
        if (copyPage.revisionButton.getSelection())
            revision = SVNRevision.getRevision(copyPage.getRevision());
    } catch (Exception e) {
        MessageDialog.openError(getShell(), Policy.bind("BranchTagDialog.title"), // $NON-NLS-1$
        e.getMessage());
        return false;
    }
    if (!multipleSelections()) {
        BusyIndicator.showWhile(Display.getDefault(), new Runnable() {

            public void run() {
                ISVNInfo svnInfo = null;
                SVNUrl[] sourceUrls = getUrls();
                ISVNClientAdapter svnClient = null;
                ISVNRepositoryLocation repository = null;
                try {
                    SVNProviderPlugin.disableConsoleLogging();
                    repository = SVNProviderPlugin.getPlugin().getRepository(sourceUrls[0].toString());
                    svnClient = repository.getSVNClient();
                    svnInfo = svnClient.getInfo(toUrl);
                } catch (Exception e) {
                } finally {
                    SVNProviderPlugin.enableConsoleLogging();
                    if (repository != null) {
                        repository.returnSVNClient(svnClient);
                    }
                }
                alreadyExists = svnInfo != null;
            }
        });
        if (alreadyExists) {
            MessageDialog.openError(getShell(), Policy.bind("BranchTagDialog.title"), Policy.bind("BranchTagDialog.alreadyExists", // $NON-NLS-1$ //$NON-NLS-2$
            toUrl.toString()));
            return false;
        }
    }
    if (resources != null)
        updateTagsProperty(toUrl);
    return true;
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 28 with ISVNRepositoryLocation

use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.

the class SVNLightweightDecorator method decorateTextLabel.

/**
 * decorate the text label of the given resource. This method assumes that only one thread will be
 * accessing it at a time.
 */
protected void decorateTextLabel(ISVNLocalResource svnResource, LocalResourceStatus status, IDecoration decoration, boolean isDirty) {
    Map bindings = new HashMap(6);
    // has been deleted after we where asked to decorate it.
    if (svnResource.getIResource().getLocation() == null) {
        return;
    }
    if (status.isUnversioned())
        return;
    // get the format
    IDecoratorComponent[][] format;
    int type = svnResource.getIResource().getType();
    if (type == IResource.FOLDER) {
        format = folderDecoratorFormat;
    } else if (type == IResource.PROJECT) {
        format = projectDecoratorFormat;
    } else {
        format = fileDecoratorFormat;
    }
    // fill the bindings
    if (isDirty & !status.isAdded()) {
        bindings.put(SVNDecoratorConfiguration.DIRTY_FLAG, dirtyFlag);
    }
    if (status.getUrlString() != null) {
        String label = null;
        ISVNRepositoryLocation repository = status.getRepository();
        if (repository != null) {
            label = status.getRepository().getLabel();
        }
        bindings.put(SVNDecoratorConfiguration.RESOURCE_LABEL, label == null ? status.getUrlString() : label);
        bindings.put(SVNDecoratorConfiguration.RESOURCE_URL, Util.unescape(status.getUrlString()));
        // short url is the path relative to root url of repository
        SVNUrl repositoryRoot = null;
        if (repository != null) {
            repositoryRoot = repository.getRepositoryRoot();
        }
        if (repositoryRoot != null) {
            int urlLen = status.getUrlString().length();
            int rootLen = repositoryRoot.toString().length() + 1;
            String shortUrl;
            if (urlLen > rootLen)
                shortUrl = status.getUrlString().substring(rootLen);
            else
                shortUrl = status.getUrlString();
            bindings.put(SVNDecoratorConfiguration.RESOURCE_URL_SHORT, Util.unescape(shortUrl));
        }
    }
    if (status.isAdded()) {
        bindings.put(SVNDecoratorConfiguration.ADDED_FLAG, addedFlag);
    } else if (SVNStatusKind.EXTERNAL.equals(status.getTextStatus())) {
        bindings.put(SVNDecoratorConfiguration.EXTERNAL_FLAG, externalFlag);
    } else {
        if ((status.getTextStatus() != SVNStatusKind.UNVERSIONED) && (status.getTextStatus() != SVNStatusKind.ADDED)) {
            if (status.getLastChangedRevision() != null) {
                bindings.put(SVNDecoratorConfiguration.RESOURCE_REVISION, status.getLastChangedRevision().toString());
            }
            if (status.getLastCommitAuthor() != null) {
                bindings.put(SVNDecoratorConfiguration.RESOURCE_AUTHOR, status.getLastCommitAuthor());
            }
        }
        if (status.getLastChangedDate() != null) {
            bindings.put(SVNDecoratorConfiguration.RESOURCE_DATE, dateFormat.format(status.getLastChangedDate()));
        }
    }
    SVNDecoratorConfiguration.decorate(decoration, format, bindings);
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) HashMap(java.util.HashMap) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) HashMap(java.util.HashMap) Map(java.util.Map)

Example 29 with ISVNRepositoryLocation

use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.

the class ChooseUrlDialog method okPressed.

protected void okPressed() {
    saveLocation();
    ISelection selection = treeViewer.getSelection();
    if (!selection.isEmpty() && (selection instanceof IStructuredSelection)) {
        IStructuredSelection structured = (IStructuredSelection) selection;
        Object first = structured.getFirstElement();
        if (first instanceof ISVNRemoteResource) {
            url = ((ISVNRemoteResource) first).getUrl().toString();
            name = ((ISVNRemoteResource) first).getName();
        }
        if (first instanceof ISVNRepositoryLocation)
            url = ((ISVNRepositoryLocation) first).getUrl().toString();
        if (first instanceof Alias)
            url = AliasManager.transformUrl(resource, (Alias) first);
        ArrayList urlArray = new ArrayList();
        ArrayList nameArray = new ArrayList();
        Iterator iter = structured.iterator();
        while (iter.hasNext()) {
            Object selectedItem = iter.next();
            if (selectedItem instanceof ISVNRemoteResource) {
                urlArray.add(((ISVNRemoteResource) selectedItem).getUrl().toString());
                nameArray.add(((ISVNRemoteResource) selectedItem).getName());
            }
        }
        urls = new String[urlArray.size()];
        urlArray.toArray(urls);
        names = new String[nameArray.size()];
        nameArray.toArray(names);
    }
    super.okPressed();
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) Alias(org.tigris.subversion.subclipse.core.history.Alias) ISelection(org.eclipse.jface.viewers.ISelection) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource)

Example 30 with ISVNRepositoryLocation

use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.

the class ChooseUrlDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    // $NON-NLS-1$
    getShell().setText(Policy.bind("ChooseUrlDialog.title"));
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    if (message != null) {
        Label messageLabel = new Label(composite, SWT.NONE);
        messageLabel.setText(message);
    }
    if (multipleSelect)
        treeViewer = new TreeViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    else
        treeViewer = new TreeViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    contentProvider = new RemoteContentProvider();
    contentProvider.setIncludeBranchesAndTags(includeBranchesAndTags);
    contentProvider.setResource(resource);
    treeViewer.setContentProvider(contentProvider);
    if (foldersOnly)
        treeViewer.addFilter(RepositoryFilters.FOLDERS_ONLY);
    // treeViewer.setLabelProvider(new WorkbenchLabelProvider());
    treeViewer.setLabelProvider(new RemoteLabelProvider());
    ISVNRepositoryLocation repository = null;
    if (repositoryLocation == null) {
        if (resource == null)
            treeViewer.setInput(new AllRootsElement());
        else {
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
            try {
                LocalResourceStatus status = svnResource.getStatus();
                if (status != null) {
                    repository = svnResource.getStatus().getRepository();
                }
            } catch (SVNException e1) {
            }
            if (repository == null) {
                repository = svnResource.getRepository();
            }
            if (!repository.getUrl().toString().equals(repository.getRepositoryRoot().toString())) {
                RepositoryRootFolder rootFolder = new RepositoryRootFolder(repository, repository.getRepositoryRoot(), repository.getRootFolder().getRevision());
                contentProvider.setRootFolder(rootFolder);
            }
        }
    } else {
        repository = repositoryLocation;
    }
    if (repository == null)
        treeViewer.setInput(new AllRootsElement());
    else {
        try {
            repository.validateConnection(new NullProgressMonitor());
            treeViewer.setInput(repository);
        } catch (SVNException e) {
            MessageDialog.openError(getShell(), Policy.bind("ChooseUrlDialog.title"), e.getMessage());
            saveLocation = false;
            cancelPressed();
            return composite;
        }
    }
    GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
    data.heightHint = LIST_HEIGHT_HINT;
    data.widthHint = LIST_WIDTH_HINT;
    treeViewer.getControl().setLayoutData(data);
    // when F5 is pressed, refresh
    treeViewer.getControl().addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            if (event.keyCode == SWT.F5) {
                refreshAction.run();
            }
        }
    });
    treeViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent e) {
            okPressed();
        }
    });
    // Create the popup menu
    MenuManager menuMgr = new MenuManager();
    Tree tree = treeViewer.getTree();
    Menu menu = menuMgr.createContextMenu(tree);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            manager.add(newFolderAction);
            if (!treeViewer.getSelection().isEmpty())
                manager.add(deleteFolderAction);
            manager.add(refreshAction);
        }
    });
    menuMgr.setRemoveAllWhenShown(true);
    tree.setMenu(menu);
    // set F1 help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.CHOOSE_URL_DIALOG);
    return composite;
}
Also used : RepositoryRootFolder(org.tigris.subversion.subclipse.core.resources.RepositoryRootFolder) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IMenuListener(org.eclipse.jface.action.IMenuListener) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) RemoteContentProvider(org.tigris.subversion.subclipse.ui.repository.model.RemoteContentProvider) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) AllRootsElement(org.tigris.subversion.subclipse.ui.repository.model.AllRootsElement) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Tree(org.eclipse.swt.widgets.Tree) Menu(org.eclipse.swt.widgets.Menu) IMenuManager(org.eclipse.jface.action.IMenuManager) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)

Aggregations

ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)69 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)20 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 IResource (org.eclipse.core.resources.IResource)15 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)15 TeamException (org.eclipse.team.core.TeamException)14 ArrayList (java.util.ArrayList)13 SVNException (org.tigris.subversion.subclipse.core.SVNException)13 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)13 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)12 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11 File (java.io.File)10 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)9 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)8 LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)8 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)8 Iterator (java.util.Iterator)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 ISVNRemoteFolder (org.tigris.subversion.subclipse.core.ISVNRemoteFolder)7 List (java.util.List)6