use of org.eclipse.core.runtime.IProgressMonitor in project tdi-studio-se by Talend.
the class JSONFileSchema2TreeLinker method createLinks.
public void createLinks() {
removeAllLinks();
getBackgroundRefresher().refreshBackground();
ProgressDialog progressDialog = new ProgressDialog(getSource().getShell(), 1000) {
private IProgressMonitor monitorWrap;
@Override
public void run(IProgressMonitor monitor) {
TreeItem root = jsonViewer.getTree().getItem(0);
// if (getManager().getFoxComponent().istFileOutputMSXML()) {
// List<FOXTreeNode> treeData = getManager().getTreeData(getManager().getCurrentSchema());
// if (treeData != null && treeData.size() > 0) {
// FOXTreeNode rootTreeData = treeData.get(0);
// for (TreeItem item : xmlViewer.getTree().getItems()) {
// if (rootTreeData == item.getData()) {
// root = item;
// break;
// }
// }
// }
// }
List<TreeItem> allItems = TreeUtils.collectAllItems(root);
monitorWrap = new EventLoopProgressMonitor(monitor);
String taskName = "Loop links creation ...";
int totalWork = allItems.size();
//$NON-NLS-1$
monitorWrap.beginTask(taskName, totalWork);
for (int i = 0; i < totalWork; i++) {
if (monitorWrap.isCanceled()) {
return;
}
TreeItem treeItem = allItems.get(i);
FOXTreeNode node = (FOXTreeNode) treeItem.getData();
if (node.getColumn() == null) {
//$NON-NLS-1$
continue;
}
createLoopLinks(node.getColumn().getLabel(), treeItem, monitorWrap, i == totalWork - 1);
monitorWrap.worked(1);
}
monitorWrap.done();
}
};
try {
progressDialog.executeProcess();
} catch (InvocationTargetException e) {
e.printStackTrace();
ExceptionHandler.process(e);
} catch (InterruptedException e) {
ExceptionHandler.process(e);
}
}
use of org.eclipse.core.runtime.IProgressMonitor in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method updateRunJobContext.
protected void updateRunJobContext() {
final JobContextManager manager = (JobContextManager) getProcess().getContextManager();
if (manager.isModified()) {
final Map<String, String> nameMap = manager.getNameMap();
// gcui:add a progressDialog.
Shell shell = null;
Display display = PlatformUI.getWorkbench().getDisplay();
if (display != null) {
shell = display.getActiveShell();
}
if (shell == null) {
display = Display.getCurrent();
if (display == null) {
display = Display.getDefault();
}
if (display != null) {
shell = display.getActiveShell();
}
}
ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell);
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(final IProgressMonitor monitor) {
//$NON-NLS-1$
monitor.beginTask(Messages.getString("AbstractMultiPageTalendEditor_pleaseWait"), IProgressMonitor.UNKNOWN);
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
factory.executeRepositoryWorkUnit(new //$NON-NLS-1$
RepositoryWorkUnit<Object>(//$NON-NLS-1$
"..", //$NON-NLS-1$
this) {
@Override
protected void run() throws LoginException, PersistenceException {
try {
IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
Set<String> curContextVars = getCurrentContextVariables(manager);
IProcess2 process2 = getProcess();
String jobId = process2.getProperty().getId();
IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
List<IProcess2> processes = CorePlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
// gcui:if nameMap is empty it do nothing.
if (!nameMap.isEmpty()) {
UpdateRunJobComponentContextHelper.updateItemRunJobComponentReference(factory, nameMap, jobId, curContextVars);
UpdateRunJobComponentContextHelper.updateOpenedJobRunJobComponentReference(processes, nameMap, jobId, curContextVars);
}
// add for bug 9564
List<IRepositoryViewObject> all = factory.getAll(ERepositoryObjectType.PROCESS, true);
List<ProcessItem> allProcess = new ArrayList<ProcessItem>();
for (IRepositoryViewObject repositoryObject : all) {
Item item = repositoryObject.getProperty().getItem();
if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
allProcess.add(processItem);
}
}
UpdateRunJobComponentContextHelper.updateRefJobRunJobComponentContext(factory, allProcess, process2);
} catch (PersistenceException e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
manager.setModified(false);
}
});
}
});
monitor.done();
if (monitor.isCanceled()) {
try {
//$NON-NLS-1$
throw new InterruptedException("Save Fail");
} catch (InterruptedException e) {
ExceptionHandler.process(e);
}
}
}
};
try {
progressDialog.run(true, true, runnable);
} catch (InvocationTargetException e1) {
ExceptionHandler.process(e1);
} catch (InterruptedException e1) {
ExceptionHandler.process(e1);
}
}
}
use of org.eclipse.core.runtime.IProgressMonitor in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method generateCode.
/**
* DOC bqian Comment method "generateCode".
*/
protected void generateCode() {
final IProcess2 process = getProcess();
if (!(process.getProperty().getItem() instanceof ProcessItem)) {
// shouldn't work for joblet
return;
}
if (process.getGeneratingNodes().size() != 0) {
Job job = new //$NON-NLS-1$
AccessingEmfJob(//$NON-NLS-1$
"Generating code") {
@Override
protected IStatus doRun(IProgressMonitor monitor) {
try {
ProcessorUtilities.generateCode(process, process.getContextManager().getDefaultContext(), false, false, true, ProcessorUtilities.GENERATE_WITH_FIRST_CHILD);
} catch (ProcessorException e) {
ExceptionHandler.process(e);
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.setPriority(Job.BUILD);
// start as soon as possible
job.schedule();
}
}
use of org.eclipse.core.runtime.IProgressMonitor in project tdi-studio-se by Talend.
the class NewProcessWizard method performFinish.
/**
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
@Override
public boolean performFinish() {
RepositoryWorkUnit<Object> workUnit = new RepositoryWorkUnit<Object>(this.getWindowTitle(), this) {
@Override
protected void run() throws LoginException, PersistenceException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRunnable operation = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
createProcessItem();
}
};
try {
workspace.run(operation, null);
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
};
workUnit.setAvoidUnloadResources(true);
repositoryFactory.executeRepositoryWorkUnit(workUnit);
return processItem != null;
}
use of org.eclipse.core.runtime.IProgressMonitor in project tdi-studio-se by Talend.
the class JavaProcessor method initCodePath.
public void initCodePath(IContext c) throws ProcessorException {
if (buildChildrenJobs != null) {
buildChildrenJobs.clear();
}
ITalendProcessJavaProject tProcessJavaProject = getTalendJavaProject();
IProgressMonitor monitor = new NullProgressMonitor();
IFolder srcFolder = null;
IFolder resourcesFolder = null;
IFolder outputFolder = null;
if (isTestJob) {
srcFolder = tProcessJavaProject.getTestSrcFolder();
resourcesFolder = tProcessJavaProject.getTestResourcesFolder();
outputFolder = tProcessJavaProject.getTestOutputFolder();
} else {
srcFolder = tProcessJavaProject.getSrcFolder();
resourcesFolder = tProcessJavaProject.getResourcesFolder();
outputFolder = tProcessJavaProject.getOutputFolder();
}
/*
* assume the job is "TestJob 0.1", project is "Test" .
*/
String jobClassPackageFolder = null;
String jobClassFilePath = null;
// only for "standard" job
if (isStandardJob()) {
Item item = property.getItem();
// test/testjob_0_1
jobClassPackageFolder = JavaResourcesHelper.getJobClassPackageFolder(item, isTestJob);
// test/testjob_0_1/TestJob.java
jobClassFilePath = JavaResourcesHelper.getJobClassFilePath(item, filenameFromLabel, isTestJob);
// test.testjob_0_1.TestJob
this.mainClass = JavaResourcesHelper.getJobPackagedClass(item, filenameFromLabel, isTestJob);
} else {
// for shadow process, or preview process
// test/shadowfileinputtodelimitedoutput_0_1, test/preview_data
jobClassPackageFolder = JavaResourcesHelper.getProjectFolderName(property) + JavaUtils.PATH_SEPARATOR + JavaResourcesHelper.getJobFolderName(process.getName(), process.getVersion());
// test/shadowfileinputtodelimitedoutput_0_1/ShadowFileInputToDelimitedOutput.java,
// test/preview_data/Preview_Data.java
jobClassFilePath = jobClassPackageFolder + JavaUtils.PATH_SEPARATOR + (filenameFromLabel ? JavaResourcesHelper.escapeFileName(process.getName()) : process.getId()) + JavaUtils.JAVA_EXTENSION;
// test.shadowfileinputtodelimitedoutput_0_1.ShadowFileInputToDelimitedOutput,
// test.preview_data.Preview_Data
this.mainClass = new Path(jobClassFilePath).removeFileExtension().toString().replace('/', '.');
}
// create job packages, src/main/java/test/testjob_0_1
// or test job packages, src/main/java/test/testjob_0_1/testjunitjob_0_1
tProcessJavaProject.createSubFolder(monitor, srcFolder, jobClassPackageFolder);
// src/main/java/test/testjob_0_1/TestJob.java
// or src/main/java/test/testjob_0_1/testjunitjob_0_1/TestjunitJob.java
this.codePath = srcFolder.getProjectRelativePath().append(jobClassFilePath);
// target/classes/test/testjob_0_1
// or target/test-classes/test/testjob_0_1/testjunitjob_0_1
IFolder jobClassFolder = outputFolder.getFolder(jobClassPackageFolder);
// TestJob
String jobName = new Path(jobClassFilePath).removeFileExtension().lastSegment();
// target/classes/test/testjob_0_1/TestJob
// or target/test-classes/test/testjob_0_1/testjunitjob_0_1/TestjunitJob
this.compiledCodePath = jobClassFolder.getProjectRelativePath().append(jobName);
if (isTestJob) {
// test/testjob_0_1/datas
IPath dataPath = new Path(jobClassPackageFolder).append(JavaUtils.JAVA_DATAS_DIRECTORY);
this.dataFilePath = resourcesFolder.getFolder(dataPath).getProjectRelativePath();
}
/*
* for context.
*/
// test/testjob_0_1/contexts
// or test/testjob_0_1/testjunitjob_0_1/contexts
IPath jobContextFolderPath = new Path(jobClassPackageFolder).append(JavaUtils.JAVA_CONTEXTS_DIRECTORY);
// src/main/resources/test/testjob_0_1/contexts
// or src/test/resources/test/testjob_0_1/testjunitjob_0_1/contexts
tProcessJavaProject.createSubFolder(monitor, resourcesFolder, jobContextFolderPath.toString());
// for example, Default
String contextFileName = JavaResourcesHelper.getJobContextFileName(c);
// test/testjob_0_1/contexts/Default.properties
// or test/testjob_0_1/testjunitjob_0_1/contexts/Default.properties
IPath jobContextPath = jobContextFolderPath.append(contextFileName);
// src/main/resources/test/testjob_0_1/contexts/Default.properties
// or src/test/resources/test/testjob_0_1/testjunitjob_0_1/contexts/Default.properties
this.contextPath = resourcesFolder.getFile(jobContextPath).getProjectRelativePath();
// target/classes/test/testjob_0_1/contexts/Default.properties
// or target/test-classes/test/testjob_0_1/testjunitjob_0_1/contexts/Default.properties
this.compiledContextPath = outputFolder.getFile(jobContextPath).getProjectRelativePath();
}
Aggregations