Sync with 5.4.0
[deliverable/titan.core.git] / titan_executor_api / TITAN_Executor_API_Demo / src / org / eclipse / titan / executorapi / demo / ExecuteTestcaseDialog.java
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;
9
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;
17
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;
24
25 import org.eclipse.titan.executorapi.JniExecutor;
26 import org.eclipse.titan.executorapi.exception.JniExecutorIllegalArgumentException;
27 import org.eclipse.titan.executorapi.exception.JniExecutorWrongStateException;
28
29 public class ExecuteTestcaseDialog extends JDialog {
30
31 /** Generated serial version ID to avoid warning */
32 private static final long serialVersionUID = 9090176653704431781L;
33
34 private JTextField mTextFieldModule = new JTextField();
35 private JTextField mTextFieldTestcase = new JTextField();
36 private JButton mButtonExecute = new JButton("Execute");
37
38 public ExecuteTestcaseDialog( final DemoFrame aParent ) {
39 super( aParent, "Execute testcase", true );
40
41 // init ui elements
42 // default values
43 mTextFieldModule.setText(CommonData.MODULE);
44 mTextFieldTestcase.setText(CommonData.TESTCASE);
45
46 mButtonExecute.addActionListener(new ActionListener() {
47 @Override
48 public void actionPerformed(ActionEvent e) {
49 final JniExecutor je = JniExecutor.getInstance();
50 try {
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);
56 }
57 }
58 });
59
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);
65
66 c.gridx = 0;
67 c.gridy = 0;
68 add( new JLabel("Module:"), c);
69 c.gridy++;
70 add( new JLabel("Testcase:"), c);
71
72 c.weightx = 1.0;
73 c.weighty = 0.0;
74 c.gridx = 1;
75 c.gridy = 0;
76 add( mTextFieldModule, c);
77 c.gridy++;
78 add( mTextFieldTestcase, c);
79
80 c.gridx = 0;
81 c.gridy++;
82 c.gridwidth = 2;
83 c.fill = GridBagConstraints.NONE;
84 add(mButtonExecute, c);
85
86 setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
87 setSize( 600, 200 );
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);
91 }
92 }
This page took 0.063194 seconds and 5 git commands to generate.