30Boxes Viewer
Without further ado, here is the 30Boxes widget I prepared for BarCamp but never got finished. Thanks to SwingX-WS, it was very easy to wrap REST calls, parse the responses, and react appropriately.
Here's the wrapper function for deleting a Todo:
public void deleteTodo(todo) {
def response = session.get ("http://30boxes.com/api/api.php?method=todos.Delete" +
"&apiKey="+apiKey+"&authorizedUserToken="+authToken+
"&todoId="+todo)
def status = parseResponse(response.getBody())
if (status == "fail")
// Make this an option pane later
println "There was a problem deleting the todo."
}
The viewer works for simple creation and deletion of Todos and creation of Events. The pseudo-API(Groovy service layer) does have method calls for deletion of events[and some other stuff] but Swing was acting funny and I wanted to get it out the door since it wasn't going to be feature-complete anyways. To run it with your own data, you must visit 30Boxes, get an API key and authorization token, and put them in the config.xml file. Unlike Facebook, these keys are per-user not per-application.
Concerning the layout, I used Nimbus for the look and feel. The task pane is nested inside a titled panel with a simple background painter applied to the title. Here is the code that draws the frame:
frame = swing.frame(size:[300,300],defaultCloseOperation:WindowConstants.EXIT_ON_CLOSE) {
titledPanel(title:"30Boxes Viewer", titlePainter:makeTitlePainter(),
border:new DropShadowBorder(Color.BLACK,15), size:[300,400],mousePressed:{menu.setVisible(true)}) {
scrollPane() {
taskPaneContainer() {
todoPane = taskPane(title:"To Do:",layout:new MigLayout())
eventPane = taskPane(title:"Events:", layout:new MigLayout())
}
}
}
}
}
Download the Netbeans project here.
Enjoy!