use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project tdi-studio-se by Talend.
the class ImportItemWizardPage method populateItems.
/**
* DOC hcw Comment method "populateItems".
*/
private void populateItems() {
selectedItems.clear();
final Collection<ItemRecord> items = new ArrayList<ItemRecord>();
IRunnableWithProgress op = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
repositoryUtil.clearAllData();
items.addAll(totalItemRecords = repositoryUtil.populateItems(manager, overwrite, monitor));
}
};
try {
new ProgressMonitorDialog(getShell()).run(true, true, op);
} catch (Exception e) {
// ignore me
}
errors.clear();
for (ItemRecord itemRecord : items) {
// bug 21738
if (itemRecord.getExistingItemWithSameId() != null && itemRecord.getExistingItemWithSameId() instanceof RepositoryViewObject) {
RepositoryViewObject reObject = (RepositoryViewObject) itemRecord.getExistingItemWithSameId();
if (itemRecord.getProperty() != null && reObject != null) {
if (itemRecord.getProperty().getId().equals(reObject.getId()) && itemRecord.getProperty().getLabel().equals(reObject.getLabel()) && itemRecord.getProperty().getVersion().equals(reObject.getVersion())) {
for (String error : itemRecord.getErrors()) {
//$NON-NLS-1$ //$NON-NLS-2$
errors.add("'" + itemRecord.getItemName() + "' " + error);
}
} else if (itemRecord.getProperty().getId().equals(reObject.getId()) && itemRecord.getProperty().getLabel().equals(reObject.getLabel()) && !itemRecord.getProperty().getVersion().equals(reObject.getVersion())) {
for (String error : itemRecord.getErrors()) {
//$NON-NLS-1$ //$NON-NLS-2$
errors.add("'" + itemRecord.getItemName() + "' " + Messages.getString("ImportItemWizardPage.ErrorsMessage", reObject.getVersion()));
}
} else {
// TDI-21399,TDI-21401
// if item is locked, cannot overwrite
ERepositoryStatus status = reObject.getRepositoryStatus();
if (status == ERepositoryStatus.LOCK_BY_OTHER || status == ERepositoryStatus.LOCK_BY_USER) {
for (String error : itemRecord.getErrors()) {
//$NON-NLS-1$ //$NON-NLS-2$
errors.add("'" + itemRecord.getItemName() + "' " + error);
}
}
}
}
} else {
if (itemRecord.getProperty() != null) {
Item item = itemRecord.getProperty().getItem();
if (item != null && (item instanceof JobDocumentationItem || item instanceof JobletDocumentationItem)) {
continue;
}
for (String error : itemRecord.getErrors()) {
//$NON-NLS-1$ //$NON-NLS-2$
errors.add("'" + itemRecord.getItemName() + "' " + error);
}
}
}
}
if (errorsList != null) {
errorsList.refresh();
}
selectedItems.addAll(items);
checkTreeViewer.refresh(true);
checkTreeViewer.expandAll();
filteredCheckboxTree.resetCheckedElements();
checkValidItems();
updateFinishStatus();
// see feature 0004170: Unselect all items to import
// itemsList.setCheckedElements(checkValidItems());
}
use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project tdi-studio-se by Talend.
the class CustomComponentSettingPage method performApply.
@Override
protected void performApply() {
final IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("Save custom component setting", (sharedAdded.size() + backAdded.size()) * 100);
finish(monitor);
}
};
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
try {
if (!sharedAdded.isEmpty() || !backAdded.isEmpty()) {
dialog.run(true, false, runnable);
}
init();
sharedAdded.clear();
backAdded.clear();
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
ExceptionHandler.process(e);
}
}
use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project bndtools by bndtools.
the class GitHubRepoDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
setTitle(title);
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
container.setLayout(new GridLayout(2, false));
Label lblRepo = new Label(container, SWT.NONE);
lblRepo.setText("Repository Name:");
txtRepository = new Text(container, SWT.BORDER);
txtRepository.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
txtRepository.setMessage("username/repository");
if (repository != null)
txtRepository.setText(repository);
new Label(container, SWT.NONE).setText("Branch:");
txtBranch = new Text(container, SWT.BORDER);
txtBranch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
txtBranch.setMessage("default branch");
if (branch != null)
txtBranch.setText(branch);
ControlDecoration branchDecor = new ControlDecoration(txtBranch, SWT.LEFT, container);
branchDecor.setDescriptionText("Specify the branch, tag or commit ID you would like to clone from the\nrepository. We use the default branch specified in GitHub settings.");
branchDecor.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
branchDecor.setShowHover(true);
final Button btnValidate = new Button(container, SWT.PUSH);
btnValidate.setText("Validate");
btnValidate.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 2, 1));
ModifyListener modifyListener = new ModifyListener() {
@Override
public void modifyText(ModifyEvent ev) {
if (!txtRepository.getText().trim().equals(repository)) {
isValidated = false;
repository = txtRepository.getText().trim();
}
branch = txtBranch.getText().trim();
updateButtons();
}
};
txtRepository.addModifyListener(modifyListener);
txtBranch.addModifyListener(modifyListener);
btnValidate.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setMessage(null, IMessageProvider.INFORMATION);
try {
if (repository == null || repository.isEmpty())
throw new GitHubValidationException("No repository name specified");
if (repository.contains(":/"))
throw new GitHubValidationException("Specify GitHub repositories as username/repository");
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
final GithubRepoDetailsDTO dto = new GitHub(cache, executor).loadRepoDetails(repository).getValue();
final URI cloneUri = URI.create(dto.clone_url);
btnValidate.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
setMessage(String.format("Validated! Clone URL is '%s'. Default branch 'origin/%s'", cloneUri, dto.default_branch), IMessageProvider.INFORMATION);
isValidated = true;
updateButtons();
}
});
} catch (InvocationTargetException e) {
throw e;
} catch (Exception e) {
throw new InvocationTargetException(e);
}
}
};
ProgressRunner.execute(false, runnable, new ProgressMonitorDialog(getParentShell()), btnValidate.getDisplay());
setErrorMessage(null);
} catch (InvocationTargetException ex) {
Throwable t = ex.getCause();
if (t instanceof FileNotFoundException)
setErrorMessage("Could not find the requested repository");
else
setErrorMessage(t.getClass().getSimpleName() + ": " + t.getMessage());
} catch (GitHubValidationException ex) {
setErrorMessage(ex.getMessage());
} catch (Exception ex) {
setErrorMessage(ex.getClass().getSimpleName() + ": " + ex.getMessage());
}
}
});
return area;
}
Aggregations