use of org.talend.repository.ui.dialog.OverTimePopupDialogTask in project tdi-studio-se by Talend.
the class LoginHelper method getProjects.
public Project[] getProjects(ConnectionBean connBean, ErrorManager errorManager) {
if (connBean == null) {
return null;
}
Project[] projects = null;
if (connBean != null) {
String user2 = connBean.getUser();
String repositoryId2 = connBean.getRepositoryId();
String workSpace = connBean.getWorkSpace();
String name = connBean.getName();
if (//$NON-NLS-1$ //$NON-NLS-2$
user2 != null && !"".equals(user2) && repositoryId2 != null && !"".equals(repositoryId2) && workSpace != null && !"".equals(workSpace) && name != null && !"".equals(name)) {
//$NON-NLS-1$ //$NON-NLS-2$
boolean valid = false;
if (isRemoteConnection(connBean)) {
String url = connBean.getDynamicFields().get(RepositoryConstants.REPOSITORY_URL);
//$NON-NLS-1$
valid = url != null && !"".equals(url);
} else {
valid = Pattern.matches(RepositoryConstants.MAIL_PATTERN, user2);
}
connBean.setComplete(valid);
}
}
ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
repositoryFactory.setRepositoryFactoryFromProvider(RepositoryFactoryProvider.getRepositoriyById(connBean.getRepositoryId()));
if (!connBean.isComplete()) {
return projects;
}
boolean initialized = false;
//$NON-NLS-1$
final String newLine = ":\n";
try {
try {
repositoryFactory.checkAvailability();
} catch (WarningException e) {
String warnings = e.getMessage();
if (warnings != null && !warnings.equals(lastWarnings)) {
lastWarnings = warnings;
if (errorManager != null) {
errorManager.setWarnMessage(warnings);
} else {
final Shell shell = new Shell(DisplayUtils.getDisplay(), SWT.ON_TOP | SWT.TOP);
//$NON-NLS-1$
MessageDialog.openWarning(shell, Messages.getString("LoginComposite.warningTitle"), warnings);
}
}
}
OverTimePopupDialogTask<Boolean> overTimePopupDialogTask = new OverTimePopupDialogTask<Boolean>() {
@Override
public Boolean run() throws Throwable {
ProxyRepositoryFactory.getInstance().initialize();
return null;
}
};
overTimePopupDialogTask.setNeedWaitingProgressJob(false);
overTimePopupDialogTask.runTask();
initialized = true;
} catch (Throwable e) {
projects = new Project[0];
if (errorManager != null) {
//$NON-NLS-1$
errorManager.setErrMessage(Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
} else {
final Shell shell = new Shell(DisplayUtils.getDisplay(), SWT.ON_TOP | SWT.TOP);
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
shell, //$NON-NLS-1$
Messages.getString("LoginComposite.warningTitle"), //$NON-NLS-1$
Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
}
}
if (initialized) {
try {
OverTimePopupDialogTask<Project[]> overTimePopupDialogTask = new OverTimePopupDialogTask<Project[]>() {
@Override
public Project[] run() throws Throwable {
return ProxyRepositoryFactory.getInstance().readProject();
}
};
overTimePopupDialogTask.setNeedWaitingProgressJob(false);
projects = overTimePopupDialogTask.runTask();
Arrays.sort(projects, new Comparator<Project>() {
@Override
public int compare(Project p1, Project p2) {
return p1.getLabel().compareTo(p2.getLabel());
}
});
} catch (PersistenceException e) {
projects = new Project[0];
if (errorManager != null) {
//$NON-NLS-1$
errorManager.setErrMessage(Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
} else {
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
getUsableShell(), //$NON-NLS-1$
Messages.getString("LoginComposite.errorTitle"), //$NON-NLS-1$
Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
}
} catch (BusinessException e) {
projects = new Project[0];
if (errorManager != null) {
//$NON-NLS-1$
errorManager.setErrMessage(Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
} else {
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
getUsableShell(), //$NON-NLS-1$
Messages.getString("LoginComposite.errorTitle"), //$NON-NLS-1$
Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
}
} catch (Throwable e) {
projects = new Project[0];
if (errorManager != null) {
//$NON-NLS-1$
errorManager.setErrMessage(Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
} else {
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
getUsableShell(), //$NON-NLS-1$
Messages.getString("LoginComposite.errorTitle"), //$NON-NLS-1$
Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
}
}
}
return projects;
}
use of org.talend.repository.ui.dialog.OverTimePopupDialogTask in project tdi-studio-se by Talend.
the class LoginProjectPage method validateUpdate.
protected void validateUpdate() throws JSONException {
final ConnectionBean currentBean = getConnection();
String repositoryId = null;
// at 1st time open the studio there are no bean at all,so need avoid NPE
if (currentBean != null) {
repositoryId = currentBean.getRepositoryId();
}
try {
if (currentBean != null && isSVNProviderPluginLoadedRemote() && isWorkSpaceSame()) {
if (afterUpdate) {
refreshProjectOperationAreaEnable(false);
//$NON-NLS-1$
errorManager.setErrMessage(Messages.getString("LoginProjectPage.archivaFinish"));
changeFinishButtonAction(FINISH_ACTION_RESTART);
} else {
OverTimePopupDialogTask<Boolean> overTimePopupDialogTask = new OverTimePopupDialogTask<Boolean>() {
@Override
public Boolean run() throws Throwable {
return LoginHelper.isStudioNeedUpdate(currentBean);
}
};
overTimePopupDialogTask.setNeedWaitingProgressJob(false);
boolean needUpdate = overTimePopupDialogTask.runTask();
if (needUpdate && isWorkSpaceSame()) {
refreshProjectOperationAreaEnable(false);
//$NON-NLS-1$
errorManager.setErrMessage(Messages.getString("LoginProjectPage.updateArchiva"));
changeFinishButtonAction(FINISH_ACTION_UPDATE);
}
}
}
} catch (PersistenceException e) {
CommonExceptionHandler.process(e);
} catch (SystemException e) {
updateArchivaErrorButton();
} catch (Throwable e) {
CommonExceptionHandler.process(e);
}
}
Aggregations