01: /*
02: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
07: *
08: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
09: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
10: * the license for the specific language governing your rights and limitations.
11: *
12: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
13: */
14: package org.pentaho.reportdesigner.crm.report.properties.editors;
15:
16: import org.jetbrains.annotations.NotNull;
17: import org.jetbrains.annotations.Nullable;
18: import org.pentaho.reportdesigner.lib.client.i18n.TranslationManager;
19: import org.pentaho.reportdesigner.lib.client.util.FontUtils;
20:
21: import java.awt.*;
22:
23: /**
24: * User: Martin
25: * Date: 27.10.2005
26: * Time: 07:24:52
27: */
28: public class CellEditorJLabelWithEllipsisFont extends
29: CellEditorJLabelWithEllipsis<Font> {
30: @NotNull
31: private Font tableFont;
32:
33: public CellEditorJLabelWithEllipsisFont(@NotNull
34: Font tableFont) {
35: this .tableFont = tableFont;
36: }
37:
38: public void setValue(@Nullable
39: Font font, boolean commit) {
40: super .setValue(font, commit);
41:
42: Font f = getValue();
43: if (f != null && font != null) {
44: if (f.getSize() > tableFont.getSize()) {
45: f = FontUtils.getDerivedFont(font, font.getStyle(),
46: tableFont.getSize());
47: }
48:
49: label.setFont(f);
50: }
51: }
52:
53: @Nullable
54: public String convertToText(@Nullable
55: Font font) {
56: if (font == null) {
57: return null;
58: }
59:
60: StringBuilder sb = new StringBuilder(font.getName());
61: sb.append(" ");
62: sb.append(font.getSize());
63: if ((font.getStyle() & Font.BOLD) == Font.BOLD) {
64: sb.append(" ");
65: sb
66: .append(TranslationManager
67: .getInstance()
68: .getTranslation("R",
69: "CellEditorJLabelWithEllipsisFont.Suffix.Bold"));
70: }
71: if ((font.getStyle() & Font.ITALIC) == Font.ITALIC) {
72: sb.append(" ");
73: sb.append(TranslationManager.getInstance().getTranslation(
74: "R",
75: "CellEditorJLabelWithEllipsisFont.Suffix.Italic"));
76: }
77:
78: return sb.toString();
79: }
80: }
|