1 /* 2 Copyright (c) 2003, Laurent Caillette. 3 All rights reserved. 4 5 Redistribution and use in source and binary forms, with or without modifica- 6 tion, are permitted provided that the following conditions are met: 7 8 1. Redistributions of source code must retain the above copyright notice, 9 this list of conditions and the following disclaimer. 10 11 2. Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 15 3. The end-user documentation included with the redistribution, if any, must 16 include the following acknowledgment: "This product includes software 17 written by Laurent Caillette." 18 Alternately, this acknowledgment may appear in the software itself, if 19 and wherever such third-party acknowledgments normally appear. 20 21 4. The name "Laurent Caillette" must not be used to endorse or 22 promote products derived from this software without 23 prior written permission. For written permission, please contact 24 laurent.caillette@laposte.net 25 26 5. Products derived from this software may not be called 27 "Laurent Caillette", nor may "Laurent Caillette" appear 28 in their name, without prior written permission of the 29 author. 30 31 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 32 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 33 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 34 AUTHOR (LAURENT CAILLETTE) BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 35 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 36 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 37 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 38 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 39 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 40 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 */ 42 package tweed.demo; 43 import javax.swing.Action; 44 import javax.swing.JButton; 45 import javax.swing.JLabel; 46 import javax.swing.JPanel; 47 import javax.swing.JTextField; 48 import javax.swing.SwingConstants; 49 import javax.swing.WindowConstants; 50 import java.awt.BorderLayout; 51 import java.awt.Dimension; 52 import java.awt.FlowLayout; 53 import tweed.context.Context; 54 import tweed.swing.ContextualizedAction; 55 import tweed.swing.ContextualizedFrame; 56 import tweed.swing.UserMessageBar; 57 import tweed.system.FunctionalException; 58 59 /*** 60 * @author Laurent Caillette 61 * @version $Id$ 62 */ 63 64 public class DemoFrame extends ContextualizedFrame { 65 66 /*package*/ final CustomerPanel customerPanel = new CustomerPanel()/package-summary.html">color="#329900">package*/ final CustomerPanel customerPanel = new CustomerPanel(); 67 private JPanel jPanelSearch = new JPanel(); 68 private JLabel jLabelSearchFor = new JLabel(); 69 /*package*/ final JTextField jTextFieldIdToSearchFor = new JTextField()/package-summary.html">color="#329900">package*/ final JTextField jTextFieldIdToSearchFor = new JTextField(); 70 private JButton jButtonSearch = new JButton(); 71 private FlowLayout flowLayout1 = new FlowLayout(); 72 73 public DemoFrame() { 74 jbInit(); 75 } 76 77 public DemoFrame( Context context ) { 78 super( context ) ; 79 jbInit() ; 80 } 81 82 public static void main( String[] args ) throws Exception { 83 DemoFrame frame = new DemoFrame() ; 84 frame.setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE ) ; 85 frame.pack(); 86 frame.show(); 87 } 88 89 private void jbInit() { 90 this.setTitle("Bindweed demo"); 91 jLabelSearchFor.setText("Customer ID"); 92 jTextFieldIdToSearchFor.setMinimumSize(new Dimension(100, 100)); 93 jTextFieldIdToSearchFor.setColumns(5); 94 jTextFieldIdToSearchFor.setHorizontalAlignment(SwingConstants.RIGHT); 95 jButtonSearch.setText("Search !"); 96 jPanelSearch.setLayout(flowLayout1); 97 this.getContentPane().add(customerPanel, BorderLayout.CENTER); 98 this.getContentPane().add(jPanelSearch, BorderLayout.NORTH); 99 jPanelSearch.add(jLabelSearchFor, null); 100 jPanelSearch.add(jTextFieldIdToSearchFor, null); 101 jPanelSearch.add(jButtonSearch, null); 102 this.getContentPane().add(userMessageDisplay1, BorderLayout.SOUTH); 103 jButtonSearch.setAction( searchAction ) ; 104 } 105 106 private Action searchAction = new ContextualizedAction( this, "Search !" ) { 107 public void perform( Object actionEvent ) { 108 SearchCommand search = new SearchCommand( getContext() ) ; 109 110 new SearchQueryBinding( 111 getContext(), 112 search.getSearchQueryModel(), 113 jTextFieldIdToSearchFor 114 ).updateModel() ; 115 116 try { 117 search.execute() ; 118 } catch( FunctionalException ex ) { 119 throw new RuntimeException( ex ) ; 120 } 121 new CustomerBinding( 122 getContext(), 123 search.getCustomer(), 124 customerPanel 125 ).updateView() ; 126 } 127 } ; 128 129 private UserMessageBar userMessageDisplay1 = new UserMessageBar( this ) ; 130 131 }

This page was automatically generated by Maven