1 /******************************************************************************
2 * Copyright (c) 2000-2015 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 ******************************************************************************/
8 package org
.eclipse
.titan
.executorapi
.demo
;
10 import java
.awt
.Dimension
;
11 import java
.awt
.GridBagConstraints
;
12 import java
.awt
.GridBagLayout
;
13 import java
.awt
.Insets
;
14 import java
.awt
.Toolkit
;
15 import java
.awt
.event
.ActionEvent
;
16 import java
.awt
.event
.ActionListener
;
18 import javax
.swing
.JButton
;
19 import javax
.swing
.JDialog
;
20 import javax
.swing
.JFrame
;
21 import javax
.swing
.JLabel
;
22 import javax
.swing
.JOptionPane
;
23 import javax
.swing
.JTextField
;
25 import org
.eclipse
.titan
.executorapi
.JniExecutor
;
26 import org
.eclipse
.titan
.executorapi
.exception
.JniExecutorIllegalArgumentException
;
27 import org
.eclipse
.titan
.executorapi
.exception
.JniExecutorWrongStateException
;
29 public class ExecuteTestcaseDialog
extends JDialog
{
31 /** Generated serial version ID to avoid warning */
32 private static final long serialVersionUID
= 9090176653704431781L;
34 private JTextField mTextFieldModule
= new JTextField();
35 private JTextField mTextFieldTestcase
= new JTextField();
36 private JButton mButtonExecute
= new JButton("Execute");
38 public ExecuteTestcaseDialog( final DemoFrame aParent
) {
39 super( aParent
, "Execute testcase", true );
43 mTextFieldModule
.setText(CommonData
.MODULE
);
44 mTextFieldTestcase
.setText(CommonData
.TESTCASE
);
46 mButtonExecute
.addActionListener(new ActionListener() {
48 public void actionPerformed(ActionEvent e
) {
49 final JniExecutor je
= JniExecutor
.getInstance();
51 je
.executeTestcase(mTextFieldModule
.getText(), mTextFieldTestcase
.getText());
52 ExecuteTestcaseDialog
.this.setVisible(false);
53 ExecuteTestcaseDialog
.this.dispose();
54 } catch (JniExecutorIllegalArgumentException
| JniExecutorWrongStateException e1
) {
55 JOptionPane
.showMessageDialog(ExecuteTestcaseDialog
.this, e1
.toString(), "Error", JOptionPane
.ERROR_MESSAGE
);
60 // add ui elements to layout
61 setLayout( new GridBagLayout() );
62 GridBagConstraints c
= new GridBagConstraints();
63 c
.fill
= GridBagConstraints
.BOTH
;
64 c
.insets
= new Insets(10, 10, 10, 10);
68 add( new JLabel("Module:"), c
);
70 add( new JLabel("Testcase:"), c
);
76 add( mTextFieldModule
, c
);
78 add( mTextFieldTestcase
, c
);
83 c
.fill
= GridBagConstraints
.NONE
;
84 add(mButtonExecute
, c
);
86 setDefaultCloseOperation( JFrame
.DISPOSE_ON_CLOSE
);
88 // place to the middle of the screen
89 Dimension dim
= Toolkit
.getDefaultToolkit().getScreenSize();
90 setLocation(dim
.width
/2-this.getSize().width
/2, dim
.height
/2-this.getSize().height
/2);