1 | // Copyright 2004-2007 Jean-Francois Poilpret |
2 | // |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | // you may not use this file except in compliance with the License. |
5 | // You may obtain a copy of the License at |
6 | // |
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | // |
9 | // Unless required by applicable law or agreed to in writing, software |
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | // See the License for the specific language governing permissions and |
13 | // limitations under the License. |
14 | |
15 | package net.sourceforge.hiveboard.dialog; |
16 | |
17 | import java.awt.Component; |
18 | |
19 | import javax.swing.JList; |
20 | |
21 | import org.jvnet.substance.SubstanceDefaultListCellRenderer; |
22 | |
23 | import net.sourceforge.hiveboard.BoardTokenSetter; |
24 | import net.sourceforge.hivegui.application.ApplicationContextHolder; |
25 | import net.sourceforge.hivegui.component.TextMapRendererDelegate; |
26 | |
27 | public class BoardTokenSetterRenderer extends SubstanceDefaultListCellRenderer |
28 | { |
29 | static private final String NAME = "BoardTokenSetterRenderer"; |
30 | |
31 | public BoardTokenSetterRenderer() |
32 | { |
33 | _delegate = new TextMapRendererDelegate(); |
34 | _delegate.setRendererName(NAME); |
35 | _delegate.addText(BoardTokenSetter.InitiatorOnly); |
36 | _delegate.addText(BoardTokenSetter.InitiatorOrCurrentWriter); |
37 | _delegate.addText(BoardTokenSetter.InitiatorOrCurrentWriterOrSystem); |
38 | } |
39 | |
40 | public void setContextHolder(ApplicationContextHolder holder) |
41 | { |
42 | _delegate.setContextHolder(holder); |
43 | } |
44 | |
45 | @Override public Component getListCellRendererComponent(JList list, |
46 | Object value, |
47 | int index, |
48 | boolean isSelected, |
49 | boolean cellHasFocus) |
50 | { |
51 | super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
52 | _delegate.setValue(this, value); |
53 | return this; |
54 | } |
55 | |
56 | private final TextMapRendererDelegate _delegate; |
57 | } |