use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class LoginDialogV2 method getFirstTimeStartupPageIfNeeded.
protected AbstractLoginActionPage getFirstTimeStartupPageIfNeeded() {
AbstractLoginActionPage loginPage = null;
IBrandingService service = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
if (service != null) {
IBrandingConfiguration brandingConfiguration = service.getBrandingConfiguration();
if (brandingConfiguration != null && brandingConfiguration.isOnlyRemoteConnection()) {
return null;
}
}
// try to find if there are projects in workspace
Project[] projects = LoginHelper.getInstance().getProjects(LoginHelper.createDefaultLocalConnection());
if (projects == null || projects.length == 0) {
List<ConnectionBean> storedConnections = LoginHelper.getInstance().getStoredConnections();
if (storedConnections == null || storedConnections.isEmpty() || (storedConnections.size() == 1 && !LoginHelper.isRemoteConnection(storedConnections.get(0)) && LoginHelper.isWorkspaceSame(storedConnections.get(0)))) {
// for local license case
loginPage = new LoginFirstTimeStartupActionPage(base, this, SWT.NONE);
}
}
return loginPage;
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class LoginProjectPage method getBranch.
public String getBranch() {
Project project = getProject();
boolean isRemoteConnection = LoginHelper.isRemoteConnection(getConnection());
if (branchesViewer != null && isRemoteConnection && !branchesViewer.getSelection().isEmpty() && project != null) {
IStructuredSelection ss = (IStructuredSelection) branchesViewer.getSelection();
String branch = (String) ss.getFirstElement();
// if (branchList != null && branchList.contains(branch)) {
return branch;
// }
} else if (!isRemoteConnection && project != null) {
List<ProjectReference> referenceProjects = project.getEmfProject().getReferencedProjects();
String currentBranch = null;
if (referenceProjects != null && !referenceProjects.isEmpty()) {
boolean allBranchesAreSame = true;
for (ProjectReference referenceProject : referenceProjects) {
String branchFromReference = referenceProject.getBranch();
if (currentBranch == null) {
if (branchFromReference == null) {
//$NON-NLS-1$
branchFromReference = "";
}
currentBranch = branchFromReference;
continue;
}
if (!currentBranch.equals(branchFromReference)) {
allBranchesAreSame = false;
break;
}
}
if (!allBranchesAreSame) {
//$NON-NLS-1$
currentBranch = "";
}
} else {
//$NON-NLS-1$
currentBranch = "";
}
return currentBranch;
}
return null;
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class LoginProjectPage method saveLastUsedProjectAndBranch.
private void saveLastUsedProjectAndBranch() {
Project project = getProject();
loginHelper.getPrefManipulator().setLastProject(project.getLabel());
if (loginHelper.isRemoteConnection(getConnection())) {
String branch = getBranch();
if (branch == null) {
branch = SVNConstant.EMPTY;
}
try {
loginHelper.getPrefManipulator().setLastSVNBranch(//$NON-NLS-1$
new JSONObject(project.getEmfProject().getUrl()).getString("location"), //$NON-NLS-1$
project.getTechnicalLabel(), branch);
} catch (JSONException e) {
ExceptionHandler.process(e);
}
} else {
try {
String jsonStr = project.getEmfProject().getUrl();
if (jsonStr != null && !jsonStr.isEmpty()) {
String lastLogonBranch = loginHelper.getPrefManipulator().getLastSVNBranch(new JSONObject(jsonStr).getString("location"), //$NON-NLS-1$
project.getTechnicalLabel());
ProjectManager.getInstance().setMainProjectBranch(project, lastLogonBranch);
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class ComponentChooseDialog method propaHadoopCfgChanges.
/**
* DOC ycbai Comment method "propaHadoopCfgChanges".
*
* <P>
* Propagate the changes from hadoop cluster to M/R process when drag&drop hadoop subnode from repository view to
* M/R process.
* </P>
*
* @param repositoryNode
*/
private void propaHadoopCfgChanges(IRepositoryNode repositoryNode) {
if (repositoryNode == null || repositoryNode.getObject() == null) {
return;
}
IHadoopClusterService hadoopClusterService = HadoopRepositoryUtil.getHadoopClusterService();
if (hadoopClusterService == null || !hadoopClusterService.isHadoopSubnode(repositoryNode)) {
return;
}
IProcess process = editor.getProcess();
if (!ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process.getComponentsType()) && !ComponentCategory.CATEGORY_4_SPARK.getName().equals(process.getComponentsType()) && !ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName().equals(process.getComponentsType())) {
return;
}
if ((process instanceof IProcess2) && (((IProcess2) process).getProperty().getItem() instanceof JobletProcessItem)) {
return;
}
Item subItem = repositoryNode.getObject().getProperty().getItem();
String propertyParamName = MR_PROPERTY_PREFIX + EParameterName.PROPERTY_TYPE.getName();
String propertyRepTypeParamName = MR_PROPERTY_PREFIX + EParameterName.REPOSITORY_PROPERTY_TYPE.getName();
IElementParameter propertyParam = process.getElementParameter(propertyParamName);
if (propertyParam == null) {
return;
}
String repositoryValue = propertyParam.getRepositoryValue();
if (repositoryValue == null) {
return;
}
//$NON-NLS-1$
String[] supportedRepositoryTypes = repositoryValue.split("\\|");
String repositoryType = hadoopClusterService.getRepositoryTypeOfHadoopSubItem(subItem);
if (!ArrayUtils.contains(supportedRepositoryTypes, repositoryType)) {
return;
}
Item hadoopClusterItem = hadoopClusterService.getHadoopClusterBySubitemId(new Project(ProjectManager.getInstance().getProject(subItem)), subItem.getProperty().getId());
String hadoopClusterId = hadoopClusterItem.getProperty().getId();
if (EmfComponent.REPOSITORY.equals(propertyParam.getValue())) {
// do nothing when select the same hadoop cluster.
String propertyId = (String) process.getElementParameter(propertyRepTypeParamName).getValue();
if (hadoopClusterId.equals(propertyId)) {
return;
}
}
Connection connection = ((ConnectionItem) subItem).getConnection();
if (hadoopClusterService.hasDiffsFromClusterToProcess(subItem, process)) {
boolean confirmUpdate = MessageDialog.openConfirm(editor.getSite().getShell(), //$NON-NLS-1$
Messages.getString("TalendEditorDropTargetListener.updateHadoopCfgDialog.title"), //$NON-NLS-1$
Messages.getString("TalendEditorDropTargetListener.updateHadoopCfgDialog.msg"));
if (confirmUpdate) {
// Update spark mode to YARN_CLIENT if repository
if (ComponentCategory.CATEGORY_4_SPARK.getName().equals(process.getComponentsType()) || ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName().equals(process.getComponentsType())) {
IElementParameter sparkLocalParam = process.getElementParameter(HadoopConstants.SPARK_LOCAL_MODE);
IElementParameter sparkParam = process.getElementParameter(HadoopConstants.SPARK_MODE);
if (sparkLocalParam != null && (Boolean) (sparkLocalParam.getValue())) {
sparkLocalParam.setValue(false);
}
if (sparkParam != null && !HadoopConstants.SPARK_MODE_YARN_CLIENT.equals(sparkParam.getValue())) {
sparkParam.setValue(HadoopConstants.SPARK_MODE_YARN_CLIENT);
}
}
propertyParam.setValue(EmfComponent.REPOSITORY);
ChangeValuesFromRepository command = new ChangeValuesFromRepository(process, connection, propertyRepTypeParamName, subItem.getProperty().getId());
execCommandStack(command);
}
}
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class ShowRoutineItemsLabelProvider method getElements.
public Object[] getElements(Object inputElement) {
Set<Project> projects = allRoutineItems.keySet();
List<Object> objects = new ArrayList<Object>();
Project currentProject = ProjectManager.getInstance().getCurrentProject();
for (Project p : projects) {
if (p.equals(currentProject)) {
List<Property> items = allRoutineItems.get(p);
if (items != null) {
objects.addAll(items);
}
} else {
objects.add(p);
}
}
return objects.toArray();
}
Aggregations