001: /*
002: * Created on Oct 3, 2004
003: *
004: * @author ctaylor
005: *
006: */
007: package com.pk.script.ui;
008:
009: import java.awt.Color;
010: import java.awt.Component;
011:
012: import java.awt.GridBagConstraints;
013: import java.awt.GridBagLayout;
014: import java.awt.Insets;
015: import java.awt.event.ActionListener;
016:
017: import javax.swing.BorderFactory;
018: import javax.swing.BoxLayout;
019: import javax.swing.ButtonGroup;
020: import javax.swing.JButton;
021: import javax.swing.JPanel;
022: import javax.swing.JRadioButton;
023: import javax.swing.JScrollPane;
024: import javax.swing.JTextArea;
025: import javax.swing.JTextField;
026:
027: import com.pk.script.Script;
028:
029: /**
030: * @author ctaylor
031: *
032: */
033: public class PasteScriptPanel extends JPanel {
034: /**
035: *
036: */
037: private static final long serialVersionUID = -3708779830891735747L;
038: private JTextArea scriptTextArea;
039: private JButton okButton;
040: private JButton cancelButton;
041: private JTextField delimiterTextField;
042: private JRadioButton insertEndRadioButton;
043: private JRadioButton insertBeginningRadioButton;
044: private JRadioButton insertAtCurserRadioButton;
045: private JRadioButton replaceCurrentScriptRadioButton;
046: private ActionListener actionListener;
047:
048: public PasteScriptPanel(ActionListener argActionListener) {
049: actionListener = argActionListener;
050: JPanel radioButtonPanel = new JPanel();
051: insertEndRadioButton = new JRadioButton("Insert at End");
052: insertEndRadioButton.setSelected(true);
053: radioButtonPanel.add(insertEndRadioButton);
054: insertBeginningRadioButton = new JRadioButton(
055: "Insert at Beginning");
056: radioButtonPanel.add(insertBeginningRadioButton);
057: insertAtCurserRadioButton = new JRadioButton("Insert at Curser");
058: radioButtonPanel.add(insertAtCurserRadioButton);
059: replaceCurrentScriptRadioButton = new JRadioButton(
060: "Replace Current Script");
061: radioButtonPanel.add(replaceCurrentScriptRadioButton);
062: radioButtonPanel.setBorder(BorderFactory
063: .createLineBorder(Color.BLACK));
064: ButtonGroup radioGroup = new ButtonGroup();
065: radioGroup.add(insertEndRadioButton);
066: radioGroup.add(insertBeginningRadioButton);
067: radioGroup.add(insertAtCurserRadioButton);
068: radioGroup.add(replaceCurrentScriptRadioButton);
069:
070: this .add(radioButtonPanel);
071:
072: scriptTextArea = new JTextArea(20, 40);
073: JScrollPane sqlScrollPane = new JScrollPane(scriptTextArea);
074:
075: okButton = new JButton("Ok");
076: okButton.addActionListener(actionListener);
077:
078: okButton.setAlignmentX(Component.CENTER_ALIGNMENT);
079:
080: cancelButton = new JButton("Cancel");
081: cancelButton.addActionListener(actionListener);
082: cancelButton.setAlignmentX(Component.CENTER_ALIGNMENT);
083:
084: JPanel buttonPanel = new JPanel();
085: buttonPanel.setLayout(new BoxLayout(buttonPanel,
086: BoxLayout.Y_AXIS));
087: okButton.setSize(cancelButton.getSize());
088: buttonPanel.add(okButton);
089: buttonPanel.add(cancelButton);
090:
091: JPanel centerPanel = new JPanel();
092: centerPanel.setLayout(new GridBagLayout());
093: GridBagConstraints gbc = new GridBagConstraints();
094: gbc.anchor = GridBagConstraints.NORTH;
095: gbc.insets = new Insets(6, 15, 6, 15);
096: gbc.gridx = 0;
097: gbc.gridy = 0;
098: centerPanel.add(sqlScrollPane, gbc);
099: gbc.gridx = 1;
100: centerPanel.add(buttonPanel, gbc);
101: this .add(centerPanel);
102: }
103:
104: /**
105: * @return Returns the cancelButton.
106: */
107: public JButton getCancelButton() {
108: return cancelButton;
109: }
110:
111: /**
112: * @return Returns the delimiterTextField.
113: */
114: public JTextField getDelimiterTextField() {
115: return delimiterTextField;
116: }
117:
118: /**
119: * @return Returns the insertAtCurserRadioButton.
120: */
121: public JRadioButton getInsertAtCurserRadioButton() {
122: return insertAtCurserRadioButton;
123: }
124:
125: /**
126: * @return Returns the insertBeginningRadioButton.
127: */
128: public JRadioButton getInsertBeginningRadioButton() {
129: return insertBeginningRadioButton;
130: }
131:
132: /**
133: * @return Returns the insertEndRadioButton.
134: */
135: public JRadioButton getInsertEndRadioButton() {
136: return insertEndRadioButton;
137: }
138:
139: /**
140: * @return Returns the okButton.
141: */
142: public JButton getOkButton() {
143: return okButton;
144: }
145:
146: /**
147: * @return Returns the replaceCurrentScriptRadioButton.
148: */
149: public JRadioButton getReplaceCurrentScriptRadioButton() {
150: return replaceCurrentScriptRadioButton;
151: }
152:
153: /**
154: * @return Returns the scriptTextArea.
155: */
156: public JTextArea getScriptTextArea() {
157: return scriptTextArea;
158: }
159:
160: /**
161: * @return
162: */
163: public int getInsertMode() {
164: if (insertEndRadioButton.isSelected()) {
165: return Script.NEW_COMMAND_INSERT_END_MODE;
166: } else if (insertBeginningRadioButton.isSelected()) {
167: return Script.NEW_COMMAND_INSERT_BEGINNING_MODE;
168: } else if (insertAtCurserRadioButton.isSelected()) {
169: return Script.NEW_COMMAND_INSERT_AT_CURSER_MODE;
170: } else {
171: return Script.NEW_COMMAND_REPLACE_CURRENT_SCRIPT_MODE;
172: }
173: }
174: }
|