Last sync 2016.04.01
[deliverable/titan.core.git] / titan_executor_api / TITAN_Executor_API_Demo / src / org / eclipse / titan / executorapi / demo / ExecuteTestcaseDialog.java
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
7 *
8 * Contributors:
9 * Balasko, Jeno
10 * Lovassy, Arpad
11 *
12 ******************************************************************************/
13 package org.eclipse.titan.executorapi.demo;
14
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;
22
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;
29
30 import org.eclipse.titan.executorapi.JniExecutor;
31 import org.eclipse.titan.executorapi.exception.JniExecutorIllegalArgumentException;
32 import org.eclipse.titan.executorapi.exception.JniExecutorWrongStateException;
33
34 public class ExecuteTestcaseDialog extends JDialog {
35
36 /** Generated serial version ID to avoid warning */
37 private static final long serialVersionUID = 9090176653704431781L;
38
39 private JTextField mTextFieldModule = new JTextField();
40 private JTextField mTextFieldTestcase = new JTextField();
41 private JButton mButtonExecute = new JButton("Execute");
42
43 public ExecuteTestcaseDialog( final DemoFrame aParent ) {
44 super( aParent, "Execute testcase", true );
45
46 // init ui elements
47 // default values
48 mTextFieldModule.setText(CommonData.MODULE);
49 mTextFieldTestcase.setText(CommonData.TESTCASE);
50
51 mButtonExecute.addActionListener(new ActionListener() {
52 @Override
53 public void actionPerformed(ActionEvent e) {
54 final JniExecutor je = JniExecutor.getInstance();
55 try {
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);
61 }
62 }
63 });
64
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);
70
71 c.gridx = 0;
72 c.gridy = 0;
73 add( new JLabel("Module:"), c);
74 c.gridy++;
75 add( new JLabel("Testcase:"), c);
76
77 c.weightx = 1.0;
78 c.weighty = 0.0;
79 c.gridx = 1;
80 c.gridy = 0;
81 add( mTextFieldModule, c);
82 c.gridy++;
83 add( mTextFieldTestcase, c);
84
85 c.gridx = 0;
86 c.gridy++;
87 c.gridwidth = 2;
88 c.fill = GridBagConstraints.NONE;
89 add(mButtonExecute, c);
90
91 setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
92 setSize( 600, 200 );
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);
96 }
97 }
This page took 0.032088 seconds and 5 git commands to generate.