Source Code Cross Referenced for ApplicationProperties.java in  » UML » MetaBoss » com » metaboss » applications » designstudio » 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 » UML » MetaBoss » com.metaboss.applications.designstudio 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002:        // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003:        // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004:        // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005:        // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006:        // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007:        // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008:        // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009:        // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010:        // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011:        // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012:        // POSSIBILITY OF SUCH DAMAGE.
013:        //
014:        // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015:        package com.metaboss.applications.designstudio;
016:
017:        import java.awt.Dimension;
018:        import java.awt.Rectangle;
019:        import java.awt.Toolkit;
020:        import java.io.File;
021:        import java.util.ArrayList;
022:        import java.util.StringTokenizer;
023:
024:        import com.metaboss.applications.designstudio.components.Rule;
025:        import com.metaboss.applications.designstudio.userobjects.ModelUserObject;
026:
027:        /*		Application Propeties Class 		*/
028:
029:        public class ApplicationProperties {
030:            public static final String GRID_SIZE = "GridSize";
031:            public static final String USE_GRID = "UseGrid";
032:            public static final String SHOW_GRID = "ShowGrid";
033:            public static final String SHOW_EDGESLABELS = "ShowEdgesLabels";
034:            public static final String SHOW_EDGESCARDINALITY = "ShowEdgesCardinality";
035:            public static final String SHOW_EDGESENDS = "ShowEdgesEnds";
036:            public static final String PORTS_VISIBLE = "PortsVisible";
037:            public static final String RULER_VISIBLE = "RulerVisible";
038:            public static final String RULER_MODE = "RulerMode";
039:            public static final String SHOW_TOOLTIP = "ShowToolTip";
040:            //public static final String CLOSEBUTTON_REGIME = "CloseButtonRegime";
041:            public static final String FRAME_POSITION = "MainFrameBounds";
042:            public static final String DEVIDER_LOCATION = "DeviderLocation";
043:            public static final String RIGHTDEVIDER_LOCATION = "RightDeviderLocation";
044:            public static final String VIEW_STATUSBAR = "ViewStatusBar";
045:            public static final String VIEW_PROPERTIESBAR = "ViewPropertiesBar";
046:            public static final String VIEW_SYSTEMLOG = "ViewSystemLog";
047:            public static final String MODEL_VALIDATE = "ModelValidate";
048:            public static final String MODEL_VALIDATEONSAVE = "ModelValidateOnSave";
049:            public static final String MODEL = "Model";
050:            public static final String REOPEN_MODEL = "ReopenModel";
051:            public static final String LASTDIR = "LastDir";
052:
053:            public int mGridSize = 1;
054:            public boolean mUseGrid = false;
055:            public boolean mShowGrid = false;
056:            public boolean mShowEdgesLabels = true;
057:            public boolean mShowEdgesCardinality = false;
058:            public boolean mShowEdgesEndsNames = false;
059:            public boolean mPortsVisible = false;
060:            public boolean mShowToolTip = false;
061:            public boolean mShowRuler = true;
062:            public int mRulerMode = Rule.RM_METRIC;
063:            //public int			mCloseButtonRegime = TabPanel.CB_VISIBLE;
064:            public Rectangle mMainFrameBounds = null;
065:            public int mDeviderLocation = 0;
066:            public int mRightDeviderLocation = 0;
067:            public boolean mViewStatusBar = true;
068:            public boolean mViewPropertiesBar = true;
069:            public boolean mViewSystemLog = true;
070:            public boolean mAutoValidateModel = false;
071:            public boolean mValidateModelOnSave = true;
072:            public String mLastDir = null;
073:            public ArrayList mPreLoadModels = new ArrayList();
074:            public ArrayList mReopenModels = new ArrayList();
075:
076:            public ApplicationProperties() {
077:                setDefaultValues();
078:            }
079:
080:            public void saveProperties() {
081:                UserPreferences.setProperty(GRID_SIZE, new Integer(mGridSize)
082:                        .toString());
083:                UserPreferences.setProperty(USE_GRID, new Boolean(mUseGrid)
084:                        .toString());
085:                UserPreferences.setProperty(SHOW_GRID, new Boolean(mShowGrid)
086:                        .toString());
087:                UserPreferences.setProperty(SHOW_EDGESLABELS, new Boolean(
088:                        mShowEdgesLabels).toString());
089:                UserPreferences.setProperty(SHOW_EDGESCARDINALITY, new Boolean(
090:                        mShowEdgesCardinality).toString());
091:                UserPreferences.setProperty(SHOW_EDGESENDS, new Boolean(
092:                        mShowEdgesEndsNames).toString());
093:                UserPreferences.setProperty(PORTS_VISIBLE, new Boolean(
094:                        mPortsVisible).toString());
095:                UserPreferences.setProperty(SHOW_TOOLTIP, new Boolean(
096:                        mShowToolTip).toString());
097:                UserPreferences.setProperty(RULER_VISIBLE, new Boolean(
098:                        mShowRuler).toString());
099:                UserPreferences.setProperty(RULER_MODE, new Integer(mRulerMode)
100:                        .toString());
101:                //UserPreferences.setProperty(CLOSEBUTTON_REGIME, new Integer(mCloseButtonRegime).toString());
102:                UserPreferences.setProperty(FRAME_POSITION,
103:                        rectangleToString(mMainFrameBounds));
104:                UserPreferences.setProperty(DEVIDER_LOCATION, new Integer(
105:                        mDeviderLocation).toString());
106:                UserPreferences.setProperty(RIGHTDEVIDER_LOCATION, new Integer(
107:                        mRightDeviderLocation).toString());
108:                UserPreferences.setProperty(VIEW_STATUSBAR, new Boolean(
109:                        mViewStatusBar).toString());
110:                UserPreferences.setProperty(VIEW_PROPERTIESBAR, new Boolean(
111:                        mViewPropertiesBar).toString());
112:                UserPreferences.setProperty(VIEW_SYSTEMLOG, new Boolean(
113:                        mViewSystemLog).toString());
114:                UserPreferences.setProperty(MODEL_VALIDATE, new Boolean(
115:                        mAutoValidateModel).toString());
116:                UserPreferences.setProperty(MODEL_VALIDATEONSAVE, new Boolean(
117:                        mValidateModelOnSave).toString());
118:                UserPreferences.setProperty(LASTDIR, mLastDir);
119:
120:                int k = 0;
121:                for (int i = 0; i < Application.getModelsCount(); i++) {
122:                    ModelUserObject lModel = Application.getModel(i);
123:                    if (lModel != null && !lModel.isSystem()) {
124:                        File lFile = new File(lModel.getFileName());
125:                        if (lFile.exists()) {
126:                            UserPreferences.setProperty(MODEL
127:                                    + new Integer(k).toString(), lModel
128:                                    .getFileName());
129:                            k++;
130:                        }
131:                    }
132:                }
133:                UserPreferences.setProperty(MODEL + new Integer(k).toString(),
134:                        "");
135:
136:                k = 0;
137:                for (int i = 0; i < mReopenModels.size(); i++) {
138:                    String lFileName = (String) mReopenModels.get(i);
139:                    File lFile = new File(lFileName);
140:                    if (lFile.exists()) {
141:                        UserPreferences.setProperty(REOPEN_MODEL
142:                                + new Integer(k).toString(), lFileName);
143:                        k++;
144:                    }
145:                }
146:                UserPreferences.setProperty(REOPEN_MODEL
147:                        + new Integer(k).toString(), "");
148:
149:                UserPreferences.save();
150:            }
151:
152:            public void loadProperties() {
153:                try {
154:                    String lSetting = UserPreferences.getProperty(GRID_SIZE);
155:                    String lUseGridSetting = UserPreferences
156:                            .getProperty(USE_GRID);
157:                    String lShowGridSetting = UserPreferences
158:                            .getProperty(SHOW_GRID);
159:                    String lShowEdgesLablesSetting = UserPreferences
160:                            .getProperty(SHOW_EDGESLABELS);
161:                    String lShowEdgesCardinalitySetting = UserPreferences
162:                            .getProperty(SHOW_EDGESCARDINALITY);
163:                    String lShowEdgesEndsSetting = UserPreferences
164:                            .getProperty(SHOW_EDGESENDS);
165:                    String lPortsVisibleSetting = UserPreferences
166:                            .getProperty(PORTS_VISIBLE);
167:                    String lRulerVisibleSetting = UserPreferences
168:                            .getProperty(RULER_VISIBLE);
169:                    String lRulerModeSetting = UserPreferences
170:                            .getProperty(RULER_MODE);
171:                    String lShowToolTipString = UserPreferences
172:                            .getProperty(SHOW_TOOLTIP);
173:                    //String			lCloseButtonRegime = UserPreferences.getProperty(CLOSEBUTTON_REGIME);
174:                    String lBoundsSetting = UserPreferences
175:                            .getProperty(FRAME_POSITION);
176:                    String lDeviderString = UserPreferences
177:                            .getProperty(DEVIDER_LOCATION);
178:                    String lRightDeviderString = UserPreferences
179:                            .getProperty(RIGHTDEVIDER_LOCATION);
180:                    String lViewStatusBarString = UserPreferences
181:                            .getProperty(VIEW_STATUSBAR);
182:                    String lViewPropertiesBarString = UserPreferences
183:                            .getProperty(VIEW_PROPERTIESBAR);
184:                    String lViewSystemLogString = UserPreferences
185:                            .getProperty(VIEW_SYSTEMLOG);
186:                    String lModelValidateString = UserPreferences
187:                            .getProperty(MODEL_VALIDATE);
188:                    String lModelValidateOnSaveString = UserPreferences
189:                            .getProperty(MODEL_VALIDATEONSAVE);
190:
191:                    StringTokenizer lBoundsTokenizer = (lBoundsSetting != null) ? new StringTokenizer(
192:                            lBoundsSetting, ",", false)
193:                            : null;
194:
195:                    mGridSize = (lSetting != null) ? Integer.parseInt(lSetting)
196:                            : 1;
197:                    mUseGrid = (lUseGridSetting != null) ? Boolean.valueOf(
198:                            lUseGridSetting).booleanValue() : false;
199:                    mShowGrid = (lShowGridSetting != null) ? Boolean.valueOf(
200:                            lShowGridSetting).booleanValue() : false;
201:                    mShowEdgesLabels = (lShowEdgesLablesSetting != null) ? Boolean
202:                            .valueOf(lShowEdgesLablesSetting).booleanValue()
203:                            : true;
204:                    mShowEdgesCardinality = (lShowEdgesCardinalitySetting != null) ? Boolean
205:                            .valueOf(lShowEdgesCardinalitySetting)
206:                            .booleanValue()
207:                            : false;
208:                    mShowEdgesEndsNames = (lShowEdgesEndsSetting != null) ? Boolean
209:                            .valueOf(lShowEdgesEndsSetting).booleanValue()
210:                            : false;
211:                    mPortsVisible = (lPortsVisibleSetting != null) ? Boolean
212:                            .valueOf(lPortsVisibleSetting).booleanValue()
213:                            : false;
214:                    mShowToolTip = (lShowToolTipString != null) ? Boolean
215:                            .valueOf(lShowToolTipString).booleanValue() : false;
216:                    mShowRuler = (lRulerVisibleSetting != null) ? Boolean
217:                            .valueOf(lRulerVisibleSetting).booleanValue()
218:                            : true;
219:                    mRulerMode = (lRulerModeSetting != null) ? Integer
220:                            .parseInt(lRulerModeSetting) : Rule.RM_METRIC;
221:                    //mCloseButtonRegime = (lCloseButtonRegime!=null) ? Integer.parseInt(lCloseButtonRegime) : TabPanel.CB_VISIBLE;
222:                    mMainFrameBounds = (lBoundsTokenizer != null) ? new Rectangle(
223:                            Integer.parseInt(lBoundsTokenizer.nextToken()),
224:                            Integer.parseInt(lBoundsTokenizer.nextToken()),
225:                            Integer.parseInt(lBoundsTokenizer.nextToken()),
226:                            Integer.parseInt(lBoundsTokenizer.nextToken()))
227:                            : createDefaultRectangle();
228:                    mDeviderLocation = (lDeviderString != null) ? Integer
229:                            .parseInt(lDeviderString) : 0;
230:                    mRightDeviderLocation = (lRightDeviderString != null) ? Integer
231:                            .parseInt(lRightDeviderString)
232:                            : 0;
233:                    mViewStatusBar = (lViewStatusBarString != null) ? Boolean
234:                            .valueOf(lViewStatusBarString).booleanValue()
235:                            : true;
236:                    mViewPropertiesBar = (lViewPropertiesBarString != null) ? Boolean
237:                            .valueOf(lViewPropertiesBarString).booleanValue()
238:                            : true;
239:                    mViewSystemLog = (lViewSystemLogString != null) ? Boolean
240:                            .valueOf(lViewSystemLogString).booleanValue()
241:                            : true;
242:                    mAutoValidateModel = (lModelValidateString != null) ? Boolean
243:                            .valueOf(lModelValidateString).booleanValue()
244:                            : false;
245:                    mValidateModelOnSave = (lModelValidateOnSaveString != null) ? Boolean
246:                            .valueOf(lModelValidateOnSaveString).booleanValue()
247:                            : true;
248:                    mLastDir = UserPreferences.getProperty(LASTDIR);
249:                } catch (Exception e) {
250:                    e.printStackTrace();
251:                    setDefaultValues();
252:                }
253:                readPreLoadModels();
254:                readReopenModels();
255:            }
256:
257:            public void addToReopen(String pFileName) {
258:                File lFile = new File(pFileName);
259:                if (lFile.exists())
260:                    mReopenModels.add(0, pFileName);
261:            }
262:
263:            public void removeFromReopen(String pFileName) {
264:                int lIndex = findFileNameIndex(pFileName, mReopenModels);
265:                if (lIndex > -1)
266:                    mReopenModels.remove(lIndex);
267:            }
268:
269:            // convert rectangle to string 	
270:            private String rectangleToString(Rectangle lRectangle) {
271:                return Integer.toString((int) lRectangle.getX()) + ","
272:                        + Integer.toString((int) lRectangle.getY()) + ","
273:                        + Integer.toString((int) lRectangle.getWidth()) + ","
274:                        + Integer.toString((int) lRectangle.getHeight());
275:            }
276:
277:            // read preload file names
278:            private void readPreLoadModels() {
279:                mPreLoadModels.clear();
280:
281:                int k = 0;
282:                while (true) {
283:                    try {
284:                        String lFileName = UserPreferences.getProperty(MODEL
285:                                + new Integer(k).toString());
286:                        if (lFileName != null && lFileName.length() > 0) {
287:                            if (findFileNameIndex(lFileName, mPreLoadModels) < 0)
288:                                mPreLoadModels.add(lFileName);
289:                            k++;
290:                        } else
291:                            break;
292:                    } catch (Exception e) {
293:                        break;
294:                    }
295:                }
296:            }
297:
298:            // read reopen file names
299:            private void readReopenModels() {
300:                mReopenModels.clear();
301:
302:                int k = 0;
303:                int n = 0;
304:                while (true) {
305:                    try {
306:                        String lFileName = UserPreferences
307:                                .getProperty(REOPEN_MODEL
308:                                        + new Integer(k).toString());
309:                        if (lFileName != null && lFileName.length() > 0) {
310:                            if (findFileNameIndex(lFileName, mReopenModels) < 0
311:                                    && findFileNameIndex(lFileName,
312:                                            mPreLoadModels) < 0) {
313:                                mReopenModels.add(lFileName);
314:                                n++;
315:                            }
316:                            k++;
317:                        } else
318:                            break;
319:                    } catch (Exception e) {
320:                        break;
321:                    }
322:                    if (n == 4)
323:                        break;
324:                }
325:            }
326:
327:            public int findFileNameIndex(String pFileName, ArrayList pList) {
328:                for (int i = 0; i < pList.size(); i++) {
329:                    String lFileName = (String) pList.get(i);
330:                    if (lFileName.equals(pFileName))
331:                        return i;
332:                }
333:                return -1;
334:            }
335:
336:            // set default values
337:            public void setDefaultValues() {
338:                mGridSize = 1;
339:                mUseGrid = false;
340:                mShowGrid = false;
341:                mShowEdgesLabels = true;
342:                mPortsVisible = false;
343:                mShowToolTip = false;
344:                mShowRuler = true;
345:                mRulerMode = Rule.RM_METRIC;
346:                //mCloseButtonRegime = TabPanel.CB_VISIBLE;
347:                mMainFrameBounds = createDefaultRectangle();
348:                mDeviderLocation = 0;
349:                mRightDeviderLocation = 0;
350:                mViewStatusBar = true;
351:                mViewPropertiesBar = true;
352:                mViewSystemLog = true;
353:                mAutoValidateModel = false;
354:                mValidateModelOnSave = true;
355:                mLastDir = null;
356:            }
357:
358:            private Rectangle createDefaultRectangle() {
359:                Dimension screenSize = Toolkit.getDefaultToolkit()
360:                        .getScreenSize();
361:                return new Rectangle((int) (screenSize.getWidth() / 4),
362:                        (int) (screenSize.getHeight() / 4), (int) (screenSize
363:                                .getWidth() / 2),
364:                        (int) (screenSize.getHeight() / 2));
365:            }
366:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.