View Javadoc

1   /*
2    * @(#)$Id: DatabaseSelector.java 693 2009-07-24 20:31:11Z kurmannu $
3    *
4    * Author		:	Ueli Kurmann, igesture@uelikurmann.ch
5    *                  
6    *
7    * Purpose		: 
8    *
9    * -----------------------------------------------------------------------
10   *
11   * Revision Information:
12   *
13   * Date				Who			Reason
14   *
15   * 17.06.2008			ukurmann	Initial Release
16   *
17   * -----------------------------------------------------------------------
18   *
19   * Copyright 1999-2009 ETH Zurich. All Rights Reserved.
20   *
21   * This software is the proprietary information of ETH Zurich.
22   * Use is subject to license terms.
23   * 
24   */
25  
26  
27  package org.ximtec.igesture.tool.view;
28  
29  import java.awt.BorderLayout;
30  import java.awt.Color;
31  import java.awt.Dimension;
32  import java.awt.FlowLayout;
33  import java.awt.Image;
34  import java.io.File;
35  import java.io.IOException;
36  
37  import javax.imageio.ImageIO;
38  import javax.swing.ImageIcon;
39  import javax.swing.JButton;
40  import javax.swing.JDialog;
41  import javax.swing.JLabel;
42  import javax.swing.JPanel;
43  import javax.swing.JTextField;
44  
45  import org.ximtec.igesture.tool.locator.Locator;
46  import org.ximtec.igesture.tool.service.GuiBundleService;
47  import org.ximtec.igesture.tool.view.databaseselector.BrowseAction;
48  
49  
50  
51  /**
52   * Comment
53   * @version 1.0 17.06.2008
54   * @author Ueli Kurmann
55   */
56  public class DatabaseSelector extends JDialog{
57     
58     private JPanel panel;
59     
60     public DatabaseSelector(){
61        init();
62     }
63     
64     public File getDatabase(){
65      return null;  
66     }
67     
68     private void init(){
69        
70        panel = new JPanel();
71        BorderLayout layout = new BorderLayout();
72        panel.setLayout(layout);
73        panel.setBackground(Color.white);
74        panel.setForeground(Color.white);
75        panel.setOpaque(true);
76        setSize(new Dimension(400,200));
77        
78        JLabel label = new JLabel();
79        Image img = null;
80        
81        try {
82           img = ImageIO.read(DatabaseSelector.class.getClassLoader().getResourceAsStream("image/igesture.gif"));
83        }
84        catch (IOException e) {
85           e.printStackTrace();
86        }
87        
88        ImageIcon icon = new ImageIcon(img);
89        label.setIcon(icon);
90        panel.add(label,BorderLayout.NORTH);
91        
92        panel.add(createSelectPanel(), BorderLayout.CENTER);
93        panel.add(createNavigationPanel(), BorderLayout.SOUTH);
94        
95        add(panel);
96        
97        this.setVisible(true);
98     }
99     
100    private JPanel createSelectPanel(){
101       JPanel panel = new JPanel();
102       panel.setBackground(Color.white);
103       panel.setForeground(Color.white);
104       panel.setOpaque(true);
105       
106       panel.setLayout(new FlowLayout());
107       JTextField field = new JTextField();
108       field.setSize(new Dimension(300, 25));
109       field.setPreferredSize(new Dimension(300,25));
110       panel.add(field);
111       JButton button = new JButton();
112       button.setAction(new BrowseAction(field));
113       panel.add(button);
114       return panel;
115    }
116    
117    private JPanel createNavigationPanel(){
118       JPanel panel = new JPanel();
119       panel.setBackground(Color.white);
120       panel.setForeground(Color.white);
121       panel.setOpaque(true);
122       panel.setLayout(new FlowLayout());
123      // panel.add(new JButton(new SelectDatabaseAction(null)));
124       return panel;
125    }
126    
127    public static void main(String[] args) {
128       Locator locator = Locator.getDefault();
129       locator.addService(new GuiBundleService("igestureMenu"));
130       
131       new DatabaseSelector();
132    }
133 }