Просмотр исходного кода

SONAR-1378 Add the ability to specify a "type" when defining a plugin property

tags/3.0
Simon Brandhof 12 лет назад
Родитель
Сommit
c8ca6faa85
19 измененных файлов: 236 добавлений и 165 удалений
  1. 21
    19
      plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java
  2. 17
    9
      plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
  3. 65
    59
      plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdPlugin.java
  4. 12
    3
      plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DbCleanerPlugin.java
  5. 5
    1
      plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DefaultPurgeTask.java
  6. 24
    19
      plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsPlugin.java
  7. 3
    1
      plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
  8. 29
    28
      plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java
  9. 20
    0
      sonar-plugin-api/src/main/java/org/sonar/api/Property.java
  10. 15
    14
      sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java
  11. 0
    1
      sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb
  12. 1
    1
      sonar-server/src/main/webapp/WEB-INF/app/views/server_id_configuration/index.html.erb
  13. 9
    10
      sonar-server/src/main/webapp/WEB-INF/app/views/settings/_plugins.html.erb
  14. 5
    0
      sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_BOOLEAN.html.erb
  15. 1
    0
      sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_FLOAT.html.erb
  16. 1
    0
      sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_INTEGER.html.erb
  17. 1
    0
      sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PASSWORD.html.erb
  18. 6
    0
      sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_SINGLE_SELECT_LIST.html.erb
  19. 1
    0
      sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_TEXT.html.erb

+ 21
- 19
plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java Просмотреть файл

@@ -19,34 +19,36 @@
*/
package org.sonar.plugins.checkstyle;

import org.sonar.api.SonarPlugin;
import org.sonar.api.Properties;
import org.sonar.api.Property;
import org.sonar.api.SonarPlugin;

import java.util.Arrays;
import java.util.List;

@Properties( {
@Properties({
@Property(key = CheckstyleConstants.FILTERS_KEY,
defaultValue = CheckstyleConstants.FILTERS_DEFAULT_VALUE,
name = "Filters",
description = "Checkstyle support three error filtering mechanisms : SuppressionCommentFilter, SuppressWithNearbyCommentFilter and SuppressionFilter."
+ "This property allows to configure all those filters with a native XML format."
+ " See <a href='http://checkstyle.sourceforge.net/config.html'>Checkstyle configuration page</a> to get more information on those filters.",
project = false, global = true) })
public class CheckstylePlugin extends SonarPlugin {
defaultValue = CheckstyleConstants.FILTERS_DEFAULT_VALUE,
name = "Filters",
description = "Checkstyle support three error filtering mechanisms : SuppressionCommentFilter, SuppressWithNearbyCommentFilter and SuppressionFilter."
+ "This property allows to configure all those filters with a native XML format."
+ " See <a href='http://checkstyle.sourceforge.net/config.html'>Checkstyle configuration page</a> to get more information on those filters.",
project = false,
global = true,
type = Property.Type.TEXT)})
public final class CheckstylePlugin extends SonarPlugin {

public List getExtensions() {
return Arrays.asList(
CheckstyleSensor.class,
CheckstyleConfiguration.class,
CheckstyleExecutor.class,
CheckstyleAuditListener.class,
CheckstyleProfileExporter.class,
CheckstyleProfileImporter.class,
CheckstyleRuleRepository.class,
SonarWayProfile.class,
SunConventionsProfile.class,
SonarWayWithFindbugsProfile.class);
CheckstyleSensor.class,
CheckstyleConfiguration.class,
CheckstyleExecutor.class,
CheckstyleAuditListener.class,
CheckstyleProfileExporter.class,
CheckstyleProfileImporter.class,
CheckstyleRuleRepository.class,
SonarWayProfile.class,
SunConventionsProfile.class,
SonarWayWithFindbugsProfile.class);
}
}

+ 17
- 9
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java Просмотреть файл

@@ -74,7 +74,8 @@ import java.util.List;
project = true,
module = true,
global = true,
category = CoreProperties.CATEGORY_SECURITY),
category = CoreProperties.CATEGORY_SECURITY,
type = Property.Type.BOOLEAN),
@Property(
key = CoreProperties.CORE_TENDENCY_DEPTH_PROPERTY,
defaultValue = "" + CoreProperties.CORE_TENDENCY_DEPTH_DEFAULT_VALUE,
@@ -82,7 +83,8 @@ import java.util.List;
description = TendencyDecorator.PROP_DAYS_DESCRIPTION,
project = false,
global = true,
category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS,
type = Property.Type.INTEGER),
@Property(
key = CoreProperties.SKIP_TENDENCIES_PROPERTY,
defaultValue = "" + CoreProperties.SKIP_TENDENCIES_DEFAULT_VALUE,
@@ -91,7 +93,8 @@ import java.util.List;
project = true,
module = false,
global = true,
category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS,
type = Property.Type.BOOLEAN),
@Property(
key = CoreProperties.CORE_SKIPPED_MODULES_PROPERTY,
name = "Exclude modules",
@@ -106,7 +109,8 @@ import java.util.List;
description = "Forcing user authentication stops un-logged users to access Sonar.",
project = false,
global = true,
category = CoreProperties.CATEGORY_SECURITY),
category = CoreProperties.CATEGORY_SECURITY,
type = Property.Type.BOOLEAN),
@Property(
key = CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_PROPERTY,
defaultValue = "" + CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_DEAULT_VALUE,
@@ -114,7 +118,8 @@ import java.util.List;
description = "Users can sign up online.",
project = false,
global = true,
category = CoreProperties.CATEGORY_SECURITY),
category = CoreProperties.CATEGORY_SECURITY,
type = Property.Type.BOOLEAN),
@Property(
key = CoreProperties.CORE_DEFAULT_GROUP,
defaultValue = CoreProperties.CORE_DEFAULT_GROUP_DEFAULT_VALUE,
@@ -199,22 +204,25 @@ import java.util.List;
description = "Downcase login during user authentication, typically for Active Directory",
project = false,
global = false,
defaultValue = "false"),
defaultValue = "false",
type = Property.Type.BOOLEAN),
@Property(
key = CoreProperties.CORE_AUTHENTICATOR_CREATE_USERS,
name = "Create user accounts",
description = "Create accounts when authenticating users via an external system",
project = false,
global = false,
defaultValue = "true"),
defaultValue = "true",
type = Property.Type.BOOLEAN),
@Property(
key = CoreProperties.CORE_AUTHENTICATOR_IGNORE_STARTUP_FAILURE,
name = "Ignore failures during authenticator startup",
defaultValue = "false",
project = false,
global = false)
global = false,
type = Property.Type.BOOLEAN)
})
public class CorePlugin extends SonarPlugin {
public final class CorePlugin extends SonarPlugin {

@SuppressWarnings({"rawtypes", "unchecked"})
public List getExtensions() {

+ 65
- 59
plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdPlugin.java Просмотреть файл

@@ -31,69 +31,75 @@ import java.util.Arrays;
import java.util.List;

@Properties({
@Property(
key = CoreProperties.CPD_ENGINE,
defaultValue = CoreProperties.CPD_ENGINE_DEFAULT_VALUE,
name = "Copy&Paste detection engine",
description = "Sonar embeds its own CPD engine since Sonar 2.11, but it's still possible to use the old PMD CPD engine (value 'pmd')." +
" Some Sonar users might want to keep on working with PMD CPD engine for instance to prevent any impact on measures during an upgrade of Sonar." +
" Moreover this Sonar CPD engine is not supported by all Sonar language plugins and when this support is not available," +
" the PMD CPD engine is automatically selected.",
project = true,
module = true,
global = true,
category = CoreProperties.CATEGORY_DUPLICATIONS),
@Property(
key = CoreProperties.CPD_CROSS_RPOJECT,
defaultValue = CoreProperties.CPD_CROSS_RPOJECT_DEFAULT_VALUE + "",
name = "Cross project duplicaton detection",
description = "Sonar supports the detection of cross project duplications." +
" Activating this property will slightly increase each Sonar analysis time." +
" This mode can't be used along with the PMD CPD engine.",
project = true,
module = true,
global = true,
category = CoreProperties.CATEGORY_DUPLICATIONS),
@Property(
key = CoreProperties.CPD_MINIMUM_TOKENS_PROPERTY,
defaultValue = CoreProperties.CPD_MINIMUM_TOKENS_DEFAULT_VALUE + "",
name = "Minimum tokens",
description = "Deprecated property used only by the PMD CPD engine." +
" The number of duplicate tokens above which a block is considered as a duplication.",
project = true,
module = true,
global = true,
category = CoreProperties.CATEGORY_DUPLICATIONS),
@Property(
key = CoreProperties.CPD_IGNORE_LITERALS_PROPERTY,
defaultValue = CoreProperties.CPD_IGNORE_LITERALS_DEFAULT_VALUE + "",
name = "Ignore literals",
description = "Deprecated property used only by the PMD CPD engine." +
" If true, PMD-CPD ignores literal value differences when evaluating a duplicate block." +
" This means that foo=\"first string\"; and foo=\"second string\"; will be seen as equivalent.",
project = true,
module = true,
global = true,
category = CoreProperties.CATEGORY_DUPLICATIONS),
@Property(
key = CoreProperties.CPD_IGNORE_IDENTIFIERS_PROPERTY,
defaultValue = CoreProperties.CPD_IGNORE_IDENTIFIERS_DEFAULT_VALUE + "",
name = "Ignore identifiers",
description = "Deprecated property used only by the PMD CPD engine." +
" Similar to 'Ignore literals' but for identifiers; i.e., variable names, methods names, and so forth.",
project = true,
module = true,
global = true,
category = CoreProperties.CATEGORY_DUPLICATIONS)
@Property(
key = CoreProperties.CPD_ENGINE,
defaultValue = CoreProperties.CPD_ENGINE_DEFAULT_VALUE,
name = "Copy&Paste detection engine",
description = "Sonar embeds its own CPD engine since Sonar 2.11, but it's still possible to use the old PMD CPD engine (value 'pmd')." +
" Some Sonar users might want to keep on working with PMD CPD engine for instance to prevent any impact on measures during an upgrade of Sonar." +
" Moreover this Sonar CPD engine is not supported by all Sonar language plugins and when this support is not available," +
" the PMD CPD engine is automatically selected.",
project = true,
module = true,
global = true,
category = CoreProperties.CATEGORY_DUPLICATIONS,
type = Property.Type.SINGLE_SELECT_LIST,
options = {"sonar", "pmd"}),
@Property(
key = CoreProperties.CPD_CROSS_RPOJECT,
defaultValue = CoreProperties.CPD_CROSS_RPOJECT_DEFAULT_VALUE + "",
name = "Cross project duplicaton detection",
description = "Sonar supports the detection of cross project duplications." +
" Activating this property will slightly increase each Sonar analysis time." +
" This mode can't be used along with the PMD CPD engine.",
project = true,
module = true,
global = true,
category = CoreProperties.CATEGORY_DUPLICATIONS,
type = Property.Type.BOOLEAN),
@Property(
key = CoreProperties.CPD_MINIMUM_TOKENS_PROPERTY,
defaultValue = CoreProperties.CPD_MINIMUM_TOKENS_DEFAULT_VALUE + "",
name = "Minimum tokens",
description = "Deprecated property used only by the PMD CPD engine." +
" The number of duplicate tokens above which a block is considered as a duplication.",
project = true,
module = true,
global = true,
category = CoreProperties.CATEGORY_DUPLICATIONS,
type = Property.Type.INTEGER),
@Property(
key = CoreProperties.CPD_IGNORE_LITERALS_PROPERTY,
defaultValue = CoreProperties.CPD_IGNORE_LITERALS_DEFAULT_VALUE + "",
name = "Ignore literals",
description = "Deprecated property used only by the PMD CPD engine." +
" If true, PMD-CPD ignores literal value differences when evaluating a duplicate block." +
" This means that foo=\"first string\"; and foo=\"second string\"; will be seen as equivalent.",
project = true,
module = true,
global = true,
category = CoreProperties.CATEGORY_DUPLICATIONS,
type = Property.Type.BOOLEAN),
@Property(
key = CoreProperties.CPD_IGNORE_IDENTIFIERS_PROPERTY,
defaultValue = CoreProperties.CPD_IGNORE_IDENTIFIERS_DEFAULT_VALUE + "",
name = "Ignore identifiers",
description = "Deprecated property used only by the PMD CPD engine." +
" Similar to 'Ignore literals' but for identifiers; i.e., variable names, methods names, and so forth.",
project = true,
module = true,
global = true,
category = CoreProperties.CATEGORY_DUPLICATIONS,
type = Property.Type.BOOLEAN)
})
public class CpdPlugin extends SonarPlugin {
public final class CpdPlugin extends SonarPlugin {

public List getExtensions() {
return Arrays.asList(CpdSensor.class, SumDuplicationsDecorator.class, DuplicationDensityDecorator.class,
IndexFactory.class,
SonarEngine.class,
PmdEngine.class,
SonarBridgeEngine.class);
IndexFactory.class,
SonarEngine.class,
PmdEngine.class,
SonarBridgeEngine.class);
}

}

+ 12
- 3
plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DbCleanerPlugin.java Просмотреть файл

@@ -32,14 +32,23 @@ import java.util.List;
@Property(key = DbCleanerConstants.WEEKS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_WEEK, defaultValue = "4",
name = "Number of weeks before starting to keep only one snapshot by week",
description = "After this number of weeks, if there are several snapshots during the same week, "
+ "the DbCleaner keeps the first one and fully delete the other ones.", global = true, project = true),
+ "the DbCleaner keeps the first one and fully delete the other ones.",
global = true,
project = true,
type = Property.Type.INTEGER),
@Property(key = DbCleanerConstants.WEEKS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_MONTH, defaultValue = "52",
name = "Number of weeks before starting to keep only one snapshot by month",
description = "After this number of weeks, if there are several snapshots during the same month, "
+ "the DbCleaner keeps the first one and fully delete the other ones.", global = true, project = true),
+ "the DbCleaner keeps the first one and fully delete the other ones.",
global = true,
project = true,
type = Property.Type.INTEGER),
@Property(key = DbCleanerConstants.WEEKS_BEFORE_DELETING_ALL_SNAPSHOTS, defaultValue = "260",
name = "Number of weeks before starting to delete all remaining snapshots",
description = "After this number of weeks, all snapshots are fully deleted.", global = true, project = true)
description = "After this number of weeks, all snapshots are fully deleted.",
global = true,
project = true,
type = Property.Type.INTEGER)
}
)
public final class DbCleanerPlugin extends SonarPlugin {

+ 5
- 1
plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DefaultPurgeTask.java Просмотреть файл

@@ -37,7 +37,11 @@ import org.sonar.plugins.dbcleaner.period.DefaultPeriodCleaner;
@Property(
key = DbCleanerConstants.PROPERTY_CLEAN_DIRECTORY,
defaultValue = "true",
name = "Clean history data of directories/packages")
name = "Clean history data of directories/packages",
global = true,
project = true,
module = false,
type = Property.Type.BOOLEAN)
})
public class DefaultPurgeTask implements PurgeTask {
private static final Logger LOG = LoggerFactory.getLogger(DefaultPurgeTask.class);

+ 24
- 19
plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsPlugin.java Просмотреть файл

@@ -25,25 +25,30 @@ import java.util.ArrayList;
import java.util.List;

@Properties({
@Property(
key = CoreProperties.FINDBUGS_EFFORT_PROPERTY,
defaultValue = CoreProperties.FINDBUGS_EFFORT_DEFAULT_VALUE,
name = "Effort",
description = "Effort of the bug finders. Valid values are Min, Default and Max. Setting 'Max' increases precision but also increases " +
"memory consumption.",
project = true, module = true, global = true),
@Property(
key = CoreProperties.FINDBUGS_TIMEOUT_PROPERTY,
defaultValue = CoreProperties.FINDBUGS_TIMEOUT_DEFAULT_VALUE + "",
name = "Timeout",
description = "Specifies the amount of time, in milliseconds, that FindBugs may run before it is assumed to be hung and is terminated. " +
"The default is 600,000 milliseconds, which is ten minutes.",
project = true, module = true, global = true),
@Property(
key = FindbugsConstants.EXCLUDES_FILTERS_PROPERTY,
name = "Excludes Filters",
description = "Paths to findbugs filter-files with exclusions (comma-separated).",
project = true, module = true, global = true) })
@Property(
key = CoreProperties.FINDBUGS_EFFORT_PROPERTY,
defaultValue = CoreProperties.FINDBUGS_EFFORT_DEFAULT_VALUE,
name = "Effort",
description = "Effort of the bug finders. Valid values are Min, Default and Max. Setting 'Max' increases precision but also increases " +
"memory consumption.",
project = true,
module = true,
global = true),
@Property(
key = CoreProperties.FINDBUGS_TIMEOUT_PROPERTY,
defaultValue = CoreProperties.FINDBUGS_TIMEOUT_DEFAULT_VALUE + "",
name = "Timeout",
description = "Specifies the amount of time, in milliseconds, that FindBugs may run before it is assumed to be hung and is terminated. " +
"The default is 600,000 milliseconds, which is ten minutes.",
project = true,
module = true,
global = true,
type = Property.Type.INTEGER),
@Property(
key = FindbugsConstants.EXCLUDES_FILTERS_PROPERTY,
name = "Excludes Filters",
description = "Paths to findbugs filter-files with exclusions (comma-separated).",
project = true, module = true, global = true)})
public class FindbugsPlugin extends SonarPlugin {

public List<Class<? extends Extension>> getExtensions() {

+ 3
- 1
plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties Просмотреть файл

@@ -50,6 +50,7 @@ display=Display
download_verb=Download
edit=Edit
events=Events
false=False
file=File
files=Files
filter_verb=Filter
@@ -119,6 +120,7 @@ template=Template
title=Title
to=To
treemap=Treemap
true=True
update_verb=Update
updated=Updated
unfollow=Unfollow
@@ -298,7 +300,6 @@ default_filters.page=Default Filters
dependencies.page=Dependencies
duplications.page=Duplications
email_configuration.page=Email Settings
encryption.page=Settings Encryption
event_categories.page=Event Categories
filters.page=Filters
global_roles.page=Global Roles
@@ -538,6 +539,7 @@ dashboard.error_unshare_default=This dashboard can't be unshared as long as it's
#------------------------------------------------------------------------------
settings.save_category=Save {0} Settings
property.category.email=Email
property.category.encryption=Encryption
property.category.general=General
property.category.security=Security
property.category.java=Java

+ 29
- 28
plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java Просмотреть файл

@@ -29,39 +29,40 @@ import java.util.Arrays;
import java.util.List;

@Properties({
@Property(key = SquidPluginProperties.SQUID_ANALYSE_ACCESSORS_PROPERTY,
defaultValue = SquidPluginProperties.SQUID_ANALYSE_ACCESSORS_DEFAULT_VALUE
+ "",
name = "Separate accessors",
description = "Flag whether Squid should separate accessors (getters/setters) from methods. " +
"In that case, accessors are not counted in metrics such as complexity or API documentation.",
project = true,
global = true,
category = CoreProperties.CATEGORY_JAVA),
@Property(key = SquidPluginProperties.FIELDS_TO_EXCLUDE_FROM_LCOM4_COMPUTATION,
defaultValue = SquidPluginProperties.FIELDS_TO_EXCLUDE_FROM_LCOM4_COMPUTATION_DEFAULT_VALUE,
name = "List of fields to exclude from LCOM4 computation",
description = "Some fields should not be taken into account when computing LCOM4 measure as they " +
"unexpectedly and artificially decrease the LCOM4 measure. "
+ "The best example is a logger used by all methods of a class. " +
"All field names to exclude from LCOM4 computation must be separated by a comma.",
project = true,
global = true,
category = CoreProperties.CATEGORY_JAVA),
@Property(
key = CoreProperties.DESIGN_SKIP_DESIGN_PROPERTY,
defaultValue = "" + CoreProperties.DESIGN_SKIP_DESIGN_DEFAULT_VALUE,
name = "Skip design analysis",
project = true,
global = true,
category = CoreProperties.CATEGORY_JAVA)
@Property(key = SquidPluginProperties.SQUID_ANALYSE_ACCESSORS_PROPERTY,
defaultValue = SquidPluginProperties.SQUID_ANALYSE_ACCESSORS_DEFAULT_VALUE + "",
name = "Separate accessors",
description = "Flag whether Squid should separate accessors (getters/setters) from methods. " +
"In that case, accessors are not counted in metrics such as complexity or API documentation.",
project = true,
global = true,
category = CoreProperties.CATEGORY_JAVA,
type = Property.Type.BOOLEAN),
@Property(key = SquidPluginProperties.FIELDS_TO_EXCLUDE_FROM_LCOM4_COMPUTATION,
defaultValue = SquidPluginProperties.FIELDS_TO_EXCLUDE_FROM_LCOM4_COMPUTATION_DEFAULT_VALUE,
name = "List of fields to exclude from LCOM4 computation",
description = "Some fields should not be taken into account when computing LCOM4 measure as they " +
"unexpectedly and artificially decrease the LCOM4 measure. "
+ "The best example is a logger used by all methods of a class. " +
"All field names to exclude from LCOM4 computation must be separated by a comma.",
project = true,
global = true,
category = CoreProperties.CATEGORY_JAVA),
@Property(
key = CoreProperties.DESIGN_SKIP_DESIGN_PROPERTY,
defaultValue = "" + CoreProperties.DESIGN_SKIP_DESIGN_DEFAULT_VALUE,
name = "Skip design analysis",
project = true,
global = true,
category = CoreProperties.CATEGORY_JAVA,
type = Property.Type.BOOLEAN)
})
public final class SquidPlugin extends SonarPlugin {

public List getExtensions() {
return Arrays.asList(SquidSensor.class, SquidRuleRepository.class, JavaSourceImporter.class,
ClassComplexityDistributionBuilder.class, FunctionComplexityDistributionBuilder.class, ClassesDecorator.class,
ChidamberKemererDistributionBuilder.class, FunctionsDecorator.class);
ClassComplexityDistributionBuilder.class, FunctionComplexityDistributionBuilder.class, ClassesDecorator.class,
ChidamberKemererDistributionBuilder.class, FunctionsDecorator.class);
}

}

+ 20
- 0
sonar-plugin-api/src/main/java/org/sonar/api/Property.java Просмотреть файл

@@ -45,6 +45,13 @@ import java.lang.annotation.Target;
@Target(ElementType.TYPE)
public @interface Property {

/**
* @since 2.15
*/
public static enum Type {
STRING, TEXT, PASSWORD, BOOLEAN, INTEGER, FLOAT, SINGLE_SELECT_LIST
}

/**
* Unique key within all plugins. It's recommended to prefix the key by 'sonar.' and the plugin name. Examples :
* 'sonar.cobertura.reportPath' and 'sonar.cpd.minimumTokens'.
@@ -76,4 +83,17 @@ public @interface Property {
* Is the property displayed in global settings page ?
*/
boolean global() default true;

/**
* @since 2.15
*/
Type type() default Type.STRING;

/**
* Options for *_LIST types
*
* @since 2.15
*/
String[] options() default {};

}

+ 15
- 14
sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java Просмотреть файл

@@ -42,20 +42,21 @@ import java.util.Date;
* @since 2.4
*/
@Properties({
@Property(
key = "sonar.updatecenter.activate",
defaultValue = "true",
name = "Enable Update Center",
project = false,
global = false, // hidden from UI
category = "Update Center"),
@Property(
key = UpdateCenterClient.URL_PROPERTY,
defaultValue = "http://update.sonarsource.org/update-center.properties",
name = "Update Center URL",
project = false,
global = false, // hidden from UI
category = "Update Center")
@Property(
key = "sonar.updatecenter.activate",
defaultValue = "true",
name = "Enable Update Center",
project = false,
global = false, // hidden from UI
category = "Update Center",
type = Property.Type.BOOLEAN),
@Property(
key = UpdateCenterClient.URL_PROPERTY,
defaultValue = "http://update.sonarsource.org/update-center.properties",
name = "Update Center URL",
project = false,
global = false, // hidden from UI
category = "Update Center")
})
public class UpdateCenterClient implements ServerComponent {


+ 0
- 1
sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb Просмотреть файл

@@ -141,7 +141,6 @@
<li class="<%= 'selected' if controller.controller_path=='updatecenter' -%>">
<a href="<%= ApplicationController.root_context -%>/updatecenter"><%= message('update_center.page') -%></a></li>
<% end %>
<li class="<%= 'selected' if request.request_uri.include?('/encryption') -%>"><a href="<%= ApplicationController.root_context -%>/encryption"><%= message('encryption.page') -%></a></li>
<% end %>

<% end %>

+ 1
- 1
sonar-server/src/main/webapp/WEB-INF/app/views/server_id_configuration/index.html.erb Просмотреть файл

@@ -36,7 +36,7 @@
<p class="marginbottom10"><%= message('server_id_configuration.organisation.desc') -%></p>

<p>
<input type="text" name="organisation" value="<%= @organisation -%>"/>
<input type="text" name="organisation" value="<%= @organisation -%>" size="50"/>
</p>
</td>
</tr>

+ 9
- 10
sonar-server/src/main/webapp/WEB-INF/app/views/settings/_plugins.html.erb Просмотреть файл

@@ -24,10 +24,11 @@
}
</style>
<script type="text/javascript">
function replaceTextField(span_id, key) {
var text_field_value = $F(key);
var text_area = '<textarea cols="100" id="' + key + '" name="' + key + '" rows="10">' + text_field_value + '</textarea>';
$(span_id).replace(text_area);
function enlargeTextInput(propertyKey) {
var eltId = 'input_' + propertyKey;
var textValue = $F(eltId);
var textArea = '<textarea class="width100" id="' + propertyKey + '" name="' + propertyKey + '" rows="10" id="input_' + propertyKey + '">' + textValue + '</textarea>';
$(eltId).parentNode.replace(textArea);
}
</script>
<div id="plugins">
@@ -85,6 +86,9 @@
if @properties_per_category[@category]
@properties_per_category[@category].each do |property|
value = Property.value(property.key(), (@project ? @project.id : nil), '')

# for backward-compatibility with properties that do not define the type TEXT
property_type = value.include?("\n") ? 'TEXT' : property.type
%>
<tr class="<%= cycle('even', 'odd', :name => 'properties') -%>">
<td style="padding: 10px">
@@ -97,13 +101,8 @@
if desc.present? %>
<p class="marginbottom10"><%= desc -%></p>
<% end %>
<div><%= render :partial => "settings/type_#{property_type}", :locals => {:property => property, :value => value} -%></div>
<p>
<% span_id = "text_" + property.key().gsub('.', '_') %>
<% textfield = text_field_tag property.key(), value, :size => '20' %>
<% textfield += link_to_function(image_tag("zoom.png"), "replaceTextField('#{span_id}', '#{property.key()}')", :id => "toggle_text", :class => 'nolink') %>
<% textarea = text_area_tag property.key(), value, :size => "100x10" %>
<span id="<%= span_id %>"><%= (value && value.length >= 50) ? textarea : textfield -%></span>

<%
default_prop_value = (@project ? Property.value(property.key(), nil, property.defaultValue()) : property.defaultValue())
unless default_prop_value.blank? %>

+ 5
- 0
sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_BOOLEAN.html.erb Просмотреть файл

@@ -0,0 +1,5 @@
<select name="<%= h property.key -%>" id="input_<%= h property.key-%>">
<option value="" <%= 'selected' if value.blank? -%>><%= message('default') -%></option>
<option value="true" <%= 'selected' if value=='true' -%>><%= message('true') -%></option>
<option value="false" <%= 'selected' if value=='false' -%>><%= message('false') -%></option>
</select>

+ 1
- 0
sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_FLOAT.html.erb Просмотреть файл

@@ -0,0 +1 @@
<input type="text" name="<%= h property.key -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.key-%>"/>

+ 1
- 0
sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_INTEGER.html.erb Просмотреть файл

@@ -0,0 +1 @@
<input type="text" name="<%= h property.key -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.key-%>"/>

+ 1
- 0
sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PASSWORD.html.erb Просмотреть файл

@@ -0,0 +1 @@
<input type="password" name="<%= h property.key -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.key-%>"/>

+ 6
- 0
sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_SINGLE_SELECT_LIST.html.erb Просмотреть файл

@@ -0,0 +1,6 @@
<select name="<%= h property.key -%>" id="input_<%= h property.key-%>">
<option value=""><%= message('default') -%></option>
<% property.options.each do |option| %>
<option value="<%= h option -%>"><%= h option -%></option>
<% end %>
</select>

+ 1
- 0
sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_TEXT.html.erb Просмотреть файл

@@ -0,0 +1 @@
<textarea rows="5" cols="80" class="width100" name="<%= h property.key -%>" id="input_<%= h property.key-%>"><%= h value if value -%></textarea>

Загрузка…
Отмена
Сохранить