|
|
|
|
Re: Building from source - Setting up the workbench [message #659014 is a reply to message #658999] |
Thu, 10 March 2011 17:05 |
Aaron Allsbrook Messages: 24 Registered: July 2009 |
Junior Member |
|
|
I'm attempting to move EGLDoc onto EDT.
Creating a new plugin
1. New Project, Type Plugin Project
2. Name - com.clearblade.edt.egl.doc
3. Next, Next, On templates page choose Plugin with a popup menu
4. On popup menu wizard page
- Target Objects Class - org.eclipse.core.resources.IProject
- Submenu Name - ClearBlade Documentation
- Action Label - Create EGLDoc
- java package name - default
- action calls - EGLDocPopup
- Multiple selection //EDIT I change this to '+' in the plugin editor view so that popup will activate for 1 to many projects selected
5. Click Finish
Updating the plugin dependencies
1. Open the MANIFEST.MF editor
2. Choose dependencies tab
3. Under required plugins - Click add and include org.eclipse.edt.compiler, org.eclipse.edt.mof, and org.eclipse.edt.mof.egl
[Updated on: Thu, 10 March 2011 18:37] Report message to a moderator
|
|
|
|
|
Re: Building from source - Setting up the workbench [message #659254 is a reply to message #659043] |
Fri, 11 March 2011 16:58 |
Aaron Allsbrook Messages: 24 Registered: July 2009 |
Junior Member |
|
|
Its not the most elegant thing at this point. But this bit of code will inspect eclipse projects, find EGLSource folders, force an EGL to EGLXML compile into a project local directory. It then builds a list of all parts in the compile folder. From there it iterates across each part and prints some interesting stuff to the screen (this is taken from one of the provided samples)
package com.clearblade.edt.egl.doc;
import java.io.File;
import java.io.PrintStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.edt.mof.egl.Part;
import org.eclipse.edt.mof.egl.compiler.EGL2IR;
import org.eclipse.edt.mof.egl.utils.IRLoader;
import org.eclipse.edt.mof.egl.utils.LoadPartException;
import org.eclipse.edt.mof.serialization.Serializer;
import org.eclipse.edt.mof.serialization.xml.XMLSerializer;
public class EGLDocManager {
private class IRLoaderInfo {
String rootDir;
String partName;
}
public EGLDocManager(List<IProject> selectedProjects) {
try {
for (Iterator<IProject> iterator = selectedProjects.iterator(); iterator.hasNext();) {
IProject iProject = (IProject) iterator.next();
if (iProject.exists()){
forceCompile(iProject);
iProject.getProject().refreshLocal(1, new NullProgressMonitor());
List<IRLoaderInfo> IRLoaderInfoList = getIRLoaderInfoForProject(iProject);
processParts(IRLoaderInfoList);
System.out.println("stop here");
//cleanup the IR xml
//deleteDir(file)
iProject.getProject().refreshLocal(1, new NullProgressMonitor());
}
}
} catch (CoreException e) {
e.printStackTrace();
}
}
private void forceCompile(IProject iProject){
IFolder eglSourceFolder = iProject.getFolder("EGLSource");
String irDest = (iProject.getLocation().append("edtIR")).toOSString();
File file = new File (irDest);
file.mkdir();
deleteDir(file);
String[] args = { "-irDestination", irDest, "-xmlOut", "-isVAGCompatible", eglSourceFolder.getLocation().toOSString() };
try {
EGL2IR.main(args);
} catch (Throwable t) {
t.printStackTrace();
}
}
private List<IRLoaderInfo> getIRLoaderInfoForProject(IProject iProject){
List<IRLoaderInfo> IRLoaderInfoList = new ArrayList<IRLoaderInfo>();
String irDest = (iProject.getLocation().append("edtIR")).toOSString();
IFolder eglIRFolder = iProject.getFolder("edtIR");
IRLoaderInfoList = getEGLFileList(eglIRFolder, irDest, "");
return IRLoaderInfoList;
}
private List<IRLoaderInfo> getEGLFileList(IFolder iFolder, String rootDir, String eglPackage) {
List<IRLoaderInfo> IRLoaderInfoList = new ArrayList<IRLoaderInfo> ();
String filePath;
IRLoaderInfo irLoaderInfo;
try {
IResource[] resources = ((IContainer) iFolder).members();
for (int i = 0; i < resources.length; i++) {
if (resources[i] instanceof IFolder){
String nextPackage = ((IFolder)resources[i]).getName();
if (eglPackage.length()>0) {
nextPackage = eglPackage+"."+((IFolder)resources[i]).getName();
}
IRLoaderInfoList.addAll(getEGLFileList((IFolder)resources[i], rootDir, nextPackage));
}
else if (resources[i] instanceof IFile && ((IFile)resources[i]).exists()){
filePath = ((IFile)resources[i]).getLocation().toOSString();
if ( filePath.endsWith(".eglxml")) {
irLoaderInfo = new IRLoaderInfo();
irLoaderInfo.partName=eglPackage+"."+((IFile)resources[i]).getName();
irLoaderInfo.partName = irLoaderInfo.partName.substring(0, irLoaderInfo.partName.length()-7);
irLoaderInfo.rootDir=rootDir;
IRLoaderInfoList.add(irLoaderInfo);
}
}
}
} catch (CoreException e) {
e.printStackTrace();
}
return IRLoaderInfoList;
}
private void deleteDir(File dir){
if(dir.isDirectory()){
for(File sub : dir.listFiles()){
deleteDir(sub);
}
dir.delete();
}else{
dir.delete();
}
}
private void processParts(List<IRLoaderInfo> irLoaderInfoList) {
for (Iterator<IRLoaderInfo> iterator = irLoaderInfoList.iterator(); iterator.hasNext();) {
IRLoaderInfo irLoaderInfo = (IRLoaderInfo) iterator.next();
Part part;
try {
part = IRLoader.loadEGLPart(irLoaderInfo.rootDir, irLoaderInfo.partName);
displayPart(part,System.out);
displaySerializedPart(part,System.out);
} catch (LoadPartException e) {
e.printStackTrace();
}
}
}
public void displayPart(Part part, PrintStream out) {
out.print(part.toString());
}
public void displaySerializedPart(Part part, PrintStream out) {
Serializer xml = new XMLSerializer();
xml.serialize(part);
out.print((String)xml.getContents());
}
}
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05416 seconds