use of org.talend.core.context.RepositoryContext in project tdi-studio-se by Talend.
the class NewProjectWizard method performFinish.
/**
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
@Override
public boolean performFinish() {
IProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
Context ctx = CorePlugin.getContext();
RepositoryContext repositoryContext = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
try {
Project projectInfor = ProjectHelper.createProject(mainPage.getName().trim().replace(' ', '_'), mainPage.getDescription(), mainPage.getLanguage(), repositoryContext.getUser());
project = repositoryFactory.createProject(projectInfor);
return true;
} catch (PersistenceException e) {
MessageDialog.openError(getShell(), Messages.getString("NewProjectWizard.failureTitle"), //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$ //$NON-NLS-2$
"NewProjectWizard.failureText"));
MessageBoxExceptionHandler.process(e);
return false;
}
}
use of org.talend.core.context.RepositoryContext in project tmdm-studio-se by Talend.
the class MDMLockDecorator method isEditableAsReadOnly.
private void isEditableAsReadOnly() {
Context ctx = CoreRuntimePlugin.getInstance().getContext();
RepositoryContext rc = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
editableAsReadOnly = rc.isEditableAsReadOnly();
}
use of org.talend.core.context.RepositoryContext in project tmdm-studio-se by Talend.
the class MDMRepositoryLabelProvider method getLockInfo.
private String getLockInfo(Object element) {
User currentLoginUser = ((RepositoryContext) CoreRuntimePlugin.getInstance().getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser();
String currentLogin = null;
if (currentLoginUser != null) {
currentLogin = currentLoginUser.getLogin();
}
IRepositoryViewObject viewObj = (IRepositoryViewObject) element;
Item item = viewObj.getProperty().getItem();
if (item != null) {
LockInfo lockInfo = ProxyRepositoryFactory.getInstance().getLockInfo(item);
if (!lockInfo.getUser().equals(currentLogin)) {
String login = lockInfo.getUser();
String application = lockInfo.getApplication();
if (login != null && !"".equals(login)) {
// $NON-NLS-1$
String content = Messages.bind(Messages.MDMRepositoryLabelProvider_lockinfo, login, application);
return content;
}
}
}
return null;
}
use of org.talend.core.context.RepositoryContext in project tdq-studio-se by Talend.
the class UnitTestBuildHelper method initRepositoryContext.
private static void initRepositoryContext(Project project) {
RepositoryContext repositoryContext = new RepositoryContext();
Context ctx = CoreRuntimePlugin.getInstance().getContext();
ctx.putProperty(Context.REPOSITORY_CONTEXT_KEY, repositoryContext);
repositoryContext.setUser(project.getAuthor());
repositoryContext.setClearPassword(project.getLabel());
repositoryContext.setProject(project);
repositoryContext.setFields(new HashMap<String, String>());
ProjectManager.getInstance().setMainProjectBranch(project, null);
ReponsitoryContextBridge.initialized(project.getEmfProject(), project.getAuthor());
}
use of org.talend.core.context.RepositoryContext in project tdq-studio-se by Talend.
the class CorePlugin method initProxyRepository.
/**
* DOC zshen Comment method "initProxyRepository".
*/
public ReturnCode initProxyRepository() {
ReturnCode rc = new ReturnCode();
Project project = null;
RepositoryContext repositoryContext = (RepositoryContext) org.talend.core.runtime.CoreRuntimePlugin.getInstance().getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
if (repositoryContext != null) {
project = repositoryContext.getProject();
User user = repositoryContext.getUser();
ReponsitoryContextBridge.initialized(project.getEmfProject(), user);
} else {
// else project is null, then we are in TOP only
Location instanceLoc = Platform.getInstanceLocation();
try {
if (instanceLoc.isLocked()) {
// $NON-NLS-1$
rc.setMessage(DefaultMessagesImpl.getString("CorePlugin.workspaceInUse"));
rc.setOk(false);
return rc;
} else {
instanceLoc.lock();
}
} catch (IOException e) {
log.error(e, e);
}
ProxyRepositoryFactory proxyRepository = ProxyRepositoryFactory.getInstance();
IRepositoryFactory repository = RepositoryFactoryProvider.getRepositoriyById(RepositoryConstants.REPOSITORY_LOCAL_ID);
if (repository == null) {
// $NON-NLS-1$
log.fatal(DefaultMessagesImpl.getString("CorePlugin.noLocalRepositoryFound"));
// $NON-NLS-1$
rc.setMessage(DefaultMessagesImpl.getString("CorePlugin.noLocalRepositoryFound"));
rc.setOk(false);
return rc;
}
proxyRepository.setRepositoryFactoryFromProvider(repository);
try {
proxyRepository.checkAvailability();
proxyRepository.initialize();
XmiResourceManager xmiResourceManager = proxyRepository.getRepositoryFactoryFromProvider().getResourceManager();
IProject rootProject = ResourceManager.getRootProject();
if (rootProject.getFile(FileConstants.LOCAL_PROJECT_FILENAME).exists()) {
// Initialize TDQ EMF model packages.
new EMFUtil();
project = new Project(xmiResourceManager.loadProject(rootProject));
} else {
// $NON-NLS-1$
String username = "talend@talend.com";
// $NON-NLS-1$
String password = "talend@talend.com";
User user = PropertiesFactoryImpl.eINSTANCE.createUser();
user.setLogin(username);
user.setPassword(password.getBytes());
String projectName = ResourceManager.getRootProjectName();
String projectDesc = ResourcesPlugin.getWorkspace().newProjectDescription(projectName).getComment();
Project projectInfor = ProjectHelper.createProject(projectName, projectDesc, ECodeLanguage.JAVA.getName(), user);
// MOD zshen create project by proxyRepository
checkFileName(projectInfor.getLabel(), RepositoryConstants.PROJECT_PATTERN);
project = proxyRepository.getRepositoryFactoryFromProvider().createProject(user, password, projectInfor);
}
if (project != null) {
initRepositoryContext(project);
// add status
// $NON-NLS-1$
String defaultTechnicalStatusList = "DEV development;TEST testing;PROD production";
List<Status> statusList = StatusHelper.parse(defaultTechnicalStatusList);
proxyRepository.setTechnicalStatus(statusList);
// 'maven_user_settings.xml').before set, must check user setting first.
if (org.talend.commons.utils.platform.PluginChecker.isOnlyTopLoaded()) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMavenUIService.class)) {
IMavenUIService mavenUIService = (IMavenUIService) GlobalServiceRegister.getDefault().getService(IMavenUIService.class);
if (mavenUIService != null) {
mavenUIService.checkUserSettings(new NullProgressMonitor());
mavenUIService.updateMavenResolver(false);
mavenUIService.addMavenConfigurationChangeListener();
}
}
// deploy libraries and maven index here
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
ILibrariesService librariesService = (ILibrariesService) GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
if (librariesService != null) {
librariesService.syncLibraries();
// TDQ-9529 check libararies install status at here,so that
// "Optional third-party libraries" is displayed in the "Additional Talend Package"
// dialog.
librariesService.checkLibraries();
}
}
}
CWMPlugin.getDefault().createLibFolderIfNotExist();
// TDQ-11348 the readOnlyUser property is false for TOP.
// $NON-NLS-1$
System.getProperties().put("ReadOnlyUser", new Boolean(false).toString());
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
rc.setMessage(e.getMessage());
rc.setOk(false);
return rc;
}
}
return rc;
}
Aggregations