Source Code Cross Referenced for JtaDiscRack.java in  » J2EE » enhydra » jtaDiscRack » 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 » J2EE » enhydra » jtaDiscRack 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package jtaDiscRack;
002:
003:        import org.enhydra.dods.*;
004:
005:        import javax.swing.*;
006:        import java.util.*;
007:        import java.awt.*;
008:        import java.awt.event.*;
009:        import java.net.*;
010:        import java.io.*;
011:
012:        /**
013:         * The main class of DiscRack application.
014:         *
015:         * @author Sasa Bojanic
016:         * @version 1.0
017:         */
018:        public class JtaDiscRack extends JPanel {
019:            // Application Title and other stuff. From resource file.
020:            private static final String appTitle = "JtaDiscRack";
021:            // Application Icon. From resource file.
022:            private static ImageIcon appIcon;
023:
024:            /**
025:             * Checks if java version is >= 1.4, sets application title and icon, as
026:             * well as logo icon.
027:             */
028:            static {
029:                try {
030:                    String vers = System.getProperty("java.version");
031:                    if (vers.compareTo("1.") < 0) {
032:                        System.out
033:                                .println("!!!WARNING: Application must be run with a "
034:                                        + "1.4 or higher version VM!!!");
035:                    }
036:
037:                    // Icon
038:                    URL url = ResourceManager.getResource("Icon");
039:                    if (url != null)
040:                        appIcon = new ImageIcon(url);
041:
042:                    try {
043:                        //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
044:                        UIManager.setLookAndFeel(UIManager
045:                                .getSystemLookAndFeelClassName());
046:                    } catch (Exception exc) {
047:                        System.err.println("Error loading L&F: " + exc);
048:                    }
049:                } catch (Throwable t) {
050:                    System.err.println("uncaught exception: " + t);
051:                    t.printStackTrace();
052:                }
053:            }
054:
055:            // The frame of application
056:            protected JFrame myFrame;
057:
058:            protected Hashtable commands;
059:            protected JMenuBar menubar;
060:            protected JToolBar toolbar;
061:            /**
062:             * Actions defined by the WorkflowAdmin class
063:             */
064:            protected Action[] defaultActions;
065:
066:            private JScrollPane helperJSP = new JScrollPane();
067:            private JPanel centralPanel = new JPanel();
068:
069:            //************************** CONSTRUCTOR ***********************
070:            /** Creates instance of main application class. */
071:            public JtaDiscRack() {
072:                super (true);
073:
074:                setBorder(BorderFactory.createEtchedBorder());
075:                setLayout(new BorderLayout());
076:
077:                commands = new Hashtable();
078:                // Actions defined by the ProcessEditor class
079:                createActions();
080:                Action[] actions = getActions();
081:                for (int i = 0; i < actions.length; i++) {
082:                    Action a = actions[i];
083:                    commands.put(a.getValue(Action.NAME), a);
084:                }
085:
086:                menubar = BarFactory.createMenubar("menubar", commands);
087:                // adding menubar to the main panel
088:                add(menubar, BorderLayout.NORTH);
089:                // adding center component
090:                JPanel helperPanel = new JPanel();
091:                helperPanel.setLayout(new BorderLayout());
092:
093:                toolbar = (JToolBar) BarFactory.createToolbar("toolbar",
094:                        commands);
095:                helperPanel.add(toolbar, BorderLayout.NORTH);
096:                helperJSP.setViewportView(centralPanel);
097:                helperPanel.add(helperJSP, BorderLayout.CENTER);
098:                //add(centralPanel,BorderLayout.CENTER);
099:                add(helperPanel, BorderLayout.CENTER);
100:
101:                myFrame = new JFrame();
102:                myFrame.setBackground(Color.lightGray);
103:                myFrame.getContentPane().setLayout(new BorderLayout());
104:                myFrame.getContentPane().add(this , BorderLayout.CENTER);
105:                myFrame
106:                        .setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
107:                myFrame.addWindowListener(new AppCloser());
108:                myFrame.pack();
109:                Dimension screenSize = Toolkit.getDefaultToolkit()
110:                        .getScreenSize();
111:                int xSize = 950, ySize = 600;
112:                int xMinus, yMinus;
113:                if (screenSize.width > xSize) {
114:                    xMinus = screenSize.width - xSize;
115:                } else {
116:                    xMinus = 0;
117:                }
118:                if (screenSize.height > ySize) {
119:                    yMinus = screenSize.height - ySize;
120:                } else {
121:                    yMinus = 0;
122:                }
123:
124:                myFrame.setBounds(xMinus / 2, yMinus / 2, screenSize.width
125:                        - xMinus, screenSize.height - yMinus);
126:
127:                if (appIcon != null)
128:                    myFrame.setIconImage(appIcon.getImage());
129:                setTitleUser(null);
130:
131:                getAction("Logout").setEnabled(false);
132:                myFrame.show();
133:                getAction("Login").actionPerformed(null);
134:
135:            }
136:
137:            //************************* END OF WORKLISTHANDLER CONSTRUCTOR *****************
138:
139:            public void setTitleUser(String user) {
140:                if (user == null) {
141:                    user = "no logged user";
142:                }
143:                myFrame.setTitle(appTitle + " - " + user);
144:            }
145:
146:            //************** APPCLOSER CLASS FOR CLOSING APPLICATION WINDOW ***************
147:            /**
148:             * To shutdown when run as an application.
149:             */
150:            protected final class AppCloser extends WindowAdapter {
151:                public void windowClosing(WindowEvent e) {
152:                    getAction("Exit").actionPerformed(null);
153:                }
154:            }
155:
156:            //**** END OF CREATING APPLICATION CLOSER COMPONENT FOR APPLICATION WINDOW ****
157:
158:            // ************************* GETTING ACTION STUFF *****************************
159:            protected void createActions() {
160:                defaultActions = new Action[] {
161:                        new jtaDiscRack.actions.Exit(this ),
162:                        new jtaDiscRack.actions.Login(this ),
163:                        new jtaDiscRack.actions.Logout(this ),
164:                        new jtaDiscRack.actions.Register(this ), };
165:            }
166:
167:            /**
168:             * Fetch the list of actions supported by this app.
169:             */
170:            public Action[] getActions() {
171:                return defaultActions;
172:            }
173:
174:            /**
175:             * Method to get action corresponding to the given string.
176:             * @param cmd String representation of editor's action.
177:             * @return action specified by the string cmd.
178:             **/
179:            public Action getAction(String cmd) {
180:                return (Action) commands.get(cmd);
181:            }
182:
183:            // ********************* END OF GETTING ACTION STUFF **************************
184:
185:            //*********************** END OF EXIT ACTION CLASS *************************
186:
187:            public JFrame getFrame() {
188:                return myFrame;
189:            }
190:
191:            public String getAppTitle() {
192:                return appTitle;
193:            }
194:
195:            public void setCentralPanel(JPanel p) {
196:                centralPanel = p;
197:                helperJSP.setViewportView(centralPanel);
198:            }
199:
200:            public static void main(String[] args) {
201:                try {
202:                    /*
203:                     * Initialize Application configuration file path
204:                     */
205:                    String conFilePath = null;
206:                    String userDir = System.getProperty("user.dir");
207:                    conFilePath = userDir + File.separator + "conf"
208:                            + File.separator + "jtaDiscRack.conf";
209:
210:                    if (args.length > 0) {
211:                        String tempPath = args[0];
212:                        File tempConfFile = new File(tempPath);
213:                        if (tempConfFile.exists()) {
214:                            conFilePath = tempConfFile.getCanonicalPath();
215:                        }
216:                    }
217:
218:                    /*
219:                     * Initialize JNDI, JOTM and Datasource JNDI context instance
220:                     */
221:                    org.enhydra.dods.jts.LocalContextFactory
222:                            .setup("jtaDiscRackDB");
223:
224:                    /*
225:                     * Initialize and configure DODS instalce
226:                     */
227:                    DODS.startup(conFilePath);
228:
229:                    /*
230:                     * Start application
231:                     */
232:                    JtaDiscRack jdr = new JtaDiscRack();
233:                } catch (Exception ex) {
234:                    ex.printStackTrace();
235:                    System.exit(0);
236:                }
237:            }
238:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.