use of org.obeonetwork.dsl.requirement.CategoriesContainer in project InformationSystem by ObeoNetwork.
the class CategoriesTreeContentProvider method getChildren.
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof CategoriesContainer) {
CategoriesContainer categoriesContainer = (CategoriesContainer) parentElement;
List<Category> ownedCategories = new ArrayList<Category>(categoriesContainer.getOwnedCategories());
ownedCategories.removeAll(hiddenCategories);
Collections.sort(ownedCategories, CategoryComparator.INSTANCE);
return ownedCategories.toArray();
}
return new Object[] {};
}
use of org.obeonetwork.dsl.requirement.CategoriesContainer in project InformationSystem by ObeoNetwork.
the class CategoriesTreeContentProvider method getRootCategoriesContainers.
private Collection<CategoriesContainer> getRootCategoriesContainers(Session session) {
Collection<CategoriesContainer> categoriesContainers = new ArrayList<CategoriesContainer>();
Collection<EObject> roots = getRootObjects(session);
for (EObject root : roots) {
if (root instanceof CategoriesContainer) {
categoriesContainers.add((CategoriesContainer) root);
}
}
return categoriesContainers;
}
use of org.obeonetwork.dsl.requirement.CategoriesContainer in project InformationSystem by ObeoNetwork.
the class RequirementsServices method copyCategory.
/**
* CopyCategory.
*
* @param category
*/
public void copyCategory(Category category) {
Shell shell = getShell();
CategorySelectionDialog dlg = new CategorySelectionDialog(shell, "Copy a category", "Select a container for the new category");
dlg.setInput(SessionManager.INSTANCE.getSession(category));
dlg.setInitialSelection(category.eContainer());
if (dlg.open() == Window.OK) {
Object selectedObject = dlg.getFirstResult();
if (selectedObject instanceof CategoriesContainer) {
CategoriesContainer newContainer = (CategoriesContainer) selectedObject;
// Check if there are referenced objects
boolean keepReferencedObject = false;
if (!category.getReferencedObject().isEmpty()) {
keepReferencedObject = MessageDialog.openQuestion(shell, "Referenced objects", "Do you want to keep the referenced objects ?");
}
// Copy object
Category newCategory = EcoreUtil.copy(category);
newCategory.setId(getNewIdForCopiedCategory(newContainer, newCategory));
if (!keepReferencedObject) {
newCategory.getReferencedObject().clear();
}
// Add to parent
addToCategoriesContainer(newContainer, newCategory);
}
}
;
}
use of org.obeonetwork.dsl.requirement.CategoriesContainer in project InformationSystem by ObeoNetwork.
the class RequirementsServices method moveCategory.
/**
* Move Category.
*
* @param category
*/
public void moveCategory(Category category) {
Shell shell = getShell();
CategorySelectionDialog dlg = new CategorySelectionDialog(shell, "Move a category", "Select a new container for the category", category);
dlg.setInput(SessionManager.INSTANCE.getSession(category));
dlg.setInitialSelection(category.eContainer());
if (dlg.open() == Window.OK) {
Object selectedObject = dlg.getFirstResult();
if (selectedObject instanceof CategoriesContainer) {
CategoriesContainer newContainer = (CategoriesContainer) selectedObject;
// Add to parent
addToCategoriesContainer(newContainer, category);
}
}
}
Aggregations