use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project tdi-studio-se by Talend.
the class ImportExchangeDialog method okPressed.
@Override
protected void okPressed() {
//$NON-NLS-1$ //$NON-NLS-2$
IPath tempPath = new Path(System.getProperty("user.dir")).append("temp");
File pathFile = tempPath.toFile();
if (downloadproperty.getFileName() == null || downloadproperty.getFileName() == null) {
MessageBox box = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_WARNING | SWT.OK);
//$NON-NLS-1$
box.setText(Messages.getString("ImportExchangeDialog.WARNING"));
//$NON-NLS-1$
box.setMessage(Messages.getString("ImportExchangeDialog.NOTSELECTWARNING"));
box.open();
return;
}
tempFile = new File(pathFile, downloadproperty.getFileName());
try {
url = new URL(downloadproperty.getDownloadUrl());
} catch (MalformedURLException e1) {
ExceptionHandler.process(e1);
}
if (!pathFile.exists()) {
pathFile.mkdirs();
}
ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell().getShell());
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) {
//$NON-NLS-1$
monitor.beginTask(Messages.getString("ImportExchangeDialog.downloadProgressBar"), IProgressMonitor.UNKNOWN);
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
try {
new DownloadHelper().download(url, tempFile);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
});
monitor.done();
}
};
try {
progressDialog.run(true, true, runnable);
} catch (InvocationTargetException e1) {
ExceptionHandler.process(e1);
} catch (InterruptedException e1) {
ExceptionHandler.process(e1);
}
selectFile = tempFile.toString();
super.okPressed();
}
use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project tdi-studio-se by Talend.
the class ImportCompatibleEcoComponentsComposite method findChoiceExchange.
/**
*
* This is a progressBar.when this progressBar run it will download some jobs/templates/routines from net.
*/
public void findChoiceExchange() {
ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell().getShell());
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) {
monitor.beginTask(progressBarMessage, IProgressMonitor.UNKNOWN);
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
compatible = ComponentSearcher.getImportComponentExtensions(version, ExchangeUtils.getCurrentLanguage(), categoryCombo.getSelectionIndex() >= 0 ? fCategorys.get(categoryCombo.getSelectionIndex()).getCategoryId() : "");
updateTable(compatible);
}
});
monitor.done();
if (monitor.isCanceled()) {
try {
//$NON-NLS-1$
throw new InterruptedException(Messages.getString("ImportExchangeDialog.OPERATION_CANCELLED"));
} 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.dialogs.ProgressMonitorDialog in project tdi-studio-se by Talend.
the class GuessSchemaController method runShadowProcessForPerl.
private void runShadowProcessForPerl() {
final ProgressMonitorDialog pmd = new ProgressMonitorDialog(this.composite.getShell());
try {
pmd.run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
if (columns != null) {
columns.clear();
}
//$NON-NLS-1$
monitor.beginTask(Messages.getString("GuessSchemaController.waitOpenDatabase"), IProgressMonitor.UNKNOWN);
if (connParameters == null) {
initConnectionParameters();
}
ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
DatabaseConnection connt = service.createConnection(connParameters);
IMetadataConnection iMetadataConnection = null;
boolean isStatus = false;
ExtractMetaDataUtils extractMeta = ExtractMetaDataUtils.getInstance();
if (connt != null) {
iMetadataConnection = ConvertionHelper.convert(connt);
isStatus = checkConnection(iMetadataConnection);
}
if (!monitor.isCanceled()) {
try {
if (isStatus) {
extractMeta.getConnection(iMetadataConnection.getDbType(), iMetadataConnection.getUrl(), iMetadataConnection.getUsername(), iMetadataConnection.getPassword(), iMetadataConnection.getDatabase(), iMetadataConnection.getSchema(), iMetadataConnection.getDriverClass(), iMetadataConnection.getDriverJarPath(), iMetadataConnection.getDbVersionString(), iMetadataConnection.getAdditionalParams());
if (extractMeta.getConn() != null) {
Statement smst = extractMeta.getConn().createStatement();
extractMeta.setQueryStatementTimeout(smst);
ResultSet rs = smst.executeQuery(memoSQL);
ResultSetMetaData rsmd = rs.getMetaData();
int numbOfColumn = rsmd.getColumnCount();
int count = 0;
List<String[]> cvsArrays = new ArrayList<String[]>();
while (rs.next() && count < 50) {
String[] dataOneRow = new String[numbOfColumn];
for (int i = 1; i <= numbOfColumn; i++) {
String tempStr = rs.getString(i);
dataOneRow[i - 1] = tempStr;
}
cvsArrays.add(dataOneRow);
count++;
}
refreshMetaDataTable(rsmd, cvsArrays);
extractMeta.closeConnection();
}
} else {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
//$NON-NLS-1$
String pid = "org.talend.sqlbuilder";
//$NON-NLS-1$
String mainMsg = "Database connection is failed. ";
ErrorDialogWithDetailAreaAndContinueButton dialog = new ErrorDialogWithDetailAreaAndContinueButton(composite.getShell(), pid, mainMsg, connParameters.getConnectionComment());
if (dialog.getCodeOfButton() == Window.OK) {
openParamemerDialog(composite.getShell(), part.getProcess().getContextManager());
}
}
});
}
} catch (Exception e) {
extractMeta.closeConnection();
ExceptionHandler.process(e);
final String strExcepton = "Connect to DB error ,or some errors in SQL query string, or 'Guess Schema' not compatible with current SQL query string." + System.getProperty("line.separator");
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openWarning(composite.getShell(), Messages.getString("GuessSchemaController.connError"), //$NON-NLS-1$
strExcepton);
}
});
}
}
}
});
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project tdi-studio-se by Talend.
the class I18nPreferencePage method runProgressMonitorDialog.
/**
*
* DOC wzhang Comment method "runProgressMonitorDialog".
*
* @param validated
*/
public void runProgressMonitorDialog(final String zipFileName) {
updateCompleted = false;
ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(getFieldEditorParent().getShell());
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) {
try {
//$NON-NLS-1$
monitor.beginTask(Messages.getString("I18nPreferencePage.wait_process"), IProgressMonitor.UNKNOWN);
applyBabiliResource(zipFileName);
} catch (Exception e1) {
ExceptionHandler.process(e1);
} finally {
monitor.done();
}
}
};
try {
progressDialog.run(true, true, runnable);
} catch (InvocationTargetException e1) {
ExceptionHandler.process(e1);
} catch (InterruptedException e1) {
ExceptionHandler.process(e1);
}
if (updateCompleted) {
} else {
}
}
use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project tdi-studio-se by Talend.
the class UpdateManagerUtils method doExecuteUpdates.
private static boolean doExecuteUpdates(final List<UpdateResult> results, final boolean updateAllJobs) {
if (results == null || results.isEmpty()) {
return false;
}
try {
IWorkspaceRunnable op = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
monitor.setCanceled(false);
int size = (results.size() * 2 + 1) * UpdatesConstants.SCALE;
//$NON-NLS-1$
monitor.beginTask(Messages.getString("UpdateManagerUtils.Update"), size);
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
// first list by job we need to update
Map<String, Set<String>> jobIdToVersion = new HashMap<String, Set<String>>();
Map<String, Boolean> jobIdClosed = new HashMap<String, Boolean>();
for (UpdateResult result : results) {
// if (!result.isChecked()) {
// continue;
// }
String id = result.getObjectId();
String version = result.getObjectVersion();
if (id == null) {
if (result.getJob() != null && result.getJob() instanceof IProcess) {
IProcess process = (IProcess) result.getJob();
if (process instanceof IProcess2 && ERepositoryStatus.LOCK_BY_OTHER.equals(factory.getStatus(((IProcess2) process).getProperty().getItem()))) {
// file.
continue;
}
id = process.getId();
version = process.getVersion();
result.setObjectId(id);
result.setObjectVersion(version);
} else {
continue;
}
}
Set<String> versionList;
if (!jobIdToVersion.containsKey(id)) {
versionList = new HashSet<String>();
jobIdToVersion.put(id, versionList);
} else {
versionList = jobIdToVersion.get(id);
}
versionList.add(version);
//$NON-NLS-1$
jobIdClosed.put(id + " - " + version, result.isFromItem());
}
// now will execute updates only for the job selected depends this list.
for (String currentId : jobIdToVersion.keySet()) {
for (String version : jobIdToVersion.get(currentId)) {
IRepositoryViewObject currentObj = null;
//$NON-NLS-1$
boolean closedItem = jobIdClosed.get(currentId + " - " + version);
IProcess process = null;
Item item = null;
if (closedItem) {
// if item is closed, then just load it.
boolean checkOnlyLastVersion = Boolean.parseBoolean(DesignerPlugin.getDefault().getPreferenceStore().getString(//$NON-NLS-1$
"checkOnlyLastVersion"));
try {
if (checkOnlyLastVersion || version == null) {
currentObj = factory.getLastVersion(currentId);
} else {
List<IRepositoryViewObject> allVersion = factory.getAllVersion(currentId);
for (IRepositoryViewObject obj : allVersion) {
if (obj.getVersion().equals(version)) {
currentObj = obj;
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (currentObj == null) {
// item not found, don't do anything
continue;
}
item = currentObj.getProperty().getItem();
IDesignerCoreService designerCoreService = CorePlugin.getDefault().getDesignerCoreService();
if (item instanceof ProcessItem) {
process = designerCoreService.getProcessFromProcessItem((ProcessItem) item);
} else if (item instanceof JobletProcessItem) {
process = designerCoreService.getProcessFromJobletProcessItem((JobletProcessItem) item);
}
}
for (UpdateResult result : results) {
// }
if (!StringUtils.equals(currentId, result.getObjectId())) {
// not the current job we need to update
continue;
}
if (closedItem) {
if (result.getJob() == null) {
result.setJob(process);
} else {
process = (IProcess) result.getJob();
}
IUpdateItemType jobletContextType = UpdateManagerProviderDetector.INSTANCE.getUpdateItemType(UpdateManagerHelper.TYPE_JOBLET_CONTEXT);
if (process != null && jobletContextType != null && (jobletContextType.equals(result.getUpdateType()))) {
if ((result.getParameter() instanceof List) && process.getContextManager() != null) {
process.getContextManager().setListContext((List<IContext>) result.getParameter());
}
}
}
// execute
executeUpdate(result, monitor, updateAllJobs);
if (closedItem) {
result.setJob(null);
}
}
boolean isTestContainer = false;
ITestContainerProviderService testContainerService = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
if (testContainerService != null) {
isTestContainer = testContainerService.isTestContainerItem(item);
}
}
if (closedItem && process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
ProcessType processType;
try {
processType = process2.saveXmlFile(false);
if (isTestContainer) {
testContainerService.setTestContainerProcess(processType, item);
} else if (item instanceof JobletProcessItem) {
((JobletProcessItem) item).setJobletProcess((JobletProcess) processType);
} else {
((ProcessItem) item).setProcess(processType);
}
factory.save(item);
} catch (IOException e) {
ExceptionHandler.process(e);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
if (closedItem && !ERepositoryStatus.LOCK_BY_USER.equals(factory.getStatus(item))) {
// unload item from memory, but only if this one is not locked by current user.
try {
factory.unloadResources(item.getProperty());
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
}
UpdateManagerProviderDetector.INSTANCE.postUpdate(results);
// update joblet reference
upadateJobletReferenceInfor();
final List<UpdateResult> tempResults = new ArrayList<UpdateResult>(results);
// refresh
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
refreshRelatedViewers(tempResults);
// hyWang add method checkandRefreshProcess for bug7248
checkandRefreshProcess(tempResults);
}
});
monitor.worked(1 * UpdatesConstants.SCALE);
monitor.done();
}
};
IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
ISchedulingRule schedulingRule = workspace.getRoot();
workspace.run(op, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
}
};
try {
new ProgressMonitorDialog(null).run(false, false, iRunnableWithProgress);
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
}
return !results.isEmpty();
} finally {
results.clear();
}
}
Aggregations