use of org.talend.repository.model.nodes.IProjectRepositoryNode in project tdi-studio-se by Talend.
the class BusinessAssignmentComposite method createSelectionListener.
private void createSelectionListener() {
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
BusinessAssignment businessAssignment = getBusinessAssignment(event.getSelection());
if (businessAssignment != null) {
final IRepositoryView repositoryView = getRepositoryView();
if (repositoryView != null) {
IProjectRepositoryNode rootRepositoryNode = repositoryView.getRoot();
TalendItem item = businessAssignment.getTalendItem();
//
if (item instanceof Routine && rootRepositoryNode instanceof ProjectRepositoryNode) {
RepositoryNodeUtilities.expandParentNode(getRepositoryView(), ((ProjectRepositoryNode) rootRepositoryNode).getRootRepositoryNode(ERepositoryObjectType.CODE));
}
selectChild(item, (IRepositoryNode) rootRepositoryNode);
}
}
}
private void selectChild(TalendItem item, IRepositoryNode rootRepositoryNode) {
try {
RepositoryNode curNode = null;
JobSettingsView viewer = (JobSettingsView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(JobSettingsView.ID);
IRepositoryViewObject lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(item.getId());
if (lastVersion != null) {
curNode = RepositoryNodeUtilities.getRepositoryNode(lastVersion);
select(viewer, curNode);
} else if (item instanceof TableMetadata) {
MetadataTable table = MetadataToolHelper.getMetadataTableFromRepository(item.getId());
if (table != null) {
//$NON-NLS-1$
String id = item.getId().split(" - ")[0];
RepositoryNode node = RepositoryNodeUtilities.getMetadataTableFromConnection(item.getId());
IRepositoryView view = getRepositoryView();
if (view != null) {
RepositoryNodeUtilities.expandParentNode(view, node);
select(viewer, node);
}
}
} else if (item instanceof Query) {
org.talend.core.model.metadata.builder.connection.Query query = MetadataToolHelper.getQueryFromRepository(item.getId());
if (query != null) {
//$NON-NLS-1$
String id = item.getId().split(" - ")[0];
IRepositoryView view = getRepositoryView();
RepositoryNode node = RepositoryNodeUtilities.getQueryFromConnection(item.getId());
RepositoryNodeUtilities.expandParentNode(view, node);
select(viewer, node);
}
} else if (item instanceof SAPFunction) {
SAPFunctionUnit function = MetadataToolHelper.getSAPFunctionFromRepository(item.getId());
if (function != null) {
IRepositoryView view = getRepositoryView();
RepositoryNode node = RepositoryNodeUtilities.getSAPFunctionFromConnection(item.getId());
RepositoryNodeUtilities.expandParentNode(view, node);
select(viewer, node);
}
} else {
for (IRepositoryNode node : rootRepositoryNode.getChildren()) {
RepositoryNode rNode = (RepositoryNode) node;
if (item instanceof SQLPattern && rNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.SQLPATTERNS) {
if (rNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
SQLPatternItem sqlItem = (SQLPatternItem) rNode.getObject().getProperty().getItem();
if (sqlItem.isSystem() && item.getLabel().equals(rNode.getObject().getLabel())) {
select(viewer, rNode);
}
} else {
selectChild(item, rNode);
}
} else if (item instanceof Routine && rNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.ROUTINES) {
if (rNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
RoutineItem sqlItem = (RoutineItem) rNode.getObject().getProperty().getItem();
if (sqlItem.isBuiltIn() && item.getLabel().equals(rNode.getObject().getLabel())) {
select(viewer, rNode);
}
} else {
selectChild(item, rNode);
}
}
}
}
} catch (PersistenceException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
ExceptionHandler.process(e);
}
}
private void select(JobSettingsView viewer, RepositoryNode repositoryNode) {
if (viewer == null) {
return;
}
if (repositoryNode == null) {
return;
}
CorePlugin.getDefault().getRepositoryService().removeRepositoryTreeViewListener(viewer);
final IRepositoryView repositoryView = getRepositoryView();
if (repositoryView != null) {
repositoryView.getViewer().setSelection(new StructuredSelection(repositoryNode));
}
CorePlugin.getDefault().getRepositoryService().addRepositoryTreeViewListener(viewer);
}
});
}
use of org.talend.repository.model.nodes.IProjectRepositoryNode in project tdi-studio-se by Talend.
the class AbstractVersionManagementProjectSettingPage method processItems.
protected void processItems(List<ItemVersionObject> objects, RepositoryNode node) {
if (node == null) {
return;
}
// if the root node of type is not init, force init.
IProjectRepositoryNode root = node.getRoot();
if (root instanceof ProjectRepositoryNode) {
((ProjectRepositoryNode) root).initNode(node);
}
if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
if (node.getObject() != null) {
Property property = node.getObject().getProperty();
Item item = property.getItem();
if (item != null && filterRepositoryNode(node)) {
// must be item
ItemVersionObject object = createItemVersionObject(node, property);
objects.add(object);
}
}
} else {
IContentProvider contentProvider = treeViewer.getContentProvider();
if (contentProvider instanceof NavigatorContentServiceContentProvider) {
NavigatorContentServiceContentProvider navigatorProvider = (NavigatorContentServiceContentProvider) contentProvider;
Object[] children = navigatorProvider.getChildren(node);
for (Object child : children) {
if (child instanceof RepositoryNode) {
processItems(objects, (RepositoryNode) child);
}
}
} else {
for (IRepositoryNode child : node.getChildren()) {
processItems(objects, (RepositoryNode) child);
}
}
}
}
use of org.talend.repository.model.nodes.IProjectRepositoryNode in project tdi-studio-se by Talend.
the class StatusManagerSettingPage method processItems.
private void processItems(List<RepositoryObject> objects, IRepositoryNode node) {
if (node == null) {
return;
}
// if the root node of type is not init, force init.
IProjectRepositoryNode root = node.getRoot();
if (root instanceof ProjectRepositoryNode) {
((ProjectRepositoryNode) root).initNode(node);
}
if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
if (node.getObject() != null) {
Property property = node.getObject().getProperty();
Item item = property.getItem();
if (item != null && filterRepositoryNode((RepositoryNode) node)) {
// must be item
RepositoryObject object = new RepositoryObject(node.getObject().getProperty());
object.setRepositoryNode(node);
// ItemVersionObject object = new ItemVersionObject(node, property.getVersion());
objects.add(object);
}
}
} else {
IContentProvider contentProvider = treeViewer.getContentProvider();
if (contentProvider instanceof NavigatorContentServiceContentProvider) {
NavigatorContentServiceContentProvider navigatorProvider = (NavigatorContentServiceContentProvider) contentProvider;
Object[] children = navigatorProvider.getChildren(node);
for (Object child : children) {
if (child instanceof RepositoryNode) {
processItems(objects, (RepositoryNode) child);
}
}
} else {
for (IRepositoryNode child : node.getChildren()) {
processItems(objects, child);
}
}
}
}
use of org.talend.repository.model.nodes.IProjectRepositoryNode 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.model.nodes.IProjectRepositoryNode in project tdi-studio-se by Talend.
the class StatusManagerSettingPage method expandSomeNodes.
private void expandSomeNodes(IProjectRepositoryNode root) {
if (root instanceof IProjectRepositoryNode) {
final IProjectRepositoryNode rootNode = root;
// metadata
IRepositoryNode metadataConNode = rootNode.getRootRepositoryNode(ERepositoryObjectType.METADATA);
if (metadataConNode != null) {
treeViewer.expandToLevel(metadataConNode, 1);
}
// code
IRepositoryNode codeNode = rootNode.getRootRepositoryNode(ERepositoryObjectType.CODE);
if (codeNode != null) {
treeViewer.expandToLevel(codeNode, 1);
}
}
}
Aggregations