Skip to content

Commit

Permalink
allow filtering on the tooltip text
Browse files Browse the repository at this point in the history
this allows more fine grained Glob filtering e.g. on the resource name e.g. using "FROM:*mypackage" which allows to filter reqs and caps based on their underlying resources
Signed-off-by: Christoph Rueger <[email protected]>
  • Loading branch information
chrisrueger committed Dec 7, 2023
1 parent 4d1c6b0 commit 6dca628
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private Object[] filter(Object[] array) {
if (obj instanceof RequirementWrapper rw) {

for (Glob g : globs) {
if (g.matcher(rw.requirement.toString())
if (g.matcher(RequirementWrapperLabelProvider.tooltipText(rw))
.find()) {
filteredResults.add(obj);
return;
Expand All @@ -152,7 +152,7 @@ private Object[] filter(Object[] array) {
else if (obj instanceof Capability cap) {

for (Glob g : globs) {
if (g.matcher(cap.toString())
if (g.matcher(CapabilityLabelProvider.tooltipText(cap))
.find()) {
filteredResults.add(obj);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,40 +44,44 @@ public String getToolTipText(Object element) {
if (element instanceof Capability) {
Capability cap = (Capability) element;

StringBuilder buf = new StringBuilder();

buf.append(cap.getNamespace());

Resource r = cap.getResource();
if (r instanceof SupportingResource sr) {
int index = sr.getSupportingIndex();
if (index >= 0) {
buf.append("Capability from a supporting resource ")
.append(index)
.append(" part of ")
.append(sr.getParent())
.append("\n");
}
}

for (Entry<String, Object> attribute : cap.getAttributes()
.entrySet())
buf.append(";\n\t")
.append(attribute.getKey())
.append(" = ")
.append(attribute.getValue());

for (Entry<String, String> directive : cap.getDirectives()
.entrySet())
buf.append(";\n\t")
.append(directive.getKey())
.append(" := ")
.append(directive.getValue());

return buf.toString();
return tooltipText(cap);
}

return null;
}

static String tooltipText(Capability cap) {
StringBuilder buf = new StringBuilder();

buf.append(cap.getNamespace());

Resource r = cap.getResource();
if (r instanceof SupportingResource sr) {
int index = sr.getSupportingIndex();
if (index >= 0) {
buf.append("Capability from a supporting resource ")
.append(index)
.append(" part of ")
.append(sr.getParent())
.append("\n");
}
}

for (Entry<String, Object> attribute : cap.getAttributes()
.entrySet())
buf.append(";\n\t")
.append(attribute.getKey())
.append(" = ")
.append(attribute.getValue());

for (Entry<String, String> directive : cap.getDirectives()
.entrySet())
buf.append(";\n\t")
.append(directive.getKey())
.append(" := ")
.append(directive.getValue());

return buf.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,54 +64,57 @@ public void update(ViewerCell cell) {

@Override
public String getToolTipText(Object element) {
if (element instanceof RequirementWrapper) {
RequirementWrapper rw = (RequirementWrapper) element;
Requirement req = rw.requirement;

StringBuilder buf = new StringBuilder();
if (rw.resolved)
buf.append("RESOLVED:\n");
if (rw.java)
buf.append("JAVA:\n");

buf.append("FROM: ")
.append(req.getResource())
.append("\n");

Resource r = rw.requirement.getResource();
if (r instanceof SupportingResource sr) {
int index = sr.getSupportingIndex();
if (index >= 0) {
buf.append("Requirement from a supporting resource ")
.append(index)
.append(" part of ")
.append(sr.getParent())
.append("\n");
}
}
buf.append(req.getNamespace());
if (element instanceof RequirementWrapper rw) {
return tooltipText(rw);
}

return null;
}

for (Entry<String, Object> attr : req.getAttributes()
.entrySet())
buf.append(";\n\t")
.append(attr.getKey())
.append(" = ")
.append(attr.getValue());

for (Entry<String, String> directive : req.getDirectives()
.entrySet())
buf.append(";\n\t")
.append(directive.getKey())
.append(" := ")
.append(directive.getValue());
static String tooltipText(RequirementWrapper rw) {
Requirement req = rw.requirement;

StringBuilder buf = new StringBuilder();
if (rw.resolved)
buf.append("RESOLVED:\n");
if (rw.java)
buf.append("JAVA:\n");

buf.append("FROM: ")
.append(req.getResource())
.append("\n");

Resource r = req.getResource();
if (r instanceof SupportingResource sr) {
int index = sr.getSupportingIndex();
if (index >= 0) {
buf.append("Requirement from a supporting resource ")
.append(index)
.append(" part of ")
.append(sr.getParent())
.append("\n");
}
}
buf.append(req.getNamespace());

Resource resource = req.getResource();
for (Entry<String, Object> attr : req.getAttributes()
.entrySet())
buf.append(";\n\t")
.append(attr.getKey())
.append(" = ")
.append(attr.getValue());

return buf.toString();
}
for (Entry<String, String> directive : req.getDirectives()
.entrySet())
buf.append(";\n\t")
.append(directive.getKey())
.append(" := ")
.append(directive.getValue());

return null;
Resource resource = req.getResource();

return buf.toString();
}

}

0 comments on commit 6dca628

Please sign in to comment.