use of org.talend.commons.ui.swt.dialogs.EventLoopProgressMonitor 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.talend.commons.ui.swt.dialogs.EventLoopProgressMonitor in project tdi-studio-se by Talend.
the class JSONToXPathLinker method createLinks.
/**
* DOC amaumont Comment method "createLinks".
*/
public void createLinks() {
removeAllLinks();
getBackgroundRefresher().refreshBackground();
ProgressDialog progressDialog = new ProgressDialog(getTree().getShell(), 1000) {
private IProgressMonitor monitorWrap;
@Override
public void run(IProgressMonitor monitor) {
TableItem[] loopTableItems = loopTableEditorView.getTable().getItems();
TableItem[] fieldsTableItems = fieldsTableEditorView.getTable().getItems();
monitorWrap = new EventLoopProgressMonitor(monitor);
String taskName = "Loop links creation ...";
int totalWork = loopTableItems.length + fieldsTableItems.length;
monitorWrap.beginTask(taskName, totalWork);
List<JSONXPathLoopDescriptor> xpathLoopDescriptorList = loopTableEditorView.getModel().getBeansList();
for (int i = 0; i < loopTableItems.length; i++) {
if (monitorWrap.isCanceled()) {
return;
}
TableItem tableItem = loopTableItems[i];
JSONXPathLoopDescriptor xpathLoopDescriptor = xpathLoopDescriptorList.get(i);
String originalValue = xpathLoopDescriptor.getAbsoluteXPathQuery();
if (xpathLoopDescriptor.getConnection() != null) {
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(xpathLoopDescriptor.getConnection(), xpathLoopDescriptor.getConnection().getContextName());
if (contextType != null) {
originalValue = ConnectionContextHelper.getOriginalValue(contextType, xpathLoopDescriptor.getAbsoluteXPathQuery());
originalValue = TalendQuoteUtils.removeQuotes(originalValue);
}
}
if (originalValue != null) {
createLoopLinks(originalValue, tableItem, monitorWrap);
}
monitorWrap.worked(1);
}
List<SchemaTarget> schemaTargetList = fieldsTableEditorView.getModel().getBeansList();
createFieldsLinkWithProgressMonitor(monitorWrap, schemaTargetList.size() + loopTableItems.length, schemaTargetList, 0, fieldsTableItems.length);
monitorWrap.done();
}
};
try {
progressDialog.executeProcess();
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
// Nothing to do
}
}
use of org.talend.commons.ui.swt.dialogs.EventLoopProgressMonitor 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.talend.commons.ui.swt.dialogs.EventLoopProgressMonitor in project tdi-studio-se by Talend.
the class MultipleThreadDynamicComposite method updateRepositoryList.
public void updateRepositoryList() {
ProgressDialog progressDialog = new ProgressDialog(this.getShell(), 1000) {
private IProgressMonitor monitorWrap;
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitorWrap = new EventLoopProgressMonitor(monitor);
IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
List<IRepositoryViewObject> repositoryObjects = getAllRepositoryMetadata();
// + elem.getElementParameters().size();
int total = repositoryObjects.size();
//$NON-NLS-1$
monitorWrap.beginTask(Messages.getString("MultipleThreadDynamicComposite.gatherInformation"), total);
IElementParameter propertyParam = elem.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE, section);
String repositoryValue = null;
if (propertyParam != null) {
repositoryValue = propertyParam.getRepositoryValue();
}
if (repositoryObjects != null && (repositoryObjects.size() != 0)) {
tableIdAndDbTypeMap.clear();
tableIdAndDbSchemaMap.clear();
for (IRepositoryViewObject curObject : repositoryObjects) {
Item item = curObject.getProperty().getItem();
if (item instanceof ConnectionItem) {
ConnectionItem connectionItem = (ConnectionItem) item;
Connection connection = connectionItem.getConnection();
if (connection == null || connection.isReadOnly()) {
continue;
}
for (Object tableObj : ConnectionHelper.getTables(connection)) {
org.talend.core.model.metadata.builder.connection.MetadataTable table;
table = (org.talend.core.model.metadata.builder.connection.MetadataTable) tableObj;
if (factory.getStatus(connectionItem) != ERepositoryStatus.DELETED) {
if (!factory.isDeleted(table)) {
IMetadataTable newTable = ConvertionHelper.convert(table);
// newTable);
if (connection instanceof DatabaseConnection) {
String dbType = ((DatabaseConnection) connection).getDatabaseType();
String schema = ((DatabaseConnection) connection).getUiSchema();
tableIdAndDbTypeMap.put(newTable.getId(), dbType);
if (schema != null && !schema.equals("")) {
//$NON-NLS-1$
tableIdAndDbSchemaMap.put(newTable.getId(), schema);
}
}
}
}
}
monitorWrap.worked(1);
}
// hywang add for feature 6484
if (item instanceof FileItem) {
FileItem FileItem = (FileItem) item;
if (repositoryValue != null) {
if (repositoryValue.equals("RULE")) {
//$NON-NLS-1$
repositoryFileItemMap.put(FileItem.getProperty().getId(), FileItem);
}
}
monitorWrap.worked(1);
}
if (item instanceof LinkRulesItem) {
LinkRulesItem linkItem = (LinkRulesItem) item;
if (repositoryValue != null) {
if (repositoryValue.equals("RULE")) {
//$NON-NLS-1$
repositoryLinkRulesItemMap.put(linkItem.getProperty().getId(), linkItem);
}
}
monitorWrap.worked(1);
}
}
}
monitorWrap.done();
}
};
try {
progressDialog.executeProcess();
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
return;
} catch (Exception e) {
ExceptionHandler.process(e);
return;
}
}
use of org.talend.commons.ui.swt.dialogs.EventLoopProgressMonitor in project tdi-studio-se by Talend.
the class SchemaXMLLinker method createLinks.
/**
* amaumont Comment 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 = xmlViewer.getTree().getItem(0);
//
List<HL7TreeNode> mappableNodes = new ArrayList<HL7TreeNode>();
if (getManager().getHl7Component().isHL7Output()) {
if (getManager() instanceof HL7OutputManager) {
//$NON-NLS-1$
mappableNodes = ((HL7OutputManager) getManager()).getTreeData("");
createLoopLinks(mappableNodes);
xmlViewer.refresh();
getBackgroundRefresher().refreshBackground();
}
} else {
List<TreeItem> allItems = TreeUtils.collectAllItems(root);
monitorWrap = new EventLoopProgressMonitor(monitor);
//$NON-NLS-1$
String taskName = Messages.getString("XmlToXPathLinker.Loop");
int totalWork = allItems.size();
monitorWrap.beginTask(taskName, totalWork);
for (int i = 0; i < totalWork; i++) {
if (monitorWrap.isCanceled()) {
return;
}
TreeItem treeItem = allItems.get(i);
HL7TreeNode node = (HL7TreeNode) treeItem.getData();
if (node.getColumn() == null) {
continue;
}
// add now parameter for bug 9279
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) {
// Nothing to do
ExceptionHandler.process(e);
}
}
Aggregations