use of com.archimatetool.model.IProperty in project archi by archimatetool.
the class UserPropertiesSection method getDropTargetPosition.
private int getDropTargetPosition(DropTargetEvent event) {
int index = -1;
Point pt = fTableViewer.getControl().toControl(event.x, event.y);
if (pt.y < 5) {
index = 0;
} else if (event.item != null) {
IProperty property = (IProperty) event.item.getData();
index = fPropertiesElement.getProperties().indexOf(property);
} else {
index = fPropertiesElement.getProperties().size();
}
// Dropped in after position
int feedback = getDragFeedbackType(event);
if (feedback == DND.FEEDBACK_INSERT_AFTER) {
index += 1;
}
return index;
}
use of com.archimatetool.model.IProperty in project archi by archimatetool.
the class AbstractModelView method getParentToRefreshFromNotification.
/**
* @return The parent folder to refresh when one of its children is added/removed/set
*/
protected Object getParentToRefreshFromNotification(Notification msg) {
int type = msg.getEventType();
EObject element = null;
if (type == Notification.REMOVE) {
if (msg.getNotifier() instanceof EObject) {
element = (EObject) msg.getNotifier();
// Property removed and element has format expression
if (msg.getOldValue() instanceof IProperty && hasFormatExpression(element)) {
element = element.eContainer();
}
}
} else if (type == Notification.ADD) {
if (msg.getNewValue() instanceof EObject) {
element = ((EObject) msg.getNewValue()).eContainer();
// Property added and element has format expression
if (msg.getNewValue() instanceof IProperty && hasFormatExpression(element)) {
element = element.eContainer();
}
}
} else if (type == Notification.SET) {
// Need to refresh parent node on name or label expression change because of using a ViewerSorter
if (msg.getNotifier() instanceof EObject) {
element = ((EObject) msg.getNotifier());
// Name
if (msg.getFeature() == IArchimatePackage.Literals.NAMEABLE__NAME) {
element = element.eContainer();
} else // Ancestor folder has label expression
if (hasFormatExpression(element)) {
element = element.eContainer();
// Property set
if (msg.getNotifier() instanceof IProperty) {
element = element.eContainer();
}
}
}
}
return (element instanceof IFolder) ? element : null;
}
use of com.archimatetool.model.IProperty in project archi by archimatetool.
the class PropertiesRenderer method getAllProperties.
private String getAllProperties(IProperties object, boolean full) {
String s = "";
for (int i = 0; i < object.getProperties().size(); i++) {
IProperty property = object.getProperties().get(i);
if (full) {
s += property.getKey() + ": ";
}
s += property.getValue();
if (i < object.getProperties().size() - 1) {
s += "\n";
}
}
return s;
}
use of com.archimatetool.model.IProperty in project archi by archimatetool.
the class PropertiesRenderer method renderPropertyValue.
private String renderPropertyValue(IArchimateModelObject object, String text) {
Matcher matcher = PROPERTY_VALUE_PATTERN.matcher(text);
while (matcher.find()) {
String prefix = matcher.group(1);
String key = matcher.group(2);
String propertyValue = "";
IArchimateModelObject refObject = getObjectFromPrefix(object, prefix);
if (refObject instanceof IProperties) {
IProperty property = getProperty((IProperties) refObject, key);
if (property != null) {
propertyValue = property.getValue();
}
}
text = text.replace(matcher.group(), propertyValue);
}
return text;
}
use of com.archimatetool.model.IProperty 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());
// Normalise in case of multi-line text
name = StringUtils.normaliseNewLineCharacters(name);
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