Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » illegalArgumentException(Attempted to beginRule: L/deneme/user.mydsl2, does not match outer scope rule: L/deneme/denemeCT.mydAttempted to beginRule: L/deneme/user.mydsl2, does not match outer scope rule: L/deneme/denemeCT.myd)
illegalArgumentException [message #1085104] Mon, 12 August 2013 13:04 Go to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi all,

I use two editor.I create some elements another editor automatically. but I receive an error about create URİ.I created resource Uri such as platfor/resource/relative path but
I receive an error :Attempted to beginRule: L/deneme/user.mydsl2, does not match outer scope rule: L/deneme/denemeCT.mydAttempted to beginRule: L/deneme/user.mydsl2, does not match outer scope rule: L/deneme/denemeCT.myds.I do not solve this problem Sad

public class Sitepermission6 {
	
	@Inject
	Provider<XtextResourceSet> rsp;
	
	
	public File userFile;

	public static SitePermission createDefaultSitePermission(String webName,
			String webGuID, UserModel userModel) {
		// Initialize the model
		MyDsl2Package.eINSTANCE.eClass();
		// Retrieve the default factory singleton
		MyDsl2Factory factory = MyDsl2Factory.eINSTANCE;
		// SitePermission
		SitePermission sitePermission = factory.createSitePermission();
		sitePermission.setName(webName);
		sitePermission.setWebGUID(webGuID);

		// Owners Group
		Group ownerGroup = MyDsl2Factory.eINSTANCE.createGroup();
		ownerGroup.setName("Owners");
		sitePermission.getOwnedGroup().add(ownerGroup);
		
        
		userModel.getSitePermissions().add(sitePermission);
		
		return sitePermission;
	}

	public SitePermission loadForCreateSitePermission(String webName,
			String webGuID) {
		
		
		SitePermission sitePermission = null;
	
		XtextResourceSet resourceSet = rsp.get();
		
		resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
		
		Resource resource = resourceSet.getResource(URI.createURI(getUserFileLocationURI()), true);
			System.out.println(resource);
			
			UserModel eobject = (UserModel) resource.getContents().get(0);
			
			sitePermission = createDefaultSitePermission(webName, webGuID, eobject);
		
			try {
				resource.save(null);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		
		
		return sitePermission;
	}


public  String getUserFileLocationURI() {
		IEditorPart editorPart = PlatformUI.getWorkbench()
				.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
		
		if (editorPart != null) {
			IFileEditorInput input = (IFileEditorInput) editorPart
					.getEditorInput();
			IFile file = input.getFile();
			
			String path = "";
			int segmentCount = file.getProjectRelativePath().segmentCount();
			if(segmentCount != 1){
				for (int i = 0; i < segmentCount -1; i++) {
					path += file.getProjectRelativePath().segment(i) + "/";
				}
			}
			return "platform:/resource/" + file.getProject().getName() + "/" + path + UserConstant1.USER_FILE_NAME;
		}
		return "";
	}
	

}




PS:

ıf use this code crate uri C:\relative path ,I do not receive an error.and I created elements in the editor but every time I save other editor for use cerated elements in the referenced editor.

public SitePermission loadForCreateSitePermission(String webName,
			String webGuID) {
		
		
		SitePermission sitePermission = null;
	
		XtextResourceSet resourceSet = rsp.get();
		
		resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
		
	getUserFilePath(getProjectName(), UserConstant1.USER_FILE_NAME);
		if (getUserFile() != null) {
		Resource resource = resourceSet.getResource(URI.createURI(userFile.toURI().toString()), true);
		Resource resource = resourceSet.getResource(URI.createURI(getUserFileLocationURI()), true);
			System.out.println(resource);
			
			UserModel eobject = (UserModel) resource.getContents().get(0);
			
			sitePermission = createDefaultSitePermission(webName, webGuID, eobject);
		
			try {
				resource.save(null);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			
		}
		
		return sitePermission;
	}

	/*public static IProject getProjectName() {
		IEditorPart editorPart = PlatformUI.getWorkbench()
				.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
		IProject activeProject = null;
		if (editorPart != null) {
			IFileEditorInput input = (IFileEditorInput) editorPart
					.getEditorInput();
			IFile file = input.getFile();
			activeProject = file.getProject();
		}
		return activeProject;
	}

	public void getUserFilePath(IProject project, String name) {
		File[] files = project.getLocation().toFile().listFiles();
		showFiles(files, name);
	}

	public void showFiles(File[] files, String name) {
		if (getUserFile() == null) {
			for (File file : files) {
				if (name.equals(file.getName())) {
					setUserFile(file);
					break;
				} else {
					if (file.isDirectory()) {
		showFiles(file.listFiles(), name); // Calls same method again.
					}
				}
			}
		}
	}

	public File getUserFile() {
		return userFile;
	}

	public void setUserFile(File userFile) {
		this.userFile = userFile;




Best Regards
Re: illegalArgumentException [message #1085107 is a reply to message #1085104] Mon, 12 August 2013 13:09 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

did you

Quote:
If you really want to modify different files on save, you'll have to
override XtextDocumentProvider.getSaveRule(..)


as Sebastian suggested?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Can't access implicit local variable from DSL editor
Next Topic:XTEXT Erfahrungsaustausch Frankfurt/Main, Interesse?
Goto Forum:
  


Current Time: Thu Apr 25 05:23:29 GMT 2024

Powered by FUDForum. Page generated in 0.03406 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top