Java tutorial
/******************************************************************************* * Copyright (c) 2008, 2012 Obeo. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Obeo - initial API and implementation *******************************************************************************/ package com.iauto.mist.spec.m2t.uml2html.launch; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.eclipse.acceleo.common.preference.AcceleoPreferences; import org.eclipse.acceleo.engine.utils.AcceleoLaunchingUtil; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.emf.common.util.BasicMonitor; import org.eclipse.emf.common.util.URI; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.window.Window; import org.eclipse.m2m.atl.common.ATLExecutionException; import org.eclipse.m2m.atl.core.ATLCoreException; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.PlatformUI; import org.eclipse.uml2.uml.Element; import org.eclipse.uml2.uml.Model; import org.eclipse.uml2.uml.Package; import org.eclipse.uml2.uml.StateMachine; import com.iauto.html5.tools.activator.PluginToolsActivator; import com.iauto.mist.spec.common.plugin.constant.ProjectProperty; import com.iauto.mist.spec.common.plugin.property.PropertyUtil; import com.iauto.mist.spec.common.plugin.specification.view.util.SpecificationUtil; import com.iauto.mist.spec.common.plugin.util.ATLStandAlone; import com.iauto.mist.spec.common.plugin.util.AtlDataTracker; import com.iauto.mist.spec.common.plugin.util.EditorUtil; import com.iauto.mist.spec.common.plugin.util.FileUtil; import com.iauto.mist.spec.common.plugin.util.ModelUtil; import com.iauto.mist.spec.common.plugin.util.OSinfo; import com.iauto.mist.spec.common.plugin.util.UtilCommonMethod; import com.iauto.mist.spec.m2m.uml2spec.files.Uml2spec; import com.iauto.mist.spec.m2m.uml2spec.util.ATLUtil; import com.iauto.mist.spec.m2t.uml2html.dialog.StateMachineChooseDialog; import com.iauto.mist.spec.m2t.uml2html.dialog.Uml2HtmlDialog; import com.iauto.mist.spec.m2t.uml2html.main.GenSvgFlowchart; import com.iauto.mist.spec.m2t.uml2html.main.GenUpdateInfoJson; import com.iauto.mist.spec.m2t.uml2html.main.Generate; import com.iauto.mist.spec.m2t.uml2html.main.StateFlowXml; import com.iauto.mist.spec.m2t.uml2html.main.StateFlowXml2; import com.iauto.mist.spec.m2t.uml2html.main.StateOperJson; import com.iauto.mist.spec.m2t.uml2html.main.StateOperJsonForDesignCheckSheet; import com.iauto.mist.spec.m2t.uml2html.util.ConfigUtil; import com.iauto.mist.spec.m2t.uml2html.util.Define; import com.iauto.mist.spec.m2t.uml2html.util.DesignCheckSheet; import com.iauto.mist.spec.m2t.uml2html.util.GenerateUpi; import com.iauto.mist.spec.m2t.uml2html.util.GenerateXls; import com.iauto.mist.spec.m2t.uml2html.util.GenerateXls2; import com.iauto.mist.spec.m2t.uml2html.util.JsonToOperaXls; import com.iauto.mist.spec.m2t.uml2html.util.XlsRender2; import com.iauto.mist.spec.m2t.uml2html.util.XlsRenderForFlow; import com.iauto.mist.spec.m2t.uml2html.util.utils; import com.iauto.mist.spec.m2t.uml2html.util.sxssfDeal.Trans2SxssfWorkbook; import com.iauto.mist.spec.m2t.uml2uiflow.util.WebAppUtil; /** * Main entry point of the 'Uml2xtopoJLaunch' generation module. */ public class UML2HtmlDynamicSpecificationLaunch { private String pluginName = com.iauto.mist.spec.m2t.uml2html.Activator.PLUGIN_ID; // ???map public static final Map<IProject, Boolean> projectCheckMap = new HashMap<IProject, Boolean>(); private static final String[] ignores = new String[] { ".svn" }; public int returnValue; private static IFile modelFile; /** * The model URI. */ private URI modelURI; /** * The output folder. */ private String targetPath; private String prefix; private String postfix; private String imageFolder; private String ccFolder; private String refDocFolder; private String externalJarFilePath; private boolean gends = true; private boolean genupi = false; private boolean genfc = false; private boolean genfc2 = false; private boolean genfc3 = false; private boolean genop = false; private boolean genApp = false; private String screenType = "Pad"; private boolean retryFlg = false; /** * The other arguments. */ List<? extends Object> arguments; IProject mistProject; /** * Constructor for launch in platform * * @param modelURI * is the URI of the model. * @param targetFolder * is the output folder * @param arguments * are the other arguments * @throws URISyntaxException * @throws IOException * Thrown when the output cannot be saved. */ public UML2HtmlDynamicSpecificationLaunch(URI modelURI, IFile modelFile, String targetPath, List<? extends Object> arguments) { this.modelURI = modelURI; this.targetPath = targetPath; this.arguments = arguments; this.modelFile = modelFile; this.refDocFolder = modelFile.getProject().getLocation() + "/ref_doc"; this.imageFolder = modelFile.getProject().getLocation() + ProjectProperty.ProjectImagePath; this.ccFolder = modelFile.getProject().getLocation() + ProjectProperty.ProjectCCPath; this.externalJarFilePath = FileUtil.getJarPath("com.iauto.mist.spec.external.plugin"); mistProject = modelFile.getProject(); } /** * constructor for launch in ant task * * @param modelURI * @param targetFolder * @param arguments */ public UML2HtmlDynamicSpecificationLaunch(URI modelURI, String targetPath, String prefix, String postfix, String imageFolder, String refDocFolder, String jarFilePath, String externalJarFilePath, List<? extends Object> arguments) { this.modelURI = modelURI; this.targetPath = targetPath; this.arguments = arguments; this.prefix = prefix; this.postfix = postfix; this.refDocFolder = refDocFolder; this.imageFolder = imageFolder; this.externalJarFilePath = externalJarFilePath; mistProject = modelFile.getProject(); } /** * ??? * * @param monitor * @param outputFolder * @param topModelPath * @return * @throws IOException */ private void doDynamicSpecGeneration(IProgressMonitor monitor, File outputFolder, String topModelPath, Model topModel) throws IOException { monitor.subTask("Generate Dynamic Specification!"); PluginToolsActivator.getDefault().writeMsgToConsole("", "Dynamic Specification Generating -- start", 0); // ConsolepageFile SpecificationUtil.getParsefailedpagefilenamelist().clear(); // atl? monitor.subTask("Performing ATL transform..."); PluginToolsActivator.getDefault().writeMsgToConsole("", "Performing ATL transform...", 0); URI inURI = URI.createFileURI(topModelPath); URI outURI = inURI.trimFileExtension().appendFileExtension("spec"); { // spec File outAtlFile = new File(outURI.toFileString()); if (outAtlFile.exists()) { outAtlFile.delete(); } // atl? boolean atlProcessResult = ATLUtil.doAtlProcess(monitor, modelFile.getProject(), inURI, outURI); // atl if (!outAtlFile.exists()) { return; } // atl Cancel or atl error, if (!atlProcessResult) { return; } } // ?required FileUtil.copyTemplateFile(outputFolder.getAbsolutePath(), FileUtil.getJarPath("com.iauto.mist.spec.m2t.uml2html"), "required"); if (monitor.isCanceled()) { return; } // ?disvg monitor.subTask("Loading..."); GenSvgFlowchart gen3 = new GenSvgFlowchart(modelURI, outputFolder, arguments); String generationID3 = AcceleoLaunchingUtil.computeUIProjectID(pluginName, GenSvgFlowchart.class.getName(), modelURI.toString(), outputFolder.toString(), new ArrayList<String>()); gen3.setGenerationID(generationID3); gen3.doGenerate(BasicMonitor.toMonitor(monitor)); if (monitor.isCanceled()) { return; } // 2015-11-04 add for 3815 start // collect modeName into utils(need to display sound info) if (utils.needDisplaySoundInfoStmList == null) { utils.needDisplaySoundInfoStmList = new ArrayList<String>(); } else { utils.needDisplaySoundInfoStmList.clear(); } String[] soundColumnLabels = new String[] { "operationType", "soundColumn" }; String scType = PropertyUtil.loadFileProperty((IProject) mistProject, soundColumnLabels, ""); if ("Displayed".equals(scType)) { Set<StateMachine> stateMachines = new HashSet<StateMachine>(); getAllStateMachine(topModel, stateMachines); for (StateMachine curSM : stateMachines) { utils.needDisplaySoundInfoStmList.add(curSM.getName()); } } // 2015-11-04 add for 3815 end // Generating // acceleo?state.js Generate generate = new Generate(outURI, outputFolder, arguments); String genStateID = AcceleoLaunchingUtil.computeUIProjectID(pluginName, Generate.class.getName(), outURI.toString(), outputFolder.toString(), new ArrayList<String>()); generate.setGenerationID(genStateID); generate.doGenerate(BasicMonitor.toMonitor(monitor)); // 2015-11-04 add for 3815 start // clear modeName into utils(need to display sound info) utils.needDisplaySoundInfoStmList.clear(); // 2015-11-04 add for 3815 end if (monitor.isCanceled()) { return; } // generate update info if (genupi) { // model utils.curTopModel = topModel; GenUpdateInfoJson gen = new GenUpdateInfoJson(outURI, outputFolder, arguments); String generationID = AcceleoLaunchingUtil.computeUIProjectID(pluginName, GenUpdateInfoJson.class.getName(), outURI.toString(), outputFolder.toString(), new ArrayList<String>()); gen.setGenerationID(generationID); gen.doGenerate(BasicMonitor.toMonitor(monitor)); if (monitor.isCanceled()) { return; } // model utils.modelUndoClear(); monitor.subTask("Generating update info Json..."); PluginToolsActivator.getDefault().writeMsgToConsole("", "Update info Json Generating -- start", 0); // ?update info Json GenerateUpi genUpi = new GenerateUpi(); genUpi.deal(monitor); PluginToolsActivator.getDefault().writeMsgToConsole("", "Update info Json Generating -- end", 0); } // ?spec? app WebAppUtil.doWebAppBasicCoreGeneration(monitor, outputFolder, modelFile, outURI, imageFolder, refDocFolder, arguments, WebAppUtil.FUNC_NAME_DS); PluginToolsActivator.getDefault().writeMsgToConsole("", "Dynamic Specification Generating -- end", 0); } /** * ?flowchart excel * * @param monitor * @param outputFolder * @param topModel * @return * @throws IOException */ private void doFlowChartGeneration(IProgressMonitor monitor, File outputFolder, Model topModel) throws IOException { monitor.subTask("Generate Flowchart excel!"); PluginToolsActivator.getDefault().writeMsgToConsole("", "Flowchart excel Generating -- start", 0); // ConsolepageFile SpecificationUtil.getParsefailedpagefilenamelist().clear(); // clear ????statemachine?? if (genfc || genfc3) { // has operatrion sheet GenerateXls.clearIgnoreStatemachine(); utils.clearIgnoreStatemachine(); PluginToolsActivator.getDefault().writeMsgToConsole("", "operation sheet output: true", 0); } else { // without operatrion sheet GenerateXls2.clearIgnoreStatemachine(); PluginToolsActivator.getDefault().writeMsgToConsole("", "operation sheet output: false", 0); } // statemachine? List<StateMachine> stateMachines = selectStateMachine(topModel, new ArrayList<StateMachine>()); for (StateMachine stateMachine : stateMachines) { // ???statemachine?? if (genfc || genfc3) { // has operatrion sheet GenerateXls.addIgnoreStatemachine(stateMachine); utils.addIgnoreStatemachine(stateMachine); } else { // without operatrion sheet GenerateXls2.addIgnoreStatemachine(stateMachine); } } // when operatrion sheet is needed, ?sheet??outline? if (genfc) { PluginToolsActivator.getDefault().writeMsgToConsole("", "outline: display", 0); GenerateXls.appUpdateRecords = genApp; GenerateXls.outline_display = true; GenerateXls.scrTyFlg = screenType; } else if (genfc3) { PluginToolsActivator.getDefault().writeMsgToConsole("", "outline display: false", 0); GenerateXls.appUpdateRecords = genApp; GenerateXls.outline_display = false; GenerateXls.scrTyFlg = screenType; } else if (genfc2) { GenerateXls2.scrTyFlg = screenType; } if (monitor.isCanceled()) { return; } // Generate if (genfc || genfc3) { // when operatrion sheet is needed monitor.subTask("Generating json data..."); PluginToolsActivator.getDefault().writeMsgToConsole("", "Generating json data...", 0); // statemachine?statemachine?json File jsonFolder = new File(outputFolder.getAbsolutePath() + File.separator + "tempJson"); if (!jsonFolder.exists()) { jsonFolder.mkdirs(); } StateOperJson gen2 = new StateOperJson(modelURI, jsonFolder, arguments); String generationID2 = AcceleoLaunchingUtil.computeUIProjectID(pluginName, StateOperJson.class.getName(), modelURI.toString(), outputFolder.toString(), new ArrayList<String>()); gen2.setGenerationID(generationID2); gen2.doGenerate(BasicMonitor.toMonitor(monitor)); if (monitor.isCanceled()) { return; } monitor.subTask("Generating flowchart excel..."); PluginToolsActivator.getDefault().writeMsgToConsole("", "Generating flowchart excel...", 0); // Acceleo?flowchart excel StateFlowXml gen1 = new StateFlowXml(modelURI, outputFolder, arguments); String generationID1 = AcceleoLaunchingUtil.computeUIProjectID(pluginName, StateFlowXml.class.getName(), modelURI.toString(), outputFolder.toString(), new ArrayList<String>()); gen1.setGenerationID(generationID1); gen1.doGenerate(BasicMonitor.toMonitor(monitor)); monitor.subTask("Delete json data."); PluginToolsActivator.getDefault().writeMsgToConsole("", "Delete json data.", 0); // delete??json utils.clearIgnoreStatemachine(); Trans2SxssfWorkbook.cleanJsonFolderAndJsonData(); } else { // when operatrion sheet is not needed monitor.subTask("Generating flowchart excel..."); PluginToolsActivator.getDefault().writeMsgToConsole("", "Generating flowchart excel...", 0); // Acceleo?flowchart excel StateFlowXml2 gen12 = new StateFlowXml2(modelURI, outputFolder, arguments); String generationID12 = AcceleoLaunchingUtil.computeUIProjectID(pluginName, StateFlowXml2.class.getName(), modelURI.toString(), outputFolder.toString(), new ArrayList<String>()); gen12.setGenerationID(generationID12); gen12.doGenerate(BasicMonitor.toMonitor(monitor)); } PluginToolsActivator.getDefault().writeMsgToConsole("", "Flowchart excel Generating -- end", 0); } /** * ?Design Check Sheet * * @param monitor * @param outputFolder * @return * @throws IOException */ private void doDesignCheckSheetGeneration(IProgressMonitor monitor, File outputFolder) throws IOException { monitor.subTask("Generate Design Check Sheet!"); PluginToolsActivator.getDefault().writeMsgToConsole("", "Design Check Sheet Generating -- start", 0); // ConsolepageFile SpecificationUtil.getParsefailedpagefilenamelist().clear(); monitor.subTask("Generating json data..."); PluginToolsActivator.getDefault().writeMsgToConsole("", "Generating json data...", 0); // ?Design Check Sheetjson? StateOperJsonForDesignCheckSheet gen3 = new StateOperJsonForDesignCheckSheet(modelURI, outputFolder, arguments); String generationID3 = AcceleoLaunchingUtil.computeUIProjectID(pluginName, StateOperJsonForDesignCheckSheet.class.getName(), modelURI.toString(), outputFolder.toString(), new ArrayList<String>()); gen3.setGenerationID(generationID3); gen3.doGenerate(BasicMonitor.toMonitor(monitor)); if (monitor.isCanceled()) { return; } monitor.subTask("Generating design Check Sheet..."); PluginToolsActivator.getDefault().writeMsgToConsole("", "Generating design Check Sheet...", 0); // ?Design Check Sheet DesignCheckSheet designCheckSheet = new DesignCheckSheet(); designCheckSheet.deal(externalJarFilePath, monitor, 0); PluginToolsActivator.getDefault().writeMsgToConsole("", "Design Check Sheet Generating -- end", 0); } public void doPlatformGeneration(IProgressMonitor monitor) throws IOException { monitor.subTask("Setting acceleo config."); PluginToolsActivator.getDefault().writeMsgToConsole("", "Setting acceleo config.", 0); AcceleoPreferences.switchForceDeactivationNotifications(true); AcceleoPreferences.switchNotifications(false); // acceleo?? ConfigUtil.defaultPre = ConfigUtil.getPrefix(modelFile.getProject()); ConfigUtil.defaultPost = ConfigUtil.getPostfix(modelFile.getProject()); // ?dirtyeditor monitor.subTask("Saving all dirty editors."); PluginToolsActivator.getDefault().writeMsgToConsole("", "Saving all dirty editors.", 0); EditorUtil.saveAllEditors(monitor); // ? StringBuffer customedTarget = new StringBuffer(targetPath); // folder File folder = null; String[] dsPathLabels = new String[] { "path", "ds" }; String target = PropertyUtil.loadFileProperty(mistProject, dsPathLabels, File.separator + "web"); { setDefaultPathPrompt(modelFile.getProject(), true); customedTarget = new StringBuffer(target); if (getDefaultPathPrompt(modelFile.getProject())) { monitor.subTask("Popup Dynamic Specification dialog."); PluginToolsActivator.getDefault().writeMsgToConsole("", "Popup Dynamic Specification dialog.", 0); String topModel = ModelUtil.findTopModelPath(ModelUtil.parseUMLFile(modelURI)); this.returnValue = this.getTargetFolder(customedTarget, modelFile.getProject(), topModel); if (Window.CANCEL == this.returnValue) { PluginToolsActivator.getDefault().writeMsgToConsole("", "Dynamic Specification dialog was canceled.", 0); return; } PluginToolsActivator.getDefault().writeMsgToConsole("", "Transforming model : " + topModel + " in project : " + modelFile.getProject().getName(), 0); monitor.subTask( "Transforming model : " + topModel + " in project : " + modelFile.getProject().getName()); } // ? monitor.subTask("Saving output path to property file."); PluginToolsActivator.getDefault().writeMsgToConsole("", "Saving output path to property file.", 0); target = customedTarget.toString(); PropertyUtil.saveFileProperty(mistProject, dsPathLabels, target); target = target.trim(); if (OSinfo.isLinux() || OSinfo.isMacOS() || OSinfo.isMacOSX()) { // linux absolute path if (target.startsWith("/home")) { folder = new File(target); } else { folder = new File(modelFile.getProject().getLocation().toString() + target); } } else if (OSinfo.isWindows()) { if (FileUtil.isAbsolutePath(target)) { folder = new File(target); } else { folder = new File(modelFile.getProject().getLocation().toString() + target); } } // ? if (!folder.exists()) { folder.mkdirs(); } monitor.subTask("Output path : " + folder.getAbsolutePath()); PluginToolsActivator.getDefault().writeMsgToConsole("", "Output path : " + folder.getAbsolutePath(), 0); } // ? String[] screenTypeLabels = new String[] { "size", "screenType" }; screenType = PropertyUtil.loadFileProperty(mistProject, screenTypeLabels, "Pad"); // ? { Define.RUN_TIME_TEXT_OUTPUT_PATH = folder.getAbsolutePath(); Define.RUN_TIME_TEXT_IMAGE_PATH = modelFile.getProject().getLocation() + "/resources"; com.iauto.mist.spec.common.plugin.util.Define.HTML5PROJECT = modelFile.getProject(); XlsRender2.write_path = Define.RUN_TIME_TEXT_OUTPUT_PATH + "/" + Define.TEXT_OUTPUT_PATH + "/" + Define.XLS_OUTPUT_PATH; XlsRenderForFlow.write_path = Define.RUN_TIME_TEXT_OUTPUT_PATH + "/" + Define.TEXT_OUTPUT_PATH + "/" + Define.XLS_OUTPUT_PATH; Trans2SxssfWorkbook.write_path = Define.RUN_TIME_TEXT_OUTPUT_PATH + "/" + Define.TEXT_OUTPUT_PATH + "/" + Define.XLS_OUTPUT_PATH; } String umlFilePath; umlFilePath = modelFile.getLocation().toString(); // ?modelmodel String topModelPath = umlFilePath; Model selectedModel = ModelUtil.parseUMLFile(URI.createFileURI(umlFilePath)); Model topModel = null; if (null != selectedModel) { topModel = ModelUtil.findTopModel(selectedModel, new ArrayList<Model>()); if (null != topModel) { topModelPath = getModelPath(topModel); } } if (monitor.isCanceled()) { PluginToolsActivator.getDefault().writeMsgToConsole("", "Generation was canceled.", 0); this.returnValue = Window.CANCEL; return; } if (gends) { // ??? doDynamicSpecGeneration(monitor, folder, topModelPath, topModel); } if (monitor.isCanceled()) { PluginToolsActivator.getDefault().writeMsgToConsole("", "Generation was canceled.", 0); this.returnValue = Window.CANCEL; return; } if (genfc || genfc2 || genfc3) { // ?flowchart excel doFlowChartGeneration(monitor, folder, topModel); } if (monitor.isCanceled()) { PluginToolsActivator.getDefault().writeMsgToConsole("", "Generation was canceled.", 0); this.returnValue = Window.CANCEL; return; } if (genop) { // ?Design Check Sheet doDesignCheckSheetGeneration(monitor, folder); } if (monitor.isCanceled()) { PluginToolsActivator.getDefault().writeMsgToConsole("", "Generation was canceled.", 0); this.returnValue = Window.CANCEL; } } // public void doPlatformGeneration(IProgressMonitor monitor) // throws IOException { // AcceleoPreferences.switchForceDeactivationNotifications(true); // AcceleoPreferences.switchNotifications(false); // // acceleo?? // ConfigUtil.defaultPre = ConfigUtil.getPrefix(modelFile.getProject()); // ConfigUtil.defaultPost = ConfigUtil.getPostfix(modelFile.getProject()); // // ?dirtyeditor // EditorUtil.saveAllEditors(monitor); // // ? // StringBuffer customedTarget = new StringBuffer(targetPath); // // folder // File folder = null; // String[] dsPathLabels = new String[] { "path", "ds" }; // String target = PropertyUtil.loadFileProperty(mistProject, // dsPathLabels, File.separator + "web"); // { // setDefaultPathPrompt(modelFile.getProject(), true); // customedTarget = new StringBuffer(target); // if (getDefaultPathPrompt(modelFile.getProject())) { // String topModel = ModelUtil.findTopModelPath(ModelUtil // .parseUMLFile(modelURI)); // this.returnValue = this.getTargetFolder(customedTarget, // modelFile.getProject(), topModel); // if (Window.CANCEL == this.returnValue) { // return; // } // PluginToolsActivator.getDefault().writeMsgToConsole( // "", // "Transforming model : " + topModel + " in project : " // + modelFile.getProject().getName(), 0); // monitor.subTask("Transforming model : " + topModel // + " in project : " + modelFile.getProject().getName()); // } // // ? // target = customedTarget.toString(); // PropertyUtil.saveFileProperty(mistProject, dsPathLabels, target); // target = target.trim(); // // if (OSinfo.isLinux() || OSinfo.isMacOS() || OSinfo.isMacOSX()) { // // linux absolute path // if (target.startsWith("/home")) { // folder = new File(target); // } else { // folder = new File(modelFile.getProject().getLocation() // .toString() // + target); // } // } else if (OSinfo.isWindows()) { // if (FileUtil.isAbsolutePath(target)) { // folder = new File(target); // } else { // folder = new File(modelFile.getProject().getLocation() // .toString() // + target); // } // } // // ? // if (!folder.exists()) { // folder.mkdirs(); // } // monitor.subTask("Output path : " + folder.getAbsolutePath()); // PluginToolsActivator.getDefault().writeMsgToConsole("", // "Output path : " + folder.getAbsolutePath(), 0); // } // // ? // { // Define.RUN_TIME_TEXT_OUTPUT_PATH = folder.getAbsolutePath(); // Define.RUN_TIME_TEXT_IMAGE_PATH = modelFile.getProject() // .getLocation() + "/resources"; // com.iauto.mist.spec.common.plugin.util.Define.HTML5PROJECT = modelFile // .getProject(); // // XlsRender2.write_path = Define.RUN_TIME_TEXT_OUTPUT_PATH + "/" // + Define.TEXT_OUTPUT_PATH + "/" + Define.XLS_OUTPUT_PATH; // XlsRenderForFlow.write_path = Define.RUN_TIME_TEXT_OUTPUT_PATH // + "/" + Define.TEXT_OUTPUT_PATH + "/" // + Define.XLS_OUTPUT_PATH; // // } // // ?img,ref // { // FileUtil.copyFolder(imageFolder, folder.getAbsolutePath() + "/img", // ignores); // // copy refDoc // FileUtil.copyFolder(refDocFolder, folder.getAbsolutePath() // + "/ref_doc", ignores); // } // // // ?required // { // FileUtil.copyTemplateFile(folder.getAbsolutePath(), // FileUtil.getJarPath("com.iauto.mist.spec.m2t.uml2html"), // "required"); // String sdk = UtilCommonMethod.getSDKPrefix(mistProject); // File tempStmFolder = FileUtil.createTempFolder(folder); // FileUtil.copyFolder(folder.getAbsolutePath() + File.separator // + "app" + File.separator + "stm", // tempStmFolder.getAbsolutePath(), new String[] { " " }); // FileUtil.copyTemplateFile(folder.getAbsolutePath() + File.separator // + "app", FileUtil.getJarPath("com.iauto.html5.sdk"), sdk); // FileUtil.copyFolder(tempStmFolder.getAbsolutePath(), // folder.getAbsolutePath() + File.separator + "app" // + File.separator + "stm", new String[] { " " }); // // // FileUtil.deleteFolder(tempStmFolder); // } // // // ?disvg // monitor.subTask("Transforming *.di file to *.svg file"); // PluginToolsActivator.getDefault().writeMsgToConsole("", // "Transforming *.di file to *.svg file", 0); // // String umlFilePath; // umlFilePath = modelFile.getLocation().toString(); // // monitor.subTask("Loading..."); // // // ?modelmodel // String topModelPath = umlFilePath; // Model selectedModel = ModelUtil.parseUMLFile(URI // .createFileURI(umlFilePath)); // Model topModel = null; // if (null != selectedModel) { // topModel = ModelUtil.findTopModel(selectedModel, // new ArrayList<Model>()); // if (null != topModel) { // topModelPath = getModelPath(topModel); // } // } // // // Generate // StateFlowXml gen1 = new StateFlowXml(modelURI, folder, arguments); // String generationID1 = AcceleoLaunchingUtil.computeUIProjectID( // pluginName, StateFlowXml.class.getName(), modelURI.toString(), // folder.toString(), new ArrayList<String>()); // gen1.setGenerationID(generationID1); // // StateFlowXml2 gen12 = new StateFlowXml2(modelURI, folder, arguments); // String generationID12 = AcceleoLaunchingUtil.computeUIProjectID( // pluginName, StateFlowXml2.class.getName(), modelURI.toString(), // folder.toString(), new ArrayList<String>()); // gen12.setGenerationID(generationID12); // // // 2015-1-20 modified for 2741 start // // StateOperJson gen2 = new StateOperJson(modelURI, folder, arguments); // File jsonFolder = new File(Define.RUN_TIME_TEXT_OUTPUT_PATH // + File.separator + "tempJson"); // if (!jsonFolder.exists()) { // jsonFolder.mkdirs(); // } // StateOperJson gen2 = new StateOperJson(modelURI, jsonFolder, arguments); // // 2015-1-20 modified for 2741 end // String generationID2 = AcceleoLaunchingUtil.computeUIProjectID( // pluginName, StateOperJson.class.getName(), modelURI.toString(), // folder.toString(), new ArrayList<String>()); // gen2.setGenerationID(generationID2); // // if (gends) { // // atl? // monitor.subTask("Performing ATL transform,the process may be slowly."); // PluginToolsActivator.getDefault().writeMsgToConsole("", // "Performing ATL transform,the process may be slowly.", 0); // // URI inURI = URI.createFileURI(topModelPath); // URI outURI = inURI.trimFileExtension().appendFileExtension("spec"); // // { // // // File outAtlFile = new File(outURI.toFileString()); // if (outAtlFile.exists()) { // outAtlFile.delete(); // } // // doAtlProcess(modelFile.getProject(), inURI, outURI); // // // atl // if (!outAtlFile.exists()) { // return; // } // } // // monitor.subTask("Generating,the process may be slowly."); // PluginToolsActivator.getDefault().writeMsgToConsole("", // "Generating,the process may be slowly.", 0); // // Generate generate = new Generate(outURI, folder, arguments); // String genStateID = AcceleoLaunchingUtil.computeUIProjectID( // pluginName, Generate.class.getName(), outURI.toString(), // folder.toString(), new ArrayList<String>()); // generate.setGenerationID(genStateID); // generate.doGenerate(BasicMonitor.toMonitor(monitor)); // // svg?? // GenSvgFlowchart gen3 = new GenSvgFlowchart(modelURI, folder, // arguments); // String generationID3 = AcceleoLaunchingUtil.computeUIProjectID( // pluginName, GenSvgFlowchart.class.getName(), // modelURI.toString(), folder.toString(), // new ArrayList<String>()); // gen3.setGenerationID(generationID3); // gen3.doGenerate(BasicMonitor.toMonitor(monitor)); // // // cpy /resources/img??page?htmljs // FileUtil.copyFolder(imageFolder, // folder.getAbsolutePath() + File.separator + "app" // + ProjectProperty.ProjectImagePath, ignores); // // copy noPage.png // FileUtil.copyTemplateFile(folder.getAbsolutePath() + File.separator // + "app" + ProjectProperty.ProjectImagePath, // FileUtil.getJarPath("com.iauto.mist.spec.external.plugin"), // "required/NoPage.png"); // String jsPath = folder.getAbsolutePath() + File.separator + "app" // + File.separator + "controllers"; // String htmlPath = folder.getAbsolutePath() + File.separator + "app" // + File.separator + "views"; // String cssPath = folder.getAbsolutePath() + File.separator + "app" // + File.separator + "resources/css"; // // String pagePath = mistProject // .getFolder(ProjectProperty.ProjectPageFoder).getLocation() // .toString(); // SpecCommonUtil.generateHtmlAndJsByPage(pagePath, mistProject, // htmlPath, jsPath, cssPath); // // app/index.html // String indexPath = folder.getAbsolutePath() + File.separator // + "app" + File.separator + "index.html"; // if (new File(indexPath).exists()) { // UtilFileMethod.modifyFileContent(new File(indexPath), // "%ProjectName%", mistProject.getName()); // } // // if (!new File(folder.getAbsolutePath() + File.separator + "app" // + File.separator + "resources/css/" + mistProject.getName() // + ".css").exists()) { // new File(folder.getAbsolutePath() + File.separator + "app" // + File.separator + "resources/css/" // + mistProject.getName() + ".css").createNewFile(); // } // // // ?CC // FileUtil.copyFolder(ccFolder, folder.getAbsolutePath() // + File.separator + "app" + ProjectProperty.ProjectCCPath, // ignores); // // // ?uml2uiflow jartpth stm/lib // String libDestDir = folder.getAbsolutePath() + File.separator // + "app" + File.separator + "stm" + File.separator + "lib"; // FileUtil.copyTemplateFile( // libDestDir, // FileUtil.getJarPath(com.iauto.mist.spec.m2t.uml2uiflow.Activator.PLUGIN_ID), // "required"); // // // ?context.js // this.copyContextXml(new File(folder.getAbsolutePath() // + File.separator + "app" + File.separator + "stm")); // // // // File uiflowFolder = new File(folder.getAbsolutePath() // + File.separator + "app" + File.separator + "stm"); // File tempFolder = FileUtil.createTempFolder(uiflowFolder); // // com.iauto.mist.spec.m2t.uml2uiflow.main.GenerateHtml gen0 = new com.iauto.mist.spec.m2t.uml2uiflow.main.GenerateHtml( // outURI, tempFolder, arguments); // String generationID = org.eclipse.acceleo.engine.utils.AcceleoLaunchingUtil // .computeUIProjectID( // "com.iauto.mist.spec.m2t.uml2uiflow", // "com.iauto.mist.spec.m2t.uml2uiflow.main.GenerateHtml", // outURI.toString(), tempFolder.toString(), // new ArrayList<String>()); // gen0.setGenerationID(generationID); // gen0.doGenerate(BasicMonitor.toMonitor(monitor)); // // try { // FileUtil.copyFolder(tempFolder, uiflowFolder, // new String[] { " " }); // } finally { // // // FileUtil.deleteFolder(tempFolder); // } // // // appapp.json?reference project // SpecCommonUtil.createAppJson(folder.getAbsolutePath() // + File.separator + "app", modelFile.getProject()); // // // 2015-1-27 add for 2791 start // SpecCommonUtil.addWinEditorJSFile(mistProject, // folder.getAbsolutePath() + File.separator + "app" // + File.separator + "index.html", // folder.getAbsolutePath() + File.separator + "app"); // // 2015-1-27 add for 2791 end // // ?? // // file:///D:/mist_ver2/runtime-New_configuration/sample/web/index.html#/ // final String url = "file:///" // + SpecCommonUtil.urlEncode(folder.getAbsolutePath()) // + "/index.html#/"; // IPreferenceStore store = Activator.getDefault() // .getPreferenceStore(); // String chromePath = store.getString("CHROME_PATH"); // // if (null != chromePath) { // File chromeFile = new File(chromePath); // if (chromeFile.exists()) { // ChromeUtil.openChrome(chromePath, url); // } else { // ChromeUtil.configChromePath(url); // } // } else { // ChromeUtil.configChromePath(url); // } // } // if (genfc) { // GenerateXls.clearIgnoreStatemachine(); // // 2015-1-20 add for 2741 start // utils.clearIgnoreStatemachine(); // // 2015-1-20 add for 2741 end // List<StateMachine> stateMachines = selectStateMachine(topModel, // new ArrayList<StateMachine>()); // for (StateMachine stateMachine : stateMachines) { // GenerateXls.addIgnoreStatemachine(stateMachine); // // 2015-1-20 add for 2741 start // utils.addIgnoreStatemachine(stateMachine); // // 2015-1-20 add for 2741 end // } // GenerateXls.appUpdateRecords = genApp; // GenerateXls.outline_display = true; // // gen2.doGenerate(BasicMonitor.toMonitor(monitor)); // // // 2015-1-20 delete for 2741 start // // XlsRender2.setOpeJsonObj(); // // 2015-1-20 delete for 2741 end // gen1.doGenerate(BasicMonitor.toMonitor(monitor)); // // } // if (genfc2) { // GenerateXls2.clearIgnoreStatemachine(); // List<StateMachine> stateMachines = selectStateMachine(topModel, // new ArrayList<StateMachine>()); // for (StateMachine stateMachine : stateMachines) { // GenerateXls2.addIgnoreStatemachine(stateMachine); // } // gen12.doGenerate(BasicMonitor.toMonitor(monitor)); // } // if (genfc3) { // GenerateXls.clearIgnoreStatemachine(); // // 2015-1-20 add for 2741 start // utils.clearIgnoreStatemachine(); // // 2015-1-20 add for 2741 end // List<StateMachine> stateMachines = selectStateMachine(topModel, // new ArrayList<StateMachine>()); // for (StateMachine stateMachine : stateMachines) { // GenerateXls.addIgnoreStatemachine(stateMachine); // // 2015-1-20 add for 2741 start // utils.addIgnoreStatemachine(stateMachine); // // 2015-1-20 add for 2741 end // } // GenerateXls.appUpdateRecords = genApp; // GenerateXls.outline_display = false; // // gen2.doGenerate(BasicMonitor.toMonitor(monitor)); // // 2015-1-20 delete for 2741 start // // XlsRender2.setOpeJsonObj(); // // 2015-1-20 delete for 2741 end // gen1.doGenerate(BasicMonitor.toMonitor(monitor)); // } // // 2015-1-20 add for 2741 start // if (genfc || genfc3) { // utils.clearIgnoreStatemachine(); // XlsRender2.cleanJsonFolderAndJsonData(); // } // // 2015-1-20 add for 2741 end // if (genop) { // // 2015-1-20 delete for 2741 start // // if (!genfc) { // // // gen2.doGenerate(BasicMonitor.toMonitor(monitor)); // // TimeUtil.pause(TimeUtil.PAUSE_1); // // } // // 2015-1-20 delete for 2741 end // // 2015-1-20 add for 2741 start // // make json data for design check sheet // StateOperJsonForDesignCheckSheet gen3 = new StateOperJsonForDesignCheckSheet( // modelURI, folder, arguments); // String generationID3 = AcceleoLaunchingUtil.computeUIProjectID( // pluginName, // StateOperJsonForDesignCheckSheet.class.getName(), // modelURI.toString(), folder.toString(), // new ArrayList<String>()); // gen3.setGenerationID(generationID3); // gen3.doGenerate(BasicMonitor.toMonitor(monitor)); // // 2015-1-20 add for 2741 end // // DesignCheckSheet designCheckSheet = new DesignCheckSheet(); // designCheckSheet.deal(externalJarFilePath, monitor, 0); // } // // 2015-1-27 modify for 2791 start // if (!gends) { // SpecCommonUtil.addWinEditorJSFile(mistProject, // folder.getAbsolutePath() + File.separator + "app" // + File.separator + "index.html", // folder.getAbsolutePath() + File.separator + "app"); // } // // 2015-1-27 modify for 2791 end // // // 2015-1-20 delete for 2741 start // // XlsRender2.cleanOldFile(); // // 2015-1-20 delete for 2741 end // } private void doAtlProcess(final IProject html5Project, final URI inURI, final URI outURI) { // ?com.iauto.mist.spec.atl.standalone?jar/com.iauto.mist.spec.atl.standalone.jar if (ATLStandAlone.canStandAlone()) { String jarPath = ATLStandAlone.getJarFilePath(); String cmd = "java -jar " + jarPath + " " + inURI.toFileString() + " " + outURI.toFileString(); try { Process process = Runtime.getRuntime().exec(cmd); try { int exitCode = process.waitFor(); if (exitCode == 0) { PluginToolsActivator.getDefault().writeMsgToConsole("", "ATL complete.", 0); } else { BufferedReader stdInput = new BufferedReader( new InputStreamReader(process.getInputStream())); // read the output from the command // System.out // .println("Here is the standard output of the command:\n"); StringBuffer out = new StringBuffer(); String s = null; while ((s = stdInput.readLine()) != null) { // System.out.println(s); out.append(s); } PluginToolsActivator.getDefault().writeMsgToConsole("", "ATL error.", 0); PluginToolsActivator.getDefault().writeMsgToConsole("", out.toString(), 0); // delete atl file File atlFile = new File(outURI.toFileString()); if (atlFile.exists()) { atlFile.delete(); } PluginToolsActivator.getDefault().writeMsgToConsole("", "Start running atl by plugin.", 0); // UML??SPEC Job atlTransformJob = new Job("Transforming UML model to SPEC model...") { @Override protected IStatus run(IProgressMonitor monitor) { launchUML2Spec(inURI, outURI); return Status.OK_STATUS; } }; atlTransformJob.setUser(true); try { atlTransformJob.schedule(); atlTransformJob.join(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } return; } } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } else { // UML??SPEC Job atlTransformJob = new Job("Transforming UML model to SPEC model...") { @Override protected IStatus run(IProgressMonitor monitor) { launchUML2Spec(inURI, outURI); return Status.OK_STATUS; } }; atlTransformJob.setUser(true); try { atlTransformJob.schedule(); atlTransformJob.join(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } // atl? Job atlDataJob = new Job("Filling in SPEC model data...") { @Override protected IStatus run(final IProgressMonitor monitor) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { AtlDataTracker tracker = new AtlDataTracker(html5Project, Display.getDefault().getActiveShell(), monitor); spec.Model specModel = tracker.parseAtlModel(outURI); Model umlModel = ModelUtil.parseUMLFile(inURI); tracker.fillAtlData(umlModel, specModel); tracker.saveAtlModel(specModel); tracker.replaceHoshi(outURI.toFileString()); } }); return Status.OK_STATUS; } }; atlDataJob.setUser(true); try { atlDataJob.schedule(); atlDataJob.join(); } catch (Exception e) { e.printStackTrace(); } } private void doAntGeneration(IProgressMonitor monitor) throws IOException { // acceleo?? ConfigUtil.defaultPre = prefix; ConfigUtil.defaultPost = postfix; // ? StringBuffer customedTarget = new StringBuffer(targetPath); // ? String target = "/web"; // ? File folder = new File(target); // ?project if (!folder.isAbsolute()) { if (!target.startsWith("\\") && !target.startsWith("/")) { folder = new File(modelFile.getProject().getLocation().toString() + "/" + target); } else { folder = new File(modelFile.getProject().getLocation().toString() + target); } } if (!folder.exists()) { folder.mkdirs(); } print("Output path : " + folder.getAbsolutePath(), false); // ? // File tempFolder = FileUtil.createTempFolder( folder ); // ? Define.RUN_TIME_TEXT_OUTPUT_PATH = folder.getAbsolutePath(); Define.RUN_TIME_TEXT_IMAGE_PATH = modelFile.getProject().getLocation() + ""; XlsRender2.write_path = Define.RUN_TIME_TEXT_OUTPUT_PATH + "/" + Define.TEXT_OUTPUT_PATH + "/" + Define.XLS_OUTPUT_PATH; // ? FileUtil.copyFolder(imageFolder, folder.getAbsolutePath() + ProjectProperty.ProjectImagePath, ignores); FileUtil.copyFolder(refDocFolder, folder.getAbsolutePath() + "/ref_doc", ignores); // iAuto-SDK/platforms/{sdk}/templates/WebAppProjectTemplate String sdk = UtilCommonMethod.getSDKPrefix(null); FileUtil.copyTemplateFile(folder.getAbsolutePath(), FileUtil.getJarPath("com.iauto.html5.sdk"), sdk); // ?disvg String umlFilePath; umlFilePath = modelURI.toFileString(); JsonToOperaXls jsonToOperaXls = new JsonToOperaXls(); jsonToOperaXls.deal(externalJarFilePath, monitor, 0); } /** * Lacuches the generate method * * @param monitor * @param isInPlatform * ?platform * @throws IOException */ public void doGenerate(IProgressMonitor monitor, boolean isInPlatform) throws IOException { if (isInPlatform) { doPlatformGeneration(monitor); } else { doAntGeneration(monitor); } } private void launchUML2Spec(URI inURI, URI outURI) { Uml2spec runner; try { runner = new Uml2spec(); runner.loadModels(inURI.toString()); runner.doUml2spec(new NullProgressMonitor()); runner.saveModels(outURI.toString()); } catch (ATLCoreException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (ATLExecutionException e) { e.printStackTrace(); } } /** * * * @param model * @return */ private String getModelPath(Model model) { if (null != model.eResource().getURI()) { return model.eResource().getURI().toFileString(); } else { return null; } } /** * platformant??? * * @param isInPlatform */ private void print(String message, boolean isInPlatform) { if (isInPlatform) { PluginToolsActivator.getDefault().writeMsgToConsole("", message, 0); } else { System.out.println(message); } } /** * ???? * * @param targetFolder * @param iProject * @return */ public int getTargetFolder(final StringBuffer targetFolder, final IProject iProject, final String topModel) { final StringBuffer ret = new StringBuffer(); Display.getDefault().syncExec(new Runnable() { @Override public void run() { Uml2HtmlDialog dlg = new Uml2HtmlDialog(Display.getDefault().getActiveShell(), "Dynamic Specification", "Enter output folder.", targetFolder.toString(), topModel, iProject); if (dlg.open() == Window.OK) { // User clicked OK; targetFolder.replace(0, targetFolder.length(), ""); targetFolder.append(dlg.getValue()); ret.append(Window.OK); } else { ret.append(Window.CANCEL); } // if not need prompt , save it if (dlg.defaultCheck) { setDefaultPathPrompt(iProject, false); } dlg.close(); gends = dlg.isGends(); genfc = dlg.isGenfc(); genfc2 = dlg.isGenfc2(); genfc3 = dlg.isGenfc3(); genop = dlg.isGenop(); genupi = dlg.isGenupi(); } }); return Integer.valueOf(ret.toString()); } /** * ?project->properties? * * @param iProject * @param needPrompt */ private void setDefaultPathPrompt(IProject iProject, boolean needPrompt) { String defaultPathPrompt = "defaultPathPromptDS"; String value = needPrompt ? "true" : "false"; try { ((IResource) iProject).setPersistentProperty(new QualifiedName("", defaultPathPrompt), value); } catch (CoreException e) { e.printStackTrace(); } } private List<StateMachine> selectStateMachine(Model model, List<StateMachine> selection) { final Set<StateMachine> stateMachines = new HashSet<StateMachine>(); getAllStateMachine(model, stateMachines); final List<StateMachine> preSelectList = new ArrayList<StateMachine>(selection); final List<StateMachine> ret = new ArrayList<StateMachine>(); Display.getDefault().syncExec(new Runnable() { @Override public void run() { StateMachineChooseDialog dialog = new StateMachineChooseDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow(), new ArrayList<StateMachine>(stateMachines), preSelectList); dialog.open(); if (dialog.getReturnCode() == Window.OK) { ret.addAll(dialog.getSelection()); genApp = dialog.isGenApp(); } } }); giveErrorMessage(ret); if (retryFlg) { return selectStateMachine(model, ret); } stateMachines.removeAll(ret); return new ArrayList<StateMachine>(stateMachines); } private void giveErrorMessage(List<StateMachine> stateMachines) { // ?? StringBuffer opendFilesb = new StringBuffer(); FileOutputStream out = null; for (StateMachine sm : stateMachines) { try { File filePath = new File(XlsRender2.write_path); if (!filePath.exists()) { filePath.mkdirs(); } String fileName = XlsRender2.write_path + File.separator + sm.getName() + Define.FILE_SUFFIX_XLS; File file = new File(fileName); if (file.exists()) { out = new FileOutputStream(fileName); } } catch (FileNotFoundException e) { // ??? opendFilesb.append(sm.getName()); opendFilesb.append("\r\n"); } finally { if (out != null) { try { out.close(); } catch (IOException ioe) { ioe.printStackTrace(); } } } } // ??? String dialogMessageFixed = "The excel file corresponding to the following model(s) is opening now, please close it(them) and click \"Retry\"."; if ("".equals(opendFilesb.toString())) { retryFlg = false; return; } final String dialogMessage = dialogMessageFixed + "\r\n\r\n" + opendFilesb.toString(); // ?? Display.getDefault().syncExec(new Runnable() { @Override public void run() { MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error", null, dialogMessage, MessageDialog.ERROR, new String[] { IDialogConstants.RETRY_LABEL }, 0); dialog.open(); if (dialog.getReturnCode() == Window.OK) { retryFlg = true; } } }); } // private Set<StateMachine> getAllStateMachine( Model model ) { // Set<StateMachine> ret = new HashSet<StateMachine>(); // List<Element> elements = model.allOwnedElements(); // for ( Element element : elements ) { // if ( element instanceof StateMachine ) { // ret.add( (StateMachine) element ); // } // } // // List<Package> importedPackages = model.getImportedPackages(); // for ( Package importedPackage : importedPackages ) { // if ( importedPackage instanceof Model ) { // ret.addAll( getAllStateMachine( (Model) importedPackage ) ); // } // } // return ret; // } private void getAllStateMachine(Model model, Set<StateMachine> sets) { List<Element> elements = model.allOwnedElements(); for (Element element : elements) { if (element instanceof StateMachine) { if (!checkExist((StateMachine) element, sets)) { sets.add((StateMachine) element); } } } List<Package> importedPackages = model.getImportedPackages(); for (Package importedPackage : importedPackages) { if (importedPackage instanceof Model) { getAllStateMachine((Model) importedPackage, sets); } } } public boolean checkExist(StateMachine sm, Set<StateMachine> sets) { for (StateMachine curSm : sets) { if (curSm.getName().equals(sm.getName())) { return true; } } return false; } /** * project->properties?? * * @param iProject * @return */ private boolean getDefaultPathPrompt(IProject iProject) { String defaultPathPrompt = "defaultPathPromptDS"; try { String value = ((IResource) iProject).getPersistentProperty(new QualifiedName("", defaultPathPrompt)); if (null != value) { if ("true".equals(value)) { return true; } else { return false; } } else { return true; } } catch (CoreException e) { return true; } } /** * jarPluginNamejar?destDir * * @param destDir * @param jarPluginName * @throws IOException * @throws URISyntaxException */ public void copyContextXml(File destDir) { String filePath = modelFile.getProject().getLocation().toString() + "/context.js"; File file = new File(filePath); if (file.exists()) { FileUtil.copyFile(file, destDir); } } public static void setProjectCheck(boolean projectCheck) { projectCheckMap.put(modelFile.getProject(), projectCheck); } public static boolean getProjectCheck() { if (null == projectCheckMap.get(modelFile.getProject())) { projectCheckMap.put(modelFile.getProject(), false); return false; } else { return projectCheckMap.get(modelFile.getProject()); } } }