diff options
| author | slewis | 2005-02-23 16:21:04 +0000 |
|---|---|---|
| committer | slewis | 2005-02-23 16:21:04 +0000 |
| commit | a639087489ccf2e24e273db4c19d1b0f70447ce1 (patch) | |
| tree | 88c80775a91525f25d81efb298b14bad8a9060a8 | |
| parent | da3877ec44ffec0979283b634a646662da6ff9a9 (diff) | |
| download | org.eclipse.ecf-a639087489ccf2e24e273db4c19d1b0f70447ce1.tar.gz org.eclipse.ecf-a639087489ccf2e24e273db4c19d1b0f70447ce1.tar.xz org.eclipse.ecf-a639087489ccf2e24e273db4c19d1b0f70447ce1.zip | |
Generalized use of IProject interface to IResource (so it could be associated with projects and/or workspaces or other resources)
3 files changed, 26 insertions, 27 deletions
diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java index 888f846e3..24b2992b7 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java @@ -18,7 +18,7 @@ import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.Vector; -import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; @@ -75,7 +75,7 @@ public class Client { } } - protected static void addClientEntry(IProject proj, ClientEntry entry) { + protected static void addClientEntry(IResource proj, ClientEntry entry) { synchronized (clients) { Vector v = (Vector) clients.get(proj.getName()); if (v == null) { @@ -85,12 +85,12 @@ public class Client { clients.put(proj.getName(),v); } } - protected static Vector getClientEntries(IProject proj) { + protected static Vector getClientEntries(IResource proj) { synchronized (clients) { return (Vector) clients.get(proj.getName()); } } - protected static ClientEntry getClientEntry(IProject proj, String type) { + protected static ClientEntry getClientEntry(IResource proj, String type) { synchronized (clients) { Vector v = (Vector) getClientEntries(proj); if (v == null) return null; @@ -103,7 +103,7 @@ public class Client { } return null; } - protected static boolean containsEntry(IProject proj, String type) { + protected static boolean containsEntry(IResource proj, String type) { synchronized (clients) { Vector v = (Vector) clients.get(proj.getName()); if (v == null) return false; @@ -116,7 +116,7 @@ public class Client { } return false; } - protected static void removeClientEntry(IProject proj, String type) { + protected static void removeClientEntry(IResource proj, String type) { synchronized (clients) { Vector v = (Vector) clients.get(proj.getName()); if (v == null) return; @@ -137,7 +137,7 @@ public class Client { defaultGroupID = IDFactory.makeStringID(DEFAULT_SERVER_ID); } - protected User getUserData(String containerType, ID clientID, String usernick, String proj, IProject project) { + protected User getUserData(String containerType, ID clientID, String usernick, String proj, IResource project) { Vector topElements = new Vector(); String contType = containerType.substring(containerType.lastIndexOf(".")+1); topElements.add(new TreeItem("Project", proj)); @@ -170,24 +170,24 @@ public class Client { return new User(clientID, usernick, topElements); } - protected String getSharedFileDirectoryForProject(IProject proj) { + protected String getSharedFileDirectoryForProject(IResource proj) { String eclipseDir = Platform.getLocation().lastSegment(); if (proj == null) return eclipseDir + "/" + ECFDIRECTORY; else return FILE_DIRECTORY; } - protected IProject getFirstProjectFromWorkspace() throws Exception { + protected IResource getFirstProjectFromWorkspace() throws Exception { IWorkspace ws = ResourcesPlugin.getWorkspace(); IWorkspaceRoot wr = ws.getRoot(); - IProject[] projects = wr.getProjects(); + IResource[] projects = wr.getProjects(); if (projects == null) return null; return projects[0]; } protected void makeAndAddSharedObject(final ClientEntry client, - final IProject proj, User user, String fileDir) throws Exception { + final IResource proj, User user, String fileDir) throws Exception { IWorkbenchWindow ww = PlatformUI.getWorkbench() .getActiveWorkbenchWindow(); EclipseCollabSharedObject sharedObject = new EclipseCollabSharedObject(proj, ww, @@ -213,8 +213,8 @@ public class Client { } protected void addObjectToClient(ClientEntry client, - String username, IProject proj) throws Exception { - IProject project = (proj == null) ? getFirstProjectFromWorkspace() + String username, IResource proj) throws Exception { + IResource project = (proj == null) ? getFirstProjectFromWorkspace() : proj; String fileDir = getSharedFileDirectoryForProject(project); String projName = (project == null) ? "<workspace>" : project.getName(); @@ -223,7 +223,7 @@ public class Client { makeAndAddSharedObject(client, project, user, fileDir); } - public synchronized ClientEntry isConnected(IProject project, String type) { + public synchronized ClientEntry isConnected(IResource project, String type) { if (type == null) type = GENERIC_CONTAINER_CLIENT_NAME; ClientEntry entry = getClientEntry(project,type); return entry; @@ -236,7 +236,7 @@ public class Client { else return false; } public synchronized void createAndConnectClient(String type, final ID gID, String username, - Object data, final IProject proj) throws Exception { + Object data, final IResource proj) throws Exception { if (proj == null) throw new NullPointerException("Project cannot be null"); ClientEntry entry = getClientEntry(proj,type); @@ -274,12 +274,12 @@ public class Client { addClientEntry(proj,newClient); } - public synchronized void disposeClient(IProject proj, ClientEntry entry) { + public synchronized void disposeClient(IResource proj, ClientEntry entry) { entry.dispose(); removeClientEntry(proj,entry.getType()); } - public synchronized static ISharedObjectContainer getContainer(IProject proj) { + public synchronized static ISharedObjectContainer getContainer(IResource proj) { ClientEntry entry = getClientEntry(proj,GENERIC_CONTAINER_CLIENT_NAME); if (entry != null) return entry.getContainer(); else return null; diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseCollabSharedObject.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseCollabSharedObject.java index d05900f9a..a58fd9cc3 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseCollabSharedObject.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseCollabSharedObject.java @@ -16,7 +16,6 @@ import java.io.IOException; import java.net.URL; import java.net.URLClassLoader; import java.util.Date; -import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Platform; @@ -59,7 +58,7 @@ public class EclipseCollabSharedObject extends GenericSharedObject implements protected LineChatClientView localGUI; - IProject localProject; + IResource localProject; User localUser; @@ -80,7 +79,7 @@ public class EclipseCollabSharedObject extends GenericSharedObject implements public EclipseCollabSharedObject() { } - public EclipseCollabSharedObject(IProject proj, IWorkbenchWindow shell, + public EclipseCollabSharedObject(IResource proj, IWorkbenchWindow shell, User user, String downloaddir) { this.localProject = proj; this.shellWindow = shell; @@ -187,10 +186,10 @@ public class EclipseCollabSharedObject extends GenericSharedObject implements eclipseDir = "."; } String projectDir = null; - if (getProject() == null) { + if (getResource() == null) { projectDir = downloaddir; } else { - projectDir = getProject().getFullPath().toOSString(); + projectDir = getResource().getFullPath().toOSString(); } File fresult = new File(eclipseDir, projectDir); return fresult.getAbsolutePath(); @@ -228,7 +227,7 @@ public class EclipseCollabSharedObject extends GenericSharedObject implements return localGUI; } - public IProject getProject() { + public IResource getResource() { return localProject; } @@ -724,7 +723,7 @@ public class EclipseCollabSharedObject extends GenericSharedObject implements } } - protected void doCVSUpdateOperation(IProject proj, User fromUser) { + protected void doCVSUpdateOperation(IResource proj, User fromUser) { /* * IResource[] resources = new IResource[1]; resources[0] = proj; try { * new UpdateOperation(getViewPart(), resources, @@ -738,7 +737,7 @@ public class EclipseCollabSharedObject extends GenericSharedObject implements protected void handleCVSProjectUpdateRequest(final User fromUser, final String msg) { - final IProject proj = getProject(); + final IResource proj = getResource(); // If project doesn't actually exist, just return silently if (!proj.exists() || !isCVSShared()) return; diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseProject.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseProject.java index c5b3c5245..6b8260c5f 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseProject.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseProject.java @@ -11,7 +11,7 @@ package org.eclipse.ecf.example.collab.share; -import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; import org.eclipse.ecf.core.ISharedObjectContext; import org.eclipse.ecf.core.identity.ID; import org.eclipse.swt.widgets.Control; @@ -29,7 +29,7 @@ public interface EclipseProject { public ID getID(); - public IProject getProject(); + public IResource getResource(); public IWorkbenchWindow getWorkbenchWindow(); public ISharedObjectContext getContext(); |
