@Override protected void runJob() throws Exception { Controller controller = getController(); // is invoked head less? DefaultMainFrame mainFrame = ApplicationContext.getDefaultMainFrame(); boolean headless = (mainFrame == null); Db db = null; try { if (!headless) { // create new project, if it was not specific by the user m_project = m_params.getOutputProject(); if (m_project == null) { m_project = (DbSMSProject) mainFrame.createDefaultProject(db); } db = m_project.getDb(); db.beginWriteTrans(LocaleMgr.misc.getString("ImportJavaBytecode")); // create class model m_classModel = new DbJVClassModel(m_project); } // import Java classes files (jobDone 0% to 80%) DbJVPackage topMostPackage = importFiles(controller, 0, 80); // show success/failure message if (controller.getErrorsCount() == 0) { controller.println(LocaleMgr.misc.getString("Success")); } else { controller.println(LocaleMgr.misc.getString("Failed")); } // end if // create and reveal diagram ((jobDone 80% to 100%) if (!headless) { if ((topMostPackage != null) && (m_params.createDiagrams)) { createAndRevealDiagram(mainFrame, topMostPackage, controller, 80, 100); } db.commitTrans(); } // end if controller.checkPoint(100); } catch (DbException ex) { controller.println(ex.toString()); controller.cancel(); } // end try } // end runJob()
private Map<Byte, DbJVPrimitiveType> getJavaTypes() throws DbException { // if first call, build the map if (m_javaTypes == null) { m_javaTypes = new HashMap<Byte, DbJVPrimitiveType>(); DbRelationN relN = m_project.getComponents(); DbEnumeration enu = relN.elements(DbSMSBuiltInTypeNode.metaClass); while (enu.hasMoreElements()) { DbSMSBuiltInTypeNode typeNode = (DbSMSBuiltInTypeNode) enu.nextElement(); DbRelationN relN2 = typeNode.getComponents(); DbEnumeration enu2 = relN2.elements(DbSMSBuiltInTypePackage.metaClass); while (enu2.hasMoreElements()) { DbSMSBuiltInTypePackage pack = (DbSMSBuiltInTypePackage) enu2.nextElement(); DbSMSTargetSystem ts = pack.getTargetSystem(); if ("Java".equals(ts.getName())) { DbRelationN relN3 = pack.getComponents(); DbEnumeration enu3 = relN3.elements(DbJVPrimitiveType.metaClass); while (enu3.hasMoreElements()) { DbJVPrimitiveType type = (DbJVPrimitiveType) enu3.nextElement(); String name = type.getName(); if ("boolean".equals(name)) { m_javaTypes.put(Constants.T_BOOLEAN, type); } else if ("byte".equals(name)) { m_javaTypes.put(Constants.T_BYTE, type); } else if ("short".equals(name)) { m_javaTypes.put(Constants.T_SHORT, type); } else if ("char".equals(name)) { m_javaTypes.put(Constants.T_CHAR, type); } else if ("int".equals(name)) { m_javaTypes.put(Constants.T_INT, type); } else if ("long".equals(name)) { m_javaTypes.put(Constants.T_LONG, type); } else if ("double".equals(name)) { m_javaTypes.put(Constants.T_DOUBLE, type); } else if ("float".equals(name)) { m_javaTypes.put(Constants.T_FLOAT, type); } // end if } // end while enu3.close(); } // end if pack.getAlias(); } // end while enu2.close(); } // end while enu.close(); } // end if return m_javaTypes; }