use of org.talend.commons.exception.SystemException in project tdi-studio-se by Talend.
the class CodeView method refresh.
public void refresh() {
ICodeGeneratorService service = DesignerPlugin.getDefault().getCodeGeneratorService();
if (service.isInitializingJet()) {
return;
}
if (isGenerating()) {
return;
}
setGenerating(true);
final List<? extends INode> generatingNodes = selectedNode.getProcess().getGeneratingNodes();
Job job = new //$NON-NLS-1$
Job(//$NON-NLS-1$
Messages.getString("CodeView.initMessage")) {
@Override
protected IStatus run(IProgressMonitor monitor) {
if (selectedNode != null) {
//$NON-NLS-1$
generatedCode = "";
try {
// joblet or joblet node
boolean isJoblet = AbstractProcessProvider.isExtensionProcessForJoblet(selectedNode.getProcess());
if (!isJoblet && PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService jobletSservice = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (jobletSservice != null && jobletSservice.isJobletComponent(selectedNode)) {
isJoblet = true;
}
}
if (isJoblet) {
return org.eclipse.core.runtime.Status.OK_STATUS;
}
generatingNode = null;
for (INode node : generatingNodes) {
if (node.getUniqueName().equals(selectedNode.getUniqueName())) {
generatingNode = node;
}
}
if (generatingNode == null) {
//$NON-NLS-1$
generatedCode = Messages.getString("CodeView.MultipleComponentError");
return org.eclipse.core.runtime.Status.OK_STATUS;
}
ICodeGeneratorService service = DesignerPlugin.getDefault().getCodeGeneratorService();
// have to do this dirty change to avoid the side effect for BD component.
codeGenerator = service.createCodeGenerator(selectedNode.getProcess(), false, false);
viewStartAction.setChecked(false);
viewMainAction.setChecked(false);
viewEndAction.setChecked(false);
viewAllAction.setChecked(false);
switch(codeView) {
case CODE_START:
viewStartAction.setChecked(true);
generatedCode = codeGenerator.generateComponentCode(generatingNode, ECodePart.BEGIN);
break;
case CODE_MAIN:
viewMainAction.setChecked(true);
generatedCode = codeGenerator.generateComponentCode(generatingNode, ECodePart.MAIN);
break;
case CODE_END:
viewEndAction.setChecked(true);
generatedCode = codeGenerator.generateComponentCode(generatingNode, ECodePart.END);
break;
case CODE_ALL:
viewAllAction.setChecked(true);
generatedCode = codeGenerator.generateComponentCode(generatingNode, ECodePart.BEGIN);
generatedCode += codeGenerator.generateComponentCode(generatingNode, ECodePart.MAIN);
generatedCode += codeGenerator.generateComponentCode(generatingNode, ECodePart.END);
break;
default:
}
} catch (SystemException e) {
//$NON-NLS-1$
generatedCode = Messages.getString("CodeView.Error");
ExceptionHandler.process(e);
} catch (Exception e) {
// Some exceptions can appear in case we close some jobs while generating
// Just ignore them, and set blank directly to the code view
//$NON-NLS-1$
generatedCode = "";
}
}
return org.eclipse.core.runtime.Status.OK_STATUS;
}
};
job.setPriority(Job.INTERACTIVE);
job.schedule();
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
new UIJob("") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
document.set(generatedCode);
setGenerating(false);
return org.eclipse.core.runtime.Status.OK_STATUS;
}
}.schedule();
}
});
}
use of org.talend.commons.exception.SystemException in project tdi-studio-se by Talend.
the class JavaSQLPatternSynchronizer method syncSQLPattern.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.codegen.ISQLPatternSynchronizer#syncSQLPattern(org.talend.core.model.properties.SQLPatternItem
* , boolean)
*/
@Override
public void syncSQLPattern(SQLPatternItem routineItem, boolean copyToTemp) throws SystemException {
FileOutputStream fos = null;
try {
IFile file = getSQLPatternFile(routineItem);
if (file == null) {
return;
}
if (copyToTemp) {
String routineContent = new String(routineItem.getContent().getInnerContent());
File f = file.getLocation().toFile();
fos = new FileOutputStream(f);
fos.write(routineContent.getBytes());
fos.close();
}
file.refreshLocal(1, null);
} catch (CoreException e) {
throw new SystemException(e);
} catch (IOException e) {
throw new SystemException(e);
} finally {
try {
fos.close();
} catch (Exception e) {
// ignore me even if i'm null
}
}
}
use of org.talend.commons.exception.SystemException in project tdi-studio-se by Talend.
the class JavaRoutineSynchronizer method syncRoutineItems.
private void syncRoutineItems(Collection<RoutineItem> routineObjects, boolean forceUpdate) throws SystemException {
for (RoutineItem routineItem : routineObjects) {
syncRoutine(routineItem, true, forceUpdate);
}
try {
ILibrariesService jms = CorePlugin.getDefault().getLibrariesService();
List<URL> urls = jms.getTalendRoutinesFolder();
for (URL systemModuleURL : urls) {
if (systemModuleURL != null) {
String fileName = systemModuleURL.getPath();
if (fileName.startsWith("/")) {
//$NON-NLS-1$
fileName = fileName.substring(1);
}
File f = new File(systemModuleURL.getPath());
if (f.isDirectory()) {
syncModule(f.listFiles());
}
}
}
} catch (IOException e) {
throw new SystemException(e);
}
}
use of org.talend.commons.exception.SystemException in project tdi-studio-se by Talend.
the class GenerateGrammarController method addReferenceJavaFile.
/**
* Store file to file system. Actually, it locates src/routines/xx DOC ytao Comment method "addReferenceJavaFile".
*
* @param routineItem
* @param copyToTemp
* @return
* @throws SystemException
*/
private IFile addReferenceJavaFile(RoutineItem routineItem, boolean copyToTemp) throws SystemException {
FileOutputStream fos = null;
try {
IRunProcessService service = DesignerPlugin.getDefault().getRunProcessService();
ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
if (talendProcessJavaProject == null) {
return null;
}
String label = routineItem.getProperty().getLabel();
IFile file = talendProcessJavaProject.getSrcFolder().getFile(JavaUtils.JAVA_ROUTINES_DIRECTORY + '/' + label + JavaUtils.JAVA_EXTENSION);
if (copyToTemp) {
String routineContent = new String(routineItem.getContent().getInnerContent());
if (!label.equals(ITalendSynchronizer.TEMPLATE)) {
routineContent = routineContent.replaceAll(ITalendSynchronizer.TEMPLATE, label);
File f = file.getLocation().toFile();
fos = new FileOutputStream(f);
fos.write(routineContent.getBytes());
fos.close();
}
}
if (!file.exists()) {
file.refreshLocal(1, null);
}
return file;
} catch (Exception e) {
throw new SystemException(e);
} finally {
try {
fos.close();
} catch (Exception e) {
// ignore me even if i'm null
ExceptionHandler.process(e);
}
}
}
use of org.talend.commons.exception.SystemException in project tdi-studio-se by Talend.
the class OpenExistVersionProcessWizard method openAnotherVersion.
protected void openAnotherVersion(final RepositoryNode node, final boolean readonly) {
try {
if (node.getObject() != null) {
final Item item = node.getObject().getProperty().getItem();
final IWorkbenchPage page = getActivePage();
final RepositoryEditorInput fileEditorInput = getEditorInput(item, readonly, page);
if (fileEditorInput != null) {
IEditorPart editorPart = page.findEditor(fileEditorInput);
if (editorPart == null) {
fileEditorInput.setRepositoryNode(node);
if (item instanceof ProcessItem) {
page.openEditor(fileEditorInput, MultiPageTalendEditor.ID, readonly);
} else if (item instanceof BusinessProcessItem) {
CorePlugin.getDefault().getDiagramModelService().openBusinessDiagramEditor(page, fileEditorInput);
} else {
ECodeLanguage lang = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage();
//$NON-NLS-1$ //$NON-NLS-2$
String talendEditorID = "org.talend.designer.core.ui.editor.StandAloneTalend" + lang.getCaseName() + "Editor";
page.openEditor(fileEditorInput, talendEditorID);
}
} else {
page.activate(editorPart);
}
} else {
// TDI-19014:open another version of jobScript
if (item instanceof JobScriptItem) {
IProject fsProject = ResourceUtils.getProject(ProjectManager.getInstance().getCurrentProject());
openXtextEditor(node, fsProject, readonly);
}
}
}
} catch (PartInitException e) {
MessageBoxExceptionHandler.process(e);
} catch (SystemException e) {
MessageBoxExceptionHandler.process(e);
}
}
Aggregations