コード例 #1
0
 public void doExecute(@NotNull final AnActionEvent event, final Map<String, Object> _params) {
   try {
     IModule module = ((SModelDescriptor) MapSequence.fromMap(_params).get("model")).getModule();
     TreeFileChooser treeFileChooser = new TreeFileChooser();
     treeFileChooser.setDirectoriesAreAlwaysVisible(true);
     treeFileChooser.setMode(TreeFileChooser.MODE_DIRECTORIES);
     final SModel sModel =
         ((SModelDescriptor) MapSequence.fromMap(_params).get("model")).getSModel();
     treeFileChooser.setFileFilter(
         new IFileFilter() {
           public boolean accept(IFile file) {
             return JavaCompiler.checkBaseModelMatchesSourceDirectory(
                 sModel, new File(file.getPath()));
           }
         });
     String generatorOutputPath = module.getGeneratorOutputPath();
     File initial = null;
     File output = new File(generatorOutputPath);
     if (output.exists()) {
       initial = output;
       File sourceRoot = new File(initial.getParentFile(), "source");
       if (!(sourceRoot.exists())) {
         sourceRoot = new File(initial.getParentFile(), "src");
       }
       initial = sourceRoot;
       if (sourceRoot.exists()) {
         File modelSource = new File(sourceRoot, NameUtil.pathFromNamespace(sModel.getLongName()));
         if (modelSource.exists()) {
           initial = modelSource;
         }
       }
     }
     if (initial != null) {
       treeFileChooser.setInitialFile(
           FileSystem.getInstance().getFileByPath(initial.getAbsolutePath()));
     }
     IFile result =
         treeFileChooser.showDialog(((Frame) MapSequence.fromMap(_params).get("frame")));
     if (result != null) {
       JavaCompiler javaCompiler =
           new JavaCompiler(
               ((IOperationContext) MapSequence.fromMap(_params).get("context")),
               module,
               new File(result.getPath()),
               false,
               sModel);
       javaCompiler.compile();
     }
   } catch (Throwable t) {
     if (log.isErrorEnabled()) {
       log.error("User's action execute method failed. Action:" + "GetModelContentsFromSource", t);
     }
   }
 }