import org.sonar.plugins.core.widgets.TimelineWidget;
import org.sonar.plugins.core.widgets.TreemapWidget;
import org.sonar.plugins.core.widgets.WelcomeWidget;
-import org.sonar.plugins.core.widgets.actionPlans.ActionPlansWidget;
+import org.sonar.plugins.core.widgets.ActionPlansWidget;
import org.sonar.plugins.core.widgets.reviews.FalsePositiveReviewsWidget;
import org.sonar.plugins.core.widgets.reviews.MyReviewsWidget;
import org.sonar.plugins.core.widgets.reviews.PlannedReviewsWidget;
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.widgets;
+
+import org.sonar.api.web.WidgetCategory;
+
+@WidgetCategory({"Action plans", "Reviews"})
+public class ActionPlansWidget extends CoreWidget {
+ public ActionPlansWidget() {
+ super("action_plans", "Action plans", "/org/sonar/plugins/core/widgets/actionPlans/action_plans.html.erb");
+ }
+}
\ No newline at end of file
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.WidgetLayout;
import org.sonar.api.web.WidgetLayoutType;
@WidgetLayout(WidgetLayoutType.NONE)
-public class AlertsWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+public class AlertsWidget extends CoreWidget {
- public String getId() {
- return "alerts";
+ public AlertsWidget() {
+ super("alerts", "Alerts", "/org/sonar/plugins/core/widgets/alerts.html.erb");
}
- public String getTitle() {
- return "Alerts";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/alerts.html.erb";
- }
}
\ No newline at end of file
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
+public class CommentsDuplicationsWidget extends CoreWidget {
-public class CommentsDuplicationsWidget extends AbstractRubyTemplate implements RubyRailsWidget {
-
- public String getId() {
- return "comments_duplications";
- }
-
- public String getTitle() {
- return "Comments & Duplications";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/comments_duplications.html.erb";
+ public CommentsDuplicationsWidget() {
+ super("comments_duplications", "Comments & Duplications", "/org/sonar/plugins/core/widgets/comments_duplications.html.erb");
}
}
\ No newline at end of file
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
+public class ComplexityWidget extends CoreWidget {
-public class ComplexityWidget extends AbstractRubyTemplate implements RubyRailsWidget {
-
- public String getId() {
- return "complexity";
- }
-
- public String getTitle() {
- return "Complexity";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/complexity.html.erb";
+ public ComplexityWidget() {
+ super("complexity", "Complexity", "/org/sonar/plugins/core/widgets/complexity.html.erb");
}
}
\ No newline at end of file
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.widgets;
+
+import org.sonar.api.web.AbstractRubyTemplate;
+import org.sonar.api.web.RubyRailsWidget;
+
+public abstract class CoreWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+ private String id, title, templatePath;
+
+ protected CoreWidget(String id, String title, String templatePath) {
+ this.id = id;
+ this.title = title;
+ this.templatePath = templatePath;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ @Override
+ protected String getTemplatePath() {
+ return templatePath;
+ }
+}
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.UserRole;
import org.sonar.api.web.WidgetCategory;
@WidgetCategory("Tests")
@UserRole(UserRole.USER)
-public class CoverageWidget extends AbstractRubyTemplate implements RubyRailsWidget {
- public String getId() {
- return "code_coverage";
- }
-
- public String getTitle() {
- return "Code coverage";
- }
+public class CoverageWidget extends CoreWidget {
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/coverage.html.erb";
+ public CoverageWidget() {
+ super("code_coverage", "Code coverage", "/org/sonar/plugins/core/widgets/coverage.html.erb");
}
}
\ No newline at end of file
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.WidgetProperties;
import org.sonar.api.web.WidgetProperty;
import org.sonar.api.web.WidgetPropertyType;
-@WidgetProperties(
-{
- @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric4", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric5", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric6", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric7", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric8", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric9", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric10", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS})
+@WidgetProperties({
+ @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric4", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric5", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric6", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric7", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric8", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric9", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric10", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS})
})
-public class CustomMeasuresWidget extends AbstractRubyTemplate implements RubyRailsWidget {
- public String getId() {
- return "custom_measures";
- }
-
- public String getTitle() {
- return "Custom Measures";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/custom_measures.html.erb";
+public class CustomMeasuresWidget extends CoreWidget {
+ public CustomMeasuresWidget() {
+ super("custom_measures", "Custom Measures", "/org/sonar/plugins/core/widgets/custom_measures.html.erb");
}
}
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.WidgetLayout;
import org.sonar.api.web.WidgetLayoutType;
@WidgetLayout(WidgetLayoutType.NONE)
-public class DescriptionWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+public class DescriptionWidget extends CoreWidget {
- public String getId() {
- return "description";
- }
-
- public String getTitle() {
- return "Description";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/description.html.erb";
+ public DescriptionWidget() {
+ super("description", "Description", "/org/sonar/plugins/core/widgets/description.html.erb");
}
}
\ No newline at end of file
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
+public class EventsWidget extends CoreWidget {
-public class EventsWidget extends AbstractRubyTemplate implements RubyRailsWidget {
-
- public String getId() {
- return "events";
- }
-
- public String getTitle() {
- return "Events";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/events.html.erb";
+ public EventsWidget() {
+ super("events", "Events", "/org/sonar/plugins/core/widgets/events.html.erb");
}
}
\ No newline at end of file
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.WidgetCategory;
import org.sonar.api.web.WidgetProperties;
import org.sonar.api.web.WidgetProperty;
import org.sonar.api.web.WidgetPropertyType;
@WidgetCategory({ "Hotspots" })
-@WidgetProperties(
- {
+@WidgetProperties({
@WidgetProperty(key = "title", type = WidgetPropertyType.STRING),
@WidgetProperty(key = "metric", type = WidgetPropertyType.METRIC, defaultValue = "ncloc"),
@WidgetProperty(key = "numberOfLines", type = WidgetPropertyType.INTEGER, defaultValue = "5")
- }
-)
-public class HotspotMetricWidget extends AbstractRubyTemplate implements RubyRailsWidget {
- public String getId() {
- return "hotspot_metric";
- }
-
- public String getTitle() {
- return "Metric hotspot";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/hotspots/hotspot_metric.html.erb";
+})
+public class HotspotMetricWidget extends CoreWidget {
+ public HotspotMetricWidget() {
+ super("hotspot_metric", "Metric hotspot", "/org/sonar/plugins/core/widgets/hotspots/hotspot_metric.html.erb");
}
}
\ No newline at end of file
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.WidgetCategory;
import org.sonar.api.web.WidgetProperties;
import org.sonar.api.web.WidgetProperty;
import org.sonar.api.web.WidgetPropertyType;
-@WidgetCategory({ "Hotspots" })
-@WidgetProperties(
- {
- @WidgetProperty(key = "numberOfLines", type = WidgetPropertyType.INTEGER, defaultValue = "5")
- }
-)
-public class HotspotMostViolatedResourcesWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+@WidgetCategory({"Hotspots"})
+@WidgetProperties({
+ @WidgetProperty(key = "numberOfLines", type = WidgetPropertyType.INTEGER, defaultValue = "5")
+})
+public class HotspotMostViolatedResourcesWidget extends CoreWidget {
- public String getId() {
- return "hotspot_most_violated_resources";
- }
-
- public String getTitle() {
- return "Most violated resources";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/hotspots/hotspot_most_violated_resources.html.erb";
+ public HotspotMostViolatedResourcesWidget() {
+ super("hotspot_most_violated_resources", "Most violated resources", "/org/sonar/plugins/core/widgets/hotspots/hotspot_most_violated_resources.html.erb");
}
}
\ No newline at end of file
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.*;
+import org.sonar.api.web.WidgetCategory;
+import org.sonar.api.web.WidgetProperties;
+import org.sonar.api.web.WidgetProperty;
+import org.sonar.api.web.WidgetPropertyType;
@WidgetCategory("Hotspots")
@WidgetProperties(
@WidgetProperty(key = "defaultSeverity", type = WidgetPropertyType.STRING, description = "Values: BLOCKER, CRITICAL, MAJOR, MINOR, INFO")
}
)
-public class HotspotMostViolatedRulesWidget extends AbstractRubyTemplate implements RubyRailsWidget {
- public String getId() {
- return "hotspot_most_violated_rules";
- }
-
- public String getTitle() {
- return "Most violated rules";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/hotspots/hotspot_most_violated_rules.html.erb";
+public class HotspotMostViolatedRulesWidget extends CoreWidget {
+ public HotspotMostViolatedRulesWidget() {
+ super("hotspot_most_violated_rules", "Most violated rules", "/org/sonar/plugins/core/widgets/hotspots/hotspot_most_violated_rules.html.erb");
}
}
\ No newline at end of file
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.UserRole;
import org.sonar.api.web.WidgetCategory;
@WidgetCategory("Tests")
@UserRole(UserRole.USER)
-public class ItCoverageWidget extends AbstractRubyTemplate implements RubyRailsWidget {
- public String getId() {
- return "it-coverage";
- }
-
- public String getTitle() {
- return "Integration Test Coverage";
- }
+public class ItCoverageWidget extends CoreWidget {
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/it_coverage.html.erb";
+ public ItCoverageWidget() {
+ super("it-coverage", "Integration Test Coverage", "/org/sonar/plugins/core/widgets/it_coverage.html.erb");
}
}
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.WidgetCategory;
import org.sonar.api.web.WidgetProperties;
import org.sonar.api.web.WidgetProperty;
@WidgetProperties({
@WidgetProperty(key = MeasureFilterListWidget.FILTER_PROPERTY, type = WidgetPropertyType.FILTER, optional = false),
@WidgetProperty(key = MeasureFilterListWidget.PAGE_SIZE_PROPERTY, type = WidgetPropertyType.INTEGER, defaultValue = "30")
-}
-)
-public class MeasureFilterListWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+})
+public class MeasureFilterListWidget extends CoreWidget {
public static final String FILTER_PROPERTY = "filter";
public static final String PAGE_SIZE_PROPERTY = "pageSize";
public static final String ID = "measure_filter_list";
- public String getId() {
- return ID;
- }
-
- public String getTitle() {
- return "Measure Filter as List";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/measure_filter_list.html.erb";
+ public MeasureFilterListWidget() {
+ super(ID, "Measure Filter as List",
+ "/org/sonar/plugins/core/widgets/measure_filter_list.html.erb");
}
}
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.WidgetCategory;
import org.sonar.api.web.WidgetProperties;
import org.sonar.api.web.WidgetProperty;
@WidgetProperty(key = MeasureFilterTreemapWidget.FILTER_PROPERTY, type = WidgetPropertyType.FILTER, optional = false),
@WidgetProperty(key = MeasureFilterTreemapWidget.SIZE_METRIC_PROPERTY, type = WidgetPropertyType.METRIC, optional = true),
@WidgetProperty(key = MeasureFilterTreemapWidget.COLOR_METRIC_PROPERTY, type = WidgetPropertyType.METRIC, optional = true, options = "type:PERCENT")
-}
-)
-public class MeasureFilterTreemapWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+})
+public class MeasureFilterTreemapWidget extends CoreWidget {
public static final String FILTER_PROPERTY = "filter";
public static final String SIZE_METRIC_PROPERTY = "sizeMetric";
public static final String COLOR_METRIC_PROPERTY = "colorMetric";
public static final String ID = "measure_filter_treemap";
- public String getId() {
- return ID;
- }
-
- public String getTitle() {
- return "Measure Filter as Treemap";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/measure_filter_treemap.html.erb";
+ public MeasureFilterTreemapWidget() {
+ super(ID, "Measure Filter as Treemap", "/org/sonar/plugins/core/widgets/measure_filter_treemap.html.erb");
}
}
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.WidgetCategory;
-@WidgetCategory({ "Rules" })
-public class RulesWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+@WidgetCategory({"Rules"})
+public class RulesWidget extends CoreWidget {
- public String getId() {
- return "rules";
- }
-
- public String getTitle() {
- return "Rules Compliance";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/rules.html.erb";
+ public RulesWidget() {
+ super("rules", "Rules Compliance", "/org/sonar/plugins/core/widgets/rules.html.erb");
}
}
\ No newline at end of file
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
+public class SizeWidget extends CoreWidget {
-public class SizeWidget extends AbstractRubyTemplate implements RubyRailsWidget {
-
- public String getId() {
- return "size";
- }
-
- public String getTitle() {
- return "Size metrics";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/size.html.erb";
+ public SizeWidget() {
+ super("size", "Size metrics", "/org/sonar/plugins/core/widgets/size.html.erb");
}
}
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.WidgetCategory;
import org.sonar.api.web.WidgetProperties;
import org.sonar.api.web.WidgetProperty;
@WidgetProperty(key = "title", type = WidgetPropertyType.STRING),
@WidgetProperty(key = "numberOfColumns", type = WidgetPropertyType.INTEGER, defaultValue = "3"),
@WidgetProperty(key = "displaySparkLine", type = WidgetPropertyType.BOOLEAN),
- @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric4", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric5", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric6", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric7", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric8", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric9", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric10", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS})
+ @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric4", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric5", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric6", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric7", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric8", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric9", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric10", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS})
})
-public class TimeMachineWidget extends AbstractRubyTemplate implements RubyRailsWidget {
- public String getId() {
- return "time_machine";
- }
-
- public String getTitle() {
- return "History Table";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/time_machine.html.erb";
+public class TimeMachineWidget extends CoreWidget {
+ public TimeMachineWidget() {
+ super("time_machine", "History Table", "/org/sonar/plugins/core/widgets/time_machine.html.erb");
}
}
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.WidgetCategory;
import org.sonar.api.web.WidgetProperties;
import org.sonar.api.web.WidgetProperty;
@WidgetCategory("History")
@WidgetProperties({
@WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING),
- @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
- @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
@WidgetProperty(key = "hideEvents", type = WidgetPropertyType.BOOLEAN),
@WidgetProperty(key = "chartHeight", type = WidgetPropertyType.INTEGER, defaultValue = "80")
})
-public class TimelineWidget extends AbstractRubyTemplate implements RubyRailsWidget {
- public String getId() {
- return "timeline";
- }
-
- public String getTitle() {
- return "Timeline";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/timeline.html.erb";
+public class TimelineWidget extends CoreWidget {
+ public TimelineWidget() {
+ super("timeline", "Timeline", "/org/sonar/plugins/core/widgets/timeline.html.erb");
}
}
package org.sonar.plugins.core.widgets;
import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.web.*;
+import org.sonar.api.web.WidgetProperties;
+import org.sonar.api.web.WidgetProperty;
+import org.sonar.api.web.WidgetPropertyType;
@WidgetProperties({
- @WidgetProperty(key = "sizeMetric", type= WidgetPropertyType.METRIC, defaultValue = CoreMetrics.NCLOC_KEY, description = "Default metric for size"),
- @WidgetProperty(key = "colorMetric", type= WidgetPropertyType.METRIC, defaultValue = CoreMetrics.VIOLATIONS_DENSITY_KEY, description = "Default metric for color")
+ @WidgetProperty(key = "sizeMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.NCLOC_KEY, description = "Default metric for size"),
+ @WidgetProperty(key = "colorMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.VIOLATIONS_DENSITY_KEY, description = "Default metric for color")
})
-public class TreemapWidget extends AbstractRubyTemplate implements RubyRailsWidget {
- public String getId() {
+public class TreemapWidget extends CoreWidget {
+ public TreemapWidget() {
// do not use the id "treemap" to avoid conflict with the same CSS class
- return "treemap-widget";
- }
-
- public String getTitle() {
- return "Treemap of Components";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/treemap.html.erb";
+ super("treemap-widget", "Treemap of Components", "/org/sonar/plugins/core/widgets/treemap.html.erb");
}
}
\ No newline at end of file
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.WidgetCategory;
import org.sonar.api.web.WidgetScope;
@WidgetCategory({"Global"})
@WidgetScope(GLOBAL)
-public class WelcomeWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+public class WelcomeWidget extends CoreWidget {
public static final String ID = "welcome";
- public String getId() {
- return ID;
- }
-
- public String getTitle() {
- return "Welcome";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/welcome.html.erb";
+ public WelcomeWidget() {
+ super(ID, "Welcome", "/org/sonar/plugins/core/widgets/welcome.html.erb");
}
}
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.widgets;
+
+/**
+ * Constants shared accross multiple widgets
+ */
+interface WidgetConstants {
+
+ /**
+ * Widget property option used to filter out all the metrics which keys start with "new_".
+ *
+ * @see org.sonar.api.web.WidgetProperty#options()
+ */
+ String FILTER_OUT_NEW_METRICS = "key:^(?!new_).*";
+}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.core.widgets;
-
-/**
- * Constants shared accross multiple widgets
- */
-interface WidgetsConstants {
-
- /**
- * Widget property option used to filter out all the metrics which keys start with "new_".
- *
- * @see org.sonar.api.web.WidgetProperty#options()
- */
- String FILTER_OUT_NEW_METRICS = "key:^(?!new_).*";
-}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.core.widgets.actionPlans;
-
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
-import org.sonar.api.web.WidgetCategory;
-
-@WidgetCategory({ "Action plans", "Reviews" })
-public class ActionPlansWidget extends AbstractRubyTemplate implements RubyRailsWidget {
- public String getId() {
- return "action_plans";
- }
-
- public String getTitle() {
- return "Action plans";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/actionPlans/action_plans.html.erb";
- }
-}
\ No newline at end of file
*/
package org.sonar.plugins.core.widgets.reviews;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.WidgetCategory;
import org.sonar.api.web.WidgetProperties;
import org.sonar.api.web.WidgetProperty;
import org.sonar.api.web.WidgetPropertyType;
+import org.sonar.plugins.core.widgets.CoreWidget;
-@WidgetCategory({ "Reviews" })
-@WidgetProperties(
- {
- @WidgetProperty(key = "numberOfLines", type = WidgetPropertyType.INTEGER, defaultValue = "5",
- description="Maximum number of reviews displayed at the same time.")
- }
-)
-public class FalsePositiveReviewsWidget extends AbstractRubyTemplate implements RubyRailsWidget {
- public String getId() {
- return "false_positive_reviews";
- }
-
- public String getTitle() {
- return "False positive open reviews";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/reviews/false_positive_reviews.html.erb";
+@WidgetCategory({"Reviews"})
+@WidgetProperties({
+ @WidgetProperty(key = "numberOfLines", type = WidgetPropertyType.INTEGER, defaultValue = "5",
+ description = "Maximum number of reviews displayed at the same time.")
+})
+public class FalsePositiveReviewsWidget extends CoreWidget {
+ public FalsePositiveReviewsWidget() {
+ super("false_positive_reviews", "False positive open reviews", "/org/sonar/plugins/core/widgets/reviews/false_positive_reviews.html.erb");
}
}
\ No newline at end of file
*/
package org.sonar.plugins.core.widgets.reviews;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.WidgetCategory;
import org.sonar.api.web.WidgetProperties;
import org.sonar.api.web.WidgetProperty;
import org.sonar.api.web.WidgetPropertyType;
+import org.sonar.plugins.core.widgets.CoreWidget;
-@WidgetCategory({ "Reviews" })
-@WidgetProperties(
- {
- @WidgetProperty(key = "numberOfLines", type = WidgetPropertyType.INTEGER, defaultValue = "5",
- description="Maximum number of reviews displayed at the same time.")
- }
-)
-public class MyReviewsWidget extends AbstractRubyTemplate implements RubyRailsWidget {
- public String getId() {
- return "my_reviews";
- }
-
- public String getTitle() {
- return "My active reviews";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/reviews/my_reviews.html.erb";
+@WidgetCategory({"Reviews"})
+@WidgetProperties({
+ @WidgetProperty(key = "numberOfLines", type = WidgetPropertyType.INTEGER, defaultValue = "5",
+ description = "Maximum number of reviews displayed at the same time.")
+})
+public class MyReviewsWidget extends CoreWidget {
+ public MyReviewsWidget() {
+ super("my_reviews", "My active reviews", "/org/sonar/plugins/core/widgets/reviews/my_reviews.html.erb");
}
}
\ No newline at end of file
*/
package org.sonar.plugins.core.widgets.reviews;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.WidgetCategory;
import org.sonar.api.web.WidgetProperties;
import org.sonar.api.web.WidgetProperty;
import org.sonar.api.web.WidgetPropertyType;
+import org.sonar.plugins.core.widgets.CoreWidget;
-@WidgetCategory({ "Action plans", "Reviews" })
-@WidgetProperties(
- {
- @WidgetProperty(key = "numberOfLines", type = WidgetPropertyType.INTEGER, defaultValue = "5",
- description="Maximum number of reviews displayed at the same time.")
- }
-)
-public class PlannedReviewsWidget extends AbstractRubyTemplate implements RubyRailsWidget {
- public String getId() {
- return "planned_reviews";
- }
-
- public String getTitle() {
- return "Planned reviews";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/reviews/planned_reviews.html.erb";
+@WidgetCategory({"Action plans", "Reviews"})
+@WidgetProperties({
+ @WidgetProperty(key = "numberOfLines", type = WidgetPropertyType.INTEGER, defaultValue = "5",
+ description = "Maximum number of reviews displayed at the same time.")
+})
+public class PlannedReviewsWidget extends CoreWidget {
+ public PlannedReviewsWidget() {
+ super("planned_reviews", "Planned reviews", "/org/sonar/plugins/core/widgets/reviews/planned_reviews.html.erb");
}
}
\ No newline at end of file
*/
package org.sonar.plugins.core.widgets.reviews;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.WidgetCategory;
import org.sonar.api.web.WidgetProperties;
import org.sonar.api.web.WidgetProperty;
import org.sonar.api.web.WidgetPropertyType;
+import org.sonar.plugins.core.widgets.CoreWidget;
-@WidgetCategory({ "Reviews" })
-@WidgetProperties(
- {
- @WidgetProperty(key = "numberOfLines", type = WidgetPropertyType.INTEGER, defaultValue = "5",
- description="Maximum number of reviews displayed at the same time.")
- }
-)
-public class ProjectReviewsWidget extends AbstractRubyTemplate implements RubyRailsWidget {
- public String getId() {
- return "project_reviews";
- }
-
- public String getTitle() {
- return "Project active reviews";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/reviews/project_reviews.html.erb";
+@WidgetCategory({"Reviews"})
+@WidgetProperties({
+ @WidgetProperty(key = "numberOfLines", type = WidgetPropertyType.INTEGER, defaultValue = "5",
+ description = "Maximum number of reviews displayed at the same time.")
+})
+public class ProjectReviewsWidget extends CoreWidget {
+ public ProjectReviewsWidget() {
+ super("project_reviews", "Project active reviews", "/org/sonar/plugins/core/widgets/reviews/project_reviews.html.erb");
}
}
\ No newline at end of file
*/
package org.sonar.plugins.core.widgets.reviews;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.WidgetCategory;
+import org.sonar.plugins.core.widgets.CoreWidget;
-@WidgetCategory({ "Reviews" })
-public class ReviewsMetricsWidget extends AbstractRubyTemplate implements RubyRailsWidget {
- public String getId() {
- return "reviews_metrics";
- }
-
- public String getTitle() {
- return "Review Activity";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/reviews/reviews_metrics.html.erb";
+@WidgetCategory({"Reviews"})
+public class ReviewsMetricsWidget extends CoreWidget {
+ public ReviewsMetricsWidget() {
+ super("reviews_metrics", "Review Activity", "/org/sonar/plugins/core/widgets/reviews/reviews_metrics.html.erb");
}
}
*/
package org.sonar.plugins.core.widgets.reviews;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.WidgetCategory;
+import org.sonar.plugins.core.widgets.CoreWidget;
-@WidgetCategory({ "Reviews" })
-public class ReviewsPerDeveloperWidget extends AbstractRubyTemplate implements RubyRailsWidget {
- public String getId() {
- return "reviews_per_developer";
- }
-
- public String getTitle() {
- return "Active reviews per developer";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/reviews/reviews_per_developer.html.erb";
+@WidgetCategory({"Reviews"})
+public class ReviewsPerDeveloperWidget extends CoreWidget {
+ public ReviewsPerDeveloperWidget() {
+ super("reviews_per_developer", "Active reviews per developer", "/org/sonar/plugins/core/widgets/reviews/reviews_per_developer.html.erb");
}
}
\ No newline at end of file
*/
package org.sonar.plugins.core.widgets.reviews;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.WidgetCategory;
import org.sonar.api.web.WidgetProperties;
import org.sonar.api.web.WidgetProperty;
import org.sonar.api.web.WidgetPropertyType;
+import org.sonar.plugins.core.widgets.CoreWidget;
-@WidgetCategory({ "Action plans", "Reviews" })
-@WidgetProperties(
- {
- @WidgetProperty(key = "numberOfLines", type = WidgetPropertyType.INTEGER, defaultValue = "5",
- description="Maximum number of reviews displayed at the same time.")
- }
-)
-public class UnplannedReviewsWidget extends AbstractRubyTemplate implements RubyRailsWidget {
- public String getId() {
- return "unplanned_reviews";
- }
-
- public String getTitle() {
- return "Unplanned reviews";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/reviews/unplanned_reviews.html.erb";
+@WidgetCategory({"Action plans", "Reviews"})
+@WidgetProperties({
+ @WidgetProperty(key = "numberOfLines", type = WidgetPropertyType.INTEGER, defaultValue = "5",
+ description = "Maximum number of reviews displayed at the same time.")
+})
+public class UnplannedReviewsWidget extends CoreWidget {
+ public UnplannedReviewsWidget() {
+ super("unplanned_reviews", "Unplanned reviews", "/org/sonar/plugins/core/widgets/reviews/unplanned_reviews.html.erb");
}
}
\ No newline at end of file
package org.sonar.plugins.core;
import org.junit.Test;
-import org.reflections.Reflections;
-import org.sonar.api.web.AbstractRubyTemplate;
-
-import java.util.Set;
import static org.fest.assertions.Assertions.assertThat;
public class CorePluginTest {
@Test
- public void should_define_many_extensions() {
+ public void should_define_extensions() {
assertThat(new CorePlugin().getExtensions().size()).isGreaterThan(10);
}
-
- @Test
- public void should_contain_all_core_widgets() {
- Set<Class<? extends AbstractRubyTemplate>> widgets = new Reflections("org.sonar.plugins.core.widgets").getSubTypesOf(AbstractRubyTemplate.class);
-
- assertThat(widgets).isNotEmpty();
- assertThat(new CorePlugin().getExtensions()).contains(widgets.toArray());
- }
}
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.widgets;
+
+import com.google.common.base.Function;
+import com.google.common.base.Throwables;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Sets;
+import org.junit.Test;
+import org.reflections.Reflections;
+import org.sonar.plugins.core.CorePlugin;
+
+import javax.annotation.Nullable;
+
+import java.util.Collection;
+import java.util.Set;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class CoreWidgetsTest {
+
+ @Test
+ public void widget_ids_should_be_unique() {
+ Collection<CoreWidget> widgets = widgets();
+ Collection<String> widgetIds = Collections2.transform(widgets, new Function<CoreWidget, String>() {
+ public String apply(@Nullable CoreWidget widget) {
+ return widget.getId();
+ }
+ });
+ assertThat(widgetIds).hasSize(Sets.newHashSet(widgetIds).size());
+ }
+
+ @Test
+ public void widget_templates_should_be_unique() {
+ Collection<CoreWidget> widgets = widgets();
+ Collection<String> templates = Collections2.transform(widgets, new Function<CoreWidget, String>() {
+ public String apply(@Nullable CoreWidget widget) {
+ return widget.getTemplatePath();
+ }
+ });
+ assertThat(templates).hasSize(Sets.newHashSet(templates).size());
+ }
+
+ @Test
+ public void widget_titles_should_be_unique() {
+ Collection<CoreWidget> widgets = widgets();
+ Collection<String> templates = Collections2.transform(widgets, new Function<CoreWidget, String>() {
+ public String apply(@Nullable CoreWidget widget) {
+ return widget.getTitle();
+ }
+ });
+ assertThat(templates).hasSize(Sets.newHashSet(templates).size());
+ }
+
+ @Test
+ public void should_find_templates() {
+ for (CoreWidget widget : widgets()) {
+ assertThat(widget.getClass().getResource(widget.getTemplatePath())).isNotNull();
+ }
+ }
+
+ @Test
+ public void should_be_registered_as_an_extension() {
+ for (CoreWidget widget : widgets()) {
+ assertThat(new CorePlugin().getExtensions()).contains(widget.getClass());
+ }
+ }
+
+ @Test
+ public void should_find_core_widgets() {
+ assertThat(widgets().size()).isGreaterThan(25);
+ }
+
+ private Set<Class<? extends CoreWidget>> widgetClasses() {
+ String[] packages = {"org.sonar.plugins.core.widgets", "org.sonar.plugins.core.widgets.reviews"};
+ return new Reflections(packages).getSubTypesOf(CoreWidget.class);
+ }
+
+ private Collection<CoreWidget> widgets() {
+ return Collections2.transform(widgetClasses(), new Function<Class<? extends CoreWidget>, CoreWidget>() {
+ public CoreWidget apply(@Nullable Class<? extends CoreWidget> aClass) {
+ try {
+ return aClass.newInstance();
+ } catch (Exception e) {
+ throw Throwables.propagate(e);
+ }
+ }
+ });
+ }
+}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.core.widgets;
-
-import org.junit.Test;
-import org.sonar.plugins.core.CorePlugin;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class CoverageWidgetTest {
- @Test
- public void should_define_widget() {
- CoverageWidget widget = new CoverageWidget();
-
- assertThat(widget.getId()).isEqualTo("code_coverage");
- assertThat(widget.getTitle()).isEqualTo("Code coverage");
- }
-
- @Test
- public void should_find_template() {
- CoverageWidget widget = new CoverageWidget();
- assertThat(WelcomeWidget.class.getResource(widget.getTemplatePath())).isNotNull();
- }
-
- @Test
- public void should_be_registered_as_an_extension() {
- assertThat(new CorePlugin().getExtensions()).contains(CoverageWidget.class);
- }
-}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.core.widgets;
-
-import com.google.common.io.Resources;
-import org.junit.Test;
-import org.sonar.plugins.core.CorePlugin;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class ItCoverageWidgetTest {
- @Test
- public void should_define_widget() {
- ItCoverageWidget widget = new ItCoverageWidget();
-
- assertThat(widget.getId()).isEqualTo("it-coverage");
- assertThat(widget.getTitle()).isEqualTo("Integration Test Coverage");
- }
-
- @Test
- public void should_find_template() {
- ItCoverageWidget widget = new ItCoverageWidget();
- assertThat(ItCoverageWidget.class.getResource(widget.getTemplatePath())).isNotNull();
- }
-
- @Test
- public void should_be_registered_as_an_extension() {
- assertThat(new CorePlugin().getExtensions()).contains(ItCoverageWidget.class);
- }
-}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.core.widgets;
-
-import org.junit.Test;
-import org.sonar.plugins.core.CorePlugin;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class TreemapWidgetTest {
- @Test
- public void should_define_widget() {
- TreemapWidget widget = new TreemapWidget();
-
- assertThat(widget.getId()).isEqualTo("treemap-widget");
- assertThat(widget.getTitle()).isEqualTo("Treemap of Components");
- }
-
- @Test
- public void should_find_template() {
- TreemapWidget widget = new TreemapWidget();
- assertThat(WelcomeWidget.class.getResource(widget.getTemplatePath())).isNotNull();
- }
-
- @Test
- public void should_be_registered_as_an_extension() {
- assertThat(new CorePlugin().getExtensions()).contains(TreemapWidget.class);
- }
-}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.core.widgets;
-
-import org.junit.Test;
-import org.sonar.plugins.core.CorePlugin;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class WelcomeWidgetTest {
- @Test
- public void should_define_widget() {
- WelcomeWidget widget = new WelcomeWidget();
-
- assertThat(widget.getId()).isEqualTo("welcome");
- assertThat(widget.getTitle()).isEqualTo("Welcome");
- }
-
- @Test
- public void should_find_template() {
- WelcomeWidget widget = new WelcomeWidget();
- assertThat(WelcomeWidget.class.getResource(widget.getTemplatePath())).isNotNull();
- }
-
- @Test
- public void should_be_registered_as_an_extension() {
- assertThat(new CorePlugin().getExtensions()).contains(WelcomeWidget.class);
- }
-}