Save This Page
Home » openjdk-7 » net.sourceforge » neurosdbm » [javadoc | source]
    1   //
    2   //  Neuros Database Manipulator
    3   //  Copyright (C) 2003  Neuros Database Manipulator
    4   //
    5   //  This program is free software; you can redistribute it and/or modify
    6   //  it under the terms of the GNU General Public License as published by
    7   //  the Free Software Foundation; either version 2 of the License, or
    8   //  (at your option) any later version.
    9   //
   10   //  This program is distributed in the hope that it will be useful,
   11   //  but WITHOUT ANY WARRANTY; without even the implied warranty of
   12   //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13   //  GNU General Public License for more details.
   14   //
   15   //  You should have received a copy of the GNU General Public License
   16   //  along with this program; if not, write to the Free Software
   17   //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   18   //
   19   //  For information about Neuros Database Manipulator and its authors,
   20   //  please contact the Neuros Database Manipulator Web Site at
   21   //  http://neurosdbm.sourceforge.net
   22   //
   23   //
   24   
   25   package net.sourceforge.neurosdbm;
   26   
   27   
   28   import java.io.File;
   29   import java.awt.Frame;
   30   import java.awt.Component;
   31   import java.awt.Point;
   32   import java.awt.Dimension;
   33   import java.awt.GridBagLayout;
   34   import java.awt.GridBagConstraints;
   35   import java.awt.Insets;
   36   import java.awt.event.ActionListener;
   37   import java.awt.event.ActionEvent;
   38   import javax.swing.SwingConstants;
   39   import javax.swing.JFileChooser;
   40   import javax.swing.JPanel;
   41   import javax.swing.JLabel;
   42   import javax.swing.JComboBox;
   43   import javax.swing.JCheckBox;
   44   import javax.swing.JTextField;
   45   import net.sourceforge.neurosdbm.db.NeurosDevice;
   46   
   47   public class NeurosDeviceSelection extends JFileChooser {
   48   
   49     private JComboBox devices;
   50     private Frame parent;
   51     private final JTextField pathText = new JTextField();
   52    
   53    public NeurosDeviceSelection() {
   54      this( null);
   55    }
   56    
   57    public NeurosDeviceSelection( Frame parent) {
   58       setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   59       
   60       this.parent = parent;
   61       
   62       GridBagLayout gridbag = new GridBagLayout();
   63       GridBagConstraints constraints = new GridBagConstraints();
   64       constraints.insets = new Insets(3, 3, 3, 3);
   65       
   66       JPanel pane = new JPanel();
   67       pane.setLayout(gridbag);
   68       
   69       JLabel label = new JLabel("Device type:", JLabel.LEFT);
   70       constraints.gridwidth = GridBagConstraints.REMAINDER;
   71       constraints.fill = GridBagConstraints.BOTH;
   72       gridbag.setConstraints(label, constraints);
   73       pane.add(label);
   74   
   75       devices = new JComboBox(NeurosDevice.getDescriptions());
   76       gridbag.setConstraints(devices, constraints);
   77       pane.add(devices);
   78   
   79       JLabel pusher = new JLabel();
   80       constraints.gridheight = GridBagConstraints.REMAINDER;
   81       constraints.fill = GridBagConstraints.BOTH;
   82       constraints.weighty = 1;
   83       gridbag.setConstraints(pusher, constraints);
   84       pane.add(pusher);
   85       
   86       setAccessory(pane);
   87     }
   88   
   89     public boolean getDevice() {
   90       int returnVal = showDialog(parent, "Enter Neuros Device Path and Type");
   91       if (returnVal != JFileChooser.APPROVE_OPTION) {
   92         return false;
   93       }
   94       File newpathFile = getSelectedFile();
   95       String newpath = newpathFile.toString();
   96       int deviceType = devices.getSelectedIndex();
   97       NeurosProperties.setDevicePath(newpath);
   98       NeurosProperties.setDeviceType(deviceType);
   99   
  100       Symbols symbols = NeurosProperties.getSymbols();
  101       String path = pathText.getText();
  102       if (path.length() > 0) symbols.setPath(path);
  103   
  104       NeurosProperties.setSymbols(symbols);
  105       return true;
  106     }
  107   }

Save This Page
Home » openjdk-7 » net.sourceforge » neurosdbm » [javadoc | source]