01: //WebOnSwing - Web Application Framework
02: //Copyright (C) 2004 Fernando Damian Petrola
03: //
04: //This library is free software; you can redistribute it and/or
05: //modify it under the terms of the GNU Lesser General Public
06: //License as published by the Free Software Foundation; either
07: //version 2.1 of the License, or (at your option) any later version.
08: //
09: //This library is distributed in the hope that it will be useful,
10: //but WITHOUT ANY WARRANTY; without even the implied warranty of
11: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: //Lesser General Public License for more details.
13: //
14: //You should have received a copy of the GNU Lesser General Public
15: //License along with this library; if not, write to the Free Software
16: //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17:
18: package weblog.contributors;
19:
20: import java.util.*;
21:
22: import javax.swing.*;
23:
24: import net.ar.webonswing.remote.*;
25: import net.ar.webonswing.render.markup.*;
26: import net.ar.webonswing.ui.*;
27: import net.ar.webonswing.wrapping.*;
28:
29: public class LabelUIContributor extends
30: AbstractSwingComponentUIContributor {
31: public void doRenderingContribution(
32: RenderingContributionContainer theContribManager) {
33: JLabel aLabel = (JLabel) getJComponent();
34: RemoteHelper.removeToolTipListeners(aLabel);
35:
36: Tag theTag;
37:
38: if (aLabel.getIcon() != null)
39: theTag = new Tag("img").addAttribute(new TagAttribute(
40: "src", "/"
41: + ((ImageIcon) aLabel.getIcon())
42: .getDescription()));
43: else
44: theTag = new Tag("span").addTextToContainer(aLabel
45: .getText());
46:
47: RemoteHelper.addMouseListeners(aLabel, theComponent.getName(),
48: theTag);
49: theContribManager.doContribution(theComponent, theTag, theTag,
50: RemoteHelper.getComponentInitScript(theComponent));
51: }
52:
53: public void dispatchEvents(List anEvents) {
54: for (Iterator i = anEvents.iterator(); i.hasNext();) {
55: RemoteEvent theEvent = (RemoteEvent) i.next();
56: JLabel theLabel = (JLabel) ((AbstractComponentWrapper) theEvent
57: .getSource()).getWrappedComponent();
58:
59: if (theEvent.getType().equals("mouseClicked"))
60: RemoteHelper.fireClickEvent(theLabel);
61: }
62: }
63: }
|