001: /*
002: * JacORB - a free Java ORB
003: *
004: * Copyright (C) 1999-2004 Gerald Brose
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Library General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Library General Public License for more details.
015: *
016: * You should have received a copy of the GNU Library General Public
017: * License along with this library; if not, write to the Free
018: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
019: *
020: */
021: package org.jacorb.imr.util;
022:
023: import java.awt.*;
024: import javax.swing.*;
025: import java.awt.event.ActionListener;
026: import java.awt.event.ActionEvent;
027:
028: /**
029: * ConnectWindow.java
030: *
031: *
032: * Created: Mon Nov 1 18:22:20 1999
033: *
034: */
035:
036: public class ConnectWindow extends JFrame implements ActionListener {
037: private JTextField m_imr_url_tf;
038: private JButton m_imr_connect_btn;
039: private JButton m_cancel_btn;
040: private transient ImRModel m_model;
041:
042: public ConnectWindow(ImRModel model) {
043: super ("Connect to remote repository");
044:
045: m_model = model;
046:
047: JPanel _url_panel = new JPanel();
048: GridBagLayout _url_gbl = new GridBagLayout();
049: GridBagConstraints _constraints = new GridBagConstraints();
050:
051: JLabel _url_lbl = new JLabel("Enter a URL:");
052: buildConstraints(_constraints, 0, 0, 1, 1, 1, 1);
053: _constraints.fill = GridBagConstraints.NONE;
054: _url_gbl.setConstraints(_url_lbl, _constraints);
055: _url_panel.add(_url_lbl);
056:
057: m_imr_url_tf = new JTextField("http://", 30);
058: buildConstraints(_constraints, 0, 1, 2, 1, 1, 1);
059: _constraints.fill = GridBagConstraints.HORIZONTAL;
060: _url_gbl.setConstraints(m_imr_url_tf, _constraints);
061: _url_panel.add(m_imr_url_tf);
062:
063: m_imr_connect_btn = new JButton("Connect");
064: m_imr_connect_btn.addActionListener(this );
065: buildConstraints(_constraints, 0, 2, 1, 1, 1, 1);
066: _constraints.fill = GridBagConstraints.NONE;
067: _url_gbl.setConstraints(m_imr_connect_btn, _constraints);
068: _url_panel.add(m_imr_connect_btn);
069:
070: m_cancel_btn = new JButton("Cancel");
071: m_cancel_btn.addActionListener(this );
072: buildConstraints(_constraints, 1, 2, 1, 1, 1, 1);
073: _constraints.fill = GridBagConstraints.NONE;
074: _url_gbl.setConstraints(m_cancel_btn, _constraints);
075: _url_panel.add(m_cancel_btn);
076:
077: _url_panel.setLayout(_url_gbl);
078:
079: getContentPane().add(_url_panel);
080: pack();
081: setVisible(true);
082: }
083:
084: private void buildConstraints(GridBagConstraints gbc, int gx,
085: int gy, int gw, int gh, int wx, int wy) {
086: gbc.gridx = gx;
087: gbc.gridy = gy;
088: gbc.gridwidth = gw;
089: gbc.gridheight = gh;
090: gbc.weightx = wx;
091: gbc.weighty = wy;
092: }
093:
094: // implementation of java.awt.event.ActionListener interface
095:
096: public void actionPerformed(ActionEvent event) {
097: JButton _source = (JButton) event.getSource();
098:
099: if (_source == m_cancel_btn)
100: dispose();
101: else if (_source == m_imr_connect_btn) {
102: dispose();
103: m_model.connectTo(m_imr_url_tf.getText());
104: }
105: }
106: } // ConnectWindow
|