001: /*
002: JSmooth: a VM wrapper toolkit for Windows
003: Copyright (C) 2003 Rodrigo Reyes <reyes@charabia.net>
004:
005: This program is free software; you can redistribute it and/or modify
006: it under the terms of the GNU General Public License as published by
007: the Free Software Foundation; either version 2 of the License, or
008: (at your option) any later version.
009:
010: This program is distributed in the hope that it will be useful,
011: but WITHOUT ANY WARRANTY; without even the implied warranty of
012: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013: GNU General Public License for more details.
014:
015: You should have received a copy of the GNU General Public License
016: along with this program; if not, write to the Free Software
017: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
018:
019: */
020:
021: /*
022: * SkeletonEditor.java
023: *
024: * Created on 7 août 2003, 22:23
025: */
026:
027: package net.charabia.jsmoothgen.skeleton;
028:
029: import javax.swing.*;
030: import javax.swing.table.*;
031: import java.util.*;
032: import java.io.*;
033: import java.awt.*;
034:
035: public class SkeletonEditor extends javax.swing.JFrame {
036: private SkeletonPropertyTableModel m_model = new SkeletonPropertyTableModel();
037:
038: /** Creates new form SkeletonEditor */
039: public SkeletonEditor() {
040: initComponents();
041: setSkeleton(new SkeletonBean());
042: // m_propTable.setModel(m_model);
043: }
044:
045: /** This method is called from within the constructor to
046: * initialize the form.
047: * WARNING: Do NOT modify this code. The content of this method is
048: * always regenerated by the Form Editor.
049: */
050: private void initComponents()//GEN-BEGIN:initComponents
051: {
052: java.awt.GridBagConstraints gridBagConstraints;
053:
054: m_fileChooser = new javax.swing.JFileChooser();
055: m_popupMenu = new javax.swing.JPopupMenu();
056: m_menuAddItem = new javax.swing.JMenuItem();
057: m_menuRemoveItem = new javax.swing.JMenuItem();
058: jSeparator3 = new javax.swing.JSeparator();
059: m_menuItemUp = new javax.swing.JMenuItem();
060: jPanel1 = new javax.swing.JPanel();
061: jLabel5 = new javax.swing.JLabel();
062: m_exeName = new javax.swing.JTextField();
063: m_labelName = new javax.swing.JLabel();
064: m_name = new javax.swing.JTextField();
065: jLabel1 = new javax.swing.JLabel();
066: jScrollPane1 = new javax.swing.JScrollPane();
067: m_description = new javax.swing.JEditorPane();
068: jLabel2 = new javax.swing.JLabel();
069: m_categoryName = new javax.swing.JTextField();
070: jLabel3 = new javax.swing.JLabel();
071: m_jarId = new javax.swing.JTextField();
072: jLabel4 = new javax.swing.JLabel();
073: m_propsId = new javax.swing.JTextField();
074: m_cbDebug = new javax.swing.JCheckBox();
075: m_tablescrollpane = new javax.swing.JScrollPane();
076: m_propTable = new javax.swing.JTable();
077: jMenuBar1 = new javax.swing.JMenuBar();
078: jMenu1 = new javax.swing.JMenu();
079: m_menuNew = new javax.swing.JMenuItem();
080: m_menuLoadKBML = new javax.swing.JMenuItem();
081: m_menuLoad = new javax.swing.JMenuItem();
082: jSeparator1 = new javax.swing.JSeparator();
083: m_menuSaveKbml = new javax.swing.JMenuItem();
084: m_menuSave = new javax.swing.JMenuItem();
085: jSeparator2 = new javax.swing.JSeparator();
086: m_menuExit = new javax.swing.JMenuItem();
087:
088: m_fileChooser.setCurrentDirectory(new java.io.File("c:\\"));
089: m_fileChooser
090: .setFileFilter(new javax.swing.filechooser.FileFilter() {
091: public boolean accept(File f) {
092: if (f.toString().endsWith(".skel"))
093: return true;
094: if (f.isDirectory())
095: return true;
096: return false;
097: }
098:
099: public String getDescription() {
100: return "JSmooth Skeletons (*.skel)";
101: }
102: });
103: m_fileChooser
104: .setFileSelectionMode(javax.swing.JFileChooser.FILES_AND_DIRECTORIES);
105: m_menuAddItem.setText("Add item");
106: m_menuAddItem
107: .addActionListener(new java.awt.event.ActionListener() {
108: public void actionPerformed(
109: java.awt.event.ActionEvent evt) {
110: menuAddItemActionPerformed(evt);
111: }
112: });
113:
114: m_popupMenu.add(m_menuAddItem);
115:
116: m_menuRemoveItem.setText("RemoveItems");
117: m_menuRemoveItem
118: .addActionListener(new java.awt.event.ActionListener() {
119: public void actionPerformed(
120: java.awt.event.ActionEvent evt) {
121: menuRemoveItemActionPerformed(evt);
122: }
123: });
124:
125: m_popupMenu.add(m_menuRemoveItem);
126:
127: m_popupMenu.add(jSeparator3);
128:
129: m_menuItemUp.setText("Item Up");
130: m_menuItemUp
131: .addActionListener(new java.awt.event.ActionListener() {
132: public void actionPerformed(
133: java.awt.event.ActionEvent evt) {
134: menuItemUpActionPerformed(evt);
135: }
136: });
137:
138: m_popupMenu.add(m_menuItemUp);
139:
140: getContentPane().setLayout(new java.awt.GridBagLayout());
141:
142: setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
143: setTitle("JSmooth Skeleton Editor");
144: addWindowListener(new java.awt.event.WindowAdapter() {
145: public void windowClosing(java.awt.event.WindowEvent evt) {
146: exitForm(evt);
147: }
148: });
149:
150: jPanel1.setLayout(new java.awt.GridBagLayout());
151:
152: jPanel1.setBorder(new javax.swing.border.EtchedBorder());
153: jLabel5
154: .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
155: jLabel5.setText("Executable Name");
156: gridBagConstraints = new java.awt.GridBagConstraints();
157: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
158: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 5);
159: jPanel1.add(jLabel5, gridBagConstraints);
160:
161: gridBagConstraints = new java.awt.GridBagConstraints();
162: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
163: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
164: gridBagConstraints.weightx = 0.5;
165: jPanel1.add(m_exeName, gridBagConstraints);
166:
167: m_labelName
168: .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
169: m_labelName.setText("Short Name");
170: m_labelName
171: .setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
172: gridBagConstraints = new java.awt.GridBagConstraints();
173: gridBagConstraints.gridy = 1;
174: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
175: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 5);
176: jPanel1.add(m_labelName, gridBagConstraints);
177:
178: gridBagConstraints = new java.awt.GridBagConstraints();
179: gridBagConstraints.gridy = 1;
180: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
181: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
182: gridBagConstraints.weightx = 0.5;
183: jPanel1.add(m_name, gridBagConstraints);
184:
185: jLabel1.setText("Description");
186: gridBagConstraints = new java.awt.GridBagConstraints();
187: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
188: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
189: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
190: jPanel1.add(jLabel1, gridBagConstraints);
191:
192: jScrollPane1.setViewportView(m_description);
193:
194: gridBagConstraints = new java.awt.GridBagConstraints();
195: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
196: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
197: gridBagConstraints.weightx = 0.5;
198: gridBagConstraints.weighty = 0.5;
199: jPanel1.add(jScrollPane1, gridBagConstraints);
200:
201: jLabel2
202: .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
203: jLabel2.setText("Category Name");
204: gridBagConstraints = new java.awt.GridBagConstraints();
205: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
206: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 5);
207: jPanel1.add(jLabel2, gridBagConstraints);
208:
209: gridBagConstraints = new java.awt.GridBagConstraints();
210: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
211: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
212: gridBagConstraints.weightx = 0.5;
213: jPanel1.add(m_categoryName, gridBagConstraints);
214:
215: jLabel3
216: .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
217: jLabel3.setText("Resource Id for JAR");
218: gridBagConstraints = new java.awt.GridBagConstraints();
219: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
220: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 5);
221: jPanel1.add(jLabel3, gridBagConstraints);
222:
223: gridBagConstraints = new java.awt.GridBagConstraints();
224: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
225: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
226: jPanel1.add(m_jarId, gridBagConstraints);
227:
228: jLabel4
229: .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
230: jLabel4.setText("Resource Id for Properties");
231: gridBagConstraints = new java.awt.GridBagConstraints();
232: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
233: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 5);
234: jPanel1.add(jLabel4, gridBagConstraints);
235:
236: m_propsId
237: .addActionListener(new java.awt.event.ActionListener() {
238: public void actionPerformed(
239: java.awt.event.ActionEvent evt) {
240: m_propsIdActionPerformed(evt);
241: }
242: });
243:
244: gridBagConstraints = new java.awt.GridBagConstraints();
245: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
246: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
247: jPanel1.add(m_propsId, gridBagConstraints);
248:
249: m_cbDebug.setText("Mark this wrapper for debugging only");
250: m_cbDebug
251: .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
252: gridBagConstraints = new java.awt.GridBagConstraints();
253: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
254: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
255: jPanel1.add(m_cbDebug, gridBagConstraints);
256:
257: m_tablescrollpane
258: .addMouseListener(new java.awt.event.MouseAdapter() {
259: public void mousePressed(
260: java.awt.event.MouseEvent evt) {
261: tablescrollpaneMousePressed(evt);
262: }
263:
264: public void mouseReleased(
265: java.awt.event.MouseEvent evt) {
266: tablescrollpaneMouseReleased(evt);
267: }
268: });
269:
270: m_propTable.setModel(new javax.swing.table.DefaultTableModel(
271: new Object[][] { { null, null, null, null, null },
272: { null, null, null, null, null },
273: { null, null, null, null, null },
274: { null, null, null, null, null } },
275: new String[] { "Id", "Label", "Description", "Type",
276: "Value" }));
277: m_propTable.addMouseListener(new java.awt.event.MouseAdapter() {
278: public void mouseClicked(java.awt.event.MouseEvent evt) {
279: propTableMouseClicked(evt);
280: }
281:
282: public void mousePressed(java.awt.event.MouseEvent evt) {
283: propTableMousePressed(evt);
284: }
285:
286: public void mouseReleased(java.awt.event.MouseEvent evt) {
287: propTableMouseReleased(evt);
288: }
289: });
290:
291: m_tablescrollpane.setViewportView(m_propTable);
292:
293: gridBagConstraints = new java.awt.GridBagConstraints();
294: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
295: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
296: gridBagConstraints.weightx = 1.0;
297: gridBagConstraints.weighty = 1.0;
298: jPanel1.add(m_tablescrollpane, gridBagConstraints);
299:
300: gridBagConstraints = new java.awt.GridBagConstraints();
301: gridBagConstraints.gridx = 1;
302: gridBagConstraints.gridy = 1;
303: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
304: gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
305: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
306: gridBagConstraints.weightx = 0.9;
307: gridBagConstraints.weighty = 0.9;
308: getContentPane().add(jPanel1, gridBagConstraints);
309:
310: jMenu1.setText("System");
311: m_menuNew.setText("New");
312: m_menuNew
313: .addActionListener(new java.awt.event.ActionListener() {
314: public void actionPerformed(
315: java.awt.event.ActionEvent evt) {
316: menuNewActionPerformed(evt);
317: }
318: });
319:
320: jMenu1.add(m_menuNew);
321:
322: m_menuLoadKBML.setText("Load");
323: m_menuLoadKBML
324: .addActionListener(new java.awt.event.ActionListener() {
325: public void actionPerformed(
326: java.awt.event.ActionEvent evt) {
327: menuLoadKBMLActionPerformed(evt);
328: }
329: });
330:
331: jMenu1.add(m_menuLoadKBML);
332:
333: m_menuLoad.setText("Load (deprecated)");
334: m_menuLoad
335: .addActionListener(new java.awt.event.ActionListener() {
336: public void actionPerformed(
337: java.awt.event.ActionEvent evt) {
338: menuLoadActionPerformed(evt);
339: }
340: });
341:
342: jMenu1.add(m_menuLoad);
343:
344: jMenu1.add(jSeparator1);
345:
346: m_menuSaveKbml.setText("Save");
347: m_menuSaveKbml
348: .addActionListener(new java.awt.event.ActionListener() {
349: public void actionPerformed(
350: java.awt.event.ActionEvent evt) {
351: saveKbmlActionPerformed(evt);
352: }
353: });
354:
355: jMenu1.add(m_menuSaveKbml);
356:
357: m_menuSave.setText("Save (deprecated)");
358: m_menuSave
359: .addActionListener(new java.awt.event.ActionListener() {
360: public void actionPerformed(
361: java.awt.event.ActionEvent evt) {
362: menuSaveActionPerformed(evt);
363: }
364: });
365:
366: jMenu1.add(m_menuSave);
367:
368: jMenu1.add(jSeparator2);
369:
370: m_menuExit.setText("Exit");
371: jMenu1.add(m_menuExit);
372:
373: jMenuBar1.add(jMenu1);
374:
375: setJMenuBar(jMenuBar1);
376:
377: java.awt.Dimension screenSize = java.awt.Toolkit
378: .getDefaultToolkit().getScreenSize();
379: setBounds((screenSize.width - 400) / 2,
380: (screenSize.height - 254) / 2, 400, 254);
381: }//GEN-END:initComponents
382:
383: private void menuLoadKBMLActionPerformed(
384: java.awt.event.ActionEvent evt)//GEN-FIRST:event_menuLoadKBMLActionPerformed
385: {//GEN-HEADEREND:event_menuLoadKBMLActionPerformed
386: // Add your handling code here:
387: if (m_fileChooser.showOpenDialog(this ) == JFileChooser.APPROVE_OPTION) {
388: File f = m_fileChooser.getSelectedFile();
389: System.out.println("loading "
390: + m_fileChooser.getSelectedFile().toString());
391: try {
392: SkeletonBean skel = SkeletonPersistency.loadWithJox(f);
393: setSkeleton(skel);
394: } catch (IOException iox) {
395: iox.printStackTrace();
396: }
397: }
398: }//GEN-LAST:event_menuLoadKBMLActionPerformed
399:
400: private void saveKbmlActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_saveKbmlActionPerformed
401: {//GEN-HEADEREND:event_saveKbmlActionPerformed
402: // Add your handling code here:
403: if (m_fileChooser.showSaveDialog(this ) == JFileChooser.APPROVE_OPTION) {
404: File f = m_fileChooser.getSelectedFile();
405: if (f.toString().endsWith(".skel") == false) {
406: f = new File(f.getAbsolutePath() + ".skel");
407: }
408: System.out.println("loading "
409: + m_fileChooser.getSelectedFile().toString());
410: try {
411: SkeletonBean skel = getSkeleton();
412: SkeletonPersistency.saveWithJox(f, skel);
413: } catch (IOException iox) {
414: iox.printStackTrace();
415: }
416: }
417:
418: }//GEN-LAST:event_saveKbmlActionPerformed
419:
420: private void menuItemUpActionPerformed(
421: java.awt.event.ActionEvent evt)//GEN-FIRST:event_menuItemUpActionPerformed
422: {//GEN-HEADEREND:event_menuItemUpActionPerformed
423: // Add your handling code here:
424: int selr = m_propTable.getSelectedRow();
425: if (selr > 0) {
426: m_model.swapItems(selr, selr - 1);
427: }
428: }//GEN-LAST:event_menuItemUpActionPerformed
429:
430: private void menuRemoveItemActionPerformed(
431: java.awt.event.ActionEvent evt)//GEN-FIRST:event_menuRemoveItemActionPerformed
432: {//GEN-HEADEREND:event_menuRemoveItemActionPerformed
433: int selr = m_propTable.getSelectedRow();
434: if (selr != -1) {
435: m_model.removeRow(selr);
436: }
437: }//GEN-LAST:event_menuRemoveItemActionPerformed
438:
439: private void menuAddItemActionPerformed(
440: java.awt.event.ActionEvent evt)//GEN-FIRST:event_menuAddItemActionPerformed
441: {//GEN-HEADEREND:event_menuAddItemActionPerformed
442: SkeletonProperty prop = new SkeletonProperty();
443: int selr = m_propTable.getSelectedRow();
444: if (selr >= 0)
445: m_model.add(prop, selr);
446: else
447: m_model.add(prop);
448: }//GEN-LAST:event_menuAddItemActionPerformed
449:
450: private void tablescrollpaneMouseReleased(
451: java.awt.event.MouseEvent evt)//GEN-FIRST:event_tablescrollpaneMouseReleased
452: {//GEN-HEADEREND:event_tablescrollpaneMouseReleased
453: // Add your handling code here:
454: System.out.println("MOUSE");
455: if (evt.isPopupTrigger()) {
456: System.out.println("trigger !");
457: showPopupMenu(evt, m_tablescrollpane);
458: }
459: }//GEN-LAST:event_tablescrollpaneMouseReleased
460:
461: private void tablescrollpaneMousePressed(
462: java.awt.event.MouseEvent evt)//GEN-FIRST:event_tablescrollpaneMousePressed
463: {//GEN-HEADEREND:event_tablescrollpaneMousePressed
464: // Add your handling code here:
465: System.out.println("MOUSE");
466: if (evt.isPopupTrigger()) {
467: System.out.println("trigger !");
468: showPopupMenu(evt, m_tablescrollpane);
469: }
470: }//GEN-LAST:event_tablescrollpaneMousePressed
471:
472: private void propTableMouseReleased(java.awt.event.MouseEvent evt)//GEN-FIRST:event_propTableMouseReleased
473: {//GEN-HEADEREND:event_propTableMouseReleased
474: // Add your handling code here:
475: System.out.println("MOUSE");
476: if (evt.isPopupTrigger()) {
477: System.out.println("trigger !");
478: showPopupMenu(evt, m_propTable);
479: }
480: }//GEN-LAST:event_propTableMouseReleased
481:
482: private void propTableMousePressed(java.awt.event.MouseEvent evt)//GEN-FIRST:event_propTableMousePressed
483: {//GEN-HEADEREND:event_propTableMousePressed
484: // Add your handling code here:
485: System.out.println("MOUSE");
486: if (evt.isPopupTrigger()) {
487: System.out.println("trigger !");
488: showPopupMenu(evt, m_propTable);
489: }
490: }//GEN-LAST:event_propTableMousePressed
491:
492: private void propTableMouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_propTableMouseClicked
493: {//GEN-HEADEREND:event_propTableMouseClicked
494: // Add your handling code here:
495: System.out.println("MOUSE");
496: if (evt.isPopupTrigger()) {
497: System.out.println("trigger !");
498: showPopupMenu(evt, m_propTable);
499: }
500: }//GEN-LAST:event_propTableMouseClicked
501:
502: private void m_propsIdActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_m_propsIdActionPerformed
503: {//GEN-HEADEREND:event_m_propsIdActionPerformed
504: // Add your handling code here:
505: }//GEN-LAST:event_m_propsIdActionPerformed
506:
507: private void menuSaveActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_menuSaveActionPerformed
508: {//GEN-HEADEREND:event_menuSaveActionPerformed
509: // Add your handling code here:
510: if (m_fileChooser.showSaveDialog(this ) == JFileChooser.APPROVE_OPTION) {
511: File f = m_fileChooser.getSelectedFile();
512: if (f.toString().endsWith(".skel") == false) {
513: f = new File(f.getAbsolutePath() + ".skel");
514: }
515: System.out.println("loading "
516: + m_fileChooser.getSelectedFile().toString());
517: try {
518: SkeletonBean skel = getSkeleton();
519: SkeletonPersistency.save(f, skel);
520: } catch (IOException iox) {
521: iox.printStackTrace();
522: }
523: }
524: }//GEN-LAST:event_menuSaveActionPerformed
525:
526: private void menuLoadActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_menuLoadActionPerformed
527: {//GEN-HEADEREND:event_menuLoadActionPerformed
528: // Add your handling code here:
529: if (m_fileChooser.showOpenDialog(this ) == JFileChooser.APPROVE_OPTION) {
530: File f = m_fileChooser.getSelectedFile();
531: System.out.println("loading "
532: + m_fileChooser.getSelectedFile().toString());
533: try {
534: SkeletonBean skel = SkeletonPersistency.load(f);
535: setSkeleton(skel);
536: } catch (IOException iox) {
537: iox.printStackTrace();
538: }
539: }
540: }//GEN-LAST:event_menuLoadActionPerformed
541:
542: private void menuNewActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_menuNewActionPerformed
543: {//GEN-HEADEREND:event_menuNewActionPerformed
544: // Add your handling code here:
545: SkeletonBean skel = new SkeletonBean();
546: setSkeleton(skel);
547: }//GEN-LAST:event_menuNewActionPerformed
548:
549: /** Exit the Application */
550: private void exitForm(java.awt.event.WindowEvent evt)//GEN-FIRST:event_exitForm
551: {
552: System.exit(0);
553: }//GEN-LAST:event_exitForm
554:
555: public void setSkeleton(SkeletonBean skel) {
556: m_name.setText(skel.getShortName());
557: m_description.setText(skel.getDescription());
558: m_categoryName.setText(skel.getResourceCategory());
559: m_jarId
560: .setText(new Integer(skel.getResourceJarId())
561: .toString());
562: m_propsId.setText(new Integer(skel.getResourcePropsId())
563: .toString());
564: m_exeName.setText(skel.getExecutableName());
565: m_cbDebug.setSelected(skel.isDebug());
566:
567: m_model = new SkeletonPropertyTableModel(skel
568: .getSkeletonProperties());
569: TableColumn type = m_propTable.getColumnModel().getColumn(3);
570: JComboBox typeCombo = new JComboBox();
571: typeCombo.addItem(SkeletonProperty.TYPE_STRING);
572: typeCombo.addItem(SkeletonProperty.TYPE_TEXTAREA);
573: typeCombo.addItem(SkeletonProperty.TYPE_BOOLEAN);
574: type.setCellEditor(new DefaultCellEditor(typeCombo));
575:
576: m_propTable.setModel(m_model);
577: }
578:
579: public SkeletonBean getSkeleton() {
580: SkeletonBean skel = new SkeletonBean();
581: skel.setExecutableName(m_exeName.getText());
582: skel.setShortName(m_name.getText());
583: skel.setDescription(m_description.getText());
584: skel.setResourceCategory(m_categoryName.getText());
585: skel.setResourceJarId(Integer.parseInt(m_jarId.getText()));
586: skel.setResourcePropsId(Integer.parseInt(m_propsId.getText()));
587: skel.setSkeletonProperties(m_model.getProperties());
588: skel.setDebug(m_cbDebug.isSelected());
589: return skel;
590: }
591:
592: public void showPopupMenu(java.awt.event.MouseEvent evt,
593: JComponent comp) {
594: int r = m_propTable
595: .rowAtPoint(new Point(evt.getX(), evt.getY()));
596: if (r != -1) {
597: m_propTable.setRowSelectionInterval(r, r);
598: }
599: m_popupMenu.show(comp, evt.getX(), evt.getY());
600: }
601:
602: /**
603: * @param args the command line arguments
604: */
605: public static void main(String args[]) {
606: new SkeletonEditor().setVisible(true);
607: }
608:
609: // Variables declaration - do not modify//GEN-BEGIN:variables
610: private javax.swing.JLabel jLabel1;
611: private javax.swing.JLabel jLabel2;
612: private javax.swing.JLabel jLabel3;
613: private javax.swing.JLabel jLabel4;
614: private javax.swing.JLabel jLabel5;
615: private javax.swing.JMenu jMenu1;
616: private javax.swing.JMenuBar jMenuBar1;
617: private javax.swing.JPanel jPanel1;
618: private javax.swing.JScrollPane jScrollPane1;
619: private javax.swing.JSeparator jSeparator1;
620: private javax.swing.JSeparator jSeparator2;
621: private javax.swing.JSeparator jSeparator3;
622: private javax.swing.JTextField m_categoryName;
623: private javax.swing.JCheckBox m_cbDebug;
624: private javax.swing.JEditorPane m_description;
625: private javax.swing.JTextField m_exeName;
626: private javax.swing.JFileChooser m_fileChooser;
627: private javax.swing.JTextField m_jarId;
628: private javax.swing.JLabel m_labelName;
629: private javax.swing.JMenuItem m_menuAddItem;
630: private javax.swing.JMenuItem m_menuExit;
631: private javax.swing.JMenuItem m_menuItemUp;
632: private javax.swing.JMenuItem m_menuLoad;
633: private javax.swing.JMenuItem m_menuLoadKBML;
634: private javax.swing.JMenuItem m_menuNew;
635: private javax.swing.JMenuItem m_menuRemoveItem;
636: private javax.swing.JMenuItem m_menuSave;
637: private javax.swing.JMenuItem m_menuSaveKbml;
638: private javax.swing.JTextField m_name;
639: private javax.swing.JPopupMenu m_popupMenu;
640: private javax.swing.JTable m_propTable;
641: private javax.swing.JTextField m_propsId;
642: private javax.swing.JScrollPane m_tablescrollpane;
643: // End of variables declaration//GEN-END:variables
644:
645: }
|