Source Code Cross Referenced for DigitalBiosphereServer.java in  » 6.0-JDK-Modules » java-3d » com » db » server » 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 » 6.0 JDK Modules » java 3d » com.db.server 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Copyright (c) 2001 Silvere Martin-Michiellot All Rights Reserved.
0003:         *
0004:         * Silvere Martin-Michiellot grants you ("Licensee") a non-exclusive,
0005:         * royalty free, license to use, modify and redistribute this
0006:         * software in source and binary code form,
0007:         * provided that i) this copyright notice and license appear on all copies of
0008:         * the software; and ii) Licensee does not utilize the software in a manner
0009:         * which is disparaging to Silvere Martin-Michiellot.
0010:         *
0011:         * This software is provided "AS IS," without a warranty of any kind. ALL
0012:         * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
0013:         * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
0014:         * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. Silvere Martin-Michiellot
0015:         * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
0016:         * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
0017:         * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
0018:         * Silvere Martin-Michiellot OR ITS LICENSORS BE LIABLE
0019:         * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
0020:         * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
0021:         * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
0022:         * OR INABILITY TO USE SOFTWARE, EVEN IF Silvere Martin-Michiellot HAS BEEN
0023:         * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
0024:         *
0025:         * This software is not designed or intended for use in on-line control of
0026:         * aircraft, air traffic, aircraft navigation or aircraft communications; or in
0027:         * the design, construction, operation or maintenance of any nuclear
0028:         * facility. Licensee represents and warrants that it will not use or
0029:         * redistribute the Software for such purposes.
0030:         *
0031:         * @Author: Silvere Martin-Michiellot
0032:         *
0033:         */
0034:
0035:        package com.db.server;
0036:
0037:        import java.awt.*;
0038:        import java.awt.event.*;
0039:        import java.net.*;
0040:        import java.util.*;
0041:        import java.io.*;
0042:        import java.lang.reflect.*;
0043:        import javax.help.*;
0044:        import javax.swing.*;
0045:        import javax.swing.tree.*;
0046:        import javax.swing.event.*;
0047:        import java.beans.PropertyChangeListener;
0048:        import java.beans.PropertyChangeEvent;
0049:
0050:        import java.security.PublicKey;
0051:
0052:        /**
0053:         * Front end Gui part of the UniverseServer.
0054:         */
0055:
0056:        public class DigitalBiosphereServer extends JFrame implements 
0057:                ActionListener, WindowListener {
0058:
0059:            //manage information, ip, port, worldspots, remoteservers, gates, serverhelper, time offset, end of service, update notify, ruler login and password
0060:            //button to add gates from the well known server
0061:            //do log and allow administrator to save information
0062:
0063:            private final static int DefaultLoglevel = 0;
0064:            private final static String DefaultLogin = "anonymous";
0065:            private final static String DefaultPassword = "anonymous";
0066:
0067:            private UniverseServer universeServer;
0068:            private ResourceBundle resourceBundle;
0069:
0070:            private InetAddress ip;
0071:            private int port;
0072:            private LoginInformation loginInformation;
0073:            private int logLevel;
0074:            private HashSet worldSpots;
0075:            private HashSet remoteServers;
0076:            private HashSet gates;
0077:
0078:            private javax.swing.Timer timer;
0079:
0080:            private String[] timeZoneIDs;
0081:            private int currentTimeZoneIndex;
0082:
0083:            private final String helpSetName = "DigitalBiosphereServerHelp";
0084:            private final String helpSetURL = "DigitalBiosphereServerHelp.hs";
0085:            private HelpSet helpSet;
0086:            private HelpBroker helpBroker;
0087:
0088:            private DefaultTreeModel defaultTreeModel;
0089:            private DefaultMutableTreeNode defaultMutableTreeNode;
0090:            private DefaultMutableTreeNode treeNode1;
0091:            private DefaultMutableTreeNode subTreeNode1;
0092:            private DefaultMutableTreeNode subTreeNode2;
0093:            private DefaultMutableTreeNode treeNode2;
0094:
0095:            private JMenuBar menuBar;
0096:            private JMenu fileMenu;
0097:            private JMenuItem openMenuItem;
0098:            private JMenuItem saveMenuItem;
0099:            private JMenuItem saveAsMenuItem;
0100:            private JMenuItem exitMenuItem;
0101:            private JMenu editMenu;
0102:            private JMenuItem cutMenuItem;
0103:            private JMenuItem copyMenuItem;
0104:            private JMenuItem pasteMenuItem;
0105:            private JMenuItem deleteMenuItem;
0106:            private JMenuItem informationMenuItem;
0107:            private JMenuItem loginMenuItem;
0108:            private JMenuItem connectionMenuItem;
0109:            private JMenu languageMenu;
0110:            private JRadioButtonMenuItem languageMenuItem;
0111:            private JMenu helpMenu;
0112:            private JMenuItem contentsMenuItem;
0113:            private JMenuItem aboutMenuItem;
0114:            private JPanel jPanel1;
0115:            private JLabel jLabel1;
0116:            private JComboBox jComboBox1;
0117:            private JPanel jPanel5;
0118:            private JTree jTree1;
0119:            private JPanel jPanel6;
0120:            private JButton jButton4;
0121:            private JButton jButton5;
0122:            private JButton jButton6;
0123:            private JPanel jPanel7;
0124:            private JButton jButton7;
0125:            private JButton jButton8;
0126:            private JPanel jPanel8;
0127:            private JTextArea jTextArea1;
0128:
0129:            private Locale[] locales;
0130:
0131:            public DigitalBiosphereServer(String[] args,
0132:                    ResourceBundle resourceBundle) {
0133:
0134:                TimeZone timeZone;
0135:
0136:                WorldSpot worldSpot;
0137:                RemoteWorldSpotsAccess remoteWorldSpotsAccess;
0138:                Gate gate;
0139:                Iterator iterator;
0140:                JScrollPane jScrollPane;
0141:
0142:                DefaultMutableTreeNode subTreeNode;
0143:                DefaultMutableTreeNode subsubTreeNode;
0144:
0145:                this .parseArgs(args);
0146:
0147:                try {
0148:                    this .universeServer = new UniverseServer(this 
0149:                            .getLoginInformation(), this .getIP(), this 
0150:                            .getPort(), (WorldSpot) this .getWorldSpots()
0151:                            .iterator().next());
0152:                } catch (IOException iOException) {
0153:                }
0154:
0155:                this .resourceBundle = resourceBundle;
0156:
0157:                menuBar = new JMenuBar();
0158:                fileMenu = new JMenu();
0159:                saveAsMenuItem = new JMenuItem();
0160:                exitMenuItem = new JMenuItem();
0161:                editMenu = new JMenu();
0162:                cutMenuItem = new JMenuItem();
0163:                copyMenuItem = new JMenuItem();
0164:                pasteMenuItem = new JMenuItem();
0165:                deleteMenuItem = new JMenuItem();
0166:                informationMenuItem = new JMenuItem();
0167:                loginMenuItem = new JMenuItem();
0168:                connectionMenuItem = new JMenuItem();
0169:                languageMenu = new JMenu();
0170:                helpMenu = new JMenu();
0171:                contentsMenuItem = new JMenuItem();
0172:                aboutMenuItem = new JMenuItem();
0173:                jPanel1 = new JPanel();
0174:                jLabel1 = new JLabel();
0175:                jComboBox1 = new JComboBox();
0176:                jPanel5 = new JPanel();
0177:                jTree1 = new JTree();
0178:                jPanel6 = new JPanel();
0179:                jButton4 = new JButton();
0180:                jButton5 = new JButton();
0181:                jButton6 = new JButton();
0182:                jPanel7 = new JPanel();
0183:                jButton7 = new JButton();
0184:                jButton8 = new JButton();
0185:                jPanel8 = new JPanel();
0186:                jTextArea1 = new JTextArea();
0187:
0188:                fileMenu.setText(resourceBundle.getString("File"));
0189:                fileMenu.getAccessibleContext().setAccessibleDescription(
0190:                        resourceBundle.getString("MenuFileDescription"));
0191:
0192:                saveAsMenuItem.setText(resourceBundle
0193:                        .getString("Save Log As ..."));
0194:                saveAsMenuItem.getAccessibleContext().setAccessibleDescription(
0195:                        resourceBundle
0196:                                .getString("MenuItemSaveLogAsDescription"));
0197:                saveAsMenuItem.setMnemonic(KeyEvent.VK_S);
0198:                saveAsMenuItem
0199:                        .setActionCommand(new String("MenuItemSaveLogAs"));
0200:                saveAsMenuItem.addActionListener(this );
0201:                fileMenu.add(saveAsMenuItem);
0202:
0203:                fileMenu.addSeparator();
0204:
0205:                exitMenuItem.setText(resourceBundle.getString("Exit"));
0206:                exitMenuItem.getAccessibleContext().setAccessibleDescription(
0207:                        resourceBundle.getString("MenuItemExitDescription"));
0208:                exitMenuItem.setMnemonic(KeyEvent.VK_Q);
0209:                exitMenuItem.setActionCommand(new String("MenuItemExit"));
0210:                exitMenuItem.addActionListener(this );
0211:                fileMenu.add(exitMenuItem);
0212:
0213:                menuBar.add(fileMenu);
0214:
0215:                editMenu.setText(resourceBundle.getString("Edit"));
0216:                editMenu.getAccessibleContext().setAccessibleDescription(
0217:                        resourceBundle.getString("MenuEditDescription"));
0218:
0219:                cutMenuItem.setText(resourceBundle.getString("Cut"));
0220:                cutMenuItem.getAccessibleContext().setAccessibleDescription(
0221:                        resourceBundle.getString("MenuItemCutDescription"));
0222:                cutMenuItem.setMnemonic(KeyEvent.VK_CUT);
0223:                cutMenuItem.setActionCommand(new String("MenuItemCut"));
0224:                cutMenuItem.addActionListener(this );
0225:                editMenu.add(cutMenuItem);
0226:
0227:                copyMenuItem.setText(resourceBundle.getString("Copy"));
0228:                copyMenuItem.getAccessibleContext().setAccessibleDescription(
0229:                        resourceBundle.getString("MenuItemCopyDescription"));
0230:                copyMenuItem.setMnemonic(KeyEvent.VK_COPY);
0231:                copyMenuItem.setActionCommand(new String("MenuItemCopy"));
0232:                copyMenuItem.addActionListener(this );
0233:                editMenu.add(copyMenuItem);
0234:
0235:                pasteMenuItem.setText(resourceBundle.getString("Paste"));
0236:                pasteMenuItem.getAccessibleContext().setAccessibleDescription(
0237:                        resourceBundle.getString("MenuItemPasteDescription"));
0238:                pasteMenuItem.setMnemonic(KeyEvent.VK_PASTE);
0239:                pasteMenuItem.setActionCommand(new String("MenuItemPaste"));
0240:                pasteMenuItem.addActionListener(this );
0241:                editMenu.add(pasteMenuItem);
0242:
0243:                deleteMenuItem.setText(resourceBundle.getString("Delete"));
0244:                deleteMenuItem.getAccessibleContext().setAccessibleDescription(
0245:                        resourceBundle.getString("MenuItemDeleteDescription"));
0246:                deleteMenuItem.setMnemonic(KeyEvent.VK_DELETE);
0247:                deleteMenuItem.setActionCommand(new String("MenuItemDelete"));
0248:                deleteMenuItem.addActionListener(this );
0249:                editMenu.add(deleteMenuItem);
0250:
0251:                editMenu.addSeparator();
0252:
0253:                informationMenuItem.setText(resourceBundle
0254:                        .getString("Information..."));
0255:                informationMenuItem
0256:                        .getAccessibleContext()
0257:                        .setAccessibleDescription(
0258:                                resourceBundle
0259:                                        .getString("MenuItemInformationDescription"));
0260:                informationMenuItem.setMnemonic(KeyEvent.VK_I);
0261:                informationMenuItem.setActionCommand(new String(
0262:                        "MenuItemInformation"));
0263:                informationMenuItem.addActionListener(this );
0264:                editMenu.add(informationMenuItem);
0265:
0266:                loginMenuItem.setText(resourceBundle
0267:                        .getString("Ruler Login..."));
0268:                loginMenuItem.getAccessibleContext().setAccessibleDescription(
0269:                        resourceBundle.getString("MenuItemLoginDescription"));
0270:                loginMenuItem.setMnemonic(KeyEvent.VK_L);
0271:                loginMenuItem.setActionCommand(new String("MenuItemLogin"));
0272:                loginMenuItem.addActionListener(this );
0273:                editMenu.add(loginMenuItem);
0274:
0275:                connectionMenuItem.setText(resourceBundle
0276:                        .getString("Connection..."));
0277:                connectionMenuItem
0278:                        .getAccessibleContext()
0279:                        .setAccessibleDescription(
0280:                                resourceBundle
0281:                                        .getString("MenuItemConnectionDescription"));
0282:                connectionMenuItem.setMnemonic(KeyEvent.VK_C);
0283:                connectionMenuItem.setActionCommand(new String(
0284:                        "MenuItemConnection"));
0285:                connectionMenuItem.addActionListener(this );
0286:                editMenu.add(connectionMenuItem);
0287:
0288:                menuBar.add(editMenu);
0289:
0290:                locales = Locale.getAvailableLocales();
0291:
0292:                if (locales.length > 1) {
0293:
0294:                    languageMenu.setText(resourceBundle.getString("Language"));
0295:                    languageMenu
0296:                            .getAccessibleContext()
0297:                            .setAccessibleDescription(
0298:                                    resourceBundle
0299:                                            .getString("MenuLanguageDescription"));
0300:
0301:                    for (int i = 0; i < locales.length; i++) {
0302:                        languageMenuItem = new JRadioButtonMenuItem();
0303:                        languageMenuItem.setText(resourceBundle
0304:                                .getString(Locale.getDefault()
0305:                                        .getDisplayLanguage(locales[i])));
0306:                        languageMenuItem
0307:                                .getAccessibleContext()
0308:                                .setAccessibleDescription(
0309:                                        resourceBundle
0310:                                                .getString("MenuItemLanguageDescription"));
0311:                        languageMenuItem
0312:                                .setActionCommand(new String("MenuItemLanguage"
0313:                                        + " "
0314:                                        + Locale.getDefault()
0315:                                                .getDisplayLanguage(locales[i])));
0316:                        languageMenuItem.addActionListener(this );
0317:
0318:                        if (resourceBundle.getLocale() == locales[i]) {
0319:                            languageMenuItem.setSelected(false);
0320:                        } else {
0321:                            languageMenuItem.setSelected(true);
0322:                        }
0323:                        languageMenu.add(languageMenuItem);
0324:                    }
0325:
0326:                    menuBar.add(languageMenu);
0327:                }
0328:
0329:                helpMenu.setText(resourceBundle.getString("Help"));
0330:                helpMenu.getAccessibleContext().setAccessibleDescription(
0331:                        resourceBundle.getString("MenuHelpDescription"));
0332:
0333:                contentsMenuItem.setText(resourceBundle.getString("Contents"));
0334:                contentsMenuItem
0335:                        .getAccessibleContext()
0336:                        .setAccessibleDescription(
0337:                                resourceBundle
0338:                                        .getString("MenuItemContentsDescription"));
0339:                contentsMenuItem.setMnemonic(KeyEvent.VK_HELP);
0340:                contentsMenuItem
0341:                        .setActionCommand(new String("MenuItemContents"));
0342:                contentsMenuItem.addActionListener(this );
0343:                helpMenu.add(contentsMenuItem);
0344:
0345:                aboutMenuItem.setText(resourceBundle.getString("About"));
0346:                aboutMenuItem.getAccessibleContext().setAccessibleDescription(
0347:                        resourceBundle.getString("MenuItemAboutDescription"));
0348:                aboutMenuItem.setMnemonic(KeyEvent.VK_A);
0349:                aboutMenuItem.setActionCommand(new String("MenuItemAbout"));
0350:                aboutMenuItem.addActionListener(this );
0351:                helpMenu.add(aboutMenuItem);
0352:
0353:                menuBar.add(Box.createHorizontalGlue());
0354:
0355:                menuBar.add(helpMenu);
0356:
0357:                this .getContentPane().setLayout(new FlowLayout());
0358:                this .setName(resourceBundle
0359:                        .getString("DigitalBiosphere Server"));
0360:                this .setTitle(resourceBundle
0361:                        .getString("DigitalBiosphere Server"));
0362:
0363:                jPanel1.setLayout(new FlowLayout(0, 5, 5));
0364:                jPanel1.setPreferredSize(new Dimension(300, 20));
0365:                jPanel1.setMinimumSize(new Dimension(300, 20));
0366:
0367:                //"Current time is XX:XX:XX with offset:"
0368:                jLabel1.setText("");
0369:                jLabel1.setHorizontalAlignment(SwingConstants.LEFT);
0370:                jPanel1.add(jLabel1);
0371:
0372:                timeZone = TimeZone.getDefault();
0373:                timeZoneIDs = timeZone.getAvailableIDs();
0374:
0375:                for (int i = 0; i < timeZoneIDs.length; i++) {
0376:                    jComboBox1.addItem(TimeZone.getTimeZone(timeZoneIDs[i])
0377:                            .getDisplayName(locales[i]));
0378:                }
0379:                jComboBox1.setSelectedIndex(0);
0380:
0381:                currentTimeZoneIndex = jComboBox1.getSelectedIndex();
0382:
0383:                jComboBox1.addActionListener(this );
0384:                jComboBox1.setToolTipText(resourceBundle
0385:                        .getString("OffsetToolTipText"));
0386:                jComboBox1
0387:                        .getAccessibleContext()
0388:                        .setAccessibleDescription(
0389:                                resourceBundle
0390:                                        .getString("OffsetAccessibleDescription"));
0391:                jPanel1.add(jComboBox1);
0392:
0393:                //label about the text (again)
0394:                this .setTimeLabel(jLabel1);
0395:
0396:                this .getContentPane().add(jPanel1);
0397:
0398:                jPanel5.setPreferredSize(new Dimension(300, 256));
0399:                jPanel5.setMinimumSize(new Dimension(300, 256));
0400:
0401:                //Create the nodes.
0402:                defaultMutableTreeNode = new DefaultMutableTreeNode();
0403:
0404:                treeNode1 = new DefaultMutableTreeNode(resourceBundle
0405:                        .getString("ThisServer")
0406:                        + " (" + universeServer.getName() + ")");
0407:                defaultMutableTreeNode.add(treeNode1);
0408:
0409:                subTreeNode1 = new DefaultMutableTreeNode(resourceBundle
0410:                        .getString("LocalWorldSpots"));
0411:                treeNode1.add(subTreeNode1);
0412:                iterator = universeServer.getLocalWorldSpots().iterator();
0413:                while (iterator.hasNext()) {
0414:                    worldSpot = (WorldSpot) iterator.next();
0415:                    subsubTreeNode = new DefaultMutableTreeNode(worldSpot
0416:                            .getName());
0417:                    subTreeNode1.add(subsubTreeNode);
0418:                }
0419:
0420:                subTreeNode2 = new DefaultMutableTreeNode(resourceBundle
0421:                        .getString("RemoteWorldSpots"));
0422:                treeNode1.add(subTreeNode2);
0423:                iterator = universeServer.getRemoteServers().iterator();
0424:                while (iterator.hasNext()) {
0425:                    remoteWorldSpotsAccess = (RemoteWorldSpotsAccess) iterator
0426:                            .next();
0427:                    subsubTreeNode = new DefaultMutableTreeNode(
0428:                            remoteWorldSpotsAccess.getInformation(
0429:                                    this .universeServer).get(
0430:                                    WorldSpot.STRING_NAME));
0431:                    subTreeNode2.add(subsubTreeNode);
0432:                }
0433:
0434:                treeNode2 = new DefaultMutableTreeNode(resourceBundle
0435:                        .getString("DistantServers"));
0436:                defaultMutableTreeNode.add(treeNode2);
0437:                iterator = universeServer.getGates().iterator();
0438:                while (iterator.hasNext()) {
0439:                    gate = (Gate) iterator.next();
0440:                    subTreeNode = new DefaultMutableTreeNode(gate
0441:                            .getInformation(this .universeServer).get(
0442:                                    WorldSpot.STRING_NAME));
0443:                    treeNode2.add(subTreeNode);
0444:                }
0445:
0446:                defaultTreeModel = new DefaultTreeModel(defaultMutableTreeNode);
0447:                defaultTreeModel
0448:                        .addTreeModelListener(new ServerTreeModelListener());
0449:
0450:                jTree1 = new JTree(defaultTreeModel);
0451:                jTree1.setEditable(true);
0452:                jTree1.getSelectionModel().setSelectionMode(
0453:                        TreeSelectionModel.SINGLE_TREE_SELECTION);
0454:                jTree1.putClientProperty("JTree.lineStyle", "Angled");
0455:                jTree1.setShowsRootHandles(true);
0456:
0457:                jScrollPane = new JScrollPane(jTree1);
0458:                jPanel5.add(jScrollPane);
0459:
0460:                jTree1.setPreferredSize(new Dimension(300, 256));
0461:                jTree1.setMinimumSize(new Dimension(300, 256));
0462:                jPanel5.add(jTree1);
0463:
0464:                this .getContentPane().add(jPanel5);
0465:
0466:                jPanel6.setPreferredSize(new Dimension(300, 35));
0467:                jPanel6.setMinimumSize(new Dimension(300, 35));
0468:
0469:                jButton4.setText(resourceBundle.getString("Add"));
0470:                jButton4.addActionListener(this );
0471:                jButton4.setToolTipText(resourceBundle
0472:                        .getString("AddToolTipText"));
0473:                jButton4.getAccessibleContext().setAccessibleDescription(
0474:                        resourceBundle.getString("AddAccessibleDescription"));
0475:                jPanel6.add(jButton4);
0476:
0477:                jButton5.setText(resourceBundle.getString("Delete"));
0478:                jButton5.addActionListener(this );
0479:                jButton5.setToolTipText(resourceBundle
0480:                        .getString("DeleteToolTipText"));
0481:                jButton5
0482:                        .getAccessibleContext()
0483:                        .setAccessibleDescription(
0484:                                resourceBundle
0485:                                        .getString("DeleteAccessibleDescription"));
0486:                jPanel6.add(jButton5);
0487:
0488:                jButton6.setText(resourceBundle.getString("Update"));
0489:                jButton6.addActionListener(this );
0490:                jButton6.setToolTipText(resourceBundle
0491:                        .getString("UpdateToolTipText"));
0492:                jButton6
0493:                        .getAccessibleContext()
0494:                        .setAccessibleDescription(
0495:                                resourceBundle
0496:                                        .getString("UpdateAccessibleDescription"));
0497:                jPanel6.add(jButton6);
0498:
0499:                this .getContentPane().add(jPanel6);
0500:
0501:                jPanel7.setPreferredSize(new Dimension(300, 35));
0502:                jPanel7.setMinimumSize(new Dimension(300, 35));
0503:
0504:                jButton7.setText(resourceBundle.getString("Add known gates"));
0505:                jButton7.addActionListener(this );
0506:                jButton7.setToolTipText(resourceBundle
0507:                        .getString("AddKnownGatesToolTipText"));
0508:                jButton7
0509:                        .getAccessibleContext()
0510:                        .setAccessibleDescription(
0511:                                resourceBundle
0512:                                        .getString("AddKnownGatesAccessibleDescription"));
0513:                jPanel7.add(jButton7);
0514:
0515:                jButton8.setText(resourceBundle.getString("Notify gates"));
0516:                jButton8.addActionListener(this );
0517:                jButton8.setToolTipText(resourceBundle
0518:                        .getString("NotifyGatesToolTipText"));
0519:                jButton8.getAccessibleContext().setAccessibleDescription(
0520:                        resourceBundle
0521:                                .getString("NotifyGatesAccessibleDescription"));
0522:                jPanel7.add(jButton8);
0523:
0524:                this .getContentPane().add(jPanel7);
0525:
0526:                jPanel8.setPreferredSize(new Dimension(300, 128));
0527:                jPanel8.setMinimumSize(new Dimension(300, 128));
0528:
0529:                jTextArea1.setPreferredSize(new Dimension(300, 128));
0530:                jTextArea1.setMinimumSize(new Dimension(300, 128));
0531:                jTextArea1.setToolTipText(resourceBundle
0532:                        .getString("LogToolTipText"));
0533:                jTextArea1.getAccessibleContext().setAccessibleDescription(
0534:                        resourceBundle.getString("LogAccessibleDescription"));
0535:                jTextArea1.setLineWrap(true);
0536:                jTextArea1.setWrapStyleWord(true);
0537:                jTextArea1.setEditable(false);
0538:                jPanel8.add(jTextArea1);
0539:
0540:                this .getContentPane().add(jPanel8);
0541:
0542:                this .setJMenuBar(menuBar);
0543:
0544:                Dimension screenSize = Toolkit.getDefaultToolkit()
0545:                        .getScreenSize();
0546:                Dimension dialogSize = this .getSize();
0547:
0548:                this .setSize(new Dimension(320, 510));
0549:                this .setLocation((screenSize.width - 320) / 2,
0550:                        (screenSize.height - 510) / 2);
0551:
0552:                timer = new javax.swing.Timer(500, this );
0553:                timer.setLogTimers(false);
0554:                timer.start();
0555:
0556:                this .pack();
0557:
0558:            }
0559:
0560:            private void addToLog(String string, int logLevel) {
0561:
0562:                Calendar rightNow;
0563:                String currentTime;
0564:
0565:                rightNow = Calendar.getInstance(TimeZone
0566:                        .getTimeZone(timeZoneIDs[currentTimeZoneIndex]),
0567:                        locales[currentTimeZoneIndex]);
0568:
0569:                currentTime = new String(" ");
0570:                currentTime.concat(new Integer(rightNow
0571:                        .get(Calendar.HOUR_OF_DAY)).toString());
0572:                currentTime.concat(":");
0573:                currentTime.concat(new Integer(rightNow.get(Calendar.MINUTE))
0574:                        .toString());
0575:                currentTime.concat(":");
0576:                currentTime.concat(new Integer(rightNow.get(Calendar.SECOND))
0577:                        .toString());
0578:                currentTime.concat(" ");
0579:
0580:                if (this .getLogLevel() >= logLevel) {
0581:                    jTextArea1.append(currentTime + string);
0582:                }
0583:
0584:            }
0585:
0586:            private void setTimeLabel(JLabel jLabel) {
0587:
0588:                Calendar rightNow;
0589:                String currentTime;
0590:
0591:                rightNow = Calendar.getInstance(TimeZone
0592:                        .getTimeZone(timeZoneIDs[currentTimeZoneIndex]),
0593:                        locales[currentTimeZoneIndex]);
0594:
0595:                //  SimpleDateFormat simpleDateFormat;
0596:                //  simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss", locale);
0597:                //
0598:                //  currentTime = simpleDateFormat.format(rightNow.getTime());
0599:
0600:                currentTime = new String(" ");
0601:                currentTime.concat(new Integer(rightNow
0602:                        .get(Calendar.HOUR_OF_DAY)).toString());
0603:                currentTime.concat(":");
0604:                currentTime.concat(new Integer(rightNow.get(Calendar.MINUTE))
0605:                        .toString());
0606:                currentTime.concat(":");
0607:                currentTime.concat(new Integer(rightNow.get(Calendar.SECOND))
0608:                        .toString());
0609:                currentTime.concat(" ");
0610:                jLabel.setText(resourceBundle.getString("CurrentTimeIs")
0611:                        + currentTime
0612:                        + resourceBundle.getString("WithOffSetIs"));
0613:
0614:            }
0615:
0616:            private void startServer() {
0617:
0618:                this .universeServer.start();
0619:                this .addToLog(resourceBundle.getString("ServerAction") + " "
0620:                        + resourceBundle.getString("ServerStarted"), 1);
0621:
0622:            }
0623:
0624:            public void actionPerformed(ActionEvent TheActionEvent) {
0625:
0626:                String login;
0627:                String password;
0628:                PublicKey publicKey;
0629:                LoginInformation loginInformation;
0630:                ClientInformation clientInformation;
0631:                Object TheObject;
0632:
0633:                TheObject = TheActionEvent.getSource();
0634:
0635:                if (TheObject instanceof  JComboBox) {
0636:
0637:                    currentTimeZoneIndex = jComboBox1.getSelectedIndex();
0638:
0639:                }
0640:                if (TheObject instanceof  javax.swing.Timer) {
0641:                    this .setTimeLabel(jLabel1);
0642:                } else if (TheObject instanceof  JMenuItem) {
0643:                    //      String arg = TheActionEvent.getActionCommand();
0644:                    if (TheObject == saveAsMenuItem) {
0645:                        this .TheSaveAsCommand();
0646:                    } else if (TheObject == exitMenuItem) {
0647:                        this .TheExitCommand();
0648:                    } else if (TheObject == cutMenuItem) {
0649:                        this .TheCutCommand();
0650:                    } else if (TheObject == copyMenuItem) {
0651:                        this .TheCopyCommand();
0652:                    } else if (TheObject == pasteMenuItem) {
0653:                        this .ThePasteCommand();
0654:                    } else if (TheObject == deleteMenuItem) {
0655:                        this .TheDeleteCommand();
0656:                    } else if (TheObject == informationMenuItem) {
0657:                        this .TheInformationCommand();
0658:                    } else if (TheObject == loginMenuItem) {
0659:                        this .TheLoginCommand();
0660:                    } else if (TheObject == connectionMenuItem) {
0661:                        this .TheConnectionCommand();
0662:                    } else if (((JMenuItem) TheObject).getParent() == languageMenu) {
0663:                        this .TheLanguageCommand((JMenuItem) TheObject);
0664:                    } else if (TheObject == contentsMenuItem) {
0665:                        this .TheContentsCommand();
0666:                    } else if (TheObject == aboutMenuItem) {
0667:                        this .TheAboutCommand();
0668:                    }
0669:                } else if (TheObject instanceof  JButton) {
0670:                    if (TheObject == jButton4) {
0671:                        this .TheAddGateCommand();
0672:                    }
0673:                    if (TheObject == jButton5) {
0674:                        this .TheDeleteGateCommand();
0675:                    }
0676:                    if (TheObject == jButton6) {
0677:                        this .TheUpdateGatesCommand();
0678:                    }
0679:                    if (TheObject == jButton7) {
0680:                        this .TheAddKnownGatesCommand();
0681:                    }
0682:                    if (TheObject == jButton8) {
0683:                        this .TheNotifyCommand();
0684:                    }
0685:                }
0686:            }
0687:
0688:            private void TheSaveAsCommand() {
0689:
0690:                JFileChooser jFileChooser;
0691:                FileOutputStream fileOutputStream;
0692:                int result;
0693:
0694:                //path of last save is NOT kept
0695:                jFileChooser = new JFileChooser();
0696:
0697:                jFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
0698:                result = jFileChooser.showSaveDialog(this );
0699:                if (result == JFileChooser.APPROVE_OPTION) {
0700:                    try {
0701:                        fileOutputStream = new FileOutputStream(jFileChooser
0702:                                .getSelectedFile());
0703:                        try {
0704:                            fileOutputStream.write(jTextArea1.getText()
0705:                                    .getBytes());
0706:                            fileOutputStream.flush();
0707:                            fileOutputStream.close();
0708:                        } catch (IOException iOException) {
0709:                        }
0710:                    } catch (FileNotFoundException fileNotFoundException) {
0711:                    }
0712:
0713:                } else {
0714:                    //JFileChooser.CANCEL_OPTION
0715:                }
0716:
0717:            }
0718:
0719:            private void TheExitCommand() {
0720:
0721:                JOptionPane jOptionPane;
0722:                JDialog jDialog;
0723:                int value;
0724:
0725:                jOptionPane = new JOptionPane(resourceBundle
0726:                        .getString("Close and Quit DigitalBiosphere Server ?"),
0727:                        JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);
0728:
0729:                jDialog = new JDialog(this , resourceBundle
0730:                        .getString("Close and Quit DigitalBiosphere Server ?"),
0731:                        true);
0732:                jDialog.setContentPane(jOptionPane);
0733:                jDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
0734:                jDialog.addWindowListener(new WindowAdapter() {
0735:                    public void windowClosing(WindowEvent we) {
0736:                    }
0737:                });
0738:                jOptionPane
0739:                        .addPropertyChangeListener(new ExitPropertyChangeListener(
0740:                                jDialog, jOptionPane));
0741:                jDialog.pack();
0742:                jDialog.setVisible(true);
0743:
0744:                value = ((Integer) jOptionPane.getValue()).intValue();
0745:                if (value == JOptionPane.YES_OPTION) {
0746:                    //quit the server
0747:                    this .universeServer.stop();
0748:                    helpSet = null;
0749:                    helpBroker = null;
0750:                    this .setVisible(false);
0751:                    this .dispose();
0752:                    System.exit(0);
0753:                } else if (value == JOptionPane.NO_OPTION) {
0754:                    //do nothing if user doesn't want to quit
0755:                }
0756:
0757:            }
0758:
0759:            private void TheCutCommand() {
0760:
0761:                //Null operation by now
0762:                //jTextArea1.cut();
0763:
0764:            }
0765:
0766:            private void TheCopyCommand() {
0767:
0768:                jTextArea1.copy();
0769:
0770:            }
0771:
0772:            private void ThePasteCommand() {
0773:
0774:                //Null operation by now
0775:                jTextArea1.paste();
0776:
0777:            }
0778:
0779:            private void TheDeleteCommand() {
0780:
0781:                //String textString;
0782:
0783:                //Null operation by now
0784:                //textString = jTextArea1.getText();
0785:                //if (jTextArea1.getSelectionStart()!=jTextArea1.getSelectionEnd()) {
0786:                //textString = textString.subString(0, jTextArea1.getSelectionStart()).concat(textString.subString(jTextArea1.getSelectionEnd(), textString.length()));
0787:                //jTextArea1.setText(textString);
0788:                //}
0789:
0790:            }
0791:
0792:            private void TheInformationCommand() {
0793:
0794:                InformationJDialog informationJDialog;
0795:
0796:                informationJDialog = new InformationJDialog(this ,
0797:                        this .universeServer.getInformation(),
0798:                        this .resourceBundle);
0799:                informationJDialog.show();
0800:
0801:            }
0802:
0803:            protected void setInformationJDialogResult(Hashtable information) {
0804:
0805:                this .universeServer.setInformation(information);
0806:                this .addToLog(resourceBundle.getString("ServerAction") + " "
0807:                        + resourceBundle.getString("ChangedLoginAndPassword"),
0808:                        1);
0809:
0810:            }
0811:
0812:            private void TheLoginCommand() {
0813:
0814:                LoginJDialog loginJDialog;
0815:
0816:                this .universeServer.getLoginInformation();
0817:                loginJDialog = new LoginJDialog(this , loginInformation,
0818:                        resourceBundle);
0819:                loginJDialog.show();
0820:
0821:            }
0822:
0823:            protected void setLoginJDialogResult(
0824:                    LoginInformation loginInformation) {
0825:
0826:                this .universeServer.setLoginInformation(loginInformation);
0827:                this .addToLog(resourceBundle.getString("ServerAction") + " "
0828:                        + resourceBundle.getString("ChangedInformation"), 1);
0829:
0830:            }
0831:
0832:            private void TheConnectionCommand() {
0833:
0834:                ConnectionJDialog connectionJDialog;
0835:
0836:                connectionJDialog = new ConnectionJDialog(this ,
0837:                        this .resourceBundle);
0838:                connectionJDialog.show();
0839:
0840:            }
0841:
0842:            protected void setConnectionJDialogResult(InetAddress inetAddress,
0843:                    int port) {
0844:
0845:                this .addToLog(resourceBundle.getString("ServerAction") + " "
0846:                        + resourceBundle.getString("ChangedIPorPort"), 1);
0847:                //quit the server
0848:                this .addToLog(resourceBundle.getString("ServerAction") + " "
0849:                        + resourceBundle.getString("QuittingServer"), 1);
0850:                this .universeServer.stop();
0851:                //restart the server
0852:                this .setIP(inetAddress);
0853:                this .setPort(port);
0854:                try {
0855:                    this .universeServer = new UniverseServer(this 
0856:                            .getLoginInformation(), this .getIP(), this 
0857:                            .getPort(), (WorldSpot) this .getWorldSpots()
0858:                            .iterator().next());
0859:                    this .addToLog(resourceBundle.getString("ServerAction")
0860:                            + " "
0861:                            + resourceBundle.getString("RestartingServer"), 1);
0862:                    //Add worldSpots, remote servers, gates
0863:
0864:                    this .universeServer.setLocalWorldSpots(worldSpots);
0865:                    this .universeServer.setRemoteServers(remoteServers);
0866:                    this .universeServer.setGates(gates);
0867:                    this .universeServer.start();
0868:                } catch (IOException iOException) {
0869:                    this 
0870:                            .addToLog(
0871:                                    resourceBundle.getString("ServerAction")
0872:                                            + " "
0873:                                            + resourceBundle
0874:                                                    .getString("UnableToRestartServer"),
0875:                                    1);
0876:                }
0877:
0878:            }
0879:
0880:            private void TheLanguageCommand(JMenuItem jMenuItem) {
0881:
0882:                locales = Locale.getAvailableLocales();
0883:                int currentLocale;
0884:
0885:                if (locales.length > 1) {
0886:                    currentLocale = 0;
0887:                    for (int i = 0; i < languageMenu.getItemCount(); i++) {
0888:                        if (locales[i].getDisplayLanguage(
0889:                                resourceBundle.getLocale()).equals(
0890:                                jMenuItem.getText())) {
0891:                            languageMenuItem.setSelected(true);
0892:                            currentLocale = i;
0893:                        } else {
0894:                            languageMenuItem.setSelected(false);
0895:                        }
0896:                    }
0897:                    resourceBundle = ResourceBundle.getBundle("ResourceBundle",
0898:                            locales[currentLocale]);
0899:                    this .repaint();
0900:                }
0901:
0902:            }
0903:
0904:            private void TheContentsCommand() {
0905:
0906:                if (helpSet == null) {
0907:                    this .createHelpSet();
0908:                }
0909:                helpBroker.setDisplayed(true);
0910:
0911:            }
0912:
0913:            private void createHelpSet() {
0914:
0915:                URL url;
0916:                ClassLoader loader;
0917:
0918:                loader = this .getClass().getClassLoader();
0919:
0920:                try {
0921:                    url = HelpSet.findHelpSet(loader, helpSetName);
0922:                    if (url == null) {
0923:                        //this.getCodeBase()
0924:                        url = new URL(new URL(System.getProperty("user.dir")),
0925:                                helpSetURL);
0926:                    }
0927:                    helpSet = new HelpSet(loader, url);
0928:                    helpBroker = helpSet.createHelpBroker();
0929:                } catch (Exception exception) {
0930:                    System.err.println("Trouble in HelpSet creation.");
0931:                    exception.printStackTrace();
0932:                }
0933:
0934:            }
0935:
0936:            private void TheAboutCommand() {
0937:
0938:                AboutJDialog aboutJDialog;
0939:
0940:                aboutJDialog = new AboutJDialog(this .resourceBundle);
0941:                aboutJDialog.show();
0942:
0943:            }
0944:
0945:            private void TheAddGateCommand() {
0946:
0947:                DefaultMutableTreeNode parentNode;
0948:                TreePath parentPath;
0949:                GateJDialog gateJDialog;
0950:                JFileChooser jFileChooser;
0951:                FileOutputStream fileOutputStream;
0952:                WorldSpot worldSpot;
0953:                DefaultMutableTreeNode childNode;
0954:                boolean shouldBeVisible;
0955:                int result;
0956:                URL uRL;
0957:                URL[] uRLs;
0958:                URLClassLoader uRLClassLoader;
0959:                DefaultMutableTreeNode subsubTreeNode;
0960:
0961:                Object[] objects;
0962:
0963:                int modifiers;
0964:                Constructor[] constructors;
0965:                Modifier modifier;
0966:                Class[] classes;
0967:                Class aClass;
0968:
0969:                shouldBeVisible = true;
0970:
0971:                parentPath = jTree1.getSelectionPath();
0972:
0973:                if (parentPath == null) {
0974:                    parentNode = defaultMutableTreeNode;
0975:                } else {
0976:                    parentNode = (DefaultMutableTreeNode) (parentPath
0977:                            .getLastPathComponent());
0978:                }
0979:
0980:                if ((parentNode == subTreeNode2) || (parentNode == treeNode2)) {
0981:                    gateJDialog = new GateJDialog(this , this .resourceBundle);
0982:                    gateJDialog.show();
0983:                } else {
0984:                    if (parentNode == subTreeNode1) {
0985:                        //path of last save is NOT kept
0986:                        jFileChooser = new JFileChooser();
0987:                        jFileChooser
0988:                                .setFileSelectionMode(JFileChooser.FILES_ONLY);
0989:                        result = jFileChooser.showOpenDialog(this );
0990:                        if (result == JFileChooser.APPROVE_OPTION) {
0991:                            //this.getCodeBase()
0992:                            try {
0993:                                uRL = new URL(System.getProperty("user.dir"));
0994:                                uRLs = new URL[1];
0995:                                uRLs[0] = uRL;
0996:                                uRLClassLoader = new URLClassLoader(uRLs);
0997:
0998:                                try {
0999:
1000:                                    aClass = (Class) uRLClassLoader
1001:                                            .loadClass(jFileChooser
1002:                                                    .getSelectedFile()
1003:                                                    .getName());
1004:
1005:                                    modifiers = aClass.getModifiers();
1006:                                    modifier = new Modifier();
1007:                                    if (aClass
1008:                                            .isAssignableFrom(WorldSpot.class)) {
1009:                                        if (!(modifier.isAbstract(modifiers))
1010:                                                && !(modifier
1011:                                                        .isPrivate(modifiers))
1012:                                                && !(modifier
1013:                                                        .isInterface(modifiers))) {
1014:                                            constructors = aClass
1015:                                                    .getDeclaredConstructors();
1016:                                            if (constructors.length > 0) {
1017:                                                classes = constructors[0]
1018:                                                        .getParameterTypes();
1019:                                                if (((classes[0]
1020:                                                        .equals("[Lcom.db.server.UniverseServer")) && (classes[1]
1021:                                                        .equals("[Lcom.db.world.Avatar")))
1022:                                                        || ((classes[0]
1023:                                                                .equals("[Lcom.db.server.UniverseServer"))
1024:                                                                && (classes[1]
1025:                                                                        .equals("[Lcom.db.world.Avatar")) && (classes[1]
1026:                                                                .equals("[Ljavax.media.j3d.Bounds")))) {
1027:                                                    objects = new Object[2];
1028:                                                    objects[0] = this .universeServer;
1029:                                                    objects[1] = this 
1030:                                                            .newRuler();
1031:                                                    try {
1032:                                                        worldSpot = (WorldSpot) constructors[0]
1033:                                                                .newInstance(objects);
1034:                                                        //check if does not exist
1035:                                                        if (!this 
1036:                                                                .getWorldSpots()
1037:                                                                .contains(
1038:                                                                        worldSpot)) {
1039:                                                            this 
1040:                                                                    .addWorldSpot(worldSpot);
1041:                                                            this .universeServer
1042:                                                                    .addLocalWorldSpot(worldSpot);
1043:                                                            //add to JTree
1044:                                                            childNode = new DefaultMutableTreeNode(
1045:                                                                    worldSpot
1046:                                                                            .getName());
1047:                                                            subTreeNode1
1048:                                                                    .add(childNode);
1049:
1050:                                                            // Make sure the user can see the lovely new node.
1051:                                                            if (shouldBeVisible) {
1052:                                                                jTree1
1053:                                                                        .scrollPathToVisible(new TreePath(
1054:                                                                                childNode
1055:                                                                                        .getPath()));
1056:                                                            }
1057:                                                        }
1058:                                                    }
1059:                                                    //InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
1060:                                                    catch (Exception exception) {
1061:                                                    }
1062:                                                }
1063:                                            }
1064:                                        }
1065:                                    }
1066:
1067:                                } catch (ClassNotFoundException classNotFoundException) {
1068:                                }
1069:
1070:                            } catch (IOException iOException) {
1071:                            }
1072:                        } else {
1073:                            //JFileChooser.CANCEL_OPTION
1074:                        }
1075:                    }
1076:                }
1077:
1078:            }
1079:
1080:            //adds a gate or a remote world spot
1081:            protected void setGateJDialogResult(String name,
1082:                    InetAddress inetAddress, int port) {
1083:
1084:                DefaultMutableTreeNode parentNode;
1085:                TreePath parentPath;
1086:                Gate gate;
1087:                RemoteWorldSpotsAccess remoteWorldSpotsAccess;
1088:                boolean shouldBeVisible;
1089:                HashSet remoteWorldSpots;
1090:                Hashtable information;
1091:                TreeNode childNode;
1092:
1093:                information = new Hashtable();
1094:                information.put(WorldSpot.STRING_NAME, name);
1095:
1096:                shouldBeVisible = true;
1097:
1098:                this .addToLog(resourceBundle.getString("ServerAction") + " "
1099:                        + resourceBundle.getString("AddGate"), 1);
1100:
1101:                parentPath = jTree1.getSelectionPath();
1102:
1103:                if (parentPath == null) {
1104:                    parentNode = defaultMutableTreeNode;
1105:                } else {
1106:                    parentNode = (DefaultMutableTreeNode) (parentPath
1107:                            .getLastPathComponent());
1108:                }
1109:
1110:                if (parentNode == subTreeNode2) {
1111:                    remoteWorldSpots = new HashSet();
1112:                    remoteWorldSpotsAccess = new RemoteWorldSpotsAccess(
1113:                            information, inetAddress, port, remoteWorldSpots);
1114:                    this .universeServer.addRemoteServer(remoteWorldSpotsAccess);
1115:
1116:                } else if (parentNode == treeNode2) {
1117:                    gate = new Gate(information, inetAddress, port);
1118:                    this .universeServer.addGate(gate);
1119:
1120:                }
1121:
1122:                childNode = new DefaultMutableTreeNode(name);
1123:                parentNode.add((MutableTreeNode) childNode);
1124:                //jTree1.getModel().insertNodeInto(childNode, parentNode, parentNode.getChildCount());
1125:
1126:                // Make sure the user can see the lovely new node.
1127:                if (shouldBeVisible) {
1128:                    jTree1.scrollPathToVisible(new TreePath(
1129:                            ((DefaultMutableTreeNode) childNode)
1130:                                    .getUserObjectPath()));
1131:                }
1132:
1133:            }
1134:
1135:            private void TheDeleteGateCommand() {
1136:
1137:                TreePath currentSelection;
1138:                DefaultMutableTreeNode currentNode;
1139:                MutableTreeNode parent;
1140:                Iterator iterator;
1141:                boolean found;
1142:                WorldSpot worldSpot;
1143:                RemoteWorldSpotsAccess remoteWorldSpotsAccess;
1144:                Gate gate;
1145:
1146:                this .addToLog(resourceBundle.getString("ServerAction") + " "
1147:                        + resourceBundle.getString("DeleteGate"), 1);
1148:
1149:                currentSelection = jTree1.getSelectionPath();
1150:                if (currentSelection != null) {
1151:                    currentNode = (DefaultMutableTreeNode) (currentSelection
1152:                            .getLastPathComponent());
1153:                    parent = (MutableTreeNode) (currentNode.getParent());
1154:                    if (parent != null) {
1155:                        if (!((parent == defaultMutableTreeNode)
1156:                                || (parent == treeNode1)
1157:                                || (parent == subTreeNode1)
1158:                                || (parent == subTreeNode2) || (parent == treeNode2))) {
1159:                            if (parent == subTreeNode1) {
1160:                                iterator = this .universeServer
1161:                                        .getLocalWorldSpots().iterator();
1162:                                found = false;
1163:                                worldSpot = null;
1164:                                while (iterator.hasNext() || (!found)) {
1165:                                    worldSpot = (WorldSpot) iterator.next();
1166:                                    found = worldSpot
1167:                                            .getName()
1168:                                            .equals(
1169:                                                    (String) ((DefaultMutableTreeNode) currentNode)
1170:                                                            .getUserObject());
1171:                                }
1172:                                if (found) {
1173:                                    this .universeServer
1174:                                            .removeLocalWorldSpot(worldSpot);
1175:                                    defaultTreeModel
1176:                                            .removeNodeFromParent(currentNode);
1177:                                }
1178:                            } else {
1179:                                if (parent == subTreeNode2) {
1180:                                    iterator = this .universeServer
1181:                                            .getRemoteServers().iterator();
1182:                                    found = false;
1183:                                    remoteWorldSpotsAccess = null;
1184:                                    while (iterator.hasNext() || (!found)) {
1185:                                        remoteWorldSpotsAccess = (RemoteWorldSpotsAccess) iterator
1186:                                                .next();
1187:                                        found = remoteWorldSpotsAccess
1188:                                                .getInformation(
1189:                                                        this .universeServer)
1190:                                                .get(WorldSpot.STRING_NAME)
1191:                                                .equals(
1192:                                                        (String) currentNode
1193:                                                                .getUserObject());
1194:                                    }
1195:                                    if (found) {
1196:                                        this .universeServer
1197:                                                .removeRemoteServer(remoteWorldSpotsAccess);
1198:                                        defaultTreeModel
1199:                                                .removeNodeFromParent(currentNode);
1200:                                    }
1201:                                } else {
1202:                                    if (parent == treeNode2) {
1203:                                        iterator = universeServer.getGates()
1204:                                                .iterator();
1205:                                        found = false;
1206:                                        gate = null;
1207:                                        while (iterator.hasNext() || (!found)) {
1208:                                            gate = (Gate) iterator.next();
1209:                                            found = gate
1210:                                                    .getInformation(
1211:                                                            this .universeServer)
1212:                                                    .get(WorldSpot.STRING_NAME)
1213:                                                    .equals(
1214:                                                            (String) currentNode
1215:                                                                    .getUserObject());
1216:                                        }
1217:                                        if (found) {
1218:                                            this .universeServer
1219:                                                    .removeGate(gate);
1220:                                            defaultTreeModel
1221:                                                    .removeNodeFromParent(currentNode);
1222:                                        }
1223:                                    }
1224:
1225:                                }
1226:
1227:                            }
1228:
1229:                        }
1230:                    }
1231:                }
1232:
1233:                // Either there was no selection, or an invalid node was selected.
1234:
1235:            }
1236:
1237:            //with current implementation does not remove invalid gates
1238:            //but fetches information about remote World Spots
1239:            private void TheUpdateGatesCommand() {
1240:
1241:                Iterator iterator;
1242:                RemoteWorldSpotsAccess remoteWorldSpotsAccess;
1243:                DefaultMutableTreeNode subsubTreeNode;
1244:
1245:                this .addToLog(resourceBundle.getString("ServerAction") + " "
1246:                        + resourceBundle.getString("UpdateGates"), 1);
1247:                //this.universeServer.updateRemoteServersList();
1248:                this .universeServer.updateRemoteServers();
1249:                //this.universeServer.updateGates();
1250:                subTreeNode2.removeAllChildren();
1251:                iterator = this .universeServer.getRemoteServers().iterator();
1252:                while (iterator.hasNext()) {
1253:                    remoteWorldSpotsAccess = (RemoteWorldSpotsAccess) iterator
1254:                            .next();
1255:                    subsubTreeNode = new DefaultMutableTreeNode(
1256:                            remoteWorldSpotsAccess.getInformation(
1257:                                    this .universeServer).get(
1258:                                    WorldSpot.STRING_NAME));
1259:                    subTreeNode2.add(subsubTreeNode);
1260:                }
1261:                defaultTreeModel.reload();
1262:
1263:            }
1264:
1265:            private void TheAddKnownGatesCommand() {
1266:
1267:                Iterator iterator;
1268:                Gate gate;
1269:                DefaultMutableTreeNode subTreeNode;
1270:
1271:                this .addToLog(resourceBundle.getString("ServerAction") + " "
1272:                        + resourceBundle.getString("UpdateGates"), 1);
1273:                this .universeServer.queryServerHelper();
1274:                treeNode2.removeAllChildren();
1275:                iterator = this .universeServer.getGates().iterator();
1276:                while (iterator.hasNext()) {
1277:                    gate = (Gate) iterator.next();
1278:                    subTreeNode = new DefaultMutableTreeNode(gate
1279:                            .getInformation(this .universeServer).get(
1280:                                    WorldSpot.STRING_NAME));
1281:                    treeNode2.add(subTreeNode);
1282:                }
1283:                defaultTreeModel.reload();
1284:
1285:            }
1286:
1287:            private void TheNotifyCommand() {
1288:
1289:                this .addToLog(resourceBundle.getString("ServerAction") + " "
1290:                        + resourceBundle.getString("Notify"), 1);
1291:                this .universeServer.notifyLocalWorldSpotUpdate();
1292:
1293:            }
1294:
1295:            //Universe Server front end
1296:            public void main(String[] args) {
1297:
1298:                DigitalBiosphereServer digitalBiosphereServer;
1299:                ResourceBundle resourceBundle;
1300:                Locale locale;
1301:
1302:                locale = new Locale(new String("en"), new String("US"));
1303:                resourceBundle = ResourceBundle.getBundle("ResourceBundle",
1304:                        locale);
1305:
1306:                SplashWindow.showSplashscreen("splash.jpg");
1307:
1308:                SplashWindow.showMessage(resourceBundle
1309:                        .getString("InitialisingHelp"));
1310:                this .createHelpSet();
1311:
1312:                //build the gui side
1313:                SplashWindow.showMessage(resourceBundle
1314:                        .getString("BuildingGUI"));
1315:                digitalBiosphereServer = new DigitalBiosphereServer(args,
1316:                        resourceBundle);
1317:
1318:                //start the real server
1319:                digitalBiosphereServer.startServer();
1320:                SplashWindow.showMessage(resourceBundle
1321:                        .getString("StartingServer"));
1322:
1323:                digitalBiosphereServer
1324:                        .addWindowListener(digitalBiosphereServer);
1325:                digitalBiosphereServer.show();
1326:
1327:                SplashWindow.destroySplashscreen();
1328:
1329:            }
1330:
1331:            public static void usage() {
1332:                System.err
1333:                        .println("Usage : java DigitalBiosphereServer [-ip ipnumber] [-port portnumber] [-login login] [-password password] [-loglevel level] worldspostclassname(s)");
1334:                System.exit(1);
1335:            }
1336:
1337:            public String getAppletInfo() {
1338:
1339:                return new String(resourceBundle
1340:                        .getString("CopyrightInformation"));
1341:
1342:            }
1343:
1344:            //IP defaults to local host
1345:            //port defaults to 777
1346:            //login defaults to anonymous
1347:            //password defaults to anonymous
1348:            //loglevel defaults to 0 (minimal log)
1349:            public String[][] getParameterInfo() {
1350:
1351:                String[][] info = {
1352:                        { "ip", "string",
1353:                                resourceBundle.getString("IPParameter") },
1354:                        { "port", "int",
1355:                                resourceBundle.getString("PortParameter") },
1356:                        { "login", "string",
1357:                                resourceBundle.getString("LoginParameter") },
1358:                        { "password", "string",
1359:                                resourceBundle.getString("PasswordParameter") },
1360:                        { "log", "int",
1361:                                resourceBundle.getString("LogParameter") }, };
1362:                return info;
1363:
1364:            }
1365:
1366:            private InetAddress getIP() {
1367:
1368:                return this .ip;
1369:
1370:            }
1371:
1372:            private int getPort() {
1373:
1374:                return this .port;
1375:
1376:            }
1377:
1378:            private LoginInformation getLoginInformation() {
1379:
1380:                return this .loginInformation;
1381:
1382:            }
1383:
1384:            private int getLogLevel() {
1385:
1386:                return this .logLevel;
1387:
1388:            }
1389:
1390:            private void setIP(InetAddress inetAddress) {
1391:
1392:                this .ip = inetAddress;
1393:
1394:            }
1395:
1396:            private void setPort(int port) {
1397:
1398:                this .port = port;
1399:
1400:            }
1401:
1402:            private void setLoginInformation(LoginInformation loginInformation) {
1403:
1404:                this .loginInformation = loginInformation;
1405:
1406:            }
1407:
1408:            private void setLogLevel(int level) {
1409:
1410:                this .logLevel = level;
1411:
1412:            }
1413:
1414:            private Avatar newRuler() {
1415:
1416:                return this .universeServer.createRuler(this .loginInformation);
1417:
1418:            }
1419:
1420:            private void addWorldSpot(WorldSpot worldSpot) {
1421:
1422:                this .worldSpots.add(worldSpot);
1423:
1424:            }
1425:
1426:            private HashSet getWorldSpots() {
1427:
1428:                return this .worldSpots;
1429:
1430:            }
1431:
1432:            private void parseArgs(String[] args) {
1433:
1434:                ArrayList arrayList;
1435:                LoginInformation loginInformation;
1436:                String login;
1437:                String password;
1438:
1439:                URL uRL;
1440:                URL[] uRLs;
1441:                URLClassLoader uRLClassLoader;
1442:                WorldSpot worldSpot;
1443:                Object[] objects;
1444:
1445:                int modifiers;
1446:                Constructor[] constructors;
1447:                Modifier modifier;
1448:                Class[] classes;
1449:                Class aClass;
1450:
1451:                try {
1452:                    this .setIP(InetAddress.getLocalHost());
1453:                } catch (UnknownHostException unknownHostException) {
1454:                }
1455:
1456:                login = DefaultLogin;
1457:                password = DefaultPassword;
1458:
1459:                this .setPort(UniverseServer.DefaultServerPort);
1460:                this .setLogLevel(this .DefaultLoglevel);
1461:                loginInformation = new LoginInformation(this .DefaultLogin,
1462:                        this .DefaultPassword);
1463:                this .setLoginInformation(loginInformation);
1464:
1465:                arrayList = new ArrayList(args.length);
1466:
1467:                for (int i = 0; i < args.length; i++) {
1468:                    arrayList.add(i, args[i]);
1469:                }
1470:
1471:                while (arrayList.size() > 0) {
1472:                    if (arrayList.get(0) == "-ip") {
1473:                        if (arrayList.size() > 1) {
1474:                            try {
1475:                                this 
1476:                                        .setIP(InetAddress
1477:                                                .getAllByName((String) arrayList
1478:                                                        .get(1))[0]);
1479:                            } catch (UnknownHostException unknownHostException) {
1480:                            }
1481:                            arrayList.remove(0);
1482:                            arrayList.remove(1);
1483:                        } else {
1484:                            System.err.println(resourceBundle
1485:                                    .getString("MissingArgumentsError"));
1486:                        }
1487:                    } else if (arrayList.get(0) == "-port") {
1488:                        if (arrayList.size() > 1) {
1489:                            try {
1490:                                this .setPort(new Integer((String) arrayList
1491:                                        .get(1)).intValue());
1492:                            } catch (NumberFormatException exception) {
1493:                                System.err.println(resourceBundle
1494:                                        .getString("InvalidArgumentsError"));
1495:                            }
1496:                            arrayList.remove(0);
1497:                            arrayList.remove(1);
1498:                        } else {
1499:                            System.err.println(resourceBundle
1500:                                    .getString("MissingArgumentsError"));
1501:                        }
1502:                    } else if (arrayList.get(0) == "-login") {
1503:                        if (arrayList.size() > 1) {
1504:                            login = (String) arrayList.get(1);
1505:                            arrayList.remove(0);
1506:                            arrayList.remove(1);
1507:                        } else {
1508:                            System.err.println(resourceBundle
1509:                                    .getString("MissingArgumentsError"));
1510:                        }
1511:                    } else if (arrayList.get(0) == "-password") {
1512:                        if (arrayList.size() > 1) {
1513:                            password = (String) arrayList.get(1);
1514:                            arrayList.remove(0);
1515:                            arrayList.remove(1);
1516:                        } else {
1517:                            System.err.println(resourceBundle
1518:                                    .getString("MissingArgumentsError"));
1519:                        }
1520:                    }
1521:                    if (arrayList.get(0) == "-loglevel") {
1522:                        if (arrayList.size() > 1) {
1523:                            try {
1524:                                this .setLogLevel(new Integer((String) arrayList
1525:                                        .get(1)).intValue());
1526:                            } catch (NumberFormatException exception) {
1527:                                System.err.println(resourceBundle
1528:                                        .getString("InvalidArgumentsError"));
1529:                            }
1530:                            arrayList.remove(0);
1531:                            arrayList.remove(1);
1532:                        } else {
1533:                            System.err.println(resourceBundle
1534:                                    .getString("MissingArgumentsError"));
1535:                        }
1536:                    } else if (((String) arrayList.get(0)).startsWith("-")) {
1537:                        System.err.println(resourceBundle
1538:                                .getString("ExcessArgumentsError")
1539:                                + arrayList.get(0));
1540:                    } else {
1541:                        try {
1542:                            uRL = new URL((String) arrayList.get(0));
1543:                            uRLs = new URL[1];
1544:                            uRLs[0] = uRL;
1545:
1546:                            uRLClassLoader = new URLClassLoader(uRLs);
1547:
1548:                            try {
1549:                                aClass = (Class) uRLClassLoader
1550:                                        .loadClass((String) arrayList.get(0));
1551:
1552:                                modifiers = aClass.getModifiers();
1553:                                modifier = new Modifier();
1554:                                if (aClass.isAssignableFrom(WorldSpot.class)) {
1555:                                    if (!(modifier.isAbstract(modifiers))
1556:                                            && !(modifier.isPrivate(modifiers))
1557:                                            && !(modifier
1558:                                                    .isInterface(modifiers))) {
1559:                                        constructors = aClass
1560:                                                .getDeclaredConstructors();
1561:                                        if (constructors.length > 0) {
1562:                                            classes = constructors[0]
1563:                                                    .getParameterTypes();
1564:                                            if (((classes[0]
1565:                                                    .equals("[Lcom.db.server.UniverseServer")) && (classes[1]
1566:                                                    .equals("[Lcom.db.world.Avatar")))
1567:                                                    || ((classes[0]
1568:                                                            .equals("[Lcom.db.server.UniverseServer"))
1569:                                                            && (classes[1]
1570:                                                                    .equals("[Lcom.db.world.Avatar")) && (classes[1]
1571:                                                            .equals("[Ljavax.media.j3d.Bounds")))) {
1572:                                                objects = new Object[2];
1573:                                                objects[0] = this .universeServer;
1574:                                                objects[1] = this .newRuler();
1575:                                                try {
1576:                                                    worldSpot = (WorldSpot) constructors[0]
1577:                                                            .newInstance(objects);
1578:                                                    this 
1579:                                                            .addWorldSpot(worldSpot);
1580:                                                }
1581:                                                //InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
1582:                                                catch (Exception exception) {
1583:                                                }
1584:                                            }
1585:                                        }
1586:                                    }
1587:                                }
1588:                            } catch (ClassNotFoundException classNotFoundException) {
1589:                            }
1590:                        } catch (MalformedURLException malformedURLException) {
1591:                        }
1592:                        arrayList.remove(0);
1593:                    }
1594:                }
1595:
1596:                if ((login != null) && (password != null)) {
1597:                    loginInformation = new LoginInformation(login, password);
1598:                    this .setLoginInformation(loginInformation);
1599:                }
1600:                if (!this .getWorldSpots().iterator().hasNext()) {
1601:                    System.err.println(resourceBundle
1602:                            .getString("MissingArgumentsError")
1603:                            + arrayList.get(0));
1604:                }
1605:
1606:            }
1607:
1608:            public void windowActivated(WindowEvent e) {
1609:
1610:            }
1611:
1612:            public void windowClosed(WindowEvent e) {
1613:
1614:            }
1615:
1616:            public void windowClosing(WindowEvent e) {
1617:
1618:                this .TheExitCommand();
1619:
1620:            }
1621:
1622:            public void windowDeactivated(WindowEvent e) {
1623:
1624:            }
1625:
1626:            public void windowDeiconified(WindowEvent e) {
1627:
1628:            }
1629:
1630:            public void windowIconified(WindowEvent e) {
1631:
1632:            }
1633:
1634:            public void windowOpened(WindowEvent e) {
1635:
1636:            }
1637:
1638:            private class ServerTreeModelListener implements  TreeModelListener {
1639:                public void treeNodesChanged(TreeModelEvent e) {
1640:                    DefaultMutableTreeNode node;
1641:                    node = (DefaultMutableTreeNode) (e.getTreePath()
1642:                            .getLastPathComponent());
1643:
1644:                    /*
1645:                     * If the event lists children, then the changed
1646:                     * node is the child of the node we've already
1647:                     * gotten.  Otherwise, the changed node and the
1648:                     * specified node are the same.
1649:                     */
1650:                    try {
1651:                        int index = e.getChildIndices()[0];
1652:                        node = (DefaultMutableTreeNode) (node.getChildAt(index));
1653:                    } catch (NullPointerException exc) {
1654:                    }
1655:
1656:                }
1657:
1658:                public void treeNodesInserted(TreeModelEvent e) {
1659:                }
1660:
1661:                public void treeNodesRemoved(TreeModelEvent e) {
1662:                }
1663:
1664:                public void treeStructureChanged(TreeModelEvent e) {
1665:                }
1666:            }
1667:
1668:            private class ExitPropertyChangeListener implements 
1669:                    PropertyChangeListener {
1670:
1671:                private JDialog jDialog;
1672:                private JOptionPane jOptionPane;
1673:
1674:                public ExitPropertyChangeListener(JDialog jDialog,
1675:                        JOptionPane jOptionPane) {
1676:
1677:                    this .jDialog = jDialog;
1678:                    this .jOptionPane = jOptionPane;
1679:
1680:                }
1681:
1682:                public void propertyChange(
1683:                        PropertyChangeEvent propertyChangeEvent) {
1684:
1685:                    String property = propertyChangeEvent.getPropertyName();
1686:
1687:                    if (jDialog.isVisible()
1688:                            && (propertyChangeEvent.getSource() == jOptionPane)
1689:                            && (property.equals(JOptionPane.VALUE_PROPERTY) || property
1690:                                    .equals(JOptionPane.INPUT_VALUE_PROPERTY))) {
1691:                        //If you were going to check something
1692:                        //before closing the window, you'd do
1693:                        //it here.
1694:                        jDialog.setVisible(false);
1695:                    }
1696:                }
1697:            }
1698:
1699:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.