Skip to content

Commit

Permalink
v1.84, push messages
Browse files Browse the repository at this point in the history
  • Loading branch information
marc committed Jun 20, 2014
1 parent f0fa583 commit 0e77187
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 20 deletions.
5 changes: 2 additions & 3 deletions src/gui/GW2EventerGui.form
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,12 @@
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="labelMapDate">
<Component class="javax.swing.JLabel" name="labelPushMessage">
<Properties>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="cc" green="cc" red="cc" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value="&lt;html&gt;Event Patch&lt;br&gt;17.06.2014&lt;/html&gt;"/>
<Property name="toolTipText" type="java.lang.String" value="Event data from 17.06.2014"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
Expand Down
48 changes: 31 additions & 17 deletions src/gui/GW2EventerGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public class GW2EventerGui extends javax.swing.JFrame {

public static final int EVENT_COUNT = 23;

public static final String VERSION = "1.83";
public static final String VERSION = "1.84";

private JButton workingButton;
private JCheckBox refreshSelector;
Expand Down Expand Up @@ -443,7 +443,7 @@ public void mousePressed(java.awt.event.MouseEvent evt) {

this.preventSleepMode();
this.runUpdateService();
//this.runPushService();
this.runPushService();
this.runTips();
//this.runTest();
}
Expand Down Expand Up @@ -613,7 +613,7 @@ private void initComponents() {
jLabelNewVersion = new javax.swing.JLabel();
jLabelWorking = new javax.swing.JLabel();
jLabelServer = new javax.swing.JLabel();
labelMapDate = new javax.swing.JLabel();
labelPushMessage = new javax.swing.JLabel();
labelEvent1 = new javax.swing.JLabel();
labelEvent2 = new javax.swing.JLabel();
labelEvent3 = new javax.swing.JLabel();
Expand Down Expand Up @@ -851,10 +851,9 @@ public void mousePressed(java.awt.event.MouseEvent evt) {
jLabelServer.setEnabled(false);
jPanel4.add(jLabelServer, new org.netbeans.lib.awtextra.AbsoluteConstraints(1090, 690, 170, -1));

labelMapDate.setForeground(new java.awt.Color(204, 204, 204));
labelMapDate.setText("<html>Event Patch<br>17.06.2014</html>");
labelMapDate.setToolTipText("Event data from 17.06.2014");
jPanel4.add(labelMapDate, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 680, -1, -1));
labelPushMessage.setForeground(new java.awt.Color(204, 204, 204));
labelPushMessage.setToolTipText("");
jPanel4.add(labelPushMessage, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 680, -1, -1));

labelEvent1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
labelEvent1.setForeground(new java.awt.Color(255, 51, 0));
Expand Down Expand Up @@ -1561,7 +1560,7 @@ private void runPushService() {
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(10 * 1000).build();
HttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(requestConfig).build();

HttpGet request = new HttpGet("http://gw2eventer.sourceforge.net/gw2/push");
HttpGet request = new HttpGet("http://gw2eventer.sourceforge.net/push/");

HttpResponse response;

Expand All @@ -1578,12 +1577,6 @@ private void runPushService() {

try {

try {
Thread.sleep(60000 * 33);
} catch (InterruptedException ex) {
Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex);
}

response = client.execute(request);

if (response.getStatusLine().toString().contains("200")) {
Expand Down Expand Up @@ -1620,7 +1613,7 @@ private void runPushService() {
}

if (!date.equals("") && enabled.equals("true")) {

try {

Date dateData = new Date(Long.parseLong(date));
Expand All @@ -1629,11 +1622,14 @@ private void runPushService() {
if (!dateData.equals(getLastPushDate())) {

setLastPushDate(dateData);
showPushGui(title, message, 100);
//showPushGui(title, message, 100);
setPushMessage(title, message);
}
} catch (java.lang.NumberFormatException ex) {
//
}
} else {
clearPushMessage();
}
} catch (ParseException ex) {

Expand All @@ -1643,6 +1639,12 @@ private void runPushService() {

request.releaseConnection();
//this.interrupt();

try {
Thread.sleep(60000 * 5);
} catch (InterruptedException ex) {
Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
try {
request.releaseConnection();
Expand Down Expand Up @@ -1827,6 +1829,18 @@ private void showPushGui(String title, String content, int height) {
this.pushGui.setVisible(true);
}

private void setPushMessage(String title, String message) {

this.labelPushMessage.setText("<html><b><font style=\"color: red;\">" + title + "</font></b><br><font style=\"color: white;\">" + message + "</font></html>");
this.labelPushMessage.setToolTipText(message);
}

private void clearPushMessage() {

this.labelPushMessage.setText("");
this.labelPushMessage.setToolTipText("");
}

private void showFeedbackGui() {

this.feedbackGui.setLocationRelativeTo(this);
Expand Down Expand Up @@ -1963,7 +1977,7 @@ public void run() {
private javax.swing.JLabel labelEvent7;
private javax.swing.JLabel labelEvent8;
private javax.swing.JLabel labelEvent9;
private javax.swing.JLabel labelMapDate;
private javax.swing.JLabel labelPushMessage;
private javax.swing.JLabel labelTimer1;
private javax.swing.JLabel labelTimer10;
private javax.swing.JLabel labelTimer11;
Expand Down

0 comments on commit 0e77187

Please sign in to comment.