- Timestamp:
- 06/19/12 23:26:01 (12 years ago)
- Location:
- trunk/modelicaml/org.openmodelica.modelicaml.common/src/org/openmodelica/modelicaml/common
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modelicaml/org.openmodelica.modelicaml.common/src/org/openmodelica/modelicaml/common/services/ModelicaMLServices.java
r1538 r1548 5 5 import java.io.FileNotFoundException; 6 6 import java.io.FileOutputStream; 7 import java.io.FileWriter;8 7 import java.io.IOException; 9 8 import java.io.OutputStreamWriter; 10 9 import java.io.UnsupportedEncodingException; 11 import java.net.URI;12 10 import java.util.ArrayList; 13 11 import java.util.Collections; 14 12 import java.util.Comparator; 13 import java.util.HashMap; 15 14 import java.util.HashSet; 16 15 import java.util.List; … … 30 29 import org.eclipse.emf.common.util.EList; 31 30 import org.eclipse.emf.ecore.EObject; 31 import org.eclipse.emf.ecore.resource.Resource; 32 32 import org.eclipse.papyrus.core.utils.BusinessModelResolver; 33 33 import org.eclipse.papyrus.resource.uml.UmlModel; 34 import org.eclipse.papyrus.resource.uml.UmlUtils;35 34 import org.eclipse.uml2.uml.Element; 36 35 import org.eclipse.uml2.uml.NamedElement; … … 41 40 public class ModelicaMLServices { 42 41 43 42 /* 43 * Regeneration of code 44 */ 45 public static HashMap<Resource,Long> modelModificationStamp = new HashMap<Resource,Long>(); 46 public static HashMap<Resource,Long> codeGenerationStamp = new HashMap<Resource,Long>(); 47 48 public static boolean regenerateCode(Resource resource){ 49 50 // TODO: check if the code-gen folder exists in the project 51 52 Long modifiedModelTimeStamp = modelModificationStamp.get(resource); 53 Long generatedCodeTimeStamp = codeGenerationStamp.get(resource); 54 55 // System.err.println("Checking if it is neccesary to regenerate code for: "+ resource); 56 // System.err.println("modifiedModelTimeStamp: " + modifiedModelTimeStamp); 57 // System.err.println("generatedCodeTimeStamp: " + generatedCodeTimeStamp); 58 // if (generatedCodeTimeStamp != null && modifiedModelTimeStamp != null) { 59 // System.err.println("modifiedModelTimeStamp < generatedCodeTimeStamp: " + (modifiedModelTimeStamp < generatedCodeTimeStamp)); 60 // } 61 62 if (generatedCodeTimeStamp != null && modifiedModelTimeStamp != null) { 63 // if code was generated after the model modification -> no need for regenerating code 64 if (modifiedModelTimeStamp < generatedCodeTimeStamp) { 65 System.err.println("Skipping code generation ... "); 66 return false; 67 68 } 69 } 70 return true; 71 } 72 73 74 public static boolean saveModel(UmlModel umlModel){ 75 try { 76 umlModel.saveModel(); 77 return true; 78 } catch (IOException e) { 79 // TODO Auto-generated catch block 80 e.printStackTrace(); 81 } 82 return false; 83 } 84 85 /* 86 * Element adoption 87 */ 44 88 public static EObject adaptSelectedElement( Object selection) { 89 45 90 EObject eObject = null; 46 91 if(selection != null) { … … 58 103 } 59 104 105 106 /* 107 * Requirements data 108 */ 60 109 public static String getRequirementID(Element req){ 61 110 if (req instanceof NamedElement) { … … 81 130 82 131 132 /* 133 * Utilities 134 */ 83 135 public static List<TreeObject> getSortedByDotPath(HashSet<TreeObject> set){ 84 136 if (set == null) { return null; } … … 219 271 // } 220 272 221 273 /* 274 * OMC handling 275 */ 222 276 public static boolean containsOMCErrorMessage(String msg){ 223 277 if ( msg.contains("Error: ") … … 287 341 288 342 343 /* 344 * Files handling 345 */ 289 346 public static IStatus deleteFiles(List<String> filesToBeDeleted, IProgressMonitor monitor, String message){ 290 347
Note: See TracChangeset
for help on using the changeset viewer.