001: package org.objectweb.salome_tmf.ihm.main;
002:
003: import java.awt.BorderLayout;
004: import java.awt.Dimension;
005: import java.awt.FlowLayout;
006: import java.awt.Frame;
007: import java.awt.Rectangle;
008: import java.awt.event.ActionEvent;
009: import java.awt.event.ActionListener;
010:
011: import javax.swing.BoxLayout;
012: import javax.swing.JButton;
013: import javax.swing.JCheckBox;
014: import javax.swing.JDialog;
015: import javax.swing.JPanel;
016:
017: import org.objectweb.salome_tmf.ihm.languages.Language;
018:
019: public class OptionExecDialog extends JDialog implements ActionListener {
020:
021: JButton bOK;
022: JButton bCancel;
023: JCheckBox checkWithOutResTest;
024: JCheckBox checkAssignedTest;
025: JCheckBox checkWithOutSucces;
026: boolean cancelPerformed = false;
027:
028: OptionExecDialog(Frame parent, boolean withOutSucces,
029: boolean withOutRes, boolean withAssigned) {
030: super (parent, true);
031: initComponent(withOutSucces, withOutRes, withAssigned);
032: centerParent();
033: }
034:
035: void initComponent(boolean withOutSucces, boolean checkWithOutRes,
036: boolean checkAssigned) {
037: bOK = new JButton(Language.getInstance().getText("Lancer"));
038: bCancel = new JButton(Language.getInstance().getText("Annuler"));
039: checkWithOutResTest = new JCheckBox(Language.getInstance()
040: .getText("Executer_tests_sans_resultat"));
041: checkAssignedTest = new JCheckBox(Language.getInstance()
042: .getText("Executer_tests_assigne"));
043: checkWithOutSucces = new JCheckBox(Language.getInstance()
044: .getText("Executer_tests_en_echec"));
045:
046: bOK.addActionListener(this );
047: bCancel.addActionListener(this );
048: checkWithOutResTest.addActionListener(this );
049: checkAssignedTest.addActionListener(this );
050:
051: JPanel checkBoxPanel = new JPanel();
052: checkBoxPanel.setLayout(new BoxLayout(checkBoxPanel,
053: BoxLayout.Y_AXIS));
054: if (checkWithOutRes) {
055: checkBoxPanel.add(checkWithOutResTest);
056: }
057: if (withOutSucces) {
058: checkBoxPanel.add(checkWithOutSucces);
059: }
060: if (checkAssigned) {
061: checkBoxPanel.add(checkAssignedTest);
062: }
063:
064: JPanel buttonPanel = new JPanel(new FlowLayout(
065: FlowLayout.CENTER));
066: buttonPanel.add(bCancel);
067: buttonPanel.add(bOK);
068:
069: getContentPane().setLayout(new BorderLayout());
070: getContentPane().add(checkBoxPanel, BorderLayout.CENTER);
071: getContentPane().add(buttonPanel, BorderLayout.SOUTH);
072: }
073:
074: void centerParent() {
075: Dimension dim = getToolkit().getScreenSize();
076: this .pack();
077: Rectangle abounds = getBounds();
078: setLocation((dim.width - abounds.width) / 2,
079: (dim.height - abounds.height) / 2);
080: this .setVisible(true);
081: requestFocus();
082: }
083:
084: /*********************** Action Listener ***************************/
085:
086: public void actionPerformed(ActionEvent e) {
087: if (e.getSource().equals(bOK)) {
088: bOKPerformed();
089: } else if (e.getSource().equals(bCancel)) {
090: bCancelPerformed();
091: } else if (e.getSource().equals(checkWithOutResTest)) {
092: checkWithOutResTestPerformed();
093: } else if (e.getSource().equals(checkAssignedTest)) {
094: checkAssignedTestPerformed();
095: }
096: }
097:
098: boolean isOkSelected() {
099: return !cancelPerformed;
100: }
101:
102: boolean isAssignedTestSelected() {
103: return checkAssignedTest.isSelected();
104: }
105:
106: boolean isTestWihtoutResSelected() {
107: return checkWithOutResTest.isSelected();
108: }
109:
110: boolean ischeckWithOutSuccesSelected() {
111: return checkWithOutSucces.isSelected();
112: }
113:
114: void bOKPerformed() {
115: dispose();
116: }
117:
118: void bCancelPerformed() {
119: cancelPerformed = true;
120: dispose();
121: }
122:
123: void checkWithOutResTestPerformed() {
124:
125: }
126:
127: void checkAssignedTestPerformed() {
128:
129: }
130: }
|