Source Code Cross Referenced for Application.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) 


0001:        // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
0002:        // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
0003:        // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
0004:        // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
0005:        // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
0006:        // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0007:        // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
0008:        // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
0009:        // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
0010:        // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
0011:        // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
0012:        // POSSIBILITY OF SUCH DAMAGE.
0013:        //
0014:        // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
0015:        package com.metaboss.applications.designstudio;
0016:
0017:        import java.awt.AWTEvent;
0018:        import java.awt.Container;
0019:        import java.awt.Cursor;
0020:        import java.awt.Dimension;
0021:        import java.awt.EventQueue;
0022:        import java.awt.Font;
0023:        import java.awt.Graphics;
0024:        import java.awt.Toolkit;
0025:        import java.awt.image.BufferedImage;
0026:        import java.io.File;
0027:        import java.util.ArrayList;
0028:        import java.util.Collection;
0029:        import java.util.EventListener;
0030:        import java.util.Iterator;
0031:        import java.util.List;
0032:        import java.util.Properties;
0033:        import java.util.ResourceBundle;
0034:
0035:        import javax.naming.Context;
0036:        import javax.naming.InitialContext;
0037:        import javax.swing.AbstractButton;
0038:        import javax.swing.Action;
0039:        import javax.swing.ButtonGroup;
0040:        import javax.swing.Icon;
0041:        import javax.swing.ImageIcon;
0042:        import javax.swing.JButton;
0043:        import javax.swing.JCheckBoxMenuItem;
0044:        import javax.swing.JComponent;
0045:        import javax.swing.JFileChooser;
0046:        import javax.swing.JMenu;
0047:        import javax.swing.JMenuItem;
0048:        import javax.swing.JOptionPane;
0049:        import javax.swing.JPopupMenu;
0050:        import javax.swing.JToggleButton;
0051:        import javax.swing.JToolBar;
0052:        import javax.swing.UIManager;
0053:
0054:        import org.apache.commons.logging.Log;
0055:        import org.apache.commons.logging.LogFactory;
0056:        import org.apache.log4j.Appender;
0057:        import org.apache.log4j.Layout;
0058:        import org.apache.log4j.Level;
0059:        import org.apache.log4j.Logger;
0060:        import org.apache.log4j.SimpleLayout;
0061:        import org.apache.log4j.WriterAppender;
0062:        import org.jgraph.graph.GraphConstants;
0063:
0064:        import com.jgoodies.plaf.FontSizeHints;
0065:        import com.jgoodies.plaf.Options;
0066:        import com.metaboss.applications.designstudio.auxilarydialogs.AboutDialog;
0067:        import com.metaboss.applications.designstudio.auxilarydialogs.CopyElementDialog;
0068:        import com.metaboss.applications.designstudio.auxilarydialogs.SaveContentDialog;
0069:        import com.metaboss.applications.designstudio.auxilarydialogs.SplashScreen;
0070:        import com.metaboss.applications.designstudio.components.ContainerAction;
0071:        import com.metaboss.applications.designstudio.components.ModelFileFilter;
0072:        import com.metaboss.applications.designstudio.components.SeparatorAction;
0073:        import com.metaboss.applications.designstudio.components.ToolBarSeparator;
0074:        import com.metaboss.applications.designstudio.icons.IconsHolder;
0075:        import com.metaboss.applications.designstudio.systemlog.LogOutputStream;
0076:        import com.metaboss.applications.designstudio.userobjects.ModelUserObject;
0077:        import com.metaboss.applications.designstudio.userobjects.UserObjectFactory;
0078:        import com.metaboss.enterprise.bs.BSNamingAndDirectoryServiceInvocationException;
0079:        import com.metaboss.licensing.LicenseService;
0080:        import com.metaboss.sdlctools.models.ModelRepository;
0081:        import com.metaboss.sdlctools.models.ModelValidationException;
0082:        import com.metaboss.sdlctools.models.impl.metabossmodel.ModelElementResolverImpl;
0083:        import com.metaboss.sdlctools.models.metabossmodel.MetaBossModelPackage;
0084:        import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
0085:        import com.metaboss.sdlctools.models.metabossmodel.ModelUtils;
0086:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.AbstractNamespace;
0087:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataDictionary;
0088:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataType;
0089:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Namespace;
0090:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Structure;
0091:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.TypeTemplate;
0092:        import com.metaboss.sdlctools.models.metabossmodel.designlibrarymodel.DesignLibrary;
0093:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Enterprise;
0094:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Message;
0095:        import com.metaboss.sdlctools.models.metabossmodel.technologylibrarymodel.RelationalStorageTechnology;
0096:        import com.metaboss.sdlctools.models.metabossmodel.visualmodel.Diagram;
0097:
0098:        /*		Metaboss design Studio application class			*/
0099:
0100:        public class Application extends JComponent {
0101:            // Model Repository
0102:            public static ModelRepository sModelRepository = null;
0103:            public static ArrayList sModelErrors = new ArrayList();
0104:            public static String sErrorElement = null;
0105:            public static ArrayList sModels = new ArrayList();
0106:            public static ModelChangesListener sModelListener = new ModelChangesListener();
0107:            // The path for the user and system settings for the application
0108:            public static final String sApplicationPath = "/com/metaboss/applications/designstudio";
0109:            public static final String sApplicationName = "MetaBossDesignStudio";
0110:            // properties file name
0111:            public static final String PROPERTIES_FILE = "MetaBossDesignStudio.properties";
0112:            // default application font 
0113:            public static final Font DEFAULT_FONT = new Font("Dialog",
0114:                    Font.PLAIN, 11);
0115:            public static final Font DEFAULT_FONT_BOLD = new Font("Dialog",
0116:                    Font.BOLD, 11);
0117:            public static final Font DEFAULT_FONT_SMALL = new Font("Dialog",
0118:                    Font.PLAIN, 8);
0119:            public static final Font EDITOR_FONT = new Font("Courier New",
0120:                    Font.PLAIN, 12);
0121:            public static final Font VERTEX_FONT = GraphConstants.defaultFont
0122:                    .deriveFont(Font.BOLD, 12);
0123:            // resource strings
0124:            public static ResourceBundle resStrings = null;
0125:            // properties
0126:            public static ApplicationProperties properties = new ApplicationProperties();
0127:            public static Object sClassInitialisationSemaphore = new Object();
0128:            public static LicenseService sLicenseService = null;
0129:            // Application 
0130:            public static Application instance = null;
0131:            public static MainFrame mainFrame = null;
0132:            public static SplashScreen splash = null;
0133:            // icons
0134:            public static ImageIcon METABOSS_LOGO = IconsHolder
0135:                    .loadIcon("MBLogo.png");
0136:            public static ImageIcon METABOSS_ICON = IconsHolder
0137:                    .loadIcon("MetaBoss.gif");
0138:            public static ImageIcon ADD_ICON = IconsHolder.loadIcon("add.gif");
0139:            public static ImageIcon ADDNEW_ICON = IconsHolder
0140:                    .loadIcon("AddNew.gif");
0141:            public static ImageIcon ASSOCIATION_ICON = IconsHolder
0142:                    .loadIcon("ModelElement_Association.gif");
0143:            public static ImageIcon ATTRIBUTE_ICON = IconsHolder
0144:                    .loadIcon("ModelElement_Attribute.gif");
0145:            //public static ImageIcon				ENTITY_ICON	= IconsHolder.loadIcon("ModelElement_Entity.gif");
0146:            public static ImageIcon ENTITY_ICON = IconsHolder
0147:                    .loadIcon("Graph_Entity.gif");
0148:            public static ImageIcon REPORT_ICON = IconsHolder
0149:                    .loadIcon("ModelElement_Report.gif");
0150:            public static ImageIcon MESSAGE_ICON = IconsHolder
0151:                    .loadIcon("ModelElement_Message.gif");
0152:            public static ImageIcon DOMAIN_ICON = IconsHolder
0153:                    .loadIcon("ModelElement_Domain.gif");
0154:            public static ImageIcon FIELDS_ICON = IconsHolder
0155:                    .loadIcon("Fields.gif");
0156:            public static ImageIcon ENTERPRISE_ICON = IconsHolder
0157:                    .loadIcon("ModelElement_Enterprise.gif");
0158:            public static ImageIcon SYSTEM_ICON = IconsHolder
0159:                    .loadIcon("ModelElement_System.gif");
0160:            public static ImageIcon PRIMARYKEY_ICON = IconsHolder
0161:                    .loadIcon("ModelElement_PrimaryKeyElement.gif");
0162:            public static ImageIcon SERVICEMODULE_ICON = IconsHolder
0163:                    .loadIcon("ModelElement_Servicemodule.gif");
0164:            public static ImageIcon SERVICEMODULESERVICE_ICON = IconsHolder
0165:                    .loadIcon("ModelElement_Service.gif");
0166:            public static ImageIcon STRUCTURE_ICON = IconsHolder
0167:                    .loadIcon("ModelElement_Structure.gif");
0168:            public static ImageIcon EDIT_ICON = IconsHolder
0169:                    .loadIcon("Edit.gif");
0170:            public static ImageIcon DELETE_ICON = IconsHolder
0171:                    .loadIcon("Delete.gif");
0172:            public static ImageIcon VIEWSTRUCTURE_ICON = IconsHolder
0173:                    .loadIcon("ViewStructure.gif");
0174:            public static ImageIcon VIEWSOURCE_ICON = IconsHolder
0175:                    .loadIcon("ViewSource.gif");
0176:            public static ImageIcon ADDSOURCE_ICON = IconsHolder
0177:                    .loadIcon("AddSource.gif");
0178:            public static ImageIcon DELETESOURCE_ICON = IconsHolder
0179:                    .loadIcon("DeleteSource.gif");
0180:            public static ImageIcon OPTIONS_ICON = IconsHolder
0181:                    .loadIcon("Options.gif");
0182:            public static ImageIcon SELECTOR_ICON = IconsHolder
0183:                    .loadIcon("ModelElement_Selector.gif");
0184:            public static ImageIcon ASSOCIATIONROLE_ICON = IconsHolder
0185:                    .loadIcon("ModelElement_AssociationRole.gif");
0186:            public static ImageIcon APPLICATION_ICON = IconsHolder
0187:                    .loadIcon("Application.gif");
0188:            public static ImageIcon STATE_ICON = IconsHolder
0189:                    .loadIcon("ModelElement_State.gif");
0190:            public static ImageIcon SEARCH_ICON = IconsHolder
0191:                    .loadIcon("Search.gif");
0192:            public static ImageIcon PRINT_ICON = IconsHolder
0193:                    .loadIcon("Print.gif");
0194:            public static ImageIcon BRINGTOFRONT_ICON = IconsHolder
0195:                    .loadIcon("BringToFront.gif");
0196:            public static ImageIcon BRINGTOBACK_ICON = IconsHolder
0197:                    .loadIcon("BringToBack.gif");
0198:            public static ImageIcon NORMALSIZE_ICON = IconsHolder
0199:                    .loadIcon("NormalSize.gif");
0200:            public static ImageIcon ZOOMIN_ICON = IconsHolder
0201:                    .loadIcon("ZoomIn.gif");
0202:            public static ImageIcon ZOOMOUT_ICON = IconsHolder
0203:                    .loadIcon("ZoomOut.gif");
0204:            public static ImageIcon FITTOSIZE_ICON = IconsHolder
0205:                    .loadIcon("FitToSize.gif");
0206:            public static ImageIcon UNSELECT_ICON = IconsHolder
0207:                    .loadIcon("Unselect.gif");
0208:            public static ImageIcon REFRESH_ICON = IconsHolder
0209:                    .loadIcon("Refresh.gif");
0210:            public static ImageIcon DATATYPE_ICON = IconsHolder
0211:                    .loadIcon("ModelElement_DataType.gif");
0212:            public static ImageIcon TYPETEMPLATE_ICON = IconsHolder
0213:                    .loadIcon("ModelElement_TypeTemplate.gif");
0214:            public static ImageIcon PROPERTY_ICON = IconsHolder
0215:                    .loadIcon("ModelElement_Property.gif");
0216:            public static ImageIcon PROPERTYDESCRIPTOR_ICON = IconsHolder
0217:                    .loadIcon("ModelElement_PropertyDescriptor.gif");
0218:            public static ImageIcon STATETRANSITION_ICON = IconsHolder
0219:                    .loadIcon("ModelElement_Transition.gif");
0220:            public static ImageIcon ALIGNTOGRID_ICON = IconsHolder
0221:                    .loadIcon("AlignToGrid.gif");
0222:            public static ImageIcon DOMAINCLASSDIAGRAM_ICON = IconsHolder
0223:                    .loadIcon("DomainClassDiagram.gif");
0224:            public static ImageIcon STATESDIAGRAM_ICON = IconsHolder
0225:                    .loadIcon("StatesDiagram.gif");
0226:            public static ImageIcon SYSTEMSDIAGRAM_ICON = IconsHolder
0227:                    .loadIcon("SystemsDiagram.gif");
0228:            public static ImageIcon SAVE_ICON = IconsHolder
0229:                    .loadIcon("Save.gif");
0230:            public static ImageIcon CHECK_ICON = IconsHolder
0231:                    .loadIcon("check.gif");
0232:            public static ImageIcon UNCHECK_ICON = IconsHolder
0233:                    .loadIcon("uncheck.gif");
0234:            public static ImageIcon SERVICEIMPL_ICON = IconsHolder
0235:                    .loadIcon("serviceimpl.gif");
0236:            public static ImageIcon OPERATION_ICON = IconsHolder
0237:                    .loadIcon("ModelElement_Operation.gif");
0238:            public static ImageIcon OUTMESSAGE_ICON = IconsHolder
0239:                    .loadIcon("ModelElement_OperationOutputMessage.gif");
0240:            public static ImageIcon REPORTOUTPUTELEMENT_ICON = IconsHolder
0241:                    .loadIcon("ModelElement_ReportOutputElement.gif");
0242:            public static ImageIcon CLASSDIAGRAM_ICON = IconsHolder
0243:                    .loadIcon("ClassDiagram.gif");
0244:            public static ImageIcon NAMESPACE_ICON = IconsHolder
0245:                    .loadIcon("ModelElement_Namespace.gif");
0246:            public static ImageIcon STORAGE_ICON = IconsHolder
0247:                    .loadIcon("ModelElement_StorageTechnology.gif");
0248:            public static ImageIcon DATADICTIONARY_ICON = IconsHolder
0249:                    .loadIcon("ModelElement_DataDictionary.gif");
0250:            public static ImageIcon VALIDATE_ICON = IconsHolder
0251:                    .loadIcon("Validate.gif");
0252:            public static ImageIcon KEYELEMENT_ICON = IconsHolder
0253:                    .loadIcon("KeyElement.gif");
0254:            public static ImageIcon ADDALLATTRIBUTES_ICON = IconsHolder
0255:                    .loadIcon("AddAllAttributes.gif");
0256:            public static ImageIcon DESIGNLIB_ICON = IconsHolder
0257:                    .loadIcon("ModelElement_DesignLibrary.gif");
0258:            public static ImageIcon TECHLIB_ICON = IconsHolder
0259:                    .loadIcon("ModelElement_TechnologyLibrary.gif");
0260:            public static ImageIcon OPEN_ICON = IconsHolder
0261:                    .loadIcon("Open.gif");
0262:            public static ImageIcon LIBRARY_ICON = IconsHolder
0263:                    .loadIcon("Library.gif");
0264:            public static ImageIcon COPYTOCLIP_ICON = IconsHolder
0265:                    .loadIcon("CopyToClipboard.gif");
0266:            public static ImageIcon CLEAR_ICON = IconsHolder
0267:                    .loadIcon("Clear.gif");
0268:            public static ImageIcon ENTITYTABLE_ICON = IconsHolder
0269:                    .loadIcon("EntityTable.gif");
0270:            public static ImageIcon ASSOCIATIONTABLE_ICON = IconsHolder
0271:                    .loadIcon("AssociationTable.gif");
0272:            public static ImageIcon TABLE_ICON = IconsHolder
0273:                    .loadIcon("Table.gif");
0274:            public static ImageIcon ATTRIBUTECOLUMN_ICON = IconsHolder
0275:                    .loadIcon("ModelElement_AttributeColumn.gif");
0276:            public static ImageIcon EXPORTXMI_ICON = IconsHolder
0277:                    .loadIcon("ExportXMI.gif");
0278:            public static ImageIcon DOMAINIMPL_ICON = IconsHolder
0279:                    .loadIcon("ModelElement_DomainImplementation.gif");
0280:            public static ImageIcon STATEMACHINE_ICON = IconsHolder
0281:                    .loadIcon("ModelElement_StateMachine.gif");
0282:            public static ImageIcon LEFT_ICON = IconsHolder
0283:                    .loadIcon("Left.gif");
0284:            public static ImageIcon LEFTLEFT_ICON = IconsHolder
0285:                    .loadIcon("LeftLeft.gif");
0286:            public static ImageIcon RIGHT_ICON = IconsHolder
0287:                    .loadIcon("Right.gif");
0288:            public static ImageIcon RIGHTRIGHT_ICON = IconsHolder
0289:                    .loadIcon("RightRight.gif");
0290:            public static ImageIcon COPYELEMENT_ICON = IconsHolder
0291:                    .loadIcon("CopyElement.gif");
0292:            public static ImageIcon INPUTFIELD_ICON = IconsHolder
0293:                    .loadIcon("ModelElement_InputField.gif");
0294:            public static ImageIcon OUTPUTFIELD_ICON = IconsHolder
0295:                    .loadIcon("ModelElement_OutputField.gif");
0296:            public static ImageIcon SEARCHDOWN_ICON = IconsHolder
0297:                    .loadIcon("SearchDown.gif");
0298:            public static ImageIcon SEARCHUP_ICON = IconsHolder
0299:                    .loadIcon("SearchUp.gif");
0300:            public static ImageIcon DESCRIPTION_ICON = IconsHolder
0301:                    .loadIcon("Description.gif");
0302:            public static ImageIcon ERRORSIGN_ICON = IconsHolder
0303:                    .loadIcon("ErrorSign.gif");
0304:            public static ImageIcon WARNINGSIGN_ICON = IconsHolder
0305:                    .loadIcon("Warning.gif");
0306:            public static ImageIcon MODELERROR_ICON = IconsHolder
0307:                    .loadIcon("ModelErrors.gif");
0308:            public static ImageIcon ELEMENTERROR_ICON = IconsHolder
0309:                    .loadIcon("ElementErrors.gif");
0310:            public static ImageIcon RECTIFY_ICON = IconsHolder
0311:                    .loadIcon("Rectify.gif");
0312:            public static ImageIcon EXPORTMBXMI_ICON = IconsHolder
0313:                    .loadIcon("ExportMetabossXMI.gif");
0314:            public static ImageIcon CONSTRAINT_ICON = IconsHolder
0315:                    .loadIcon("ModelElement_ModelElementConstraint.gif");
0316:            public static ImageIcon NEWMODEL_ICON = IconsHolder
0317:                    .loadIcon("NewModel.gif");
0318:            public static ImageIcon DIAGRAM_ICON = IconsHolder
0319:                    .loadIcon("Diagram.gif");
0320:            public static ImageIcon PASTE_ICON = IconsHolder
0321:                    .loadIcon("Paste.gif");
0322:            public static ImageIcon DELETEFROMMODEL_ICON = IconsHolder
0323:                    .loadIcon("DeleteFromModel.gif");
0324:            public static ImageIcon MOVEUP_ICON = IconsHolder
0325:                    .loadIcon("MoveUp.gif");
0326:            public static ImageIcon MOVEDOWN_ICON = IconsHolder
0327:                    .loadIcon("MoveDown.gif");
0328:            public static ImageIcon EXPANDTREE_ICON = IconsHolder
0329:                    .loadIcon("ExpandTree.gif");
0330:            public static ImageIcon COLLAPSETREE_ICON = IconsHolder
0331:                    .loadIcon("CollapseTree.gif");
0332:            public static ImageIcon BISTREAM_ICON = IconsHolder
0333:                    .loadIcon("Bistream.gif");
0334:            public static ImageIcon UPSTREAM_ICON = IconsHolder
0335:                    .loadIcon("Upstream.gif");
0336:            public static ImageIcon DOWNSTREAM_ICON = IconsHolder
0337:                    .loadIcon("Downstream.gif");
0338:            public static ImageIcon LESSDETAILS_ICON = IconsHolder
0339:                    .loadIcon("LessDetails.gif");
0340:            public static ImageIcon MOREDETAILS_ICON = IconsHolder
0341:                    .loadIcon("MoreDetails.gif");
0342:            public static ImageIcon ACTOR_ICON = IconsHolder
0343:                    .loadIcon("Actor.gif");
0344:            public static ImageIcon USECASE_ICON = IconsHolder
0345:                    .loadIcon("UseCase.gif");
0346:            public static ImageIcon USAGESPECIFICATION_ICON = IconsHolder
0347:                    .loadIcon("ModelElement_UsageSpecification.gif");
0348:            public static ImageIcon SYSTEMUSECASEDIAGRAM_ICON = IconsHolder
0349:                    .loadIcon("SystemUseCasesDiagram.gif");
0350:            public static ImageIcon EVENTSUBSCRIPTION_ICON = IconsHolder
0351:                    .loadIcon("ModelElement_EventSubscription.gif");
0352:            public static ImageIcon EVENT_ICON = IconsHolder
0353:                    .loadIcon("ModelElement_Event.gif");
0354:            public static ImageIcon SYNCEVENT_ICON = IconsHolder
0355:                    .loadIcon("SyncronisationEvent.gif");
0356:
0357:            public static ImageIcon GRAPH_ENTITY_ICON = IconsHolder
0358:                    .loadIcon("Graph_Entity.gif");
0359:            public static ImageIcon GRAPH_COMPOSITION_ICON = IconsHolder
0360:                    .loadIcon("Graph_Composition.gif");
0361:            public static ImageIcon GRAPH_AGREGATION_ICON = IconsHolder
0362:                    .loadIcon("Graph_Agregation.gif");
0363:            public static ImageIcon GRAPH_ASSOCIATION_ICON = IconsHolder
0364:                    .loadIcon("Graph_Association.gif");
0365:            public static ImageIcon GRAPH_GENERALIZATION_ICON = IconsHolder
0366:                    .loadIcon("Graph_Generalization.gif");
0367:            public static ImageIcon GRAPH_DEPENDENCY_ICON = IconsHolder
0368:                    .loadIcon("Graph_Dependency.gif");
0369:            public static ImageIcon GRAPH_SYSTEM_ICON = IconsHolder
0370:                    .loadIcon("Graph_System.gif");
0371:            public static ImageIcon GRAPH_CLASS_ICON = IconsHolder
0372:                    .loadIcon("Graph_Class.gif");
0373:            public static ImageIcon GRAPH_INITIALSTATE_ICON = IconsHolder
0374:                    .loadIcon("Graph_InitialState.gif");
0375:            public static ImageIcon GRAPH_FINALSTATE_ICON = IconsHolder
0376:                    .loadIcon("Graph_FinalState.gif");
0377:
0378:            public static ImageIcon GRAPH_PUBLIC_ICON = IconsHolder
0379:                    .loadIcon("public.gif");
0380:
0381:            private static Log sLogger = null;
0382:            private static String sModelTechLibFileName = null;
0383:            private static String sModelDesignLibFileName = null;
0384:            private static String sSaveModelName = null;
0385:            private static boolean sAddSeparator = false;
0386:
0387:            /** Design Center application main entry point */
0388:            public static void main(String[] args) {
0389:                try {
0390:                    initialiseLogging();
0391:                    com.metaboss.util.MetaBossSpecificUtils
0392:                            .setupSystemProperties();
0393:                    loadLicenseInfo();
0394:                    printStartupBanner();
0395:
0396:                    resStrings = ResourceBundle
0397:                            .getBundle("com.metaboss.applications.designstudio.DesignStudioStrings");
0398:                    splash = new SplashScreen();
0399:
0400:                    UserPreferences.initialise(Application.sApplicationName);
0401:                    checkPath();
0402:                    sModelTechLibFileName = System.getProperty("MetaBoss.Home")
0403:                            + File.separator + "technologylib" + File.separator
0404:                            + "Model.xml";
0405:                    sModelDesignLibFileName = System
0406:                            .getProperty("MetaBoss.Home")
0407:                            + File.separator
0408:                            + "designlib"
0409:                            + File.separator
0410:                            + "Model.xml";
0411:
0412:                    // Start application
0413:                    instance = new Application();
0414:                    instance.loadSettings();
0415:                    instance.configureUI();
0416:                    instance.startUI();
0417:                    // Mark the end of the startup
0418:                    sLogger.info("Start up complete");
0419:                } catch (Exception e) {
0420:                    e.printStackTrace();
0421:                }
0422:            }
0423:
0424:            private static void initialiseLogging() {
0425:                // Override the console output
0426:                LogOutputStream lOutputStream = new LogOutputStream(System.out);
0427:                System.setOut(lOutputStream);
0428:                System.setErr(System.out);
0429:                // Init log4j stuff
0430:                Layout lLayout = new SimpleLayout();
0431:                Appender lAppender = new WriterAppender(lLayout, lOutputStream);
0432:                Logger lRootLogger = Logger.getRootLogger();
0433:                lRootLogger.setLevel(Level.INFO);
0434:                lRootLogger.addAppender(lAppender);
0435:                // Initialise looger only after dealing with log4j
0436:                sLogger = LogFactory.getLog(Application.class);
0437:            }
0438:
0439:            private static void printStartupBanner() throws Exception {
0440:                // Print startup banner
0441:                loadLicenseInfo();
0442:                sLogger.info("MetaBoss Design Studio is starting up ....");
0443:                sLogger.info("Product Version: "
0444:                        + sLicenseService.getProductVersion() + " (Built on "
0445:                        + sLicenseService.getProductBuildDate() + " "
0446:                        + sLicenseService.getProductBuildTime() + ")");
0447:                sLogger.info(sLicenseService.getManufacturerCopyrightNotice());
0448:            }
0449:
0450:            public static void beginTransaction() throws Exception {
0451:                if (sModelRepository != null)
0452:                    sModelRepository.beginTransaction();
0453:            }
0454:
0455:            public static void commit() throws Exception {
0456:                if (sModelRepository != null) {
0457:                    sModelRepository.commitTransaction();
0458:                    if (properties.mAutoValidateModel)
0459:                        validateModels(true, true);
0460:                }
0461:            }
0462:
0463:            public static void rollback() throws Exception {
0464:                if (sModelRepository != null)
0465:                    sModelRepository.rollbackTransaction();
0466:            }
0467:
0468:            public static void checkAndRollback() throws Exception {
0469:                if (sModelRepository != null && isInTransaction())
0470:                    rollback();
0471:            }
0472:
0473:            public static boolean isInTransaction() {
0474:                try {
0475:                    return (sModelRepository != null && sModelRepository
0476:                            .isInTransaction());
0477:                } catch (Exception e) {
0478:                    return false;
0479:                }
0480:            }
0481:
0482:            // return ModelElement by its ID
0483:            public static ModelElement getModelElementByID(String ID) {
0484:                ModelElement lResult = null;
0485:                if (sModelRepository != null) {
0486:                    try {
0487:                        javax.jmi.reflect.RefBaseObject lObject = sModelRepository
0488:                                .getModelObjectByRepositoryId(ID);
0489:                        if (lObject instanceof  ModelElement)
0490:                            lResult = (ModelElement) lObject;
0491:                    } catch (Exception e) {
0492:                        lResult = null;
0493:                    }
0494:                }
0495:                return lResult;
0496:            }
0497:
0498:            // return UserObject by ID
0499:            public static BaseUserObject getUserObjectByID(String ID) {
0500:                ModelElement lElement = getModelElementByID(ID);
0501:                if (lElement != null)
0502:                    return UserObjectFactory.createUserObject(lElement);
0503:                else
0504:                    return null;
0505:            }
0506:
0507:            public static BaseUserObject getCurrentUserObject() {
0508:                if (mainFrame != null && mainFrame.mTreePanel != null)
0509:                    return mainFrame.mTreePanel.getCurrentUserObject();
0510:                else
0511:                    return null;
0512:            }
0513:
0514:            // return registration key
0515:            public static boolean getRegistered() {
0516:                return (sLicenseService != null) ? sLicenseService
0517:                        .isProductCommerciallyLicensed() : false;
0518:            }
0519:
0520:            // return Application Version
0521:            public static String getVersionString() {
0522:                Object[] arguments = { getVersion(), getBuildDate() };
0523:                return java.text.MessageFormat.format(
0524:                        "Version {0} (build date {1})", arguments);
0525:
0526:            }
0527:
0528:            public static String getVersion() {
0529:                String lMajor = System
0530:                        .getProperty("com.metaboss.release.id.majorversion");
0531:                String lMinor = System
0532:                        .getProperty("com.metaboss.release.id.minorversion");
0533:                String lBuild = System
0534:                        .getProperty("com.metaboss.release.id.buildnumber");
0535:                return lMajor + "." + lMinor + "." + lBuild;
0536:            }
0537:
0538:            public static String getBuildDate() {
0539:                String lDate = System
0540:                        .getProperty("com.metaboss.release.id.builddate");
0541:                String lTime = System
0542:                        .getProperty("com.metaboss.release.id.buildtime");
0543:                return lDate + " " + lTime;
0544:            }
0545:
0546:            // return resource string
0547:            public static String getString(String pTitle) {
0548:                String lResult = null;
0549:                try {
0550:                    lResult = resStrings.getString(pTitle);
0551:                } catch (Exception e) {
0552:                    e.printStackTrace();
0553:                    lResult = null;
0554:                }
0555:                return lResult;
0556:            }
0557:
0558:            // show error message
0559:            public static void showError(String pError) {
0560:                JOptionPane.showMessageDialog(mainFrame, pError, "Error",
0561:                        JOptionPane.ERROR_MESSAGE);
0562:            }
0563:
0564:            // show warning message
0565:            public static void showWarning(String pWarning) {
0566:                JOptionPane.showMessageDialog(mainFrame, pWarning, "Warning",
0567:                        JOptionPane.WARNING_MESSAGE);
0568:            }
0569:
0570:            // show information message
0571:            public static void showInformation(String pInformation) {
0572:                JOptionPane.showMessageDialog(mainFrame, pInformation,
0573:                        "Information", JOptionPane.INFORMATION_MESSAGE);
0574:            }
0575:
0576:            // process exception
0577:            public static void processError(Throwable e) {
0578:                if (e == null)
0579:                    return;
0580:                if (e instanceof  ModelWarning) {
0581:                    String lString = e.getMessage();
0582:                    if (lString != null && lString.length() > 0) {
0583:                        String lMessage = e.getMessage();
0584:                        System.err.println(lMessage);
0585:                        showWarning(lMessage);
0586:                    }
0587:                } else {
0588:                    e.printStackTrace();
0589:                    String lString = e.getMessage();
0590:                    if (lString != null && lString.length() > 0)
0591:                        showError(e.getMessage());
0592:                }
0593:            }
0594:
0595:            // draw and return "object add" icon
0596:            public static ImageIcon getAddIcon(ImageIcon pRealIcon) {
0597:                BufferedImage lImage = new BufferedImage(pRealIcon
0598:                        .getIconWidth(), pRealIcon.getIconHeight(),
0599:                        BufferedImage.TYPE_INT_ARGB);
0600:                Graphics lGraphics = lImage.getGraphics();
0601:                ImageIcon lAddIcon = Application.ADD_ICON;
0602:
0603:                pRealIcon.paintIcon(null, lGraphics, -2, 2);
0604:                lAddIcon.paintIcon(null, lGraphics, lImage.getWidth()
0605:                        - lAddIcon.getIconWidth(), 0);
0606:
0607:                return new ImageIcon(lImage);
0608:            }
0609:
0610:            // draw and return "key" icon
0611:            public static ImageIcon getKeyIcon(ImageIcon pRealIcon) {
0612:                BufferedImage lImage = new BufferedImage(pRealIcon
0613:                        .getIconWidth(), pRealIcon.getIconHeight(),
0614:                        BufferedImage.TYPE_INT_ARGB);
0615:                Graphics lGraphics = lImage.getGraphics();
0616:                ImageIcon lKeyIcon = Application.KEYELEMENT_ICON;
0617:
0618:                pRealIcon.paintIcon(null, lGraphics, 0, 0);
0619:                lKeyIcon.paintIcon(null, lGraphics, 0, lImage.getHeight()
0620:                        - lKeyIcon.getIconHeight());
0621:
0622:                return new ImageIcon(lImage);
0623:            }
0624:
0625:            // draw and return "error" icon
0626:            public static ImageIcon getErrorIcon(Icon pRealIcon) {
0627:                BufferedImage lImage = new BufferedImage(pRealIcon
0628:                        .getIconWidth(), pRealIcon.getIconHeight(),
0629:                        BufferedImage.TYPE_INT_ARGB);
0630:                Graphics lGraphics = lImage.getGraphics();
0631:                ImageIcon lIcon = Application.ERRORSIGN_ICON;
0632:
0633:                pRealIcon.paintIcon(null, lGraphics, 0, 0);
0634:                lIcon.paintIcon(null, lGraphics, 0, lImage.getHeight()
0635:                        - lIcon.getIconHeight());
0636:
0637:                return new ImageIcon(lImage);
0638:            }
0639:
0640:            // draw and return "warning" icon
0641:            public static ImageIcon getWarningIcon(Icon pRealIcon) {
0642:                BufferedImage lImage = new BufferedImage(pRealIcon
0643:                        .getIconWidth(), pRealIcon.getIconHeight(),
0644:                        BufferedImage.TYPE_INT_ARGB);
0645:                Graphics lGraphics = lImage.getGraphics();
0646:                ImageIcon lIcon = Application.WARNINGSIGN_ICON;
0647:
0648:                pRealIcon.paintIcon(null, lGraphics, 0, 0);
0649:                lIcon.paintIcon(null, lGraphics, 0, lImage.getHeight()
0650:                        - lIcon.getIconHeight());
0651:
0652:                return new ImageIcon(lImage);
0653:            }
0654:
0655:            public static void defineButton(AbstractButton pButton) {
0656:                if (pButton == null)
0657:                    return;
0658:
0659:                pButton.setText("");
0660:                pButton.setFocusable(false);
0661:
0662:                pButton.setMaximumSize(new Dimension(24, 24));
0663:                pButton.setMinimumSize(new Dimension(24, 24));
0664:                pButton.setPreferredSize(new Dimension(24, 24));
0665:            }
0666:
0667:            // Options Event
0668:            public static void addOptionsEventListener(
0669:                    OptionsChangedListener listener) {
0670:                if (instance != null)
0671:                    instance.listenerList.add(OptionsChangedListener.class,
0672:                            listener);
0673:            }
0674:
0675:            public static void removeOptionsEventListener(
0676:                    OptionsChangedListener listener) {
0677:                if (instance != null)
0678:                    instance.listenerList.remove(OptionsChangedListener.class,
0679:                            listener);
0680:            }
0681:
0682:            // Refresh Event
0683:            public static void addRefreshListener(RefreshListener listener) {
0684:                if (instance != null)
0685:                    instance.listenerList.add(RefreshListener.class, listener);
0686:            }
0687:
0688:            public static void removeRefreshListener(RefreshListener listener) {
0689:                if (instance != null)
0690:                    instance.listenerList.remove(RefreshListener.class,
0691:                            listener);
0692:            }
0693:
0694:            // Model Changed Event
0695:            public static void addObjectChanged(ObjectChangedListener listener) {
0696:                if (instance != null)
0697:                    instance.listenerList.add(ObjectChangedListener.class,
0698:                            listener);
0699:            }
0700:
0701:            public static void removeObjectChanged(
0702:                    ObjectChangedListener listener) {
0703:                if (instance != null)
0704:                    instance.listenerList.remove(ObjectChangedListener.class,
0705:                            listener);
0706:            }
0707:
0708:            // Show Container Event
0709:            public static void addContainerShowListener(
0710:                    ShowContainerListener listener) {
0711:                if (instance != null)
0712:                    instance.listenerList.add(ShowContainerListener.class,
0713:                            listener);
0714:            }
0715:
0716:            public static void removeContainerShowListener(
0717:                    ShowContainerListener listener) {
0718:                if (instance != null)
0719:                    instance.listenerList.remove(ShowContainerListener.class,
0720:                            listener);
0721:            }
0722:
0723:            // On Container close Event
0724:            public static void addOnContainerCloseListener(
0725:                    OnContainerCloseListener listener) {
0726:                if (instance != null)
0727:                    instance.listenerList.add(OnContainerCloseListener.class,
0728:                            listener);
0729:            }
0730:
0731:            public static void removeOnContainerCloseListener(
0732:                    OnContainerCloseListener listener) {
0733:                if (instance != null)
0734:                    instance.listenerList.remove(
0735:                            OnContainerCloseListener.class, listener);
0736:            }
0737:
0738:            // On Container Changed Event
0739:            public static void addOnContainerChangedListener(
0740:                    OnContainerChangedListener listener) {
0741:                if (instance != null)
0742:                    instance.listenerList.add(OnContainerChangedListener.class,
0743:                            listener);
0744:            }
0745:
0746:            public static void removeOnContainerChangedListener(
0747:                    OnContainerChangedListener listener) {
0748:                if (instance != null)
0749:                    instance.listenerList.remove(
0750:                            OnContainerChangedListener.class, listener);
0751:            }
0752:
0753:            // On Errors Found Event
0754:            public static void addOnErrorsFoundListener(
0755:                    OnErrorsFoundListener listener) {
0756:                if (instance != null)
0757:                    instance.listenerList.add(OnErrorsFoundListener.class,
0758:                            listener);
0759:            }
0760:
0761:            public static void removeOnErrorsFoundListener(
0762:                    OnErrorsFoundListener listener) {
0763:                if (instance != null)
0764:                    instance.listenerList.remove(OnErrorsFoundListener.class,
0765:                            listener);
0766:            }
0767:
0768:            // On Current Model Changed
0769:            public static void addOnModelChangedListener(
0770:                    OnModelChangedListener listener) {
0771:                if (instance != null)
0772:                    instance.listenerList.add(OnModelChangedListener.class,
0773:                            listener);
0774:            }
0775:
0776:            public static void removeOnModelChangedListener(
0777:                    OnModelChangedListener listener) {
0778:                if (instance != null)
0779:                    instance.listenerList.remove(OnModelChangedListener.class,
0780:                            listener);
0781:            }
0782:
0783:            // Model Closed
0784:            public static void addCloseModelListener(CloseModelListener listener) {
0785:                if (instance != null)
0786:                    instance.listenerList.add(CloseModelListener.class,
0787:                            listener);
0788:            }
0789:
0790:            public static void removeCloseModelListener(
0791:                    CloseModelListener listener) {
0792:                if (instance != null)
0793:                    instance.listenerList.remove(CloseModelListener.class,
0794:                            listener);
0795:            }
0796:
0797:            // Diagram Changed
0798:            public static void addRefreshDiagramsListener(
0799:                    RefreshDiagramsEventListener listener) {
0800:                if (instance != null)
0801:                    instance.listenerList.add(
0802:                            RefreshDiagramsEventListener.class, listener);
0803:            }
0804:
0805:            public static void removeRefreshDiagramsListener(
0806:                    RefreshDiagramsEventListener listener) {
0807:                if (instance != null)
0808:                    instance.listenerList.remove(
0809:                            RefreshDiagramsEventListener.class, listener);
0810:            }
0811:
0812:            // Index changed
0813:            public static void addElementIndexChangedEvent(
0814:                    OnElemenIndexChangedEventListener listener) {
0815:                if (instance != null)
0816:                    instance.listenerList.add(
0817:                            OnElemenIndexChangedEventListener.class, listener);
0818:            }
0819:
0820:            public static void removeElementIndexChangedEvent(
0821:                    OnElemenIndexChangedEventListener listener) {
0822:                if (instance != null)
0823:                    instance.listenerList.remove(
0824:                            OnElemenIndexChangedEventListener.class, listener);
0825:            }
0826:
0827:            // fire Properties changed event
0828:            public static void fireOptionsChanged(boolean pMetabossChanged) {
0829:                if (instance != null)
0830:                    instance.fireOptionsChangedEvent(pMetabossChanged);
0831:            }
0832:
0833:            public void fireOptionsChangedEvent(boolean pMetabossChanged) {
0834:                OptionsChangedEvent lEvent = new OptionsChangedEvent(
0835:                        pMetabossChanged);
0836:                EventQueue queue = Toolkit.getDefaultToolkit()
0837:                        .getSystemEventQueue();
0838:                queue.postEvent(lEvent);
0839:            }
0840:
0841:            // fire Refresh event
0842:            public static void fireRefresh() {
0843:                if (instance != null)
0844:                    instance.fireRefreshEvent();
0845:            }
0846:
0847:            public void fireRefreshEvent() {
0848:                RefreshEvent lEvent = new RefreshEvent();
0849:                EventQueue queue = Toolkit.getDefaultToolkit()
0850:                        .getSystemEventQueue();
0851:                queue.postEvent(lEvent);
0852:            }
0853:
0854:            // fire Model Changed event
0855:            public static void fireObjectSelected(BaseUserObject pUserObject) {
0856:                if (instance != null)
0857:                    instance.fireObjectChanged(pUserObject,
0858:                            ObjectChangedEvent.ET_SELECTED);
0859:            }
0860:
0861:            public static void fireObjectSelect(BaseUserObject pUserObject) {
0862:                if (instance != null)
0863:                    instance.fireObjectChanged(pUserObject,
0864:                            ObjectChangedEvent.ET_SELECT);
0865:            }
0866:
0867:            public static void fireObjectEdited(BaseUserObject pUserObject) {
0868:                if (instance != null)
0869:                    instance.fireObjectChanged(pUserObject,
0870:                            ObjectChangedEvent.ET_EDITED);
0871:            }
0872:
0873:            public static void fireObjectDeleted(String pID, String pModelName) {
0874:                if (instance != null)
0875:                    instance.fireObjectChanged(pID, pModelName,
0876:                            ObjectChangedEvent.ET_DELETED);
0877:            }
0878:
0879:            public static void fireObjectDeleted(BaseUserObject pUserObject) {
0880:                if (instance != null)
0881:                    instance.fireObjectChanged(pUserObject,
0882:                            ObjectChangedEvent.ET_DELETED);
0883:            }
0884:
0885:            public static void fireObjectInserted(BaseUserObject pUserObject) {
0886:                if (instance != null)
0887:                    instance.fireObjectChanged(pUserObject,
0888:                            ObjectChangedEvent.ET_INSERTED);
0889:            }
0890:
0891:            public void fireObjectChanged(BaseUserObject pObject, int pSource) {
0892:                ObjectChangedEvent lEvent = new ObjectChangedEvent(pObject,
0893:                        pSource);
0894:                EventQueue queue = Toolkit.getDefaultToolkit()
0895:                        .getSystemEventQueue();
0896:                queue.postEvent(lEvent);
0897:            }
0898:
0899:            public void fireObjectChanged(String pID, String pModelName,
0900:                    int pSource) {
0901:                ObjectChangedEvent lEvent = new ObjectChangedEvent(pID,
0902:                        pModelName, pSource);
0903:                EventQueue queue = Toolkit.getDefaultToolkit()
0904:                        .getSystemEventQueue();
0905:                queue.postEvent(lEvent);
0906:            }
0907:
0908:            public static void fireObjectMoved(BaseUserObject pUserObject) {
0909:                if (instance != null)
0910:                    instance.fireObjectChanged(pUserObject,
0911:                            ObjectChangedEvent.ET_MOVED);
0912:            }
0913:
0914:            // fire Show Container event
0915:            public static void fireShowContainer(BaseChildPanel pContainer,
0916:                    BaseUserObject pObject) {
0917:                if (instance != null)
0918:                    instance.fireShowContainerEvent(pContainer, pObject, null);
0919:            }
0920:
0921:            public static void fireShowContainer(BaseChildPanel pContainer,
0922:                    BaseUserObject pObject, Icon pIcon) {
0923:                if (instance != null)
0924:                    instance.fireShowContainerEvent(pContainer, pObject, pIcon);
0925:            }
0926:
0927:            public void fireShowContainerEvent(BaseChildPanel pContainer,
0928:                    BaseUserObject pObject, Icon pIcon) {
0929:                ShowContainerEvent lEvent = new ShowContainerEvent(pContainer,
0930:                        pObject, pIcon);
0931:                EventQueue queue = Toolkit.getDefaultToolkit()
0932:                        .getSystemEventQueue();
0933:                queue.postEvent(lEvent);
0934:            }
0935:
0936:            // fire On Container close event
0937:            public static void fireOnContainerClose(BaseChildPanel pContainer) {
0938:                if (instance != null)
0939:                    instance.fireOnContainerCloseEvent(pContainer);
0940:            }
0941:
0942:            public void fireOnContainerCloseEvent(BaseChildPanel pContainer) {
0943:                OnContainerCloseEvent lEvent = new OnContainerCloseEvent(
0944:                        pContainer);
0945:                EventQueue queue = Toolkit.getDefaultToolkit()
0946:                        .getSystemEventQueue();
0947:                queue.postEvent(lEvent);
0948:            }
0949:
0950:            // fire On Container Changed event
0951:            public static void fireOnContainerChanged(Container pContainer) {
0952:                if (instance != null)
0953:                    instance.fireOnContainerChangedEvent(pContainer);
0954:            }
0955:
0956:            public void fireOnContainerChangedEvent(Container pContainer) {
0957:                OnContainerChangedEvent lEvent = new OnContainerChangedEvent(
0958:                        pContainer);
0959:                EventQueue queue = Toolkit.getDefaultToolkit()
0960:                        .getSystemEventQueue();
0961:                queue.postEvent(lEvent);
0962:            }
0963:
0964:            // fire On Errors Found event
0965:            public static void fireOnErrorsFound() {
0966:                if (instance != null)
0967:                    instance.fireOnErrorsFoundEvent();
0968:            }
0969:
0970:            public void fireOnErrorsFoundEvent() {
0971:                OnErrorsFoundEvent lEvent = new OnErrorsFoundEvent();
0972:                EventQueue queue = Toolkit.getDefaultToolkit()
0973:                        .getSystemEventQueue();
0974:                queue.postEvent(lEvent);
0975:            }
0976:
0977:            // fire On Current Model Changed event
0978:            public static void fireOnCurrentModelChanged() {
0979:                if (instance != null)
0980:                    instance.fireOnCurrentModelChangedEvent();
0981:            }
0982:
0983:            public void fireOnCurrentModelChangedEvent() {
0984:                OnModelChangedEvent lEvent = new OnModelChangedEvent(
0985:                        Application.getCurrentPackage(),
0986:                        OnModelChangedEvent.CURRENT_CHANGED);
0987:                EventQueue queue = Toolkit.getDefaultToolkit()
0988:                        .getSystemEventQueue();
0989:                queue.postEvent(lEvent);
0990:            }
0991:
0992:            // fire Model closed
0993:            public static void fireOnModelClosed(ModelUserObject pModel) {
0994:                if (instance != null)
0995:                    instance.fireOnModelClosedEvent(pModel);
0996:            }
0997:
0998:            public void fireOnModelClosedEvent(ModelUserObject pModel) {
0999:                OnModelChangedEvent lEvent = new OnModelChangedEvent(pModel,
1000:                        OnModelChangedEvent.MODEL_CLOSED);
1001:                EventQueue queue = Toolkit.getDefaultToolkit()
1002:                        .getSystemEventQueue();
1003:                queue.postEvent(lEvent);
1004:            }
1005:
1006:            // fire Model opened
1007:            public static void fireOnModelOpened(ModelUserObject pModel) {
1008:                if (instance != null)
1009:                    instance.fireOnModelOpenedEvent(pModel);
1010:            }
1011:
1012:            public void fireOnModelOpenedEvent(ModelUserObject pModel) {
1013:                OnModelChangedEvent lEvent = new OnModelChangedEvent(pModel,
1014:                        OnModelChangedEvent.MODEL_OPENED);
1015:                EventQueue queue = Toolkit.getDefaultToolkit()
1016:                        .getSystemEventQueue();
1017:                queue.postEvent(lEvent);
1018:            }
1019:
1020:            // fire Model saved
1021:            public static void fireOnModelSaved(ModelUserObject pModel) {
1022:                if (instance != null)
1023:                    instance.fireOnModelSavedEvent(pModel);
1024:            }
1025:
1026:            public void fireOnModelSavedEvent(ModelUserObject pModel) {
1027:                OnModelChangedEvent lEvent = new OnModelChangedEvent(pModel,
1028:                        OnModelChangedEvent.MODEL_SAVED);
1029:                EventQueue queue = Toolkit.getDefaultToolkit()
1030:                        .getSystemEventQueue();
1031:                queue.postEvent(lEvent);
1032:            }
1033:
1034:            // fire Close Model event
1035:            public static void fireCloseModel(ModelUserObject pModel) {
1036:                if (instance != null)
1037:                    instance.fireCloseModelEvent(pModel);
1038:            }
1039:
1040:            public void fireCloseModelEvent(ModelUserObject pModel) {
1041:                CloseModelEvent lEvent = new CloseModelEvent(pModel);
1042:                EventQueue queue = Toolkit.getDefaultToolkit()
1043:                        .getSystemEventQueue();
1044:                queue.postEvent(lEvent);
1045:            }
1046:
1047:            // fire Refresh Diagram event
1048:            public static void fireRefreshDiagram(Diagram pDiagram,
1049:                    BaseUserObject pUserObject) {
1050:                if (instance != null)
1051:                    instance.fireRefreshDiagramEvent(pDiagram, pUserObject);
1052:            }
1053:
1054:            public void fireRefreshDiagramEvent(Diagram pDiagram,
1055:                    BaseUserObject pUserObject) {
1056:                RefreshDiagramsEvent lEvent = new RefreshDiagramsEvent(
1057:                        pDiagram, pUserObject);
1058:                EventQueue queue = Toolkit.getDefaultToolkit()
1059:                        .getSystemEventQueue();
1060:                queue.postEvent(lEvent);
1061:            }
1062:
1063:            // fire Index Changed event
1064:            public static void fireIndexChanged(BaseUserObject pUserObject,
1065:                    int pOldIndex, int pNewIndex) {
1066:                if (instance != null)
1067:                    instance.fireIndexChangedEvent(pUserObject, pOldIndex,
1068:                            pNewIndex);
1069:            }
1070:
1071:            public void fireIndexChangedEvent(BaseUserObject pUserObject,
1072:                    int pOldIndex, int pNewIndex) {
1073:                OnElementIndexChangedEvent lEvent = new OnElementIndexChangedEvent(
1074:                        pUserObject, pOldIndex, pNewIndex);
1075:                EventQueue queue = Toolkit.getDefaultToolkit()
1076:                        .getSystemEventQueue();
1077:                queue.postEvent(lEvent);
1078:            }
1079:
1080:            // exit application
1081:            public static void exit() {
1082:                if (mainFrame != null)
1083:                    mainFrame.beforeClose();
1084:                instance.saveSettings();
1085:                System.exit(0);
1086:            }
1087:
1088:            // fill actions
1089:            public static void fillActions(BaseUserObject pUserObject,
1090:                    JToolBar pToolBar, JMenu pMenu, JPopupMenu pPopupMenu) {
1091:                clearOldItems(pToolBar, pMenu, pPopupMenu);
1092:                Object[] lActions = (pUserObject != null) ? pUserObject
1093:                        .getActions() : null;
1094:                simpleFillActions(lActions, pToolBar, pMenu, pPopupMenu);
1095:                if (pToolBar != null)
1096:                    pToolBar.repaint();
1097:            }
1098:
1099:            public static void fillActions(Object[] pActions,
1100:                    JToolBar pToolBar, JMenu pMenu, JPopupMenu pPopupMenu) {
1101:                clearOldItems(pToolBar, pMenu, pPopupMenu);
1102:                simpleFillActions(pActions, pToolBar, pMenu, pPopupMenu);
1103:                if (pToolBar != null)
1104:                    pToolBar.repaint();
1105:            }
1106:
1107:            public static void simpleFillActions(Object[] pActions,
1108:                    JToolBar pToolBar, JMenu pMenu, JPopupMenu pPopupMenu) {
1109:                try {
1110:                    if (pActions != null)
1111:                        for (int i = 0; i < pActions.length; i++)
1112:                            fillAction((Action) pActions[i], pToolBar, pMenu,
1113:                                    pPopupMenu);
1114:                    if (pMenu != null)
1115:                        pMenu.setEnabled(pMenu.getItemCount() > 0);
1116:                } finally {
1117:                    sAddSeparator = false;
1118:                }
1119:            }
1120:
1121:            // fill button and menuitems for action
1122:            public static void fillAction(Action pAction, JToolBar pToolBar,
1123:                    JMenu pMenu, JPopupMenu pPopupMenu) {
1124:                if (pAction instanceof  SeparatorAction) {
1125:                    if (pToolBar != null)
1126:                        sAddSeparator = true;
1127:                    if (pMenu != null && pMenu.getItemCount() > 0)
1128:                        pMenu.addSeparator();
1129:                    if (pPopupMenu != null)
1130:                        pPopupMenu.addSeparator();
1131:                } else if (pAction instanceof  ContainerAction) {
1132:                    JMenu pBar = new JMenu(pAction);
1133:                    if (pMenu != null)
1134:                        pMenu.add(pBar);
1135:                    if (pPopupMenu != null)
1136:                        pPopupMenu.add(pBar);
1137:                    simpleFillActions(((ContainerAction) pAction).getActions(),
1138:                            pToolBar, pBar, null);
1139:                } else {
1140:                    boolean lAddToToolBar = true;
1141:                    boolean lAddToMenu = true;
1142:                    boolean lAddToPopUp = true;
1143:                    if (pAction instanceof  BaseAction) {
1144:                        lAddToToolBar = ((BaseAction) pAction)
1145:                                .getAddToToolBar()
1146:                                && ((BaseAction) pAction)
1147:                                        .getValue(Action.SMALL_ICON) != null;
1148:                        lAddToMenu = ((BaseAction) pAction).mAddToMenu;
1149:                        lAddToPopUp = ((BaseAction) pAction).mAddToPopUp;
1150:                    }
1151:
1152:                    if (pToolBar != null && lAddToToolBar) {
1153:                        if (sAddSeparator) {
1154:                            if (pToolBar.getComponentCount() > 0)
1155:                                pToolBar.add(new ToolBarSeparator(pToolBar));
1156:                            sAddSeparator = false;
1157:                        }
1158:                        pToolBar.add(createButton(pAction));
1159:                    }
1160:                    if (pMenu != null && lAddToMenu)
1161:                        pMenu.add(createMenuItem(pAction));
1162:                    if (pPopupMenu != null && lAddToPopUp)
1163:                        pPopupMenu.add(createMenuItem(pAction));
1164:                }
1165:            }
1166:
1167:            public static JMenuItem createMenuItem(Action pAction) {
1168:                JMenuItem lResult = null;
1169:                if (pAction != null && pAction instanceof  BaseAction) {
1170:                    if (((BaseAction) pAction).isCheck()) {
1171:                        JCheckBoxMenuItem lItem = new JCheckBoxMenuItem(pAction);
1172:                        lItem.setState(((BaseAction) pAction).isChecked());
1173:                        lResult = lItem;
1174:                    }
1175:                }
1176:                if (lResult == null)
1177:                    lResult = new JMenuItem(pAction);
1178:                lResult.setToolTipText(null);
1179:                return lResult;
1180:            }
1181:
1182:            public static AbstractButton createButton(Action pAction) {
1183:                AbstractButton lResult = null;
1184:                if (pAction != null && pAction instanceof  BaseAction
1185:                        && ((BaseAction) pAction).isCheck()) {
1186:                    lResult = new JToggleButton(pAction);
1187:                    if (((BaseAction) pAction).getSelectedIcon() != null)
1188:                        lResult.setSelectedIcon(((BaseAction) pAction)
1189:                                .getSelectedIcon());
1190:                    ButtonGroup lGroup = ((BaseAction) pAction)
1191:                            .getButtonGroup();
1192:                    if (lGroup != null)
1193:                        lGroup.add(lResult);
1194:                } else
1195:                    lResult = new JButton(pAction);
1196:
1197:                defineButton(lResult);
1198:                return lResult;
1199:            }
1200:
1201:            // clear old items and buttons
1202:            public static void clearOldItems(JToolBar pToolBar, JMenu pMenu,
1203:                    JPopupMenu pPopupMenu) {
1204:                if (pMenu != null)
1205:                    pMenu.removeAll();
1206:                if (pToolBar != null)
1207:                    pToolBar.removeAll();
1208:                if (pPopupMenu != null)
1209:                    pPopupMenu.removeAll();
1210:            }
1211:
1212:            // laod application settings
1213:            public void loadSettings() {
1214:                try {
1215:                    Application.properties.loadProperties();
1216:                } catch (Exception e) {
1217:                    e.printStackTrace();
1218:                    properties.setDefaultValues();
1219:                }
1220:                loadModels();
1221:            }
1222:
1223:            // save application settings
1224:            public void saveSettings() {
1225:                try {
1226:                    Application.properties.saveProperties();
1227:                } catch (Exception e) {
1228:                    e.printStackTrace();
1229:                }
1230:                try {
1231:                    sModelRepository.close();
1232:                } catch (Exception e) {
1233:                    e.printStackTrace();
1234:                }
1235:            }
1236:
1237:            // get current package
1238:            public static ModelUserObject getCurrentPackage() {
1239:                if (mainFrame != null)
1240:                    return mainFrame.getCurrentPackage();
1241:                return null;
1242:            }
1243:
1244:            // get models count
1245:            public static int getModelsCount() {
1246:                return sModels.size();
1247:            }
1248:
1249:            // return model user object by index
1250:            public static ModelUserObject getModel(int index) {
1251:                ModelUserObject lResult = null;
1252:                try {
1253:                    lResult = (ModelUserObject) sModels.get(index);
1254:                } catch (Exception e) {
1255:                    lResult = null;
1256:                }
1257:                return lResult;
1258:            }
1259:
1260:            public static ModelUserObject getModel(String pFileName) {
1261:                for (int i = 0; i < sModels.size(); i++) {
1262:                    ModelUserObject lModel = getModel(i);
1263:                    if (lModel.getFileName().equals(pFileName))
1264:                        return lModel;
1265:                }
1266:                return null;
1267:            }
1268:
1269:            public static ModelUserObject getModel(MetaBossModelPackage pPackage) {
1270:                for (int i = 0; i < sModels.size(); i++) {
1271:                    ModelUserObject lModel = getModel(i);
1272:                    if (lModel.getPackage().equals(pPackage))
1273:                        return lModel;
1274:                }
1275:                return null;
1276:            }
1277:
1278:            // create Model
1279:            public static void createModel() {
1280:                JFileChooser lChooser = new JFileChooser();
1281:                ModelFileFilter lFilter = new ModelFileFilter();
1282:
1283:                lChooser.setDialogTitle("Select New Model Root Directory");
1284:                lChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
1285:                if (Application.properties.mLastDir != null)
1286:                    lChooser.setCurrentDirectory((new File(
1287:                            Application.properties.mLastDir)).getParentFile());
1288:
1289:                int returnVal = lChooser.showDialog(mainFrame, "Select");
1290:                if (returnVal == JFileChooser.APPROVE_OPTION) {
1291:                    String lPath = lChooser.getSelectedFile().getPath();
1292:                    String lFileName = lPath + File.separator + "Model.xml";
1293:                    File lFile = new File(lPath);
1294:                    if (lFile.exists() && lFile.list().length > 0) {
1295:                        int n = JOptionPane.showConfirmDialog(null, Application
1296:                                .getString("nonemptydir_query"), "Confirm",
1297:                                JOptionPane.YES_NO_OPTION);
1298:                        if (n != 0)
1299:                            return;
1300:                    }
1301:                    try {
1302:                        ModelUserObject lModel = new ModelUserObject(lFileName,
1303:                                true, false);
1304:                        sModels.add(lModel);
1305:                        if (lModel != null) {
1306:                            fireOnModelOpened(lModel);
1307:                            Application.properties.mLastDir = lFileName;
1308:                        }
1309:                    } catch (Exception e) {
1310:                        processError(e);
1311:                    }
1312:                }
1313:            }
1314:
1315:            // open Model
1316:            public static void openModel() {
1317:                JFileChooser lChooser = new JFileChooser();
1318:                ModelFileFilter lFilter = new ModelFileFilter();
1319:
1320:                lChooser.setDialogTitle("Open Model");
1321:                lFilter.addExtension("xml");
1322:                lFilter.setDescription("MetaBoss Model files");
1323:                lChooser.setFileFilter(lFilter);
1324:                if (Application.properties.mLastDir != null)
1325:                    lChooser.setCurrentDirectory((new File(
1326:                            Application.properties.mLastDir)).getParentFile());
1327:
1328:                int returnVal = lChooser.showOpenDialog(mainFrame);
1329:                if (returnVal == JFileChooser.APPROVE_OPTION) {
1330:                    try {
1331:                        String lPath = lChooser.getSelectedFile().getPath();
1332:                        openModel(lPath);
1333:                        properties.mLastDir = lPath;
1334:                    } catch (Exception e) {
1335:                        processError(e);
1336:                    }
1337:                }
1338:            }
1339:
1340:            public static void openModel(String pFileName) throws Exception {
1341:                Cursor lCursor = mainFrame.getCursor();
1342:                try {
1343:                    mainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
1344:
1345:                    ModelUserObject lModel = getModel(pFileName);
1346:                    if (lModel == null) {
1347:                        lModel = new ModelUserObject(pFileName, false, false);
1348:                        sModels.add(lModel);
1349:                        properties.removeFromReopen(pFileName);
1350:                    }
1351:                    if (lModel != null)
1352:                        fireOnModelOpened(lModel);
1353:                } finally {
1354:                    mainFrame.setCursor(lCursor);
1355:                }
1356:            }
1357:
1358:            // close Model
1359:            public static void closeModel(ModelUserObject pModel,
1360:                    boolean pSilent, boolean pSave) {
1361:                if (pModel == null)
1362:                    return;
1363:
1364:                if (pModel.isModified() && pSave) {
1365:                    try {
1366:                        if (pSilent)
1367:                            saveModel(pModel);
1368:                        else {
1369:                            int n = JOptionPane
1370:                                    .showConfirmDialog(
1371:                                            null,
1372:                                            "\""
1373:                                                    + pModel.getModelName()
1374:                                                    + "\" has been modified! Save changes?",
1375:                                            "Confirm",
1376:                                            JOptionPane.YES_NO_CANCEL_OPTION);
1377:                            if (n == 0)
1378:                                saveOneModel(pModel);
1379:                            else if (n == 2)
1380:                                return;
1381:                        }
1382:                    } catch (Exception e) {
1383:                        processError(e);
1384:                    }
1385:                }
1386:
1387:                try {
1388:                    pModel.closeModel();
1389:                } catch (Exception e) {
1390:                    processError(e);
1391:                }
1392:            }
1393:
1394:            // close all models
1395:            public static void closeAllModels() throws Exception {
1396:                ArrayList lList = new ArrayList();
1397:                for (int i = 0; i < getModelsCount(); i++) {
1398:                    ModelUserObject lObject = getModel(i);
1399:                    if (lObject.isModified())
1400:                        lList.add(lObject);
1401:                }
1402:
1403:                if (lList.size() > 0) {
1404:                    SaveContentDialog lDialog = new SaveContentDialog(
1405:                            mainFrame, lList);
1406:                    if (lDialog.getModalResult() == SaveContentDialog.MR_OK) {
1407:                        for (int i = 0; i < getModelsCount(); i++) {
1408:                            ModelUserObject lObject = getModel(i);
1409:                            closeModel(lObject, true, lList.contains(lObject));
1410:                        }
1411:                    }
1412:                }
1413:            }
1414:
1415:            // load Metaboss Models
1416:            public static void loadModels() {
1417:                sModels.clear();
1418:                try {
1419:                    Context lContext = new InitialContext();
1420:                    sModelRepository = (ModelRepository) lContext
1421:                            .lookup(ModelRepository.COMPONENT_URL);
1422:                } catch (Exception e) {
1423:                    sModelRepository = null;
1424:                    e.printStackTrace();
1425:                }
1426:
1427:                if (sModelRepository != null) {
1428:                    //??? îòêðûòü Enterprise Models
1429:                    for (int i = 0; i < properties.mPreLoadModels.size(); i++) {
1430:                        String lFileName = (String) properties.mPreLoadModels
1431:                                .get(i);
1432:                        if (lFileName != null) {
1433:                            File lFile = new File(lFileName);
1434:                            if (lFile.exists()) {
1435:                                try {
1436:                                    sModels.add(new ModelUserObject(lFileName,
1437:                                            false, false));
1438:                                } catch (Exception e) {
1439:                                    e.printStackTrace();
1440:                                }
1441:                            } else {
1442:                                String lError = java.text.MessageFormat
1443:                                        .format(
1444:                                                "File \"{0}\" is not found. Design studio is unable to open the model!",
1445:                                                new Object[] { lFileName });
1446:                                System.err.println(lError);
1447:                            }
1448:                        }
1449:                    }
1450:
1451:                    //??? îòêðûòü design lib
1452:                    try {
1453:                        sModels.add(new ModelUserObject(
1454:                                sModelDesignLibFileName, false, true));
1455:                    } catch (Exception e) {
1456:                        e.printStackTrace();
1457:                    }
1458:
1459:                    //??? îòêðûòü tech lib
1460:                    try {
1461:                        sModels.add(new ModelUserObject(sModelTechLibFileName,
1462:                                false, true));
1463:                    } catch (Exception e) {
1464:                        e.printStackTrace();
1465:                    }
1466:                }
1467:            }
1468:
1469:            // get count of modified models
1470:            public static int getModifiedModelsCount() {
1471:                int lResult = 0;
1472:                try {
1473:                    String[] lModels = sModelRepository.listModelNames();
1474:                    if (lModels != null)
1475:                        for (int i = 0; i < lModels.length; i++)
1476:                            if (sModelRepository.isModelModified(lModels[i]))
1477:                                lResult++;
1478:                } catch (Exception e) {
1479:                    lResult = 0;
1480:                }
1481:                return lResult;
1482:            }
1483:
1484:            // save Metaboss models
1485:            public static void saveModels(boolean pShowDialog, boolean pClose)
1486:                    throws Exception {
1487:                Cursor lCursor = mainFrame.getCursor();
1488:                try {
1489:                    mainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
1490:
1491:                    sModelErrors.clear();
1492:                    sSaveModelName = null;
1493:
1494:                    if (pShowDialog) {
1495:                        ArrayList lList = new ArrayList();
1496:                        for (int i = 0; i < getModelsCount(); i++) {
1497:                            ModelUserObject lObject = getModel(i);
1498:                            if (lObject.isModified())
1499:                                lList.add(lObject);
1500:                        }
1501:
1502:                        if (lList.size() > 0) {
1503:                            SaveContentDialog lDialog = new SaveContentDialog(
1504:                                    mainFrame, lList);
1505:                            if (lDialog.getModalResult() == SaveContentDialog.MR_OK) {
1506:                                for (int i = 0; i < getModelsCount(); i++) {
1507:                                    ModelUserObject lObject = getModel(i);
1508:                                    if (lList.contains(lObject))
1509:                                        saveModel(lObject);
1510:                                }
1511:                            } else
1512:                                throw new Exception();
1513:                        }
1514:                    } else {
1515:                        String[] lModels = sModelRepository.listModelNames();
1516:                        if (lModels != null)
1517:                            for (int i = 0; i < lModels.length; i++)
1518:                                saveModel(lModels[i]);
1519:                    }
1520:
1521:                    fireOnErrorsFound();
1522:                    if (sModelErrors.size() > 0)
1523:                        showErrorsFound(pClose);
1524:                } finally {
1525:                    mainFrame.setCursor(lCursor);
1526:                }
1527:            }
1528:
1529:            // check for errors
1530:            public static boolean errorsFound() {
1531:                return sModelErrors.size() > 0;
1532:            }
1533:
1534:            public static void setErrorElementID(String pID) {
1535:                if ((sErrorElement != null && pID == null)
1536:                        || (sErrorElement == null && pID != null)
1537:                        || (sErrorElement != null && !sErrorElement.equals(pID))) {
1538:                    sErrorElement = pID;
1539:                    fireOnErrorsFound();
1540:                }
1541:            }
1542:
1543:            private static void saveInvalidModels() throws Exception {
1544:                if (sSaveModelName != null)
1545:                    saveModelNoValidate(sSaveModelName);
1546:                else {
1547:                    for (int i = 0; i < sModelErrors.size(); i++) {
1548:                        ModelErrorDescription lDescription = (ModelErrorDescription) sModelErrors
1549:                                .get(i);
1550:                        if (lDescription != null)
1551:                            saveModelNoValidate(lDescription.getModelName());
1552:                    }
1553:                }
1554:            }
1555:
1556:            // delete errors of the given model
1557:            public static void removeModelErrors(ModelUserObject pModel) {
1558:                if (pModel != null) {
1559:                    int i = 0;
1560:                    while (i < sModelErrors.size()) {
1561:                        ModelErrorDescription lDescription = (ModelErrorDescription) sModelErrors
1562:                                .get(i);
1563:                        if (lDescription.getModelName().equals(
1564:                                pModel.getFileName()))
1565:                            sModelErrors.remove(lDescription);
1566:                        else
1567:                            i++;
1568:                    }
1569:                }
1570:            }
1571:
1572:            public static void removeModelErrors(String pModelName) {
1573:                if (pModelName != null) {
1574:                    int i = 0;
1575:                    while (i < sModelErrors.size()) {
1576:                        ModelErrorDescription lDescription = (ModelErrorDescription) sModelErrors
1577:                                .get(i);
1578:                        if (lDescription.getModelName().equals(pModelName))
1579:                            sModelErrors.remove(lDescription);
1580:                        else
1581:                            i++;
1582:                    }
1583:                }
1584:            }
1585:
1586:            public static int getModelErrorsCount(ModelUserObject pModel) {
1587:                int lResult = 0;
1588:                for (int i = 0; i < sModelErrors.size(); i++) {
1589:                    ModelErrorDescription lDescription = (ModelErrorDescription) sModelErrors
1590:                            .get(i);
1591:                    if (lDescription.getModelName()
1592:                            .equals(pModel.getFileName()))
1593:                        lResult++;
1594:                }
1595:                return lResult;
1596:            }
1597:
1598:            // show Errors dialog
1599:            private static void showErrorsFound(boolean pClose)
1600:                    throws Exception {
1601:                if (properties.mValidateModelOnSave) {
1602:                    if (pClose) {
1603:                        int n = JOptionPane.showConfirmDialog(mainFrame,
1604:                                getString("save_errors")
1605:                                        + getString("save_errors_prompt0"),
1606:                                getString("save_errors_caption"),
1607:                                JOptionPane.YES_NO_CANCEL_OPTION);
1608:                        switch (n) {
1609:                        case 0:
1610:                            saveInvalidModels();
1611:                            break;
1612:                        case 2:
1613:                            throw new Exception();
1614:                        }
1615:                    } else {
1616:                        int n = JOptionPane.showConfirmDialog(mainFrame,
1617:                                getString("save_errors")
1618:                                        + getString("save_errors_prompt1"),
1619:                                getString("save_errors_caption"),
1620:                                JOptionPane.YES_NO_OPTION);
1621:                        switch (n) {
1622:                        case 0:
1623:                            saveInvalidModels();
1624:                            break;
1625:                        }
1626:                    }
1627:                } else
1628:                    saveInvalidModels();
1629:            }
1630:
1631:            // validate and save model
1632:            public static void saveModel(String pModelName) throws Exception {
1633:                if (sModelRepository.isModelModified(pModelName)) {
1634:                    try {
1635:                        sModelRepository.saveModel(pModelName, true);
1636:                        fireOnModelSaved(getModel(pModelName));
1637:                    } catch (ModelValidationException e) {
1638:                        sModelErrors.add(new ModelErrorDescription(pModelName,
1639:                                e));
1640:                    } catch (Exception e) {
1641:                        processError(e);
1642:                    }
1643:                }
1644:            }
1645:
1646:            public static void saveModel(ModelUserObject pModel)
1647:                    throws Exception {
1648:                saveModel(pModel.getFileName());
1649:            }
1650:
1651:            public static void saveOneModel(ModelUserObject pModel)
1652:                    throws Exception {
1653:                Cursor lCursor = mainFrame.getCursor();
1654:                try {
1655:                    mainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
1656:                    sSaveModelName = pModel.getFileName();
1657:                    try {
1658:                        try {
1659:                            removeModelErrors(pModel);
1660:                            saveModel(pModel.getFileName());
1661:                        } catch (Exception e) {
1662:                            processError(e);
1663:                        }
1664:                        fireOnErrorsFound();
1665:                        if (getModelErrorsCount(pModel) > 0)
1666:                            showErrorsFound(false);
1667:                    } finally {
1668:                        sSaveModelName = null;
1669:                    }
1670:                } finally {
1671:                    mainFrame.setCursor(lCursor);
1672:                }
1673:            }
1674:
1675:            // save model withouot validation	
1676:            public static void saveModelNoValidate(String pModelName)
1677:                    throws Exception {
1678:                if (sModelRepository.isModelModified(pModelName)) {
1679:                    try {
1680:                        sModelRepository.saveModel(pModelName, false);
1681:                        fireOnModelSaved(getModel(pModelName));
1682:                    } catch (Exception e) {
1683:                        processError(e);
1684:                    }
1685:                }
1686:            }
1687:
1688:            public static void saveModelNoVlidate(ModelUserObject pModel)
1689:                    throws Exception {
1690:                saveModelNoValidate(pModel.getFileName());
1691:                //fireOnModelSaved(pModel);
1692:            }
1693:
1694:            public static int getErrorsCount() {
1695:                int lResult = 0;
1696:                for (int i = 0; i < sModelErrors.size(); i++)
1697:                    lResult += ((ModelErrorDescription) sModelErrors.get(i))
1698:                            .getCount();
1699:                return lResult;
1700:            }
1701:
1702:            // check element ID
1703:            public static boolean isErrorElementID(String pID) {
1704:                if (pID != null) {
1705:                    for (int i = 0; i < sModelErrors.size(); i++) {
1706:                        ModelErrorDescription lDescription = (ModelErrorDescription) sModelErrors
1707:                                .get(i);
1708:                        if (lDescription != null) {
1709:                            for (int k = 0; k < lDescription.getCount(); k++) {
1710:                                ModelValidationException lError = lDescription
1711:                                        .getError();
1712:                                if (lError != null) {
1713:                                    String lID = lError
1714:                                            .getErrorModelElementRepositoryId(k);
1715:                                    if (lID != null && lID.equals(pID))
1716:                                        return true;
1717:                                }
1718:                            }
1719:                        }
1720:                    }
1721:                }
1722:                return false;
1723:            }
1724:
1725:            // validate models
1726:            public static void validateModels(boolean pSilent, boolean pCheck) {
1727:                Cursor lCursor = mainFrame.getCursor();
1728:                try {
1729:                    mainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
1730:
1731:                    int lErrorsCount = getErrorsCount();
1732:                    try {
1733:                        //???sModelErrors.clear();
1734:                        String[] lModels = sModelRepository.listModelNames();
1735:                        if (lModels != null)
1736:                            for (int i = 0; i < lModels.length; i++)
1737:                                if (!pCheck
1738:                                        || sModelRepository
1739:                                                .isModelModified(lModels[i]))
1740:                                    validateModel(lModels[i]);
1741:                    } catch (Exception e) {
1742:                        e.printStackTrace();
1743:                    }
1744:
1745:                    int lNewErrorsCount = getErrorsCount();
1746:                    if (/*!pSilent ||*/lErrorsCount != lNewErrorsCount)
1747:                        fireOnErrorsFound();
1748:                    if (!pSilent && lNewErrorsCount == 0)
1749:                        showInformation(getString("validation_ok"));
1750:                } finally {
1751:                    mainFrame.setCursor(lCursor);
1752:                }
1753:            }
1754:
1755:            // validate and save model
1756:            public static void validateModel(String pModelName)
1757:                    throws Exception {
1758:                try {
1759:                    removeModelErrors(pModelName);
1760:                    sModelRepository.validateModel(pModelName);
1761:                } catch (ModelValidationException e) {
1762:                    sModelErrors.add(new ModelErrorDescription(pModelName, e));
1763:                } catch (Exception e) {
1764:                    e.printStackTrace();
1765:                }
1766:            }
1767:
1768:            public static void validateModel(ModelUserObject pModel) {
1769:                Cursor lCursor = mainFrame.getCursor();
1770:                try {
1771:                    mainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
1772:                    try {
1773:                        validateModel(pModel.getFileName());
1774:                    } catch (Exception e) {
1775:                        e.printStackTrace();
1776:                    }
1777:                    fireOnErrorsFound();
1778:                } finally {
1779:                    mainFrame.setCursor(lCursor);
1780:                }
1781:            }
1782:
1783:            // rectify model
1784:            public static void rectifyModel(String pModelName) {
1785:                try {
1786:                    sModelRepository.rectifyModel(pModelName);
1787:                } catch (Exception e) {
1788:                    e.printStackTrace();
1789:                }
1790:            }
1791:
1792:            public static void rectifyModel(ModelUserObject pModel) {
1793:                Cursor lCursor = mainFrame.getCursor();
1794:                try {
1795:                    mainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
1796:
1797:                    try {
1798:                        removeModelErrors(pModel);
1799:                        rectifyModel(pModel.getFileName());
1800:                    } catch (Exception e) {
1801:                        e.printStackTrace();
1802:                    }
1803:                } finally {
1804:                    mainFrame.setCursor(lCursor);
1805:                }
1806:                validateModel(pModel);
1807:            }
1808:
1809:            // export model
1810:            public static void exportModel(ModelUserObject pModel,
1811:                    boolean pInUML) throws Exception {
1812:                JFileChooser lChooser = new JFileChooser();
1813:                ModelFileFilter lFilter = new ModelFileFilter();
1814:
1815:                lChooser.setDialogTitle("Select XML File");
1816:                lFilter.addExtension("xml");
1817:                lFilter.setDescription("XML files");
1818:                lChooser.setFileFilter(lFilter);
1819:                if (Application.properties.mLastDir != null)
1820:                    lChooser.setCurrentDirectory((new File(
1821:                            Application.properties.mLastDir)).getParentFile());
1822:                lChooser.setSelectedFile(new File(pModel.getModelName()
1823:                        + ".xml"));
1824:
1825:                int returnVal = lChooser.showSaveDialog(mainFrame);
1826:                if (returnVal == JFileChooser.APPROVE_OPTION) {
1827:                    File lFile = lChooser.getSelectedFile();
1828:                    Cursor lCursor = mainFrame.getCursor();
1829:                    try {
1830:                        mainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
1831:                        // If we have ben asked to export as UML, we need to convert it first
1832:                        String lModelName = pModel.getFileName();
1833:                        if (pInUML) {
1834:                            // Pick a name for the temporary model
1835:                            String lTempUMLModelName = "TempUML_TempUML_TempUML_"
1836:                                    + lModelName + "_TempUML_TempUML_TempUML";
1837:                            try {
1838:                                ModelUtils.convertMetaBossModelToUMLModel(
1839:                                        lModelName, lTempUMLModelName);
1840:                                sModelRepository.exportModel(lTempUMLModelName,
1841:                                        false, lFile, new Properties());
1842:                            } finally {
1843:                                // Close the temporary model.
1844:                                if (sModelRepository
1845:                                        .containsModel(lTempUMLModelName))
1846:                                    sModelRepository
1847:                                            .closeModel(lTempUMLModelName);
1848:                            }
1849:                        } else
1850:                            sModelRepository.exportModel(pModel.getFileName(),
1851:                                    false, lFile, new Properties());
1852:                        Application.properties.mLastDir = lFile.getPath();
1853:                        Object[] arguments = { pModel.getModelName(),
1854:                                lFile.getPath() };
1855:                        showInformation(java.text.MessageFormat.format(
1856:                                getString("exported_message"), arguments));
1857:                    } finally {
1858:                        mainFrame.setCursor(lCursor);
1859:                    }
1860:                }
1861:            }
1862:
1863:            // copy Model Element
1864:            public static void copyModelElement(BaseUserObject pObject,
1865:                    ModelUserObject pCurrentPackage) {
1866:                ArrayList lList = new ArrayList();
1867:                for (int i = 0; i < getModelsCount(); i++) {
1868:                    ModelUserObject lObject = getModel(i);
1869:                    if (!lObject.isSystem() && !lObject.equals(pCurrentPackage))
1870:                        lList.add(lObject);
1871:                }
1872:
1873:                if (lList.size() > 0) {
1874:                    CopyElementDialog lDialog = new CopyElementDialog(
1875:                            mainFrame, lList);
1876:                    if (lDialog.getModalResult() == CopyElementDialog.MR_OK) {
1877:                        for (int i = 0; i < getModelsCount(); i++) {
1878:                            ModelUserObject lObject = getModel(i);
1879:                            if (lList.contains(lObject)) {
1880:                                try {
1881:                                    copyModelElement(lObject, pObject);
1882:                                } catch (Exception e) {
1883:                                    processError(e);
1884:                                }
1885:                            }
1886:                        }
1887:                    }
1888:                }
1889:            }
1890:
1891:            public static void copyModelElement(ModelUserObject pModel,
1892:                    BaseUserObject pObject) throws Exception {
1893:                if (pModel == null || pObject == null || pModel.isSystem())
1894:                    return;
1895:                Enterprise lEnterprise = (Enterprise) pModel.getRootElement();
1896:                if (lEnterprise == null)
1897:                    return;
1898:                Cursor lCursor = mainFrame.getCursor();
1899:                try {
1900:                    mainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
1901:
1902:                    boolean lInTransaction = isInTransaction();
1903:                    if (!lInTransaction)
1904:                        beginTransaction();
1905:                    try {
1906:                        ModelElement lSourceModelElement = pObject
1907:                                .getBOObject();
1908:                        if (lSourceModelElement instanceof  Namespace
1909:                                || lSourceModelElement instanceof  TypeTemplate
1910:                                || lSourceModelElement instanceof  Structure
1911:                                || lSourceModelElement instanceof  Message
1912:                                || lSourceModelElement instanceof  DataType) {
1913:                            DataDictionary lSourceOwnerDataDictionary = null;
1914:                            if (lSourceModelElement instanceof  Namespace)
1915:                                lSourceOwnerDataDictionary = ((Namespace) lSourceModelElement)
1916:                                        .getOwnerDataDictionary();
1917:                            else if (lSourceModelElement instanceof  TypeTemplate)
1918:                                lSourceOwnerDataDictionary = ((TypeTemplate) lSourceModelElement)
1919:                                        .getOwnerDataDictionary();
1920:                            else if (lSourceModelElement instanceof  DataType)
1921:                                lSourceOwnerDataDictionary = ((DataType) lSourceModelElement)
1922:                                        .getOwnerDataDictionary();
1923:                            else if (lSourceModelElement instanceof  Message)
1924:                                lSourceOwnerDataDictionary = ((Message) lSourceModelElement)
1925:                                        .getOwnerDataDictionary();
1926:                            else if (lSourceModelElement instanceof  Structure)
1927:                                lSourceOwnerDataDictionary = ((Structure) lSourceModelElement)
1928:                                        .getOwnerDataDictionary();
1929:
1930:                            // Get or create target data dictionary (use shallow copy)
1931:                            DataDictionary lTargetOwnerDictionary = lEnterprise
1932:                                    .getDesignLibrary().findDataDictionary(
1933:                                            lSourceOwnerDataDictionary
1934:                                                    .getName());
1935:                            if (lTargetOwnerDictionary == null) {
1936:                                lTargetOwnerDictionary = (DataDictionary) sModelRepository
1937:                                        .copyModelElement(
1938:                                                lSourceOwnerDataDictionary,
1939:                                                sModelRepository
1940:                                                        .getOwnerModelName(lEnterprise),
1941:                                                false, null);
1942:                            }
1943:
1944:                            // Find or create target namespace and the whole tree above it 
1945:                            // This will ensure that the taget model has the Namespace where the Namespace/TypeTemplate/DataType must be created
1946:                            List lSourcePathWithoutDictionary = null;
1947:                            if (lSourceModelElement instanceof  TypeTemplate)
1948:                                lSourcePathWithoutDictionary = ((TypeTemplate) lSourceModelElement)
1949:                                        .getNamespace()
1950:                                        .getPathWithoutDictionary();
1951:                            else if (lSourceModelElement instanceof  DataType)
1952:                                lSourcePathWithoutDictionary = ((DataType) lSourceModelElement)
1953:                                        .getNamespace()
1954:                                        .getPathWithoutDictionary();
1955:                            else if (lSourceModelElement instanceof  Namespace)
1956:                                lSourcePathWithoutDictionary = ((Namespace) lSourceModelElement)
1957:                                        .getNamespace()
1958:                                        .getPathWithoutDictionary();
1959:                            else if (lSourceModelElement instanceof  Message)
1960:                                lSourcePathWithoutDictionary = ((Message) lSourceModelElement)
1961:                                        .getNamespace()
1962:                                        .getPathWithoutDictionary();
1963:                            else if (lSourceModelElement instanceof  Structure)
1964:                                lSourcePathWithoutDictionary = ((Structure) lSourceModelElement)
1965:                                        .getNamespace()
1966:                                        .getPathWithoutDictionary();
1967:
1968:                            AbstractNamespace lTargetParentNamespace = lTargetOwnerDictionary;
1969:                            for (Iterator lSourceNamespaceIterator = lSourcePathWithoutDictionary
1970:                                    .iterator(); lSourceNamespaceIterator
1971:                                    .hasNext();) {
1972:                                AbstractNamespace lSourceNamespace = (AbstractNamespace) lSourceNamespaceIterator
1973:                                        .next();
1974:                                AbstractNamespace lTargetNamespace = lTargetParentNamespace
1975:                                        .findSubNamespace(lSourceNamespace
1976:                                                .getName());
1977:                                if (lTargetNamespace == null) {
1978:                                    // Namespace is not present - create shallow copy of the source.
1979:                                    lTargetNamespace = (Namespace) sModelRepository
1980:                                            .copyModelElement(lSourceNamespace,
1981:                                                    pModel.getFileName(),
1982:                                                    false, null);
1983:                                    lTargetParentNamespace.getSubNamespaces()
1984:                                            .add(lTargetNamespace);
1985:                                }
1986:                                // Step down one level
1987:                                lTargetParentNamespace = lTargetNamespace;
1988:                            }
1989:                            // We now have the target parent namespace, check if it already has the element same to what we have been asked to copy
1990:                            if (lSourceModelElement instanceof  TypeTemplate) {
1991:                                TypeTemplate lSourceTypeTemplate = (TypeTemplate) lSourceModelElement;
1992:                                TypeTemplate lTargetTypeTemplate = lTargetParentNamespace
1993:                                        .findTypeTemplate(lSourceTypeTemplate
1994:                                                .getName());
1995:                                if (lTargetTypeTemplate != null) {
1996:                                    if (JOptionPane
1997:                                            .showConfirmDialog(
1998:                                                    mainFrame,
1999:                                                    "TypeTemplate "
2000:                                                            + lSourceTypeTemplate
2001:                                                                    .getName()
2002:                                                            + " already exists in the target model. Do you wish to overwrite it?",
2003:                                                    "Copy Model Element",
2004:                                                    JOptionPane.YES_NO_OPTION,
2005:                                                    JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION)
2006:                                        sModelRepository.retrofitModelElement(
2007:                                                lSourceTypeTemplate,
2008:                                                lTargetTypeTemplate,
2009:                                                ModelElementResolverImpl
2010:                                                        .getInstance());
2011:                                } else {
2012:                                    lTargetTypeTemplate = (TypeTemplate) sModelRepository
2013:                                            .copyModelElement(
2014:                                                    lSourceTypeTemplate, pModel
2015:                                                            .getFileName(),
2016:                                                    true,
2017:                                                    ModelElementResolverImpl
2018:                                                            .getInstance());
2019:                                    lTargetTypeTemplate
2020:                                            .setNamespace(lTargetParentNamespace);
2021:                                }
2022:                            } else if (lSourceModelElement instanceof  DataType) {
2023:                                DataType lSourceDataType = (DataType) lSourceModelElement;
2024:                                DataType lTargetDataType = lTargetParentNamespace
2025:                                        .findDataType(lSourceDataType.getName());
2026:                                if (lTargetDataType != null) {
2027:                                    if (JOptionPane
2028:                                            .showConfirmDialog(
2029:                                                    mainFrame,
2030:                                                    "DataType "
2031:                                                            + lSourceDataType
2032:                                                                    .getName()
2033:                                                            + " already exists in the target model. Do you wish to overwrite it?",
2034:                                                    "Copy Model Element",
2035:                                                    JOptionPane.YES_NO_OPTION,
2036:                                                    JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION)
2037:                                        sModelRepository.retrofitModelElement(
2038:                                                lSourceDataType,
2039:                                                lTargetDataType,
2040:                                                ModelElementResolverImpl
2041:                                                        .getInstance());
2042:                                } else {
2043:                                    lTargetDataType = (DataType) sModelRepository
2044:                                            .copyModelElement(lSourceDataType,
2045:                                                    pModel.getFileName(), true,
2046:                                                    ModelElementResolverImpl
2047:                                                            .getInstance());
2048:                                    lTargetDataType
2049:                                            .setNamespace(lTargetParentNamespace);
2050:                                }
2051:                            } else if (lSourceModelElement instanceof  Structure) {
2052:                                Structure lSourceStructure = (Structure) lSourceModelElement;
2053:                                Structure lTargetStructure = lTargetParentNamespace
2054:                                        .findStructure(lSourceStructure
2055:                                                .getName());
2056:                                if (lTargetStructure != null) {
2057:                                    if (JOptionPane
2058:                                            .showConfirmDialog(
2059:                                                    mainFrame,
2060:                                                    "Structure "
2061:                                                            + lSourceStructure
2062:                                                                    .getName()
2063:                                                            + " already exists in the target model. Do you wish to overwrite it?",
2064:                                                    "Copy Model Element",
2065:                                                    JOptionPane.YES_NO_OPTION,
2066:                                                    JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION)
2067:                                        sModelRepository.retrofitModelElement(
2068:                                                lSourceStructure,
2069:                                                lTargetStructure,
2070:                                                ModelElementResolverImpl
2071:                                                        .getInstance());
2072:                                } else {
2073:                                    lTargetStructure = (Structure) sModelRepository
2074:                                            .copyModelElement(lSourceStructure,
2075:                                                    pModel.getFileName(), true,
2076:                                                    ModelElementResolverImpl
2077:                                                            .getInstance());
2078:                                    lTargetStructure
2079:                                            .setNamespace(lTargetParentNamespace);
2080:                                }
2081:                            } else if (lSourceModelElement instanceof  Message) {
2082:                                Message lSourceMessage = (Message) lSourceModelElement;
2083:                                Message lTargetMessage = lTargetParentNamespace
2084:                                        .findMessage(lSourceMessage.getName());
2085:                                if (lTargetMessage != null) {
2086:                                    if (JOptionPane
2087:                                            .showConfirmDialog(
2088:                                                    mainFrame,
2089:                                                    "Message "
2090:                                                            + lSourceMessage
2091:                                                                    .getName()
2092:                                                            + " already exists in the target model. Do you wish to overwrite it?",
2093:                                                    "Copy Model Element",
2094:                                                    JOptionPane.YES_NO_OPTION,
2095:                                                    JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION)
2096:                                        sModelRepository.retrofitModelElement(
2097:                                                lSourceMessage, lTargetMessage,
2098:                                                ModelElementResolverImpl
2099:                                                        .getInstance());
2100:                                } else {
2101:                                    lTargetMessage = (Message) sModelRepository
2102:                                            .copyModelElement(lSourceMessage,
2103:                                                    pModel.getFileName(), true,
2104:                                                    ModelElementResolverImpl
2105:                                                            .getInstance());
2106:                                    lTargetMessage
2107:                                            .setNamespace(lTargetParentNamespace);
2108:                                }
2109:                            } else if (lSourceModelElement instanceof  Namespace) {
2110:                                Namespace lSourceNamespace = (Namespace) lSourceModelElement;
2111:                                Namespace lTargetNamespace = lTargetParentNamespace
2112:                                        .findSubNamespace(lSourceNamespace
2113:                                                .getName());
2114:                                if (lTargetNamespace != null) {
2115:                                    if (JOptionPane
2116:                                            .showConfirmDialog(
2117:                                                    mainFrame,
2118:                                                    "Namespace "
2119:                                                            + lSourceNamespace
2120:                                                                    .getName()
2121:                                                            + " already exists in the target model. Do you wish to overwrite it?",
2122:                                                    "Copy Model Element",
2123:                                                    JOptionPane.YES_NO_OPTION,
2124:                                                    JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION)
2125:                                        sModelRepository.retrofitModelElement(
2126:                                                lSourceNamespace,
2127:                                                lTargetNamespace,
2128:                                                ModelElementResolverImpl
2129:                                                        .getInstance());
2130:                                } else {
2131:                                    lTargetNamespace = (Namespace) sModelRepository
2132:                                            .copyModelElement(lSourceNamespace,
2133:                                                    pModel.getFileName(), true,
2134:                                                    ModelElementResolverImpl
2135:                                                            .getInstance());
2136:                                    lTargetNamespace
2137:                                            .setNamespace(lTargetParentNamespace);
2138:                                }
2139:                            }
2140:                        } else if (lSourceModelElement instanceof  RelationalStorageTechnology) {
2141:                            RelationalStorageTechnology lSourceRelationalStorageTechnology = (RelationalStorageTechnology) lSourceModelElement;
2142:                            checkObjectAlreadyIn(pModel.getModelName(),
2143:                                    pObject, lEnterprise.getTechnologyLibrary()
2144:                                            .getStorageTechnologies());
2145:                            RelationalStorageTechnology lTargetRelationalStorageTechnology = (RelationalStorageTechnology) sModelRepository
2146:                                    .copyModelElement(
2147:                                            lSourceRelationalStorageTechnology,
2148:                                            pModel.getFileName(), true,
2149:                                            ModelElementResolverImpl
2150:                                                    .getInstance());
2151:                            lEnterprise.getTechnologyLibrary()
2152:                                    .getStorageTechnologies().add(
2153:                                            lTargetRelationalStorageTechnology);
2154:                        } else if (lSourceModelElement instanceof  DataDictionary) {
2155:                            DataDictionary lSourceDataDictionary = (DataDictionary) lSourceModelElement;
2156:                            DesignLibrary lTargetDesignLibrary = lEnterprise
2157:                                    .getDesignLibrary();
2158:                            // Retrofit existing or create new data dictionary in the target model
2159:                            DataDictionary lTargetDataDictionary = lTargetDesignLibrary
2160:                                    .findDataDictionary(lSourceDataDictionary
2161:                                            .getName());
2162:                            if (lTargetDataDictionary != null) {
2163:                                if (JOptionPane
2164:                                        .showConfirmDialog(
2165:                                                mainFrame,
2166:                                                "Data Dictionary "
2167:                                                        + lSourceDataDictionary
2168:                                                                .getName()
2169:                                                        + " already exists in the target model. Do you wish to overwrite it?",
2170:                                                "Copy Model Element",
2171:                                                JOptionPane.YES_NO_OPTION,
2172:                                                JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION)
2173:                                    sModelRepository.retrofitModelElement(
2174:                                            lSourceDataDictionary,
2175:                                            lTargetDataDictionary,
2176:                                            ModelElementResolverImpl
2177:                                                    .getInstance());
2178:                            } else {
2179:                                lTargetDataDictionary = (DataDictionary) sModelRepository
2180:                                        .copyModelElement(
2181:                                                lSourceDataDictionary,
2182:                                                sModelRepository
2183:                                                        .getOwnerModelName(lEnterprise),
2184:                                                true, ModelElementResolverImpl
2185:                                                        .getInstance());
2186:                                lTargetDataDictionary
2187:                                        .setDesignLibrary(lTargetDesignLibrary);
2188:                            }
2189:                        } else if (lSourceModelElement instanceof  com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System) {
2190:                            com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSourceSystem = (com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System) lSourceModelElement;
2191:                            com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lTargetSystem = lEnterprise
2192:                                    .findSystem(lSourceSystem.getName());
2193:                            // Retrofit existing or create new system in the target model
2194:                            if (lTargetSystem != null) {
2195:                                if (JOptionPane
2196:                                        .showConfirmDialog(
2197:                                                mainFrame,
2198:                                                "System "
2199:                                                        + lSourceSystem
2200:                                                                .getName()
2201:                                                        + " already exists in the target model. Do you wish to overwrite it?",
2202:                                                "Copy Model Element",
2203:                                                JOptionPane.YES_NO_OPTION,
2204:                                                JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION)
2205:                                    sModelRepository.retrofitModelElement(
2206:                                            lSourceSystem, lTargetSystem,
2207:                                            ModelElementResolverImpl
2208:                                                    .getInstance());
2209:                            } else {
2210:                                lTargetSystem = (com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System) sModelRepository
2211:                                        .copyModelElement(
2212:                                                lSourceSystem,
2213:                                                sModelRepository
2214:                                                        .getOwnerModelName(lEnterprise),
2215:                                                true, ModelElementResolverImpl
2216:                                                        .getInstance());
2217:                                lTargetSystem.setEnterprise(lEnterprise);
2218:                            }
2219:                        }
2220:                        if (!lInTransaction)
2221:                            commit();
2222:                    } finally {
2223:                        if (!lInTransaction)
2224:                            checkAndRollback();
2225:                    }
2226:                } finally {
2227:                    mainFrame.setCursor(lCursor);
2228:                }
2229:            }
2230:
2231:            // get TypeTemplate for newly copied DataType
2232:            private static TypeTemplate getTypeTemplateForNewDataType(
2233:                    ModelUserObject pModel, BaseUserObject pOldDataType,
2234:                    DataDictionary pDictionary) {
2235:                TypeTemplate lResult = null;
2236:                if (pModel != null && pOldDataType != null
2237:                        && pDictionary != null) {
2238:                    TypeTemplate lOldTypeTemplate = ((DataType) pOldDataType
2239:                            .getBOObject()).getTypetemplate();
2240:                    if (lOldTypeTemplate != null) {
2241:                        lResult = findTypeTemplate(pDictionary,
2242:                                lOldTypeTemplate.getName());
2243:                        if (lResult == null) {
2244:                            int n = JOptionPane
2245:                                    .showConfirmDialog(
2246:                                            mainFrame,
2247:                                            java.text.MessageFormat
2248:                                                    .format(
2249:                                                            getString("notypetemplate_message"),
2250:                                                            new Object[] { pModel
2251:                                                                    .getModelName() }),
2252:                                            getString("confirm"),
2253:                                            JOptionPane.YES_NO_OPTION);
2254:                            switch (n) {
2255:                            case 0:
2256:                                try {
2257:                                    copyModelElement(pModel, UserObjectFactory
2258:                                            .createUserObject(lOldTypeTemplate));
2259:                                    lResult = findTypeTemplate(pDictionary,
2260:                                            lOldTypeTemplate.getName());
2261:                                } catch (Exception e) {
2262:                                    processError(e);
2263:                                }
2264:                                break;
2265:                            }
2266:                        }
2267:                    }
2268:                }
2269:                return lResult;
2270:            }
2271:
2272:            private static TypeTemplate findTypeTemplate(
2273:                    AbstractNamespace pNameSpace, String pName) {
2274:                TypeTemplate lResult = null;
2275:                if (pNameSpace != null) {
2276:                    lResult = pNameSpace.findTypeTemplate(pName);
2277:                    if (lResult == null) {
2278:                        Object[] lNameSpaces = pNameSpace.getSubNamespaces()
2279:                                .toArray();
2280:                        for (int i = 0; i < lNameSpaces.length; i++) {
2281:                            lResult = findTypeTemplate(
2282:                                    (AbstractNamespace) lNameSpaces[i], pName);
2283:                            if (lResult != null)
2284:                                break;
2285:                        }
2286:                    }
2287:                }
2288:                return lResult;
2289:            }
2290:
2291:            private static void checkObjectAlreadyIn(String pModelName,
2292:                    BaseUserObject pObject, Collection pCollection)
2293:                    throws Exception {
2294:                if (pObject != null && pCollection != null) {
2295:                    ModelElement lElement = findModelElement(pObject
2296:                            .getBOObject(), pCollection.toArray());
2297:                    if (lElement != null)
2298:                        throw new ModelWarning(java.text.MessageFormat.format(
2299:                                getString("elementalreadyin_message"),
2300:                                new Object[] { pModelName,
2301:                                        pObject.getElementType(),
2302:                                        pObject.toString() }));
2303:                }
2304:            }
2305:
2306:            private static ModelElement findModelElement(
2307:                    ModelElement pModelElement, Object[] pElements) {
2308:                if (pElements != null) {
2309:                    for (int i = 0; i < pElements.length; i++) {
2310:                        ModelElement lModelElement = (ModelElement) pElements[i];
2311:                        if (lModelElement.getName().equals(
2312:                                pModelElement.getName()))
2313:                            return lModelElement;
2314:                    }
2315:                }
2316:                return null;
2317:            }
2318:
2319:            // load license information
2320:            public static void loadLicenseInfo() {
2321:                try {
2322:                    synchronized (sClassInitialisationSemaphore) {
2323:                        try {
2324:                            javax.naming.Context lCtx = new javax.naming.InitialContext();
2325:                            sLicenseService = (LicenseService) lCtx
2326:                                    .lookup(LicenseService.COMPONENT_URL);
2327:                        } catch (javax.naming.NamingException e) {
2328:                            throw new BSNamingAndDirectoryServiceInvocationException(
2329:                                    "Unable to initialise CopyrightUtils", e);
2330:                        }
2331:                    }
2332:                } catch (Exception e) {
2333:                    e.printStackTrace();
2334:                }
2335:            }
2336:
2337:            // process application event
2338:            protected void processEvent(AWTEvent e) {
2339:                if (e instanceof  OptionsChangedEvent) {
2340:                    EventListener[] listeners = listenerList
2341:                            .getListeners(OptionsChangedListener.class);
2342:                    for (int i = 0; i < listeners.length; i++)
2343:                        ((OptionsChangedListener) listeners[i])
2344:                                .optionsChanged((OptionsChangedEvent) e);
2345:                } else if (e instanceof  RefreshEvent) {
2346:                    EventListener[] listeners = listenerList
2347:                            .getListeners(RefreshListener.class);
2348:                    for (int i = 0; i < listeners.length; i++)
2349:                        ((RefreshListener) listeners[i])
2350:                                .refresh((RefreshEvent) e);
2351:                } else if (e instanceof  ObjectChangedEvent) {
2352:                    EventListener[] listeners = listenerList
2353:                            .getListeners(ObjectChangedListener.class);
2354:                    for (int i = 0; i < listeners.length; i++)
2355:                        ((ObjectChangedListener) listeners[i])
2356:                                .onObjectChanged((ObjectChangedEvent) e);
2357:                } else if (e instanceof  ShowContainerEvent) {
2358:                    EventListener[] listeners = listenerList
2359:                            .getListeners(ShowContainerListener.class);
2360:                    for (int i = 0; i < listeners.length; i++)
2361:                        ((ShowContainerListener) listeners[i])
2362:                                .showContainer((ShowContainerEvent) e);
2363:                } else if (e instanceof  OnContainerCloseEvent) {
2364:                    EventListener[] listeners = listenerList
2365:                            .getListeners(OnContainerCloseListener.class);
2366:                    for (int i = 0; i < listeners.length; i++)
2367:                        ((OnContainerCloseListener) listeners[i])
2368:                                .closeContainer((OnContainerCloseEvent) e);
2369:                } else if (e instanceof  OnContainerChangedEvent) {
2370:                    EventListener[] listeners = listenerList
2371:                            .getListeners(OnContainerChangedListener.class);
2372:                    for (int i = 0; i < listeners.length; i++)
2373:                        ((OnContainerChangedListener) listeners[i])
2374:                                .containerChanged((OnContainerChangedEvent) e);
2375:                } else if (e instanceof  OnErrorsFoundEvent) {
2376:                    EventListener[] listeners = listenerList
2377:                            .getListeners(OnErrorsFoundListener.class);
2378:                    for (int i = 0; i < listeners.length; i++)
2379:                        ((OnErrorsFoundListener) listeners[i])
2380:                                .errorsFound((OnErrorsFoundEvent) e);
2381:                } else if (e instanceof  OnModelChangedEvent) {
2382:                    EventListener[] listeners = listenerList
2383:                            .getListeners(OnModelChangedListener.class);
2384:                    for (int i = 0; i < listeners.length; i++)
2385:                        ((OnModelChangedListener) listeners[i])
2386:                                .modelChanged((OnModelChangedEvent) e);
2387:                } else if (e instanceof  CloseModelEvent) {
2388:                    EventListener[] listeners = listenerList
2389:                            .getListeners(CloseModelListener.class);
2390:                    for (int i = 0; i < listeners.length; i++)
2391:                        ((CloseModelListener) listeners[i])
2392:                                .closeModel((CloseModelEvent) e);
2393:                } else if (e instanceof  RefreshDiagramsEvent) {
2394:                    EventListener[] listeners = listenerList
2395:                            .getListeners(RefreshDiagramsEventListener.class);
2396:                    for (int i = 0; i < listeners.length; i++)
2397:                        ((RefreshDiagramsEventListener) listeners[i])
2398:                                .refreshDiagram((RefreshDiagramsEvent) e);
2399:                } else if (e instanceof  OnElementIndexChangedEvent) {
2400:                    EventListener[] listeners = listenerList
2401:                            .getListeners(OnElemenIndexChangedEventListener.class);
2402:                    for (int i = 0; i < listeners.length; i++)
2403:                        ((OnElemenIndexChangedEventListener) listeners[i])
2404:                                .indexChanged((OnElementIndexChangedEvent) e);
2405:                } else
2406:                    super .processEvent(e);
2407:            }
2408:
2409:            private void configureUI() {
2410:                UIManager.put(Options.USE_SYSTEM_FONTS_APP_KEY, Boolean.TRUE);
2411:                Options.setGlobalFontSizeHints(FontSizeHints.MIXED);
2412:                Options.setDefaultIconSize(new Dimension(18, 18));
2413:
2414:                //String lafName =
2415:                //	LookUtils.isWindowsXP()
2416:                //		? Options.getCrossPlatformLookAndFeelClassName()
2417:                //		: Options.getSystemLookAndFeelClassName();
2418:
2419:                //String lafName = Options.getSystemLookAndFeelClassName();
2420:
2421:                String lafName = Options.getCrossPlatformLookAndFeelClassName();
2422:                try {
2423:                    UIManager.setLookAndFeel(lafName);
2424:
2425:                    //PlasticLookAndFeel.setMyCurrentTheme(new DesertBluer());
2426:                    //UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
2427:                } catch (Exception e) {
2428:                    System.err.println("Can't set look & feel:" + e);
2429:                }
2430:            }
2431:
2432:            private void startUI() {
2433:                try {
2434:                    mainFrame = new MainFrame();
2435:                    mainFrame.makeVisible();
2436:                    if (!getRegistered())
2437:                        new AboutDialog(mainFrame);
2438:                } catch (Throwable t) {
2439:                    t.printStackTrace();
2440:                }
2441:            }
2442:
2443:            // check and correct Metaboss system variables
2444:            public static void checkPath() {
2445:                // Ensure that MetaBoss.Home is given and accessible
2446:                String lMetaBossHome = System.getProperty("MetaBoss.Home");
2447:                if (lMetaBossHome == null) {
2448:                    System.out
2449:                            .println("MetaBoss.Home system property must be specified.");
2450:                    System.exit(1);
2451:                }
2452:                File lMetaBossHomeFile = new File(lMetaBossHome)
2453:                        .getAbsoluteFile();
2454:                if (lMetaBossHomeFile.exists() == false
2455:                        || lMetaBossHomeFile.isDirectory() == false
2456:                        || lMetaBossHomeFile.canRead() == false) {
2457:                    System.out
2458:                            .println("MetaBoss.Home system property does not point to accessible directory: "
2459:                                    + lMetaBossHomeFile.getAbsolutePath());
2460:                    System.exit(1);
2461:                }
2462:                // Set property to absolute, so no one will have any troubles
2463:                System.setProperty("MetaBoss.Home", lMetaBossHomeFile
2464:                        .getAbsolutePath());
2465:
2466:                // Ensure that MetaBoss.SystemDefinitionPath is given and accessible
2467:                /*String lMetaBossSystemDefinitionPath = System.getProperty("MetaBoss.SystemDefinitionPath");
2468:                if (lMetaBossSystemDefinitionPath == null)
2469:                {
2470:                	System.out.println("MetaBoss.SystemDefinitionPath system property must be specified.");
2471:                	System.exit(1);
2472:                }
2473:                File lMetaBossSystemDefinitionPathFile = new File(lMetaBossSystemDefinitionPath).getAbsoluteFile();
2474:                if (lMetaBossSystemDefinitionPathFile.exists() == false ||
2475:                	lMetaBossSystemDefinitionPathFile.isDirectory() == false ||
2476:                	lMetaBossSystemDefinitionPathFile.canRead() == false)
2477:                {
2478:                	System.out.println("MetaBoss.SystemDefinitionPath system property does not point to accessible directory: " + lMetaBossSystemDefinitionPathFile.getAbsolutePath());
2479:                	System.exit(1);
2480:                }
2481:                // Set property to absolute, so no one will have any troubles
2482:                System.setProperty("MetaBoss.SystemDefinitionPath",lMetaBossSystemDefinitionPathFile.getAbsolutePath());*/
2483:            }
2484:
2485:            /*					Auxilary classes						*/
2486:
2487:            /*						Events								*/
2488:
2489:            /*			Application Options Changed Event				*/
2490:
2491:            public class OptionsChangedEvent extends AWTEvent {
2492:                public static final int OPTIONS_EVENT = AWTEvent.RESERVED_ID_MAX + 998;
2493:                private boolean mMetabossChanged = false;
2494:
2495:                public OptionsChangedEvent() {
2496:                    super (Application.instance, OPTIONS_EVENT);
2497:                }
2498:
2499:                public OptionsChangedEvent(boolean pMetabossChanged) {
2500:                    super (Application.instance, OPTIONS_EVENT);
2501:                    mMetabossChanged = pMetabossChanged;
2502:                }
2503:
2504:                public boolean getMetabossChanged() {
2505:                    return mMetabossChanged;
2506:                }
2507:            }
2508:
2509:            /*		Options Changed Event Listener				*/
2510:
2511:            public interface OptionsChangedListener extends EventListener {
2512:                public void optionsChanged(OptionsChangedEvent event);
2513:            }
2514:
2515:            /*			Application Refresh Event				*/
2516:
2517:            public class RefreshEvent extends AWTEvent {
2518:                public static final int REFRESH_EVENT = AWTEvent.RESERVED_ID_MAX + 997;
2519:
2520:                public RefreshEvent() {
2521:                    super (Application.instance, REFRESH_EVENT);
2522:                }
2523:            }
2524:
2525:            /*				Refresh Event Listener				*/
2526:
2527:            public interface RefreshListener extends EventListener {
2528:                public void refresh(RefreshEvent event);
2529:            }
2530:
2531:            /*	     Application Model Object Changed Event	*/
2532:
2533:            public class ObjectChangedEvent extends AWTEvent {
2534:                public static final int OBJECTCHANGED_EVENT = AWTEvent.RESERVED_ID_MAX + 996;
2535:                public static final int ET_SELECTED = 0;
2536:                public static final int ET_EDITED = 1;
2537:                public static final int ET_INSERTED = 2;
2538:                public static final int ET_DELETED = 3;
2539:                public static final int ET_SELECT = 4;
2540:                public static final int ET_MOVED = 5;
2541:
2542:                private BaseUserObject mUserObject = null;
2543:                private String mID = null;
2544:                private String mModelName = null;
2545:                private int mSource = ET_SELECTED;
2546:
2547:                public ObjectChangedEvent(BaseUserObject pUserObject,
2548:                        int pSource) {
2549:                    super (Application.instance, OBJECTCHANGED_EVENT);
2550:                    mUserObject = pUserObject;
2551:                    if (mUserObject != null)
2552:                        mID = mUserObject.getID();
2553:                    mSource = pSource;
2554:                }
2555:
2556:                public ObjectChangedEvent(String pID, String pModelName,
2557:                        int pSource) {
2558:                    super (Application.instance, OBJECTCHANGED_EVENT);
2559:                    mID = pID;
2560:                    mModelName = pModelName;
2561:                    mSource = pSource;
2562:                }
2563:
2564:                public BaseUserObject getUserObject() {
2565:                    return mUserObject;
2566:                }
2567:
2568:                public String getObjectID() {
2569:                    return mID;
2570:                }
2571:
2572:                public String getModelName() {
2573:                    return mModelName;
2574:                }
2575:
2576:                public int getEventSource() {
2577:                    return mSource;
2578:                }
2579:            }
2580:
2581:            /*			Model Changed Event Listener			    */
2582:
2583:            public interface ObjectChangedListener extends EventListener {
2584:                public void onObjectChanged(ObjectChangedEvent event);
2585:            }
2586:
2587:            /*			Application Show Container Event				*/
2588:
2589:            public class ShowContainerEvent extends AWTEvent {
2590:                public static final int SHOWCONTANER_EVENT = AWTEvent.RESERVED_ID_MAX + 996;
2591:                private BaseChildPanel mContainer = null;
2592:                private BaseUserObject mObject = null;
2593:                private Icon mIcon = null;
2594:
2595:                public ShowContainerEvent(BaseChildPanel pContainer,
2596:                        BaseUserObject pObject) {
2597:                    super (Application.instance, SHOWCONTANER_EVENT);
2598:                    mContainer = pContainer;
2599:                    mObject = pObject;
2600:                }
2601:
2602:                public ShowContainerEvent(BaseChildPanel pContainer,
2603:                        BaseUserObject pObject, Icon pIcon) {
2604:                    super (Application.instance, SHOWCONTANER_EVENT);
2605:                    mContainer = pContainer;
2606:                    mObject = pObject;
2607:                    mIcon = pIcon;
2608:                }
2609:
2610:                public BaseChildPanel getContainer() {
2611:                    return mContainer;
2612:                }
2613:
2614:                public BaseUserObject getUserObject() {
2615:                    return mObject;
2616:                }
2617:
2618:                public Icon getIcon() {
2619:                    return (mIcon != null) ? mIcon : mObject.getIcon();
2620:                }
2621:            }
2622:
2623:            /*				Show Container Event Listener		 	*/
2624:
2625:            public interface ShowContainerListener extends EventListener {
2626:                public void showContainer(ShowContainerEvent event);
2627:            }
2628:
2629:            /*		On Container Closed Event		*/
2630:
2631:            public class OnContainerCloseEvent extends AWTEvent {
2632:                public static final int ONCONTAINERCLOSE_EVENT = AWTEvent.RESERVED_ID_MAX + 995;
2633:                private BaseChildPanel mContainer = null;
2634:
2635:                public OnContainerCloseEvent(BaseChildPanel pContainer) {
2636:                    super (Application.instance, ONCONTAINERCLOSE_EVENT);
2637:                    mContainer = pContainer;
2638:                }
2639:
2640:                public Container getContainer() {
2641:                    return mContainer;
2642:                }
2643:            }
2644:
2645:            /*			On Container Close Event Listener		 	*/
2646:
2647:            public interface OnContainerCloseListener extends EventListener {
2648:                public void closeContainer(OnContainerCloseEvent event);
2649:            }
2650:
2651:            /*		On Container Changed Event		*/
2652:
2653:            public class OnContainerChangedEvent extends AWTEvent {
2654:                public static final int ONCONTAINERCHANGED_EVENT = AWTEvent.RESERVED_ID_MAX + 994;
2655:                private Container mContainer = null;
2656:
2657:                public OnContainerChangedEvent(Container pContainer) {
2658:                    super (Application.instance, ONCONTAINERCHANGED_EVENT);
2659:                    mContainer = pContainer;
2660:                }
2661:
2662:                public Container getContainer() {
2663:                    return mContainer;
2664:                }
2665:            }
2666:
2667:            /*			On Container Changed Event Listener		 	*/
2668:
2669:            public interface OnContainerChangedListener extends EventListener {
2670:                public void containerChanged(OnContainerChangedEvent event);
2671:            }
2672:
2673:            /*		On Errors Found Event			*/
2674:
2675:            public class OnErrorsFoundEvent extends AWTEvent {
2676:                public static final int ERRORSFOUND_EVENT = AWTEvent.RESERVED_ID_MAX + 993;
2677:
2678:                public OnErrorsFoundEvent() {
2679:                    super (Application.instance, ERRORSFOUND_EVENT);
2680:                }
2681:            }
2682:
2683:            /*			Errors Found Event Listener				*/
2684:
2685:            public interface OnErrorsFoundListener extends EventListener {
2686:                public void errorsFound(OnErrorsFoundEvent event);
2687:            }
2688:
2689:            /*		On Current Model Changed		*/
2690:
2691:            public class OnModelChangedEvent extends AWTEvent {
2692:                public static final int MODELCHANGED_EVENT = AWTEvent.RESERVED_ID_MAX + 992;
2693:                public static final int CURRENT_CHANGED = 0;
2694:                public static final int MODEL_CLOSED = 1;
2695:                public static final int MODEL_OPENED = 2;
2696:                public static final int MODEL_SAVED = 3;
2697:
2698:                private ModelUserObject mModel = null;
2699:                private int mEventSource = CURRENT_CHANGED;
2700:
2701:                public OnModelChangedEvent(ModelUserObject pMaster, int pSource) {
2702:                    super (Application.instance, MODELCHANGED_EVENT);
2703:                    mModel = pMaster;
2704:                    mEventSource = pSource;
2705:                }
2706:
2707:                public ModelUserObject getModel() {
2708:                    return mModel;
2709:                }
2710:
2711:                public int getEventSource() {
2712:                    return mEventSource;
2713:                }
2714:            }
2715:
2716:            /*			Errors Found Event Listener				*/
2717:
2718:            public interface OnModelChangedListener extends EventListener {
2719:                public void modelChanged(OnModelChangedEvent event);
2720:            }
2721:
2722:            /*			Close Model Event			*/
2723:
2724:            public class CloseModelEvent extends AWTEvent {
2725:                public static final int ERRORSFOUND_EVENT = AWTEvent.RESERVED_ID_MAX + 991;
2726:
2727:                private ModelUserObject mModel = null;
2728:
2729:                public CloseModelEvent(ModelUserObject pModel) {
2730:                    super (Application.instance, ERRORSFOUND_EVENT);
2731:                    mModel = pModel;
2732:                }
2733:
2734:                public ModelUserObject getModel() {
2735:                    return mModel;
2736:                }
2737:            }
2738:
2739:            /*			Close Model Event Listener				*/
2740:
2741:            public interface CloseModelListener extends EventListener {
2742:                public void closeModel(CloseModelEvent event);
2743:            }
2744:
2745:            /*          Refresh Diagram Event           */
2746:
2747:            public class RefreshDiagramsEvent extends AWTEvent {
2748:                public static final int REFRESHDIAGRAM_EVENT = AWTEvent.RESERVED_ID_MAX + 990;
2749:
2750:                protected Diagram mDiagram = null;
2751:                protected BaseUserObject mUserObject = null;
2752:
2753:                public RefreshDiagramsEvent(Diagram pDiagram,
2754:                        BaseUserObject pUserObject) {
2755:                    super (Application.instance, REFRESHDIAGRAM_EVENT);
2756:                    mDiagram = pDiagram;
2757:                    mUserObject = pUserObject;
2758:                }
2759:
2760:                // get graph panel
2761:                public Diagram getDiagram() {
2762:                    return mDiagram;
2763:                }
2764:
2765:                // get user object
2766:                public BaseUserObject getUserObject() {
2767:                    return mUserObject;
2768:                }
2769:            }
2770:
2771:            /*          Refresh Diagram Event Listener              */
2772:
2773:            public interface RefreshDiagramsEventListener extends EventListener {
2774:                public void refreshDiagram(RefreshDiagramsEvent event);
2775:            }
2776:
2777:            /*       Tree element index changed Event      */
2778:
2779:            public class OnElementIndexChangedEvent extends AWTEvent {
2780:                public static final int INDEXCHANGED_EVENT = AWTEvent.RESERVED_ID_MAX + 989;
2781:
2782:                protected BaseUserObject mUserObject = null;
2783:                protected int mOldIndex = -1;
2784:                protected int mNewIndex = -1;
2785:
2786:                public OnElementIndexChangedEvent(BaseUserObject pUserObject,
2787:                        int pOldIndex, int pNewIndex) {
2788:                    super (Application.instance, INDEXCHANGED_EVENT);
2789:
2790:                    mUserObject = pUserObject;
2791:                    mOldIndex = pOldIndex;
2792:                    mNewIndex = pNewIndex;
2793:                }
2794:
2795:                // get user object
2796:                public BaseUserObject getUserObject() {
2797:                    return mUserObject;
2798:                }
2799:
2800:                // get old index
2801:                public int getOldIndex() {
2802:                    return mOldIndex;
2803:                }
2804:
2805:                // get old index
2806:                public int getNewIndex() {
2807:                    return mNewIndex;
2808:                }
2809:            }
2810:
2811:            /*       Tree element index changed Event listener       */
2812:
2813:            public interface OnElemenIndexChangedEventListener extends
2814:                    EventListener {
2815:                public void indexChanged(OnElementIndexChangedEvent event);
2816:            }
2817:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.