1 /******************************************************************************
2 * Copyright (c) 2000-2016 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
12 ******************************************************************************/
13 package org
.eclipse
.titan
.executorapi
.demo
;
15 import java
.awt
.Dimension
;
16 import java
.awt
.GridBagConstraints
;
17 import java
.awt
.GridBagLayout
;
18 import java
.awt
.Insets
;
19 import java
.awt
.Toolkit
;
20 import java
.awt
.event
.ActionEvent
;
21 import java
.awt
.event
.ActionListener
;
23 import javax
.swing
.JButton
;
24 import javax
.swing
.JDialog
;
25 import javax
.swing
.JFrame
;
26 import javax
.swing
.JLabel
;
27 import javax
.swing
.JOptionPane
;
28 import javax
.swing
.JTextField
;
30 import org
.eclipse
.titan
.executorapi
.JniExecutor
;
31 import org
.eclipse
.titan
.executorapi
.exception
.JniExecutorIllegalArgumentException
;
32 import org
.eclipse
.titan
.executorapi
.exception
.JniExecutorWrongStateException
;
34 public class ExecuteTestcaseDialog
extends JDialog
{
36 /** Generated serial version ID to avoid warning */
37 private static final long serialVersionUID
= 9090176653704431781L;
39 private JTextField mTextFieldModule
= new JTextField();
40 private JTextField mTextFieldTestcase
= new JTextField();
41 private JButton mButtonExecute
= new JButton("Execute");
43 public ExecuteTestcaseDialog( final DemoFrame aParent
) {
44 super( aParent
, "Execute testcase", true );
48 mTextFieldModule
.setText(CommonData
.MODULE
);
49 mTextFieldTestcase
.setText(CommonData
.TESTCASE
);
51 mButtonExecute
.addActionListener(new ActionListener() {
53 public void actionPerformed(ActionEvent e
) {
54 final JniExecutor je
= JniExecutor
.getInstance();
56 je
.executeTestcase(mTextFieldModule
.getText(), mTextFieldTestcase
.getText());
57 ExecuteTestcaseDialog
.this.setVisible(false);
58 ExecuteTestcaseDialog
.this.dispose();
59 } catch (JniExecutorIllegalArgumentException
| JniExecutorWrongStateException e1
) {
60 JOptionPane
.showMessageDialog(ExecuteTestcaseDialog
.this, e1
.toString(), "Error", JOptionPane
.ERROR_MESSAGE
);
65 // add ui elements to layout
66 setLayout( new GridBagLayout() );
67 GridBagConstraints c
= new GridBagConstraints();
68 c
.fill
= GridBagConstraints
.BOTH
;
69 c
.insets
= new Insets(10, 10, 10, 10);
73 add( new JLabel("Module:"), c
);
75 add( new JLabel("Testcase:"), c
);
81 add( mTextFieldModule
, c
);
83 add( mTextFieldTestcase
, c
);
88 c
.fill
= GridBagConstraints
.NONE
;
89 add(mButtonExecute
, c
);
91 setDefaultCloseOperation( JFrame
.DISPOSE_ON_CLOSE
);
93 // place to the middle of the screen
94 Dimension dim
= Toolkit
.getDefaultToolkit().getScreenSize();
95 setLocation(dim
.width
/2-this.getSize().width
/2, dim
.height
/2-this.getSize().height
/2);