String query = null;
String htmlCode = null;
List<String> subscriptionNames = new ArrayList<String>();
JSONObject template;
JSONArray templates = null;
Send send = null;
if (selectedSendOption.equals("Generate HTML")) {
JFileChooser chooser = new JFileChooser(".");
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setAcceptAllFileFilterUsed(false);
if (chooser.showDialog(this.view.getFrame(), "Select output directory.") == JFileChooser.APPROVE_OPTION) {
outPutFolder = chooser.getSelectedFile().getAbsolutePath()
+ "/";
outPutFolder = outPutFolder.replace(File.separatorChar, '/');
} else {
return;
}
}
try {
templates = subscriptions.getJSONArray("templates");
} catch (JSONException e) {
this.view.showError(e.toString());
e.printStackTrace();
}
for (int i = 0; i < templates.length(); i++) {
try {
template = templates.getJSONObject(i);
name = template.getString("name");
name = name.replaceAll(" ", "");
subscriptionNames.add(name);
query = template.getString("query");
htmlCode = template.getString("htmlCode");
} catch (JSONException e) {
this.view.showError(e.toString());
e.printStackTrace();
}
if (selectedSendOption.equals("Generate HTML")) {
send = new GenerateHTML(name, outPutFolder);
} else if (selectedSendOption.equals("Send EMail")) {
//_______________________________________________________________________________________________
send = new SendEMail("text/html");
//---------------------------------------------------------------------------------------
} else if (selectedSendOption.equals("Sliding Window")) {
send = new SlidingWindow();
}
send.init();
subscribe(new Subscription("#" + this.subcount++ + " " + name,
query), new PageAction(name, htmlCode, send));
}