1 /*
2 * Scope: a generic MVC framework.
3 * Copyright (c) 2000-2002, The Scope team
4 * All rights reserved.
5 *
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * Neither the name "Scope" nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 *
36 * $Id: SearchView.java,v 1.4 2002/09/05 15:41:48 ludovicc Exp $
37 */
38 package samples.filefind;
39
40
41 import java.awt.Dimension;
42 import java.awt.GridBagLayout;
43 import javax.swing.JLabel;
44 import javax.swing.JScrollPane;
45 import org.scopemvc.core.Control;
46 import org.scopemvc.core.ModelChangeEvent;
47 import org.scopemvc.core.ModelChangeEventSource;
48 import org.scopemvc.core.ModelChangeListener;
49 import org.scopemvc.view.swing.SButton;
50 import org.scopemvc.view.swing.SCheckBox;
51 import org.scopemvc.view.swing.SPanel;
52 import org.scopemvc.view.swing.STable;
53 import org.scopemvc.view.swing.STextField;
54 import samples.util.GridBagHelper;
55
56 /***
57 * @author <A HREF="mailto:daniel.michalik@autel.cz">Daniel Michalik</A>
58 * @created 05 September 2002
59 * @version $Revision: 1.4 $ $Date: 2002/09/05 15:41:48 $
60 */
61 public final class SearchView extends SPanel {
62
63 /***
64 * A ModelChangeListener used to show and hide the DateCriteriaView
65 * depending on whether isDateCriteriaEnabled() of bound model.
66 */
67 ModelChangeListener myModelChangeListener =
68 new ModelChangeListener() {
69 public void modelChanged(ModelChangeEvent e) {
70 SearchViewModel m = (SearchViewModel) e.getModel();
71 dateCriteriaView.setVisible(m.isDateCriteriaEnabled());
72 }
73 };
74
75 private DateCriteriaView dateCriteriaView;
76
77
78 /***
79 * Constructor for the SearchView object
80 */
81 public SearchView() {
82
83 GridBagLayout gridbag = new GridBagLayout();
84 gridbag.columnWidths = new int[]{12, 0, 11, 0, 11, 0, 0, 11};
85 gridbag.columnWeights = new double[]{0, 0, 0, 0, 1, 0};
86 gridbag.rowHeights = new int[]{12, 0, 5, 0, 11, 0, 0, 0, 0, 0, 11};
87 gridbag.rowWeights = new double[]{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0};
88 setLayout(gridbag);
89 GridBagHelper hlp = new GridBagHelper();
90
91 add(new JLabel("Search files with name (PERL regular expression):"), hlp.xywh(3, 1, 3, 1, "w"));
92
93 STextField t = new STextField();
94 t.setSelector(SearchViewModel.FILE_NAME_PATTERN);
95 add(t, hlp.xywh(3, 3, 4, 1, "we"));
96
97 SCheckBox b = new SCheckBox();
98 b.setText("Date");
99 b.setSelector(SearchViewModel.DATE_CRITERIA_ENABLED);
100 add(b, hlp.xy(3, 5, "wen"));
101
102 dateCriteriaView = new DateCriteriaView();
103 add(dateCriteriaView, hlp.xy(5, 5));
104
105 SButton searchBtn = new SButton("Search");
106 searchBtn.setControlID(SearchController.SEARCH_CONTROL_ID);
107 add(searchBtn, hlp.xy(3, 8));
108
109 STable table = new STable();
110 table.setSelectorString("fsRoots.fileSystemRoots");
111 table.setColumnNames(new String[]{
112 "",
113 "",
114 });
115 table.setColumnSelectorStrings(new String[]{
116 "enabled",
117 "name",
118 });
119
120 JScrollPane scroll = new JScrollPane(table);
121 scroll.setPreferredSize(new Dimension(80, 100));
122 add(scroll, hlp.xywh(1, 1, 1, 9, "news"));
123 // add(new FSRootsView(), hlp.xywh(1, 1, 1, 9, "news"));
124 }
125
126
127 /***
128 * Gets the close control
129 *
130 * @return The closeControl value
131 */
132 public Control getCloseControl() {
133 return new Control(SearchController.EXIT_CONTROL_ID, this);
134 }
135
136
137 /***
138 * Gets the title
139 *
140 * @return The title value
141 */
142 public String getTitle() {
143 return "Find File";
144 }
145
146
147 /***
148 * Register a private ModelChangeListener to show and hide the
149 * DateCriteriaView depending on whether isDateCriteriaEnabled() of bound
150 * model.
151 *
152 * @param inModel The new boundModel value
153 */
154 public void setBoundModel(Object inModel) {
155 super.setBoundModel(inModel);
156 ModelChangeEventSource m = (ModelChangeEventSource) inModel;
157 m.addModelChangeListener(myModelChangeListener);
158 }
159 }
This page was automatically generated by Maven