use of org.obeonetwork.dsl.requirement.design.selection.CategorySelectionDialog 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.design.selection.CategorySelectionDialog 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);
}
}
}
use of org.obeonetwork.dsl.requirement.design.selection.CategorySelectionDialog in project InformationSystem by ObeoNetwork.
the class RequirementsServices method copyRequirement.
/**
* Copy Requirement.
*
* @param requirement
*/
public void copyRequirement(Requirement requirement) {
Shell shell = getShell();
CategorySelectionDialog dlg = new CategorySelectionDialog(shell, "Copy a requirement", "Select a container for the new requirement");
dlg.setInput(SessionManager.INSTANCE.getSession(requirement));
dlg.setInitialSelection(requirement.eContainer());
dlg.setValidator(new ISelectionStatusValidator() {
public IStatus validate(Object[] selection) {
if (selection.length > 0 && selection[0] instanceof Category) {
return new Status(IStatus.OK, Activator.PLUGIN_ID, "");
}
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Select a category");
}
});
if (dlg.open() == Window.OK) {
Object selectedObject = dlg.getFirstResult();
if (selectedObject instanceof Category) {
Category newContainer = (Category) selectedObject;
// Check if there are referenced objects
boolean keepReferencedObject = false;
if (!requirement.getReferencedObject().isEmpty()) {
keepReferencedObject = MessageDialog.openQuestion(shell, "Referenced objects", "Do you want to keep the referenced objects ?");
}
// Copy object
Requirement newRequirement = EcoreUtil.copy(requirement);
newRequirement.setId(getNewIdForCopiedRequirement(newContainer, newRequirement));
if (!keepReferencedObject) {
newRequirement.getReferencedObject().clear();
}
// Add to parent
newContainer.getRequirements().add(newRequirement);
}
}
;
}
use of org.obeonetwork.dsl.requirement.design.selection.CategorySelectionDialog in project InformationSystem by ObeoNetwork.
the class RequirementsServices method moveRequirement.
/**
* move Requirement.
*
* @param requirement
*/
public void moveRequirement(Requirement requirement) {
Shell shell = getShell();
CategorySelectionDialog dlg = new CategorySelectionDialog(shell, "Move a requirement", "Select a new container for the requirement");
dlg.setInput(SessionManager.INSTANCE.getSession(requirement));
dlg.setInitialSelection(requirement.eContainer());
dlg.setValidator(new ISelectionStatusValidator() {
public IStatus validate(Object[] selection) {
if (selection.length > 0 && selection[0] instanceof Category) {
return new Status(IStatus.OK, Activator.PLUGIN_ID, "");
}
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Select a category");
}
});
if (dlg.open() == Window.OK) {
Object selectedObject = dlg.getFirstResult();
if (selectedObject instanceof Category) {
Category newContainer = (Category) selectedObject;
// change parent
newContainer.getRequirements().add(requirement);
}
}
;
}
Aggregations