From ad9d1149559aa8a5b3a608d00b31901e9f5a590c Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Tue, 15 Jul 2014 12:50:12 +0600 Subject: SONAR-5207 Remove ruby treemap --- .../WEB-INF/app/models/measure_filter_display.rb | 2 +- .../app/models/measure_filter_display_treemap.rb | 149 --------------------- 2 files changed, 1 insertion(+), 150 deletions(-) delete mode 100644 server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter_display_treemap.rb (limited to 'server/sonar-web') diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter_display.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter_display.rb index 8c691228f75..5763d3179db 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter_display.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter_display.rb @@ -19,7 +19,7 @@ # class MeasureFilterDisplay - DISPLAY_CLASSES = [MeasureFilterDisplayList, MeasureFilterDisplayTreemap] + DISPLAY_CLASSES = [MeasureFilterDisplayList] def self.create(filter, options) key = filter.criteria('display') diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter_display_treemap.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter_display_treemap.rb deleted file mode 100644 index 775cc1a5236..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter_display_treemap.rb +++ /dev/null @@ -1,149 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2014 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 3 of the License, or (at your option) any later version. -# -# SonarQube is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -require 'set' -class MeasureFilterDisplayTreemap < MeasureFilterDisplay - include ActionView::Helpers::UrlHelper - - KEY = :treemap - PROPERTY_KEYS = Set.new([:tmSize, :tmColor, :tmHeight]) - MAX_RESULTS = 1000 - DEFAULT_HEIGHT_PERCENTS = 55 - attr_reader :id, :size, :size_metric, :color_metric, :height_percents - - def initialize(filter, options) - super(filter, options) - - @size_metric = Metric.by_key(@filter.criteria(:tmSize)||'ncloc') - @color_metric = Metric.by_key(@filter.criteria(:tmColor)||'coverage') - @height_percents = (@filter.criteria(:tmHeight) || DEFAULT_HEIGHT_PERCENTS).to_i - @height_percents = DEFAULT_HEIGHT_PERCENTS if @height_percents<=0 - @filter.metrics=([@size_metric, @color_metric].compact) - @id_count = 0 - - filter.set_criteria_value(:pageSize, MAX_RESULTS) - filter.set_criteria_value(:page, 1) - end - - def html - # SONAR-3524 - # If filter is empty, we return a empty result in order to be treated more easily - if filter.rows && !filter.rows.empty? - root = Treemap::Node.new(:id => -1, :label => '') - build_tree(root) - output = Sonar::HtmlOutput.new do |o| - # width in percents - o.width = 100 - o.height = 100 - o.full_html = false - o.details_at_depth = 1 - end - output.to_html(root) - end - end - - def empty? - @filter.rows.nil? || @filter.rows.empty? - end - - def url_params - @filter.criteria.select { |k, v| PROPERTY_KEYS.include?(k.to_sym) } - end - - private - - def build_tree(node) - if @filter.rows && @size_metric - @filter.rows.each do |row| - size_measure=row.measure(@size_metric) - if size_measure - color_measure=(@color_metric ? row.measure(@color_metric) : nil) - resource = row.snapshot.resource - child = Treemap::Node.new(:size => size_value(size_measure), - :label => resource.name(false), - :title => escape_javascript(resource.name(true)), - :tooltip => tooltip(resource, size_measure, color_measure), - :color => MeasureColor.color(color_measure, {:check_alert_status => false}).html, - :rid => resource.id, - :leaf => resource.source_code?) - node.add_child(child) - end - end - end - end - - def tooltip(resource, size_measure, color_measure) - html=CGI::escapeHTML(resource.name(true)) - html += " - #{CGI::escapeHTML(@size_metric.short_name)}: #{CGI::escapeHTML(size_measure.formatted_value)}" - if color_measure - html += " - #{CGI::escapeHTML(@color_metric.short_name)}: #{CGI::escapeHTML(color_measure.formatted_value)}" - end - html - end - - def size_value(measure) - if measure.value - measure.value.to_f.abs||0.0 - else - 0.0 - end - end - -end - -class Sonar::HtmlOutput < Treemap::HtmlOutput - - def draw_node(node) - return "" if node.bounds.nil? - - html = '' - html += "
" - if node.rid - html += "
0) - node.children.each do |c| - html += draw_node(c) - end - end - html + '
' - end - - def draw_label(node) - if node.leaf - "#{node_label(node)}" - else - "#{node_label(node)}" - end - end -end -- cgit v1.2.3