()
| 880 | } |
| 881 | |
| 882 | private void refreshGraph() { |
| 883 | final Date start = start_datebox.getValue(); |
| 884 | if (start == null) { |
| 885 | graphstatus.setText("Please specify a start time."); |
| 886 | return; |
| 887 | } |
| 888 | final Date end = end_datebox.getValue(); |
| 889 | if (end != null && !autoreload.getValue()) { |
| 890 | if (end.getTime() <= start.getTime()) { |
| 891 | end_datebox.addStyleName("dateBoxFormatError"); |
| 892 | graphstatus.setText("End time must be after start time!"); |
| 893 | return; |
| 894 | } |
| 895 | } |
| 896 | final StringBuilder url = new StringBuilder(); |
| 897 | url.append("q?start="); |
| 898 | final String start_text = start_datebox.getTextBox().getText(); |
| 899 | if (start_text.endsWith(" ago") || start_text.endsWith("-ago")) { |
| 900 | url.append(start_text); |
| 901 | } else { |
| 902 | url.append(FULLDATE.format(start)); |
| 903 | } |
| 904 | if (end != null && !autoreload.getValue()) { |
| 905 | url.append("&end="); |
| 906 | final String end_text = end_datebox.getTextBox().getText(); |
| 907 | if (end_text.endsWith(" ago") || end_text.endsWith("-ago")) { |
| 908 | url.append(end_text); |
| 909 | } else { |
| 910 | url.append(FULLDATE.format(end)); |
| 911 | } |
| 912 | } else { |
| 913 | // If there's no end-time, the graph may change while the URL remains |
| 914 | // the same. No browser seems to re-fetch an image once it's been |
| 915 | // fetched, even if we destroy the DOM object and re-created it with the |
| 916 | // same src attribute. This has nothing to do with caching headers sent |
| 917 | // by the server. The browsers simply won't retrieve the same URL again |
| 918 | // through JavaScript manipulations, period. So as a workaround, we add |
| 919 | // a special parameter that the server will delete from the query. |
| 920 | url.append("&ignore=" + nrequests++); |
| 921 | } |
| 922 | if (global_annotations.getValue()) { |
| 923 | url.append("&global_annotations"); |
| 924 | } |
| 925 | |
| 926 | if(timezone.length() > 1) |
| 927 | url.append("&tz=").append(timezone); |
| 928 | |
| 929 | if (!addAllMetrics(url)) { |
| 930 | return; |
| 931 | } |
| 932 | addLabels(url); |
| 933 | addFormats(url); |
| 934 | addYRanges(url); |
| 935 | addLogscales(url); |
| 936 | if (nokey.getValue()) { |
| 937 | url.append("&nokey"); |
| 938 | } else if (!keypos.isEmpty() || horizontalkey.getValue()) { |
| 939 | url.append("&key="); |
no test coverage detected