$search
00001 package instruction.gui.tab; 00002 00003 import instruction.gui.dialog.ConfigDlg; 00004 import instruction.configuration.ConfigurationManager; 00005 import java.awt.Dimension; 00006 import javax.swing.JFileChooser; 00007 import javax.swing.JTextField; 00008 import javax.swing.JButton; 00009 import javax.swing.JPanel; 00010 import java.awt.GridBagLayout; 00011 import javax.swing.JLabel; 00012 import java.awt.GridBagConstraints; 00013 import java.awt.Insets; 00014 import java.awt.event.ActionEvent; 00015 import java.awt.event.ActionListener; 00016 import java.io.File; 00017 00018 public class SearchViewTab extends InstructionTab { 00019 00020 private static final long serialVersionUID = -165573500527827064L; 00021 00022 public static String TITLE = "Load a Howto"; 00023 00024 private JPanel jPanel = null; 00025 private JLabel jLabel = null; 00026 private JTextField txtPath = null; 00027 private JButton btnBrowse = null; 00028 00029 private JPanel jPanel1 = null; 00030 00031 private JButton jConfigureButton = null; 00032 00033 private JLabel jLabel1 = null; 00034 00035 private JLabel jLabel11 = null; 00036 00037 private JPanel jPanel2 = null; 00038 00039 private JPanel jPanel3 = null; 00040 00045 public SearchViewTab () { 00046 00047 super(); 00048 initialize(); 00049 } 00050 00055 private void initialize() { 00056 00057 GridBagConstraints gridBagConstraints15 = new GridBagConstraints(); 00058 gridBagConstraints15.gridx = 4; 00059 gridBagConstraints15.fill = GridBagConstraints.BOTH; 00060 gridBagConstraints15.gridheight = 10; 00061 gridBagConstraints15.gridy = 0; 00062 GridBagConstraints gridBagConstraints14 = new GridBagConstraints(); 00063 gridBagConstraints14.gridx = 0; 00064 gridBagConstraints14.gridheight = 10; 00065 gridBagConstraints14.fill = GridBagConstraints.BOTH; 00066 gridBagConstraints14.gridy = 0; 00067 GridBagConstraints gridBagConstraints13 = new GridBagConstraints(); 00068 gridBagConstraints13.gridx = 2; 00069 gridBagConstraints13.insets = new Insets(5, 5, 5, 5); 00070 gridBagConstraints13.fill = GridBagConstraints.HORIZONTAL; 00071 gridBagConstraints13.anchor = GridBagConstraints.WEST; 00072 gridBagConstraints13.gridy = 1; 00073 jLabel11 = new JLabel(); 00074 jLabel11.setText("In the latter case the system will look in the Howto path selected in the \"Settings\" dialog."); 00075 GridBagConstraints gridBagConstraints121 = new GridBagConstraints(); 00076 gridBagConstraints121.gridx = 2; 00077 gridBagConstraints121.anchor = GridBagConstraints.WEST; 00078 gridBagConstraints121.fill = GridBagConstraints.HORIZONTAL; 00079 gridBagConstraints121.insets = new Insets(5, 5, 5, 5); 00080 gridBagConstraints121.gridy = 0; 00081 jLabel1 = new JLabel(); 00082 jLabel1.setText("Please select either a path to a Howto file or just type the title of a Howto (e.g. \"set a table\")."); 00083 GridBagConstraints gridBagConstraints12 = new GridBagConstraints(); 00084 gridBagConstraints12.gridx = 3; 00085 gridBagConstraints12.insets = new Insets(5, 5, 5, 5); 00086 gridBagConstraints12.fill = GridBagConstraints.NONE; 00087 gridBagConstraints12.gridy = 9; 00088 GridBagConstraints gridBagConstraints31 = new GridBagConstraints(); 00089 gridBagConstraints31.gridx = 3; 00090 gridBagConstraints31.gridy = 6; 00091 GridBagConstraints gridBagConstraints21 = new GridBagConstraints(); 00092 gridBagConstraints21.gridx = 1; 00093 gridBagConstraints21.gridy = 4; 00094 GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); 00095 gridBagConstraints3.insets = new Insets( 5, 5, 5, 5 ); 00096 gridBagConstraints3.gridx = 3; 00097 gridBagConstraints3.gridy = 3; 00098 gridBagConstraints3.gridwidth = 1; 00099 gridBagConstraints3.anchor = GridBagConstraints.NORTH; 00100 gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL; 00101 gridBagConstraints3.gridheight = 1; 00102 GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); 00103 gridBagConstraints2.fill = GridBagConstraints.HORIZONTAL; 00104 gridBagConstraints2.gridheight = 2; 00105 gridBagConstraints2.gridx = 2; 00106 gridBagConstraints2.gridy = 3; 00107 gridBagConstraints2.weightx = 1.0; 00108 gridBagConstraints2.anchor = GridBagConstraints.NORTH; 00109 gridBagConstraints2.insets = new Insets( 8, 5, 5, 5 ); 00110 GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); 00111 gridBagConstraints1.insets = new Insets(5, 5, 5, 5); 00112 gridBagConstraints1.gridx = 1; 00113 gridBagConstraints1.gridy = 3; 00114 gridBagConstraints1.anchor = GridBagConstraints.WEST; 00115 gridBagConstraints1.gridheight = 1; 00116 GridBagConstraints gridBagConstraints = new GridBagConstraints(); 00117 gridBagConstraints.gridheight = 0; 00118 gridBagConstraints.gridx = 1; 00119 gridBagConstraints.gridy = 1; 00120 gridBagConstraints.gridwidth = 0; 00121 this.setLayout( new GridBagLayout() ); 00122 this.setSize( new Dimension( 636, 237 ) ); 00123 this.add( getJPanel(), gridBagConstraints ); 00124 this.add(jLabel, gridBagConstraints1); 00125 this.add(getTxtPath(), gridBagConstraints2); 00126 this.add(getBtnBrowse(), gridBagConstraints3); 00127 this.add(getJPanel1(), gridBagConstraints31); 00128 this.add(getJConfigureButton(), gridBagConstraints12); 00129 this.add(jLabel1, gridBagConstraints121); 00130 this.add(jLabel11, gridBagConstraints13); 00131 this.add(getJPanel2(), gridBagConstraints14); 00132 this.add(getJPanel3(), gridBagConstraints15); 00133 00134 } 00135 00141 private JPanel getJPanel() { 00142 00143 if ( jPanel == null ) { 00144 jLabel = new JLabel(); 00145 jLabel.setText( "Howto:" ); 00146 jPanel = new JPanel(); 00147 jPanel.setLayout( new GridBagLayout() ); 00148 } 00149 return jPanel; 00150 } 00151 00157 private JTextField getTxtPath() { 00158 00159 if ( txtPath == null ) { 00160 txtPath = new JTextField(); 00161 txtPath.setText("make pancakes"); 00162 txtPath.setPreferredSize( new Dimension( 200, 20 ) ); 00163 } 00164 return txtPath; 00165 } 00166 00172 private JButton getBtnBrowse() { 00173 00174 if ( btnBrowse == null ) { 00175 btnBrowse = new JButton(); 00176 btnBrowse.setText( "Browse..." ); 00177 00178 btnBrowse.addActionListener( new ActionListener() { 00179 00180 public void actionPerformed( ActionEvent e ) { 00181 00182 JFileChooser dlg = new JFileChooser(); 00183 dlg.setCurrentDirectory( new File( "." ) ); 00184 int retVal = dlg.showOpenDialog( SearchViewTab.this ); 00185 if ( retVal == JFileChooser.APPROVE_OPTION ) { 00186 getTxtPath().setText( dlg.getSelectedFile().getAbsolutePath() ); 00187 00188 } 00189 } 00190 00191 } ); 00192 } 00193 return btnBrowse; 00194 } 00195 00201 private JPanel getJPanel1() { 00202 00203 if ( jPanel1 == null ) { 00204 jPanel1 = new JPanel(); 00205 jPanel1.setLayout( new GridBagLayout() ); 00206 } 00207 return jPanel1; 00208 } 00209 00210 public String getHowtoPath() { 00211 00212 return getTxtPath().getText(); 00213 } 00214 00220 private JButton getJConfigureButton() { 00221 00222 if ( jConfigureButton == null ) { 00223 jConfigureButton = new JButton(); 00224 jConfigureButton.setText("Settings..."); 00225 jConfigureButton.addActionListener( new java.awt.event.ActionListener() { 00226 public void actionPerformed( java.awt.event.ActionEvent e ) { 00227 ConfigDlg dlg = new ConfigDlg(); 00228 dlg.setModal( true ); 00229 dlg.setLocationRelativeTo( SearchViewTab.this ); 00230 dlg.setVisible( true ); 00231 ConfigurationManager.saveSettings(); 00232 } 00233 } ); 00234 00235 } 00236 return jConfigureButton; 00237 } 00238 00244 private JPanel getJPanel2() { 00245 00246 if ( jPanel2 == null ) { 00247 jPanel2 = new JPanel(); 00248 jPanel2.setLayout(new GridBagLayout()); 00249 jPanel2.setMinimumSize( new Dimension(40, 10) ); 00250 jPanel2.setMaximumSize( new Dimension(40, 10) ); 00251 jPanel2.setPreferredSize( new Dimension(40, 10) ); 00252 } 00253 return jPanel2; 00254 } 00255 00261 private JPanel getJPanel3() { 00262 00263 if ( jPanel3 == null ) { 00264 jPanel3 = new JPanel(); 00265 jPanel3.setLayout(new GridBagLayout()); 00266 jPanel3.setMinimumSize( new Dimension(40, 10) ); 00267 jPanel3.setMaximumSize( new Dimension(40, 10) ); 00268 jPanel3.setPreferredSize( new Dimension(40, 10) ); 00269 } 00270 return jPanel3; 00271 } 00272 } // @jve:decl-index=0:visual-constraint="97,81"