Login | Register
My pages Projects Community openCollabNet

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

subclipse
Discussion topic

Back to topic list

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

Author pkorros
Full name Panagiotis Korros
Date 2005-04-06 13:58:09 PDT
Message Author: pkorros
Date: Wed Apr 6 15:58:09 2005
New Revision: 1310

Added:
   branches/subclipse-3​/core/src/org/tigris​/subversion/subclips​e/core/util/ISimpleD​ialogsHelper.java
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 adding imported projects if they reside in a working
copy (Eclipse 3.1).

By Magnus Naeslund
Issue #: 261


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=1310​&p1=branches/subc​lipse-3/core/plugin.​xml&r1=1309&​p2=branches/subclips​e-3/core/plugin.xml​&r2=1310
====================​====================​====================​==================
--- branches/subclipse-3​/core/plugin.xml (original)
+++ branches/subclipse-3​/core/plugin.xml Wed Apr 6 15:58:09 2005
@@ -42,7 +42,7 @@
             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"
- metaFilePaths=".svn/​entries">
+ metaFilePaths=".svn/​entries,.project"​>
       </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=1310&p1=​branches/subclipse-3​/core/src/org/tigris​/subversion/subclips​e/core/SVNProviderPl​ugin.java&r1=130​9&p2=branches/su​bclipse-3/core/src/o​rg/tigris/subversion​/subclipse/core/SVNP​roviderPlugin.java​&r2=1310
====================​====================​====================​==================
--- 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 Wed Apr 6 15:58:09 2005
@@ -36,6 +36,7 @@
 import org.tigris.subversio​n.subclipse.core.res​ourcesListeners.File​ModificationManager;​
 import org.tigris.subversio​n.subclipse.core.res​ourcesListeners.Sync​FileChangeListener;
 import org.tigris.subversio​n.subclipse.core.sta​tus.StatusCacheManag​er;
+import org.tigris.subversio​n.subclipse.core.uti​l.ISimpleDialogsHelp​er;
 import org.tigris.subversio​n.svnclientadapter.I​SVNClientAdapter;
 import org.tigris.subversio​n.svnclientadapter.I​SVNPromptUserPasswor​d;
 
@@ -77,6 +78,8 @@
     private SVNAdapterFactories adapterFactories;
     
     private ISVNPromptUserPassword svnPromptUserPassword;
+
+ private ISimpleDialogsHelper simpleDialogsHelper;
     
     /**
      * This constructor required by the bundle loader (calls newInstance())
@@ -430,4 +433,13 @@
             ISVNPromptUserPassword svnPromptUserPassword) {
         this.svnPromptUserPassword = svnPromptUserPassword;
     }
+
+ public ISimpleDialogsHelper getSimpleDialogsHelper() {
+ return simpleDialogsHelper;
+ }
+
+ public void setSimpleDialogsHelp​er(ISimpleDialogsHel​per simpleDialogsHelper) {
+ this.simpleDialogsHelper = simpleDialogsHelper;
+ }
+
 }

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=1310&p​1=branches/subclipse​-3/core/src/org/tigr​is/subversion/subcli​pse/core/SVNTeamProv​iderType.java&r1​=1309&p2=branche​s/subclipse-3/core/s​rc/org/tigris/subver​sion/subclipse/core/​SVNTeamProviderType.​java&r2=1310
====================​====================​====================​==================
--- 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 Wed Apr 6 15:58:09 2005
@@ -9,9 +9,11 @@
  * 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
+ * Magnus Naeslund (mag at kite dot se) - Added autoadd code
  ********************​********************​********************​*******************/​
 package org.tigris.subversio​n.subclipse.core;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -32,6 +34,7 @@
 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;
+import org.tigris.subversio​n.svnclientadapter.I​SVNClientAdapter;
 
 
 /**
@@ -160,18 +163,97 @@
         return new SVNProjectSetCapability();
     }
 
- /* (non-Javadoc)
+ public static class AutoAddJob extends Job {
+ final static int MAX_RETRIES = 10;
+ int reschedCount = 0;
+ final IProject project;
+
+ protected AutoAddJob(IProject project){
+ super("Auto-adding newly created project to subversion: " + project.getName()); //$NON-NLS-1$
+ this.project = project;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.run​time.jobs.Job#run(or​g.eclipse.core.runti​me.IProgressMonitor)​
+ */
+ protected IStatus run(IProgressMonitor monitor) {
+ monitor.beginTask(null, IProgressMonitor.UNKNOWN);
+ try{
+ SVNProviderPlugin plugin = SVNProviderPlugin.getPlugin();
+
+ if (plugin == null || plugin.getSimpleDialogsHelper() == null){
+ if (++reschedCount > MAX_RETRIES){
+ String errorString = "Subclipse core and/or ui didn't come up in " + MAX_RETRIES + " retries, failing."; //$NON-NLS-1$
+ System.err.println(e​rrorString); // Let it be visible to the user
+ throw new SVNException(errorString);
+ }
+ schedule(1000);
+ return Status.OK_STATUS;
+ }
+
+ if (!plugin.getSimpleDi​alogsHelper().prompt​YesNo(
+ "Auto-add "+project.getName()+" to source control", //$NON-NLS-1$
+ "The new project \""+ project.getName() +"\" was created in a subversion " + //$NON-NLS-1$
+ "controlled directory.\n\n" + //$NON-NLS-1$
+ "Would you like to automatically add it to source control?", true)) { //$NON-NLS-1$
+
+ return Status.OK_STATUS;
+ }
+
+ SVNClientManager svnClientManager = plugin.getSVNClientManager();
+ ISVNClientAdapter client = svnClientManager.cre​ateSVNClient();
+
+ File file = project.getLocation().toFile();
+ client.addDirectory(file, false);
+
+ RepositoryProvider.map(project, SVNProviderPlugin.getTypeId());
+ SVNTeamProvider provider = (SVNTeamProvider) RepositoryProvider
+ .getProvider(project, SVNProviderPlugin.getTypeId());
+
+ plugin.getStatusCach​eManager().refreshSt​atus(project,
+ IResource.DEPTH_INFINITE);
+
+ }catch(Exception e){
+ SVNProviderPlugin.lo​g(IStatus.ERROR, "Could not auto-add project " + project.getName(), e); //$NON-NLS-1$
+ return Status.CANCEL_STATUS;
+ }finally{
+ monitor.done();
+ }
+ return Status.OK_STATUS;
+ }
+
+ }
+
+ /**
+ * Create and schedule an auto-add job
+ */
+
+ private static synchronized void createAutoAddJob(IProject project) {
+ Job j = new AutoAddJob(project);
+ j.setSystem(true);
+ j.setPriority(Job.SHORT);
+ j.setRule(ResourcesP​lugin.getWorkspace()​.getRoot());
+ j.schedule();
+ }
+
+ /* (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) {
+ boolean isProject = false;
+
         for (int i = 0; i < containers.length; i++) {
             IContainer container = containers[i];
             IContainer svnDir = null;
+
+ if (!isProject && container.getType() == IContainer.PROJECT)
+ isProject = true;
+
             if (container.getName()​.equals(".svn")) { //$NON-NLS-1$
                 svnDir = container;
             } else {
                 IResource resource = container.findMember(".svn"); //$NON-NLS-1$
- if (resource.getType() != IResource.FILE) {
+ if (resource != null && resource.getType() != IResource.FILE) {
                     svnDir = (IContainer)resource;
                 }
             }
@@ -182,7 +264,30 @@
                 SVNProviderPlugin.lo​g(IStatus.ERROR, "Could not flag meta-files as team-private for " + svnDir.getFullPath(), e); //$NON-NLS-1$
             }
         }
- getAutoShareJob().sh​are(project);
+
+ if (!isProject)
+ return; // Nothing more to do, all remaining operations are on projects
+
+ // Somehow sometimes it doesn't work using project.findMember(".svn") here, this
+ // could be due to timing issue with workspace addition, so use trusty File instead.
+
+ File svnDir = project.getLocation(​).append(".svn").toF​ile(); //$NON-NLS-1$
+
+ if (svnDir != null && svnDir.exists() && svnDir.isDirectory()) {
+ // It's a project and has toplevel .svn directory, lets share it!
+ getAutoShareJob().sh​are(project);
+ } else {
+ // It's a project and doesn't have .svn dir, let's see if we can add it!
+ File parentSvnDir = project.getLocation(​).append("../.svn").​toFile(); //$NON-NLS-1$
+
+ if (parentSvnDir != null && parentSvnDir.exists()
+ && parentSvnDir.isDirectory()) {
+
+ createAutoAddJob(project);
+ }
+ }
+
     }
-
+
+
 }

Added: branches/subclipse-3​/core/src/org/tigris​/subversion/subclips​e/core/util/ISimpleD​ialogsHelper.java
Url: http://svn.collab.ne​t/viewcvs/subclipse/​branches/subclipse-3​/core/src/org/tigris​/subversion/subclips​e/core/util/ISimpleD​ialogsHelper.java?vi​ew=auto&rev=1310​
====================​====================​====================​==================
--- (empty file)
+++ branches/subclipse-3​/core/src/org/tigris​/subversion/subclips​e/core/util/ISimpleD​ialogsHelper.java Wed Apr 6 15:58:09 2005
@@ -0,0 +1,36 @@
+
+/**
+ *
+ * This interface exists to provide the UI package a way to pass dialogs
+ * helpers to the subclipse core package.
+ *
+ * @author Magnus Naeslund (mag at kite dot se)
+ *
+ */
+
+package org.tigris.subversio​n.subclipse.core.uti​l;
+
+/**
+ *
+ * @author mag
+ * @see org.tigris.subversio​n.subclipse.ui.util.​SimpleDialogsHelper
+ * @see org.tigris.subversio​n.subclipse.core.SVN​ProviderPlugin#getSi​mpleDialogsHelper()
+ *
+ */
+
+public interface ISimpleDialogsHelper {
+
+ /**
+ *
+ * @param title
+ * @param question
+ * @param yesIsDefault
+ * @return true if the user pressed yes
+ *
+ */
+
+ public boolean promptYesNo(String title, String question, boolean yesIsDefault);
+ public boolean promptYesCancel(String title, String question, boolean yesIsDefault);
+
+
+}

--------------------​--------------------​--------------------​---------
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: r1310 - in branches/subclipse-3/core: . src/org/tigris/subversion/subclipse/core src/org/tigris/subversion/subclipse/core/util pkorros Panagiotis Korros 2005-04-06 13:58:09 PDT
Messages per page: