query

Reply

Join Date: Aug 2007
Posts: 238
Reputation: ceyesuma is an unknown quantity at this point 
Solved Threads: 0
ceyesuma ceyesuma is offline Offline
Posting Whiz in Training

query

 
0
  #1
Jan 8th, 2008
In this is just one class. can someone tell me to add a new query?
  1. /*
  2.  * SplashView.java
  3.  */
  4.  
  5. package splashapp;
  6.  
  7. import org.jdesktop.application.Action;
  8. import org.jdesktop.application.ResourceMap;
  9. import org.jdesktop.application.SingleFrameApplication;
  10. import org.jdesktop.application.FrameView;
  11. import org.jdesktop.application.TaskMonitor;
  12. import org.jdesktop.application.Task;
  13. import java.awt.event.ActionEvent;
  14. import java.awt.event.ActionListener;
  15. import java.util.ArrayList;
  16. import java.util.List;
  17. import javax.swing.Timer;
  18. import javax.swing.Icon;
  19. import javax.swing.JDialog;
  20. import javax.swing.JFrame;
  21. import javax.swing.event.ListSelectionEvent;
  22. import javax.swing.event.ListSelectionListener;
  23. import org.jdesktop.beansbinding.AbstractBindingListener;
  24. import org.jdesktop.beansbinding.Binding;
  25. import org.jdesktop.beansbinding.PropertyStateEvent;
  26.  
  27. /**
  28.  * The application's main frame.
  29.  */
  30. public class SplashView extends FrameView {
  31.  
  32. public SplashView(SingleFrameApplication app) {
  33. super(app);
  34.  
  35. initComponents();
  36.  
  37. // status bar initialization - message timeout, idle icon and busy animation, etc
  38. ResourceMap resourceMap = getResourceMap();
  39. int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
  40. messageTimer = new Timer(messageTimeout, new ActionListener() {
  41. public void actionPerformed(ActionEvent e) {
  42. statusMessageLabel.setText("");
  43. }
  44. });
  45. messageTimer.setRepeats(false);
  46. int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
  47. for (int i = 0; i < busyIcons.length; i++) {
  48. busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
  49. }
  50. busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
  51. public void actionPerformed(ActionEvent e) {
  52. busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
  53. statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
  54. }
  55. });
  56. idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
  57. statusAnimationLabel.setIcon(idleIcon);
  58. progressBar.setVisible(false);
  59.  
  60. // connecting action tasks to status bar via TaskMonitor
  61. TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
  62. taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
  63. public void propertyChange(java.beans.PropertyChangeEvent evt) {
  64. String propertyName = evt.getPropertyName();
  65. if ("started".equals(propertyName)) {
  66. if (!busyIconTimer.isRunning()) {
  67. statusAnimationLabel.setIcon(busyIcons[0]);
  68. busyIconIndex = 0;
  69. busyIconTimer.start();
  70. }
  71. progressBar.setVisible(true);
  72. progressBar.setIndeterminate(true);
  73. } else if ("done".equals(propertyName)) {
  74. busyIconTimer.stop();
  75. statusAnimationLabel.setIcon(idleIcon);
  76. progressBar.setVisible(false);
  77. progressBar.setValue(0);
  78. } else if ("message".equals(propertyName)) {
  79. String text = (String)(evt.getNewValue());
  80. statusMessageLabel.setText((text == null) ? "" : text);
  81. messageTimer.restart();
  82. } else if ("progress".equals(propertyName)) {
  83. int value = (Integer)(evt.getNewValue());
  84. progressBar.setVisible(true);
  85. progressBar.setIndeterminate(false);
  86. progressBar.setValue(value);
  87. }
  88. }
  89. });
  90.  
  91. // tracking table selection
  92. masterTable.getSelectionModel().addListSelectionListener(
  93. new ListSelectionListener() {
  94. public void valueChanged(ListSelectionEvent e) {
  95. firePropertyChange("recordSelected", !isRecordSelected(), isRecordSelected());
  96. }
  97. });
  98.  
  99. // tracking changes to save
  100. bindingGroup.addBindingListener(new AbstractBindingListener() {
  101. @Override
  102. public void targetChanged(Binding binding, PropertyStateEvent event) {
  103. // save action observes saveNeeded property
  104. setSaveNeeded(true);
  105. }
  106. });
  107.  
  108. // have a transaction started
  109. entityManager.getTransaction().begin();
  110. }
  111.  
  112.  
  113. public boolean isSaveNeeded() {
  114. return saveNeeded;
  115. }
  116.  
  117. private void setSaveNeeded(boolean saveNeeded) {
  118. if (saveNeeded != this.saveNeeded) {
  119. this.saveNeeded = saveNeeded;
  120. firePropertyChange("saveNeeded", !saveNeeded, saveNeeded);
  121. }
  122. }
  123.  
  124. public boolean isRecordSelected() {
  125. return masterTable.getSelectedRow() != -1;
  126. }
  127.  
  128.  
  129. @Action
  130. public void newRecord() {
  131. splashapp.Content c = new splashapp.Content();
  132. entityManager.persist(c);
  133. list.add(c);
  134. int row = list.size()-1;
  135. masterTable.setRowSelectionInterval(row, row);
  136. masterTable.scrollRectToVisible(masterTable.getCellRect(row, 0, true));
  137. setSaveNeeded(true);
  138. }
  139.  
  140. @Action(enabledProperty = "recordSelected")
  141. public void deleteRecord() {
  142. int[] selected = masterTable.getSelectedRows();
  143. List<splashapp.Content> toRemove = new ArrayList<splashapp.Content>(selected.length);
  144. for (int idx=0; idx<selected.length; idx++) {
  145. splashapp.Content c = list.get(masterTable.convertRowIndexToModel(selected[idx]));
  146. toRemove.add(c);
  147. entityManager.remove(c);
  148. }
  149. list.removeAll(toRemove);
  150. setSaveNeeded(true);
  151. }
  152.  
  153.  
  154. @Action(enabledProperty = "saveNeeded")
  155. public Task save() {
  156. return new SaveTask(getApplication());
  157. }
  158.  
  159. private class SaveTask extends Task {
  160. SaveTask(org.jdesktop.application.Application app) {
  161. super(app);
  162. }
  163. @Override protected Void doInBackground() {
  164. entityManager.getTransaction().commit();
  165. entityManager.getTransaction().begin();
  166. return null;
  167. }
  168. @Override protected void finished() {
  169. setSaveNeeded(false);
  170. }
  171. }
  172.  
  173. /**
  174.   * An example action method showing how to create asynchronous tasks
  175.   * (running on background) and how to show their progress. Note the
  176.   * artificial 'Thread.sleep' calls making the task long enough to see the
  177.   * progress visualization - remove the sleeps for real application.
  178.   */
  179. @Action
  180. public Task refresh() {
  181. return new RefreshTask(getApplication());
  182. }
  183.  
  184. private class RefreshTask extends Task {
  185. RefreshTask(org.jdesktop.application.Application app) {
  186. super(app);
  187. }
  188. @Override protected Void doInBackground() {
  189. try {
  190. setProgress(0, 0, 4);
  191. setMessage("Rolling back the current changes...");
  192. setProgress(1, 0, 4);
  193. entityManager.getTransaction().rollback();
  194. Thread.sleep(1000L); // remove for real app
  195. setProgress(2, 0, 4);
  196.  
  197. setMessage("Starting a new transaction...");
  198. entityManager.getTransaction().begin();
  199. Thread.sleep(500L); // remove for real app
  200. setProgress(3, 0, 4);
  201.  
  202. setMessage("Fetching new data...");
  203. java.util.Collection data = query.getResultList();
  204. Thread.sleep(1300L); // remove for real app
  205. setProgress(4, 0, 4);
  206.  
  207. Thread.sleep(150L); // remove for real app
  208. list.clear();
  209. list.addAll(data);
  210. } catch(InterruptedException ignore) { }
  211. return null;
  212. }
  213. @Override protected void finished() {
  214. setMessage("Done.");
  215. setSaveNeeded(false);
  216. }
  217. }
  218.  
  219. @Action
  220. public void showAboutBox() {
  221. if (aboutBox == null) {
  222. JFrame mainFrame = SplashApp.getApplication().getMainFrame();
  223. aboutBox = new SplashAboutBox(mainFrame);
  224. aboutBox.setLocationRelativeTo(mainFrame);
  225. }
  226. SplashApp.getApplication().show(aboutBox);
  227. }
  228. /**
  229.   * An example action method showing how to create asynchronous tasks
  230.   * (running on background) and how to show their progress. Note the
  231.   * artificial 'Thread.sleep' calls making the task long enough to see the
  232.   * progress visualization - remove the sleeps for real application.
  233.   */
  234. @Action
  235. public Task search() {
  236. return new SearchTask(getApplication());
  237. }
  238.  
  239. private class SearchTask extends Task {
  240.  
  241.  
  242. SearchTask(org.jdesktop.application.Application app) {
  243. super(app);
  244. }
  245. @Override protected Void doInBackground() {
  246. try {
  247. setProgress(0, 0, 4);
  248. setMessage("Rolling back the current changes...");
  249. setProgress(1, 0, 4);
  250. entityManager.getTransaction().rollback();
  251. Thread.sleep(1000L); // remove for real app
  252. setProgress(2, 0, 4);
  253.  
  254. setMessage("Starting a new transaction...");
  255. entityManager.getTransaction().begin();
  256. Thread.sleep(500L); // remove for real app
  257. setProgress(3, 0, 4);
  258.  
  259. setMessage("Fetching new data...");
  260. java.util.Collection data = query.getResultList();
  261. Thread.sleep(1300L); // remove for real app
  262. setProgress(4, 0, 4);
  263.  
  264. Thread.sleep(150L); // remove for real app
  265. list.clear();
  266. list.addAll(data);
  267. } catch(InterruptedException ignore) { }
  268. return null;
  269. }
  270. @Override protected void finished() {
  271. setMessage("Done.");
  272. setSaveNeeded(false);
  273. }
  274. }
  275.  
  276.  
  277. /** This method is called from within the constructor to
  278.   * initialize the form.
  279.   * WARNING: Do NOT modify this code. The content of this method is
  280.   * always regenerated by the Form Editor.
  281.   */
  282. // <editor-fold defaultstate="collapsed" desc="Generated Code">
  283. private void initComponents() {
  284. bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
  285.  
  286. mainPanel = new javax.swing.JPanel();
  287. masterScrollPane = new javax.swing.JScrollPane();
  288. masterTable = new javax.swing.JTable();
  289. bookTitleLabel = new javax.swing.JLabel();
  290. artistLabel = new javax.swing.JLabel();
  291. songLabel = new javax.swing.JLabel();
  292. pageNumLabel = new javax.swing.JLabel();
  293. bookTitleField = new javax.swing.JTextField();
  294. artistField = new javax.swing.JTextField();
  295. songField = new javax.swing.JTextField();
  296. pageNumField = new javax.swing.JTextField();
  297. saveButton = new javax.swing.JButton();
  298. refreshButton = new javax.swing.JButton();
  299. newButton = new javax.swing.JButton();
  300. deleteButton = new javax.swing.JButton();
  301. jPanel1 = new javax.swing.JPanel();
  302. searchJTextField1 = new javax.swing.JTextField();
  303. jButton1 = new javax.swing.JButton();
  304. searchJComboBox1 = new javax.swing.JComboBox();
  305. menuBar = new javax.swing.JMenuBar();
  306. javax.swing.JMenu fileMenu = new javax.swing.JMenu();
  307. javax.swing.JMenuItem newRecordMenuItem = new javax.swing.JMenuItem();
  308. javax.swing.JMenuItem deleteRecordMenuItem = new javax.swing.JMenuItem();
  309. jSeparator1 = new javax.swing.JSeparator();
  310. javax.swing.JMenuItem saveMenuItem = new javax.swing.JMenuItem();
  311. javax.swing.JMenuItem refreshMenuItem = new javax.swing.JMenuItem();
  312. jSeparator2 = new javax.swing.JSeparator();
  313. javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
  314. javax.swing.JMenu helpMenu = new javax.swing.JMenu();
  315. javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
  316. statusPanel = new javax.swing.JPanel();
  317. javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
  318. statusMessageLabel = new javax.swing.JLabel();
  319. statusAnimationLabel = new javax.swing.JLabel();
  320. progressBar = new javax.swing.JProgressBar();
  321. entityManager = javax.persistence.Persistence.createEntityManagerFactory("splashbookdbPU").createEntityManager();
  322. org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(splashapp.SplashApp.class).getContext().getResourceMap(SplashView.class);
  323. query = entityManager.createQuery(resourceMap.getString("query.query")); // NOI18N
  324. list = org.jdesktop.observablecollections.ObservableCollections.observableList(query.getResultList());
  325.  
  326. mainPanel.setName("mainPanel"); // NOI18N
  327.  
  328. masterScrollPane.setName("masterScrollPane"); // NOI18N
  329.  
  330. masterTable.setName("masterTable"); // NOI18N
  331.  
  332. org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, list, masterTable);
  333. org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${artist}"));
  334. columnBinding.setColumnName("Artist");
  335. columnBinding.setColumnClass(String.class);
  336. columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${song}"));
  337. columnBinding.setColumnName("Song");
  338. columnBinding.setColumnClass(String.class);
  339. columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${bookTitle}"));
  340. columnBinding.setColumnName("Book Title");
  341. columnBinding.setColumnClass(String.class);
  342. columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${pageNum}"));
  343. columnBinding.setColumnName("Page Num");
  344. columnBinding.setColumnClass(Integer.class);
  345. bindingGroup.addBinding(jTableBinding);
  346.  
  347. masterScrollPane.setViewportView(masterTable);
  348.  
  349. bookTitleLabel.setText(resourceMap.getString("bookTitleLabel.text")); // NOI18N
  350. bookTitleLabel.setName("bookTitleLabel"); // NOI18N
  351.  
  352. artistLabel.setText(resourceMap.getString("artistLabel.text")); // NOI18N
  353. artistLabel.setName("artistLabel"); // NOI18N
  354.  
  355. songLabel.setText(resourceMap.getString("songLabel.text")); // NOI18N
  356. songLabel.setName("songLabel"); // NOI18N
  357.  
  358. pageNumLabel.setText(resourceMap.getString("pageNumLabel.text")); // NOI18N
  359. pageNumLabel.setName("pageNumLabel"); // NOI18N
  360.  
  361. bookTitleField.setName("bookTitleField"); // NOI18N
  362.  
  363. org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.bookTitle}"), bookTitleField, org.jdesktop.beansbinding.BeanProperty.create("text"));
  364. binding.setSourceUnreadableValue(null);
  365. bindingGroup.addBinding(binding);
  366. binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), bookTitleField, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
  367. bindingGroup.addBinding(binding);
  368.  
  369. artistField.setName("artistField"); // NOI18N
  370.  
  371. binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.artist}"), artistField, org.jdesktop.beansbinding.BeanProperty.create("text"));
  372. binding.setSourceUnreadableValue(null);
  373. bindingGroup.addBinding(binding);
  374. binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), artistField, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
  375. bindingGroup.addBinding(binding);
  376.  
  377. songField.setName("songField"); // NOI18N
  378.  
  379. binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.song}"), songField, org.jdesktop.beansbinding.BeanProperty.create("text"));
  380. binding.setSourceUnreadableValue(null);
  381. bindingGroup.addBinding(binding);
  382. binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), songField, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
  383. bindingGroup.addBinding(binding);
  384.  
  385. pageNumField.setName("pageNumField"); // NOI18N
  386.  
  387. binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.pageNum}"), pageNumField, org.jdesktop.beansbinding.BeanProperty.create("text"));
  388. binding.setSourceUnreadableValue(null);
  389. bindingGroup.addBinding(binding);
  390. binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), pageNumField, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
  391. bindingGroup.addBinding(binding);
  392.  
  393. javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(splashapp.SplashApp.class).getContext().getActionMap(SplashView.class, this);
  394. saveButton.setAction(actionMap.get("save")); // NOI18N
  395. saveButton.setName("saveButton"); // NOI18N
  396.  
  397. refreshButton.setAction(actionMap.get("refresh")); // NOI18N
  398. refreshButton.setName("refreshButton"); // NOI18N
  399.  
  400. newButton.setAction(actionMap.get("newRecord")); // NOI18N
  401. newButton.setName("newButton"); // NOI18N
  402.  
  403. deleteButton.setAction(actionMap.get("deleteRecord")); // NOI18N
  404. deleteButton.setName("deleteButton"); // NOI18N
  405.  
  406. jPanel1.setName("jPanel1"); // NOI18N
  407.  
  408. searchJTextField1.setText(resourceMap.getString("searchJTextField1.text")); // NOI18N
  409. searchJTextField1.setDragEnabled(true);
  410. searchJTextField1.setName("searchJTextField1"); // NOI18N
  411.  
  412. javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  413. jPanel1.setLayout(jPanel1Layout);
  414. jPanel1Layout.setHorizontalGroup(
  415. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  416. .addComponent(searchJTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 282, Short.MAX_VALUE)
  417. );
  418. jPanel1Layout.setVerticalGroup(
  419. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  420. .addGroup(jPanel1Layout.createSequentialGroup()
  421. .addComponent(searchJTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  422. .addContainerGap(21, Short.MAX_VALUE))
  423. );
  424.  
  425. jButton1.setAction(actionMap.get("search")); // NOI18N
  426. jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
  427. jButton1.setName("jButton1"); // NOI18N
  428.  
  429. searchJComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Artist", "Song" }));
  430. searchJComboBox1.setName("searchJComboBox1"); // NOI18N
  431.  
  432. javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
  433. mainPanel.setLayout(mainPanelLayout);
  434. mainPanelLayout.setHorizontalGroup(
  435. mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  436. .addGroup(mainPanelLayout.createSequentialGroup()
  437. .addContainerGap()
  438. .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  439. .addGroup(mainPanelLayout.createSequentialGroup()
  440. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  441. .addComponent(searchJComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
  442. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  443. .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  444. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  445. .addComponent(jButton1))
  446. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
  447. .addComponent(newButton)
  448. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  449. .addComponent(deleteButton)
  450. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  451. .addComponent(refreshButton)
  452. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  453. .addComponent(saveButton))
  454. .addGroup(mainPanelLayout.createSequentialGroup()
  455. .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  456. .addComponent(bookTitleLabel)
  457. .addComponent(artistLabel)
  458. .addComponent(songLabel)
  459. .addComponent(pageNumLabel))
  460. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  461. .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  462. .addComponent(bookTitleField, javax.swing.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
  463. .addComponent(artistField, javax.swing.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
  464. .addComponent(songField, javax.swing.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
  465. .addComponent(pageNumField, javax.swing.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)))
  466. .addComponent(masterScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 427, Short.MAX_VALUE))
  467. .addContainerGap())
  468. );
  469.  
  470. mainPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {deleteButton, newButton, refreshButton, saveButton});
  471.  
  472. mainPanelLayout.setVerticalGroup(
  473. mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  474. .addGroup(mainPanelLayout.createSequentialGroup()
  475. .addContainerGap()
  476. .addComponent(masterScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
  477. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  478. .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  479. .addComponent(bookTitleLabel)
  480. .addComponent(bookTitleField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  481. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  482. .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  483. .addComponent(artistLabel)
  484. .addComponent(artistField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  485. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  486. .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  487. .addComponent(songLabel)
  488. .addComponent(songField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  489. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  490. .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  491. .addComponent(pageNumLabel)
  492. .addComponent(pageNumField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  493. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  494. .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  495. .addComponent(saveButton)
  496. .addComponent(refreshButton)
  497. .addComponent(deleteButton)
  498. .addComponent(newButton))
  499. .addGap(10, 10, 10)
  500. .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  501. .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  502. .addComponent(jButton1)
  503. .addComponent(searchJComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  504. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  505. );
  506.  
  507. menuBar.setName("menuBar"); // NOI18N
  508.  
  509. fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
  510. fileMenu.setName("fileMenu"); // NOI18N
  511.  
  512. newRecordMenuItem.setAction(actionMap.get("newRecord")); // NOI18N
  513. newRecordMenuItem.setName("newRecordMenuItem"); // NOI18N
  514. fileMenu.add(newRecordMenuItem);
  515.  
  516. deleteRecordMenuItem.setAction(actionMap.get("deleteRecord")); // NOI18N
  517. deleteRecordMenuItem.setName("deleteRecordMenuItem"); // NOI18N
  518. fileMenu.add(deleteRecordMenuItem);
  519.  
  520. jSeparator1.setName("jSeparator1"); // NOI18N
  521. fileMenu.add(jSeparator1);
  522.  
  523. saveMenuItem.setAction(actionMap.get("save")); // NOI18N
  524. saveMenuItem.setName("saveMenuItem"); // NOI18N
  525. fileMenu.add(saveMenuItem);
  526.  
  527. refreshMenuItem.setAction(actionMap.get("refresh")); // NOI18N
  528. refreshMenuItem.setName("refreshMenuItem"); // NOI18N
  529. fileMenu.add(refreshMenuItem);
  530.  
  531. jSeparator2.setName("jSeparator2"); // NOI18N
  532. fileMenu.add(jSeparator2);
  533.  
  534. exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
  535. exitMenuItem.setName("exitMenuItem"); // NOI18N
  536. fileMenu.add(exitMenuItem);
  537.  
  538. menuBar.add(fileMenu);
  539.  
  540. helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
  541. helpMenu.setName("helpMenu"); // NOI18N
  542.  
  543. aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
  544. aboutMenuItem.setName("aboutMenuItem"); // NOI18N
  545. helpMenu.add(aboutMenuItem);
  546.  
  547. menuBar.add(helpMenu);
  548.  
  549. statusPanel.setName("statusPanel"); // NOI18N
  550.  
  551. statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N
  552.  
  553. statusMessageLabel.setName("statusMessageLabel"); // NOI18N
  554.  
  555. statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
  556. statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N
  557.  
  558. progressBar.setName("progressBar"); // NOI18N
  559.  
  560. javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
  561. statusPanel.setLayout(statusPanelLayout);
  562. statusPanelLayout.setHorizontalGroup(
  563. statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  564. .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 447, Short.MAX_VALUE)
  565. .addGroup(statusPanelLayout.createSequentialGroup()
  566. .addContainerGap()
  567. .addComponent(statusMessageLabel)
  568. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 277, Short.MAX_VALUE)
  569. .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  570. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  571. .addComponent(statusAnimationLabel)
  572. .addContainerGap())
  573. );
  574. statusPanelLayout.setVerticalGroup(
  575. statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  576. .addGroup(statusPanelLayout.createSequentialGroup()
  577. .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
  578. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  579. .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  580. .addComponent(statusMessageLabel)
  581. .addComponent(statusAnimationLabel)
  582. .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  583. .addGap(3, 3, 3))
  584. );
  585.  
  586. setComponent(mainPanel);
  587. setMenuBar(menuBar);
  588. setStatusBar(statusPanel);
  589.  
  590. bindingGroup.bind();
  591. }// </editor-fold>
  592.  
  593. // Variables declaration - do not modify
  594. private javax.swing.JTextField artistField;
  595. private javax.swing.JLabel artistLabel;
  596. private javax.swing.JTextField bookTitleField;
  597. private javax.swing.JLabel bookTitleLabel;
  598. private javax.swing.JButton deleteButton;
  599. private javax.persistence.EntityManager entityManager;
  600. private javax.swing.JButton jButton1;
  601. private javax.swing.JPanel jPanel1;
  602. private javax.swing.JSeparator jSeparator1;
  603. private javax.swing.JSeparator jSeparator2;
  604. private java.util.List<splashapp.Content> list;
  605. private javax.swing.JPanel mainPanel;
  606. private javax.swing.JScrollPane masterScrollPane;
  607. private javax.swing.JTable masterTable;
  608. private javax.swing.JMenuBar menuBar;
  609. private javax.swing.JButton newButton;
  610. private javax.swing.JTextField pageNumField;
  611. private javax.swing.JLabel pageNumLabel;
  612. private javax.swing.JProgressBar progressBar;
  613. private javax.persistence.Query query;
  614. private javax.swing.JButton refreshButton;
  615. private javax.swing.JButton saveButton;
  616. private javax.swing.JComboBox searchJComboBox1;
  617. private javax.swing.JTextField searchJTextField1;
  618. private javax.swing.JTextField songField;
  619. private javax.swing.JLabel songLabel;
  620. private javax.swing.JLabel statusAnimationLabel;
  621. private javax.swing.JLabel statusMessageLabel;
  622. private javax.swing.JPanel statusPanel;
  623. private org.jdesktop.beansbinding.BindingGroup bindingGroup;
  624. // End of variables declaration
  625.  
  626. private final Timer messageTimer;
  627. private final Timer busyIconTimer;
  628. private final Icon idleIcon;
  629. private final Icon[] busyIcons = new Icon[15];
  630. private int busyIconIndex = 0;
  631.  
  632. private JDialog aboutBox;
  633.  
  634. private boolean saveNeeded;
  635. }
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: query

 
0
  #2
Jan 9th, 2008
no. Restructure that monstrosity first, think about what it is you want, and give a LOT more information.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 238
Reputation: ceyesuma is an unknown quantity at this point 
Solved Threads: 0
ceyesuma ceyesuma is offline Offline
Posting Whiz in Training

Re: query

 
-1
  #3
Jan 9th, 2008
Originally Posted by jwenting View Post
no. Restructure that monstrosity first, think about what it is you want, and give a LOT more information.
I am sorry that you don't understand this code. The entire program works beautiful. I asked a simple question. It's clear you don' know . Thank you anyway.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 238
Reputation: ceyesuma is an unknown quantity at this point 
Solved Threads: 0
ceyesuma ceyesuma is offline Offline
Posting Whiz in Training

Re: query

 
0
  #4
Jan 10th, 2008
I am sorry that you don't understand this code. The entire program works beautiful. I asked a simple question. It's clear you don' know . Thank you anyway.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: query

 
0
  #5
Jan 10th, 2008
I don't even bother to read such huge reams of code, especially if it's all in a single class.
It indicates a total lack of interest on your part in not only doing a decent job at your assignment but also in showing what your problem is.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 238
Reputation: ceyesuma is an unknown quantity at this point 
Solved Threads: 0
ceyesuma ceyesuma is offline Offline
Posting Whiz in Training

Re: query

 
0
  #6
Jan 10th, 2008
Chapter 9. Queries and EJB QL

Querying is a fundamental feature of all relational databases. It allows you to pull complex reports, calculations, and information about intricately related objects from persistence storage. Queries in Java Persistence are done using both the EJB QL query language and native Structured Query Language (SQL).

EJB QL is a declarative query language similar to the SQL used in relational databases, but it is tailored to work with Java objects rather than a relational schema. To execute queries, you reference the properties and relationships of your entity beans rather than the underlying tables and columns these objects are mapped to. When an EJQ QL query is executed, the entity manager uses the information you provided through the mapping metadata, discussed in the previous two chapters, and automatically translates it to one (or several) native SQL query. This generated native SQL is then executed through a JDBC driver directly on your database. Since EJB QL is a query language that represents Java objects, it is portable across vendor database implementations because the entity manager handles the conversion to raw SQL for you.
9.1. Query API

A query in Java Persistence is a full-blown Java interface that you obtain at runtime from the entity manager:
Code View: Scroll / Show All
  1. package javax.persistence;
  2.  
  3. public interface Query {
  4. public List getResultList( );
  5. public Object getSingleResult( );
  6. public int executeUpdate( );
  7. public Query setMaxResults(int maxResult);
  8. public Query setFirstResult(int startPosition);
  9. public Query setHint(String hintName, Object value);
  10. public Query setParameter(String name, Object value);
  11. public Query setParameter(String name, Date value, TemporalType temporalType);
  12. public Query setParameter(String name, Calendar value, TemporalType temporalType);
  13. public Query setParameter(int position, Object value);
  14. public Query setParameter(int position, Date value, TemporalType temporalType);
  15. public Query setParameter(int position, Calendar value, TemporalType temporalType);
  16. public Query setFlushMode(FlushModeType flushMode);
  17. }
In that one class. can someone tell me to where to add a new query?
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 238
Reputation: ceyesuma is an unknown quantity at this point 
Solved Threads: 0
ceyesuma ceyesuma is offline Offline
Posting Whiz in Training

Re: query

 
0
  #7
Jan 11th, 2008
entityManager.createQuery("Select e from "+MyEntity.class.getName()+" e")
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 238
Reputation: ceyesuma is an unknown quantity at this point 
Solved Threads: 0
ceyesuma ceyesuma is offline Offline
Posting Whiz in Training

Re: query

 
0
  #8
Jan 11th, 2008
public interface EntityManager

Interface used to interact with the persistence context.

An EntityManager instance is associated with a persistence context. A persistence context is a set of entity instances in which for any persistent entity identity there is a unique entity instance. Within the persistence context, the entity instances and their lifecycle are managed. This interface defines the methods that are used to interact with the persistence context. The EntityManager API is used to create and remove persistent entity instances, to find entities by their primary key, and to query over entities.

The set of entities that can be managed by a given EntityManager instance is defined by a persistence unit. A persistence unit defines the set of all classes that are related or grouped by the application, and which must be colocated in their mapping to a single database.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 238
Reputation: ceyesuma is an unknown quantity at this point 
Solved Threads: 0
ceyesuma ceyesuma is offline Offline
Posting Whiz in Training

Re: query

 
0
  #9
Jan 11th, 2008
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 238
Reputation: ceyesuma is an unknown quantity at this point 
Solved Threads: 0
ceyesuma ceyesuma is offline Offline
Posting Whiz in Training

Re: query

 
0
  #10
Jan 12th, 2008
never mind still looking
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC