Source Code Cross Referenced for RBGroupPanel.java in  » Internationalization-Localization » RBManager » com » ibm » rbm » gui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Internationalization Localization » RBManager » com.ibm.rbm.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *****************************************************************************
003:         * Copyright (C) 2000-2004, International Business Machines Corporation and  *
004:         * others. All Rights Reserved.                                              *
005:         *****************************************************************************
006:         */
007:        package com.ibm.rbm.gui;
008:
009:        import java.awt.*;
010:        import java.awt.event.*;
011:
012:        import javax.swing.*;
013:        import javax.swing.table.*;
014:        import javax.swing.event.*;
015:
016:        import com.ibm.rbm.*;
017:
018:        /**
019:         * The class used to display groups
020:         */
021:        class RBGroupPanel extends JPanel {
022:            RBManager rbm;
023:            Bundle bundle;
024:            RBManagerGUI listener;
025:
026:            // Components
027:            JLabel jLabelGroupTitle;
028:            JLabel jLabelGroupNameTitle;
029:            JLabel jLabelGroupCommentTitle;
030:            JLabel jLabelGroupComment;
031:            JComboBox jComboBoxGroup;
032:            JTable jTableGroupTable;
033:            JScrollPane jScrollPaneGroupTable;
034:
035:            // Components - Manager
036:            JList jListGroup;
037:            JButton createItemButton;
038:            JButton createGroupButton;
039:            JButton editItemButton;
040:            JButton editGroupButton;
041:            JButton deleteItemButton;
042:            JButton deleteGroupButton;
043:            JPanel itemPanel;
044:            JPanel groupPanel;
045:
046:            public RBGroupPanel(RBManagerGUI gui) {
047:                super ();
048:                listener = gui;
049:            }
050:
051:            public void setBundle(Bundle b) {
052:                rbm = null;
053:                if (bundle == null) {
054:                    bundle = b;
055:                    initComponents();
056:                } else if (bundle != b) {
057:                    bundle = b;
058:                    updateComponents();
059:                }
060:            }
061:
062:            public void setManager(RBManager m) {
063:                bundle = null;
064:                if (rbm == null) {
065:                    rbm = m;
066:                    initComponents();
067:                } else if (rbm != m) {
068:                    rbm = m;
069:                    updateComponents();
070:                }
071:            }
072:
073:            public void removeElements() {
074:                if (rbm != null || bundle != null) {
075:                    rbm = null;
076:                    bundle = null;
077:                    initComponents();
078:                }
079:            }
080:
081:            // Marks the selected resource as translated and removes from this view
082:            private void markSelectedResourceAsTranslated() {
083:                if (bundle == null)
084:                    return;
085:                if (jTableGroupTable.getSelectedRow() < 0)
086:                    return;
087:                if (jTableGroupTable.getModel() instanceof  GroupItemsTableModel) {
088:                    int row = jTableGroupTable.getSelectedRow();
089:                    GroupItemsTableModel model = (GroupItemsTableModel) jTableGroupTable
090:                            .getModel();
091:                    BundleItem item = model.getBundleItem(row);
092:                    item.setTranslated(true);
093:                    model.update();
094:                }
095:            }
096:
097:            // Removes the selected resource from the resource file
098:            private void deleteSelectedResource() {
099:                if (bundle == null)
100:                    return;
101:                if (jTableGroupTable.getSelectedRow() < 0)
102:                    return;
103:                if (jTableGroupTable.getModel() instanceof  GroupItemsTableModel) {
104:                    int row = jTableGroupTable.getSelectedRow();
105:                    GroupItemsTableModel model = (GroupItemsTableModel) jTableGroupTable
106:                            .getModel();
107:                    BundleItem item = model.getBundleItem(row);
108:                    if (item.getParentGroup() != null
109:                            && item.getParentGroup().getParentBundle() != null) {
110:                        Bundle parentBundle = item.getParentGroup()
111:                                .getParentBundle();
112:                        parentBundle.removeItem(item.getKey());
113:                    }
114:                    model.update();
115:                }
116:            }
117:
118:            private void initComponents() {
119:                // Initialize components
120:                if (bundle != null) {
121:                    jLabelGroupTitle = new JLabel(bundle.name);
122:                    jComboBoxGroup = new JComboBox(new GroupComboBoxModel(
123:                            bundle));
124:
125:                    jTableGroupTable = new JTable(new GroupItemsTableModel(
126:                            (BundleGroup) jComboBoxGroup.getSelectedItem()));
127:                    jScrollPaneGroupTable = new JScrollPane(jTableGroupTable);
128:                    jLabelGroupNameTitle = new JLabel(Resources
129:                            .getTranslation("basegroup_group_name"));
130:                    jLabelGroupCommentTitle = new JLabel(Resources
131:                            .getTranslation("basegroup_group_comment"));
132:                    jLabelGroupComment = new JLabel(
133:                            ((BundleGroup) jComboBoxGroup.getSelectedItem())
134:                                    .getComment());
135:
136:                    // Lower panel components
137:                    JPanel lowerPanel = new JPanel();
138:                    JButton deleteButton = new JButton(Resources
139:                            .getTranslation("button_delete_resource"));
140:                    JButton translateButton = new JButton(Resources
141:                            .getTranslation("button_mark_translated"));
142:
143:                    deleteButton
144:                            .setMnemonic(RBManagerMenuBar
145:                                    .getKeyEventKey(Resources
146:                                            .getTranslation("button_delete_resource_trigger")));
147:                    translateButton
148:                            .setMnemonic(RBManagerMenuBar
149:                                    .getKeyEventKey(Resources
150:                                            .getTranslation("button_mark_translated_trigger")));
151:                    lowerPanel
152:                            .setBorder(BorderFactory
153:                                    .createTitledBorder(Resources
154:                                            .getTranslation("languageuntrans_selected_resources_options")));
155:                    lowerPanel.setLayout(new GridLayout(1, 2));
156:
157:                    jLabelGroupNameTitle
158:                            .setHorizontalAlignment(SwingConstants.LEFT);
159:
160:                    jTableGroupTable
161:                            .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
162:                    jTableGroupTable.addMouseListener(listener);
163:
164:                    jComboBoxGroup
165:                            .addActionListener(new GroupComboActionListener(
166:                                    this ));
167:
168:                    jLabelGroupTitle.setFont(new Font("SansSerif", Font.PLAIN,
169:                            18));
170:
171:                    // Add action listeners
172:                    deleteButton.addActionListener(new ActionListener() {
173:                        public void actionPerformed(ActionEvent ev) {
174:                            deleteSelectedResource();
175:                        }
176:                    });
177:
178:                    translateButton.addActionListener(new ActionListener() {
179:                        public void actionPerformed(ActionEvent ev) {
180:                            markSelectedResourceAsTranslated();
181:                        }
182:                    });
183:
184:                    // Update the display
185:                    setLayout(new GridBagLayout());
186:                    GridBagConstraints gbc = new GridBagConstraints();
187:                    removeAll();
188:                    lowerPanel.add(deleteButton);
189:                    lowerPanel.add(translateButton);
190:
191:                    gbc.weightx = 1.0;
192:                    gbc.weighty = 0.0;
193:                    gbc.gridwidth = GridBagConstraints.REMAINDER;
194:                    gbc.fill = GridBagConstraints.HORIZONTAL;
195:                    add(jLabelGroupTitle, gbc);
196:                    gbc.weightx = 0.0;
197:                    gbc.gridwidth = 1;
198:                    add(jLabelGroupNameTitle, gbc);
199:                    gbc.weightx = 1.0;
200:                    gbc.gridwidth = GridBagConstraints.REMAINDER;
201:                    add(jComboBoxGroup, gbc);
202:                    gbc.weightx = 0.0;
203:                    gbc.gridwidth = 1;
204:                    add(jLabelGroupCommentTitle, gbc);
205:                    gbc.weightx = 1.0;
206:                    gbc.gridwidth = GridBagConstraints.REMAINDER;
207:                    add(jLabelGroupComment, gbc);
208:                    gbc.fill = GridBagConstraints.BOTH;
209:                    gbc.weighty = 1.0;
210:                    add(jScrollPaneGroupTable, gbc);
211:                    gbc.weighty = 0.0;
212:                    gbc.fill = GridBagConstraints.HORIZONTAL;
213:                    add(lowerPanel, gbc);
214:                } else if (rbm != null) {
215:                    Bundle mainBundle = (Bundle) rbm.getBundles()
216:                            .firstElement();
217:                    jLabelGroupTitle = new JLabel(rbm.getBaseClass() + " - "
218:                            + Resources.getTranslation("groups"));
219:                    jComboBoxGroup = new JComboBox(new GroupComboBoxModel(
220:                            mainBundle));//mainBundle.getGroupsAsVector());
221:
222:                    jListGroup = new JList(new GroupItemsListModel(
223:                            (BundleGroup) jComboBoxGroup.getSelectedItem()));
224:                    jScrollPaneGroupTable = new JScrollPane(jListGroup);
225:                    jLabelGroupNameTitle = new JLabel(Resources
226:                            .getTranslation("basegroup_group_name"));
227:                    jLabelGroupCommentTitle = new JLabel(Resources
228:                            .getTranslation("basegroup_group_comment"));
229:                    try {
230:                        jLabelGroupComment = new JLabel(
231:                                ((BundleGroup) jComboBoxGroup.getSelectedItem())
232:                                        .getComment());
233:                    } catch (NullPointerException npe) {
234:                        jLabelGroupComment = new JLabel("");
235:                    }
236:
237:                    createItemButton = new JButton(Resources
238:                            .getTranslation("button_create_resource"));
239:                    createGroupButton = new JButton(Resources
240:                            .getTranslation("button_create_group"));
241:                    deleteItemButton = new JButton(Resources
242:                            .getTranslation("button_delete_resource"));
243:                    deleteGroupButton = new JButton(Resources
244:                            .getTranslation("button_delete_group"));
245:                    editItemButton = new JButton(Resources
246:                            .getTranslation("button_edit_resource"));
247:                    editGroupButton = new JButton(Resources
248:                            .getTranslation("button_edit_group"));
249:
250:                    itemPanel = new JPanel();
251:                    groupPanel = new JPanel();
252:
253:                    itemPanel.setBorder(BorderFactory.createTitledBorder(
254:                            BorderFactory.createEtchedBorder(), Resources
255:                                    .getTranslation("basegroup_item_options")));
256:                    groupPanel
257:                            .setBorder(BorderFactory
258:                                    .createTitledBorder(
259:                                            BorderFactory.createEtchedBorder(),
260:                                            Resources
261:                                                    .getTranslation("basegroup_group_options")));
262:                    itemPanel.setLayout(new GridLayout(1, 3));
263:                    groupPanel.setLayout(new GridLayout(1, 3));
264:                    itemPanel.setMaximumSize(new Dimension(20000, 50));
265:                    groupPanel.setMaximumSize(new Dimension(20000, 50));
266:
267:                    createItemButton
268:                            .setMnemonic(RBManagerMenuBar
269:                                    .getKeyEventKey(Resources
270:                                            .getTranslation("button_create_resource_trigger")));
271:                    editItemButton
272:                            .setMnemonic(RBManagerMenuBar
273:                                    .getKeyEventKey(Resources
274:                                            .getTranslation("button_edit_resource_trigger")));
275:                    deleteItemButton
276:                            .setMnemonic(RBManagerMenuBar
277:                                    .getKeyEventKey(Resources
278:                                            .getTranslation("button_delete_resource_trigger")));
279:                    createGroupButton
280:                            .setMnemonic(RBManagerMenuBar
281:                                    .getKeyEventKey(Resources
282:                                            .getTranslation("button_create_group_trigger")));
283:
284:                    jListGroup
285:                            .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
286:
287:                    jComboBoxGroup
288:                            .addActionListener(new GroupComboActionListener(
289:                                    this ));
290:
291:                    jLabelGroupTitle.setFont(new Font("SansSerif", Font.PLAIN,
292:                            18));
293:
294:                    // Add the listeners
295:                    jListGroup.addMouseListener(new MouseAdapter() {
296:                        public void mouseClicked(MouseEvent ev) {
297:                            if (ev.getClickCount() == 2
298:                                    && ev.getSource() instanceof  JList) {
299:                                // A double click means they want to edit a bundle item
300:                                if (((JList) ev.getSource()).getSelectedValue() != null)
301:                                    new BundleItemCreationDialog(
302:                                            (BundleItem) ((JList) ev
303:                                                    .getSource())
304:                                                    .getSelectedValue(),
305:                                            listener.rbm,
306:                                            listener,
307:                                            Resources
308:                                                    .getTranslation("dialog_title_edit_item"),
309:                                            true);
310:                            }
311:                        }
312:                    });
313:
314:                    createItemButton.addActionListener(new ActionListener() {
315:                        public void actionPerformed(ActionEvent ev) {
316:                            new BundleItemCreationDialog(
317:                                    ((BundleGroup) jComboBoxGroup
318:                                            .getSelectedItem()).getName(),
319:                                    listener.rbm,
320:                                    listener,
321:                                    Resources
322:                                            .getTranslation("dialog_title_new_item"),
323:                                    true);
324:                            updateComponents();
325:                        }
326:                    });
327:                    createGroupButton.addActionListener(listener);
328:                    editItemButton.addActionListener(new ActionListener() {
329:                        public void actionPerformed(ActionEvent ev) {
330:                            if (jListGroup.getSelectedValue() != null)
331:                                new BundleItemCreationDialog(
332:                                        (BundleItem) jListGroup
333:                                                .getSelectedValue(),
334:                                        listener.rbm,
335:                                        listener,
336:                                        Resources
337:                                                .getTranslation("dialog_title_edit_item"),
338:                                        true);
339:                            updateComponents();
340:                        }
341:                    });
342:                    editGroupButton.addActionListener(new ActionListener() {
343:                        public void actionPerformed(ActionEvent ev) {
344:                            new BundleGroupEditDialog(
345:                                    (BundleGroup) jComboBoxGroup
346:                                            .getSelectedItem(),
347:                                    listener,
348:                                    Resources
349:                                            .getTranslation("dialog_title_edit_group"),
350:                                    true);
351:                            updateComponents();
352:                        }
353:                    });
354:                    deleteGroupButton.addActionListener(new ActionListener() {
355:                        public void actionPerformed(ActionEvent ev) {
356:                            int response = JOptionPane
357:                                    .showConfirmDialog(
358:                                            listener,
359:                                            Resources
360:                                                    .getTranslation("dialog_warning_delete_group"),
361:                                            Resources
362:                                                    .getTranslation("dialog_title_delete_group"),
363:                                            JOptionPane.OK_CANCEL_OPTION,
364:                                            JOptionPane.WARNING_MESSAGE);
365:                            if (response == JOptionPane.OK_OPTION) {
366:                                // Delete the group 
367:                                int index = jComboBoxGroup.getSelectedIndex();
368:                                BundleGroup group = (BundleGroup) jComboBoxGroup
369:                                        .getSelectedItem();
370:                                if (group.getName().equals("Ungrouped Items"))
371:                                    return;
372:                                if (index < jComboBoxGroup.getItemCount() - 1)
373:                                    jComboBoxGroup.setSelectedIndex(index + 1);
374:                                else
375:                                    jComboBoxGroup.setSelectedIndex(index - 1);
376:                                rbm.deleteGroup(group.getName());
377:                            }
378:                            updateComponents();
379:                        }
380:                    });
381:
382:                    deleteItemButton.addActionListener(new ActionListener() {
383:                        public void actionPerformed(ActionEvent ev) {
384:                            int response = JOptionPane
385:                                    .showConfirmDialog(
386:                                            listener,
387:                                            Resources
388:                                                    .getTranslation("dialog_warning_delete_item"),
389:                                            Resources
390:                                                    .getTranslation("dialog_title_delete_item"),
391:                                            JOptionPane.OK_CANCEL_OPTION,
392:                                            JOptionPane.WARNING_MESSAGE);
393:                            if (response == JOptionPane.OK_OPTION) {
394:                                Object o = jListGroup.getSelectedValue();
395:                                if (o != null) {
396:                                    BundleItem item = (BundleItem) o;
397:                                    handleDeleteItem(item.getKey());
398:                                    //panel.rbm.deleteItem(item.getKey());
399:                                }
400:                            }
401:                            updateComponents();
402:                        }
403:                    });
404:
405:                    // Update the display
406:                    setLayout(new GridBagLayout());
407:                    GridBagConstraints gbc = new GridBagConstraints();
408:                    removeAll();
409:                    itemPanel.add(createItemButton, BorderLayout.WEST);
410:                    itemPanel.add(editItemButton, BorderLayout.CENTER);
411:                    itemPanel.add(deleteItemButton, BorderLayout.EAST);
412:                    groupPanel.add(createGroupButton, BorderLayout.WEST);
413:                    groupPanel.add(editGroupButton, BorderLayout.CENTER);
414:                    groupPanel.add(deleteGroupButton, BorderLayout.EAST);
415:
416:                    gbc.weightx = 1.0;
417:                    gbc.weighty = 0.0;
418:                    gbc.gridwidth = GridBagConstraints.REMAINDER;
419:                    gbc.fill = GridBagConstraints.HORIZONTAL;
420:                    add(jLabelGroupTitle, gbc);
421:                    gbc.weightx = 0.0;
422:                    gbc.gridwidth = 1;
423:                    add(jLabelGroupNameTitle, gbc);
424:                    gbc.weightx = 1.0;
425:                    gbc.gridwidth = GridBagConstraints.REMAINDER;
426:                    add(jComboBoxGroup, gbc);
427:                    gbc.weightx = 0.0;
428:                    gbc.gridwidth = 1;
429:                    add(jLabelGroupCommentTitle, gbc);
430:                    gbc.weightx = 1.0;
431:                    gbc.gridwidth = GridBagConstraints.REMAINDER;
432:                    add(jLabelGroupComment, gbc);
433:                    gbc.fill = GridBagConstraints.BOTH;
434:                    gbc.weighty = 1.0;
435:                    add(jScrollPaneGroupTable, gbc);
436:                    gbc.weighty = 0.0;
437:                    gbc.fill = GridBagConstraints.HORIZONTAL;
438:                    add(groupPanel, gbc);
439:                    add(itemPanel, gbc);
440:                } else {
441:                    removeAll();
442:                }
443:            }
444:
445:            public void updateComponents() {
446:                // Initialize components
447:                if (bundle != null) {
448:                    jLabelGroupTitle.setText(bundle.name);
449:
450:                    ((GroupItemsTableModel) jTableGroupTable.getModel())
451:                            .setGroup((BundleGroup) jComboBoxGroup
452:                                    .getSelectedItem());
453:                    jLabelGroupComment.setText(((BundleGroup) jComboBoxGroup
454:                            .getSelectedItem()).getComment());
455:
456:                    jTableGroupTable
457:                            .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
458:
459:                    // Update the group comment
460:                    jLabelGroupComment.setText(((BundleGroup) jComboBoxGroup
461:                            .getSelectedItem()).getComment());
462:                    ((GroupComboBoxModel) jComboBoxGroup.getModel()).update();
463:                } else if (rbm != null) {
464:
465:                    // Update the list of groups
466:                    //			try {
467:                    ((GroupComboBoxModel) jComboBoxGroup.getModel()).update();
468:                    //			}
469:                    //			catch (Exception e) {}
470:                    // Update the group comment
471:                    if ((BundleGroup) jComboBoxGroup.getSelectedItem() != null)
472:                        jLabelGroupComment
473:                                .setText(((BundleGroup) jComboBoxGroup
474:                                        .getSelectedItem()).getComment());
475:                    else
476:                        jLabelGroupComment.setText("");
477:                    // Update the list of resources
478:                    ListModel lmodel = jListGroup.getModel();
479:                    if (lmodel instanceof  GroupItemsListModel) {
480:                        //((GroupItemsListModel)lmodel).update();
481:                        ((GroupItemsListModel) lmodel)
482:                                .setGroup((BundleGroup) jComboBoxGroup
483:                                        .getSelectedItem());
484:                    } else {
485:                        GroupItemsListModel newModel = new GroupItemsListModel(
486:                                (BundleGroup) jComboBoxGroup.getSelectedItem());
487:                        RBManagerGUI.debugMsg("List Model not as anticipated: "
488:                                + lmodel.getClass().getName());
489:                        jListGroup.setModel(newModel);
490:                        newModel.update();
491:                    }
492:                } else {
493:                    RBManagerGUI.debugMsg("Update, but no active components");
494:                    removeAll();
495:                }
496:                //validate();
497:            }
498:
499:            private void handleDeleteItem(String key) {
500:                if (rbm != null)
501:                    rbm.deleteItem(key);
502:            }
503:        }
504:
505:        /**
506:         * The action listener which monitors changes in the group to display
507:         */
508:        class GroupComboActionListener implements  ActionListener {
509:            RBGroupPanel panel;
510:
511:            protected GroupComboActionListener(RBGroupPanel panel) {
512:                this .panel = panel;
513:            }
514:
515:            public void actionPerformed(ActionEvent ev) {
516:                panel.updateComponents();
517:            }
518:        }
519:
520:        /**
521:         * The list model for groups
522:         */
523:        class GroupItemsListModel extends AbstractListModel {
524:            BundleGroup group;
525:
526:            public void setGroup(BundleGroup group) {
527:                this .group = group;
528:                update();
529:            }
530:
531:            public GroupItemsListModel(BundleGroup group) {
532:                this .group = group;
533:            }
534:
535:            public int getSize() {
536:                if (group == null)
537:                    return 0;
538:                int result = group.getItemCount();
539:                return result;
540:            }
541:
542:            public Object getElementAt(int index) {
543:                return group.getBundleItem(index);
544:            }
545:
546:            public void update() {
547:                fireContentsChanged(this , 0, getSize() - 1);
548:            }
549:        }
550:
551:        /**
552:         * The table model for searched Items
553:         */
554:        class GroupComboBoxModel extends DefaultComboBoxModel {
555:            Bundle bundle;
556:
557:            public GroupComboBoxModel(Bundle bundle) {
558:                this .bundle = bundle;
559:                setSelectedItem(bundle.getBundleGroup(0));
560:            }
561:
562:            public int getSize() {
563:                return bundle.getGroupCount();
564:            }
565:
566:            public Object getElementAt(int index) {
567:                return bundle.getBundleGroup(index);
568:            }
569:
570:            public Object getSelectedItem() {
571:                return super .getSelectedItem();
572:                //return getElementAt(0);
573:            }
574:
575:            public void update() {
576:                fireContentsChanged(this , 0, getSize() - 1);
577:            }
578:        }
579:
580:        /**
581:         * The table model for bundle groups
582:         */
583:        class GroupItemsTableModel extends AbstractTableModel {
584:            BundleGroup group;
585:
586:            public GroupItemsTableModel(BundleGroup group) {
587:                this .group = group;
588:            }
589:
590:            public int getColumnCount() {
591:                return 3;
592:            }
593:
594:            public int getRowCount() {
595:                return group.getItemCount();
596:            }
597:
598:            public void setGroup(BundleGroup bg) {
599:                group = bg;
600:                fireTableChanged(new TableModelEvent(this ));
601:            }
602:
603:            public Object getValueAt(int row, int col) {
604:                BundleItem item = group.getBundleItem(row);
605:
606:                String retStr = null;
607:
608:                switch (col) {
609:                case 0:
610:                    retStr = item.getKey();
611:                    break;
612:                case 1:
613:                    retStr = item.getTranslation();
614:                    break;
615:                case 2:
616:                    retStr = (item.getComment() == null ? "" : item
617:                            .getComment());
618:                    break;
619:                default:
620:                    retStr = Resources.getTranslation("table_cell_error");
621:                }
622:
623:                return retStr;
624:            }
625:
626:            public String getColumnName(int col) {
627:                if (col == 0)
628:                    return Resources.getTranslation("languagegroup_column_key");
629:                else if (col == 1)
630:                    return Resources
631:                            .getTranslation("languagegroup_column_translation");
632:                else if (col == 2)
633:                    return Resources
634:                            .getTranslation("languagegroup_column_comment");
635:                else
636:                    return Resources.getTranslation("table_column_error");
637:            }
638:
639:            public BundleItem getBundleItem(int row) {
640:                if (row >= group.getItemCount())
641:                    return null;
642:                return group.getBundleItem(row);
643:            }
644:
645:            public void update() {
646:                fireTableDataChanged();
647:            }
648:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.