Skip to main content



      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 04:16 Go to next message
Eclipse UserFriend
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 09:33 Go to previous message
Eclipse UserFriend
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: Sun Jul 06 13:21:47 EDT 2025

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

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

Back to the top