| 
| Creating a query plugin with graphs [message #8505] | Thu, 15 January 2009 11:47  |  | 
| Eclipse User  |  |  |  |  | It seems quite easy to create a query with a separate plugin, using existing extension points, using something like this.
 
 @Name("Test query")
 @Category("Java Basics")
 @Help("Finds out what is wrong.\n\n")
 public class TestQuery implements IQuery {
 @Argument
 public ISnapshot snapshot;
 
 public IResult execute(IProgressListener listener) throws Exception {
 SectionSpec result = new SectionSpec("Testing");
 return result;
 }
 }
 }
 
 <plugin>
 <extension
 point="org.eclipse.mat.report.query">
 <query
 impl="com.xyz.TestQuery">
 </query>
 </extension>
 </plugin>
 
 The PieFactory seems a quick way of creating graphs, but is internal to
 the org.eclipse.mat.api plugin. What's the recommended way to create pie
 charts?
 |  |  |  | 
| 
| Re: Creating a query plugin with graphs [message #8536 is a reply to message #8505] | Fri, 16 January 2009 03:43   |  | 
| Eclipse User  |  |  |  |  | Hi Andrew, 
 you're right: the PieFactory could and should be made available to ease
 create simple pie charts. For now has been restricted, because I created
 it "on the go" and I am not quite sure if it is THE api that makes sense.
 
 Why don't you go ahead, and use the PieFactory? Let me know if it works
 for you and we will add it the the public API.
 
 
 A query could look like this:
 
 
 public class PieQuery implements IQuery
 {
 @Argument
 public ISnapshot snapshot;
 
 public IResult execute(IProgressListener listener) throws Exception
 {
 PieFactory f = new PieFactory(snapshot);
 
 int[] topDominators = snapshot.getImmediateDominatedIds(-1);
 
 for (int ii = 0; ii < 5 && ii < topDominators.length; ii++)
 f.addSlice(topDominators[ii]);
 
 return f.build();
 }
 
 }
 
 
 
 This would be the change necessary:
 
 
 Index: src/org/eclipse/mat/inspections/util/PieFactory.java
 ============================================================ =======
 --- src/org/eclipse/mat/inspections/util/PieFactory.java	(revision 194)
 +++ src/org/eclipse/mat/inspections/util/PieFactory.java	(working copy)
 @@ -24,7 +24,9 @@
 import org.eclipse.mat.util.HTMLUtils;
 import org.eclipse.mat.util.Units;
 
 -
 +/**
 + * @since 0.7
 + */
 public class PieFactory
 {
 private ISnapshot snapshot;
 Index: META-INF/MANIFEST.MF
 ============================================================ =======
 --- META-INF/MANIFEST.MF	(revision 205)
 +++ META-INF/MANIFEST.MF	(working copy)
 @@ -6,6 +6,7 @@
 Bundle-Vendor: Eclipse.org
 Export-Package:
 org.eclipse.mat.inspections.osgi;x-friends:="org.eclipse.mat.ui ",
 org.eclipse.mat.inspections.osgi.model;x-friends:="org.eclipse.mat.ui ",
 + org.eclipse.mat.inspections.util,
 org.eclipse.mat.internal.snapshot;x-friends:="org.eclipse.mat.ui ",
 org.eclipse.mat.snapshot,
 org.eclipse.mat.snapshot.extension,
 
 
 
 
 
 Cheers,
 
 Andreas.
 |  |  |  | 
|  | 
Powered by 
FUDForum. Page generated in 0.03616 seconds