StringBuilder message = new StringBuilder();
if (msg.equals("")) {
if (noServer || noUsername || noPassword) {
message.append("Please set up preferences first. Go to Eclipse -> Preferences -> Code Conjurer.");
} else {
Search search = CodeConjurer.getInstance()
.getActiveEditorSearch();
ActionContributionItem showAdapterAction = (ActionContributionItem) getViewSite()
.getActionBars()
.getToolBarManager()
.find("de.uni_mannheim.swt.codeconjurer.showAdapterAction");
if (search != null) {
Result result = null;
int results = 0;
switch (search.getKind()) {
case Search.STANDARD_SEARCH:
showAdapterAction.getAction()
.setEnabled(false);
result = search.getSearchResult();
results = result.getResultItems().length;
if (results > 0) {
message.append(results
+ " results found. "
+ result.getNumberOfSuccessfullyFetchedSources()
+ " items successfully downloaded. :: Result created "
+ result.getCreationDate());
}
break;
case Search.TEST_DRIVEN_SEARCH:
showAdapterAction.getAction()
.setEnabled(true);
result = search.getSearchResult();
int passes = result
.getNumberOfSuccessfulTests();
int retrieved = result
.getNumberOfSuccessfullyFetchedSources();
long time = search.getDuration();
String duration;
if (time / Math.pow(10, 9) < 120) {
duration = String.valueOf(time
/ Math.pow(10, 9));
duration = duration.substring(0,
duration.indexOf("."));
duration += " s";
} else {
duration = String
.valueOf((time / Math.pow(
10, 9)) / 60);
duration = duration.substring(0,
duration.indexOf(".") + 2);
duration += " min";
}
results = result.getResultItems().length;
if (search.getState() == Job.RUNNING) {
message.append("Testing in progress");
message.append(" :: Time elapsed "
+ duration);
}
if (retrieved > 0) {
message.append(" :: "
+ passes
+ " of "
+ results
+ " candidates passed test. "
+ retrieved
+ " items successfully downloaded.");
if (search.isFinished()) {
message.append(" :: Result created "
+ result.getCreationDate());
message.append(" :: Result created in "
+ duration);
}