use of org.obeonetwork.dsl.requirement.Category in project InformationSystem by ObeoNetwork.
the class CategoryPropertiesEditionComponent method initPart.
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
* org.eclipse.emf.ecore.resource.ResourceSet)
*/
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
setInitializing(true);
if (editingPart != null && key == partKey) {
editingPart.setContext(elt, allResource);
final Category category = (Category) elt;
final CategoryPropertiesEditionPart categoryPart = (CategoryPropertiesEditionPart) editingPart;
// init values
if (isAccessible(RequirementViewsRepository.Category.Category_.id))
categoryPart.setId(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, category.getId()));
if (isAccessible(RequirementViewsRepository.Category.Category_.name))
categoryPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, category.getName()));
if (isAccessible(RequirementViewsRepository.Category.Category_.requirements)) {
requirementsSettings = new ReferencesTableSettings(category, RequirementPackage.eINSTANCE.getCategory_Requirements());
categoryPart.initRequirements(requirementsSettings);
}
if (isAccessible(RequirementViewsRepository.Category.Category_.subCategories)) {
subCategoriesSettings = new ReferencesTableSettings(category, RequirementPackage.eINSTANCE.getCategory_SubCategories());
categoryPart.initSubCategories(subCategoriesSettings);
}
if (isAccessible(RequirementViewsRepository.Category.Category_.requirements)) {
categoryPart.addFilterToRequirements(new ViewerFilter() {
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public boolean select(Viewer viewer, Object parentElement, Object element) {
// $NON-NLS-1$
return (element instanceof String && element.equals("")) || (element instanceof Requirement);
}
});
// Start of user code for additional businessfilters for requirements
// End of user code
}
if (isAccessible(RequirementViewsRepository.Category.Category_.subCategories)) {
categoryPart.addFilterToSubCategories(new ViewerFilter() {
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public boolean select(Viewer viewer, Object parentElement, Object element) {
// $NON-NLS-1$
return (element instanceof String && element.equals("")) || (element instanceof Category);
}
});
// Start of user code for additional businessfilters for subCategories
// End of user code
}
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
use of org.obeonetwork.dsl.requirement.Category in project InformationSystem by ObeoNetwork.
the class RequirementEditingOperation method doExecute.
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.runtime.impl.operation.WizardEditingOperation#doExecute(org.eclipse.core.runtime.IProgressMonitor,
* org.eclipse.core.runtime.IAdaptable)
*/
@Override
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
editingContext.initializeRecorder();
RequirementEditingWizard wizard = new RequirementEditingWizard(editingContext, editingContext.getAdapterFactory(), editingContext.getEObject());
EEFWizardDialog wDialog = new EEFWizardDialog(EditingUtils.getShell(), wizard);
int open = wDialog.open();
ChangeDescription description = editingContext.getChangeRecorder().endRecording();
if (open == Window.OK) {
if (wizard.getOwningCategory() != null) {
Category category = wizard.getOwningCategory();
if (editingContext.getEObject().eContainer() != category) {
category.getRequirements().add((Requirement) editingContext.getEObject());
}
}
return Status.OK_STATUS;
} else {
description.applyAndReverse();
return Status.CANCEL_STATUS;
}
}
use of org.obeonetwork.dsl.requirement.Category in project InformationSystem by ObeoNetwork.
the class CategorySelectionPage method createControl.
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
Composite control = new Composite(parent, SWT.NONE);
GridData gd = new GridData(GridData.FILL_BOTH);
control.setLayoutData(gd);
GridLayout layout = new GridLayout();
control.setLayout(layout);
Label intro = new Label(control, SWT.NONE);
// $NON-NLS-1$
intro.setText(RequirementLinkerPlugin.getInstance().getString("CategorySelectionPage_label"));
GridData labelData = new GridData(GridData.FILL_HORIZONTAL);
intro.setLayoutData(labelData);
categoriesViewer = new TreeViewer(control);
categoriesViewer.getControl().setLayoutData(gd);
AdapterFactory adapterFactory = ViewHelper.INSTANCE.createAdapterFactory();
categoriesViewer.setLabelProvider(new LinkedRequirementsLabelProvider(adapterFactory));
categoriesViewer.setContentProvider(new RequirementsRepositoriesContentProvider(adapterFactory) {
@Override
public Object[] getChildren(Object object) {
if (object instanceof Category) {
return ((Category) object).getSubCategories().toArray();
}
return super.getChildren(object);
}
@Override
public boolean hasChildren(Object object) {
if (object instanceof Category) {
return !((Category) object).getSubCategories().isEmpty();
}
return super.hasChildren(object);
}
});
categoriesViewer.setInput(getInput());
categoriesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
EObject selection = getTreeviewSelection();
if (selection instanceof Category) {
selectedCategory = (Category) selection;
setPageComplete(true);
} else {
setPageComplete(false);
}
createCategorie.setEnabled(selection instanceof Category || selection instanceof Repository);
}
});
createCategorie = new Button(control, SWT.PUSH);
createCategorie.setText(// $NON-NLS-1$
RequirementLinkerPlugin.getInstance().getString("CategorySelectionPage_CreateCategoryButton_title"));
createCategorie.addSelectionListener(new SelectionAdapter() {
/**
* {@inheritDoc}
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
InputDialog dialog = new InputDialog(getShell(), RequirementLinkerPlugin.getInstance().getString(// $NON-NLS-1$
"CategorySelectionPage_CreateCategoryDialog_title"), RequirementLinkerPlugin.getInstance().getString(// $NON-NLS-1$
"CategorySelectionPage_CreateCategoryDialog_description"), RequirementLinkerPlugin.getInstance().getString(// $NON-NLS-1$
"CategorySelectionPage_CreateCategoryDialog_defaultvalue"), null);
int open = dialog.open();
if (open == Window.OK) {
Category category = RequirementFactory.eINSTANCE.createCategory();
category.setName(dialog.getValue());
if (getTreeviewSelection() instanceof Category) {
((Category) getTreeviewSelection()).getSubCategories().add(category);
} else if (getTreeviewSelection() instanceof Repository) {
((Repository) getTreeviewSelection()).getMainCategories().add(category);
}
}
}
});
createCategorie.setEnabled(false);
if (currentValue != null) {
categoriesViewer.reveal(currentValue);
categoriesViewer.setSelection(new StructuredSelection(currentValue));
}
setControl(control);
}
use of org.obeonetwork.dsl.requirement.Category in project InformationSystem by ObeoNetwork.
the class RequirementsRepositoriesContentProvider method getChildren.
@Override
public Object[] getChildren(Object object) {
if (object instanceof Resource) {
List<Repository> repositories = new ArrayList<Repository>();
// Get Repository instances
for (EObject child : ((Resource) object).getContents()) {
if (child instanceof Repository) {
repositories.add((Repository) child);
}
}
return repositories.toArray();
} else if (object instanceof Repository) {
Repository repository = (Repository) object;
// Get categories
List<Object> children = new ArrayList<Object>();
children.addAll(repository.getOwnedCategories());
// Get requirements
children.addAll(repository.getOwnedRequirements());
return children.toArray();
} else if (object instanceof Category) {
Category category = (Category) object;
List<Object> children = new ArrayList<Object>();
children.addAll(category.getOwnedCategories());
children.addAll(category.getOwnedRequirements());
return children.toArray();
}
return new Object[] {};
}
use of org.obeonetwork.dsl.requirement.Category 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[] {};
}
Aggregations