use of org.eclipse.jface.viewers.ViewerFilter in project InformationSystem by ObeoNetwork.
the class MetadatasPropertiesEditionPartForm method createMetadataTableComposition.
/**
* @param container
*/
protected Composite createMetadataTableComposition(FormToolkit widgetFactory, Composite container) {
Composite tableContainer = widgetFactory.createComposite(container, SWT.NONE);
GridLayout tableContainerLayout = new GridLayout();
GridData tableContainerData = new GridData(GridData.FILL_BOTH);
tableContainerData.horizontalSpan = 3;
tableContainer.setLayoutData(tableContainerData);
tableContainerLayout.numColumns = 2;
tableContainer.setLayout(tableContainerLayout);
org.eclipse.swt.widgets.Table tableMetadata = widgetFactory.createTable(tableContainer, SWT.FULL_SELECTION | SWT.BORDER);
tableMetadata.setHeaderVisible(true);
GridData gdMetadata = new GridData();
gdMetadata.grabExcessHorizontalSpace = true;
gdMetadata.horizontalAlignment = GridData.FILL;
gdMetadata.grabExcessVerticalSpace = true;
gdMetadata.verticalAlignment = GridData.FILL;
tableMetadata.setLayoutData(gdMetadata);
tableMetadata.setLinesVisible(true);
// Start of user code for columns definition for Metadata
TableColumn title = new TableColumn(tableMetadata, SWT.NONE);
title.setWidth(120);
// $NON-NLS-1$
title.setText("title");
TableColumn body = new TableColumn(tableMetadata, SWT.NONE);
body.setWidth(300);
// $NON-NLS-1$
body.setText("body");
// End of user code
metadata = new TableViewer(tableMetadata);
metadata.setContentProvider(new ArrayContentProvider());
metadata.setLabelProvider(new ITableLabelProvider() {
// Start of user code for label provider definition for Metadata
public String getColumnText(Object object, int columnIndex) {
if (object instanceof Annotation) {
Annotation annot = (Annotation) object;
switch(columnIndex) {
case 0:
return annot.getTitle();
case 1:
return annot.getBody();
}
}
// $NON-NLS-1$
return "";
}
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
// End of user code
public void addListener(ILabelProviderListener listener) {
}
public void dispose() {
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void removeListener(ILabelProviderListener listener) {
}
});
metadata.getTable().addListener(SWT.MouseDoubleClick, new Listener() {
public void handleEvent(Event event) {
if (metadata.getSelection() instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) metadata.getSelection();
if (selection.getFirstElement() instanceof EObject) {
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(MetadatasPropertiesEditionPartForm.this, EnvironmentViewsRepository.Metadatas.Properties.metadata, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, selection.getFirstElement()));
metadata.refresh();
}
}
}
});
GridData metadataData = new GridData(GridData.FILL_HORIZONTAL);
metadataData.minimumHeight = 120;
metadataData.heightHint = 120;
metadata.getTable().setLayoutData(metadataData);
for (ViewerFilter filter : this.metadataFilters) {
metadata.addFilter(filter);
}
EditingUtils.setID(metadata.getTable(), EnvironmentViewsRepository.Metadatas.Properties.metadata);
// $NON-NLS-1$
EditingUtils.setEEFtype(metadata.getTable(), "eef::TableComposition::field");
createMetadataPanel(widgetFactory, tableContainer);
// End of user code
return container;
}
use of org.eclipse.jface.viewers.ViewerFilter in project InformationSystem by ObeoNetwork.
the class MetadatasPropertiesEditionPartImpl method createMetadataTableComposition.
/**
* @param container
*/
protected Composite createMetadataTableComposition(Composite container) {
Composite tableContainer = new Composite(container, SWT.NONE);
GridLayout tableContainerLayout = new GridLayout();
GridData tableContainerData = new GridData(GridData.FILL_BOTH);
tableContainerData.horizontalSpan = 3;
tableContainer.setLayoutData(tableContainerData);
tableContainerLayout.numColumns = 2;
tableContainer.setLayout(tableContainerLayout);
org.eclipse.swt.widgets.Table tableMetadata = new org.eclipse.swt.widgets.Table(tableContainer, SWT.FULL_SELECTION);
tableMetadata.setHeaderVisible(true);
GridData gdMetadata = new GridData();
gdMetadata.grabExcessHorizontalSpace = true;
gdMetadata.horizontalAlignment = GridData.FILL;
gdMetadata.grabExcessVerticalSpace = true;
gdMetadata.verticalAlignment = GridData.FILL;
tableMetadata.setLayoutData(gdMetadata);
tableMetadata.setLinesVisible(true);
// Start of user code for columns definition for Metadata
TableColumn title = new TableColumn(tableMetadata, SWT.NONE);
title.setWidth(120);
// $NON-NLS-1$
title.setText("title");
TableColumn body = new TableColumn(tableMetadata, SWT.NONE);
body.setWidth(300);
// $NON-NLS-1$
body.setText("body");
// End of user code
metadata = new TableViewer(tableMetadata);
metadata.setContentProvider(new ArrayContentProvider());
metadata.setLabelProvider(new ITableLabelProvider() {
// Start of user code for label provider definition for Metadata
public String getColumnText(Object object, int columnIndex) {
if (object instanceof Annotation) {
Annotation annot = (Annotation) object;
switch(columnIndex) {
case 0:
return annot.getTitle();
case 1:
return annot.getBody();
}
}
// $NON-NLS-1$
return "";
}
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
// End of user code
public void addListener(ILabelProviderListener listener) {
}
public void dispose() {
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void removeListener(ILabelProviderListener listener) {
}
});
metadata.getTable().addListener(SWT.MouseDoubleClick, new Listener() {
public void handleEvent(Event event) {
if (metadata.getSelection() instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) metadata.getSelection();
if (selection.getFirstElement() instanceof EObject) {
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(MetadatasPropertiesEditionPartImpl.this, EnvironmentViewsRepository.Metadatas.Properties.metadata, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, selection.getFirstElement()));
metadata.refresh();
}
}
}
});
GridData metadataData = new GridData(GridData.FILL_HORIZONTAL);
metadataData.minimumHeight = 120;
metadataData.heightHint = 120;
metadata.getTable().setLayoutData(metadataData);
for (ViewerFilter filter : this.metadataFilters) {
metadata.addFilter(filter);
}
EditingUtils.setID(metadata.getTable(), EnvironmentViewsRepository.Metadatas.Properties.metadata);
// $NON-NLS-1$
EditingUtils.setEEFtype(metadata.getTable(), "eef::TableComposition::field");
createMetadataPanel(tableContainer);
// End of user code
return container;
}
use of org.eclipse.jface.viewers.ViewerFilter in project InformationSystem by ObeoNetwork.
the class MetadataCptPropertiesEditionComponent 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);
if (editingPart instanceof CompositePropertiesEditionPart) {
((CompositePropertiesEditionPart) editingPart).getSettings().add(metadataSettings);
}
final ObeoDSMObject obeoDSMObject = (ObeoDSMObject) elt;
final MetadatasPropertiesEditionPart metadatasPart = (MetadatasPropertiesEditionPart) editingPart;
// init values
if (isAccessible(EnvironmentViewsRepository.Metadatas.Properties.metadata)) {
metadataSettings = new ReferencesTableSettings(obeoDSMObject, EnvironmentPackage.eINSTANCE.getObeoDSMObject_Metadatas(), EnvironmentPackage.eINSTANCE.getMetaDataContainer_Metadatas());
metadatasPart.initMetadata(metadataSettings);
}
// init filters
if (isAccessible(EnvironmentViewsRepository.Metadatas.Properties.metadata)) {
metadatasPart.addFilterToMetadata(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) {
if (element instanceof String)
// $NON-NLS-1$
return element.equals("");
if (element instanceof MetaData)
return true;
return element instanceof Resource;
}
});
// Start of user code for additional businessfilters for metadata
// End of user code
}
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
use of org.eclipse.jface.viewers.ViewerFilter in project InformationSystem by ObeoNetwork.
the class DtoDtoPropertiesEditionComponent 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 DTO dTO = (DTO) elt;
final DtoPropertiesEditionPart dtoPart = (DtoPropertiesEditionPart) editingPart;
// init values
if (isAccessible(EnvironmentViewsRepository.Dto.Properties.name))
dtoPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, dTO.getName()));
if (isAccessible(EnvironmentViewsRepository.Dto.Properties.supertype)) {
// init part
supertypeSettings = new EObjectFlatComboSettings(dTO, EnvironmentPackage.eINSTANCE.getStructuredType_Supertype());
dtoPart.initSupertype(supertypeSettings);
// set the button mode
dtoPart.setSupertypeButtonMode(ButtonsModeEnum.BROWSE);
}
if (isAccessible(EnvironmentViewsRepository.Dto.Properties.description))
dtoPart.setDescription(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, dTO.getDescription()));
if (isAccessible(EnvironmentViewsRepository.Dto.Properties.associatedTypes)) {
associatedTypesSettings = new ReferencesTableSettings(dTO, EnvironmentPackage.eINSTANCE.getStructuredType_AssociatedTypes());
dtoPart.initAssociatedTypes(associatedTypesSettings);
}
if (isAccessible(EnvironmentViewsRepository.Dto.Properties.supertype)) {
dtoPart.addFilterToSupertype(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 StructuredType);
}
});
// Start of user code for additional businessfilters for supertype
// End of user code
}
if (isAccessible(EnvironmentViewsRepository.Dto.Properties.associatedTypes)) {
dtoPart.addFilterToAssociatedTypes(new EObjectFilter(EnvironmentPackage.Literals.STRUCTURED_TYPE));
// Start of user code for additional businessfilters for associatedTypes
// End of user code
}
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
use of org.eclipse.jface.viewers.ViewerFilter in project InformationSystem by ObeoNetwork.
the class EnumerationEnumerationPropertiesEditionComponent 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 Enumeration enumeration = (Enumeration) elt;
final EnumerationPropertiesEditionPart enumerationPart = (EnumerationPropertiesEditionPart) editingPart;
// init values
if (isAccessible(EnvironmentViewsRepository.Enumeration.Properties.name))
enumerationPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, enumeration.getName()));
if (isAccessible(EnvironmentViewsRepository.Enumeration.Properties.literals)) {
literalsSettings = new ReferencesTableSettings(enumeration, EnvironmentPackage.eINSTANCE.getEnumeration_Literals());
enumerationPart.initLiterals(literalsSettings);
}
if (isAccessible(EnvironmentViewsRepository.Enumeration.Properties.description))
enumerationPart.setDescription(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, enumeration.getDescription()));
if (isAccessible(EnvironmentViewsRepository.Enumeration.Properties.literals)) {
enumerationPart.addFilterToLiterals(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) {
return (element instanceof Literal);
}
});
// Start of user code for additional businessfilters for literals
// End of user code
}
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
Aggregations