Search in sources :

Example 1 with CategoriesContainer

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[] {};
}
Also used : CategoriesContainer(org.obeonetwork.dsl.requirement.CategoriesContainer) Category(org.obeonetwork.dsl.requirement.Category) ArrayList(java.util.ArrayList) EObject(org.eclipse.emf.ecore.EObject)

Example 2 with CategoriesContainer

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;
}
Also used : CategoriesContainer(org.obeonetwork.dsl.requirement.CategoriesContainer) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList)

Example 3 with CategoriesContainer

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);
        }
    }
    ;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) CategoriesContainer(org.obeonetwork.dsl.requirement.CategoriesContainer) Category(org.obeonetwork.dsl.requirement.Category) CategorySelectionDialog(org.obeonetwork.dsl.requirement.design.selection.CategorySelectionDialog) EObject(org.eclipse.emf.ecore.EObject)

Example 4 with CategoriesContainer

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);
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) CategoriesContainer(org.obeonetwork.dsl.requirement.CategoriesContainer) CategorySelectionDialog(org.obeonetwork.dsl.requirement.design.selection.CategorySelectionDialog) EObject(org.eclipse.emf.ecore.EObject)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)4 CategoriesContainer (org.obeonetwork.dsl.requirement.CategoriesContainer)4 ArrayList (java.util.ArrayList)2 Shell (org.eclipse.swt.widgets.Shell)2 Category (org.obeonetwork.dsl.requirement.Category)2 CategorySelectionDialog (org.obeonetwork.dsl.requirement.design.selection.CategorySelectionDialog)2