diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2011-08-01 16:10:08 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2011-08-01 16:10:08 +0200 |
commit | c8c4752cf3f27fb4b0acf1234208127934689568 (patch) | |
tree | 968e2a81f7ba390d2037c48b2c15bffa3c3ef702 /plugins/sonar-design-plugin | |
parent | 67fe723d894ac406fe7b859bdcd13d5ea35e6f6e (diff) | |
download | sonarqube-c8c4752cf3f27fb4b0acf1234208127934689568.tar.gz sonarqube-c8c4752cf3f27fb4b0acf1234208127934689568.zip |
SONAR-75 support GWT components integrated to core
Diffstat (limited to 'plugins/sonar-design-plugin')
10 files changed, 37 insertions, 174 deletions
diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/dependencies/client/DependenciesTable.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/dependencies/client/DependenciesTable.java index ce4ed84c755..b00726c1830 100644 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/dependencies/client/DependenciesTable.java +++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/dependencies/client/DependenciesTable.java @@ -21,6 +21,7 @@ package org.sonar.plugins.design.ui.dependencies.client; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.i18n.client.Dictionary; import com.google.gwt.user.client.ui.*; import org.sonar.gwt.Links; import org.sonar.gwt.ui.Icons; @@ -43,7 +44,7 @@ public class DependenciesTable extends Composite { panel.add(createIncomingColumn(data)); panel.add(createOutgoingColumn(data)); } else { - panel.add(new Label(I18nConstants.INSTANCE.noData())); + panel.add(new Label(Dictionary.getDictionary("l10n").get("noData"))); } } @@ -51,7 +52,7 @@ public class DependenciesTable extends Composite { private Panel createIncomingColumn(Data data) { FlexTable grid = new FlexTable(); grid.setStyleName("col"); - grid.setWidget(0, 1, new HTML("<b>" + I18nConstants.INSTANCE.afferentCouplings() + "</b>: " + data.getResource().getMeasureIntValue("ca"))); + grid.setWidget(0, 1, new HTML("<b>" + Dictionary.getDictionary("l10n").get("depsTab.afferentCouplings") + "</b>: " + data.getResource().getMeasureIntValue("ca"))); grid.getRowFormatter().setStyleName(0, "coltitle"); int row = 1; @@ -69,7 +70,7 @@ public class DependenciesTable extends Composite { private Panel createOutgoingColumn(Data data) { FlexTable grid = new FlexTable(); grid.setStyleName("col"); - grid.setWidget(0, 1, new HTML("<b>" + I18nConstants.INSTANCE.efferentCouplings() + "</b>: " + data.getResource().getMeasureIntValue("ce"))); + grid.setWidget(0, 1, new HTML("<b>" + Dictionary.getDictionary("l10n").get("depsTab.efferentCouplings") + "</b>: " + data.getResource().getMeasureIntValue("ce"))); grid.getRowFormatter().setStyleName(0, "coltitle"); int row = 1; diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/dependencies/client/Header.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/dependencies/client/Header.java index 3be4f7037a5..d902504cb0b 100644 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/dependencies/client/Header.java +++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/dependencies/client/Header.java @@ -19,6 +19,7 @@ */ package org.sonar.plugins.design.ui.dependencies.client; +import com.google.gwt.i18n.client.Dictionary; import com.google.gwt.user.client.ui.*; import org.sonar.wsclient.services.Measure; import org.sonar.wsclient.services.Resource; @@ -49,17 +50,18 @@ public class Header extends Composite { header.clear(); HorizontalPanel panel = new HorizontalPanel(); header.add(panel); - addMeasure(panel, data.getResource(), "classes", I18nConstants.INSTANCE.classes()); - addMeasure(panel, data.getResource(), "dit", I18nConstants.INSTANCE.dit()); - addMeasure(panel, data.getResource(), "noc", I18nConstants.INSTANCE.noc()); - addMeasure(panel, data.getResource(), "rfc", I18nConstants.INSTANCE.rfc()); + Dictionary l10n = Dictionary.getDictionary("l10n"); + addMeasure(panel, data.getResource(), "classes", l10n.get("depsTab.classes")); + addMeasure(panel, data.getResource(), "dit", l10n.get("depsTab.dit")); + addMeasure(panel, data.getResource(), "noc", l10n.get("depsTab.noc")); + addMeasure(panel, data.getResource(), "rfc", l10n.get("depsTab.rfc")); addLcom4(data, panel); } private void addLcom4(Data data, HorizontalPanel panel) { Measure lcom4 = data.getResource().getMeasure("lcom4"); if (lcom4 != null && lcom4.getIntValue()!=null) { - HTML html = new HTML(I18nConstants.INSTANCE.lcom4() + ": "); + HTML html = new HTML(Dictionary.getDictionary("l10n").get("depsTab.lcom4") + ": "); html.setStyleName("metric"); panel.add(html); diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/dependencies/client/I18nConstants.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/dependencies/client/I18nConstants.java deleted file mode 100644 index cccb2304629..00000000000 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/dependencies/client/I18nConstants.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 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.design.ui.dependencies.client; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.i18n.client.Constants; - -public interface I18nConstants extends com.google.gwt.i18n.client.Constants { - - static I18nConstants INSTANCE = GWT.create(I18nConstants.class); - - @DefaultStringValue("Afferent (incoming) couplings") - String afferentCouplings(); - - @DefaultStringValue("Efferent (outgoing) couplings") - String efferentCouplings(); - - @DefaultStringValue("Classes") - String classes(); - - @DefaultStringValue("Depth in Tree") - String dit(); - - @DefaultStringValue("Number of Children") - String noc(); - - @Constants.DefaultStringValue("Response for Class") - String rfc(); - - @DefaultStringValue("Lack of Cohesion of Methods") - String lcom4(); - - @DefaultStringValue("No data") - String noData(); -} diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/lcom4/client/Lcom4Tab.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/lcom4/client/Lcom4Tab.java index 7fe67a1a030..b9aaba09578 100644 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/lcom4/client/Lcom4Tab.java +++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/lcom4/client/Lcom4Tab.java @@ -19,6 +19,7 @@ */ package org.sonar.plugins.design.ui.lcom4.client; +import com.google.gwt.i18n.client.Dictionary; import com.google.gwt.user.client.ui.*; import org.sonar.gwt.ui.Icons; import org.sonar.gwt.ui.Loading; @@ -87,7 +88,7 @@ public class Lcom4Tab extends Page { header.setStyleName("gwt-ViewerHeader"); HorizontalPanel panel = new HorizontalPanel(); - HTML html = new HTML("Lack of Cohesion of Methods: "); + HTML html = new HTML(Dictionary.getDictionary("l10n").get("lcom4.metric") + ": "); html.setStyleName("metric"); panel.add(html); diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/libraries/client/Filters.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/libraries/client/Filters.java index 6a76d5c681e..ca097a57421 100644 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/libraries/client/Filters.java +++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/libraries/client/Filters.java @@ -19,6 +19,7 @@ */ package org.sonar.plugins.design.ui.libraries.client; +import com.google.gwt.i18n.client.Dictionary; import com.google.gwt.user.client.ui.Anchor; import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.Grid; @@ -42,21 +43,22 @@ public class Filters extends Grid { super(1, 5); setStyleName("libFilter"); + Dictionary l10n = Dictionary.getDictionary("l10n"); keywordFilter = new KeywordFilter(); - setWidget(0, 0, new Label(I18nConstants.INSTANCE.filter())); + setWidget(0, 0, new Label(l10n.get("libs.filter"))); setWidget(0, 1, keywordFilter); - testCheckbox = new CheckBox(I18nConstants.INSTANCE.displayTests()); + testCheckbox = new CheckBox(l10n.get("libs.displayTests")); testCheckbox.getElement().setId("testCb"); testCheckbox.setValue(Boolean.valueOf(Configuration.getRequestParameter(PARAM_TEST, "false"))); setWidget(0, 2, testCheckbox); - expandCollapse = new Anchor(I18nConstants.INSTANCE.collapse()); + expandCollapse = new Anchor(l10n.get("libs.collapse")); isExpanded = true; setWidget(0, 3, expandCollapse); - usageLink = new Anchor(I18nConstants.INSTANCE.usageLink(), Links.baseUrl() + "/dependencies/index?search=" + resource.getKey()); + usageLink = new Anchor(l10n.get("libs.usageLink"), Links.baseUrl() + "/dependencies/index?search=" + resource.getKey()); setWidget(0, 4, usageLink); } @@ -98,14 +100,14 @@ public class Filters extends Grid { public void expand() { if (!isExpanded) { - expandCollapse.setText(I18nConstants.INSTANCE.collapse()); + expandCollapse.setText(Dictionary.getDictionary("l10n").get("libs.collapse")); isExpanded = true; } } public void collapse() { if (isExpanded) { - expandCollapse.setText(I18nConstants.INSTANCE.expand()); + expandCollapse.setText(Dictionary.getDictionary("l10n").get("libs.expand")); isExpanded = false; } } diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/libraries/client/I18nConstants.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/libraries/client/I18nConstants.java deleted file mode 100644 index 79eecaffdf1..00000000000 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/libraries/client/I18nConstants.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 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.design.ui.libraries.client; - -import com.google.gwt.core.client.GWT; - -public interface I18nConstants extends com.google.gwt.i18n.client.Constants { - - static I18nConstants INSTANCE = GWT.create(I18nConstants.class); - - @DefaultStringValue("Filter:") - String filter(); - - @DefaultStringValue("Display test libraries") - String displayTests(); - - @DefaultStringValue("Expand all") - String expand(); - - @DefaultStringValue("Collapse all") - String collapse(); - - @DefaultStringValue("No libraries") - String noLibraries(); - - @DefaultStringValue("Usages") - String usageLink(); -} diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/libraries/client/ProjectPanel.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/libraries/client/ProjectPanel.java index 685b5ef21c0..56a2b2e59dd 100644 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/libraries/client/ProjectPanel.java +++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/libraries/client/ProjectPanel.java @@ -19,6 +19,7 @@ */ package org.sonar.plugins.design.ui.libraries.client; +import com.google.gwt.i18n.client.Dictionary; import com.google.gwt.user.client.ui.*; import org.sonar.gwt.ui.Icons; import org.sonar.gwt.ui.Loading; @@ -101,7 +102,7 @@ public class ProjectPanel extends FlowPanel { } private Label createNoLibsMessage() { - Label msg = new Label(I18nConstants.INSTANCE.noLibraries()); + Label msg = new Label(Dictionary.getDictionary("l10n").get("libs.noLibraries")); msg.setStyleName("nolibs"); return msg; } diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/DependencyInfo.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/DependencyInfo.java index 42db5030b05..22047918857 100644 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/DependencyInfo.java +++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/DependencyInfo.java @@ -21,6 +21,7 @@ package org.sonar.plugins.design.ui.page.client; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.i18n.client.Dictionary; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.*; import org.sonar.gwt.Configuration; @@ -95,7 +96,7 @@ public class DependencyInfo extends Composite { protected void doOnResponse(Dependency dependency) { if (dependency == null) { setLoaded(); - panel.add(new Label(I18nConstants.INSTANCE.noData())); + panel.add(new Label(Dictionary.getDictionary("l10n").get("noData"))); } else { loadSubDependencies(dependency); } @@ -168,7 +169,7 @@ public class DependencyInfo extends Composite { } private Widget createNewWindowLink() { - Label popup = new Label(I18nConstants.INSTANCE.newWindow()); + Label popup = new Label(Dictionary.getDictionary("l10n").get("newWindow")); popup.setStyleName("newwindow"); popup.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/Dsm.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/Dsm.java index 6594f9dbf25..5506ec1e35e 100644 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/Dsm.java +++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/Dsm.java @@ -23,6 +23,7 @@ import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.DoubleClickEvent; import com.google.gwt.event.dom.client.DoubleClickHandler; +import com.google.gwt.i18n.client.Dictionary; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.*; import org.sonar.gwt.Links; @@ -67,25 +68,26 @@ public class Dsm extends Composite { } private Widget createLegend() { + Dictionary l10n = Dictionary.getDictionary("l10n"); HorizontalPanel legend = new HorizontalPanel(); legend.getElement().setId("dsmlegend"); legend.add(new HTML("<div class='square gray'> </div>")); - legend.add(new Label(I18nConstants.INSTANCE.legendDependencies())); + legend.add(new Label(l10n.get("design.legend.dependencies"))); legend.add(new HTML("<div class='space'></div>")); legend.add(new HTML("<div class='square red'> </div> ")); - legend.add(new Label(I18nConstants.INSTANCE.legendCycles())); + legend.add(new Label(l10n.get("design.legend.cycles"))); legend.add(new HTML(" <div class='space'></div> ")); legend.add(new HTML("<div class='square green'></div> ")); - legend.add(new Label(I18nConstants.INSTANCE.legendUses())); + legend.add(new Label(l10n.get("design.legend.uses"))); legend.add(new HTML("<div class='square blue'></div> ")); - legend.add(new Label(I18nConstants.INSTANCE.legendUses())); + legend.add(new Label(l10n.get("design.legend.uses"))); legend.add(new HTML(" <div class='square yellow'></div>")); return legend; } public void displayNoData() { dsm.clear(); - dsm.add(new Label(I18nConstants.INSTANCE.noData())); + dsm.add(new Label(Dictionary.getDictionary("l10n").get("noData"))); } public void display(DsmData.Rows data) { @@ -107,7 +109,8 @@ public class Dsm extends Composite { private Widget createHelp() { HorizontalPanel help = new HorizontalPanel(); help.getElement().setId("dsmhelp"); - Anchor link = new Anchor(I18nConstants.INSTANCE.linkToHelp(), "http://docs.codehaus.org/x/QQFhC", "docsonar"); + Dictionary l10n = Dictionary.getDictionary("l10n"); + Anchor link = new Anchor(l10n.get("design.help"), "http://docs.codehaus.org/x/QQFhC", "docsonar"); help.add(Icons.get().help().createImage()); help.add(link); return help; @@ -289,7 +292,7 @@ public class Dsm extends Composite { cell = buildCell(row, col, weight, (col > row ? GRID_CELL_TOP_RIGHT : GRID_CELL_BOTTOM_LEFT)); if (weight > 0) { - String tooltip = data.get(col).getName() + " -> " + data.get(row).getName() + " (" + weight + "). " + I18nConstants.INSTANCE.cellTooltip(); + String tooltip = data.get(col).getName() + " -> " + data.get(row).getName() + " (" + weight + "). " + Dictionary.getDictionary("l10n").get("design.cellTooltip"); cell.setTitle(tooltip); } return cell; @@ -323,7 +326,7 @@ public class Dsm extends Composite { } }; title.setStylePrimaryName(HEADER_TITLE); - title.setTitle(I18nConstants.INSTANCE.rowTooltip()); + title.setTitle(Dictionary.getDictionary("l10n").get("design.rowTooltip")); final int finalIndexRow = indexRow; title.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/I18nConstants.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/I18nConstants.java deleted file mode 100644 index 48dc7ac6ad2..00000000000 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/I18nConstants.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 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.design.ui.page.client; - -import com.google.gwt.core.client.GWT; - -public interface I18nConstants extends com.google.gwt.i18n.client.Constants { - - static I18nConstants INSTANCE = GWT.create(I18nConstants.class); - - @DefaultStringValue("Dependency") - String legendDependencies(); - - @DefaultStringValue("Suspect dependency (cycle)") - String legendCycles(); - - @DefaultStringValue("- uses >") - String legendUses(); - - @DefaultStringValue("No data") - String noData(); - - @DefaultStringValue("New window") - String newWindow(); - - @DefaultStringValue("Click to highlight, double-click to display more details.") - String cellTooltip(); - - @DefaultStringValue("Click to highlight, double-click to zoom.") - String rowTooltip(); - - @DefaultStringValue("Help") - String linkToHelp(); -} |