use of com.amalto.workbench.providers.datamodel.SchemaTreeContentProvider in project tmdm-studio-se by Talend.
the class XSDDeleteConceptWrapAction method populateAllOffspring.
/**
* Author: Fliu this fun is to populate all offsprings for a specific object
*/
private Object[] populateAllOffspring(Object obj, ArrayList offspringList) {
SchemaTreeContentProvider provider = (SchemaTreeContentProvider) viewer.getContentProvider();
Object[] offersprings = provider.getChildren(obj);
for (Object subObj : offersprings) {
if (!offspringList.contains(subObj)) {
offspringList.add(subObj);
if (provider.hasChildren(subObj)) {
populateAllOffspring(subObj, offspringList);
}
} else {
continue;
}
}
return offspringList.toArray();
}
use of com.amalto.workbench.providers.datamodel.SchemaTreeContentProvider in project tmdm-studio-se by Talend.
the class DataModelMainPage method createSchemaTreeComp.
private void createSchemaTreeComp(Composite parent) {
Composite schemaSash = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.verticalSpacing = 0;
schemaSash.setLayout(layout);
schemaSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
schemaSash.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
Composite compInfo = new Composite(schemaSash, SWT.NONE);
layout = new GridLayout();
layout.verticalSpacing = 0;
compInfo.setLayout(layout);
compInfo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
compInfo.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
Composite compSchemaTree = new Composite(schemaSash, SWT.NONE);
GridLayout glCompSchemaTree = new GridLayout();
glCompSchemaTree.verticalSpacing = 0;
glCompSchemaTree.marginWidth = 0;
glCompSchemaTree.marginHeight = 0;
glCompSchemaTree.horizontalSpacing = 0;
compSchemaTree.setLayout(glCompSchemaTree);
compSchemaTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
compSchemaTree.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
Label title = new Label(compInfo, SWT.VERTICAL);
title.setText(Messages.DataModelEntities);
title.setFont(FontUtils.getBoldFont(title.getFont()));
Color blue = new Color(compInfo.getDisplay(), 0, 0, 255);
title.setForeground(blue);
title.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
ToolBar toolBarSchemaTree = createToolbarOnComposite(compSchemaTree);
viewer = new TreeViewer(compSchemaTree, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
addToolItems2SchemaTreeToolBar(toolBarSchemaTree);
toolBarSchemaTree.pack();
drillDownAdapter = new DrillDownAdapter(viewer);
schemaTreeContentProvider = new SchemaTreeContentProvider(this.getSite(), xsdSchema);
viewer.setContentProvider(schemaTreeContentProvider);
viewer.setFilters(new ViewerFilter[] { new SchemaRoleAccessFilter(null), new SchemaNameFilter(), new SchemaUniqueElementFilter() });
viewer.getTree().addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
isSchemaSelected = true;
}
});
viewer.setLabelProvider(new XSDTreeLabelProvider());
viewer.setSorter(schemaTreeSorter);
// getViewSite());
viewer.setInput(this.getSite());
viewer.getTree().addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (isReadOnly()) {
return;
}
IStructuredSelection selection = ((IStructuredSelection) viewer.getSelection());
// delete
if ((e.stateMask == 0) && (e.keyCode == SWT.DEL)) {
if (deleteConceptWrapAction.checkInDeletableType(selection.toArray())) {
deleteConceptWrapAction.prepareToDelSelectedItems(selection, viewer);
deleteConceptWrapAction.run();
} else {
MessageDialog.openWarning(getSite().getShell(), Messages.Warning, Messages.SelectDeletableTry);
}
}
}
});
viewer.setComparer(new ElementComparer());
}
use of com.amalto.workbench.providers.datamodel.SchemaTreeContentProvider in project tmdm-studio-se by Talend.
the class TreeExpandHelper method getExpandedEntityElements.
// ///
private Object[] getExpandedEntityElements(DataModelMainPage mainPage) {
TreeViewer elementsViewer = mainPage.getElementsViewer();
SchemaTreeContentProvider contentProvider = (SchemaTreeContentProvider) elementsViewer.getContentProvider();
Object[] xsdDeclarations = getChildren(contentProvider.getXsdSchema(), contentProvider);
//
List<Object> result = new ArrayList<Object>();
//
Deque<ExpandInfoNode> nodeStack = new LinkedList<ExpandInfoNode>();
//
Deque<Object> elementStack = new LinkedList<Object>();
// record entities
Map<ExpandInfoNode, XSDElementDeclaration> expandedRoots = new HashMap<ExpandInfoNode, XSDElementDeclaration>();
for (Object obj : xsdDeclarations) {
if (obj instanceof XSDElementDeclaration) {
XSDElementDeclaration decl = (XSDElementDeclaration) obj;
String name = decl.getName();
for (ExpandInfoNode node : expandedElements) {
if (name.equals(node.name)) {
expandedRoots.put(node, decl);
result.add(decl);
// /
nodeStack.add(node);
// /
elementStack.add(decl);
break;
}
}
}
}
while (!nodeStack.isEmpty() && !elementStack.isEmpty()) {
ExpandInfoNode node = nodeStack.pollFirst();
Object element = elementStack.pollFirst();
List<ExpandInfoNode> nodes = node.childs;
Object[] elementChildren = getChildren(element, contentProvider);
if (nodes != null && nodes.size() > 0 && elementChildren != null) {
Map<ExpandInfoNode, Object> nodeElementPairs = getNodeElementPairs(elementChildren, nodes);
for (ExpandInfoNode node2 : nodeElementPairs.keySet()) {
nodeStack.add(node2);
elementStack.add(nodeElementPairs.get(node2));
result.add(nodeElementPairs.get(node2));
}
}
}
return result.toArray();
}
use of com.amalto.workbench.providers.datamodel.SchemaTreeContentProvider in project tmdm-studio-se by Talend.
the class EntityCommitHandler method updateReferenceForNewName.
private void updateReferenceForNewName(XSDElementDeclaration xsdElementDeclaration, String oldName) {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IWorkbenchPartSite site = activePage.getActivePart().getSite();
SchemaTreeContentProvider contentProvider = new SchemaTreeContentProvider(site, getCommitedObj().getSchema());
Object[] objs = Util.getAllObject(site, new ArrayList<Object>(), contentProvider);
Object[] allForeignKeyAndInfos = Util.getAllForeignKeyRelatedInfos(site, new ArrayList<Object>(), contentProvider, new HashSet<Object>());
String newName = getCommitedObj().getName();
Util.updateReference(xsdElementDeclaration, objs, allForeignKeyAndInfos, oldName, newName);
EntitySyncProcessor.syncNameForAnnotation(xsdElementDeclaration, oldName, newName);
xsdElementDeclaration.updateElement();
}
use of com.amalto.workbench.providers.datamodel.SchemaTreeContentProvider in project tmdm-studio-se by Talend.
the class TreeExpandHelper method getExpandedTypeElements.
private Object[] getExpandedTypeElements(DataModelMainPage mainPage) {
TreeViewer typesViewer = mainPage.getTypesViewer();
SchemaTreeContentProvider contentProvider = (SchemaTreeContentProvider) typesViewer.getContentProvider();
Object[] xsdDeclarations = getChildren(contentProvider.getXsdSchema(), contentProvider);
//
List<Object> result = new ArrayList<Object>();
//
Deque<ExpandInfoNode> nodeStack = new LinkedList<ExpandInfoNode>();
//
Deque<Object> elementStack = new LinkedList<Object>();
// record entities
Map<ExpandInfoNode, XSDTypeDefinition> expandedRoots = new HashMap<ExpandInfoNode, XSDTypeDefinition>();
for (Object obj : xsdDeclarations) {
XSDTypeDefinition type = (XSDTypeDefinition) obj;
String name = type.getName();
for (ExpandInfoNode node : expandedTypes) {
if (name.equals(node.name)) {
expandedRoots.put(node, type);
result.add(type);
// /
nodeStack.add(node);
// /
elementStack.add(type);
break;
}
}
}
while (!nodeStack.isEmpty() && !elementStack.isEmpty()) {
ExpandInfoNode node = nodeStack.pollFirst();
Object element = elementStack.pollFirst();
List<ExpandInfoNode> nodes = node.childs;
Object[] elementChildren = getChildren(element, contentProvider);
if (nodes != null && nodes.size() > 0 && elementChildren != null) {
Map<ExpandInfoNode, Object> nodeElementPairs = getNodeElementPairs(elementChildren, nodes);
for (ExpandInfoNode node2 : nodeElementPairs.keySet()) {
nodeStack.add(node2);
elementStack.add(nodeElementPairs.get(node2));
result.add(nodeElementPairs.get(node2));
}
}
}
return result.toArray();
}
Aggregations