}
//constructs the actions for the widget popup
public ActionGroup getActions(){
DefaultActionGroup actionGroup = new DefaultActionGroup(null, false);
File profilerCsv = ProfilerUtil.findProfilerCsv(project);
if(profilerCsv == null) {
return actionGroup;
}
ProfilerIndex profilerIndex = new ProfilerIndex(profilerCsv);
List<ProfilerRequest> requests = profilerIndex.getRequests();
Collections.reverse(requests);
if(requests.size() > 10) {
requests = requests.subList(0, 10);
}
Collection<AnAction> templateActions = new ArrayList<AnAction>();
Map<String, Integer> templateActionsMap = new HashMap<String, Integer>();
Collection<AnAction> routeActions = new ArrayList<AnAction>();
Map<String, Integer> routeActionsMap = new HashMap<String, Integer>();
Collection<AnAction> controllerActions = new ArrayList<AnAction>();
Map<String, Integer> controllerActionsMap = new HashMap<String, Integer>();
Collection<AnAction> urlActions = new ArrayList<AnAction>();
Collection<AnAction> mailActions = new ArrayList<AnAction>();
for(ProfilerRequest profilerRequest : requests) {
DefaultDataCollector collector = profilerRequest.getCollector(DefaultDataCollector.class);
String statusCode = collector.getStatusCode();
urlActions.add(new SymfonyProfilerWidgetActions.UrlAction(this.project, profilerRequest, statusCode));
// regular expression fails on current version (because of multiple mailer)
// ArrayList<MailMessage> messages = profilerRequest.getCollector(MailCollector.class).getMessages();
// @TODO: use collector
String content = profilerRequest.getContent();
if(content != null && content.contains("Swift_Mime_Headers_MailboxHeader")) {
mailActions.add(new SymfonyProfilerWidgetActions.UrlAction(this.project, profilerRequest, statusCode).withPanel("swiftmailer").withIcon(Symfony2Icons.MAIL));
}
attachProfileItem(templateActions, templateActionsMap, collector.getTemplate(), ProfilerTarget.TEMPLATE);
attachProfileItem(routeActions, routeActionsMap, collector.getRoute(), ProfilerTarget.ROUTE);
attachProfileItem(controllerActions, controllerActionsMap, collector.getController(), ProfilerTarget.CONTROLLER);
}
// routes
if(urlActions.size() > 0) {
actionGroup.addSeparator("Debug-Url");
actionGroup.addAll(urlActions);
}
// mails send by request
if(mailActions.size() > 0) {
actionGroup.addSeparator("E-Mail");
actionGroup.addAll(mailActions);
}
// routes
if(routeActions.size() > 0) {
actionGroup.addSeparator("Routes");
actionGroup.addAll(routeActions);
}
// controller methods
if(controllerActions.size() > 0) {
actionGroup.addSeparator("Controller");
actionGroup.addAll(controllerActions);
}
// template should be most use case; so keep it in cursor range
if(templateActions.size() > 0) {
actionGroup.addSeparator("Template");
actionGroup.addAll(templateActions);
}
return actionGroup;
}