aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2011-07-22 18:31:44 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2011-07-22 18:31:44 +0200
commit7c5ad0fb89f5b6ec822ecbd200806565a97f7e6c (patch)
tree91c721e513fad6af91ac92624a0cc968535195be
parente5220956e1fba2afb839760c41aa195abe05d54d (diff)
downloadsonarqube-7c5ad0fb89f5b6ec822ecbd200806565a97f7e6c.tar.gz
sonarqube-7c5ad0fb89f5b6ec822ecbd200806565a97f7e6c.zip
SONAR-2006 Allow to select manual measures in filters treemap
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/metrics/UserManagedMetrics.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/manual_measure.rb6
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/sonar/treemap_builder.rb5
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_treemap.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/filters/treemap.html.erb2
6 files changed, 12 insertions, 9 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/metrics/UserManagedMetrics.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/metrics/UserManagedMetrics.java
index 6907cacf1ef..8082cd4b95c 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/metrics/UserManagedMetrics.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/metrics/UserManagedMetrics.java
@@ -25,7 +25,7 @@ import org.sonar.api.measures.Metrics;
import java.util.Arrays;
import java.util.List;
-public class UserManagedMetrics implements Metrics {
+public final class UserManagedMetrics implements Metrics {
private static final String DOMAIN = "Management";
public List<Metric> getMetrics() {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java
index 41b8752672b..dc27e6fe46e 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java
@@ -353,14 +353,14 @@ public class Metric implements ServerExtension, BatchExtension {
}
/**
- * @return whether the metric is a managed by the users (manual metric)
+ * @return whether the metric is a managed by the users ("manual metric")
*/
public Boolean getUserManaged() {
return userManaged;
}
/**
- * Sets whether the metric is user managed
+ * Sets whether the metric is managed by users ("manual metric")
*
* @param userManaged whether the metric is user managed
* @return this
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/manual_measure.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/manual_measure.rb
index 7aefff51190..f8a6cc5a02b 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/manual_measure.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/manual_measure.rb
@@ -48,7 +48,11 @@ class ManualMeasure < ActiveRecord::Base
end
def validate_metric
- errors.add_to_base("Not a valid metric") unless metric && metric.enabled?
+ if metric.nil? || !metric.enabled?
+ errors.add_to_base("Unknown metric")
+ elsif !metric.user_managed?
+ errors.add_to_base("Not a manual metric")
+ end
end
def pending?(snapshot=nil)
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/treemap_builder.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/treemap_builder.rb
index 0be1a8494c9..4c9baa68cd5 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/treemap_builder.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/treemap_builder.rb
@@ -25,9 +25,8 @@ class Sonar::TreemapBuilder
CONFIGURATION_DEFAULT_SIZE_METRIC = 'sonar.core.treemap.sizemetric'
def self.size_metrics(options={})
- exclude_user_managed=options[:exclude_user_managed]||false
- Metric.all.select{ |metric|
- metric.treemap_size? && (!exclude_user_managed || !metric.user_managed?)
+ Metric.all.select{ |metric|
+ metric.treemap_size?
}.sort
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_treemap.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_treemap.html.erb
index 7b6eea93a2e..dacce6494f5 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_treemap.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_treemap.html.erb
@@ -7,7 +7,7 @@
<tr>
<td class="keyCell"><%= message('size') -%>:</td>
<td>
- <%= select_tag 'columns[]', options_grouped_by_domain(Sonar::TreemapBuilder.size_metrics({:exclude_user_managed => true}), size_metric.key),
+ <%= select_tag 'columns[]', options_grouped_by_domain(Sonar::TreemapBuilder.size_metrics(), size_metric.key),
:id => 'size_metric' %>
</td>
</tr>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/treemap.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/treemap.html.erb
index ade8c73ef2f..3b6601281b4 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/treemap.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/treemap.html.erb
@@ -4,7 +4,7 @@
<tr>
<td>
<span class="comments"><%= message('size') -%>:</span><br/>
- <%= select_tag 'size_metric', options_grouped_by_domain(Sonar::TreemapBuilder.size_metrics({:exclude_user_managed => true}), @size_metric.key),
+ <%= select_tag 'size_metric', options_grouped_by_domain(Sonar::TreemapBuilder.size_metrics(), @size_metric.key),
:id => 'size_metric', :class => 'small', :onchange => "load_treemap(this.form.size_metric.value,this.form.color_metric.value, false);return false;" %>
</td>
<td class="sep"> </td>