use of org.talend.core.services.ISVNProviderService in project tdi-studio-se by Talend.
the class JobletUtil method needReadOnlyJoblet.
public boolean needReadOnlyJoblet(JobletProcessItem jobletItem) {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart[] editors = page.getEditors();
for (IEditorPart editor : editors) {
if (editor instanceof AbstractMultiPageTalendEditor) {
List<? extends INode> nodeList = ((AbstractMultiPageTalendEditor) editor).getProcess().getGraphicalNodes();
for (INode node : nodeList) {
if (((Node) node).isJoblet() && jobletItem.getProperty() != null) {
if (jobletItem.getProperty().getId().equals(node.getComponent().getProcess().getId())) {
boolean haveLock = jobletItem.getState().isLocked();
boolean isSvn = false;
ISVNProviderService service = null;
if (PluginChecker.isSVNProviderPluginLoaded()) {
service = (ISVNProviderService) GlobalServiceRegister.getDefault().getService(ISVNProviderService.class);
}
if (service != null && service.isProjectInSvnMode()) {
isSvn = service.isProjectInSvnMode();
}
if (isSvn) {
IProxyRepositoryService proxyService = (IProxyRepositoryService) GlobalServiceRegister.getDefault().getService(IProxyRepositoryService.class);
IProxyRepositoryFactory factory = proxyService.getProxyRepositoryFactory();
ERepositoryStatus repositoryStatus = factory.getStatus(jobletItem);
if (repositoryStatus == ERepositoryStatus.LOCK_BY_USER) {
haveLock = true;
}
}
if (haveLock) {
return true;
}
}
}
}
}
}
return false;
}
use of org.talend.core.services.ISVNProviderService in project tdi-studio-se by Talend.
the class CustomComponentSettingPage method finish.
private void finish(IProgressMonitor... monitorWrap) {
IProgressMonitor monitor = null;
if (monitorWrap != null && monitorWrap.length == 1) {
monitor = monitorWrap[0];
}
final IProxyRepositoryFactory prf = CorePlugin.getDefault().getProxyRepositoryFactory();
if (PluginChecker.isSVNProviderPluginLoaded() && (!sharedAdded.isEmpty() || !backAdded.isEmpty())) {
RepositoryWorkUnit repositoryWorkUnit = new RepositoryWorkUnit("Update custom components") {
@Override
public void run() throws PersistenceException {
final IWorkspaceRunnable op = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor subMonitor) throws CoreException {
ISVNProviderService service = (ISVNProviderService) GlobalServiceRegister.getDefault().getService(ISVNProviderService.class);
String projectLabel = pro.getTechnicalLabel();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject eclipseProject = workspace.getRoot().getProject(projectLabel);
String targetRoot = eclipseProject.getLocation().toString() + "/" + ERepositoryObjectType.getFolderName(ERepositoryObjectType.COMPONENTS);
File componentFolder = new File(targetRoot);
URL url = null;
try {
if (!componentFolder.exists()) {
FilesUtils.createFoldersIfNotExists(targetRoot, false);
}
Bundle b = Platform.getBundle(IComponentsFactory.COMPONENTS_LOCATION);
url = FileLocator.toFileURL(FileLocator.find(b, new Path(""), null));
String sourceRoot = url.getFile();
// delete share
for (IComponent component : backAdded.keySet()) {
String componentFullPath = targetRoot + File.separator + component.getName();
if (service.isSVNProject(pro)) {
service.svnEclipseHandlerDelete(eclipseProject, pro, componentFullPath);
if (subMonitor != null) {
subMonitor.worked(10);
}
} else {
File file = new File(componentFullPath);
if (file != null && file.exists()) {
org.talend.utils.io.FilesUtils.deleteFolder(file, true);
}
}
}
if (!backAdded.isEmpty()) {
getCustomComponentSettings().removeAll(backAdded.values());
}
FileFilter ff = new FileFilter() {
@Override
public boolean accept(File pathname) {
if (FilesUtils.isSVNFolder(pathname)) {
return false;
}
return true;
}
};
// share
for (IComponent component : sharedAdded.keySet()) {
String sourcePath = sourceRoot + component.getPathSource() + File.separator + component.getName();
File sourceFile = new File(sourcePath);
String targetPath = targetRoot + File.separatorChar + component.getName();
File targetFile = new File(targetPath);
FilesUtils.copyFolder(sourceFile, targetFile, true, ff, null, true, false);
if (subMonitor != null) {
subMonitor.worked(10);
}
}
} catch (Exception e) {
resetCustomComponentSetting();
ExceptionHandler.process(e);
}
try {
prf.saveProject(pro);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
try {
eclipseProject.refreshLocal(IResource.DEPTH_INFINITE, subMonitor);
} catch (CoreException e1) {
ExceptionHandler.process(e1);
}
}
};
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
ISchedulingRule schedulingRule = workspace.getRoot();
// the update the project files need to be done in the workspace runnable to avoid all
// notification
// of changes before the end of the modifications.
workspace.run(op, schedulingRule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
} catch (CoreException e) {
throw new PersistenceException(e.getCause());
}
}
};
repositoryWorkUnit.setRefreshRepository(false);
repositoryWorkUnit.setForceTransaction(true);
prf.executeRepositoryWorkUnit(repositoryWorkUnit);
try {
repositoryWorkUnit.throwPersistenceExceptionIfAny();
} catch (PersistenceException e) {
e.printStackTrace();
}
}
if (monitor != null) {
monitor.done();
}
// refresh again after the gui closed .
try {
String projectLabel = pro.getTechnicalLabel();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject eclipseProject = workspace.getRoot().getProject(projectLabel);
eclipseProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (CoreException e1) {
ExceptionHandler.process(e1);
}
}
use of org.talend.core.services.ISVNProviderService in project tdi-studio-se by Talend.
the class Problems method isSVN.
private static boolean isSVN() {
boolean isSvn = false;
ISVNProviderService service = null;
if (PluginChecker.isSVNProviderPluginLoaded()) {
service = (ISVNProviderService) GlobalServiceRegister.getDefault().getService(ISVNProviderService.class);
}
if (service != null && service.isProjectInSvnMode()) {
isSvn = service.isProjectInSvnMode();
}
return isSvn;
}
use of org.talend.core.services.ISVNProviderService in project tdi-studio-se by Talend.
the class MultiPageTalendEditor method setName.
/**
* DOC smallet Comment method "setName".
*
* @param label
*/
@Override
public void setName() {
if (getEditorInput() == null) {
return;
}
super.setName();
IProcess2 process2 = this.getProcess();
if (process2 == null) {
return;
}
Property property = process2.getProperty();
if (property == null) {
return;
}
String label = property.getDisplayName();
//$NON-NLS-1$
String jobVersion = "0.1";
if (process2 != null) {
jobVersion = process2.getVersion();
}
// if (getActivePage() == 1) {
ISVNProviderService service = null;
if (PluginChecker.isSVNProviderPluginLoaded()) {
service = (ISVNProviderService) GlobalServiceRegister.getDefault().getService(ISVNProviderService.class);
if (revisionChanged && service.isProjectInSvnMode()) {
revisionNumStr = service.getCurrentSVNRevision(process2);
revisionChanged = false;
if (revisionNumStr != null) {
//$NON-NLS-1$
revisionNumStr = ".r" + revisionNumStr;
}
}
}
//$NON-NLS-1$
String title = "MultiPageTalendEditor.Job";
if (process2 != null) {
Item item = process2.getProperty().getItem();
if (item instanceof JobletProcessItem) {
//$NON-NLS-1$
title = "MultiPageTalendEditor.Joblet";
}
}
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
boolean allowVerchange = brandingService.getBrandingConfiguration().isAllowChengeVersion();
if (allowVerchange) {
if (revisionNumStr != null) {
setPartName(Messages.getString(title, label, jobVersion) + revisionNumStr);
} else {
setPartName(Messages.getString(title, label, jobVersion));
}
} else {
if (revisionNumStr != null) {
//$NON-NLS-1$
setPartName(Messages.getString(title, label, "") + revisionNumStr);
} else {
//$NON-NLS-1$
setPartName(Messages.getString(title, label, ""));
}
}
}
use of org.talend.core.services.ISVNProviderService in project tdi-studio-se by Talend.
the class RepositoryService method isloginDialogDisabled.
private boolean isloginDialogDisabled() {
//$NON-NLS-1$
boolean reload = Boolean.parseBoolean(System.getProperty("talend.project.reload"));
PreferenceManipulator preferenceManipulator = new PreferenceManipulator();
ConnectionBean lastBean = null;
if (reload) {
final ConnectionUserPerReader instance = ConnectionUserPerReader.getInstance();
instance.forceReadConnections();
final String lastConncetion = ConnectionUserPerReader.getInstance().readLastConncetion();
for (ConnectionBean bean : instance.readConnections()) {
if (bean.getName().equals(lastConncetion)) {
lastBean = bean;
break;
}
}
}
if (ArrayUtils.contains(Platform.getApplicationArgs(), EclipseCommandLine.TALEND_DISABLE_LOGINDIALOG_COMMAND)) {
//$NON-NLS-1$
boolean deleteProjectIfExist = ArrayUtils.contains(Platform.getApplicationArgs(), "--deleteProjectIfExist");
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
brandingService.getBrandingConfiguration().setUseProductRegistration(false);
ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
//$NON-NLS-1$ //$NON-NLS-2$
String projectName = getAppArgValue("-project", "AUTO_LOGIN_PROJECT");
//$NON-NLS-1$
String language = getAppArgValue("-language", ECodeLanguage.JAVA.getName());
//$NON-NLS-1$ //$NON-NLS-2$
String login = getAppArgValue("-login", "auto@login.com");
//$NON-NLS-1$ //$NON-NLS-2$
String password = getAppArgValue("-loginPass", "");
//$NON-NLS-1$
String tacURL = getAppArgValue("-tacURL", null);
// if tacURL is null, the branch will be no useful.
//$NON-NLS-1$
String branch = getAppArgValue("-branch", null);
// if tacURL is not null, will be remote
final boolean isRemote = tacURL != null;
if (reload && lastBean != null) {
final String lastProject = preferenceManipulator.getLastProject();
if (lastProject != null) {
projectName = lastProject;
}
final String lastUser = lastBean.getUser();
if (lastUser != null) {
login = lastUser;
}
final String lastPass = lastBean.getPassword();
if (lastPass != null) {
password = lastPass;
}
}
User userInfo = PropertiesFactoryImpl.eINSTANCE.createUser();
userInfo.setLogin(login);
try {
userInfo.setPassword(PasswordHelper.encryptPasswd(password));
} catch (NoSuchAlgorithmException e) {
ExceptionHandler.process(e);
}
LoginHelper.isAutoLogonFailed = false;
try {
ConnectionBean bean = null;
if (reload && lastBean != null) {
// reload
bean = lastBean;
} else {
if (tacURL != null && isRemote) {
// remote
bean = ConnectionBean.getDefaultRemoteConnectionBean();
bean.setUser(login);
bean.setPassword(password);
bean.getDynamicFields().put(RepositoryConstants.REPOSITORY_URL, tacURL);
} else {
bean = ConnectionBean.getDefaultConnectionBean();
}
}
Context ctx = CorePlugin.getContext();
RepositoryContext repositoryContext = new RepositoryContext();
ctx.putProperty(Context.REPOSITORY_CONTEXT_KEY, repositoryContext);
repositoryContext.setUser(userInfo);
repositoryContext.setClearPassword(password);
repositoryContext.setFields(bean.getDynamicFields());
repositoryFactory.setRepositoryFactoryFromProvider(RepositoryFactoryProvider.getRepositoriyById(bean.getRepositoryId()));
Project project = null;
for (Project p : repositoryFactory.readProject()) {
if (p.getLabel().equals(projectName) || p.getTechnicalLabel().equals(projectName)) {
project = p;
break;
}
}
if (!reload) {
if (deleteProjectIfExist && project != null) {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject eclipseProject = workspace.getRoot().getProject(project.getTechnicalLabel());
if (eclipseProject.exists()) {
eclipseProject.delete(true, new NullProgressMonitor());
}
}
if (!isRemote && (project == null || deleteProjectIfExist)) {
Project projectInfor = //$NON-NLS-1$
ProjectHelper.createProject(//$NON-NLS-1$
projectName, //$NON-NLS-1$
"", language, userInfo);
project = repositoryFactory.createProject(projectInfor);
}
} else {
if (project != null && !project.getEmfProject().isLocal() && repositoryFactory.isLocalConnectionProvider()) {
List<IRepositoryFactory> rfList = RepositoryFactoryProvider.getAvailableRepositories();
IRepositoryFactory remoteFactory = null;
for (IRepositoryFactory rf : rfList) {
if (!rf.isLocalConnectionProvider()) {
remoteFactory = rf;
break;
}
}
if (remoteFactory != null) {
repositoryFactory.setRepositoryFactoryFromProvider(remoteFactory);
repositoryFactory.getRepositoryContext().setOffline(true);
}
}
}
if (!repositoryFactory.isLocalConnectionProvider()) {
ProjectManager.getInstance().setMainProjectBranch(project, preferenceManipulator.getLastSVNBranch(new JSONObject(project.getEmfProject().getUrl()).getString("location"), project.getTechnicalLabel()));
}
if (project != null && reload && lastBean != null && repositoryFactory.getRepositoryContext().isOffline()) {
if (PluginChecker.isSVNProviderPluginLoaded()) {
ISVNProviderService svnProviderService = (ISVNProviderService) GlobalServiceRegister.getDefault().getService(ISVNProviderService.class);
if (svnProviderService.isSVNProject(project)) {
String projectUrl = svnProviderService.getProjectUrl(project);
String lastBranch = preferenceManipulator.getLastSVNBranch(projectUrl, project.getTechnicalLabel());
ProjectManager.getInstance().setMainProjectBranch(project, lastBranch);
}
}
}
if (project == null) {
//$NON-NLS-1$
throw new LoginException(Messages.getString("RepositoryService.projectNotFound", projectName));
}
repositoryContext.setProject(project);
repositoryFactory.logOnProject(project, new NullProgressMonitor());
} catch (final PersistenceException e) {
if (e instanceof OperationCancelException) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.getString("LoginDialog.logonCanceled"), e.getLocalizedMessage());
}
});
} else {
MessageBoxExceptionHandler.process(e, new Shell());
}
repositoryFactory.logOffProject();
LoginHelper.isAutoLogonFailed = true;
} catch (LoginException e) {
MessageBoxExceptionHandler.process(e, new Shell());
repositoryFactory.logOffProject();
LoginHelper.isAutoLogonFailed = true;
} catch (BusinessException e) {
MessageBoxExceptionHandler.process(e, new Shell());
repositoryFactory.logOffProject();
LoginHelper.isAutoLogonFailed = true;
} catch (CoreException e) {
MessageBoxExceptionHandler.process(e, new Shell());
repositoryFactory.logOffProject();
LoginHelper.isAutoLogonFailed = true;
} catch (JSONException e) {
ExceptionHandler.process(e);
LoginHelper.isAutoLogonFailed = true;
}
if (LoginHelper.isAutoLogonFailed) {
LoginHelper.isRestart = true;
}
return true;
}
return false;
}
Aggregations