use of com.archimatetool.model.IDocumentable in project archi by archimatetool.
the class FieldDataFactory method getFieldValue.
public static Object getFieldValue(Object dataElement, String fieldName) {
if ("this".equals(fieldName)) {
// $NON-NLS-1$
return dataElement;
}
if ("id".equals(fieldName) && dataElement instanceof IIdentifier) {
// $NON-NLS-1$
return ((IIdentifier) dataElement).getId();
}
if ("name".equals(fieldName) && dataElement instanceof INameable) {
// $NON-NLS-1$
String name = ((INameable) dataElement).getName();
if (name == null || "".equals(name)) {
// $NON-NLS-1$
name = ArchiLabelProvider.INSTANCE.getDefaultName(((EObject) dataElement).eClass());
}
return name;
}
if ("type".equals(fieldName) && dataElement instanceof EObject) {
// $NON-NLS-1$
return ArchiLabelProvider.INSTANCE.getDefaultName(((EObject) dataElement).eClass());
}
if ("documentation".equals(fieldName) && dataElement instanceof IDocumentable) {
// $NON-NLS-1$
String s = ((IDocumentable) dataElement).getDocumentation();
return StringUtils.isSet(s) ? s : null;
}
if ("purpose".equals(fieldName) && dataElement instanceof IArchimateModel) {
// $NON-NLS-1$
String s = ((IArchimateModel) dataElement).getPurpose();
return StringUtils.isSet(s) ? s : null;
}
if ("relation_source".equals(fieldName) && dataElement instanceof IArchimateRelationship) {
// $NON-NLS-1$
IArchimateRelationship relation = (IArchimateRelationship) dataElement;
IArchimateConcept source = relation.getSource();
String s = source.getName();
return StringUtils.isSet(s) ? s : null;
}
if ("relation_target".equals(fieldName) && dataElement instanceof IArchimateRelationship) {
// $NON-NLS-1$
IArchimateRelationship relation = (IArchimateRelationship) dataElement;
IArchimateConcept target = relation.getTarget();
String s = target.getName();
return StringUtils.isSet(s) ? s : null;
}
return null;
}
use of com.archimatetool.model.IDocumentable in project archi by archimatetool.
the class SearchFilter method matchesFilter.
/**
* Query whether element matches filter criteria when filtering on node/leaf elements
* @param element Any element, children will not be queried.
* @return
*/
public boolean matchesFilter(Object element) {
// EObject Type filter - do this first as the master filter
if (isObjectFiltered(element)) {
return false;
}
boolean textSearchResult = false;
boolean propertyKeyResult = false;
// Properties Key filter
if (isFilteringPropertyKeys() && element instanceof IProperties) {
for (IProperty property : ((IProperties) element).getProperties()) {
if (fPropertiesFilter.contains(property.getKey())) {
propertyKeyResult = true;
if (hasSearchText() && property.getValue().toLowerCase().contains(fSearchText.toLowerCase())) {
textSearchResult = true;
}
}
}
}
// If has search Text and no text found yet
if (hasSearchText()) {
// Name...
if (fFilterName && !textSearchResult && element instanceof INameable) {
String name = StringUtils.safeString(((INameable) element).getName());
if (name.toLowerCase().contains(fSearchText.toLowerCase())) {
textSearchResult = true;
}
}
// Then Documentation
if (fFilterDocumentation && !textSearchResult && element instanceof IDocumentable) {
String text = StringUtils.safeString(((IDocumentable) element).getDocumentation());
if (text.toLowerCase().contains(fSearchText.toLowerCase())) {
textSearchResult = true;
}
}
}
if ((hasSearchText())) {
return textSearchResult;
}
if (isFilteringPropertyKeys()) {
return propertyKeyResult;
}
return !isObjectFiltered(element);
}
Aggregations