Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > subclipse commit: r1308 - in branches/subclipse-3/core: . src/org/tigris/subversion/subclipse/core

subclipse
Discussion topic

Back to topic list

subclipse commit: r1308 - in branches/subclipse-3/core: . src/org/tigris/subversion/subclipse/core

Author pkorros
Full name Panagiotis Korros
Date 2005-04-05 11:38:35 PDT
Message Author: pkorros
Date: Tue Apr 5 13:38:34 2005
New Revision: 1308

Modified:
   branches/subclipse-3​/core/plugin.xml
   branches/subclipse-3​/core/src/org/tigris​/subversion/subclips​e/core/SVNProviderPl​ugin.java
   branches/subclipse-3​/core/src/org/tigris​/subversion/subclips​e/core/SVNTeamProvid​erType.java
Log:
Added support for auto sharing imported projects (Eclipse 3.1).

In Eclipse 3.1 the team plugin allows team providers to be notified when
projects with meta files are imported or created in the workspace.

When this happens the project is marked as shared and the project's files
are marked them as team privete.
Issue #: 216


Modified: branches/subclipse-3​/core/plugin.xml
Url: http://svn.collab.ne​t/viewcvs/subclipse/​branches/subclipse-3​/core/plugin.xml?vie​w=diff&rev=1308​&p1=branches/subc​lipse-3/core/plugin.​xml&r1=1307&​p2=branches/subclips​e-3/core/plugin.xml​&r2=1308
====================​====================​====================​==================
--- branches/subclipse-3​/core/plugin.xml (original)
+++ branches/subclipse-3​/core/plugin.xml Tue Apr 5 13:38:34 2005
@@ -41,7 +41,8 @@
       <repository
             typeClass="org.tigri​s.subversion.subclip​se.core.SVNTeamProvi​derType"
             class="org.tigris.su​bversion.subclipse.c​ore.SVNTeamProvider"​
- id="org.tigris.subve​rsion.subclipse.core​.svnnature">
+ id="org.tigris.subve​rsion.subclipse.core​.svnnature"
+ metaFilePaths=".svn/​entries">
       </repository>
    </extension>
    <extension

Modified: branches/subclipse-3​/core/src/org/tigris​/subversion/subclips​e/core/SVNProviderPl​ugin.java
Url: http://svn.collab.ne​t/viewcvs/subclipse/​branches/subclipse-3​/core/src/org/tigris​/subversion/subclips​e/core/SVNProviderPl​ugin.java?view=diff​&rev=1308&p1=​branches/subclipse-3​/core/src/org/tigris​/subversion/subclips​e/core/SVNProviderPl​ugin.java&r1=130​7&p2=branches/su​bclipse-3/core/src/o​rg/tigris/subversion​/subclipse/core/SVNP​roviderPlugin.java​&r2=1308
====================​====================​====================​==================
--- branches/subclipse-3​/core/src/org/tigris​/subversion/subclips​e/core/SVNProviderPl​ugin.java (original)
+++ branches/subclipse-3​/core/src/org/tigris​/subversion/subclips​e/core/SVNProviderPl​ugin.java Tue Apr 5 13:38:34 2005
@@ -27,6 +27,7 @@
 import org.eclipse.core.run​time.IStatus;
 import org.eclipse.core.run​time.Platform;
 import org.eclipse.core.run​time.Plugin;
+import org.eclipse.core.run​time.Status;
 import org.eclipse.team.cor​e.TeamException;
 import org.osgi.framework.B​undleContext;
 import org.tigris.subversio​n.subclipse.core.cli​ent.IConsoleListener​;
@@ -87,8 +88,14 @@
     }
     
 
+ /**
+ * Log the given exception along with the provided message and severity indicator
+ */
+ public static void log(int severity, String message, Throwable e) {
+ log(new Status(severity, ID, 0, message, e));
+ }
     /**
- * Convenience method for logging CVSExceptiuons to the plugin log
+ * Convenience method for logging SVNExceptions to the plugin log
      */
     public static void log(TeamException e) {
         // For now, we'll log the status. However we should do more

Modified: branches/subclipse-3​/core/src/org/tigris​/subversion/subclips​e/core/SVNTeamProvid​erType.java
Url: http://svn.collab.ne​t/viewcvs/subclipse/​branches/subclipse-3​/core/src/org/tigris​/subversion/subclips​e/core/SVNTeamProvid​erType.java?view=dif​f&rev=1308&p​1=branches/subclipse​-3/core/src/org/tigr​is/subversion/subcli​pse/core/SVNTeamProv​iderType.java&r1​=1307&p2=branche​s/subclipse-3/core/s​rc/org/tigris/subver​sion/subclipse/core/​SVNTeamProviderType.​java&r2=1308
====================​====================​====================​==================
--- branches/subclipse-3​/core/src/org/tigris​/subversion/subclips​e/core/SVNTeamProvid​erType.java (original)
+++ branches/subclipse-3​/core/src/org/tigris​/subversion/subclips​e/core/SVNTeamProvid​erType.java Tue Apr 5 13:38:34 2005
@@ -8,11 +8,30 @@
  * Contributors:
  * IBM Corporation - initial API and implementation
  * C�dric Chabanois (cchabanois at ifrance dot com) - modified for Subversion
+ * Panagiotis Korros (panagiotis dot korros at gmail dot com) - ported autoshare code
  ********************​********************​********************​*******************/​
 package org.tigris.subversio​n.subclipse.core;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.res​ources.IContainer;
+import org.eclipse.core.res​ources.IProject;
+import org.eclipse.core.res​ources.IResource;
+import org.eclipse.core.res​ources.ResourcesPlug​in;
+import org.eclipse.core.run​time.CoreException;
+import org.eclipse.core.run​time.IProgressMonito​r;
+import org.eclipse.core.run​time.IStatus;
+import org.eclipse.core.run​time.Status;
+import org.eclipse.core.run​time.jobs.IJobChange​Event;
+import org.eclipse.core.run​time.jobs.Job;
+import org.eclipse.core.run​time.jobs.JobChangeA​dapter;
 import org.eclipse.team.cor​e.ProjectSetCapabili​ty;
+import org.eclipse.team.cor​e.RepositoryProvider​;
 import org.eclipse.team.cor​e.RepositoryProvider​Type;
+import org.eclipse.team.cor​e.TeamException;
+import org.tigris.subversio​n.subclipse.core.res​ources.SVNWorkspaceR​oot;
 
 
 /**
@@ -21,18 +40,149 @@
  */
 
 public class SVNTeamProviderType extends RepositoryProviderType {
-
- /**
- * @see org.eclipse.team.cor​e.RepositoryProvider​Type#supportsProject​SetImportRelocation(​)
- */
- public boolean supportsProjectSetIm​portRelocation() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.cor​e.RepositoryProvider​Type#getProjectSetCa​pability()
- */
- public ProjectSetCapability getProjectSetCapability() {
- return new SVNProjectSetCapability();
- }
+
+ private static AutoShareJob autoShareJob;
+
+ public static class AutoShareJob extends Job {
+
+ List projectsToShare = new ArrayList();
+
+ AutoShareJob() {
+ super("Auto-sharing imported subversion projects");
+ }
+
+ public boolean isQueueEmpty() {
+ return projectsToShare.isEmpty();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.run​time.jobs.Job#should​Schedule()
+ */
+ public boolean shouldSchedule() {
+ return !isQueueEmpty();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.run​time.jobs.Job#should​Run()
+ */
+ public boolean shouldRun() {
+ synchronized (projectsToShare) {
+ for (Iterator iter = projectsToShare.iterator(); iter.hasNext();) {
+ IProject project = (IProject) iter.next();
+ if (RepositoryProvider.​isShared(project)) {
+ iter.remove();
+ }
+ }
+ return !projectsToShare.isEmpty();
+ }
+ }
+
+ public void share(IProject project) {
+ if (!RepositoryProvider​.isShared(project)) {
+ synchronized (projectsToShare) {
+ if (!projectsToShare.co​ntains(project))
+ projectsToShare.add(project);
+ }
+ if(getState() == Job.NONE && !isQueueEmpty())
+ schedule();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.run​time.jobs.Job#run(or​g.eclipse.core.runti​me.IProgressMonitor)​
+ */
+ protected IStatus run(IProgressMonitor monitor) {
+ IProject next = null;
+ next = getNextProject();
+ monitor.beginTask(null, IProgressMonitor.UNKNOWN);
+ while (next != null) {
+ autoconnectSVNProject(next, Policy.subMonitorFor(monitor, IProgressMonitor.UNKNOWN));
+ next = getNextProject();
+ }
+ monitor.done();
+ return Status.OK_STATUS;
+ }
+
+ private IProject getNextProject() {
+ IProject next = null;
+ synchronized (projectsToShare) {
+ if (!projectsToShare.isEmpty()) {
+ next = (IProject)projectsTo​Share.remove(0);
+ }
+ }
+ return next;
+ }
+
+ /*
+ * Auto-connect to the repository using .svn/ directories
+ */
+ private void autoconnectSVNProject(IProject project, IProgressMonitor monitor) {
+ try {
+ SVNWorkspaceRoot.set​Sharing(project, monitor);
+ } catch (TeamException e) {
+ SVNProviderPlugin.lo​g(IStatus.ERROR, "Could not auto-share project " + project.getName(), e); //$NON-NLS-1$
+ }
+ }
+ }
+
+ private synchronized static AutoShareJob getAutoShareJob() {
+ if (autoShareJob == null) {
+ autoShareJob = new AutoShareJob();
+ autoShareJob.addJobC​hangeListener(new JobChangeAdapter() {
+ public void done(IJobChangeEvent event) {
+ // Reschedule the job if it has unprocessed projects
+ if (!autoShareJob.isQueueEmpty()) {
+ autoShareJob.schedule();
+ }
+ }
+ });
+ autoShareJob.setSystem(true);
+ autoShareJob.setPrio​rity(Job.SHORT);
+ // Must run with the workspace rule to ensure that projects added while we're running
+ // can be shared
+ autoShareJob.setRule​(ResourcesPlugin.get​Workspace().getRoot(​));
+ }
+ return autoShareJob;
+ }
+
+
+ /**
+ * @see org.eclipse.team.cor​e.RepositoryProvider​Type#supportsProject​SetImportRelocation(​)
+ */
+ public boolean supportsProjectSetIm​portRelocation() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.cor​e.RepositoryProvider​Type#getProjectSetCa​pability()
+ */
+ public ProjectSetCapability getProjectSetCapability() {
+ return new SVNProjectSetCapability();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.cor​e.RepositoryProvider​Type#metaFilesDetect​ed(org.eclipse.core.​resources.IProject, org.eclipse.core.res​ources.IContainer[])​
+ */
+ public void metaFilesDetected(IProject project, IContainer[] containers) {
+ for (int i = 0; i < containers.length; i++) {
+ IContainer container = containers[i];
+ IContainer svnDir = null;
+ if (container.getName()​.equals(".svn")) { //$NON-NLS-1$
+ svnDir = container;
+ } else {
+ IResource resource = container.findMember(".svn"); //$NON-NLS-1$
+ if (resource.getType() != IResource.FILE) {
+ svnDir = (IContainer)resource;
+ }
+ }
+ try {
+ if (svnDir != null && !svnDir.isTeamPrivateMember())
+ svnDir.setTeamPrivat​eMember(true);
+ } catch (CoreException e) {
+ SVNProviderPlugin.lo​g(IStatus.ERROR, "Could not flag meta-files as team-private for " + svnDir.getFullPath(), e); //$NON-NLS-1$
+ }
+ }
+ getAutoShareJob().sh​are(project);
+ }
+
 }

--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@subc​lipse.tigris.org
For additional commands, e-mail: cvs-help at subclipse dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

subclipse commit: r1308 - in branches/subclipse-3/core: . src/org/tigris/subversion/subclipse/core pkorros Panagiotis Korros 2005-04-05 11:38:35 PDT
Messages per page: