use of org.eclipse.core.runtime.IProgressMonitor in project tdi-studio-se by Talend.
the class ImportProjectAsWizard method performFinish.
/**
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
@Override
public boolean performFinish() {
if (getContainer().getCurrentPage().equals(manyProjectsPage)) {
isImportedSeveralProject = true;
return manyProjectsPage.createProjects();
} else {
isImportedSeveralProject = false;
name = mainPage.getName().trim().replace(' ', '_');
final String technicalName = mainPage.getTechnicalName();
final String sourcePath = mainPage.getSourcePath();
final boolean isArchive = mainPage.isArchive();
// see bug 4600, update the external lib path, make it possible to
// copy external jar files into tos
updateExternalLibPath();
final Shell shell = getShell();
ProgressDialog progressDialog = new ProgressDialog(shell) {
private IProgressMonitor monitorWrap;
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitorWrap = new EventLoopProgressMonitor(monitor);
try {
if (!isArchive) {
ImportProjectsUtilities.importProjectAs(shell, name, technicalName, sourcePath, monitorWrap);
} else {
// type.equalsIgnoreCase("archive")
ImportProjectsUtilities.importArchiveProjectAs(shell, name, technicalName, sourcePath, monitorWrap);
}
} catch (IOException e) {
throw new InvocationTargetException(e);
} catch (TarException e) {
throw new InvocationTargetException(e);
}
monitorWrap.done();
//$NON-NLS-1$
MessageDialog.openInformation(//$NON-NLS-1$
shell, //$NON-NLS-1$
Messages.getString("ImportProjectAction.messageDialogTitle.project"), //$NON-NLS-1$
Messages.getString("ImportProjectAction.messageDialogContent.projectImportedSuccessfully"));
}
};
try {
progressDialog.executeProcess();
} catch (InvocationTargetException e) {
MessageBoxExceptionHandler.process(e.getTargetException(), shell);
return false;
} catch (InterruptedException e) {
IProject[] projects = org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (IProject project : projects) {
if (project.getName().equalsIgnoreCase(name)) {
try {
project.delete(true, true, null);
} catch (CoreException ee) {
ExceptionHandler.process(ee);
}
}
}
return false;
}
return true;
}
}
use of org.eclipse.core.runtime.IProgressMonitor in project tdi-studio-se by Talend.
the class ErDiagramComposite method createErDiagram.
/**
* admin Comment method "createErDiagram".
*
* @return
*/
private ErDiagram createErDiagram(boolean isShowDesignerPage) {
erDiagram = new ErDiagram();
erDiagram.setErDiagramComposite(this);
if (isShowDesignerPage) {
IRunnableWithProgress progress = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
//$NON-NLS-1$
monitor.beginTask("", IProgressMonitor.UNKNOWN);
try {
List<MetadataColumn> selectedColumns = new ArrayList<MetadataColumn>();
List<MetadataTable> tables = EMFRepositoryNodeManager.getInstance().getTables(getNodes(), selectedColumns);
erDiagram.setMetadataTables(tables);
List<String[]> fks = EMFRepositoryNodeManager.getInstance().getPKFromTables(tables, erDiagram.getErDiagramComposite().getDialog().getSelectedContext());
for (MetadataTable metadataTable : tables) {
Table table = new Table();
table.setMetadataTable(metadataTable, selectedColumns);
table.setErDiagram(erDiagram);
erDiagram.addTable(table);
}
erDiagram.setRelations(fks);
} finally {
monitor.done();
}
}
};
UIUtils.runWithProgress(progress, true, dialog.getProgressMonitor(), dialog.getShell());
} else {
erDiagram.setMetadataTables(new ArrayList<MetadataTable>());
erDiagram.setRelations(new ArrayList<String[]>());
}
return erDiagram;
}
use of org.eclipse.core.runtime.IProgressMonitor in project tdi-studio-se by Talend.
the class CreateTableCommand method execute.
@Override
public void execute() {
for (MetadataTable metadataTable : metaTables) {
if (!tableNames.contains(metadataTable.getSourceName())) {
Table table = new Table();
table.setMetadataTable(metadataTable, null);
table.setErDiagram(erDiagram);
erDiagram.addTable(table);
erDiagram.getMetadataTables().add(metadataTable);
}
}
IRunnableWithProgress progress = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
//$NON-NLS-1$
monitor.beginTask("", IProgressMonitor.UNKNOWN);
try {
fks = EMFRepositoryNodeManager.getInstance().getPKFromTables(erDiagram.getMetadataTables(), erDiagram.getErDiagramComposite().getDialog().getSelectedContext());
} finally {
monitor.done();
}
}
};
ISQLBuilderDialog dialog = erDiagram.getErDiagramComposite().getDialog();
UIUtils.runWithProgress(progress, true, dialog.getProgressMonitor(), dialog.getShell());
erDiagram.setRelations(fks);
}
use of org.eclipse.core.runtime.IProgressMonitor in project tesb-studio-se by Talend.
the class WebServiceUIPresenter method refreshPageByWsdl.
@Override
public void refreshPageByWsdl(final String wsdlLocation) {
webServiceUI.setErrorMessage(null);
portTableModel.removeAll();
functionTableModel.removeAll();
IRunnableWithProgress retrieveData = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("Retrieve WSDL parameter from net.", IProgressMonitor.UNKNOWN);
try {
retrieveData(wsdlLocation);
} catch (Exception e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
}
};
try {
webServiceUI.runWithProgress(retrieveData);
if (currentSetting.hasRpcOperation()) {
webServiceUI.setErrorMessage(Messages.getString("WebServiceUI.NotSupportRpc"));
}
final List<String> ports = new ArrayList<String>(portFunctionsMap.keySet());
portTableModel.addAll(ports);
if (!ports.isEmpty()) {
functionTableModel.addAll(portFunctionsMap.get(ports.get(0)));
webServiceUI.selectFirstFunction();
}
} catch (InvocationTargetException e) {
webServiceUI.setErrorMessage("Error getting service description: " + e.getCause().getMessage());
webServiceUI.setPageComplete(false);
} catch (InterruptedException e) {
// ignore e.
}
}
use of org.eclipse.core.runtime.IProgressMonitor in project tesb-studio-se by Talend.
the class OpenWSDLPage method finish.
public boolean finish() {
// changed by hqzhang for TDI-19527, label=displayName
final String label = item.getProperty().getDisplayName();
item.getProperty().setLabel(label);
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
public void run(final IProgressMonitor monitor) throws CoreException {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
item.setConnection(ServicesFactory.eINSTANCE.createServiceConnection());
if (creation) {
item.getProperty().setId(factory.getNextId());
factory.create(item, getDestinationPath());
repositoryNode = new RepositoryNode(new RepositoryViewObject(item.getProperty()), repositoryNode.getParent(), ENodeType.REPOSITORY_ELEMENT);
}
((ServiceConnection) item.getConnection()).setWSDLPath(path);
((ServiceConnection) item.getConnection()).getServicePort().clear();
final IFile fileWsdl = WSDLUtils.getWsdlFile(item);
final InputStream is;
if (null == path) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// create new WSDL file from template
TemplateProcessor.processTemplate("DATA_SERVICE_WSDL", Collections.singletonMap("serviceName", (Object) label), baos, getClass().getResourceAsStream(TEMPLATE_SERVICE_WSDL));
is = new ByteArrayInputStream(baos.toByteArray());
} else {
//$NON-NLS-1$
String filenameTemplate = item.getProperty().getLabel() + '_' + item.getProperty().getVersion() + ".%d.wsdl";
Map<String, InputStream> wsdls = new WSDLLoader().load(path, filenameTemplate);
is = wsdls.remove(WSDLLoader.DEFAULT_FILENAME);
for (Map.Entry<String, InputStream> wsdl : wsdls.entrySet()) {
String filename = wsdl.getKey();
IFile importedWsdl = fileWsdl.getParent().getFile(new Path(filename));
if (!importedWsdl.exists()) {
importedWsdl.create(wsdl.getValue(), true, monitor);
} else {
importedWsdl.setContents(wsdl.getValue(), 0, monitor);
}
createReferenceResources(filename.substring(filename.lastIndexOf('.', filename.lastIndexOf('.') - 1) + 1));
}
}
// store WSDL in service
if (!fileWsdl.exists()) {
fileWsdl.create(is, true, monitor);
} else {
fileWsdl.setContents(is, 0, monitor);
}
// create reference to wsdl
//$NON-NLS-1$
createReferenceResources("wsdl");
// path
definition = WSDLUtils.getDefinition(fileWsdl);
populateModelFromWsdl(factory, definition, item, repositoryNode);
factory.save(item);
ProxyRepositoryFactory.getInstance().saveProject(ProjectManager.getInstance().getCurrentProject());
} catch (Exception e) {
//delete the node if any exception during the creation
if (creation) {
try {
factory.save(item);
factory.deleteObjectPhysical(repositoryNode.getObject());
} catch (PersistenceException e1) {
throw getCoreException("WDSL creation failed", e1);
}
}
//throw the exception
if (e instanceof CoreException) {
throw (CoreException) e;
}
if (e instanceof InvocationTargetException) {
throw getCoreException("WDSL creation failed", e.getCause());
}
throw getCoreException("WDSL creation failed", e);
}
}
};
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
// we use the workspace scheduling rule to lock all
ISchedulingRule schedulingRule = workspace.getRoot();
// workspace modifications during the run.
// the update of the project files need to be done in the workspace runnable to avoid all notification
// of changes before the end of the modifications.
workspace.run(runnable, schedulingRule, IWorkspace.AVOID_UPDATE, null);
} catch (CoreException e) {
MessageBoxExceptionHandler.process(e);
return false;
}
// open wsdl editor
OpenWSDLEditorAction action = new OpenWSDLEditorAction();
action.setServiceItem(item);
action.run();
// import schemas if required
if (checkImport.isVisible() && checkImport.getSelection() && null != definition) {
PublishMetadataRunnable publishMetadataRunnable = new PublishMetadataRunnable(definition, getShell());
try {
getContainer().run(true, true, publishMetadataRunnable);
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
String message = (null != cause.getMessage()) ? cause.getMessage() : cause.getClass().getName();
setErrorMessage("Populate schema to repository: " + message);
return false;
} catch (InterruptedException e) {
return false;
}
}
return true;
}
Aggregations