001: /*
002: * Copyright (C) 2003 Robert MacGrogan
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: *
018: *
019: * $Archive: SourceJammer$
020: * $FileName: AddCommentDialog.java$
021: * $FileID: 4759$
022: *
023: * Last change:
024: * $AuthorName: Rob MacGrogan$
025: * $Date: 8/12/03 1:48 AM$
026: * $Comment: Moving along with branch on checkin.$
027: */
028: package org.sourcejammer.client.gui.dialog;
029:
030: import java.awt.BorderLayout;
031: import java.awt.Component;
032: import java.awt.Dialog;
033: import java.awt.Frame;
034: import java.awt.event.ActionEvent;
035: import java.awt.event.ActionListener;
036:
037: import javax.swing.JButton;
038: import javax.swing.JComboBox;
039: import javax.swing.JLabel;
040: import javax.swing.JList;
041: import javax.swing.JPanel;
042: import javax.swing.JScrollPane;
043: import javax.swing.JSplitPane;
044: import javax.swing.JTextArea;
045:
046: import org.sourcejammer.client.DisplayTextLibrary;
047:
048: import com.pallas.swing.pcombobox.PComboBox;
049:
050: /**
051: * Title: $FileName: AddCommentDialog.java$<br>
052: * @author $AuthorName: Rob MacGrogan$<br>
053: * @version $VerNum: 2$<br><br>
054: *
055: * $Description: Super class dialog for Branch Files Dialog and
056: * Check In Dialog.$<br>
057: * $KeyWordsOff: $<br><br>
058: */
059: public abstract class AddCommentDialog extends SJDialog implements
060: ClickValues {
061:
062: protected JTextArea mjComment = null;
063: protected String comment = null;
064: protected int buttonClicked = DIALOG_CLOSED;
065: protected AddCommentDialog dialog = null;
066: protected PComboBox identifierCombo = null;
067: protected JComboBox mjAfterCheckInCombo = null;
068:
069: public static final int CHECK_IN_MODE = 1;
070: public static final int BRANCH_MODE = 2;
071:
072: public AddCommentDialog(Frame owner, String[] fileNames,
073: String title) {
074: super (owner);
075: }
076:
077: public AddCommentDialog(Dialog owner, String[] fileNames,
078: String title) {
079: super (owner);
080: }
081:
082: public int getButtonClicked() {
083: return buttonClicked;
084: }
085:
086: protected void initializeDialog(String[] fileNames, String title) {
087: dialog = this ;
088: setTitle(title);
089: mjComment = new JTextArea();
090: mjComment.setLineWrap(true);
091: mjComment.setWrapStyleWord(true);
092: mjComment.setRows(10);
093: JScrollPane scrollComment = new JScrollPane(mjComment);
094:
095: int iNumFiles = fileNames.length;
096: JPanel fileListPane = new JPanel();
097: fileListPane.setLayout(new java.awt.GridLayout(iNumFiles, 1));
098:
099: JList fileList = new JList(fileNames);
100: fileList.setEnabled(false);
101: fileList.setForeground(java.awt.Color.black);
102: JScrollPane scrollFiles = new JScrollPane(fileList);
103:
104: JPanel commentPanel = new JPanel();
105: commentPanel.setLayout(new BorderLayout());
106: commentPanel.add(scrollComment, BorderLayout.CENTER);
107: commentPanel.add(new JLabel(DisplayTextLibrary
108: .displayText(DisplayTextLibrary.LBL_ENTER_COMMENT)),
109: java.awt.BorderLayout.NORTH);
110:
111: JPanel fileListPanel = new JPanel();
112: fileListPanel.setLayout(new BorderLayout());
113: fileListPanel.add(scrollFiles, BorderLayout.CENTER);
114: fileListPanel.add(new JLabel(DisplayTextLibrary
115: .displayText(DisplayTextLibrary.LBL_CHECKING_IN)),
116: java.awt.BorderLayout.NORTH);
117:
118: JSplitPane splitPane = new JSplitPane(
119: JSplitPane.HORIZONTAL_SPLIT, true, fileListPanel,
120: commentPanel);
121:
122: JButton jbOKButton = buildOKButton();
123: jbOKButton.setDefaultCapable(true);
124: getRootPane().setDefaultButton(jbOKButton);
125:
126: JButton jbCancelButton = new JButton(DisplayTextLibrary
127: .displayText(DisplayTextLibrary.BTN_CANCEL));
128: jbCancelButton.addActionListener(new ActionListener() {
129: public void actionPerformed(ActionEvent ev) {
130: buttonClicked = CANCEL_BUTTON_CLICKED;
131: dialog.dispose();
132: }
133: }//end anon class
134: );
135:
136: JPanel buttonPanel = new JPanel();
137: buttonPanel.add(jbOKButton);
138: buttonPanel.add(jbCancelButton);
139:
140: JPanel centerPanel = new JPanel(new BorderLayout());
141: centerPanel.add(splitPane, BorderLayout.CENTER);
142: centerPanel.add(buildBottomPanel(), BorderLayout.SOUTH);
143:
144: getContentPane().add(buttonPanel, BorderLayout.SOUTH);
145: getContentPane().add(centerPanel, BorderLayout.CENTER);
146: }
147:
148: public abstract JButton buildOKButton();
149:
150: public abstract JPanel buildBottomPanel();
151:
152: public void showDialog(Component owner) {
153: dialog.setModal(true);
154: dialog.pack();
155: dialog.setLocationRelativeTo(owner);
156: dialog.show();
157: }
158:
159: /**
160: * Returns the comment.
161: * @return String
162: */
163: public String getComment() {
164: return comment;
165: }
166:
167: }
|