use of org.talend.core.repository.model.ProjectRepositoryNode in project tdi-studio-se by Talend.
the class CreateDiagramAction method setRepositoryNode.
private void setRepositoryNode(Properties params) {
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (null == workbenchWindow) {
return;
}
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
if (null == workbenchPage) {
return;
}
IPerspectiveDescriptor currentPerspective = workbenchPage.getPerspective();
if (!IBrandingConfiguration.PERSPECTIVE_DI_ID.equals(currentPerspective.getId())) {
// show di perspective
try {
workbenchWindow.getWorkbench().showPerspective(IBrandingConfiguration.PERSPECTIVE_DI_ID, workbenchWindow);
workbenchPage = workbenchWindow.getActivePage();
} catch (WorkbenchException e) {
ExceptionHandler.process(e);
return;
}
}
// bug 16594
IRepositoryView view = RepositoryManagerHelper.getRepositoryView();
if (view != null) {
Object type = params.get("type");
if (ERepositoryObjectType.BUSINESS_PROCESS != null && ERepositoryObjectType.BUSINESS_PROCESS.name().equals(type)) {
RepositoryNode processNode = ((ProjectRepositoryNode) view.getRoot()).getRootRepositoryNode(ERepositoryObjectType.BUSINESS_PROCESS);
final StructuredViewer viewer = view.getViewer();
if (viewer instanceof TreeViewer) {
((TreeViewer) viewer).expandToLevel(processNode, 1);
}
this.repositoryNode = processNode;
}
}
}
use of org.talend.core.repository.model.ProjectRepositoryNode 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.core.repository.model.ProjectRepositoryNode in project tdi-studio-se by Talend.
the class UseDynamicJobSelectionDialog method setCheckingNodes.
private void setCheckingNodes() {
final IContentProvider contentProvider = getItemsTreeViewer().getContentProvider();
final Object input = getItemsTreeViewer().getInput();
if (contentProvider instanceof ITreeContentProvider && input instanceof ProjectRepositoryNode && getNeedCheckedjobs() != null && getNeedCheckedjobs().length > 0) {
ITreeContentProvider cnfContentProvider = (ITreeContentProvider) contentProvider;
List<IRepositoryNode> checkingNodes = new ArrayList<IRepositoryNode>();
List<String> needCheckedJobIds = new ArrayList(Arrays.asList(getNeedCheckedjobs()));
final ProjectRepositoryNode root = (ProjectRepositoryNode) input;
final RepositoryNode rootRepositoryNode = root.getRootRepositoryNode(getSupportType());
if (rootRepositoryNode == null) {
return;
}
withReferenceProjects(cnfContentProvider, rootRepositoryNode, needCheckedJobIds, checkingNodes);
// set check for node
getItemsTreeViewer().setCheckedElements(checkingNodes.toArray());
// select and will expand the selected node auto
getItemsTreeViewer().setSelection(new StructuredSelection(checkingNodes), true);
// let scroll bar on top
getItemsTreeViewer().setSelection(new StructuredSelection(rootRepositoryNode));
getItemsTreeViewer().setSelection(StructuredSelection.EMPTY);
}
}
use of org.talend.core.repository.model.ProjectRepositoryNode in project tdi-studio-se by Talend.
the class UseDynamicJobSelectionDialog method withReferenceProjects.
private void withReferenceProjects(final ITreeContentProvider cnfContentProvider, RepositoryNode rootRepositoryNode, final List<String> needCheckedJobIds, List<IRepositoryNode> checkingNodes) {
if (rootRepositoryNode == null) {
return;
}
setCheckingNodes(cnfContentProvider, rootRepositoryNode, needCheckedJobIds, checkingNodes, true);
if (needCheckedJobIds.isEmpty()) {
return;
}
// ref
final IRepositoryNode refRoot = rootRepositoryNode.getRoot().getRootRepositoryNode(ERepositoryObjectType.REFERENCED_PROJECTS);
if (refRoot != null) {
final Object[] children = cnfContentProvider.getChildren(refRoot);
for (Object c : children) {
if (c instanceof ProjectRepositoryNode) {
withReferenceProjects(cnfContentProvider, ((ProjectRepositoryNode) c).getRootRepositoryNode(getSupportType()), needCheckedJobIds, checkingNodes);
}
}
}
}
use of org.talend.core.repository.model.ProjectRepositoryNode in project tdi-studio-se by Talend.
the class ExportItemWizardPage method getSelectedItems.
/**
* Get all selected items to export.
*
* @return
*/
@SuppressWarnings("unchecked")
private Collection<Item> getSelectedItems() {
// add this if user use filter
Set checkedElements = new HashSet();
for (Object obj : filteredCheckboxTree.getCheckedLeafNodes()) {
// if (obj instanceof RepositoryNode) {
checkedElements.add(obj);
// }
}
// add this if user does not use filter
for (Object obj : filteredCheckboxTree.getViewer().getCheckedElements()) {
if (obj instanceof RepositoryNode) {
RepositoryNode repositoryNode = (RepositoryNode) obj;
if (!isRepositoryFolder(repositoryNode) && !(repositoryNode instanceof ProjectRepositoryNode)) {
checkedElements.add(obj);
}
} else {
// for transform items
checkedElements.add(obj);
}
}
Object[] elements = checkedElements.toArray();
Map<String, Item> items = new HashMap<String, Item>();
collectNodes(items, elements);
return new ArrayList<Item>(items.values());
}
Aggregations