From: Holger Z. <hz...@us...> - 2004-09-26 12:07:46
|
Update of /cvsroot/jake2/jake2/src/jake2/qcommon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29005/src/jake2/qcommon Modified Files: Q2DataDialog.java Log Message: reorganized install dialog Index: Q2DataDialog.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/Q2DataDialog.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Q2DataDialog.java 25 Sep 2004 15:17:45 -0000 1.8 --- Q2DataDialog.java 26 Sep 2004 12:07:32 -0000 1.9 *************** *** 26,30 **** public class Q2DataDialog extends javax.swing.JDialog { - /** Creates new form Q2DataDialog */ public Q2DataDialog() { super(); --- 26,29 ---- *************** *** 39,47 **** } - /** This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. - */ private void initComponents() {//GEN-BEGIN:initComponents java.awt.GridBagConstraints gridBagConstraints; --- 38,41 ---- *************** *** 52,56 **** jTextField1 = new javax.swing.JTextField(); changeButton = new javax.swing.JButton(); ! installButton = new javax.swing.JButton(); exitButton = new javax.swing.JButton(); okButton = new javax.swing.JButton(); --- 46,50 ---- jTextField1 = new javax.swing.JTextField(); changeButton = new javax.swing.JButton(); ! cancelButton = new javax.swing.JButton(); exitButton = new javax.swing.JButton(); okButton = new javax.swing.JButton(); *************** *** 67,85 **** choosePanel.setLayout(new java.awt.GridBagLayout()); - choosePanel.setMaximumSize(new java.awt.Dimension(400, 100)); choosePanel.setMinimumSize(new java.awt.Dimension(400, 100)); choosePanel.setPreferredSize(new java.awt.Dimension(400, 100)); ! jTextField1.setPreferredSize(null); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; ! gridBagConstraints.gridwidth = 2; ! gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! gridBagConstraints.weightx = 1.0; choosePanel.add(jTextField1, gridBagConstraints); ! changeButton.setText("change"); changeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { --- 61,78 ---- choosePanel.setLayout(new java.awt.GridBagLayout()); choosePanel.setMaximumSize(new java.awt.Dimension(400, 100)); choosePanel.setMinimumSize(new java.awt.Dimension(400, 100)); choosePanel.setPreferredSize(new java.awt.Dimension(400, 100)); ! gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; ! gridBagConstraints.gridwidth = 3; ! gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; ! gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 2); ! gridBagConstraints.weightx = 1; choosePanel.add(jTextField1, gridBagConstraints); ! changeButton.setText("..."); changeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { *************** *** 87,111 **** } }); ! ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; choosePanel.add(changeButton, gridBagConstraints); ! installButton.setText("Install"); ! installButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ! installButtonActionPerformed(evt); } }); - - gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; ! choosePanel.add(installButton, gridBagConstraints); exitButton.setText("Exit"); --- 80,105 ---- } }); ! gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 0; ! gridBagConstraints.gridwidth = 1; ! gridBagConstraints.weightx = 0; ! gridBagConstraints.fill = java.awt.GridBagConstraints.NONE; ! gridBagConstraints.insets = new java.awt.Insets(5, 2, 5, 5); gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; choosePanel.add(changeButton, gridBagConstraints); ! cancelButton.setText("Cancel"); ! cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ! cancelButtonActionPerformed(evt); } }); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; ! gridBagConstraints.gridwidth = 4; ! gridBagConstraints.weighty = 0; ! gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); ! gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; ! choosePanel.add(cancelButton, gridBagConstraints); exitButton.setText("Exit"); *************** *** 115,123 **** } }); ! ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); choosePanel.add(exitButton, gridBagConstraints); --- 109,116 ---- } }); ! gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; ! gridBagConstraints.gridwidth = 1; ! gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; choosePanel.add(exitButton, gridBagConstraints); *************** *** 128,141 **** } }); - - gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 1; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; ! choosePanel.add(okButton, gridBagConstraints); ! ! //getContentPane().add(choosePanel, java.awt.BorderLayout.SOUTH); Jake2Canvas c = new Jake2Canvas(); getContentPane().add(c, BorderLayout.CENTER); --- 121,131 ---- } }); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 1; ! gridBagConstraints.gridwidth = 2; ! gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST; ! choosePanel.add(okButton, gridBagConstraints); + Jake2Canvas c = new Jake2Canvas(); getContentPane().add(c, BorderLayout.CENTER); *************** *** 157,175 **** progressPanel = new ProgressPanel(this); installPanel = new InstallPanel(this); pack(); ! }//GEN-END:initComponents ! ! private void installButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_installButtonActionPerformed ! showInstallPanel(); ! }//GEN-LAST:event_installButtonActionPerformed ! ! private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitButtonActionPerformed System.exit(1); dispose(); ! }//GEN-LAST:event_exitButtonActionPerformed ! ! private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed if (dir != null) { --- 147,165 ---- progressPanel = new ProgressPanel(this); installPanel = new InstallPanel(this); + notFoundPanel = new NotFoundPanel(this); pack(); ! } ! private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) { ! showNotFoundPanel(); ! } ! ! private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) { System.exit(1); dispose(); ! } ! ! private void okButtonActionPerformed(java.awt.event.ActionEvent evt) { if (dir != null) { *************** *** 181,185 **** notifyAll(); } ! }//GEN-LAST:event_okButtonActionPerformed private void changeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeButtonActionPerformed --- 171,175 ---- notifyAll(); } ! } private void changeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeButtonActionPerformed *************** *** 208,212 **** private javax.swing.JButton changeButton; private javax.swing.JButton exitButton; ! private javax.swing.JButton installButton; private Jake2Canvas canvas; private javax.swing.JPanel choosePanel; --- 198,202 ---- private javax.swing.JButton changeButton; private javax.swing.JButton exitButton; ! private javax.swing.JButton cancelButton; private Jake2Canvas canvas; private javax.swing.JPanel choosePanel; *************** *** 214,217 **** --- 204,208 ---- private ProgressPanel progressPanel; private InstallPanel installPanel; + private NotFoundPanel notFoundPanel; private JLabel status; private javax.swing.JTextField jTextField1; *************** *** 225,228 **** --- 216,220 ---- getContentPane().remove(progressPanel); getContentPane().remove(installPanel); + getContentPane().remove(notFoundPanel); getContentPane().add(choosePanel, BorderLayout.SOUTH); validate(); *************** *** 249,252 **** --- 241,245 ---- getContentPane().remove(choosePanel); getContentPane().remove(statusPanel); + getContentPane().remove(notFoundPanel); getContentPane().add(installPanel, BorderLayout.SOUTH); validate(); *************** *** 254,257 **** --- 247,258 ---- } + void showNotFoundPanel() { + getContentPane().remove(choosePanel); + getContentPane().remove(statusPanel); + getContentPane().add(notFoundPanel, BorderLayout.SOUTH); + validate(); + repaint(); + } + void setStatus(String text) { status.setText(text); *************** *** 260,264 **** void testQ2Data() { while (FS.LoadFile("pics/colormap.pcx") == null) { ! showChooseDialog(); try { --- 261,265 ---- void testQ2Data() { while (FS.LoadFile("pics/colormap.pcx") == null) { ! showNotFoundPanel(); try { *************** *** 292,299 **** } static class InstallPanel extends JPanel { private static final String[][] mirrors = { ! {"LOC gate", "ftp://gate/q2-314-demo-x86.exe"}, // local test @home {"DE ftp.fu-berlin.de", "ftp://ftp.fu-berlin.de/pc/msdos/games/idgames/idstuff/quake2/q2-314-demo-x86.exe"}, {"UK ftp.demon.co.uk", "ftp://ftp.demon.co.uk/pub/mirrors/idsoftware/quake2/q2-314-demo-x86.exe"}, --- 293,400 ---- } + static class NotFoundPanel extends JPanel { + + private Q2DataDialog parent; + private ButtonGroup selection; + private JRadioButton dir; + private JRadioButton install; + private JButton exit; + private JButton ok; + private JLabel message; + + NotFoundPanel(Q2DataDialog d) { + parent = d; + initComponents(); + } + + private void initComponents() { + GridBagConstraints constraints = new GridBagConstraints(); + setLayout(new GridBagLayout()); + Dimension d = new Dimension(400, 100); + setMinimumSize(d); + setMaximumSize(d); + setPreferredSize(d); + + message = new JLabel("Quake2 level data not found"); + message.setForeground(Color.RED); + constraints.gridx = 0; + constraints.gridy = 0; + constraints.gridwidth = 2; + constraints.insets = new Insets(5, 5, 5, 5); + constraints.anchor = GridBagConstraints.CENTER; + add(message, constraints); + + constraints.gridx = 1; + constraints.gridy = 1; + constraints.gridwidth = 2; + constraints.weightx = 1; + constraints.fill = GridBagConstraints.HORIZONTAL; + constraints.insets = new Insets(0, 2, 0, 5); + constraints.anchor = GridBagConstraints.WEST; + add(new JLabel("select baseq2 directory from existing Quake2 installation"), constraints); + + constraints.gridx = 1; + constraints.gridy = 2; + add(new JLabel("download and install Quake2 demo data (38MB)"), constraints); + + selection = new ButtonGroup(); + dir = new JRadioButton(); + install = new JRadioButton(); + selection.add(dir); + selection.add(install); + + constraints.gridx = 0; + constraints.gridy = 1; + constraints.gridwidth = 1; + constraints.weightx = 0; + constraints.insets = new Insets(0, 5, 0, 2); + constraints.fill = GridBagConstraints.NONE; + constraints.anchor = GridBagConstraints.EAST; + dir.setSelected(true); + add(dir, constraints); + + constraints.gridx = 0; + constraints.gridy = 2; + add(install, constraints); + + constraints.gridx = 0; + constraints.gridy = 3; + constraints.gridwidth = 2; + constraints.weighty = 1; + constraints.insets = new Insets(5, 5, 5, 5); + constraints.fill = GridBagConstraints.NONE; + constraints.anchor = GridBagConstraints.SOUTHWEST; + exit = new JButton("Exit"); + exit.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + System.exit(0); + }}); + add(exit, constraints); + + constraints.gridx = 2; + constraints.gridy = 3; + constraints.gridwidth = 1; + constraints.anchor = GridBagConstraints.SOUTHEAST; + ok = new JButton("OK"); + ok.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + ok(); + }}); + add(ok, constraints); + } + + private void ok() { + if (dir.isSelected()) { + parent.showChooseDialog(); + } else { + parent.showInstallPanel(); + } + } + } + static class InstallPanel extends JPanel { private static final String[][] mirrors = { ! //{"LOC gate", "ftp://gate/q2-314-demo-x86.exe"}, // local test @home {"DE ftp.fu-berlin.de", "ftp://ftp.fu-berlin.de/pc/msdos/games/idgames/idstuff/quake2/q2-314-demo-x86.exe"}, {"UK ftp.demon.co.uk", "ftp://ftp.demon.co.uk/pub/mirrors/idsoftware/quake2/q2-314-demo-x86.exe"}, *************** *** 397,401 **** --- 498,506 ---- } + private void readMirrors() { + } + private void initMirrors() { + readMirrors(); for (int i = 0; i < mirrors.length; i++) { mirrorBox.addItem(mirrors[i][0]); *************** *** 429,434 **** try { dir = chooser.getSelectedFile().getCanonicalPath(); ! } catch (IOException e) {} ! destDir.setText(dir); } } --- 534,539 ---- try { dir = chooser.getSelectedFile().getCanonicalPath(); ! } catch (Exception e) {} ! if (dir != null) destDir.setText(dir); } } |