public List<Class<? extends Extension>> getExtensions() {
return ImmutableList.of(
- // Batch
- MavenDependenciesSensor.class,
- ProjectDsmDecorator.class,
- PackageTangleIndexDecorator.class,
- FileTangleIndexDecorator.class,
+ // Batch
+ MavenDependenciesSensor.class,
+ ProjectDsmDecorator.class,
+ PackageTangleIndexDecorator.class,
+ FileTangleIndexDecorator.class,
// UI
GwtLibrariesPage.class,
return get(Views.class).getPages(section, resourceScope, resourceQualifier, resourceLanguage, (String[]) availableMeasures);
}
+ public List<ViewProxy<Page>> getResourceTabs() {
+ return get(Views.class).getPages(NavigationSection.RESOURCE_TAB, null, null, null, null);
+ }
+
public List<ViewProxy<Page>> getResourceTabs(String scope, String qualifier, String language, Object[] availableMeasures) {
return get(Views.class).getPages(NavigationSection.RESOURCE_TAB, scope, qualifier, language, (String[]) availableMeasures);
}
//******************* HANDLING OF ACCORDION NAVIGATION [BEGIN] ******************* //
-function openAccordionItem(url, elt, updateCurrentElement) {
- var htmlClass = 'accordion-item';
- var currentElement = $j(elt).closest('.'+ htmlClass);
-
- // Create loading image
- var loadingImg = new Image();
- loadingImg.src = baseUrl + "/images/loading.gif";
- loadingImg.className = 'accordion-loading';
- var loading = $j(loadingImg);
- var existingLoading = currentElement.find('.accordion-loading');
- if (updateCurrentElement && existingLoading.length) {
- existingLoading.show();
- loading.hide();
- }
-
- // Remove elements under current element
- if (currentElement.length) {
- // Fix the height in order to not change the position on the screen when removing elements under current element
- var elementToRemove = currentElement.nextAll('.'+ htmlClass);
- if (elementToRemove.height()) {
- $j("#accordion-panel").height($j("#accordion-panel").height() + elementToRemove.height());
- }
- // Remove all accordion items after current element
- elementToRemove.remove();
- // Display loading image only if not already displayed (if previous call was not finished)
- if (currentElement.next('.accordion-loading').length === 0) {
- loading.insertAfter(currentElement);
- }
- } else {
- // Current element is not in a working view, remove all working views
- $j('.'+ htmlClass).remove();
- // Display loading image only if not already displayed (if previous call was not finished)
- if ($j("#accordion-panel").next('.accordion-loading').length === 0) {
- loading.insertAfter($j("#accordion-panel"));
- }
- }
-
- // Get content from url
+function openAccordionItem(url) {
var ajaxRequest = $j.ajax({
url: url
}).fail(function (jqXHR, textStatus) {
console.log(error);
$j("#accordion-panel").append($j('<div class="error">').append(error));
}).done(function (html) {
- if (currentElement.length) {
- var body = currentElement.find('.accordion-item-body');
- if (!updateCurrentElement && !body.hasClass('accordion-item-body-medium')) {
- body.addClass("accordion-item-body-medium");
- elt.scrollIntoView(false);
- }
- } else {
- $j("#accordion-panel").height('auto');
-
- // Current element is not in a working view, remove again all working views to purge elements that could be added just before this one
- $j('.'+ htmlClass).remove();
- }
-
- if (updateCurrentElement) {
- // Fix the height in order to not change the position on the screen
- var prevHeight = $j("#accordion-panel").height();
- currentElement.html(html);
- $j("#accordion-panel").height('auto');
- var newHeight = $j("#accordion-panel").height();
- if (prevHeight > newHeight) {
- $j("#accordion-panel").height(prevHeight);
- } else {
- $j("#accordion-panel").height(newHeight);
- }
- } else {
- // Add new item add the end of the panel and restore the height param
- var nbElement = $j("."+htmlClass).size();
- var newElement = $j('<div id="'+ htmlClass + nbElement +'" class="'+ htmlClass +'">');
- $j("#accordion-panel").append(newElement);
-
- // Add html after having adding the new element in the page in order to scripts (for instance for GWT) to be well executed
- newElement.append(html);
- $j("#accordion-panel").height('auto');
-
- // Set the focus on the top of the current item with animation
- if (currentElement.length) {
- $j('html, body').animate({
- scrollTop: currentElement.offset().top}, 500
- );
- }
- }
- loading.remove();
+ var panel = $j("#accordion-panel");
+ panel.html(html);
+ panel.scrollIntoView(false);
});
return ajaxRequest;
}
-function expandAccordionItem(elt) {
- var currentElement = $j(elt).closest('.accordion-item');
- currentElement.find('.accordion-item-body').removeClass("accordion-item-body-medium");
-}
-
//******************* HANDLING OF ACCORDION NAVIGATION [END] ******************* //
redirect_to :controller => 'component', :action => 'index', :anchor => anchor
end
+ # deprecated stuff for drilldown
+ def view
+ require_parameters 'id'
+ @resource = Project.by_key(params[:id])
+ access_denied unless has_role?(:user, @resource)
+ @snapshot = @resource.last_snapshot
+ load_extensions() if @snapshot
+ if @extension
+ render :partial => 'view'
+ else
+ not_found('Extension not found')
+ end
+ end
+
#
# Call by new component viewer to display plugin extension
#
<div id="resource_container"> </div>
-<% if @display_viewers && @drilldown.highlighted_resource %>
-<script>
- d(<%= @drilldown.highlighted_resource.id -%>, true);
-</script>
-<% end %>
+<%
+ if @display_viewers
+ resource = @drilldown.highlighted_resource || @drilldown.resource
+ if resource
+%>
+ <script>
+ d(<%= resource.id -%>, <%= resource.source_code? -%>);
+ </script>
+<%
+ end
+ end
+%>
+<%= render :partial => 'gwt/base', :locals => {:resource => nil, :popup => false, :metric => (@metric ? @metric.key : nil)} -%>
+<%= render :partial => 'gwt/resource_viewers' -%>
+
<script type="text/javascript">
/* display resource */
- function d(resourceId, display_title) {
- if (display_title == undefined) {
- display_title = true;
- }
- var url = '<%= ApplicationController.root_context -%>/resource/index/' + resourceId + '?metric=<%= @metric.id if @metric -%>' +
- '&rule=<%= @rule ? @rule.id : @severity -%>&period=<%= @period -%>&project=<%= @resource.id -%>&display_title=' + display_title;
- openAccordionItem(url, this);
+ function d(resourceId, is_file) {
+ var action = is_file ? 'index' : 'view';
+ var url = '<%= ApplicationController.root_context -%>/resource/' + action + '/' + resourceId + '?metric=<%= @metric.id if @metric -%>' +
+ '&rule=<%= @rule ? @rule.id : @severity -%>&period=<%= @period -%>&project=<%= @resource.id -%>';
+ openAccordionItem(url);
return false;
}
window.location.reload();
}
}
+
+ function loadGWT(gwtId, resourceId, resourceKey, resourceName, resourceScope, resourceQualifier, resourceLanguage) {
+ config["resource"] = [
+ {"id":resourceId, "key":resourceKey, "name":resourceName, "scope":resourceScope, "qualifier":resourceQualifier,
+ "lang":resourceLanguage}
+ ];
+ config["resource_key"] = resourceId;
+ modules[gwtId]();
+ }
</script>
};
var url = '<%= ApplicationController.root_context -%>/issues/search?' + jQuery.param(params);
- openAccordionItem(url, this, false);
+ openAccordionItem(url);
return false;
}
<a href="#" title="<%= h resource.name(true) -%>" data-key="<%= resource.key -%>"
class="js-drilldown-link underlined-link"><%= h resource.name(false) %></a>
<% else %>
- <%= link_to(h(resource.name), {:only_path => true, :overwrite_params => {:rids => (selected ? rids-[resource.id] : rids+[resource.id])}}, :class => 'underlined-link') -%>
+ <%= link_to(h(resource.name), params.merge({:only_path => true, :rids => (selected ? rids-[resource.id] : rids+[resource.id])}), :class => 'underlined-link') -%>
<% end %>
</td>
<td class="right">
--- /dev/null
+<%
+ controller.java_facade.getResourceTabs().each do |tab|
+ if tab.isGwt()
+%>
+ <script src="<%= ApplicationController.root_context -%>/deploy/gwt/<%= tab.getId() -%>/<%= tab.getId() -%>.nocache.js"></script>
+ <%
+ end
+ end
+ %>
<li>
<%= qualifier_icon(resource) -%>
- <%= link_to(h(resource.name),
- {:overwrite_params => {:id => resource.key}.merge(resource_link)}
- ) -%>
+ <%= link_to(h(resource.name), params.merge({:id => resource.key}.merge(resource_link))) -%>
</li>
<%
end
--- /dev/null
+<%
+ if @extensions.empty?
+%>
+ <span class="note"><%= message('code_viewer.no_info_displayed_due_to_security') -%></span>
+<%
+ else
+ display_title=(params[:display_title]=='true')
+%>
+
+ <% if display_title %>
+ <div class="source_title">
+ <% if @resource.project %>
+ <div class="subtitle">
+ <%= h @resource.ancestor_projects.reverse.map{|p| p.name(true)}.join(' / ') -%>
+ </div>
+ <% end %>
+ <% if logged_in? %><%= link_to_favourite(@resource) -%><% end %>
+ <span class="h1"><%= qualifier_icon(@resource) -%> <%= h @resource.name(true) -%></span>
+ </div>
+ <% end %>
+
+ <div class="source_tabs">
+ <ul class="tablinks">
+ <% first=true %>
+ <% if @snapshot.has_source && has_role?(:codeviewer, @snapshot) %>
+ <li class="<%= 'first' if first -%>">
+ <a href="<%= ApplicationController.root_context -%>/api/sources?resource=<%= @resource.key -%>&format=txt"><%= message('raw') -%></a>
+ </li>
+ <% first=false
+ end %>
+ <% unless @popup_mode %>
+ <li class="<%= 'first' if first -%>">
+ <a href="<%= url_for :controller => 'resource', :action => 'index', :id => @resource.key, :period => params[:period], :metric => params[:metric],
+ :rule => params[:rule] ? params[:rule] : params[:rule_sev], :display_title => 'true' -%>"
+ onclick="window.open(this.href,'resource','height=800,width=900,scrollbars=1,resizable=1');return false;"
+ id="new-window-<%= @resource.key.parameterize -%>"><%= image_tag 'new-window-16.gif', :alt => message('new_window') -%></a>
+ </li>
+ <% end %>
+ </ul>
+ <ul class="tabs">
+ <% @extensions.each do |extension| %>
+ <li>
+ <a href="#" onclick="return loadResourceViewer('<%= @resource.id -%>','<%= extension.getId() -%>',<%= display_title -%>,'<%= params[:period] -%>', this)"
+ class="<%= 'selected' if @extension && @extension.getId()==extension.getId() -%>"><%= message(extension.getId() + '.page', :default => extension.getTitle()) %></a>
+ </li>
+ <% end %>
+ <li>
+ <img src="<%= ApplicationController.root_context -%>/images/loading.gif" id="resource_loading" class="accordion-loading" style="display:none"/>
+ </li>
+ </ul>
+ </div>
+
+
+<% end %>
--- /dev/null
+<div>
+ <div class="accordion-item-header">
+ <%= render :partial => 'tabs' -%>
+ </div>
+ <div class="accordion-item-body">
+ <% if @extension.isGwt() %>
+ <div id="gwtpage"> </div>
+ <script>
+ loadGWT('<%= @extension.getId() -%>', <%= @resource.id -%>,'<%= escape_javascript(@resource.key) -%>', '<%= escape_javascript(@resource.name) -%>',
+ '<%= @resource.scope -%>', '<%= @resource.qualifier -%>', '<%= escape_javascript(@resource.language) -%>');
+ </script>
+ <% elsif @extension.getTarget() # ruby on rails page %>
+ <%= render :inline => @extension.getTarget().getTemplate() -%>
+ <% end %>
+ </div>
+</div>
<td class="ind <%= statuses[:hits] -%>" title="<%= message('coverage_viewer.line_covered_by_x_tests', {:params => line.covered_lines.to_s}) if line.covered_lines > 0 -%>">
<% if line.covered_lines > 0 %>
<a href="<%= ApplicationController.root_context -%>/test/testable/<%= h resource_key -%>?line=<%= index+1 -%>"
- class="sources-testable-link-<%= index+1 -%>" onclick="openAccordionItem(this.href, this); return false;"><%= line.covered_lines -%></a>
+ class="sources-testable-link-<%= index+1 -%>" onclick="openAccordionItem(this.href); return false;"><%= line.covered_lines -%></a>
<% end %>
</td>
<td class="ind <%= statuses[:conditions] -%>">