2 * Sonar, open source software quality management tool.
3 * Copyright (C) 2008-2012 SonarSource
4 * mailto:contact AT sonarsource DOT com
6 * Sonar is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * Sonar is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Sonar; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
20 package org.sonar.plugins.design.ui.dependencies.client;
22 import com.google.gwt.i18n.client.Dictionary;
23 import com.google.gwt.user.client.ui.*;
24 import org.sonar.wsclient.services.Measure;
25 import org.sonar.wsclient.services.Resource;
27 public class Header extends Composite {
28 private FlowPanel header;
31 header = new FlowPanel();
32 header.setStyleName("gwt-ViewerHeader");
36 private void addMeasure(Panel panel, Resource resource, String key, String label) {
37 Measure measure = resource.getMeasure(key);
38 if (measure != null) {
39 HTML html = new HTML(label + ": ");
40 html.setStyleName("metric");
43 html = new HTML(measure.getFormattedValue("-"));
44 html.setStyleName("value");
49 public void display(Data data) {
51 HorizontalPanel panel = new HorizontalPanel();
53 Dictionary l10n = Dictionary.getDictionary("l10n");
54 addMeasure(panel, data.getResource(), "classes", l10n.get("depsTab.classes"));
55 addMeasure(panel, data.getResource(), "dit", l10n.get("depsTab.dit"));
56 addMeasure(panel, data.getResource(), "noc", l10n.get("depsTab.noc"));
57 addMeasure(panel, data.getResource(), "rfc", l10n.get("depsTab.rfc"));
58 addLcom4(data, panel);
61 private void addLcom4(Data data, HorizontalPanel panel) {
62 Measure lcom4 = data.getResource().getMeasure("lcom4");
63 if (lcom4 != null && lcom4.getIntValue()!=null) {
64 HTML html = new HTML(Dictionary.getDictionary("l10n").get("depsTab.lcom4") + ": ");
65 html.setStyleName("metric");
68 html = new HTML(lcom4.getIntValue() + "");
69 html.setStyleName("value");
70 if (lcom4.getIntValue()>1) {
71 html.addStyleName("red bold");