- Add i18n to all filters page - Modify the I18nManager to return the key if a translation has not been found (instead of throwing a SonarException)tags/2.10
String bundleBaseName = keys.get(key); | String bundleBaseName = keys.get(key); | ||||
if (bundleBaseName == null) { | if (bundleBaseName == null) { | ||||
if (result == null) { | if (result == null) { | ||||
throw new MissingResourceException("UNKNOWN KEY : Key '" + key + "' not found in any bundle.", bundleBaseName, key); | |||||
throw new MissingResourceException("UNKNOWN KEY : Key '" + key | |||||
+ "' not found in any bundle, and no default value provided. The key is returned.", bundleBaseName, key); | |||||
} | } | ||||
LOG.warn("UNKNOWN KEY : Key '{}' not found in any bundle. Default value '{}' is returned.", key, defaultText); | LOG.warn("UNKNOWN KEY : Key '{}' not found in any bundle. Default value '{}' is returned.", key, defaultText); | ||||
unknownKeys.put(key, defaultText); | unknownKeys.put(key, defaultText); | ||||
bundleBaseName, bundleClassLoader, defaultText }); | bundleBaseName, bundleClassLoader, defaultText }); | ||||
} | } | ||||
} | } | ||||
} catch (MissingResourceException e) { | |||||
LOG.warn(e.getMessage()); | |||||
if (result == null) { | |||||
// when no translation has been found, the key is returned | |||||
return key; | |||||
} | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
LOG.error("Exception when retrieving I18n string.", e); | |||||
LOG.error("Exception when retrieving I18n string: ", e); | |||||
if (result == null) { | if (result == null) { | ||||
throw new SonarException("Exception when retrieving I18n string.", e); | |||||
// when no translation has been found, the key is returned | |||||
return key; | |||||
} | } | ||||
} | } | ||||
view.size.accessors_suffix=\ accessors | view.size.accessors_suffix=\ accessors | ||||
view.size.paragraphs_suffix=\ paragraphs | view.size.paragraphs_suffix=\ paragraphs | ||||
general_columns.links=Links | |||||
general_columns.build_time=Build time | |||||
general_columns.language=Language | |||||
general_columns.version=Version | |||||
general_columns.date=Build date | |||||
general_columns.key=Key | |||||
general_columns.name=Name | |||||
#------------------------------------------------------------------------------ | #------------------------------------------------------------------------------ | ||||
# | # | ||||
# GENERIC WORDS | |||||
# GENERIC WORDS, sorted alphabetically | |||||
# | # | ||||
#------------------------------------------------------------------------------ | #------------------------------------------------------------------------------ | ||||
add_verb=Add | |||||
and=And | and=And | ||||
author=Author | |||||
ascending=Ascending | |||||
build_date=Build date | build_date=Build date | ||||
cancel=Cancel | cancel=Cancel | ||||
change_verb=Change | |||||
class=Class | |||||
classes=Classes | classes=Classes | ||||
color=Color | |||||
criteria=Criteria | criteria=Criteria | ||||
date=Date | |||||
days=Days | days=Days | ||||
delete=Delete | delete=Delete | ||||
descending=Descending | |||||
directory=Directory | |||||
directories=Directories | directories=Directories | ||||
display=Display | |||||
edit=Edit | |||||
file=File | |||||
files=Files | files=Files | ||||
key=Key | |||||
language=Language | language=Language | ||||
library=Library | |||||
links=Links | |||||
login=Login | login=Login | ||||
max=Max | |||||
min=Min | |||||
name=Name | name=Name | ||||
none=None | none=None | ||||
operations=Operations | |||||
order=Order | |||||
package=Package | |||||
packages=Packages | packages=Packages | ||||
password=Password | password=Password | ||||
path=Path | path=Path | ||||
project=Project | |||||
projects=Projects | projects=Projects | ||||
reset_verb=Reset | reset_verb=Reset | ||||
search_verb=Search | search_verb=Search | ||||
shared=Shared | shared=Shared | ||||
view=View | |||||
views=Views | views=Views | ||||
result=Result | |||||
select_verb=Select | |||||
size=Size | |||||
sub_project=Sub-project | |||||
sub_projects=Sub-projects | sub_projects=Sub-projects | ||||
sub_view=Sub-view | |||||
sub_views=Sub-views | sub_views=Sub-views | ||||
table=Table | |||||
treemap=Treemap | |||||
unfollow=Unfollow | |||||
unit_test=Unit test | |||||
unit_tests=Unit tests | unit_tests=Unit tests | ||||
value=Value | |||||
variarion=Variation | |||||
version=Version | |||||
#------------------------------------------------------------------------------ | #------------------------------------------------------------------------------ | ||||
# | # | ||||
# GENERIC EXPRESSIONS | |||||
# GENERIC EXPRESSIONS, sorted alphabetically | |||||
# | # | ||||
#------------------------------------------------------------------------------ | #------------------------------------------------------------------------------ | ||||
alerts_feed=Alerts feed | |||||
delta_since_previous_analysis=Δ since previous analysis | |||||
delta_over_x_days=Δ over {0} days | |||||
delta_since=Δ since {0} | |||||
delta_since_version=Δ since version {0} | |||||
equals=Equals | |||||
greater_or_equals=Greater or equals | |||||
greater_than=Greater than | |||||
less_or_equals=Less or equals | |||||
less_than=Less than | |||||
move_left=Move left | |||||
move_right=Move right | |||||
no_results=No results | |||||
page_size=Page size | |||||
remove_column=Remove this column | |||||
results_not_display_due_to_security=Due to security settings, some results are not being displayed. | |||||
save_and_close=Save & Close | save_and_close=Save & Close | ||||
save_and_preview=Save & Preview | save_and_preview=Save & Preview | ||||
select_a_metric=Select a metric | |||||
time_changes=Time changes | |||||
#------------------------------------------------------------------------------ | #------------------------------------------------------------------------------ | ||||
# | # | ||||
#------------------------------------------------------------------------------ | #------------------------------------------------------------------------------ | ||||
filters.add_filter=Add filter | |||||
filters.edit_filter=Edit filter | |||||
filters.manage_filters=Manage filters | |||||
filters.search_for=Search for | filters.search_for=Search for | ||||
filters.advanced_search=Advanced search | filters.advanced_search=Advanced search | ||||
filters.default_period=Default period | filters.default_period=Default period | ||||
filters.do_you_want_to_delete=Do you want to delete this filter ? | filters.do_you_want_to_delete=Do you want to delete this filter ? | ||||
filters.during_last=During last | filters.during_last=During last | ||||
filters.prior_to_last=Prior to last | filters.prior_to_last=Prior to last | ||||
filters.search_by_name=Search by name | |||||
filters.display_as=Display as | |||||
filters.add_column=Add column | |||||
filters.default_sorted_column=Default sorted column | |||||
filters.treemap_not_supported_for_period_selection=Treemap does not support yet the selection of a period. | |||||
filters.my_filters=My filters | |||||
filters.no_filters=No filters | |||||
filters.do_you_want_to_stop_following=Do you want to stop following this filter ? | |||||
filters.shared_filters=Shared filters | |||||
filters.shared_filters_description=These filters are shared by administrators and can be followed without copying them. | |||||
#------------------------------------------------------------------------------ | #------------------------------------------------------------------------------ |
*/ | */ | ||||
package org.sonar.plugins.core.i18n; | package org.sonar.plugins.core.i18n; | ||||
import com.google.common.collect.Lists; | |||||
import org.junit.Assert; | |||||
import org.junit.Before; | |||||
import org.junit.Test; | |||||
import org.sonar.api.i18n.LanguagePack; | |||||
import org.sonar.api.platform.PluginRepository; | |||||
import static org.junit.Assert.assertEquals; | |||||
import static org.mockito.Mockito.mock; | |||||
import java.net.URL; | import java.net.URL; | ||||
import java.net.URLClassLoader; | import java.net.URLClassLoader; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Locale; | import java.util.Locale; | ||||
import static org.junit.Assert.assertEquals; | |||||
import static org.mockito.Mockito.mock; | |||||
import org.junit.Assert; | |||||
import org.junit.Before; | |||||
import org.junit.Test; | |||||
import org.sonar.api.i18n.LanguagePack; | |||||
import org.sonar.api.platform.PluginRepository; | |||||
import com.google.common.collect.Lists; | |||||
public class I18nManagerTest { | public class I18nManagerTest { | ||||
@Before | @Before | ||||
public void createManager() throws Exception { | public void createManager() throws Exception { | ||||
List<InstalledPlugin> plugins = Lists.newArrayList( | |||||
new InstalledPlugin("test", new TestClassLoader(getClass().getClassLoader().getResource("StandardPlugin.jar"))), | |||||
new InstalledPlugin("fake1", getClass().getClassLoader()), | |||||
new InstalledPlugin("fake2", getClass().getClassLoader()) | |||||
); | |||||
List<InstalledPlugin> plugins = Lists.newArrayList(new InstalledPlugin("test", new TestClassLoader(getClass().getClassLoader() | |||||
.getResource("StandardPlugin.jar"))), new InstalledPlugin("fake1", getClass().getClassLoader()), new InstalledPlugin("fake2", | |||||
getClass().getClassLoader())); | |||||
TestClassLoader frenchPackClassLoader = new TestClassLoader(getClass().getClassLoader().getResource("FrenchPlugin.jar")); | TestClassLoader frenchPackClassLoader = new TestClassLoader(getClass().getClassLoader().getResource("FrenchPlugin.jar")); | ||||
LanguagePack frenchPack = (LanguagePack) frenchPackClassLoader.loadClass(FRENCH_PACK_CLASS_NAME).newInstance(); | LanguagePack frenchPack = (LanguagePack) frenchPackClassLoader.loadClass(FRENCH_PACK_CLASS_NAME).newInstance(); | ||||
TestClassLoader quebecPackClassLoader = new TestClassLoader(getClass().getClassLoader().getResource("QuebecPlugin.jar")); | TestClassLoader quebecPackClassLoader = new TestClassLoader(getClass().getClassLoader().getResource("QuebecPlugin.jar")); | ||||
LanguagePack quebecPack = (LanguagePack) quebecPackClassLoader.loadClass(QUEBEC_PACK_CLASS_NAME).newInstance(); | LanguagePack quebecPack = (LanguagePack) quebecPackClassLoader.loadClass(QUEBEC_PACK_CLASS_NAME).newInstance(); | ||||
manager = new I18nManager(mock(PluginRepository.class), new LanguagePack[]{frenchPack, quebecPack}); | |||||
manager = new I18nManager(mock(PluginRepository.class), new LanguagePack[] { frenchPack, quebecPack }); | |||||
manager.doStart(plugins); | manager.doStart(plugins); | ||||
} | } | ||||
Assert.assertEquals("Default value for Unknown", manager.getUnknownKeys().getProperty("unknown")); | Assert.assertEquals("Default value for Unknown", manager.getUnknownKeys().getProperty("unknown")); | ||||
} | } | ||||
@Test | |||||
public void shouldReturnKeyIfTranslationMissingAndNotDefaultProvided() throws Exception { | |||||
String result = manager.message(Locale.ENGLISH, "unknown.key", null); | |||||
assertEquals("unknown.key", result); | |||||
Assert.assertEquals(0, manager.getUnknownKeys().size()); | |||||
} | |||||
public static class TestClassLoader extends URLClassLoader { | public static class TestClassLoader extends URLClassLoader { | ||||
public TestClassLoader(URL url) { | public TestClassLoader(URL url) { | ||||
super(new URL[]{url, classSource}, Thread.currentThread().getContextClassLoader()); | |||||
super(new URL[] { url, classSource }, Thread.currentThread().getContextClassLoader()); | |||||
} | } | ||||
protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { | protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { |
def qualifier_icon(object) | def qualifier_icon(object) | ||||
qualifier=(object.respond_to?('qualifier') ? object.qualifier : object.to_s) | qualifier=(object.respond_to?('qualifier') ? object.qualifier : object.to_s) | ||||
if qualifier | if qualifier | ||||
image_tag("q/#{qualifier}.png", :alt => Resourceable.qualifier_name(qualifier)) | |||||
image_tag("q/#{qualifier}.png", :alt => message(Resourceable.qualifier_name(qualifier))) | |||||
else | else | ||||
image_tag('e16.gif') | image_tag('e16.gif') | ||||
end | end |
def period_name(property) | def period_name(property) | ||||
if property=='previous_analysis' | if property=='previous_analysis' | ||||
"Δ since previous analysis" | |||||
message('delta_since_previous_analysis') | |||||
elsif property =~ /^[\d]+(\.[\d]+){0,1}$/ | elsif property =~ /^[\d]+(\.[\d]+){0,1}$/ | ||||
# is integer | # is integer | ||||
"Δ over #{property} days" | |||||
message('delta_over_x_days', :params => property) | |||||
elsif property =~ /\d{4}-\d{2}-\d{2}/ | elsif property =~ /\d{4}-\d{2}-\d{2}/ | ||||
"Δ since #{property}" | |||||
message('delta_since', :params => property) | |||||
elsif !property.blank? | elsif !property.blank? | ||||
"Δ since version #{property}" | |||||
message('delta_since_version', :params => property) | |||||
else | else | ||||
nil | nil | ||||
end | end |
belongs_to :filter | belongs_to :filter | ||||
validates_inclusion_of :sort_direction, :in => %w( ASC DESC ), :allow_nil => true | validates_inclusion_of :sort_direction, :in => %w( ASC DESC ), :allow_nil => true | ||||
def self.create_from_string(string) | def self.create_from_string(string) | ||||
if FAMILIES.include?(string) | if FAMILIES.include?(string) | ||||
FilterColumn.new(:family => string) | FilterColumn.new(:family => string) | ||||
def name | def name | ||||
if on_metric? | if on_metric? | ||||
metric ? metric.short_name : kee | |||||
Java::OrgSonarServerUi::JRubyFacade.getInstance().getI18nMessage(I18n.locale, "metric." + kee + ".name", nil, [].to_java) | |||||
else | else | ||||
case family | |||||
when 'date' | |||||
'Build date' | |||||
when 'language' | |||||
'Language' | |||||
when 'name' | |||||
'Name' | |||||
when 'links' | |||||
'Links' | |||||
when 'version' | |||||
'Version' | |||||
when 'key' | |||||
'Key' | |||||
else | |||||
kee | |||||
end | |||||
Java::OrgSonarServerUi::JRubyFacade.getInstance().getI18nMessage(I18n.locale, family, kee, [].to_java) | |||||
end | end | ||||
end | end | ||||
def display_name | def display_name | ||||
if on_metric? | |||||
metric ? metric.short_name : kee | |||||
else | |||||
case family | |||||
when 'date' | |||||
'Build date' | |||||
when 'language' | |||||
'Language' | |||||
when 'name' | |||||
'Name' | |||||
when 'links' | |||||
'Links' | |||||
when 'version' | |||||
'Version' | |||||
when 'key' | |||||
'Key' | |||||
else | |||||
kee | |||||
end | |||||
end | |||||
name | |||||
end | end | ||||
def metric | def metric |
} | } | ||||
</script> | </script> | ||||
<select name="criteria[<%= id -%>][metric_id]" id="metric-<%= id -%>"> | <select name="criteria[<%= id -%>][metric_id]" id="metric-<%= id -%>"> | ||||
<option value="">Select a metric</option> | |||||
<option value=""><%= message('select_a_metric') -%></option> | |||||
<% Metric.domains.each do |domain| %> | <% Metric.domains.each do |domain| %> | ||||
<optgroup label="<%= h domain -%>"> | <optgroup label="<%= h domain -%>"> | ||||
<% Metric.by_domain(domain).select{|m| !m.data? && !m.hidden?}.each do |metric| %> | <% Metric.by_domain(domain).select{|m| !m.data? && !m.hidden?}.each do |metric| %> | ||||
<% end %> | <% end %> | ||||
</select> | </select> | ||||
<select name="criteria[<%= id -%>][type]" id="type-<%= id -%>"> | <select name="criteria[<%= id -%>][type]" id="type-<%= id -%>"> | ||||
<option value="value" <%= 'selected' unless (criterion && criterion.variation) -%>>Value</option> | |||||
<option value="variation" <%= 'selected' if criterion && criterion.variation -%>>Variation</option> | |||||
<option value="value" <%= 'selected' unless (criterion && criterion.variation) -%>><%= message('value') -%></option> | |||||
<option value="variation" <%= 'selected' if criterion && criterion.variation -%>><%= message('variation') -%></option> | |||||
</select> | </select> | ||||
<select name="criteria[<%= id -%>][operator]" id="op-<%= id -%>"> | <select name="criteria[<%= id -%>][operator]" id="op-<%= id -%>"> | ||||
<option value=""></option> | <option value=""></option> | ||||
<option value="<" <%= 'selected' if (criterion && criterion.operator=='<') -%>>Less than</option> | |||||
<option value="<=" <%= 'selected' if (criterion && criterion.operator=='<=') -%>>Less or equals</option> | |||||
<option value="=" <%= 'selected' if (criterion && criterion.operator=='=') -%>>Equals</option> | |||||
<option value=">" <%= 'selected' if (criterion && criterion.operator=='>') -%>>Greater than</option> | |||||
<option value=">=" <%= 'selected' if (criterion && criterion.operator=='>=') -%>>Greater or equals</option> | |||||
<option value="<" <%= 'selected' if (criterion && criterion.operator=='<') -%>><%= message('less_than') -%></option> | |||||
<option value="<=" <%= 'selected' if (criterion && criterion.operator=='<=') -%>><%= message('less_or_equals') -%></option> | |||||
<option value="=" <%= 'selected' if (criterion && criterion.operator=='=') -%>><%= message('equals') -%></option> | |||||
<option value=">" <%= 'selected' if (criterion && criterion.operator=='>') -%>><%= message('greater_than') -%></option> | |||||
<option value=">=" <%= 'selected' if (criterion && criterion.operator=='>=') -%>><%= message('greater_or_equals') -%></option> | |||||
</select> | </select> | ||||
<input type="text" name="criteria[<%= id -%>][value]" size="5" value="<%= criterion.value if criterion -%>" id="val-<%= id -%>"></input> | <input type="text" name="criteria[<%= id -%>][value]" size="5" value="<%= criterion.value if criterion -%>" id="val-<%= id -%>"></input> | ||||
<a href="#" onClick="reset_criterion(<%= id -%>);return false;">Reset</a> | |||||
<a href="#" onClick="reset_criterion(<%= id -%>);return false;"><%= message('reset_verb') -%></a> |
<tr> | <tr> | ||||
<td class="first"> | <td class="first"> | ||||
Add column: | |||||
<%= message('filters.add_column') -%>: | |||||
</td> | </td> | ||||
<td> | <td> | ||||
<form id="add_column_form" action="<%= url_for :action => 'add_column', :id => @filter.id -%>" method="post"> | <form id="add_column_form" action="<%= url_for :action => 'add_column', :id => @filter.id -%>" method="post"> | ||||
<select name="column_type" id="select_column_type"> | <select name="column_type" id="select_column_type"> | ||||
<option value="value" selected>Value</option> | |||||
<option value="variation">Variation</option> | |||||
<option value="value" selected><%= message('value') -%></option> | |||||
<option value="variation"><%= message('variation') -%></option> | |||||
</select> | </select> | ||||
<select name="column" id="select_column"> | <select name="column" id="select_column"> | ||||
<% if metric.display? %><option value="metric,<%= metric.id -%>"><%= metric.short_name -%></option><% end %> | <% if metric.display? %><option value="metric,<%= metric.id -%>"><%= metric.short_name -%></option><% end %> | ||||
<% end %> | <% end %> | ||||
<% if domain=='General' %> | <% if domain=='General' %> | ||||
<% unless @filter.column('date') %><option value="date">Build date</option><% end %> | |||||
<% unless @filter.column('key') %><option value="key">Key</option><% end %> | |||||
<% unless @filter.column('language') %><option value="language">Language</option><% end %> | |||||
<% unless @filter.column('links') %><option value="links">Links</option><% end %> | |||||
<% unless @filter.column('name') %><option value="name">Name</option><% end %> | |||||
<% unless @filter.column('version') %><option value="version">Version</option><% end %> | |||||
<% unless @filter.column('date') %><option value="date"><%= message('build_date') -%></option><% end %> | |||||
<% unless @filter.column('key') %><option value="key"><%= message('key') -%></option><% end %> | |||||
<% unless @filter.column('language') %><option value="language"><%= message('language') -%></option><% end %> | |||||
<% unless @filter.column('links') %><option value="links"><%= message('links') -%></option><% end %> | |||||
<% unless @filter.column('name') %><option value="name"><%= message('name') -%></option><% end %> | |||||
<% unless @filter.column('version') %><option value="version"><%= message('version') -%></option><% end %> | |||||
<% end %> | <% end %> | ||||
</optgroup> | </optgroup> | ||||
<% end %> | <% end %> | ||||
</select> | </select> | ||||
<input type="submit" id="add_column_button" value="Add"></input> | |||||
<input type="submit" id="add_column_button" value="<%= message('add_verb') -%>"></input> | |||||
</form> | </form> | ||||
</td> | </td> | ||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td class="first">Default sorted column:</td> | |||||
<td class="first"><%= message('filters.default_sorted_column') -%>:</td> | |||||
<td> | <td> | ||||
<form id="sorted_column_form" action="<%= url_for :action => 'set_sorted_column' -%>" method="post"> | <form id="sorted_column_form" action="<%= url_for :action => 'set_sorted_column' -%>" method="post"> | ||||
<select name="id"> | <select name="id"> | ||||
<% end %> | <% end %> | ||||
</select> | </select> | ||||
<select name="sort"> | <select name="sort"> | ||||
<option value="ASC" <%= 'selected' if default_sorted_column && default_sorted_column.ascending? -%>>Ascending</option> | |||||
<option value="DESC" <%= 'selected' if default_sorted_column && default_sorted_column.descending? -%>>Descending</option> | |||||
<option value="ASC" <%= 'selected' if default_sorted_column && default_sorted_column.ascending? -%>><%= message('ascending') -%></option> | |||||
<option value="DESC" <%= 'selected' if default_sorted_column && default_sorted_column.descending? -%>><%= message('descending') -%></option> | |||||
</select> | </select> | ||||
<input type="submit" id="add_column_submit" value="Change" /> | |||||
<input type="submit" id="add_column_submit" value="<%= message('change_verb') -%>" /> | |||||
</form> | </form> | ||||
</td> | </td> | ||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td class="first">Page size:</td> | |||||
<td class="first"><%= message('page_size') -%>:</td> | |||||
<td> | <td> | ||||
<form id="page_size_form" action="<%= url_for :action => 'set_page_size' -%>" method="post"> | <form id="page_size_form" action="<%= url_for :action => 'set_page_size' -%>" method="post"> | ||||
<input type="hidden" name="id" value="<%= @filter.id -%>"></input> | <input type="hidden" name="id" value="<%= @filter.id -%>"></input> | ||||
<input type="text" name="size" value="<%= @filter.page_size -%>" maxsize="3" size="3"></input> | <input type="text" name="size" value="<%= @filter.page_size -%>" maxsize="3" size="3"></input> | ||||
<input type="submit" id="set_page_size_submit" value="Change"/> | |||||
<span class="comments">Min <%= ::Filter::MIN_PAGE_SIZE -%>, max <%= ::Filter::MAX_PAGE_SIZE -%></span> | |||||
<input type="submit" id="set_page_size_submit" value="<%= message('change_verb') -%>"/> | |||||
<span class="comments"><%= message('min') -%> <%= ::Filter::MIN_PAGE_SIZE -%>, <%= message('max').downcase -%> <%= ::Filter::MAX_PAGE_SIZE -%></span> | |||||
</td> | </td> | ||||
</tr> | </tr> |
%> | %> | ||||
<form class="admin" action="<%= url_for :action => 'set_columns', :id => @filter.id -%>" method="POST"> | <form class="admin" action="<%= url_for :action => 'set_columns', :id => @filter.id -%>" method="POST"> | ||||
<tr> | <tr> | ||||
<td class="first">Size:</td> | |||||
<td class="first"><%= message('size') -%>:</td> | |||||
<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({:exclude_user_managed => true}), size_metric.key), | ||||
:id => 'size_metric' %> | :id => 'size_metric' %> | ||||
</td> | </td> | ||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td class="first">Color:</td> | |||||
<td class="first"><%= message('color') -%>:</td> | |||||
<td> | <td> | ||||
<%= select_tag 'columns[]', options_grouped_by_domain(Sonar::TreemapBuilder.color_metrics, color_metric.key), | <%= select_tag 'columns[]', options_grouped_by_domain(Sonar::TreemapBuilder.color_metrics, color_metric.key), | ||||
:id => 'color_metric' %> | :id => 'color_metric' %> | ||||
<tr> | <tr> | ||||
<td class="first"> </td> | <td class="first"> </td> | ||||
<td> | <td> | ||||
<input type="submit" value="Change"> | |||||
<input type="submit" value="<%= message('change_verb') -%>"> | |||||
</td> | </td> | ||||
</tr> | </tr> | ||||
</form> | </form> |
<div class="operations"> | <div class="operations"> | ||||
<form action="<%= url_for :overwrite_params => {:period => nil} -%>" style="display: inline" method="get"> | <form action="<%= url_for :overwrite_params => {:period => nil} -%>" style="display: inline" method="get"> | ||||
<select name="period" onchange="submit()" class="small"> | <select name="period" onchange="submit()" class="small"> | ||||
<option value="">Time changes...</option> | |||||
<option value=""><%= message('time_changes') -%>...</option> | |||||
<% period_names.each_with_index do |name, index| %> | <% period_names.each_with_index do |name, index| %> | ||||
<option value="<%= index+1 -%>" <%= 'selected' if @filter_context.period_index==index+1 -%>><%= name -%></value> | <option value="<%= index+1 -%>" <%= 'selected' if @filter_context.period_index==index+1 -%>><%= name -%></value> | ||||
<% end %> | <% end %> | ||||
<tr class="admin"><th></th> | <tr class="admin"><th></th> | ||||
<% filter.columns.each do |column| %> | <% filter.columns.each do |column| %> | ||||
<th nowrap class="<%= column_align(column) -%>"> | <th nowrap class="<%= column_align(column) -%>"> | ||||
<%= link_to image_tag("controls/resultset_previous.png"), {:action => 'left_column', :id => column.id}, :title => 'Move left', :method => :post if filter.first_column!=column %> | |||||
<%= link_to image_tag("bin_closed.png"), {:action => 'delete_column', :id => column.id}, :title => 'Remove this column', :method => :post if column.deletable? %> | |||||
<%= link_to image_tag("controls/resultset_next.png"), {:action => 'right_column', :id => column.id}, :title => 'Move right', :method => :post if filter.last_column!=column %> | |||||
<%= link_to image_tag("controls/resultset_previous.png"), {:action => 'left_column', :id => column.id}, :title => message('move_left'), :method => :post if filter.first_column!=column %> | |||||
<%= link_to image_tag("bin_closed.png"), {:action => 'delete_column', :id => column.id}, :title => message('remove_column'), :method => :post if column.deletable? %> | |||||
<%= link_to image_tag("controls/resultset_next.png"), {:action => 'right_column', :id => column.id}, :title => message('move_right'), :method => :post if filter.last_column!=column %> | |||||
</th> | </th> | ||||
<% end %> | <% end %> | ||||
</tr> | </tr> | ||||
<tfoot> | <tfoot> | ||||
<tr> | <tr> | ||||
<td colspan="<%= filter.columns.size + 1 -%>"> | <td colspan="<%= filter.columns.size + 1 -%>"> | ||||
<span id="results_count"><%= pluralize(@filter_context.size, 'result') %></span> | |||||
<span id="results_count"><%= pluralize(@filter_context.size, message('result').downcase) %></span> | |||||
<% if @filter_context.page_count>1 %> | <% if @filter_context.page_count>1 %> | ||||
| | | | ||||
<% if @filter.projects_homepage? %> | <% if @filter.projects_homepage? %> | ||||
<a href="<%= url_for :controller => :feeds, :action => 'projects', :id => EventCategory::KEY_ALERT -%>" class="nolink"><%= image_tag 'rss-12x12.png' %></a> | <a href="<%= url_for :controller => :feeds, :action => 'projects', :id => EventCategory::KEY_ALERT -%>" class="nolink"><%= image_tag 'rss-12x12.png' %></a> | ||||
<a href="<%= url_for :controller => :feeds, :action => 'projects', :id => EventCategory::KEY_ALERT -%>" class="action">Alerts feed</a> | |||||
<a href="<%= url_for :controller => :feeds, :action => 'projects', :id => EventCategory::KEY_ALERT -%>" class="action"><%= message('alerts_feed') -%></a> | |||||
<% end %> | <% end %> | ||||
</td> | </td> | ||||
</tr> | </tr> | ||||
</table> | </table> | ||||
<br/> | <br/> | ||||
<% if @filter_context.security_exclusions? %> | <% if @filter_context.security_exclusions? %> | ||||
<p class="notes">Due to security settings, some results are not being displayed.</p> | |||||
<p class="notes"><%= message('results_not_display_due_to_security') -%></p> | |||||
<% end %> | <% end %> | ||||
</div> | </div> |
<% if logged_in? %> | <% if logged_in? %> | ||||
<div id="page-operations"> | <div id="page-operations"> | ||||
<ul class="operations"> | <ul class="operations"> | ||||
<li><a href="<%= url_for :action => 'new' -%>" >Add filter</a></li> | |||||
<li><a href="<%= url_for :action => 'new' -%>" ><%= message('filters.add_filter') -%></a></li> | |||||
<% if @filter && @filter.id && editable_filter?(@filter) %> | <% if @filter && @filter.id && editable_filter?(@filter) %> | ||||
<li><a href="<%= url_for :action => 'edit', :id => @filter.id -%>">Edit filter</a></li> | |||||
<li><a href="<%= url_for :action => 'edit', :id => @filter.id -%>"><%= message('filters.edit_filter') -%></a></li> | |||||
<% end %> | <% end %> | ||||
<li class="last"><%= link_to 'Manage filters', {:action => 'manage'} -%></li> | |||||
<li class="last"><%= link_to message('filters.manage_filters'), {:action => 'manage'} -%></li> | |||||
</ul> | </ul> | ||||
</div> | </div> | ||||
<% end %> | <% end %> |
<% if @filter.period? %> | <% if @filter.period? %> | ||||
Treemap does not support yet the selection of a period. | |||||
<%= message('filters.treemap_not_supported_for_period_selection') -%> | |||||
<% else %> | <% else %> | ||||
<% | <% |
<%= render :partial => 'filters/tabs', :locals => {:selected_tab => nil} %> | <%= render :partial => 'filters/tabs', :locals => {:selected_tab => nil} %> | ||||
<h1>My filters</h1> | |||||
<h1><%= message('filters.my_filters') -%></h1> | |||||
<br/> | <br/> | ||||
<table class="data" id="actives"> | <table class="data" id="actives"> | ||||
<thead> | <thead> | ||||
<tr> | <tr> | ||||
<th>Name</th> | |||||
<th>Author</th> | |||||
<th>Shared</th> | |||||
<th>Order</th> | |||||
<th>Operations</th> | |||||
<th><%= message('name') -%></th> | |||||
<th><%= message('author') -%></th> | |||||
<th><%= message('shared') -%></th> | |||||
<th><%= message('order') -%></th> | |||||
<th><%= message('operations') -%></th> | |||||
</tr> | </tr> | ||||
</thead> | </thead> | ||||
<tbody> | <tbody> | ||||
<% if @actives.nil? || @actives.empty? %> | <% if @actives.nil? || @actives.empty? %> | ||||
<tr class="even"><td colspan="5">No filters</td></tr> | |||||
<tr class="even"><td colspan="5"><%= message('filters.no_filters') -%></td></tr> | |||||
<% | <% | ||||
else | else | ||||
</td> | </td> | ||||
<td> | <td> | ||||
<% if editable_filter?(active.filter) %> | <% if editable_filter?(active.filter) %> | ||||
<%= link_to 'Edit', {:action => 'edit', :id => active.filter_id}, :id => "edit-#{u active.name}" %> | | |||||
<%= link_to 'Delete', {:action => 'deactivate', :id => active.filter_id}, :method => :post, :confirm => 'Do you want to delete this filter ?', :id => "delete-#{u active.name}" %> | |||||
<%= link_to message('edit'), {:action => 'edit', :id => active.filter_id}, :id => "edit-#{u active.name}" %> | | |||||
<%= link_to message('delete'), {:action => 'deactivate', :id => active.filter_id}, :method => :post, :confirm => message('filters.do_you_want_to_delete'), :id => "delete-#{u active.name}" %> | |||||
<% else %> | <% else %> | ||||
<%= link_to 'Unfollow', {:action => 'deactivate', :id => active.filter_id}, :method => :post, :confirm => 'Do you want to stop following this filter ?', :id => "unfollow-#{u active.name}" %> | |||||
<%= link_to message('unfollow'), {:action => 'deactivate', :id => active.filter_id}, :method => :post, :confirm => message('filters.do_you_want_to_stop_following'), :id => "unfollow-#{u active.name}" %> | |||||
<% end %> | <% end %> | ||||
</td> | </td> | ||||
</tr> | </tr> | ||||
</table> | </table> | ||||
<br/><br/><br/> | <br/><br/><br/> | ||||
<h1>Shared filters</h1> | |||||
<p>These filters are shared by administrators and can be followed without copying them.</p> | |||||
<h1><%= message('filters.shared_filters') -%></h1> | |||||
<p><%= message('filters.shared_filters_description') -%></p> | |||||
<br/> | <br/> | ||||
<table class="data" id="shared"> | <table class="data" id="shared"> | ||||
<thead> | <thead> | ||||
<tr> | <tr> | ||||
<th>Name</th> | |||||
<th>Author</th> | |||||
<th>Operations</th> | |||||
<th><%= message('name') -%></th> | |||||
<th><%= message('author') -%></th> | |||||
<th><%= message('operations') -%></th> | |||||
</tr> | </tr> | ||||
</thead> | </thead> | ||||
<tbody> | <tbody> | ||||
<% if @shared_filters.nil? || @shared_filters.empty? %> | <% if @shared_filters.nil? || @shared_filters.empty? %> | ||||
<tr class="even"><td colspan="3">No results.</td></tr> | |||||
<tr class="even"><td colspan="3"><%= message('no_results') -%>.</td></tr> | |||||
<% else %> | <% else %> | ||||
<% @shared_filters.each do |filter| %> | <% @shared_filters.each do |filter| %> | ||||
<tr class="<%= cycle('even', 'odd') -%>"> | <tr class="<%= cycle('even', 'odd') -%>"> |
<br/> | <br/> | ||||
<% if @filter_context %> | <% if @filter_context %> | ||||
<h1>Display</h1> | |||||
<h1><%= message('display') -%></h1> | |||||
<div class="admin"> | <div class="admin"> | ||||
<table class="form" id="view-form"> | <table class="form" id="view-form"> | ||||
<tr> | <tr> | ||||
<td class="first">Display as:</td> | |||||
<td class="first"><%= message('filters.display_as') -%>:</td> | |||||
<td> | <td> | ||||
<form action="<%= url_for :action => :set_view, :id => @filter.id -%>" method="POST"> | <form action="<%= url_for :action => :set_view, :id => @filter.id -%>" method="POST"> | ||||
<input type="radio" name="view" value="list" <%= 'checked' if @filter.default_view==::Filter::VIEW_LIST -%> id="view-list" onClick="$('view-loading').show();submit();"></input> <label for="view-list">Table</label> | |||||
<input type="radio" name="view" value="list" <%= 'checked' if @filter.default_view==::Filter::VIEW_LIST -%> id="view-list" onClick="$('view-loading').show();submit();"></input> <label for="view-list"><%= message('table') -%></label> | |||||
<span class="spacer"> </span> | <span class="spacer"> </span> | ||||
<input type="radio" name="view" value="treemap" <%= 'checked' if @filter.default_view==::Filter::VIEW_TREEMAP -%> id="view-treemap" onClick="$('view-loading').show();submit();"></input> <label for="view-treemap">Treemap</label> | |||||
<input type="radio" name="view" value="treemap" <%= 'checked' if @filter.default_view==::Filter::VIEW_TREEMAP -%> id="view-treemap" onClick="$('view-loading').show();submit();"></input> <label for="view-treemap"><%= message('treemap') -%></label> | |||||
<span class="spacer"> </span> | <span class="spacer"> </span> | ||||
<%= image_tag 'loading.gif', :id => 'view-loading', :style=>'display: none' %> | <%= image_tag 'loading.gif', :id => 'view-loading', :style=>'display: none' %> | ||||
</form> | </form> |
<h1>Search</h1> | |||||
<h1><%= message('search_verb') -%></h1> | |||||
<br/> | <br/> | ||||
<form action="<%= url_for :action => :search_path -%>" method="post" id="search_form"> | <form action="<%= url_for :action => :search_path -%>" method="post" id="search_form"> | ||||
<input type="text" name="search" id="search" value="<%= params[:search] -%>"></input> | <input type="text" name="search" id="search" value="<%= params[:search] -%>"></input> | ||||
<input type="submit" value="Search" id="search_submit" /><br/> | |||||
<p class="note">Search by name</p> | |||||
<input type="submit" value="<%= message('search_verb') -%>" id="search_submit" /><br/> | |||||
<p class="note"><%= message('filters.search_by_name') -%></p> | |||||
</form> | </form> | ||||
<br/> | <br/> | ||||
</thead> | </thead> | ||||
<tbody> | <tbody> | ||||
<% if @snapshots.empty? %> | <% if @snapshots.empty? %> | ||||
<tr class="even"><td colspan="3">No results</td></tr> | |||||
<tr class="even"><td colspan="3"><%= message('no_results') -%></td></tr> | |||||
<% else | <% else | ||||
@snapshots.each do |snapshot| %> | @snapshots.each do |snapshot| %> | ||||
<% path_name=snapshot.path_name %> | <% path_name=snapshot.path_name %> | ||||
<%= path_name -%> | <%= path_name -%> | ||||
</td> | </td> | ||||
<td><a href="#" onClick="selectPath(<%= snapshot.project_id-%>, '<%= escape_javascript(path_name) -%>')">Select</a></td> | |||||
<td><a href="#" onClick="selectPath(<%= snapshot.project_id-%>, '<%= escape_javascript(path_name) -%>')"><%= message('select_verb') -%></a></td> | |||||
</tr> | </tr> | ||||
<% end | <% end | ||||
end %> | end %> |
<table> | <table> | ||||
<tr> | <tr> | ||||
<td> | <td> | ||||
<span class="comments">Size:</span><br/> | |||||
<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({:exclude_user_managed => true}), @size_metric.key), | ||||
:id => 'size_metric', :class => 'small', :onchange => "load_treemap(this.form.size_metric.value,this.form.color_metric.value, false);return false;" %> | :id => 'size_metric', :class => 'small', :onchange => "load_treemap(this.form.size_metric.value,this.form.color_metric.value, false);return false;" %> | ||||
</td> | </td> | ||||
<td class="sep"> </td> | <td class="sep"> </td> | ||||
<td> | <td> | ||||
<span class="comments">Color: <%= render :partial => 'components/treemap_gradient', :locals => {:color_metric => @color_metric} %></span> | |||||
<span class="comments"><%= message('color') -%>: <%= render :partial => 'components/treemap_gradient', :locals => {:color_metric => @color_metric} %></span> | |||||
<br/> | <br/> | ||||
<%= select_tag 'color_metric', options_grouped_by_domain(Sonar::TreemapBuilder.color_metrics, @color_metric.key), | <%= select_tag 'color_metric', options_grouped_by_domain(Sonar::TreemapBuilder.color_metrics, @color_metric.key), | ||||
:id => 'color_metric', :class => 'small', :onchange => "load_treemap(this.form.size_metric.value,this.form.color_metric.value, false);return false;" %> | :id => 'color_metric', :class => 'small', :onchange => "load_treemap(this.form.size_metric.value,this.form.color_metric.value, false);return false;" %> |
<div id="hd"> | <div id="hd"> | ||||
<%= render :partial => 'layouts/breadcrumb' %> | <%= render :partial => 'layouts/breadcrumb' %> | ||||
<ol id="nav"> | <ol id="nav"> | ||||
<li><input type="text" autocomplete="off" size="15" name="search" id="projectSearch" onFocus="this.size=30;this.value='';autocompleteProjects('<%= ApplicationController.root_context -%>/api/resources?scopes=<%= Project::SCOPE_SET -%>&qualifiers=<%= Project::QUALIFIER_VIEW-%>,<%= Project::QUALIFIER_SUBVIEW-%>,<%= Project::QUALIFIER_PROJECT-%>', '<%= ApplicationController.root_context -%>/dashboard/index/', this, $('projectResults'));return true;" onBlur="javacript:this.size=15" value="Search"/><div id="projectResults" style="display:none"></div></li> | |||||
<li><input type="text" autocomplete="off" size="15" name="search" id="projectSearch" onFocus="this.size=30;this.value='';autocompleteProjects('<%= ApplicationController.root_context -%>/api/resources?scopes=<%= Project::SCOPE_SET -%>&qualifiers=<%= Project::QUALIFIER_VIEW-%>,<%= Project::QUALIFIER_SUBVIEW-%>,<%= Project::QUALIFIER_PROJECT-%>', '<%= ApplicationController.root_context -%>/dashboard/index/', this, $('projectResults'));return true;" onBlur="javacript:this.size=15" value="<%= message('search_verb') -%>"/><div id="projectResults" style="display:none"></div></li> | |||||
<li> | <li> | ||||
<a href="javascript:window.print()"><img src="<%= ApplicationController.root_context -%>/images/print.gif" alt="<%= message('layout.print') -%>" title="<%=message('layout.print')-%>" /></a> | <a href="javascript:window.print()"><img src="<%= ApplicationController.root_context -%>/images/print.gif" alt="<%= message('layout.print') -%>" title="<%=message('layout.print')-%>" /></a> | ||||
<% if @project %><a href="<%= url_for :overwrite_params => {:id => @project.key}-%>" id="permalink"><img src="<%= ApplicationController.root_context -%>/images/permalink.gif" alt="<%=message('layout.permalink')-%>" title="<%=message('layout.permalink')-%>" /></a><% end %> | <% if @project %><a href="<%= url_for :overwrite_params => {:id => @project.key}-%>" id="permalink"><img src="<%= ApplicationController.root_context -%>/images/permalink.gif" alt="<%=message('layout.permalink')-%>" title="<%=message('layout.permalink')-%>" /></a><% end %> |
QUALIFIER_LIB='LIB' | QUALIFIER_LIB='LIB' | ||||
QUALIFIERS=[QUALIFIER_VIEW,QUALIFIER_SUBVIEW,QUALIFIER_PROJECT,QUALIFIER_MODULE,QUALIFIER_DIRECTORY,QUALIFIER_PACKAGE,QUALIFIER_FILE,QUALIFIER_CLASS,QUALIFIER_UNIT_TEST_CLASS,QUALIFIER_LIB] | QUALIFIERS=[QUALIFIER_VIEW,QUALIFIER_SUBVIEW,QUALIFIER_PROJECT,QUALIFIER_MODULE,QUALIFIER_DIRECTORY,QUALIFIER_PACKAGE,QUALIFIER_FILE,QUALIFIER_CLASS,QUALIFIER_UNIT_TEST_CLASS,QUALIFIER_LIB] | ||||
QUALIFIER_NAMES={ | QUALIFIER_NAMES={ | ||||
QUALIFIER_VIEW => 'View', | |||||
QUALIFIER_SUBVIEW => 'Sub-view', | |||||
QUALIFIER_PROJECT => 'Project', | |||||
QUALIFIER_MODULE => 'Sub-project', | |||||
QUALIFIER_DIRECTORY => 'Directory', | |||||
QUALIFIER_PACKAGE => 'Package', | |||||
QUALIFIER_FILE => 'File', | |||||
QUALIFIER_CLASS => 'Class', | |||||
QUALIFIER_UNIT_TEST_CLASS => 'Unit test', | |||||
QUALIFIER_LIB => 'Library' | |||||
QUALIFIER_VIEW => 'view', | |||||
QUALIFIER_SUBVIEW => 'sub_view', | |||||
QUALIFIER_PROJECT => 'project', | |||||
QUALIFIER_MODULE => 'sub_project', | |||||
QUALIFIER_DIRECTORY => 'directory', | |||||
QUALIFIER_PACKAGE => 'package', | |||||
QUALIFIER_FILE => 'file', | |||||
QUALIFIER_CLASS => 'class', | |||||
QUALIFIER_UNIT_TEST_CLASS => 'unit_test', | |||||
QUALIFIER_LIB => 'library' | |||||
} | } | ||||
def set? | def set? | ||||
scope==SCOPE_SET | scope==SCOPE_SET |