use of org.eclipse.jface.operation.IRunnableWithProgress in project tesb-studio-se by Talend.
the class SchemaTool method populateSchema.
private static IStatus populateSchema(Shell shell, IWizardContainer container, Definition definition) {
IRunnableWithProgress runnable;
try {
Class<? extends IRunnableWithProgress> forName = Class.forName("org.talend.repository.services.action.PublishMetadataRunnable").asSubclass(IRunnableWithProgress.class);
Constructor<? extends IRunnableWithProgress> constructor = forName.getConstructor(Definition.class, Shell.class);
runnable = constructor.newInstance(definition, shell);
} catch (Exception e) {
String message = (null != e.getMessage()) ? e.getMessage() : e.getClass().getName();
return WebServiceComponentPlugin.getStatus("Can't create populate action: " + message, e);
}
try {
container.run(true, true, runnable);
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
String message = (null != cause.getMessage()) ? cause.getMessage() : cause.getClass().getName();
return WebServiceComponentPlugin.getStatus("Populate schema to repository: " + message, e);
} catch (InterruptedException e) {
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
use of org.eclipse.jface.operation.IRunnableWithProgress in project tesb-studio-se by Talend.
the class ServiceExportWizard method performFinish.
@Override
public boolean performFinish() {
final String destinationValue = mainPage.getDestinationValue();
// TESB-7319: add confirm dialog
if (new File(destinationValue).exists()) {
boolean openQuestion = MessageDialog.openQuestion(getShell(), Messages.ServiceExportWizard_destinationExistTitle, Messages.ServiceExportWizard_destinationExistMessage);
if (!openQuestion) {
return false;
}
}
// END TESB-7319
Map<ExportChoice, Object> exportChoiceMap = mainPage.getExportChoiceMap();
try {
if (mainPage.isAddMavenScript()) {
ServiceExportWithMavenManager mavenManager = new ServiceExportWithMavenManager(exportChoiceMap, IContext.DEFAULT, JobScriptsManager.LAUNCHER_ALL, IProcessor.NO_STATISTICS, IProcessor.NO_TRACES);
IRunnableWithProgress action = new ExportServiceWithMavenAction(mavenManager, exportChoiceMap, serviceItem, destinationValue);
getContainer().run(false, true, action);
} else {
IRunnableWithProgress action = new ExportServiceAction(serviceItem, destinationValue, exportChoiceMap);
getContainer().run(true, true, action);
}
mainPage.finish();
} catch (InvocationTargetException e) {
MessageBoxExceptionHandler.process(e.getCause(), getShell());
return false;
} catch (InterruptedException e) {
return false;
}
return true;
}
use of org.eclipse.jface.operation.IRunnableWithProgress in project tdi-studio-se by Talend.
the class JobScriptsExportWizardPage method finish.
// protected String getDestinationValueSU() {
// return this.suDestinationFilePath != null ? this.suDestinationFilePath : ""; //$NON-NLS-1$
//
// }
/**
* The Finish button was pressed. Try to do the required work now and answer a boolean indicating success. If false
* is returned then the wizard will not close.
*
* @returns boolean
*/
@Override
public boolean finish() {
// TODO
if (treeViewer != null) {
treeViewer.removeCheckStateListener(checkStateListener);
}
saveWidgetValues();
if (manager == null) {
manager = createJobScriptsManager();
}
if (!ensureTargetIsValid()) {
return false;
}
if (ensureLog4jSettingIsValid()) {
MessageDialog dialog = new MessageDialog(getShell(), "Question", null, Messages.getString("Log4jSettingPage.IlleagalBuild"), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
dialog.open();
int result = dialog.getReturnCode();
if (result != MessageDialog.OK) {
return false;
}
}
JobExportType jobExportType = getCurrentExportType1();
if (JobExportType.POJO.equals(jobExportType)) {
IRunnableWithProgress worker = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
buildJobWithMaven(JobExportType.POJO, monitor);
}
};
try {
getContainer().run(false, true, worker);
} catch (InvocationTargetException e) {
MessageBoxExceptionHandler.process(e.getCause(), getShell());
return false;
} catch (InterruptedException e) {
return false;
}
} else {
List<ContextParameterType> contextEditableResultValuesList = null;
if (manager != null) {
contextEditableResultValuesList = manager.getContextEditableResultValuesList();
}
if (nodes.length == 1) {
RepositoryNode node = nodes[0];
if (node.getType() == ENodeType.SYSTEM_FOLDER) {
manager.setTopFolderName(ProjectManager.getInstance().getCurrentProject().getLabel());
} else {
manager.setTopFolderName(getDefaultFileNameWithType());
}
} else {
manager.setTopFolderName(getDefaultFileNameWithType());
}
// for feature:11976, recover back the old default manager value with ContextParameters
if (contextEditableResultValuesList == null) {
manager.setContextEditableResultValuesList(new ArrayList<ContextParameterType>());
} else {
manager.setContextEditableResultValuesList(contextEditableResultValuesList);
}
manager.setMultiNodes(isMultiNodes());
// achen modify to fix bug 0006222
IRunnableWithProgress worker = new JobExportAction(Arrays.asList(getCheckNodes()), getSelectedJobVersion(), manager, originalRootFolderName, getProcessType());
try {
getContainer().run(false, true, worker);
} catch (InvocationTargetException e) {
MessageBoxExceptionHandler.process(e.getCause(), getShell());
return false;
} catch (InterruptedException e) {
return false;
}
}
// see bug 7181
if (zipOption != null && zipOption.equals("true")) {
// unzip
try {
String zipFile;
if (manager != null) {
zipFile = manager.getDestinationPath();
} else {
zipFile = getDestinationValue();
int separatorIndex = zipFile.lastIndexOf(File.separator);
if (separatorIndex == -1) {
//$NON-NLS-1$
String userDir = System.getProperty("user.dir");
zipFile = userDir + File.separator + zipFile;
}
}
// Added by Marvin Wang on Feb.1, 2012 for bug TDI-18824
File file = new File(zipFile);
if (file.exists()) {
ZipToFile.unZipFile(zipFile, file.getParentFile().getAbsolutePath());
}
} catch (Exception e) {
MessageBoxExceptionHandler.process(e, getShell());
return false;
}
}
if (treeViewer != null) {
treeViewer.dispose();
}
// end
return true;
}
use of org.eclipse.jface.operation.IRunnableWithProgress 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.jface.operation.IRunnableWithProgress in project tdi-studio-se by Talend.
the class RepositoryWebService method addListenerForWSDLCom.
private void addListenerForWSDLCom() {
refreshbut.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell().getShell());
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor) {
//$NON-NLS-1$
monitor.beginTask("Retrieve WSDL parameter from net.", IProgressMonitor.UNKNOWN);
Display.getDefault().syncExec(new Runnable() {
public void run() {
getDataFromNet();
}
});
monitor.done();
}
};
try {
progressDialog.run(true, true, runnable);
} catch (InvocationTargetException e1) {
ExceptionHandler.process(e1);
} catch (InterruptedException e1) {
ExceptionHandler.process(e1);
} catch (WebServiceCancelException e1) {
return;
}
if (currentPortName != null) {
connection.setPortName(currentPortName.getPortName());
} else if (currentPortName == null && allPortNames != null) {
currentPortName = allPortNames.get(0);
connection.setPortName(currentPortName.getPortName());
}
listTable.setSelection(listTable.getItem(0));
if (currentFunction != null) {
connection.setMethodName(currentFunction.getName());
connection.setServerNameSpace(currentFunction.getServerNameSpace());
connection.setServerName(currentFunction.getServerName());
connection.setPortNameSpace(currentFunction.getServerNameSpace());
}
// listTable.select(0);
isFirst = false;
}
});
// TableItem firstItem = listTable.getItem(0);
// currentFunction = firstItem.getData();
listTable = listTableView.getTable();
portListTable = portListTableView.getTable();
listTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TableItem[] item = listTable.getSelection();
currentFunction = (Function) item[0].getData();
if (currentFunction != null) {
connection.setServerName(currentFunction.getServerName());
connection.setServerNameSpace(currentFunction.getServerNameSpace());
connection.setMethodName(currentFunction.getName());
}
// if select the same as before ,don't change it
// IElementParameter METHODPara = connector.getElementParameter("METHOD"); //$NON-NLS-1$
// Object obj = METHODPara.getValue();
// if (currentFunction.getName().equals(obj.toString())) {
// return;
// }
List<ParameterInfo> listIn = currentFunction.getInputParameters();
List<ParameterInfo> listOut = currentFunction.getOutputParameters();
}
});
portListTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TableItem[] item = portListTable.getSelection();
currentPortName = (PortNames) item[0].getData();
connection.setPortName(currentPortName.getPortName());
}
});
}
Aggregations