use of com.centurylink.mdw.plugin.designer.model.JavaSource in project mdw-designer by CenturyLinkCloud.
the class CodeGenWizard method generateCode.
/**
* @return true if registration should continue
*/
protected boolean generateCode(String jetFile, IProgressMonitor monitor) throws CoreException {
String targetFolder;
if (getCodeGenType() == CodeGenType.staticJavaCode) {
targetFolder = getCodeElement().getPackageFragmentRoot().getPath().toString();
String targetFile = getCodeElement().getClassName() + ".java";
IPackageFragment packageFragment = getCodeElement().getPackageFragment();
JetAccess jet = getJet(jetFile, targetFolder, targetFile, packageFragment);
Generator generator = new Generator(getShell());
generator.createFileAndOpen(getShell(), jet, monitor);
} else if (getCodeGenType() == CodeGenType.dynamicJavaCode) {
String pkgPath = getCodeElement().getPackage().getName().replace('.', '/');
if (getCodeElement().getProject().isFilePersist())
targetFolder = getCodeElement().getProject().getAssetFolder().getFullPath() + "/" + pkgPath;
else
targetFolder = getCodeElement().getProject().getTempFolder().getFullPath() + "/" + pkgPath;
String targetFile = getCodeElement().getClassName() + ".java";
getCodeElement().getProject().setJava();
JavaSource javaAsset = createJavaAssetAndOpen(getCodeElement().getPackage(), jetFile, targetFolder, targetFile, monitor);
return javaAsset != null;
}
return true;
}
use of com.centurylink.mdw.plugin.designer.model.JavaSource in project mdw-designer by CenturyLinkCloud.
the class CodeGenWizard method createJavaAssetAndOpen.
protected JavaSource createJavaAssetAndOpen(WorkflowPackage workflowPackage, String jetFile, String targetFolder, String targetFile, IProgressMonitor monitor) throws CoreException {
JetAccess jet = getJet(jetFile, targetFolder, targetFile);
Generator generator = new Generator(getShell());
IFile contentFile = generator.createFile(jet, monitor);
WorkflowProject workflowProject = workflowPackage.getProject();
JavaSource javaAsset = new JavaSource();
javaAsset.setLanguage(RuleSetVO.JAVA);
javaAsset.setName(contentFile.getName());
javaAsset.setProject(workflowProject);
javaAsset.setPackage(workflowPackage);
String content = new String(PluginUtil.readFile(contentFile));
javaAsset.setContent(content);
contentFile.refreshLocal(IResource.DEPTH_ZERO, monitor);
contentFile.delete(true, monitor);
DesignerProxy designerProxy = javaAsset.getProject().getDesignerProxy();
try {
designerProxy.createNewWorkflowAsset(javaAsset, true);
} catch (Exception ex) {
PluginMessages.uiError(getShell(), ex, "New " + javaAsset.getTitle(), javaAsset.getProject());
return null;
}
if (designerProxy.getRunnerStatus().equals(RunnerStatus.SUCCESS)) {
javaAsset.openFile(new NullProgressMonitor());
javaAsset.addElementChangeListener(javaAsset.getProject());
javaAsset.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, javaAsset);
WorkflowAssetFactory.registerAsset(javaAsset);
return javaAsset;
} else {
return null;
}
}
use of com.centurylink.mdw.plugin.designer.model.JavaSource in project mdw-designer by CenturyLinkCloud.
the class ProjectConfigurator method loadJavaLibraries.
public void loadJavaLibraries(IProgressMonitor monitor) {
// locally save all the Java libraries
for (WorkflowAsset asset : project.getTopLevelWorkflowAssets()) {
if (asset instanceof JavaSource) {
if (!asset.isLoaded())
asset.load();
try {
IFolder folder = asset.getTempFolder();
if (!folder.exists())
PluginUtil.createFoldersAsNeeded(project.getSourceProject(), folder, monitor);
IFile tempFile = asset.getTempFile(folder);
if (tempFile.exists())
new TempFileRemover(folder, tempFile).remove(monitor);
tempFile.create(new ByteArrayInputStream(asset.getFileContent()), true, monitor);
PluginMessages.log("Created Java lib file: " + tempFile.getFullPath().toString());
} catch (CoreException ex) {
PluginMessages.uiError(ex, "Load Java Libraries", project);
}
}
}
}
Aggregations