use of org.talend.repository.ProjectManager in project tdi-studio-se by Talend.
the class ValidationRuleTypeProcessor method selectRepositoryNode.
@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
if (node.getContentType() == ERepositoryObjectType.REFERENCED_PROJECTS) {
return true;
}
ProjectManager pManager = ProjectManager.getInstance();
if (!pManager.isInCurrentMainProject(node)) {
if (node.getType() == ENodeType.STABLE_SYSTEM_FOLDER) {
return false;
}
if (node.getType() == ENodeType.SYSTEM_FOLDER) {
return true;
}
}
if (node.getType() == ENodeType.SYSTEM_FOLDER) {
return true;
}
if (node.getObject() == null || node.getObject().getProperty().getItem() == null) {
return false;
}
if (node.getObject() instanceof MetadataTable) {
return false;
}
Item item = node.getObject().getProperty().getItem();
if (item instanceof FolderItem) {
return true;
}
if (node.getObjectType() == getType()) {
return true;
}
return false;
}
use of org.talend.repository.ProjectManager in project tdi-studio-se by Talend.
the class AbstractRoutineAction method openRoutineEditor.
/**
* DOC smallet Comment method "openRoutineEditor".
*
* @param routineItem
* @throws SystemException
* @throws PartInitException
*/
protected IEditorPart openRoutineEditor(RoutineItem routineItem, boolean readOnly) throws SystemException, PartInitException {
if (routineItem == null) {
return null;
}
ICodeGeneratorService service = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
ECodeLanguage lang = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage();
ITalendSynchronizer routineSynchronizer;
switch(lang) {
case JAVA:
routineSynchronizer = service.createJavaRoutineSynchronizer();
break;
case PERL:
routineSynchronizer = service.createPerlRoutineSynchronizer();
break;
default:
//$NON-NLS-1$
throw new UnsupportedOperationException(Messages.getString("AbstractRoutineAction.unknowLanguage") + lang);
}
// check if the related editor is open.
IWorkbenchPage page = getActivePage();
IEditorReference[] editorParts = page.getEditorReferences();
//$NON-NLS-1$ //$NON-NLS-2$
String talendEditorID = "org.talend.designer.core.ui.editor.StandAloneTalend" + lang.getCaseName() + "Editor";
boolean found = false;
IEditorPart talendEditor = null;
for (IEditorReference reference : editorParts) {
IEditorPart editor = reference.getEditor(false);
if (talendEditorID.equals(editor.getSite().getId())) {
// TextEditor talendEditor = (TextEditor) editor;
RepositoryEditorInput editorInput = (RepositoryEditorInput) editor.getEditorInput();
if (editorInput.getItem().equals(routineItem)) {
page.bringToTop(editor);
found = true;
talendEditor = editor;
break;
}
}
}
if (!found) {
IFile file = null;
ProjectManager projectManager = ProjectManager.getInstance();
boolean flag = projectManager.isInCurrentMainProject(routineItem);
if (!flag) {
// is ref project
file = routineSynchronizer.getRoutinesFile(routineItem);
} else {
// need open from item file with multiple version
boolean needForceRefresh = false;
if (!ProxyRepositoryFactory.getInstance().isLocalConnectionProvider()) {
// in case only routine.item file modified, better refresh every time, especially for git mode
needForceRefresh = true;
}
routineSynchronizer.syncRoutine(routineItem, true, needForceRefresh);
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
String lastVersion = factory.getLastVersion(routineItem.getProperty().getId()).getVersion();
String curVersion = routineItem.getProperty().getVersion();
if (curVersion != null && curVersion.equals(lastVersion)) {
file = routineSynchronizer.getFile(routineItem);
} else {
file = routineSynchronizer.getRoutinesFile(routineItem);
}
}
if (file == null) {
return null;
}
RepositoryEditorInput input = new RoutineEditorInput(file, routineItem);
input.setReadOnly(readOnly);
talendEditor = page.openEditor(input, talendEditorID);
}
return talendEditor;
}
use of org.talend.repository.ProjectManager in project tdi-studio-se by Talend.
the class ExportItemWizardPage method performFinish.
public boolean performFinish() {
if (!checkExportFile()) {
return false;
}
ProjectManager pManager = ProjectManager.getInstance();
Project project = pManager.getCurrentProject().getEmfProject();
//$NON-NLS-1$
String projectPath = lastPath + "\\" + project.getTechnicalLabel();
if ((itemFromDirectoryRadio.getSelection() && new File(projectPath).exists()) || (itemFromArchiveRadio.getSelection() && new File(archivePathField.getText()).exists())) {
File oldFile = new File(projectPath).exists() ? new File(projectPath) : new File(archivePathField.getText());
if (MessageDialogWithToggle.openConfirm(null, Messages.getString("ExportItemWizardPage.waring"), Messages.getString("ExportItemWizardPage.fileAlreadyExist"))) {
//$NON-NLS-1$ //$NON-NLS-2$
deleteFile(oldFile);
} else {
return false;
}
}
Collection<Item> selectedItems = getSelectedItems();
if (exportDependencies.getSelection() && !implicitDependences.isEmpty()) {
for (IRepositoryViewObject object : implicitDependences) {
selectedItems.add(object.getProperty().getItem());
}
}
List<String> folders = new ArrayList<String>();
for (Object obj : filteredCheckboxTree.getViewer().getCheckedElements()) {
if (obj instanceof RepositoryNode) {
RepositoryNode repositoryNode = (RepositoryNode) obj;
if (repositoryNode.getType() == ENodeType.SIMPLE_FOLDER && repositoryNode.getObject() instanceof Folder) {
Folder folder = (Folder) repositoryNode.getObject();
ERepositoryObjectType contentType = repositoryNode.getContentType();
IProjectRepositoryNode root = repositoryNode.getRoot();
if (root != null && root.getProject() != null) {
IPath path = new Path(root.getProject().getTechnicalLabel());
path = path.append(contentType.getFolder());
String folderPath = folder.getPath();
if (folderPath != null && !"".equals(folderPath)) {
path = path.append(folderPath);
}
path = path.append(folder.getLabel());
folders.add(path.toPortableString() + "/");
}
}
}
}
try {
ExportItemUtil exportItemUtil = new ExportItemUtil();
if (itemFromArchiveRadio.getSelection()) {
if (lastPath != null && !lastPath.endsWith(FileConstants.TAR_FILE_SUFFIX) && !lastPath.endsWith(FileConstants.TAR_GZ_FILE_SUFFIX) && !lastPath.endsWith(FileConstants.ZIP_FILE_SUFFIX)) {
// set zip as default
lastPath = lastPath + FileConstants.ZIP_FILE_SUFFIX;
}
}
// MOD sgandon 31/03/2010 bug 12229: moved getAllVersion into ExportItemUtil.exportitems() method.
exportItemUtil.exportItems(new File(lastPath), selectedItems, folders, true, new NullProgressMonitor());
} catch (Exception e) {
MessageBoxExceptionHandler.process(e);
}
return true;
}
use of org.talend.repository.ProjectManager in project tdi-studio-se by Talend.
the class DBTreeProvider method getMetadataConnection.
/**
* @return MetadataConnection
*/
@SuppressWarnings("unchecked")
private Container getMetadataConnection() {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
ProjectManager pManager = ProjectManager.getInstance();
Container container = null;
try {
container = factory.getMetadata(pManager.getCurrentProject(), ERepositoryObjectType.METADATA_CONNECTIONS);
pManager.retrieveReferencedProjects();
for (Project p : pManager.getAllReferencedProjects()) {
RootContainer rContainer = factory.getMetadata(p, ERepositoryObjectType.METADATA_CONNECTIONS);
if (container == null) {
container = rContainer;
} else if (rContainer != null) {
Iterator iterator = rContainer.absoluteKeySet().iterator();
while (iterator.hasNext()) {
Object id = iterator.next();
container.addMember(id, rContainer.getAbsoluteMember(id));
}
}
}
} catch (PersistenceException e) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("DBTreeProvider.logMessage"), e);
} catch (BusinessException e) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("DBTreeProvider.logMessage"), e);
}
return container;
}
Aggregations