Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Made TestMergeDialog able to run with zipped models.

  • Loading branch information...
commit f48117720ad1c34c1c596b81648a7b7d272c153b 1 parent 9a49abb
authored January 12, 2011
63  core/kernel/source/jetbrains/mps/vcs/diff/ui/TestMergeDialog.java
@@ -17,53 +17,63 @@
17 17
 
18 18
 import com.intellij.openapi.project.Project;
19 19
 import com.intellij.openapi.util.Computable;
20  
-import com.intellij.openapi.util.InvalidDataException;
21  
-import com.intellij.openapi.application.Application;
22  
-import com.intellij.openapi.application.impl.ApplicationImpl;
23  
-import com.intellij.openapi.graph.base.DataProvider;
24  
-import com.intellij.openapi.diff.DiffManager;
25  
-import com.intellij.openapi.diff.DiffRequest;
26  
-import com.intellij.openapi.diff.MergeRequest;
27  
-import com.intellij.openapi.diff.impl.mergeTool.MergeRequestImpl;
28  
-import com.intellij.idea.IdeaTestApplication;
  20
+
29 21
 import static jetbrains.mps.TestMain.configureMPS;
  22
+
  23
+import com.intellij.util.io.ZipUtil;
30 24
 import jetbrains.mps.ide.IdeMain;
31 25
 import jetbrains.mps.ide.IdeMain.TestMode;
32 26
 import jetbrains.mps.smodel.*;
33 27
 import jetbrains.mps.smodel.persistence.def.ModelPersistence;
34  
-import jetbrains.mps.util.JDOMUtil;
  28
+import jetbrains.mps.util.FileUtil;
35 29
 import jetbrains.mps.vcs.ModelUtils;
  30
+import jetbrains.mps.vcs.VcsHelper;
  31
+import jetbrains.mps.vcs.VcsHelper.VcsMergeVersion;
  32
+import jetbrains.mps.vcs.diff.ui.ModelDiffTool.ReadException;
36 33
 import jetbrains.mps.vfs.FileSystem;
37 34
 import jetbrains.mps.vfs.IFile;
38 35
 import jetbrains.mps.project.*;
39 36
 
40  
-import jetbrains.mps.TestMain;
41  
-import jetbrains.mps.library.LibraryManager;
42  
-import jetbrains.mps.library.Library;
43  
-import jetbrains.mps.library.BaseLibraryManager.MyState;
44 37
 import jetbrains.mps.nodeEditor.EditorManager;
45  
-import org.jdom.Document;
46 38
 import org.jdom.JDOMException;
47 39
 import org.jetbrains.annotations.NotNull;
48 40
 
49 41
 import javax.swing.SwingUtilities;
50 42
 import javax.swing.WindowConstants;
51  
-import java.io.FileInputStream;
52  
-import java.io.IOException;
53 43
 import java.io.File;
54  
-import java.util.List;
55  
-import java.util.Set;
  44
+import java.io.IOException;
56 45
 
57 46
 public class TestMergeDialog {
58  
-  private static EditorManager myEditorManager = new EditorManager();
  47
+  private static EditorManager ourEditorManager = new EditorManager();
59 48
 
60 49
   public static void main(final String[] args) throws JDOMException, IOException {
61 50
     IdeMain.setTestMode(TestMode.NO_TEST);
62 51
     configureMPS();
63 52
 
64  
-    final SModel baseModel = ModelUtils.readModel(args[0]);
65  
-    final SModel mineModel = ModelUtils.readModel(args[1]);
66  
-    final SModel newModel = ModelUtils.readModel(args[2]);
  53
+    final SModel models[] = new SModel[3];
  54
+
  55
+    String resultFile;
  56
+    if (args.length == 2) {
  57
+      try {
  58
+        final SModel[] zipped = ModelUtils.loadZippedModels(new File(args[0]), VcsMergeVersion.values(), false);
  59
+        models[0] = zipped[0];
  60
+        models[1] = zipped[1];
  61
+        models[2] = zipped[2];
  62
+      } catch (ReadException e) {
  63
+        return;
  64
+      }
  65
+
  66
+      resultFile = args[1];
  67
+    } else if (args.length == 4) {
  68
+      models[0] = ModelUtils.readModel(args[0]);
  69
+      models[1] = ModelUtils.readModel(args[1]);
  70
+      models[2] = ModelUtils.readModel(args[2]);
  71
+
  72
+      resultFile = args[3];
  73
+    } else {
  74
+      System.err.println("There must be 2 or 4 parameters");
  75
+      return;
  76
+    }
67 77
 
68 78
     /*ModelAccess.instance().runWriteAction(new Runnable() {
69 79
       public void run() {
@@ -82,6 +92,7 @@ public void run() {
82 92
       }
83 93
     });
84 94
 */
  95
+    final String finalResultFile = resultFile;
85 96
     SwingUtilities.invokeLater(new Runnable() {
86 97
       public void run() {
87 98
         final MergeModelsDialog dialog = ModelAccess.instance().runReadAction(new Computable<MergeModelsDialog>() {
@@ -104,13 +115,13 @@ public IScope getScope() {
104 115
               @Override
105 116
               public <T> T getComponent(Class<T> clazz) {
106 117
                 if (clazz == EditorManager.class) {
107  
-                  return (T) myEditorManager;
  118
+                  return (T) ourEditorManager;
108 119
                 }
109 120
                 return null;
110 121
               }
111 122
             };
112 123
 
113  
-            return new MergeModelsDialog(context, baseModel, mineModel, newModel);
  124
+            return new MergeModelsDialog(context, models[0], models[1], models[2]);
114 125
           }
115 126
         });
116 127
         dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
@@ -123,7 +134,7 @@ public IScope getScope() {
123 134
         }
124 135
         ModelAccess.instance().runReadAction(new Runnable() {
125 136
           public void run() {
126  
-            IFile iFile = FileSystem.getFile(args[3]);
  137
+            IFile iFile = FileSystem.getFile(finalResultFile);
127 138
             if (!iFile.exists()) iFile.createNewFile();
128 139
             ModelPersistence.saveModel(result, iFile);
129 140
           }

0 notes on commit f481177

Please sign in to comment.
Something went wrong with that request. Please try again.