Search in sources :

Example 11 with ISVNLocalResource

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

the class SVNHistoryPage method tagsPropertySet.

private boolean tagsPropertySet(IResource resource) {
    if (resource == null)
        return false;
    ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
    try {
        if (svnResource.isManaged()) {
            ISVNProperty property = null;
            // $NON-NLS-1$
            property = svnResource.getSvnProperty("subclipse:tags");
            if (property != null && property.getValue() != null)
                return true;
        }
    } catch (SVNException e) {
    }
    IResource checkResource = resource;
    while (checkResource.getParent() != null) {
        checkResource = checkResource.getParent();
        if (checkResource.getParent() == null)
            return false;
        svnResource = SVNWorkspaceRoot.getSVNResourceFor(checkResource);
        try {
            if (svnResource.isManaged()) {
                ISVNProperty property = null;
                // $NON-NLS-1$
                property = svnResource.getSvnProperty("subclipse:tags");
                if (property != null && property.getValue() != null)
                    return true;
            }
        } catch (SVNException e) {
        }
    }
    return false;
}
Also used : ISVNProperty(org.tigris.subversion.svnclientadapter.ISVNProperty) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource)

Example 12 with ISVNLocalResource

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

the class SVNHistoryPage method getGetContentsAction.

// get contents Action (context menu)
private IAction getGetContentsAction() {
    if (getContentsAction == null) {
        getContentsAction = getContextMenuAction(Policy.bind("HistoryView.getContentsAction"), new // $NON-NLS-1$
        IWorkspaceRunnable() {

            public void run(IProgressMonitor monitor) throws CoreException {
                ISelection selection = getSelection();
                if (!(selection instanceof IStructuredSelection))
                    return;
                IStructuredSelection ss = (IStructuredSelection) selection;
                ISVNRemoteFile remoteFile = (ISVNRemoteFile) getLogEntry(ss).getRemoteResource();
                monitor.beginTask(null, 100);
                try {
                    if (remoteFile != null) {
                        if (confirmOverwrite()) {
                            if (remoteFile instanceof RemoteResource) {
                                if (resource != null) {
                                    ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
                                    ((RemoteResource) remoteFile).setPegRevision(localResource.getRevision());
                                } else {
                                    ((RemoteResource) remoteFile).setPegRevision(SVNRevision.HEAD);
                                }
                            }
                            InputStream in = ((IResourceVariant) remoteFile).getStorage(new SubProgressMonitor(monitor, 50)).getContents();
                            IFile file = (IFile) resource;
                            file.setContents(in, false, true, new SubProgressMonitor(monitor, 50));
                        }
                    }
                } catch (TeamException e) {
                    throw new CoreException(e.getStatus());
                } finally {
                    monitor.done();
                }
            }
        });
        PlatformUI.getWorkbench().getHelpSystem().setHelp(getContentsAction, IHelpContextIds.GET_FILE_CONTENTS_ACTION);
    }
    return getContentsAction;
}
Also used : IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) TeamException(org.eclipse.team.core.TeamException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RemoteResource(org.tigris.subversion.subclipse.core.resources.RemoteResource) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) InputStream(java.io.InputStream) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Example 13 with ISVNLocalResource

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

the class CommitSynchronizeAction method getSubscriberOperation.

/* (non-Javadoc)
   * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#getSubscriberOperation(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration, org.eclipse.compare.structuremergeviewer.IDiffElement[])
   */
protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) {
    changeSets = new ArrayList();
    // override the elemenents (this has to be done this way because of final methods in eclipse
    // api)
    elements = getFilteredDiffElementsOverride();
    String url = null;
    ChangeSet changeSet = null;
    IStructuredSelection selection = getStructuredSelection();
    Iterator iter = selection.iterator();
    String proposedComment = "";
    while (iter.hasNext()) {
        ISynchronizeModelElement synchronizeModelElement = (ISynchronizeModelElement) iter.next();
        proposedComment = getProposedComment(proposedComment, synchronizeModelElement);
        if (!(synchronizeModelElement instanceof ChangeSetDiffNode)) {
            if (url == null && selection.size() == 1) {
                IResource resource = synchronizeModelElement.getResource();
                if (resource != null) {
                    ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
                    try {
                        url = svnResource.getStatus().getUrlString();
                        if ((url == null) || (resource.getType() == IResource.FILE))
                            url = Util.getParentUrl(svnResource);
                    } catch (SVNException e) {
                        if (!e.operationInterrupted()) {
                            SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
                        }
                    }
                }
            }
        } else {
            if (selection.size() == 1) {
                ChangeSetDiffNode changeSetDiffNode = (ChangeSetDiffNode) synchronizeModelElement;
                changeSet = changeSetDiffNode.getSet();
            }
        }
    }
    CommitSynchronizeOperation operation = new CommitSynchronizeOperation(configuration, elements, url, proposedComment);
    operation.setChangeSet(changeSet);
    return operation;
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ISynchronizeModelElement(org.eclipse.team.ui.synchronize.ISynchronizeModelElement) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SVNException(org.tigris.subversion.subclipse.core.SVNException) ChangeSetDiffNode(org.eclipse.team.internal.ui.synchronize.ChangeSetDiffNode) ChangeSet(org.eclipse.team.internal.core.subscribers.ChangeSet) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource)

Example 14 with ISVNLocalResource

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

the class CommitSynchronizeOperation method confirmCommit.

private boolean confirmCommit(SyncInfoSet set) {
    commit = false;
    IResource[] modified = set.getResources();
    List conflictFiles = new ArrayList();
    List filteredModified = new ArrayList();
    boolean switched = false;
    for (int i = 0; i < modified.length; i++) {
        IResource resource = modified[i];
        filteredModified.add(resource);
        if (!(resource instanceof IContainer)) {
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
            try {
                if (svnResource.isManaged() && svnResource.getStatus().isTextConflicted()) {
                    IFile conflictNewFile = (IFile) File2Resource.getResource(svnResource.getStatus().getConflictNew());
                    if (conflictNewFile != null)
                        conflictFiles.add(conflictNewFile);
                    IFile conflictOldFile = (IFile) File2Resource.getResource(svnResource.getStatus().getConflictOld());
                    if (conflictOldFile != null)
                        conflictFiles.add(conflictOldFile);
                    IFile conflictWorkingFile = (IFile) File2Resource.getResource(svnResource.getStatus().getConflictWorking());
                    if (conflictWorkingFile != null)
                        conflictFiles.add(conflictWorkingFile);
                }
                if (svnResource.getStatus().isSwitched()) {
                    url = svnResource.getStatus().getUrlString();
                    switched = true;
                }
            } catch (SVNException e) {
            }
        }
    }
    if (switched && modified.length > 1) {
        url = null;
    }
    if (conflictFiles.size() > 0) {
        Iterator iter = conflictFiles.iterator();
        while (iter.hasNext()) {
            IFile conflictFile = (IFile) iter.next();
            filteredModified.remove(conflictFile);
        }
        modified = new IResource[filteredModified.size()];
        filteredModified.toArray(modified);
    }
    if (modified.length > 0) {
        try {
            IPreferenceStore preferenceStore = SVNUIPlugin.getPlugin().getPreferenceStore();
            boolean commitToTagsPathWithoutWarning = preferenceStore.getBoolean(ISVNUIConstants.PREF_COMMIT_TO_TAGS_PATH_WITHOUT_WARNING);
            if (!commitToTagsPathWithoutWarning && onTagPath(modified)) {
                commit = true;
                getShell().getDisplay().syncExec(new Runnable() {

                    public void run() {
                        CommitToTagsWarningDialog dialog = new CommitToTagsWarningDialog(getShell());
                        commit = dialog.open() == CommitToTagsWarningDialog.OK;
                    }
                });
                if (!commit) {
                    return false;
                }
            }
            ProjectProperties projectProperties = ProjectProperties.getProjectProperties(modified[0]);
            SvnWizardCommitPage commitPage = new SvnWizardCommitPage(modified, url, projectProperties, new HashMap(), changeSet, true);
            if (proposedComment == null || proposedComment.length() == 0)
                commitPage.setComment(getProposedComment(modified));
            else
                commitPage.setComment(proposedComment);
            commitPage.setSyncInfoSet(set);
            SvnWizard wizard = new SvnWizard(commitPage);
            final SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
            wizard.setParentDialog(dialog);
            getShell().getDisplay().syncExec(new Runnable() {

                public void run() {
                    commit = (dialog.open() == SvnWizardDialog.OK);
                }
            });
            if (commit) {
                resourcesToCommit = commitPage.getSelectedResources();
                keepLocks = commitPage.isKeepLocks();
            }
            commitComment = commitPage.getComment();
        } catch (SVNException e) {
            if (!e.operationInterrupted()) {
                SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
            }
        }
    }
    return commit;
}
Also used : IFile(org.eclipse.core.resources.IFile) HashMap(java.util.HashMap) SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) ArrayList(java.util.ArrayList) SvnWizardCommitPage(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardCommitPage) SvnWizard(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard) SVNException(org.tigris.subversion.subclipse.core.SVNException) ProjectProperties(org.tigris.subversion.subclipse.ui.settings.ProjectProperties) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) CommitToTagsWarningDialog(org.tigris.subversion.subclipse.ui.dialogs.CommitToTagsWarningDialog) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IContainer(org.eclipse.core.resources.IContainer) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IResource(org.eclipse.core.resources.IResource)

Example 15 with ISVNLocalResource

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

the class EditConflictsSynchronizeAction method getSyncInfoFilter.

/* (non-Javadoc)
   * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#getSyncInfoFilter()
   */
protected FastSyncInfoFilter getSyncInfoFilter() {
    return new FastSyncInfoFilter() {

        public boolean select(SyncInfo info) {
            IStructuredSelection selection = getStructuredSelection();
            if (selection.size() != 1)
                return false;
            ISynchronizeModelElement element = (ISynchronizeModelElement) selection.getFirstElement();
            IResource resource = element.getResource();
            if (resource == null)
                return false;
            if (!(resource instanceof IFile))
                return false;
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
            try {
                return svnResource.getStatus().isTextConflicted();
            } catch (SVNException e) {
                return false;
            }
        }
    };
}
Also used : IFile(org.eclipse.core.resources.IFile) SyncInfo(org.eclipse.team.core.synchronize.SyncInfo) ISynchronizeModelElement(org.eclipse.team.ui.synchronize.ISynchronizeModelElement) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource) FastSyncInfoFilter(org.eclipse.team.core.synchronize.FastSyncInfoFilter)

Aggregations

ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)120 IResource (org.eclipse.core.resources.IResource)77 SVNException (org.tigris.subversion.subclipse.core.SVNException)76 ArrayList (java.util.ArrayList)39 CoreException (org.eclipse.core.runtime.CoreException)24 Iterator (java.util.Iterator)20 IFile (org.eclipse.core.resources.IFile)20 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)20 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 List (java.util.List)18 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)18 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)17 LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)17 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)17 File (java.io.File)16 TeamException (org.eclipse.team.core.TeamException)16 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)15 ISynchronizeModelElement (org.eclipse.team.ui.synchronize.ISynchronizeModelElement)14 IContainer (org.eclipse.core.resources.IContainer)13 SyncInfo (org.eclipse.team.core.synchronize.SyncInfo)11