1   /**
2    * QJ-Pro
3    * Copyright (c) 2004, http://qjpro.sourceforge.net
4    *
5    * This program is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU General Public License as published by the
7    * Free Software Foundation; either version 2 of the License, or
8    * (at your option) any later version.
9    *
10   * This program is distributed in the hope that it will be useful, but WITHOUT
11   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12   * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13   * details.
14   *
15   * You should have received a copy of the GNU General Public License along with
16   * this program; if not, write to the Free Software Foundation, Inc.,
17   * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18   */
19  package com.qasystems.qstudio.java.gui.dialog;
20  
21  import com.qasystems.international.MessageResource;
22  import com.qasystems.qstudio.java.classloader.Trier;
23  import com.qasystems.swing.ButtonDialog;
24  
25  import java.awt.Dialog;
26  import java.awt.Frame;
27  
28  import javax.swing.JComboBox;
29  
30  /**
31   * This class implements a modal dialog for setting the debug level.
32   */
33  public class DebugLevelDialog extends ButtonDialog {
34    public static final int OK = 0;
35    public static final int CANCEL = 1;
36    private JComboBox BOX = new JComboBox();
37  
38    /**
39     * Default constructor
40     */
41    public DebugLevelDialog(Frame parent) {
42      super(parent);
43      init();
44    }
45  
46    /**
47     * Default constructor
48     */
49    public DebugLevelDialog(Dialog parent) {
50      super(parent);
51      init();
52    }
53  
54    private void init() {
55      final MessageResource resources = MessageResource.getClientInstance();
56      setTitle(resources.getString("WINDOWTITLE_025"));
57      setButtons(
58        new String[] {
59          resources.getString("BUTTON_005"), resources.getString("BUTTON_001")
60        }
61      );
62      BOX.addItem(resources.getString("COMBOBOX_004"));
63      BOX.addItem(resources.getString("COMBOBOX_005"));
64      BOX.addItem(resources.getString("COMBOBOX_006"));
65      BOX.addItem(resources.getString("COMBOBOX_007"));
66      BOX.setSelectedIndex(Trier.getDefaultDebugLevel());
67      setContent(BOX);
68      pack();
69    }
70  
71    protected void onActionPerformed(int action) {
72      if (action == CANCEL) {
73        dispose();
74      } else if (action == OK) {
75        Trier.setDefaultDebugLevel(BOX.getSelectedIndex());
76        dispose();
77      } else {
78        // action == UNINITIALIZED_VALUE
79      }
80    }
81  }
82