Use the PartInfoFactory class to generate part reference statistics within the Eclipse IDE; use the GenerationServer class in combination with the EGLSDK class to generate a log outside of the IDE.
com.ibm.etools.egl.ui.parts.PartInfoFactory
The PartInfoFactory class includes the following methods:
public static IPartInfo[] getReferencePartList(IFile eglFile)
throws Exception
public static IPartInfo[] getReferencePartList(IFile eglFile,
boolean removeUnusedMembers)
throws Exception
public static IPartInfo[] getReferenceElementsList(IFile eglFile)
throws Exception
public static IPartInfo[] getReferenceElementsList(IFile eglFile,
boolean removeUnusedMembers)
throws Exception
IPartInfo[] parts = PartInfoFactory.getReferencePartList(genPart);
com.ibm.etools.egl.GenerationServer
The GenerationServer class includes the following methods:
public static void addListener(IGenerationListener listener)
public static void removeListener(IGenerationListener listener)
public static void enableGeneration (boolean flag)
enableGeneration allows the setting of a boolean true or false flag to indicate whether generation of the part is to occur. The default is true. If you set the value to false before invoking the EGLSDK, you can parse and build a list of parts related to an EGL source, without causing subsequent generation to occur.
public static IPartInfo[] getAllUniqueReferencedParts(
IPartInfo[] parts)
public static IElementInfo[] getAllUniqueReferecedElements(
IElementInfo[] elements)
GenerationServer.addListener(listener);
com.ibm.etools.egl.util.EGLSDK eglsdk = new com.ibm.etools.egl.util.EGLSDK();
GenerationServer.removeListener(listener);
The IGenerationListener interface includes the following methods:
The IPartInfo interface includes the following methods:
Typically, a new Set and ArrayList are obtained and then released surrounding the logic to process all parts in the action. For example,
public void run(IAction action) {
resources = new HashSet();
partList = new ArrayList();
Iterator selectionIterator = this.selection.iterator();
while (selectionIterator.hasNext()) {
Object object = selectionIterator.next();
if ((object instanceof IEGLFile)) {
IEGLFile iEglFile = (IEGLFile) object;
try {
IFile eglFile = ResourcesPlugin.getWorkspace().getRoot().getFile(iEglFile.getUnderlyingResource().getFullPath());
IPartInfo[] associatedParts = PartInfoFactory.getReferencePartList(eglFile);
generateEglSourceFile(associatedParts, eglFile);
} catch (Exception e) {
e.printStackTrace();
}
}
}
resources = null;
partList = null;
}
private static void generateEsf(IPartInfo[] associatedParts, IFile eglFile) {
....
associatedParts = GenerationServer.getAllUniqueReferecedParts(associatedParts);
try {
BufferedWriter out = new BufferedWriter(new FileWriter(outFile, false));
for (int i = 0; i < associatedParts.length; i++) {
out.write(associatedParts[i].getSource(resources, partList));
out.write("\n");
}
out.close();
}
catch (Exception e) {
e.printStackTrace();
}
}