use of org.talend.core.context.RepositoryContext in project tdi-studio-se by Talend.
the class CreateSandboxProjectDialog method okPressed.
@Override
protected void okPressed() {
// boolean confirm = MessageDialog.openConfirm(getShell(), Messages.getString("CreateSandboxProjectDialog.ConfirmTitle"), //$NON-NLS-1$
// Messages.getString("CreateSandboxProjectDialog.ConfirmMessages")); //$NON-NLS-1$
// if (!confirm) {
// super.okPressed();
// return;
// }
//
final String url = urlText.getText();
final String projectName = projectLabelText.getText();
final String projectLanguage = languageCombo.getText();
final String projectAuthor = userLoginText.getText();
final String projectAuthorPass = userPassText.getText();
final String projectAuthorFirstname = userFirstNameText.getText();
final String projectAuthorLastname = userLastNameText.getText();
// final boolean needCreateNewConn = !existedBeforeConn() || !url.trim().equals(getExistedBeforeConnURL());
bean = new ConnectionBean();
bean.setRepositoryId(RepositoryConstants.REPOSITORY_REMOTE_ID);
bean.setUser(projectAuthor);
bean.setPassword(projectAuthorPass);
bean.setName(generateConnectionName(projectAuthor));
bean.setDescription(bean.getName());
bean.setWorkSpace(new Path(Platform.getInstanceLocation().getURL().getPath()).toFile().getPath());
bean.getDynamicFields().put(RepositoryConstants.REPOSITORY_URL, url);
bean.setComplete(true);
// set context for url and in order to create project later.
RepositoryContext repositoryContext = new RepositoryContext();
// if (existedBeforeConn()) {
// Context ctx = CorePlugin.getContext();
// RepositoryContext oldContext = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
// repositoryContext.setUser(oldContext.getUser());
// repositoryContext.setClearPassword(oldContext.getClearPassword());
// } else {
User user = ProjectHelper.createUser(projectAuthor, projectAuthorPass, projectAuthorFirstname, projectAuthorLastname, false);
repositoryContext.setUser(user);
repositoryContext.setClearPassword(projectAuthorPass);
// }
repositoryContext.setFields(bean.getDynamicFields());
Context ctx = CorePlugin.getContext();
ctx.putProperty(Context.REPOSITORY_CONTEXT_KEY, repositoryContext);
// set provider
// if (!existedBeforeConn()) { // no connection
ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
repositoryFactory.setRepositoryFactoryFromProvider(RepositoryFactoryProvider.getRepositoriyById(bean.getRepositoryId()));
// }
//
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
Display disp = Display.getCurrent();
if (disp == null) {
disp = Display.getDefault();
}
disp.syncExec(new Runnable() {
@Override
public void run() {
//$NON-NLS-1$
monitor.beginTask("Creating...", IProgressMonitor.UNKNOWN);
Project projectInfor = ProjectHelper.createProject(projectName, projectName, projectLanguage, projectAuthor, projectAuthorPass, projectAuthorFirstname, projectAuthorLastname, false);
projectInfor.setSandboxProject(true);
boolean ok = false;
try {
User authUser = originRepCtx.getUser();
String authPassword = originRepCtx.getClearPassword();
Project createProject = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().createProject(authUser, authPassword, projectInfor);
ok = (createProject != null);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
getShell(), //$NON-NLS-1$
Messages.getString("CreateSandboxProjectDialog.Failure"), //$NON-NLS-1$
Messages.getString("CreateSandboxProjectDialog.failureMessage") + "\n\n" + //$NON-NLS-1$
e.getMessage());
}
if (ok) {
// if not created, will don't close the dialog
//$NON-NLS-1$
String messages = Messages.getString("CreateSandboxProjectDialog.successMessage");
// if (needCreateNewConn) {
messages += //$NON-NLS-1$
"\n\n" + //$NON-NLS-1$
Messages.getString("CreateSandboxProjectDialog.creatingConnectionMessages", bean.getName());
// }
MessageDialog.openInformation(getShell(), Messages.getString("CreateSandboxProjectDialog.successTitile"), //$NON-NLS-1$
messages);
// if (needCreateNewConn) {
// save connection
ConnectionUserPerReader instance = ConnectionUserPerReader.getInstance();
List<ConnectionBean> connections = instance.forceReadConnections();
connections.add(bean);
instance.saveConnections(connections);
// }
CreateSandboxProjectDialog.super.okPressed();
}
monitor.done();
}
});
}
};
try {
// final ProgressMonitorJobsDialog dialog = new ProgressMonitorJobsDialog(getShell());
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
dialog.run(true, false, runnable);
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
ExceptionHandler.process(e);
}
}
use of org.talend.core.context.RepositoryContext in project tdi-studio-se by Talend.
the class LoginProjectPage method createNewProject.
protected void createNewProject() {
IProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
Context ctx = CorePlugin.getContext();
RepositoryContext repositoryContext = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
try {
Project projectInfor = //$NON-NLS-1$
ProjectHelper.createProject(//$NON-NLS-1$
newProjectName.getText().trim().replace(' ', '_'), //$NON-NLS-1$
"", ECodeLanguage.JAVA.getName(), repositoryContext.getUser());
Project project = repositoryFactory.createProject(projectInfor);
resetProjectOperationSelectionWithBusyCursor(false);
fillUIProjectListWithBusyCursor();
selectProject(project.getLabel());
checkErrors();
//$NON-NLS-1$
newProjectName.setText("");
} catch (PersistenceException e) {
MessageDialog.openError(getShell(), Messages.getString("NewProjectWizard.failureTitle"), //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"NewProjectWizard.failureText"));
MessageBoxExceptionHandler.process(e);
} catch (JSONException e) {
// TODO Auto-generated catch block
ExceptionHandler.process(e);
}
}
use of org.talend.core.context.RepositoryContext in project tdi-studio-se by Talend.
the class DemosImportTest method initTempPro.
protected void initTempPro() throws PersistenceException, CoreException, LoginException {
if (currentDemo == null) {
// maybe license problem, the demo plugin is not loaded.
return;
}
createTempDemoProject(demoName);
Context ctx = CoreRuntimePlugin.getInstance().getContext();
RepositoryContext repositoryContext = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
originalProject = repositoryContext.getProject();
ProxyRepositoryFactory.getInstance().logOnProject(tempDemoProject, new NullProgressMonitor());
// initilize the DQ sturcture for the original default project
initDQStructure();
repositoryContext.setProject(tempDemoProject);
}
use of org.talend.core.context.RepositoryContext in project tdi-studio-se by Talend.
the class TabFolderEditors method createStyledText.
private StyledText createStyledText(CTabItem item) {
StyledText styledText = null;
RepositoryContext repositoryContext = (RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
ECodeLanguage language = repositoryContext.getProject().getLanguage();
IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
styledText = new UnnotifiableColorStyledText(tabFolderEditors, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, preferenceStore, language.getName());
styledText.setEnabled(false);
item.setControl(styledText);
return styledText;
}
use of org.talend.core.context.RepositoryContext in project tdi-studio-se by Talend.
the class ExpressionBuilderDialog method getExpressionStorePath.
/**
* yzhang Comment method "getExpressionStorePath".
*
* @return
*/
protected String getExpressionStorePath() {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
RepositoryContext repositoryContext = (RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
Project project = repositoryContext.getProject();
IProject p = root.getProject(project.getTechnicalLabel());
// put to the temp folder
String projectPath = p.getLocation().toPortableString() + File.separator + RepositoryConstants.TEMP_DIRECTORY;
String configurationPath = projectPath + File.separator + ExpressionPersistance.CONFIGURATION_FOLDER_NAME;
configurationPath = getValidFolderPath(configurationPath, 1);
File configurationFolder = new File(configurationPath);
if (!configurationFolder.exists()) {
configurationFolder.mkdir();
}
String expressionPath = configurationPath + File.separator + ExpressionPersistance.EXPRESSION_FOLDER_NAME;
expressionPath = getValidFolderPath(expressionPath, 1);
File expressionFolder = new File(expressionPath);
if (!expressionFolder.exists()) {
expressionFolder.mkdir();
}
String jobName = "";
if (component != null) {
jobName = component.getProcess().getName();
} else {
jobName = "tXMLMap";
}
expressionPath = expressionPath + File.separator + jobName + XmlUtil.FILE_XML_SUFFIX;
return expressionPath;
}
Aggregations