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
1=== modified file 'src/pipe/gui/widgets/QueryPane.java'
2--- src/pipe/gui/widgets/QueryPane.java 2020-10-15 15:44:06 +0000
3+++ src/pipe/gui/widgets/QueryPane.java 2021-10-24 17:28:56 +0000
4@@ -418,14 +418,37 @@
5
6 setEnabled(list.isEnabled() && ((TAPNQuery)value).isActive());
7
8- if(!isEnabled())
9- setToolTipText("This query is disabled because it contains propositions involving places from a deactivated component");
10- else
11- setToolTipText("Double-click or press the edit button to edit this query");
12+ if(!isEnabled()){
13+ setToolTipText("This query is disabled because it contains propositions involving places from a deactivated component");
14+ } else {
15+ String queryToolTipString = getFormattedQueryToolTipString(((TAPNQuery)value).getQuery());
16+ setToolTipText(queryToolTipString);
17+ }
18+
19 setFont(list.getFont());
20 setOpaque(true);
21 return superRenderer;
22 }
23+
24+ private String getFormattedQueryToolTipString(String qString) {
25+ int stringLength = qString.length();
26+ int newLineAt = 100;
27+ if (stringLength > newLineAt) {
28+ int numOfLineBreaks = (int)Math.floor(stringLength / newLineAt);
29+
30+ StringBuilder sb = new StringBuilder(qString);
31+ sb.insert(0, "<html>");
32+
33+ for(int i = 1; i <= numOfLineBreaks; i++) {
34+ int newLineIndex = sb.indexOf(" ", newLineAt * i);
35+ sb.insert(newLineIndex, "<br>");
36+ }
37+
38+ sb.insert(sb.length(), "</html>");
39+ return sb.toString();
40+ }
41+ return qString;
42+ }
43 }
44
45 public void selectFirst() {

Subscribers

People subscribed via source and target branches