| 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.scene.control.Label; |
| 21 |
import javafx.scene.control.TextBox; |
| 22 |
import javafx.scene.Group; |
| 23 |
import javafx.scene.control.Button; |
| 24 |
import javafx.scene.Node; |
| 25 |
|
| 26 |
import javafx.ext.swing.SwingComboBox; |
| 27 |
import javafx.ext.swing.SwingComboBoxItem; |
| 28 |
|
| 29 |
import java.lang.String; |
| 30 |
|
| 31 |
import javafx.scene.CustomNode; |
| 32 |
import javafx.scene.layout.VBox; |
| 33 |
import javafx.scene.layout.HBox; |
| 34 |
import javafx.geometry.VPos; |
| 35 |
import javafx.scene.text.Font; |
| 36 |
import javafx.scene.image.ImageView; |
| 37 |
import javafx.scene.image.Image; |
| 38 |
|
| 39 |
package class Preference extends CustomNode{ |
| 40 |
|
| 41 |
var loadCalendarInfo: LoadCalendarInfo = null; |
| 42 |
|
| 43 |
public var startTweet: String; |
| 44 |
public var endTweet: String; |
| 45 |
|
| 46 |
public var googleID: String; |
| 47 |
public var googlePassword: String on replace{ locadCalendarInfo(); } |
| 48 |
public var gcalName: String; // ������������������������������ |
| 49 |
public-read var gcalID: String; // ���������������������������ID |
| 50 |
|
| 51 |
public-init var onOK : function() : Void; |
| 52 |
public-init var onCancel : function() : Void; |
| 53 |
|
| 54 |
// ������������������������������������������������������ |
| 55 |
var calendars: SwingComboBoxItem[]; |
| 56 |
|
| 57 |
override function create(): Node{ |
| 58 |
|
| 59 |
return VBox{ |
| 60 |
spacing: 5 |
| 61 |
disable: bind disable |
| 62 |
content: [ |
| 63 |
|
| 64 |
VBox{ // Configuration of Twitter |
| 65 |
spacing: 3 |
| 66 |
content: [ |
| 67 |
|
| 68 |
Label { |
| 69 |
text: "Twitter" |
| 70 |
font: Font{ |
| 71 |
oblique: true |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
HBox{ |
| 76 |
content:[ |
| 77 |
Label { |
| 78 |
text: "Start tweet:" |
| 79 |
width: bind 70 |
| 80 |
}, |
| 81 |
TextBox{ |
| 82 |
text: bind startTweet with inverse |
| 83 |
promptText: "\{title\} is replaced" |
| 84 |
columns: 25 |
| 85 |
selectOnFocus: true |
| 86 |
} |
| 87 |
] |
| 88 |
translateX: 5 |
| 89 |
}, |
| 90 |
|
| 91 |
HBox{ |
| 92 |
content:[ |
| 93 |
Label { |
| 94 |
text: "End tweet:" |
| 95 |
width: bind 70 |
| 96 |
}, |
| 97 |
TextBox{ |
| 98 |
text: bind endTweet with inverse |
| 99 |
promptText: "\{title\} is replaced" |
| 100 |
columns: 25 |
| 101 |
selectOnFocus: true |
| 102 |
} |
| 103 |
] |
| 104 |
translateX: 5 |
| 105 |
} |
| 106 |
|
| 107 |
] |
| 108 |
translateX: 5 |
| 109 |
}, // Configuration of Twitter |
| 110 |
|
| 111 |
VBox{ // Configuration of GoogleCalendar |
| 112 |
spacing: 3 |
| 113 |
content: [ |
| 114 |
Label{ |
| 115 |
text: "GoogleCalendar" |
| 116 |
font: Font{ |
| 117 |
oblique: true |
| 118 |
} |
| 119 |
}, |
| 120 |
|
| 121 |
HBox{ // ID |
| 122 |
nodeVPos: VPos.CENTER |
| 123 |
content: [ |
| 124 |
|
| 125 |
Label { |
| 126 |
text: "Account:" |
| 127 |
width: bind 70 |
| 128 |
}, |
| 129 |
|
| 130 |
TextBox { |
| 131 |
columns: 25 |
| 132 |
text: bind googleID with inverse |
| 133 |
selectOnFocus: true |
| 134 |
} |
| 135 |
|
| 136 |
] |
| 137 |
translateX: 5 |
| 138 |
}, // ID |
| 139 |
|
| 140 |
HBox{ // Password |
| 141 |
nodeVPos: VPos.CENTER |
| 142 |
content: [ |
| 143 |
|
| 144 |
Label { |
| 145 |
text: "Password:" |
| 146 |
width: bind 70 |
| 147 |
}, |
| 148 |
|
| 149 |
TextBox { |
| 150 |
columns: 25 |
| 151 |
text: bind googlePassword with inverse |
| 152 |
selectOnFocus: true |
| 153 |
} |
| 154 |
|
| 155 |
] |
| 156 |
translateX: 5 |
| 157 |
} // Password |
| 158 |
|
| 159 |
HBox{ |
| 160 |
nodeVPos: VPos.CENTER |
| 161 |
content: [ |
| 162 |
|
| 163 |
Label{ |
| 164 |
text: "Calendar:" |
| 165 |
width: bind 70 |
| 166 |
}, |
| 167 |
|
| 168 |
SwingComboBox { |
| 169 |
items: bind calendars |
| 170 |
width: 250 |
| 171 |
|
| 172 |
// ���������������������������������������������gcalName��������������� |
| 173 |
selectedItem: bind selected with inverse |
| 174 |
var selected: SwingComboBoxItem on replace{ |
| 175 |
if(selected != null){ |
| 176 |
gcalName = selected.text; |
| 177 |
gcalID = selected.value as String; |
| 178 |
} |
| 179 |
} |
| 180 |
|
| 181 |
}, |
| 182 |
|
| 183 |
ImageView { |
| 184 |
translateX: 5 |
| 185 |
image: Image { |
| 186 |
url: "{__DIR__}loading.gif" |
| 187 |
} |
| 188 |
visible: bind loadCalendarInfo != null |
| 189 |
}, |
| 190 |
|
| 191 |
] |
| 192 |
translateX: 5 |
| 193 |
} |
| 194 |
] |
| 195 |
translateX: 5 |
| 196 |
} // Configuration of GoogleCalendar |
| 197 |
|
| 198 |
Group{ // OK/Cancel Buttons |
| 199 |
content: [ |
| 200 |
|
| 201 |
Button { |
| 202 |
text: "OK" |
| 203 |
action: onOK |
| 204 |
width: 60 |
| 205 |
}, |
| 206 |
|
| 207 |
Button { |
| 208 |
text: "Cancel" |
| 209 |
action: onCancel |
| 210 |
width: 60 |
| 211 |
translateX: 65 |
| 212 |
} |
| 213 |
|
| 214 |
] |
| 215 |
translateX: 220 |
| 216 |
translateY: 2 |
| 217 |
} // OK/Cancel Buttons |
| 218 |
] |
| 219 |
} |
| 220 |
|
| 221 |
} |
| 222 |
|
| 223 |
function locadCalendarInfo():Void { |
| 224 |
|
| 225 |
// ���������ID������������������������������������������������������������������������������ |
| 226 |
if(googleID.length() != 0 and googlePassword.length() != 0){ |
| 227 |
|
| 228 |
if(loadCalendarInfo != null){ |
| 229 |
|
| 230 |
loadCalendarInfo.stop(); |
| 231 |
|
| 232 |
} |
| 233 |
|
| 234 |
// ������������������������ |
| 235 |
loadCalendarInfo = LoadCalendarInfo{ |
| 236 |
id: googleID |
| 237 |
pass: googlePassword |
| 238 |
|
| 239 |
onDone: function(){ |
| 240 |
|
| 241 |
// ��������������������� |
| 242 |
if(loadCalendarInfo.succeeded){ |
| 243 |
|
| 244 |
calendars = []; |
| 245 |
for(e in loadCalendarInfo.items){ |
| 246 |
|
| 247 |
var item: SwingComboBoxItem = e as SwingComboBoxItem; |
| 248 |
insert item into calendars; |
| 249 |
if(item.text.equals(gcalName)){ |
| 250 |
|
| 251 |
item.selected = true; |
| 252 |
gcalID = item.value as String; |
| 253 |
|
| 254 |
} |
| 255 |
|
| 256 |
} |
| 257 |
if(calendars.size() != 0){ |
| 258 |
|
| 259 |
if(gcalID == null or gcalID.equals("")){ |
| 260 |
|
| 261 |
calendars[0].selected; |
| 262 |
gcalName = calendars[0].text; |
| 263 |
gcalID = calendars[0].value as String; |
| 264 |
|
| 265 |
} |
| 266 |
|
| 267 |
} |
| 268 |
loadCalendarInfo = null; |
| 269 |
} |
| 270 |
|
| 271 |
} // onDone |
| 272 |
|
| 273 |
} // LoadCalendarInfo |
| 274 |
loadCalendarInfo.start(); |
| 275 |
|
| 276 |
} |
| 277 |
|
| 278 |
} |
| 279 |
|
| 280 |
} |