001: /*
002: * Lucane - a collaborative platform
003: * Copyright (C) 2004 Vincent Fiack <vfiack@mail15.com>
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: */
019:
020: package org.lucane.applications.rssreader.gui;
021:
022: import java.awt.*;
023: import java.awt.event.*;
024:
025: import javax.swing.*;
026:
027: import org.lucane.applications.rssreader.RssReader;
028: import org.lucane.applications.rssreader.rss.ChannelInfo;
029: import org.lucane.client.Client;
030:
031: public class ChannelDialog extends JDialog implements ActionListener,
032: KeyListener {
033: private JButton btnAdd;
034: private JButton btnCancel;
035: private JTextField name;
036: private JTextField url;
037: private MainFrame main;
038: private RssReader plugin;
039:
040: public ChannelDialog(MainFrame main, RssReader plugin) {
041: super ((JFrame) null, plugin.tr("addChannel"));
042:
043: this .main = main;
044: this .plugin = plugin;
045:
046: btnAdd = new JButton(plugin.tr("btn.add"), Client
047: .getImageIcon("add.png"));
048: btnAdd.addActionListener(this );
049: btnCancel = new JButton(plugin.tr("btn.cancel"), Client
050: .getImageIcon("cancel.png"));
051: btnCancel.addActionListener(this );
052: name = new JTextField();
053: url = new JTextField();
054: name.addKeyListener(this );
055: url.addKeyListener(this );
056:
057: JPanel labels = new JPanel(new GridLayout(2, 1));
058: labels.add(new JLabel(plugin.tr("lbl.channelName")));
059: labels.add(new JLabel(plugin.tr("lbl.channelUrl")));
060:
061: JPanel texts = new JPanel(new GridLayout(2, 1));
062: texts.add(name);
063: texts.add(url);
064:
065: JPanel buttons = new JPanel(new GridLayout(1, 2));
066: buttons.add(btnAdd);
067: buttons.add(btnCancel);
068:
069: JPanel channel = new JPanel(new BorderLayout());
070: channel.add(labels, BorderLayout.WEST);
071: channel.add(texts, BorderLayout.CENTER);
072:
073: JPanel buttonContainer = new JPanel(new BorderLayout());
074: buttonContainer.add(buttons, BorderLayout.EAST);
075:
076: getContentPane().add(channel, BorderLayout.CENTER);
077: getContentPane().add(buttonContainer, BorderLayout.SOUTH);
078: setSize(400, 100);
079: }
080:
081: public void actionPerformed(ActionEvent ae) {
082: if (ae.getSource().equals(btnAdd)) {
083: ChannelInfo ci = new ChannelInfo(name.getText(), url
084: .getText());
085: plugin.addChannel(ci);
086: main.refreshChannelList();
087: }
088: dispose();
089: }
090:
091: public void keyReleased(KeyEvent ke) {
092: }
093:
094: public void keyTyped(KeyEvent ke) {
095: }
096:
097: public void keyPressed(KeyEvent ke) {
098: if (ke.getKeyCode() == KeyEvent.VK_ENTER)
099: actionPerformed(new ActionEvent(btnAdd, 0, null));
100: else if (ke.getKeyCode() == KeyEvent.VK_ESCAPE)
101: actionPerformed(new ActionEvent(btnCancel, 0, null));
102: }
103: }
|