View Javadoc

1   /*
2    *  nextobjects Copyright (C) 2001-2005 Emmanuel Florent
3    *  This program is free software; you can redistribute it and/or modify
4    *  it under the terms of the GNU General Public License as published by the
5    *  Free Software Foundation; either version 2 of the License, or (at your
6    *  option) any later version.
7    *  This program is distributed in the hope that it will
8    *  be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9    *  of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10   *  PURPOSE. See the GNU General Public License for more details.
11   *  You should have received a copy of the GNU General Public License along
12   *  with this program; if not, write to the Free Software Foundation, Inc., 59
13   *  Temple Place - Suite 330, Boston, MA 02111-1307, USA.
14   */
15  package org.devaki.nextobjects.ui.main;
16  
17  import java.awt.Dimension;
18  import java.awt.GridBagConstraints;
19  import java.awt.GridBagLayout;
20  import java.awt.Insets;
21  import javax.swing.JDialog;
22  import javax.swing.JButton;
23  import javax.swing.JLabel;
24  import java.awt.event.ActionEvent;
25  import java.awt.event.ActionListener;
26  import org.devaki.nextobjects.NextObjects;
27  import org.devaki.nextobjects.ui.components.CustomTextField;
28  import org.devaki.nextobjects.util.TorqueWrapper;
29  import org.devaki.nextobjects.util.ModelMan;
30  import org.devaki.nextobjects.workspace.models.PhysicalModel;
31  /***
32   *  This class is responsible for setting up the torque template at first use of
33   *  this project It will create the projects repository and unzip templates from
34   *  the torque-gen archive
35   *
36   * @author     eflorent
37   * @created    December 23, 2003
38   */
39  public class TaskChooser extends JDialog
40  {
41  
42      /***  The setup template progress bar */
43      private CustomTextField jTxtTask =
44          new CustomTextField("", "Choose a Torque-gen task to run", true);
45  
46      /***  Main label */
47      private JLabel jLabel = new JLabel("Choose a task to run");
48      /***  Main label */
49      private JButton jButton = new JButton("Run ...");
50  
51  
52      /***  Create a new 'InitHome' object */
53      public TaskChooser()
54      {
55          super(NextObjects.getReference(), "Custom task");
56          // Define the size of the window
57          this.setSize(new Dimension(350, 70));
58          // Center the window
59          this.setLocationRelativeTo(null);
60          // Specify that the window is modal
61          this.setModal(true);
62          // Specify that the window is not resizable
63          this.setResizable(false);
64          // Define what to do when closing this window using
65          //this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
66          // PANELS
67          // Define a grid bag layout for the main panel
68          this.getContentPane().setLayout(new GridBagLayout());
69  
70          // PROGRESS BARS
71          // Define the progress bar to paint a
72          // String representing the progression
73          //this.jProgressBar.setStringPainted(true);
74  
75          // Content Panel
76          this.getContentPane().add(
77              this.jLabel,
78              new GridBagConstraints(
79              0,
80              0,
81              1,
82              1,
83              0.0,
84              0.0,
85              GridBagConstraints.CENTER,
86              GridBagConstraints.NONE,
87              new Insets(3, 3, 0, 3),
88              0,
89              0));
90          this.getContentPane().add(
91              this.jTxtTask,
92              new GridBagConstraints(
93              0,
94              1,
95              1,
96              1,
97              1.0,
98              1.0,
99              GridBagConstraints.CENTER,
100             GridBagConstraints.BOTH,
101             new Insets(3, 3, 3, 3),
102             0,
103             0));
104         this.getContentPane().add(
105             this.jButton,
106             new GridBagConstraints(
107             1,
108             1,
109             1,
110             1,
111             0.0,
112             1.0,
113             GridBagConstraints.EAST,
114             GridBagConstraints.NONE,
115             new Insets(3, 3, 3, 3),
116             0,
117             0));
118 
119         jButton.addActionListener(
120             new ActionListener()
121             {
122                 public void actionPerformed(ActionEvent e)
123                 {
124 					TorqueWrapper tw= new TorqueWrapper();
125 					tw.runTask(
126 					(PhysicalModel) ModelMan.getCurrentModel(),
127 					jTxtTask.getText());
128 					tw=null;                            
129                     dispose();
130                 }
131             });
132     }
133 
134 }
135