01: /*
02: * Copyright Javelin Software, All rights reserved.
03: */
04:
05: package com.javelin.swinglets.plaf.wml;
06:
07: import java.awt.*;
08: import java.util.*;
09: import java.io.*;
10:
11: import javax.swing.*;
12:
13: import com.javelin.swinglets.*;
14: import com.javelin.swinglets.plaf.*;
15:
16: /**
17: * WMLListUI defines a look and feel for default WML.
18: *
19: * @author Robin Sharp
20: */
21:
22: public class WMLListUI extends WMLComponentUI {
23: /**
24: * Render the UI on the PrintWriter
25: */
26: public void update(PrintWriter out, SComponent c) {
27: if (!c.isVisible())
28: return;
29:
30: SList list = (SList) c;
31:
32: // MS 23 Sept 1999 - added everything below this line:
33:
34: out.print("<select ");
35:
36: if (c.isEnabled()) {
37: WMLUtility.setName(out, list);
38: WMLUtility.setTitle(out, list);
39: }
40:
41: if (list.getToolTipText() != null) {
42: out.print(" title=\"");
43: out.print(list.getToolTipText());
44: out.print("\"");
45: }
46:
47: if (list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) {
48: if (list.getSelectedIndex() >= 0) {
49: out.print(" ivalue=\"");
50: out.print(list.getSelectedIndex());
51: out.print("\"");
52: }
53: out.println(" >");
54: } else {
55: // Multiple selection
56: int[] selected = list.getSelectedIndices();
57: if (selected.length > 0) {
58: out.print(" ivalue=\"");
59: for (int count = 0; count < selected.length; count++) {
60: out.print(selected[count]);
61: if (count < selected.length - 1) {
62: out.print(";");
63: }
64: }
65: out.print("\" ");
66: }
67: out.println(" multiple=\"true\" >");
68: }
69:
70: updateEvent(out, c);
71:
72: for (int index = 0; index < list.getElementCount(); index++) {
73: out.print("<option value=\"");
74: out.print(index);
75: out.print("\">");
76: out.println(list.getElementAt(index).toString());
77:
78: out.println("</option>");
79: }
80: out.println("</select>");
81: }
82:
83: }
|