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.crm.report.model.ElementBorderDefinition;
19:
20: import javax.swing.*;
21: import java.awt.*;
22:
23: /**
24: * User: Martin
25: * Date: 27.10.2005
26: * Time: 07:24:52
27: */
28: public class CellEditorJLabelWithEllipsisElementBorderDefinition extends
29: CellEditorJLabelWithEllipsis<ElementBorderDefinition> {
30:
31: public CellEditorJLabelWithEllipsisElementBorderDefinition() {
32: remove(label);//remove old label (see super)
33: label = new JLabelBorderDefinition();
34: add(label, BorderLayout.CENTER);
35: }
36:
37: public void setValue(@Nullable
38: ElementBorderDefinition borderDefinition, boolean commit) {
39: super .setValue(borderDefinition, commit);
40: ((JLabelBorderDefinition) label)
41: .setElementBorderDefinition(borderDefinition);
42: }
43:
44: @Nullable
45: public String convertToText(@Nullable
46: ElementBorderDefinition borderDefinition) {
47: return null;
48: }
49:
50: private static class JLabelBorderDefinition extends JLabel {
51: @NotNull
52: private ElementBorderDefinition borderDefinition;
53:
54: private JLabelBorderDefinition() {
55: borderDefinition = new ElementBorderDefinition();
56: setText(" ");
57: }
58:
59: public void setText(@Nullable
60: String text) {
61: super .setText(" ");
62: }
63:
64: public void setElementBorderDefinition(@Nullable
65: ElementBorderDefinition borderDefinition) {
66: if (borderDefinition != null) {
67: this .borderDefinition = borderDefinition;
68: }
69: }
70:
71: protected void paintComponent(@NotNull
72: Graphics g) {
73: super .paintComponent(g);
74:
75: Graphics2D g2d = (Graphics2D) g;
76: Stroke origStroke = g2d.getStroke();
77: Color origColor = g2d.getColor();
78:
79: if (borderDefinition.getTopSide().getType() != ElementBorderDefinition.BorderType.NONE) {
80: g2d.setColor(borderDefinition.getTopSide().getColor());
81: g2d
82: .setStroke(borderDefinition.getTopSide()
83: .getStroke());
84:
85: g2d.drawLine(0, getHeight() / 2, getWidth(),
86: getHeight() / 2);
87: }
88:
89: g2d.setStroke(origStroke);
90: g2d.setColor(origColor);
91: }
92: }
93: }
|