private Solution createSolution() { SolutionDescriptor d = new SolutionDescriptor(); String uuid = UUID.randomUUID().toString(); d.setNamespace(uuid); d.setId(ModuleId.fromString(uuid)); return StubSolution.newInstance(d, OWNER); }
private static Solution newSolutionInstance(ModuleHandle handle, MPSModuleOwner moduleOwner) { SolutionDescriptor descriptor = ((SolutionDescriptor) handle.getDescriptor()); assert descriptor != null; assert descriptor.getId() != null; return registerModule(new Solution(descriptor, handle.getFile()), moduleOwner); }
protected Solution addSolution(String name, VirtualFile[] roots) { SolutionDescriptor sd = new SolutionDescriptor(); sd.setNamespace(name); sd.setId(ModuleId.foreign(name)); addModelRoots(sd, roots); return StubSolution.newInstance(sd, this); }
@Override protected void doSetModuleDescriptor(ModuleDescriptor moduleDescriptor) { assert moduleDescriptor instanceof SolutionDescriptor; SolutionDescriptor newDescriptor = (SolutionDescriptor) moduleDescriptor; newDescriptor.setNamespace(myModule.getName()); // addLibs(newDescriptor); super.doSetModuleDescriptor(newDescriptor); try { ApplicationManager.getApplication() .getComponent(JdkStubSolutionManager.class) .claimSdk(myModule); } catch (final DifferentSdkException e) { // TODO this seems to behave suspiciously in tests StartupManager.getInstance(myModule.getProject()) .runWhenProjectIsInitialized( new Runnable() { @Override public void run() { Messages.showErrorDialog( myModule.getProject(), "There are more than one different SDKs used in modules with MPS facets.\n" + "Trying to use " + e.getRequestedSdk().getName() + " while " + e.getCurrentSdk().getName() + " is already used." + "\n", "Multiple SDKs not supported in MPS plugin"); } }); } }
@Override public void apply() { if (myJavaModuleFacet.getModule() instanceof Solution) { SolutionDescriptor descriptor = (SolutionDescriptor) myJavaModuleFacet.getModule().getModuleDescriptor(); descriptor.setCompileInMPS(myCheckBox.isSelected()); descriptor.setKind((SolutionKind) myComboBox.getSelectedItem()); } myPathsTableModel.apply(); myLibraryTableModel.apply(); }
private SNode convertSolution(SolutionDescriptor source) { SNode result = SConceptOperations.createNewNode("jetbrains.mps.lang.project.structure.Solution", null); result.setId(SNodeId.fromString("~root")); SModelOperations.addRootNode(myModel, result); fill(result, source); SPropertyOperations.set(result, "dontLoadClasses", "" + source.isDontLoadClasses()); SPropertyOperations.set(result, "outputPath", source.getOutputPath()); SPropertyOperations.set(result, "solutionPath", myFile.getPath()); collectModels(result, source); return result; }
@Override public boolean isModified() { boolean solutionCheck = false; if (myJavaModuleFacet.getModule() instanceof Solution) { SolutionDescriptor descriptor = (SolutionDescriptor) myJavaModuleFacet.getModule().getModuleDescriptor(); solutionCheck = descriptor.getCompileInMPS() != myCheckBox.isSelected() || descriptor.getKind() != myComboBox.getSelectedItem(); } return myPathsTableModel.isModified() || myLibraryTableModel.isModified() || solutionCheck; }
public static void addModelRoots( SolutionDescriptor solutionDescriptor, VirtualFile[] roots, ModelRootManager rootMgr) { Set<String> seenPaths = new HashSet<String>(); for (ModelRootDescriptor d : solutionDescriptor.getModelRootDescriptors()) { ModelRoot root = d.getRoot(); if (root != null && EqualUtil.equals(root.getManager(), rootMgr)) { seenPaths.add(root.getPath()); } } for (VirtualFile f : roots) { SModelRoot modelRoot = new SModelRoot(rootMgr); modelRoot.setPath(getLocalPath(f)); if (!seenPaths.add(modelRoot.getPath())) continue; solutionDescriptor.getModelRootDescriptors().add(modelRoot.toDescriptor()); } }
/*package*/ Solution createNewSolution(final IFile solutionDescriptorFile) { MPSProject mpsProject = myThis.getProject(); // Prepare files File dir = new File(solutionDescriptorFile.getAbsolutePath()).getParentFile(); if (!(dir.exists())) { dir.mkdirs(); } String solutionFileName = solutionDescriptorFile.getName(); String solutionName = solutionFileName.substring(0, solutionFileName.length() - 4); // Create // RE-2448 ModelRoot modelRoot = new ModelRoot(); modelRoot.setPrefix(""); modelRoot.setPath(solutionDescriptorFile.getParent().getAbsolutePath()); final Solution solution = Solution.createStubSolution(solutionName, solutionDescriptorFile, mpsProject, modelRoot); SolutionDescriptor solutionDescriptor = solution.getModuleDescriptor(); solutionDescriptor.setCompileInMPS(myThis.getCompileInMPS()); // Add SWC file to the classpath ModelRoot stubModelEntry = new ModelRoot(); stubModelEntry.setPath(myThis.getSourcesPath()); stubModelEntry.setManager(LanguageID.AS_MANAGER); solutionDescriptor.getStubModelEntries().add(stubModelEntry); // Add languages refs solutionDescriptor .getUsedLanguages() .add(ModuleReference.fromString(Languages.ACTION_SCRIPT_INTERNAL)); solutionDescriptor .getUsedLanguages() .add(ModuleReference.fromString(Languages.ACTION_SCRIPT_LOGGING)); solutionDescriptor .getUsedLanguages() .add(ModuleReference.fromString(Languages.ACTION_SCRIPT_ASSETS)); // Add playerglobal reference Dependency playerGlobalDependency = new Dependency(); playerGlobalDependency.setModuleRef(ModuleReference.fromString(PLAYERGLOBAL_SWC)); solutionDescriptor.getDependencies().add(playerGlobalDependency); // Save the solution descriptor ModelAccess.instance() .writeFilesInEDT( new Runnable() { public void run() { solution.save(); } }); mpsProject.addProjectModule(solution); return solution; }
@Override public void init() { JPanel advancedTab = new JPanel(); advancedTab.setLayout( new GridLayoutManager( (myJavaModuleFacet.getModule() instanceof Solution ? 5 : 3), 2, MPSPropertiesConfigurable.INSETS, -1, -1)); int row = 0; if (myJavaModuleFacet.getModule() instanceof Solution) { SolutionDescriptor descriptor = ((Solution) myJavaModuleFacet.getModule()).getModuleDescriptor(); JBLabel solutionKindLabel = new JBLabel( PropertiesBundle.message("mps.properties.configurable.module.javatab.solutionkind")); myComboBox = new ComboBox(new DefaultComboBoxModel(SolutionKind.values())); myComboBox.setSelectedItem(descriptor.getKind()); myComboBox.setPreferredSize(new Dimension(300, 20)); advancedTab.add( solutionKindLabel, new GridConstraints( row, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); advancedTab.add( myComboBox, new GridConstraints( row++, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); myCheckBox = new JBCheckBox( PropertiesBundle.message("mps.properties.configurable.module.javatab.compileinmps"), descriptor.getCompileInMPS()); advancedTab.add( myCheckBox, new GridConstraints( row++, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); } advancedTab.add( getSourcePathsTable(), new GridConstraints( row++, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); advancedTab.add( getLibrariesTable(), new GridConstraints( row, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); setTabComponent(advancedTab); }