Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » how to validate over all files & customize new project wizard(validation & project wizard)
how to validate over all files & customize new project wizard [message #714661] Thu, 11 August 2011 08:16 Go to next message
Michal S is currently offline Michal SFriend
Messages: 74
Registered: July 2011
Member
Hello,

I have trouble with two following tasks:

1. Validate unique names over all files with my extension in my project folder (and any subfolder)

I wrote code:
	@Check
	public void checkNamesAreUnique(Composition composition){	
		EList<FrameworkContent> contents = new BasicEList<FrameworkContent>();
		for (Resource resource: composition.eResource().getResourceSet().getResources()) {
			for (EObject eobject: resource.getContents()){
				if (eobject.getClass().getName().contains("FrameworkImpl")){
					Framework tc = ((Framework) eobject);
					contents.addAll(tc.getContents());
				}
			}
		}
		if (contents.size()>1){
			for (FrameworkContent c: contents){
				if (c.getClass().equals(composition.getClass()) && (!c.equals(composition))){
					if (((Composition) c).getName().equals(composition.getName())){
						error("Duplicate name in scope: "+ composition.getName(),FrameworkPackage.Literals.COMPOSITION__NAME);
					}
				}
			}		
		}
	}


Problem is, that composition.eResource().getResourceSet().getResources() returns only referenced resources, and I need all of them. When I close and again open the project it makes "update" and there are all resources found and it writes expected errors. But whenever I re-save the files containing duplicity, error is gone...


2. Customize Project Wizard: What I need is to create just folder structure (without files). I used to .xpt file to create folder structure with files, but I need it without them.
And also, I don't want "src" and "src-gen" folders to be created. In my model "src" has another meaning, it is used for specific purposes... not as the top level eclipse folder.
Is there any simple way how to do this?

Thanks in advance,
Michal
Re: how to validate over all files & customize new project wizard [message #714779 is a reply to message #714661] Thu, 11 August 2011 13:33 Go to previous message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

for 1) I would use the index (inject ResourceDescriptionsProvider). Note however, that e.g. in the MWE-context (resource set based index) only resources are indexed that are found in the given model path.

for 2) If you use the project wizard fragment, a MyDslProjectCreator should be generated in the src-gen folder of the UI project. It is bound in the UI module. Extend that class and bind it. I guess the best hook is in the enhanceProject method. There you are passed an IProject And there should be no problems creating new IFolders within that project.

Alex
Previous Topic:XText 2.0 --- Hover Documentation
Next Topic:Xtext 2.0 plugin product installed
Goto Forum:
  


Current Time: Fri Apr 16 18:25:04 GMT 2021

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

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

Back to the top