use of org.talend.mdm.repository.models.FolderRepositoryObject in project tmdm-studio-se by Talend.
the class RepositoryViewObjectCheckedWidget method getSelectedCommands.
public List<AbstractDeployCommand> getSelectedCommands() {
List<AbstractDeployCommand> commands = new LinkedList<AbstractDeployCommand>();
CommandManager commandManager = CommandManager.getInstance();
for (Object obj : treeViewer.getCheckedElements()) {
if (obj instanceof FolderRepositoryObject) {
continue;
}
IRepositoryViewObject viewObject = (IRepositoryViewObject) obj;
String id = viewObject.getId();
AbstractDeployCommand e = cmdMap.get(id);
if (e == null) {
List<IRepositoryViewObject> objs = new ArrayList<IRepositoryViewObject>();
objs.add(viewObject);
List<AbstractDeployCommand> newCommands = commandManager.getDeployCommands(objs, ICommand.CMD_MODIFY);
if (!newCommands.isEmpty()) {
e = newCommands.get(0);
}
}
commands.add(e);
List<AbstractDeployCommand> associatedCommands = getAssociatedObjectCommand(viewObject, ICommand.CMD_MODIFY);
if (associatedCommands != null) {
commands.addAll(associatedCommands);
}
}
return commands;
}
use of org.talend.mdm.repository.models.FolderRepositoryObject in project tmdm-studio-se by Talend.
the class RepositoryViewObjectCheckedWidget method initWidget.
private void initWidget() {
//
setLayout(new GridLayout());
treeViewer = new ContainerCheckedTreeViewer(this, SWT.BORDER | SWT.FULL_SELECTION);
Tree tree = getTree();
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
installColumns();
treeViewer.setContentProvider(new ContentProvider());
treeViewer.getTree().addListener(SWT.PaintItem, new Listener() {
public void handleEvent(Event event) {
TreeItem item = (TreeItem) event.item;
Object data = item.getData();
if (data != null && lockedViewObjs.contains(data)) {
String text = item.getText(event.index);
Point point = event.gc.textExtent(text);
int y = event.y + point.y / 2 + 2;
int x = event.x + 20;
event.gc.drawLine(x, y, x + point.x, y);
event.gc.drawText(Messages.RepositoryViewObjectCheckedWidget_lock, x + point.x + 2, event.y + 2);
}
}
});
treeViewer.addCheckStateListener(new ICheckStateListener() {
private void checkSubElement(IRepositoryViewObject viewObj) {
if (viewObj instanceof FolderRepositoryObject) {
Item item = viewObj.getProperty().getItem();
List<IRepositoryViewObject> children = RepositoryResourceUtil.findViewObjects(viewObj.getRepositoryObjectType(), item, true, true);
if (children != null) {
for (IRepositoryViewObject child : children) {
checkSubElement(child);
}
}
} else {
if (lockedViewObjs.contains(viewObj)) {
treeViewer.setChecked(viewObj, false);
}
}
}
public void checkStateChanged(CheckStateChangedEvent event) {
Object element = event.getElement();
if (element instanceof IRepositoryViewObject) {
checkSubElement((IRepositoryViewObject) element);
}
}
});
if (adapter != null) {
treeViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
updateSeverityCount();
}
});
}
treeViewer.addFilter(new ViewerFilter() {
private boolean containVisibleElement(FolderRepositoryObject parent) {
Item item = parent.getProperty().getItem();
List<IRepositoryViewObject> children = RepositoryResourceUtil.findViewObjects(parent.getRepositoryObjectType(), item, true, true);
boolean result = false;
for (IRepositoryViewObject viewObj : children) {
if (viewObj instanceof FolderRepositoryObject) {
boolean r = containVisibleElement((FolderRepositoryObject) viewObj);
if (r) {
result = true;
}
} else if (viewObj instanceof IRepositoryViewObject) {
if (isVisibleViewObj(viewObj)) {
updateServerDef(viewObj);
// updateLockedObject(viewObj);
result = true;
}
}
}
return result;
}
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (reconciliation) {
return true;
} else {
if (element instanceof FolderRepositoryObject) {
return containVisibleElement((FolderRepositoryObject) element);
} else {
IRepositoryViewObject viewObj = (IRepositoryViewObject) element;
return isVisibleViewObj(viewObj);
}
}
}
});
// show time
final Button showTimestampBun = new Button(this, SWT.CHECK);
showTimestampBun.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
showTimeStampColumns(showTimestampBun.getSelection());
}
});
showTimestampBun.setText(Messages.ConsistencyConflict_showTimeStampColumn);
//
treeViewer.setInput(input);
selectAll(true);
treeViewer.expandAll();
if (adapter != null) {
adapter.initSeverityControl(this);
}
updateSeverityCount();
}
use of org.talend.mdm.repository.models.FolderRepositoryObject in project tmdm-studio-se by Talend.
the class MDMExportRepositoryItemsWizard method recursiveExpand.
private boolean recursiveExpand(TreeItem[] items, List<IRepositoryViewObject> leafItems) {
boolean expanda = false;
for (TreeItem item : items) {
IRepositoryViewObject viewObj = (IRepositoryViewObject) item.getData();
if (leafItems.contains(viewObj)) {
expanda = true;
break;
}
if (viewObj instanceof FolderRepositoryObject) {
boolean expand = recursiveExpand(item.getItems(), leafItems);
item.setExpanded(expand);
if (expand) {
expanda = true;
}
}
}
return expanda;
}
use of org.talend.mdm.repository.models.FolderRepositoryObject in project tmdm-studio-se by Talend.
the class MDMExportRepositoryItemsWizard method getCheckedViewObjects.
private void getCheckedViewObjects(IStructuredSelection sel, List<IRepositoryViewObject> leafItems, List<IRepositoryViewObject> noneLeafItems) {
Map<String, List<IRepositoryViewObject>> viewObjTypeMap = new TreeMap<String, List<IRepositoryViewObject>>();
Map<String, List<String>> pathMap = new HashMap<String, List<String>>();
Map<String, ERepositoryObjectType> types = new HashMap<String, ERepositoryObjectType>();
List<IRepositoryViewObject> seList = sel.toList();
for (IRepositoryViewObject iRepositoryViewObject : seList) {
IRepositoryViewObject viewObj = iRepositoryViewObject;
ERepositoryObjectType repositoryObjectType = viewObj.getRepositoryObjectType();
if (repositoryObjectType != null) {
List<IRepositoryViewObject> list = viewObjTypeMap.get(repositoryObjectType.name());
List<String> typePaths = pathMap.get(repositoryObjectType.name());
if (list == null) {
list = new LinkedList<IRepositoryViewObject>();
viewObjTypeMap.put(repositoryObjectType.name(), list);
typePaths = new LinkedList<String>();
pathMap.put(repositoryObjectType.name(), typePaths);
types.put(repositoryObjectType.name(), repositoryObjectType);
}
list.add(viewObj);
typePaths.add(viewObj.getPath());
}
}
List<IRepositoryViewObject> childs = new LinkedList<IRepositoryViewObject>();
for (String etype : types.keySet()) {
List<IRepositoryViewObject> viewObjectsWithDeleted = getAllViewObjectByType(types.get(etype));
for (IRepositoryViewObject vObject : viewObjectsWithDeleted) {
List<String> pathList = pathMap.get(etype);
for (int i = 0; i < pathList.size(); i++) {
if (vObject.getPath().equals(pathList.get(i))) {
IRepositoryViewObject vo = viewObjTypeMap.get(etype).get(i);
if (vo instanceof FolderRepositoryObject && !(vObject instanceof FolderRepositoryObject)) {
childs.add(vObject);
break;
}
} else if (vObject.getPath().contains(pathList.get(i)) && viewObjTypeMap.get(etype).get(i) instanceof FolderRepositoryObject) {
childs.add(vObject);
break;
}
}
}
}
childs.addAll(seList);
for (int i = 0; i < childs.size(); i++) {
if (childs.get(i) instanceof FolderRepositoryObject) {
noneLeafItems.add(childs.get(i));
} else {
leafItems.add(childs.get(i));
}
}
}
use of org.talend.mdm.repository.models.FolderRepositoryObject in project tmdm-studio-se by Talend.
the class TreeViewerListener method treeCollapsed.
@Override
public void treeCollapsed(TreeExpansionEvent event) {
Object element = event.getElement();
if (element instanceof FolderRepositoryObject) {
FolderRepositoryObject fro = (FolderRepositoryObject) element;
String path = fro.getPath();
if (!path.isEmpty()) {
TreeItem item = getObject(viewer.getTree(), event.getElement());
if (item != null) {
item.setImage(ImageProvider.getImage(ECoreImage.FOLDER_CLOSE_ICON));
}
}
}
}
Aggregations