use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class LoginDialog method createDialogArea.
/**
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(final Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
container.setLayout(layout);
// container.setBackground(new Color(null, 215, 215, 215));
container.setBackground(new Color(null, 255, 255, 255));
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
new ImageCanvas(container, brandingService.getLoginVImage());
if (!perReader.isHaveUserPer()) {
perReader.createPropertyFile();
}
base = new Composite(container, SWT.NONE);
base.setLayoutData(new GridData(GridData.FILL_BOTH));
stackLayout = new StackLayout();
base.setLayout(stackLayout);
if (!PluginChecker.isSVNProviderPluginLoaded()) {
// tos
loginComposite = new LoginComposite(base, SWT.NONE, this, tosLoginComposite, stackLayout);
loginComposite.populateProjectList();
tosLoginComposite = new TOSLoginComposite(base, SWT.NONE, loginComposite, this);
} else {
loginComposite = new LoginComposite(base, SWT.NONE, this, tosLoginComposite, stackLayout);
}
GridData data = new GridData(GridData.FILL_BOTH);
// data.widthHint = INNER_LOGIN_COMPOSITE_WIDTH;
// data.heightHint = DIALOG_HEIGHT;
loginComposite.setLayoutData(data);
stackLayout.topControl = loginComposite;
base.layout();
if (!PluginChecker.isSVNProviderPluginLoaded()) {
Project[] projectList = readProject();
if (projectList.length > 0) {
advanced();
}
}
return container;
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class LoginDialog method advanced.
public void advanced() {
stackLayout.topControl = tosLoginComposite;
base.layout();
Project[] projectCollection = tosLoginComposite.readProject();
Map<String, String> convertorMapper = tosLoginComposite.getConvertorMapper();
for (Project element : projectCollection) {
tosLoginComposite.getProjectMap().put(element.getLabel().toUpperCase(), element);
convertorMapper.put(element.getLabel().toUpperCase(), element.getLabel());
}
ListViewer projectListViewer = tosLoginComposite.getProjectListViewer();
projectListViewer.setInput(new ArrayList(convertorMapper.values()));
try {
tosLoginComposite.setStatusArea();
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (projectListViewer.getList().getItemCount() > 0) {
projectListViewer.getList().select(0);
tosLoginComposite.enableOpenAndDelete(true);
}
}
use of org.talend.core.model.general.Project 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.core.model.general.Project in project tdi-studio-se by Talend.
the class LoginProjectPage method refreshLicenseIfNeeded.
/**
*
* @return if false: user cancel login
*/
private boolean refreshLicenseIfNeeded() {
ConnectionBean conn = loginHelper.getCurrentSelectedConnBean();
Project proj = getProject();
if (LoginHelper.isRemoteConnection(conn)) {
String url = getAdminURL();
String projLabel = proj.getLabel();
String userId = conn.getUser();
try {
String key = loginHelper.getLicenseMapKey(url, projLabel, userId);
String license = loginHelper.getLicense(key);
if (license == null || license.isEmpty()) {
Job fetchJob = fetchLicenseJobMap.get(proj);
if (fetchJob == null || fetchJob.getResult() != null) {
// if result is not null, means fetchJob has already finished but no license fetched
fetchJob = fetchLicense(proj);
}
final Job fJob = fetchJob;
if (fJob != null) {
final AtomicBoolean isInterupted = new AtomicBoolean(false);
ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
dialog.run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.setTaskName(fJob.getName());
while (true) {
if (monitor.isCanceled()) {
/**
* If network is slow, maybe just wait the fetch job finish, but still can click
* the Refresh button to cancel all fetch jobs
*/
// fJob.cancel();
isInterupted.set(true);
break;
}
IStatus result = fJob.getResult();
if (result != null) {
break;
}
try {
Thread.sleep(250);
} catch (Exception e) {
// nothing to do
}
}
}
});
if (isInterupted.get()) {
return false;
}
}
license = loginHelper.getLicense(key);
}
if (license == null || license.isEmpty()) {
//$NON-NLS-1$
throw new Exception(Messages.getString("LoginProjectPage.fetchLicense.error.failed"));
}
// will do save in CoreTisService if needed
// ICoreTisService tisService = (ICoreTisService) GlobalServiceRegister.getDefault()
// .getService(ICoreTisService.class);
// File remoteLicense = tisService.getRemoteLicenseFile();
// tisService.storeLicenseFile(remoteLicense, license);
} catch (Exception e) {
//$NON-NLS-1$
ExceptionMessageDialog.openError(//$NON-NLS-1$
getShell(), //$NON-NLS-1$
Messages.getString("LoginProjectPage.fetchLicense.error.title"), Messages.getString("LoginProjectPage.fetchLicense.error.msg"), //$NON-NLS-1$
e);
return false;
}
}
return true;
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class LoginFirstTimeStartupActionPage method importExistingProject.
protected void importExistingProject() {
ImportProjectAsAction.getInstance().run();
if (ImportProjectAsAction.getInstance().isImportedSeveralProjects()) {
try {
gotoNextPage();
} catch (Throwable e) {
CommonExceptionHandler.process(e);
}
return;
}
String importedExistingProjectName = ImportProjectAsAction.getInstance().getProjectName();
if (importedExistingProjectName == null || importedExistingProjectName.isEmpty()) {
return;
}
Project selectedProject = loginHelper.getProjectByName(loginHelper.getProjects(defaultConnectionBean), importedExistingProjectName);
openProject(selectedProject);
}
Aggregations