Search in sources :

Example 1 with IDocumentable

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;
}
Also used : IDocumentable(com.archimatetool.model.IDocumentable) IIdentifier(com.archimatetool.model.IIdentifier) INameable(com.archimatetool.model.INameable) EObject(org.eclipse.emf.ecore.EObject) IArchimateConcept(com.archimatetool.model.IArchimateConcept) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IArchimateModel(com.archimatetool.model.IArchimateModel)

Example 2 with IDocumentable

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);
}
Also used : IDocumentable(com.archimatetool.model.IDocumentable) IProperty(com.archimatetool.model.IProperty) INameable(com.archimatetool.model.INameable) IProperties(com.archimatetool.model.IProperties)

Aggregations

IDocumentable (com.archimatetool.model.IDocumentable)2 INameable (com.archimatetool.model.INameable)2 IArchimateConcept (com.archimatetool.model.IArchimateConcept)1 IArchimateModel (com.archimatetool.model.IArchimateModel)1 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)1 IIdentifier (com.archimatetool.model.IIdentifier)1 IProperties (com.archimatetool.model.IProperties)1 IProperty (com.archimatetool.model.IProperty)1 EObject (org.eclipse.emf.ecore.EObject)1