+ /*
+ * GUI MANIPULATION CALLBACKS
+ */
+
+ private PropertyChangeListener changeListener = new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent e) {
+ if(e.getNewValue() != null &&
+ e.getPropertyName().equals
+ (AccessibleContext.ACCESSIBLE_CHILD_PROPERTY)) {
+ Accessible islandInfo =
+ descendNodes(window,new int[] {0,1,0,0,2,2,0,0,0,0,1,2});;
+ String text = islandInfo.getAccessibleContext().getAccessibleText()
+ .getAtIndex(AccessibleText.SENTENCE,0);
+ int index = text.indexOf(":");
+ String name = text.substring(0,index);
+ islandName = name;
+ // if (dtxt!=null) dtxt.println(islandName);
+ sidePanel.removePropertyChangeListener(this);
+ latch.countDown();
+ }
+ }
+ };
+
+ private void getIsland() {
+ // runs on event thread
+
+ // If the league tracker is there, we can skip the faff
+ // and ask for its tooltip, since we're on a boat
+
+ Accessible leagueTrackerContainer =
+ descendNodes(window,new int[] {0,1,0,0,2,1});
+ Accessible leagueTrackerItself =
+ descendByClass(leagueTrackerContainer,
+ "com.threerings.yohoho.sea.client.LeagueTracker");
+ Accessible leagueTracker = descend(leagueTrackerItself, 1);
+ try {
+ islandName = ((JLabel)leagueTracker).getToolTipText();
+ } catch (NullPointerException e) {
+ // evidently we're actually on an island
+
+ islandName = null;
+ AccessibleContext chatArea =
+ descendNodes(window,new int[] {0,1,0,0,0,2,0,0,2})
+ .getAccessibleContext();
+ // attach the property change listener to the outer sunshine
+ // panel if the "ahoy" tab is not active, otherwise attach it to
+ // the scroll panel in the "ahoy" tab.
+ if(!"com.threerings.piracy.client.AttentionListPanel".
+ equals(descendNodes(window,new int[] {0,1,0,0,2,2,0})
+ .getClass().getCanonicalName())) {
+ sidePanel = descendNodes(window,new int[] {0,1,0,0,2,2})
+ .getAccessibleContext();
+ } else {
+ sidePanel = descendNodes(window,new int[] {0,1,0,0,2,2,0,0,0})
+ .getAccessibleContext();
+ }
+ sidePanel.addPropertyChangeListener(changeListener);
+ latch = new java.util.concurrent.CountDownLatch(1);
+ // make the Players Online ("/who") panel appear
+ AccessibleEditableText chat = chatArea.getAccessibleEditableText();
+ chat.setTextContents("/w");
+ int c = chatArea.getAccessibleAction().getAccessibleActionCount();
+ for(int i=0;i<c;i++) {
+ if("notify-field-accept".equals(chatArea.getAccessibleAction()
+ .getAccessibleActionDescription(i))) {
+ chatArea.getAccessibleAction().doAccessibleAction(i);
+ }
+ }
+ }
+ }
+
+ /**
+ * Find the ocean name from the window title, and set global
+ * oceanName variable
+ */
+ private void getOcean() {
+ // runs on event thread
+ oceanName = null;
+ AccessibleContext topwindow = window.getAccessibleContext();
+ oceanName = topwindow.getAccessibleName()
+ .replaceAll(".*on the (\\w+) ocean", "$1");
+ }
+
+
+ /**
+ * Run the data collection process, and upload the results. This
+ * is the method that calls most of the other worker methods for
+ * the process. If an error occurs, the method will call the
+ * error method and return early, freeing up the button to be
+ * clicked again.
+ *
+ * @exception Exception if an error we didn't expect occured
+ */
+ private class YarrgTimestampFetcher extends Thread {
+ public String ts = null;
+ public void run() {
+ try {
+ ts = getYarrgTimestamp();
+ progresslog("(async) yarrg timestamp ready.");
+ } catch(Exception e) {
+ error("Error getting YARRG timestamp: "+e);
+ }
+ }
+ };