use of org.talend.commons.ui.swt.dialogs.ProgressDialog 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.ProgressDialog 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.ProgressDialog 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.ProgressDialog in project tdi-studio-se by Talend.
the class ExtractDocumentationAction method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
protected void doRun() {
RepositoryNode node = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
final Item item = node.getObject().getProperty().getItem();
if (item == null) {
return;
}
String initialFileName = null;
String initialExtension = null;
if (item instanceof DocumentationItem) {
DocumentationItem documentationItem = (DocumentationItem) item;
initialFileName = documentationItem.getName();
if (documentationItem.getExtension() != null) {
initialExtension = documentationItem.getExtension();
}
} else if (item instanceof LinkDocumentationItem) {
// link documenation
LinkDocumentationItem linkDocItem = (LinkDocumentationItem) item;
if (!LinkUtils.validateLink(linkDocItem.getLink())) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.getString(//$NON-NLS-1$
"ExtractDocumentationAction.fileErrorTitle"), //$NON-NLS-1$
Messages.getString("ExtractDocumentationAction.fileErrorMessages"));
return;
}
initialFileName = linkDocItem.getName();
if (linkDocItem.getExtension() != null) {
initialExtension = linkDocItem.getExtension();
}
}
if (initialFileName != null) {
FileDialog fileDlg = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
if (initialExtension != null) {
//$NON-NLS-1$
initialFileName = initialFileName + LinkUtils.DOT + initialExtension;
//$NON-NLS-1$ //$NON-NLS-2$
fileDlg.setFilterExtensions(new String[] { "*." + initialExtension, "*.*" });
}
fileDlg.setFileName(initialFileName);
String filename = fileDlg.open();
if (filename != null) {
final File file = new File(filename);
ProgressDialog progressDialog = new ProgressDialog(Display.getCurrent().getActiveShell()) {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
if (item instanceof DocumentationItem) {
DocumentationItem documentationItem = (DocumentationItem) item;
documentationItem.getContent().setInnerContentToFile(file);
} else if (item instanceof LinkDocumentationItem) {
// link documenation
LinkDocumentationItem linkDocItem = (LinkDocumentationItem) item;
ByteArray byteArray = LinkDocumentationHelper.getLinkItemContent(linkDocItem);
if (byteArray != null) {
byteArray.setInnerContentToFile(file);
}
}
} catch (IOException ioe) {
MessageBoxExceptionHandler.process(ioe);
}
}
};
try {
progressDialog.executeProcess();
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
// Nothing to do
}
}
}
}
use of org.talend.commons.ui.swt.dialogs.ProgressDialog 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;
}
}
Aggregations