PageRenderTime 24ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/eclipse-mercurial-1.8.2/plugin/src/com/vectrace/MercurialEclipse/synchronize/HgSubscriberMergeContext.java

#
Java | 149 lines | 70 code | 18 blank | 61 comment | 3 complexity | 3d7a7c256658d1a0c380910c828d125c MD5 | raw file
Possible License(s): EPL-1.0
  1. /*******************************************************************************
  2. * Copyright (c) 2005-2008 VecTrace (Zingo Andersen) and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * bastian implementation
  10. * Andrei Loskutov (Intland) - bug fixes
  11. *******************************************************************************/
  12. package com.vectrace.MercurialEclipse.synchronize;
  13. import java.util.HashSet;
  14. import java.util.Set;
  15. import org.eclipse.core.resources.IFile;
  16. import org.eclipse.core.resources.IResource;
  17. import org.eclipse.core.resources.mapping.ResourceMapping;
  18. import org.eclipse.core.resources.mapping.ResourceTraversal;
  19. import org.eclipse.core.runtime.CoreException;
  20. import org.eclipse.core.runtime.IProgressMonitor;
  21. import org.eclipse.team.core.diff.IDiff;
  22. import org.eclipse.team.core.mapping.ISynchronizationScopeManager;
  23. import org.eclipse.team.core.subscribers.Subscriber;
  24. import org.eclipse.team.core.subscribers.SubscriberMergeContext;
  25. import org.eclipse.team.core.synchronize.SyncInfo;
  26. import org.eclipse.ui.PlatformUI;
  27. import com.vectrace.MercurialEclipse.synchronize.cs.HgChangesetsCollector;
  28. /**
  29. * @author bastian
  30. *
  31. */
  32. public class HgSubscriberMergeContext extends SubscriberMergeContext {
  33. private final Set<IFile> hidden;
  34. private final MercurialSynchronizeSubscriber subscriber;
  35. public HgSubscriberMergeContext(Subscriber subscriber,
  36. ISynchronizationScopeManager manager) {
  37. super(subscriber, manager);
  38. initialize();
  39. hidden = new HashSet<IFile>();
  40. this.subscriber = (MercurialSynchronizeSubscriber) subscriber;
  41. }
  42. /**
  43. * Called after "Overwrite" action is executed
  44. * <p>
  45. * {@inheritDoc}
  46. */
  47. @Override
  48. protected void makeInSync(IDiff diff, IProgressMonitor monitor)
  49. throws CoreException {
  50. }
  51. // @Override
  52. // public void run(IWorkspaceRunnable runnable, ISchedulingRule rule, int flags,
  53. // IProgressMonitor monitor) throws CoreException {
  54. // doPullAndMerge(subscriber.getRepo(), subscriber.getProjects(), runnable, rule, flags, monitor);
  55. // }
  56. //
  57. // @Override
  58. // protected void runInBackground(IWorkspaceRunnable runnable) {
  59. // doPullAndMerge(subscriber.getRepo(), subscriber.getProjects(), runnable);
  60. // }
  61. public void markAsMerged(IDiff node, boolean inSyncHint,
  62. IProgressMonitor monitor) throws CoreException {
  63. }
  64. public void reject(IDiff diff, IProgressMonitor monitor)
  65. throws CoreException {
  66. }
  67. /**
  68. * "Synchronize", part 2
  69. * <p>
  70. * {@inheritDoc}
  71. */
  72. @Override
  73. public void refresh(ResourceTraversal[] traversals, int flags, IProgressMonitor monitor) throws CoreException {
  74. super.refresh(traversals, flags, monitor);
  75. monitor.done();
  76. }
  77. /**
  78. * "Synchronize", part 1
  79. * <p>
  80. * {@inheritDoc}
  81. */
  82. @Override
  83. public void refresh(ResourceMapping[] mappings, IProgressMonitor monitor) throws CoreException {
  84. super.refresh(mappings, monitor);
  85. HgChangesetsCollector collector = subscriber.getCollector();
  86. if(collector != null) {
  87. collector.refresh(mappings);
  88. }
  89. }
  90. @Override
  91. protected SyncInfo getSyncInfo(IResource resource) throws CoreException {
  92. return super.getSyncInfo(resource);
  93. }
  94. @Override
  95. public void dispose() {
  96. // avoid silly NPE's in the team API code if they try to dispose compare
  97. // editors on shutdown, we don't care
  98. if(!PlatformUI.getWorkbench().isClosing()) {
  99. super.dispose();
  100. }
  101. clearHiddenFiles();
  102. }
  103. public void hide(IFile file) {
  104. hidden.add(file);
  105. // HgChangesetsCollector collector = subscriber.getCollector();
  106. // if(collector != null) {
  107. // collector.refresh(null);
  108. // }
  109. }
  110. public void clearHiddenFiles(){
  111. hidden.clear();
  112. }
  113. public boolean isHidden(IFile file){
  114. return hidden.contains(file);
  115. }
  116. // private void doPullAndMerge(HgRepositoryLocation location,
  117. // IProject[] projects,
  118. // IWorkspaceRunnable runnable) {
  119. // doPullAndMerge(location, projects, runnable, null, 0, null);
  120. // }
  121. //
  122. // private void doPullAndMerge(HgRepositoryLocation location,
  123. // IProject[] projects,
  124. // IWorkspaceRunnable runnable,
  125. // ISchedulingRule rule,
  126. // int flags,
  127. // IProgressMonitor monitor) {
  128. // //TODO This is a null solution to avoid wrong usage until it is properly implemented!
  129. // // I was originally planned to show a dialog here but that seems "impossible" :(
  130. // }
  131. }