001: /*
002: * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005:
006: package com.sun.portal.ffj.util;
007:
008: import org.openide.util.NbBundle;
009:
010: public class FileOverwriteDialog extends javax.swing.JDialog {
011:
012: public static final int OVERWRITE = 1;
013: public static final int SKIP = 2;
014: public static final int OVERWRITE_ALL = 3;
015: public static final int SKIP_ALL = 4;
016:
017: /** Creates new form FileOverwriteDialog */
018: public FileOverwriteDialog(java.awt.Frame parent, boolean modal,
019: String dir, String file, int defchoice) {
020: super (parent, modal);
021: initComponents();
022: m_OWChoice = defchoice;
023:
024: setTitle(NbBundle.getMessage(FileOverwriteDialog.class,
025: "FOWDialog.title"));
026: m_PopText.setText(NbBundle.getMessage(
027: FileOverwriteDialog.class, "FOWDialog.pop", dir));
028: m_FileText.setText(NbBundle.getMessage(
029: FileOverwriteDialog.class, "FOWDialog.file", file));
030:
031: getAccessibleContext().setAccessibleDescription(
032: m_FileText.getText());
033: m_OverwriteButton.getAccessibleContext()
034: .setAccessibleDescription(
035: NbBundle.getMessage(FileOverwriteDialog.class,
036: "ACSD_CTL_FOWDialog.Overwrite")); // NOI18N
037: m_OWAllButton.getAccessibleContext().setAccessibleDescription(
038: NbBundle.getMessage(FileOverwriteDialog.class,
039: "ACSD_CTL_FOWDialog.OverwriteAll")); // NOI18N
040: m_SkipButton.getAccessibleContext().setAccessibleDescription(
041: NbBundle.getMessage(FileOverwriteDialog.class,
042: "ACSD_CTL_FOWDialog.Skip")); // NOI18N
043: m_SkipAllButton.getAccessibleContext()
044: .setAccessibleDescription(
045: NbBundle.getMessage(FileOverwriteDialog.class,
046: "ACSD_CTL_FOWDialog.SkipAll")); // NOI18N
047:
048: pack();
049: java.awt.Dimension screenSize = java.awt.Toolkit
050: .getDefaultToolkit().getScreenSize();
051: java.awt.Dimension dialogSize = getSize();
052: setLocation((screenSize.width - dialogSize.width) / 2,
053: (screenSize.height - dialogSize.height) / 2);
054: }
055:
056: public int getOverwriteChoice() {
057: return m_OWChoice;
058: }
059:
060: public void show() {
061: if (m_OWChoice == OVERWRITE) {
062: m_OverwriteButton.requestFocus();
063: } else {
064: m_SkipButton.requestFocus();
065: }
066: super .show();
067: }
068:
069: /** This method is called from within the constructor to
070: * initialize the form.
071: * WARNING: Do NOT modify this code. The content of this method is
072: * always regenerated by the Form Editor.
073: */
074: private void initComponents() {//GEN-BEGIN:initComponents
075: m_BottomPane = new javax.swing.JPanel();
076: m_ButtonPane = new javax.swing.JPanel();
077: m_OverwriteButton = new javax.swing.JButton();
078: m_SkipButton = new javax.swing.JButton();
079: m_OWAllButton = new javax.swing.JButton();
080: m_SkipAllButton = new javax.swing.JButton();
081: m_ContentPane = new javax.swing.JPanel();
082: m_PopText = new javax.swing.JLabel();
083: m_FileText = new javax.swing.JLabel();
084:
085: setTitle("File Exists");
086: setResizable(false);
087: addWindowListener(new java.awt.event.WindowAdapter() {
088: public void windowClosing(java.awt.event.WindowEvent evt) {
089: closeDialog(evt);
090: }
091: });
092:
093: m_BottomPane.setLayout(new java.awt.FlowLayout(
094: java.awt.FlowLayout.LEFT, 10, 5));
095:
096: m_ButtonPane.setLayout(new java.awt.GridLayout(0, 2, 10, 10));
097:
098: m_OverwriteButton.setText("Overwrite");
099: m_OverwriteButton
100: .addActionListener(new java.awt.event.ActionListener() {
101: public void actionPerformed(
102: java.awt.event.ActionEvent evt) {
103: m_OverwriteButtonActionPerformed(evt);
104: }
105: });
106:
107: m_ButtonPane.add(m_OverwriteButton);
108:
109: m_SkipButton.setText("Skip");
110: m_SkipButton
111: .addActionListener(new java.awt.event.ActionListener() {
112: public void actionPerformed(
113: java.awt.event.ActionEvent evt) {
114: m_SkipButtonActionPerformed(evt);
115: }
116: });
117:
118: m_ButtonPane.add(m_SkipButton);
119:
120: m_OWAllButton.setText("Overwrite All");
121: m_OWAllButton
122: .addActionListener(new java.awt.event.ActionListener() {
123: public void actionPerformed(
124: java.awt.event.ActionEvent evt) {
125: m_OWAllButtonActionPerformed(evt);
126: }
127: });
128:
129: m_ButtonPane.add(m_OWAllButton);
130:
131: m_SkipAllButton.setText("Skip All");
132: m_SkipAllButton
133: .addActionListener(new java.awt.event.ActionListener() {
134: public void actionPerformed(
135: java.awt.event.ActionEvent evt) {
136: m_SkipAllButtonActionPerformed(evt);
137: }
138: });
139:
140: m_ButtonPane.add(m_SkipAllButton);
141:
142: m_BottomPane.add(m_ButtonPane);
143:
144: getContentPane().add(m_BottomPane, java.awt.BorderLayout.SOUTH);
145:
146: m_ContentPane.setLayout(new java.awt.GridLayout(0, 1, 0, 10));
147:
148: m_ContentPane.setBorder(new javax.swing.border.EmptyBorder(
149: new java.awt.Insets(10, 10, 10, 5)));
150: m_PopText.setText("Populating directory");
151: m_ContentPane.add(m_PopText);
152:
153: m_FileText.setText("File already exists");
154: m_ContentPane.add(m_FileText);
155:
156: getContentPane().add(m_ContentPane,
157: java.awt.BorderLayout.CENTER);
158:
159: }//GEN-END:initComponents
160:
161: private void m_SkipAllButtonActionPerformed(
162: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_SkipAllButtonActionPerformed
163: m_OWChoice = SKIP_ALL;
164: closeDialog(null);
165: }//GEN-LAST:event_m_SkipAllButtonActionPerformed
166:
167: private void m_OWAllButtonActionPerformed(
168: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_OWAllButtonActionPerformed
169: m_OWChoice = OVERWRITE_ALL;
170: closeDialog(null);
171: }//GEN-LAST:event_m_OWAllButtonActionPerformed
172:
173: private void m_OverwriteButtonActionPerformed(
174: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_OverwriteButtonActionPerformed
175: m_OWChoice = OVERWRITE;
176: closeDialog(null);
177: }//GEN-LAST:event_m_OverwriteButtonActionPerformed
178:
179: private void m_SkipButtonActionPerformed(
180: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_SkipButtonActionPerformed
181: m_OWChoice = SKIP;
182: closeDialog(null);
183: }//GEN-LAST:event_m_SkipButtonActionPerformed
184:
185: /** Closes the dialog */
186: private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
187: setVisible(false);
188: dispose();
189: }//GEN-LAST:event_closeDialog
190:
191: // Variables declaration - do not modify//GEN-BEGIN:variables
192: private javax.swing.JLabel m_FileText;
193: private javax.swing.JLabel m_PopText;
194: private javax.swing.JPanel m_ButtonPane;
195: private javax.swing.JButton m_OverwriteButton;
196: private javax.swing.JPanel m_BottomPane;
197: private javax.swing.JButton m_OWAllButton;
198: private javax.swing.JPanel m_ContentPane;
199: private javax.swing.JButton m_SkipButton;
200: private javax.swing.JButton m_SkipAllButton;
201: // End of variables declaration//GEN-END:variables
202:
203: private int m_OWChoice;
204: }
|