01: //** Copyright Statement ***************************************************
02: //The Salmon Open Framework for Internet Applications (SOFIA)
03: // Copyright (C) 1999 - 2002, Salmon LLC
04: //
05: // This program is free software; you can redistribute it and/or
06: // modify it under the terms of the GNU General Public License version 2
07: // as published by the Free Software Foundation;
08: //
09: // This program is distributed in the hope that it will be useful,
10: // but WITHOUT ANY WARRANTY; without even the implied warranty of
11: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: // GNU General Public License for more details.
13: //
14: // You should have received a copy of the GNU General Public License
15: // along with this program; if not, write to the Free Software
16: // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: //
18: // For more information please visit http://www.salmonllc.com
19: //** End Copyright Statement ***************************************************
20: package com.salmonllc.ideTools;
21:
22: /////////////////////////
23: //$Archive: /SOFIA/SourceCode/com/salmonllc/ideTools/CutPasteDialog.java $
24: //$Author: Srufle $
25: //$Revision: 9 $
26: //$Modtime: 4/15/03 2:24p $
27: /////////////////////////
28: import java.awt.*;
29: import java.awt.event.ActionEvent;
30: import java.awt.event.ActionListener;
31:
32: import javax.swing.*;
33:
34: public class CutPasteDialog extends JDialog implements ActionListener {
35:
36: JTextArea _text;
37: JScrollPane _pane;
38:
39: public CutPasteDialog(Frame owner, String text) {
40: super (owner, "View Generated Code", true);
41:
42: int width = 600;
43: int height = 450;
44: Dimension frameBounds = Toolkit.getDefaultToolkit()
45: .getScreenSize();
46: int x = (frameBounds.width - width) / 2;
47: int y = (frameBounds.height - height) / 2;
48:
49: setBounds(x, y, width, height);
50:
51: JButton select = new JButton("Select All");
52: select.addActionListener(this );
53: JButton copy = new JButton("Copy");
54: copy.addActionListener(this );
55: JButton close = new JButton("Close");
56: close.addActionListener(this );
57: JPanel buttonBar = new JPanel(new FlowLayout());
58: buttonBar.add(copy);
59: buttonBar.add(select);
60: buttonBar.add(close);
61: buttonBar.setAlignmentX(Component.CENTER_ALIGNMENT);
62: _text = new JTextArea(text);
63: _text.setRows(21);
64: _pane = DialogComponentFactory.makeScrollPane(_text);
65:
66: Box box = Box.createVerticalBox();
67: box.add(_pane);
68: box.add(Box.createRigidArea(new Dimension(100, 5)));
69: box.add(buttonBar);
70:
71: getContentPane().add(box);
72: setVisible(true);
73:
74: }
75:
76: public void actionPerformed(ActionEvent e) {
77: if (((JButton) e.getSource()).getText().equals("Close"))
78: setVisible(false);
79: else if (((JButton) e.getSource()).getText().equals("Copy")) {
80: _text.copy();
81: _text.grabFocus();
82: } else {
83: _text.selectAll();
84: _text.grabFocus();
85: }
86: }
87: }
|