Merge lp:~tapaal-contributor/tapaal/show-query-on-mouse-over-1947037 into lp:tapaal

Proposed by Kristian Morsing Pedersen
Status: Merged
Approved by: Jiri Srba
Approved revision: 1158
Merged at revision: 1157
Proposed branch: lp:~tapaal-contributor/tapaal/show-query-on-mouse-over-1947037
Merge into: lp:tapaal
Diff against target: 45 lines (+27/-4)
1 file modified
src/pipe/gui/widgets/QueryPane.java (+27/-4)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/show-query-on-mouse-over-1947037
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Review via email: mp+410699@code.launchpad.net

This proposal supersedes a proposal from 2021-10-24.

Commit message

Now shows the query in the tooltip

Description of the change

In the query panel, if you hover your mouse over a given query name it will show a peek of the query in the tooltip text.
Width is adjusted to 100 chars when inserting a line break, and is placed at the nearest space.

To post a comment you must log in.
Revision history for this message
Jiri Srba (srba) wrote : Posted in a previous version of this proposal

This looks very nice, however, the line breaks can happen in the middle of a place name for example. It would be nice, after exceeding 80 characters, to place the line break <br> once a first empty space if ound. Also instead of width 80, we could go little bit wider, say to 100.

Revision history for this message
Jiri Srba (srba) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/pipe/gui/widgets/QueryPane.java'
--- src/pipe/gui/widgets/QueryPane.java 2020-10-15 15:44:06 +0000
+++ src/pipe/gui/widgets/QueryPane.java 2021-10-24 17:28:56 +0000
@@ -418,14 +418,37 @@
418418
419 setEnabled(list.isEnabled() && ((TAPNQuery)value).isActive());419 setEnabled(list.isEnabled() && ((TAPNQuery)value).isActive());
420420
421 if(!isEnabled())421 if(!isEnabled()){
422 setToolTipText("This query is disabled because it contains propositions involving places from a deactivated component");422 setToolTipText("This query is disabled because it contains propositions involving places from a deactivated component");
423 else423 } else {
424 setToolTipText("Double-click or press the edit button to edit this query");424 String queryToolTipString = getFormattedQueryToolTipString(((TAPNQuery)value).getQuery());
425 setToolTipText(queryToolTipString);
426 }
427
425 setFont(list.getFont());428 setFont(list.getFont());
426 setOpaque(true);429 setOpaque(true);
427 return superRenderer;430 return superRenderer;
428 }431 }
432
433 private String getFormattedQueryToolTipString(String qString) {
434 int stringLength = qString.length();
435 int newLineAt = 100;
436 if (stringLength > newLineAt) {
437 int numOfLineBreaks = (int)Math.floor(stringLength / newLineAt);
438
439 StringBuilder sb = new StringBuilder(qString);
440 sb.insert(0, "<html>");
441
442 for(int i = 1; i <= numOfLineBreaks; i++) {
443 int newLineIndex = sb.indexOf(" ", newLineAt * i);
444 sb.insert(newLineIndex, "<br>");
445 }
446
447 sb.insert(sb.length(), "</html>");
448 return sb.toString();
449 }
450 return qString;
451 }
429 }452 }
430453
431 public void selectFirst() {454 public void selectFirst() {

Subscribers

People subscribed via source and target branches