01: /*
02: * Copyright 2004 JETA Software, Inc. All rights reserved.
03: * JETA SOFTWARE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
04: */
05:
06: package com.jeta.swingbuilder.gui.components.list;
07:
08: import java.awt.BorderLayout;
09: import java.awt.Dimension;
10:
11: import com.jeta.forms.components.panel.FormPanel;
12: import com.jeta.forms.store.properties.IconProperty;
13: import com.jeta.open.gui.framework.JETAPanel;
14: import com.jeta.swingbuilder.gui.utils.FormDesignerUtils;
15:
16: /**
17: * View for editing list item properties.
18: *
19: * @author Jeff Tassin
20: */
21: public class ListItemView extends JETAPanel {
22: private FormPanel m_view;
23:
24: private IconProperty m_icon_prop = new IconProperty();
25:
26: /**
27: * ctor
28: */
29: public ListItemView() {
30: this (null, null);
31: }
32:
33: /**
34: * ctor
35: */
36: public ListItemView(String label, IconProperty iconprop) {
37: m_view = new FormPanel(
38: "com/jeta/swingbuilder/gui/components/list/listItemView.jfrm");
39: setLayout(new BorderLayout());
40: add(m_view, BorderLayout.CENTER);
41:
42: m_view.getButton(ListItemNames.ID_ICON_BTN).setPreferredSize(
43: new Dimension(24, 16));
44: setValues(label, iconprop);
45: setController(new ListItemController(this ));
46: }
47:
48: public String getLabel() {
49: return m_view.getText(ListItemNames.ID_ITEM_LABEL);
50: }
51:
52: public IconProperty getIconProperty() {
53: String icon_path = FormDesignerUtils.fastTrim(m_view
54: .getText(ListItemNames.ID_ICON_PATH));
55: if (icon_path.length() == 0)
56: icon_path = null;
57:
58: m_icon_prop.setRelativePath(icon_path);
59: return m_icon_prop;
60: }
61:
62: void setIconProperty(IconProperty iprop) {
63: m_icon_prop.setValue(iprop);
64:
65: String path = (iprop == null) ? "" : iprop.getRelativePath();
66:
67: m_view.setText(ListItemNames.ID_ICON_PATH, path);
68: }
69:
70: /**
71: * Initializes the view based on the given item property
72: */
73: public void setValues(String label, IconProperty icon_prop) {
74: if (label != null)
75: m_view.setText(ListItemNames.ID_ITEM_LABEL, label);
76:
77: setIconProperty(icon_prop);
78: }
79: }
|