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
.JniExecutorWrongStateException
;
28 public class ExecuteCfgDialog
extends JDialog
{
30 /** Generated serial version ID to avoid warning */
31 private static final long serialVersionUID
= -2926485859174706529L;
33 private JTextField mTextFieldIndex
= new JTextField();
34 private JButton mButtonExecute
= new JButton("Execute");
36 public ExecuteCfgDialog( final DemoFrame aParent
) {
37 super( aParent
, "Execute config file", true );
41 mTextFieldIndex
.setText("0");
43 mButtonExecute
.addActionListener(new ActionListener() {
45 public void actionPerformed(ActionEvent e
) {
46 final JniExecutor je
= JniExecutor
.getInstance();
48 je
.executeCfg(Integer
.parseInt(mTextFieldIndex
.getText()));
49 ExecuteCfgDialog
.this.setVisible(false);
50 ExecuteCfgDialog
.this.dispose();
51 } catch (Exception e1
) {
52 JOptionPane
.showMessageDialog(ExecuteCfgDialog
.this, e1
.toString(), "Error", JOptionPane
.ERROR_MESSAGE
);
57 // add ui elements to layout
58 setLayout( new GridBagLayout() );
59 GridBagConstraints c
= new GridBagConstraints();
60 c
.fill
= GridBagConstraints
.BOTH
;
61 c
.insets
= new Insets(10, 10, 10, 10);
65 add( new JLabel("Number of testcases:"), c
);
67 add( new JLabel("Testcase index:"), c
);
75 numTestcases
= JniExecutor
.getInstance().getExecuteCfgLen();
76 } catch (JniExecutorWrongStateException e1
) {
77 JOptionPane
.showMessageDialog(ExecuteCfgDialog
.this, e1
.toString(), "Error", JOptionPane
.ERROR_MESSAGE
);
79 add( new JLabel( "" + numTestcases
), c
);
81 add( mTextFieldIndex
, c
);
86 c
.fill
= GridBagConstraints
.NONE
;
87 add(mButtonExecute
, c
);
89 setDefaultCloseOperation( JFrame
.DISPOSE_ON_CLOSE
);
91 // place to the middle of the screen
92 Dimension dim
= Toolkit
.getDefaultToolkit().getScreenSize();
93 setLocation(dim
.width
/2-this.getSize().width
/2, dim
.height
/2-this.getSize().height
/2);