Eclipse Plugin Development - Getting information from Team Provider
I am very new to developing eclipse plugins. The biggest hurdle I am facing right now is where/how to get at the data from various other plugins. I am having a real hard time finding documentation for this. For instance the Team Provider plugin....
- How do I read the svn revision of a file? Lets say I have an IResourceChangeListener and I want to keep track of the svn revision number of a file (if the user did an update for example).
- If I want to ask svn if there are pending updates for a project, how do I talk to the eclipse team provi开发者_如何学Goder?
I am not sure where to start...
Thanks!
I eventually discovered what I was looking for after many hours of searching. Unfortunately since I have less than 100 rep. I have been unable to post until now....
I am making a little progress on this. I randomly stumbled upon this while pouring through eclipse source code.
The following code snippet monitors everything that goes on with regard to an svn enabled project. If you save a file, to an update, revert etc. Anything that touches the files or meta data of the files. I just print out the file/direcory name and its revision number.
Subversive version:
final Subscriber subscriber = UpdateSubscriber.instance();
subscriber.addListener(new ISubscriberChangeListener() {
@Override
public void subscriberResourceChanged(ISubscriberChangeEvent[] events) {
for(ISubscriberChangeEvent event : events) {
UpdateSyncInfo info = (UpdateSyncInfo) subscriber.getSyncInfo(event.getResource());
System.out.println(event.getResource().getName()+" revision: "+uInfo.getLocalResource().getRevision());
}
}
});
The real trick was figuring out the entry point to get at this information: UpdateSubscriber. It would be nice if there was a good resource for finding out this sort of information.
Subclipse version:
private static final Subscriber subscriber = SVNWorkspaceSubscriber.getInstance();
private static final ISubscriberChangeListener subsciberListener = new ISubscriberChangeListener() {
@Override
public void subscriberResourceChanged(ISubscriberChangeEvent[] events) {
try {
for (ISubscriberChangeEvent event : events) {
SVNStatusSyncInfo info = (SVNStatusSyncInfo) subscriber.getSyncInfo(event.getResource());
System.out.println(event.getResource().getName() + " revision: " + info.getRepositoryRevision());
}
} catch (TeamException e) {
}
}
};
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
subscriber.addListener(subsciberListener);
}
@Override
public void stop(BundleContext context) throws Exception {
subscriber.removeListener(subsciberListener);
super.stop(context);
}
For general information on the Team API in the Eclipse platform, review the documentation in the help system.
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/team.htm
(If you're working with the Subscriber stuff, it appears that's mentioned under the "Synchronization Support" -> "Beyond the Basics" topic.)
The Java doc for the team packages also helps:
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/team/core/package-summary.html
If you're trying to integrate with or otherwise extend the Subclipse or Subversive team providers, you may have better luck asking your question in their forums:
http://subclipse.tigris.org/ds/viewForums.do
http://www.eclipse.org/subversive/newsgroup.php
One starting point would be to explore the sources of subversive to see how they did their implementation of the features you are describing.
The sources for eclipse.team
(the common module for all VCS plugins) are available in a Git repo.
The sources for EGit, another VCS plugin (for Git) can also be instructive.
精彩评论