Develop and Download Open Source Software

Browse Subversion Repository

Contents of /TimeLogger/trunk/src/org/timerabbit/logger/Main.fx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 14 - (show annotations) (download)
Sat Oct 24 16:29:40 2009 UTC (14 years, 5 months ago) by jkawamoto
File size: 5967 byte(s)


1 /*
2 * Copyright 2009 Junpei Kawamoto
3 *
4 * This file is part of TimeRabbit project TimeLogger.
5 * TimeRabbit project TimeLogger is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * TimeRabbit project TimeLogger is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with TimeRabbit project TimeLogger. If not, see <http://www.gnu.org/licenses/>.
17 */
18 package org.timerabbit.logger;
19
20 import javafx.stage.Stage;
21 import javafx.scene.Scene;
22
23 import java.net.ProxySelector;
24
25 import java.net.Proxy;
26 import java.net.URI;
27
28 import java.net.InetSocketAddress;
29
30 import java.lang.System;
31
32 import java.lang.SecurityException;
33 import javafx.animation.Timeline;
34 import javafx.animation.KeyFrame;
35 import javafx.animation.Interpolator;
36
37 import org.timerabbit.util.Config;
38
39
40 try{ // ���������������������
41
42 var selector: ProxySelector = ProxySelector.getDefault();
43 var proxy: Proxy = selector.select(new URI("http://www.google.com")).get(0);
44 println("System proxy setting for HTTP: {proxy.toString()}");
45 if(proxy.type().equals(Proxy.Type.HTTP)){
46
47 var addr: InetSocketAddress = proxy.address() as InetSocketAddress;
48 System.setProperty("http.proxyHost", addr.getHostName());
49 System.setProperty("http.proxyPort", addr.getPort().toString());
50
51 println("Using http proxy: {addr.getHostName()}:{addr.getPort()}")
52
53 }
54 proxy = selector.select(new URI("https://www.google.com")).get(0);
55 println("System proxy setting for HTTPS: {proxy.toString()}");
56 if(proxy.type().equals(Proxy.Type.HTTP)){
57
58 var addr: InetSocketAddress = proxy.address() as InetSocketAddress;
59 System.setProperty("https.proxyHost", addr.getHostName());
60 System.setProperty("https.proxyPort", addr.getPort().toString());
61
62 println("Using https proxy: {addr.getHostName()}:{addr.getPort()}")
63
64 }
65
66 }catch(e: SecurityException){
67
68 System.err.println(e.getLocalizedMessage());
69
70 } // ���������������������
71
72 // ������������������������
73 var stageX: Number = 0;
74 var stageY: Number = 0;
75
76 // ���������������������
77 def config: Config = Config{};
78 if(config.get("x") != null){
79 stageX = Number.valueOf(config.get("x"));
80 }
81 if(config.get("y") != null){
82 stageY = Number.valueOf(config.get("y"));
83 }
84
85 var alpha: Number = 0;
86 def ConunterToPreference: Timeline = Timeline {
87 keyFrames : [
88 KeyFrame {
89 time : 0s
90 values: alpha => 0
91 },
92 KeyFrame {
93 time: 0.5s
94 values: alpha => 1.0 tween Interpolator.EASEBOTH
95 }
96 ]
97 }
98 def PreferenceToCounter: Timeline = Timeline {
99 keyFrames : [
100 KeyFrame {
101 time : 0s
102 values: alpha => 1.0
103 },
104 KeyFrame {
105 time: 0.5s
106 values: alpha => 0 tween Interpolator.EASEBOTH
107 }
108 ]
109 }
110
111
112 Stage{
113
114 title: "TimeLogger : TimeRabbitProject"
115 width: 360
116 height: 240
117 resizable: false
118
119 x: bind stageX with inverse
120 y: bind stageY with inverse
121
122 def counter: Counter = Counter{ // ������������
123 isTwitter: Boolean.valueOf(config.get("Twitter"))
124 isGCal: Boolean.valueOf(config.get("GoogleCalendar"))
125 disableTwitter: bind preference.startTweet.length() == 0 and preference.endTweet.length() == 0
126 disableGCal: bind preference.gcalID.length() == 0;
127
128 opacity: bind 1.0 - alpha;
129
130 onConfig: function(){
131
132 preference.disable = false;
133 counter.disable = true;
134 ConunterToPreference.playFromStart();
135
136 }
137
138 onStart: function(title: String, start: Long){
139
140 if(counter.isTwitter and preference.startTweet.length() != 0){
141
142 SendTweet.send(preference.startTweet.replace("\{title\}", "{title}"));
143
144 }
145
146 }
147
148 onStop: function(title: String, start: Long, end: Long){
149
150 if(counter.isTwitter and preference.endTweet.length() != 0){
151
152 SendTweet.send(preference.endTweet.replace("\{title\}", "{title}"));
153
154 }
155
156 if(counter.isGCal){
157
158 SendCalendarEvent{
159 id: config.get("GoogleCalendar.ID")
160 password: config.get("GoogleCalendar.Password")
161 url: preference.gcalID
162 begin: start
163 end: end
164 title: title
165 }.start();
166
167 }
168
169 }
170
171 }; // ������������
172
173 def preference: Preference = Preference{ // ������������
174
175 // ���������������������������
176 startTweet: config.get("Twitter.StartTweet")
177 endTweet: config.get("Twitter.EndTweet")
178 googleID: config.get("GoogleCalendar.ID")
179 googlePassword: config.get("GoogleCalendar.Password")
180 gcalName: config.get("GoogleCalendar.CalendarName")
181
182 opacity: bind alpha
183 translateX: 5
184 translateY: 5
185
186 // ������������������������������������������
187 disable: true
188
189 onOK : function(){
190 config.put("Twitter.startTweet", preference.startTweet);
191 config.put("Twitter.endTweet", preference.startTweet);
192 config.put("GoogleCalendar.ID", preference.googleID);
193 config.put("GoogleCalendar.Password", preference.googlePassword);
194 config.put("GoogleCalendar.CalendarName", preference.gcalName);
195
196 preference.disable = true;
197 counter.disable = false;
198 PreferenceToCounter.playFromStart();
199 }
200
201 onCancel : function(){
202 preference.startTweet = config.get("Twitter.StartTweet");
203 preference.endTweet = config.get("Twitter.EndTweet");
204 preference.googleID = config.get("GoogleCalendar.ID");
205 preference.googlePassword = config.get("GoogleCalendar.Password");
206 preference.gcalName = config.get("GoogleCalendar.CalendarName");
207
208 preference.disable = true;
209 counter.disable = false;
210 PreferenceToCounter.playFromStart();
211 }
212
213 }; // ������������
214
215 scene : Scene{
216 content: [counter, preference]
217 }
218
219 onClose: function(){
220 config.put("x", stageX.toString());
221 config.put("y", stageY.toString());
222 config.put("Twitter", counter.isTwitter.toString());
223 config.put("GoogleCalendar", counter.isGCal.toString());
224
225 config.save();
226 }
227
228 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26