Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > subclipse commit: r792 - in branches/subclipse-3/ui/src/org/tigris/subversion/subclipse/ui: . pending

subclipse
Discussion topic

Back to topic list

subclipse commit: r792 - in branches/subclipse-3/ui/src/org/tigris/subversion/subclipse/ui: . pending

Author pkorros
Full name Panagiotis Korros
Date 2004-07-27 09:25:30 PDT
Message Author: pkorros
Date: Tue Jul 27 11:25:25 2004
New Revision: 792

Modified:
   branches/subclipse-3​/ui/src/org/tigris/s​ubversion/subclipse/​ui/messages.properti​es
   branches/subclipse-3​/ui/src/org/tigris/s​ubversion/subclipse/​ui/pending/PendingOp​erationsView.java
Log:
The pending operations are now computed in the background using a job.


Modified: branches/subclipse-3​/ui/src/org/tigris/s​ubversion/subclipse/​ui/messages.properti​es
Url: http://svn.collab.ne​t/viewcvs/subclipse/​branches/subclipse-3​/ui/src/org/tigris/s​ubversion/subclipse/​ui/messages.properti​es?view=diff&rev​=792&p1=branches​/subclipse-3/ui/src/​org/tigris/subversio​n/subclipse/ui/messa​ges.properties&r​1=791&p2=branche​s/subclipse-3/ui/src​/org/tigris/subversi​on/subclipse/ui/mess​ages.properties&​r2=792
====================​====================​====================​==================
--- branches/subclipse-3​/ui/src/org/tigris/s​ubversion/subclipse/​ui/messages.properti​es (original)
+++ branches/subclipse-3​/ui/src/org/tigris/s​ubversion/subclipse/​ui/messages.properti​es Tue Jul 27 11:25:25 2004
@@ -288,6 +288,8 @@
 PendingOperationsVie​w.showDeletedResourc​es=Show deleted resources
 PendingOperationsVie​w.showModifiedResour​ces=Show modified resources
 PendingOperationsVie​w.titleWithArgument=​Pending svn operations in {0}
+PendingOperationsVi​ew.computeStatusJob=​Computing pending SVN operations
+PendingOperationsVi​ew.errorComputingSta​tus=Error computing pending operations
 RefreshRemoteProject​SelectionPage.noWork​ingSet=Do not &use a working set
 RefreshRemoteProject​SelectionPage.pageDe​scription=Select the remote projects whose tags should be refreshed.
 RefreshRemoteProject​SelectionPage.pageTi​tle=Select Projects

Modified: branches/subclipse-3​/ui/src/org/tigris/s​ubversion/subclipse/​ui/pending/PendingOp​erationsView.java
Url: http://svn.collab.ne​t/viewcvs/subclipse/​branches/subclipse-3​/ui/src/org/tigris/s​ubversion/subclipse/​ui/pending/PendingOp​erationsView.java?vi​ew=diff&rev=792​&p1=branches/subc​lipse-3/ui/src/org/t​igris/subversion/sub​clipse/ui/pending/Pe​ndingOperationsView.​java&r1=791&​p2=branches/subclips​e-3/ui/src/org/tigri​s/subversion/subclip​se/ui/pending/Pendin​gOperationsView.java​&r2=792
====================​====================​====================​==================
--- branches/subclipse-3​/ui/src/org/tigris/s​ubversion/subclipse/​ui/pending/PendingOp​erationsView.java (original)
+++ branches/subclipse-3​/ui/src/org/tigris/s​ubversion/subclipse/​ui/pending/PendingOp​erationsView.java Tue Jul 27 11:25:25 2004
@@ -21,7 +21,11 @@
 import org.eclipse.core.res​ources.IWorkspaceRoo​t;
 import org.eclipse.core.res​ources.ResourcesPlug​in;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.run​time.IProgressMonito​r;
+import org.eclipse.core.run​time.IStatus;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.core.run​time.Status;
+import org.eclipse.core.run​time.jobs.Job;
 import org.eclipse.jface.ac​tion.Action;
 import org.eclipse.jface.ac​tion.IMenuListener;
 import org.eclipse.jface.ac​tion.IMenuManager;
@@ -42,15 +46,17 @@
 import org.eclipse.jface.vi​ewers.TableViewer;
 import org.eclipse.jface.vi​ewers.Viewer;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.cust​om.BusyIndicator;
 import org.eclipse.swt.dnd.DND;
 import org.eclipse.swt.dnd.Transfer;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layo​ut.GridData;
 import org.eclipse.swt.widg​ets.Composite;
-import org.eclipse.swt.widg​ets.Display;
 import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widg​ets.TableColumn;
+import org.eclipse.team.cor​e.TeamException;
+import org.eclipse.team.int​ernal.ui.Utils;
 import org.eclipse.ui.IActionBars;
 import org.eclipse.ui.IEditorRegistry;
 import org.eclipse.ui.IWorkbench;
@@ -91,6 +97,10 @@
     private Action toggleDeletedAction;
     private Action toggleModifiedAction;
 
+ private IResource[] changedResources = null;
+ private boolean shutdown = false;
+ private ComputeStatusJob computeStatusJob = null;
+
     public PendingOperationsView() {
         SVNProviderPlugin.ad​dResourceStateChange​Listener(this);
     }
@@ -100,47 +110,34 @@
      * @see org.eclipse.ui.IWork​benchPart#dispose()
      */
     public void dispose() {
+ shutdown = true;
         super.dispose();
         SVNProviderPlugin.re​moveResourceStateCha​ngeListener(this);
     }
 
     class EditorsContentProvider implements IStructuredContentProvider {
-
         /**
          * @see org.eclipse.jface.vi​ewers.IStructuredCon​tentProvider#getElem​ents(java.lang.Objec​t)
          */
         public Object[] getElements(Object inputElement) {
- ISVNStatus[] status = (ISVNStatus[]) inputElement;
- IWorkspaceRoot workspaceRoot = ResourcesPlugin.getW​orkspace().getRoot()​;
-
- List resourceList = new ArrayList();
- for (int i = 0; i < status.length;i++) {
- if ( ((status[i].isAdded()) && (toggleAddedAction.i​sChecked())) ||
- ((status[i].isDeleted()) && (toggleDeletedAction​.isChecked())) ||
- ((status[i].isModified()) && (toggleModifiedActio​n.isChecked())) ) {
-
- // path is sometimes absolute, sometimes relative.
- // here we make sure it is absolute
- IPath pathEclipse = null;
- try {
- pathEclipse = new Path( (new Path(status[i].getPa​th())).toFile().getC​anonicalPath());
- } catch (IOException e)
- {
- break; // should never occur ...
- }
-
- IResource resource = null;
- if (status[i].getNodeKind() == SVNNodeKind.DIR)
- resource = workspaceRoot.getCon​tainerForLocation(pa​thEclipse);
- else
- if (status[i].getNodeKind() == SVNNodeKind.FILE)
- resource = workspaceRoot.getFil​eForLocation(pathEcl​ipse);
-
- resourceList.add(resource);
- }
- }
- IResource[] resourceArray = new IResource[resourceList.size()];
- return (IResource[]) resourceList.toArray​(resourceArray);
+ // Short-circuit to optimize
+ if (changedResources != null) return changedResources;
+
+ if(computeStatusJob == null) {
+ computeStatusJob = new ComputeStatusJob();
+ }
+ if(computeStatusJob.getState() != Job.NONE) {
+ computeStatusJob.cancel();
+ try {
+ computeStatusJob.join();
+ } catch (InterruptedException e) {
+ SVNUIPlugin.log(new SVNException(Policy.​bind("PendingOperati​onsView.errorComputi​ngStatus", parent.getName()), e)); //$NON-NLS-1$
+ }
+ }
+ computeStatusJob.setContainer( parent );
+ Utils.schedule(compu​teStatusJob, getViewSite());
+
+ return new IResource[0];
         }
 
         /**
@@ -156,6 +153,7 @@
             Viewer viewer,
             Object oldInput,
             Object newInput) {
+ changedResources = null;
         }
 
     }
@@ -423,9 +421,9 @@
         tableViewer.addDropSupport(ops, transfers, new PendingDropAdapter(tableViewer, this));
     }
     
- public void setInput(ISVNStatus[] status) {
- tableViewer.setInput(status);
- }
+// public void setInput(ISVNStatus[] status) {
+// tableViewer.setInput(status);
+// }
 
     /**
      * fill the popup menu for the table
@@ -488,17 +486,14 @@
      * refresh the view
      */
     public void refresh() {
+ changedResources = null;
 
- Display.getDefault()​.syncExec(new Runnable() {
- public void run() {
- try {
- tableViewer.setInput​(getStatus());
- tableViewer.refresh();
- } catch (SVNException e) {
- // silently ignore exception
- }
- }
- });
+ // show a Busy Cursor during refresh
+ BusyIndicator.showWh​ile(tableViewer.getT​able().getDisplay(),​ new Runnable() {
+ public void run() {
+ tableViewer.refresh();
+ }
+ });
     }
 
     public void resourceSyncInfoChan​ged(IResource[] changedResources) {
@@ -519,22 +514,7 @@
         parent = container;
         setPartName(Policy.b​ind("PendingOperatio​nsView.titleWithArgu​ment", container.getName())); //$NON-NLS-1$
         setContentDescriptio​n(Policy.bind("Pendi​ngOperationsView.tit​leWithArgument", container.getName())); //$NON-NLS-1$
- tableViewer.setInput​(getStatus());
- }
-
- private ISVNStatus[] getStatus() throws SVNException {
- // can be a null parent if we have the view open before we select anything
- if(parent == null)
- return null;
- ISVNStatus[] statuses = null;
- ISVNLocalResource svnResource = SVNWorkspaceRoot.get​SVNResourceFor(paren​t);
- ISVNClientAdapter svnClient = svnResource.getRepos​itory().getSVNClient​();
- try {
- statuses = svnClient.getStatus(​parent.getLocation()​.toFile(),true,true)​;
- } catch (SVNClientException e) {
- throw SVNException.wrapException(e);
- }
- return statuses;
+ tableViewer.setInput​(container);
     }
 
     /**
@@ -564,4 +544,82 @@
         }
     }
 
+ private class ComputeStatusJob extends Job {
+ public IContainer container;
+ public ComputeStatusJob() {
+ super(Policy.bind("P​endingOperationsView​.computeStatusJob"))​; //$NON-NLS-1$;
+ }
+ public void setContainer(IContainer container) {
+ this.container = container;
+ }
+ public IStatus run(IProgressMonitor monitor) {
+ try {
+ if(container != null && !shutdown) {
+ ISVNStatus[] status = getStatus( container );
+ changedResources = getChangedResources( status );
+
+ getSite().getShell()​.getDisplay().asyncE​xec(new Runnable() {
+ public void run() {
+ if(changedResources != null && tableViewer != null && ! tableViewer.getTable​().isDisposed()) {
+ tableViewer.add( changedResources );
+ }
+ }
+ });
+ }
+ return Status.OK_STATUS;
+ } catch (TeamException e) {
+ return e.getStatus();
+ }
+ }
+ };
+
+ private ISVNStatus[] getStatus(IContainer container) throws SVNException {
+ // can be a null parent if we have the view open before we select anything
+ if(parent == null)
+ return null;
+ ISVNStatus[] statuses = null;
+ ISVNLocalResource svnResource = SVNWorkspaceRoot.get​SVNResourceFor(paren​t);
+ ISVNClientAdapter svnClient = svnResource.getRepos​itory().getSVNClient​();
+ try {
+ statuses = svnClient.getStatus(​container.getLocatio​n().toFile(),true,tr​ue);
+ } catch (SVNClientException e) {
+ throw SVNException.wrapException(e);
+ }
+ return statuses;
+ }
+
+ private IResource[] getChangedResources(​ISVNStatus[] status) {
+ if( status == null )
+ return null;
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getW​orkspace().getRoot()​;
+
+ List resourceList = new ArrayList();
+ for (int i = 0; i < status.length;i++) {
+ if ( ((status[i].isAdded()) && (toggleAddedAction.i​sChecked())) ||
+ ((status[i].isDeleted()) && (toggleDeletedAction​.isChecked())) ||
+ ((status[i].isModified()) && (toggleModifiedActio​n.isChecked())) ) {
+
+ // path is sometimes absolute, sometimes relative.
+ // here we make sure it is absolute
+ IPath pathEclipse = null;
+ try {
+ pathEclipse = new Path( (new Path(status[i].getPa​th())).toFile().getC​anonicalPath());
+ } catch (IOException e)
+ {
+ break; // should never occur ...
+ }
+
+ IResource resource = null;
+ if (status[i].getNodeKind() == SVNNodeKind.DIR)
+ resource = workspaceRoot.getCon​tainerForLocation(pa​thEclipse);
+ else
+ if (status[i].getNodeKind() == SVNNodeKind.FILE)
+ resource = workspaceRoot.getFil​eForLocation(pathEcl​ipse);
+
+ resourceList.add(resource);
+ }
+ }
+ IResource[] resourceArray = new IResource[resourceList.size()];
+ return (IResource[]) resourceList.toArray​(resourceArray);
+ }
 }

--------------------​--------------------​--------------------​---------
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: r792 - in branches/subclipse-3/ui/src/org/tigris/subversion/subclipse/ui: . pending pkorros Panagiotis Korros 2004-07-27 09:25:30 PDT
Messages per page: