Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Fillter predicate
Fillter predicate [message #1062001] Wed, 05 June 2013 11:01 Go to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi all ,

I can not solved my Filter problem. ContentType element's parent reference to own.I want to itself is outside the defined.hence I must reach current Contenttype and then remove it from other.I load screenshot:cttype2 do not come for this window,I want to remove it with filtering.I used AbstractDeclarativeScopeProvider class but not successfull :(How can I do it can ypu help me

in addition :
I syncronize Xtext and Gmf .I done same operation with EMF code in the GMF but not work in the Xtext.my code :


public static ArrayList<ContentType> getPossibleParentContentType(ContentType content){
		
		Web web = ((Web)((CustomList)content.eContainer()).eContainer());
		while(web.eContainer().eClass().getName().equals("Web")){
			web = (Web) web.eContainer();
		}
		ArrayList<ContentType> allContentTypes = new ArrayList<>();
		
		allContentTypes = returnAllContentTypeFromGivenWeb(web, allContentTypes);
		
		
		allContentTypes.remove(content);
		
		return allContentTypes;
	}





Grammar:
CustomList returns CustomList:
	'CustomList'
	name=QualifiedName
	'{'
	'guID' '=' guID=STRING
	'displayName' '=' displayName=STRING
	'type' '=' type=ListType
	('description' '=' description=STRING)?
	(ownedContentType+=ContentType (ownedContentType+=ContentType)*)?
	(ownedView+=View (ownedView+=View)*)?
	'}';
ContentType returns ContentType:
	'ContentType'
	name=QualifiedName
	'{'
	'guID' '=' guID=STRING
	'displayName' '=' displayName=STRING
	('description' '=' description=STRING)?
	('group' '=' group=STRING)?
	('parent' '=' parentContentType=[ContentType|QualifiedName])?
	(ownedField+=Field (ownedField+=Field)*)?
	'}';



best regads
  • Attachment: removeown.png
    (Size: 23.16KB, Downloaded 116 times)
Re: Fillter predicate [message #1062003 is a reply to message #1062001] Wed, 05 June 2013 11:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

why do youn still not post the scopeprovider??????

IScope scope_ContentType_parentContentType(final ContentType ctx, EReference r) {

//alternatively do your aglo here and call Scopes.scopeFor
return new FilteringScope(delegateGetScope(ctx, r), new Predicate<IEObjectDescription>() {
public boolean apply(IEObjectDescription d) {
return !ctx.getName().equals(d.getName().toString());
};
});
}

(DID not try that)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 05 June 2013 11:22]

Report message to a moderator

Re: Fillter predicate [message #1062015 is a reply to message #1062003] Wed, 05 June 2013 12:21 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christrian,

I try with Xtend same code.but not successful .I do not write it in Xtend. FilteringScope(delegateGetScope(ctx, r)
new Predicate<IEObjectDescription> I do not define these Sad

I receive error

[Updated on: Wed, 05 June 2013 12:28]

Report message to a moderator

Re: Fillter predicate [message #1062023 is a reply to message #1062015] Wed, 05 June 2013 13:05 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian ,

I create a java class ,
ContentModelScopeProvider extends AbstractDeclarativeScopeProvider .and then I wite code.I bind it in the ContentRuntimeModule.java

@Override
public Class<? extends IScopeProvider> bindIScopeProvider() {
return ContentModelScopeProvider.class;
}

but not work :(I use Xtext 2.4.1 all class are Xtend
Re: Fillter predicate [message #1062032 is a reply to message #1062023] Wed, 05 June 2013 13:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Please share

- A complete clean Xtext (NO GMF) Project with a complete reproducable example
otherwhise i cannot help.
is you method called?
what does debugging say?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Fillter predicate [message #1062131 is a reply to message #1062032] Thu, 06 June 2013 07:30 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian,

I create a new Project without GMF.but my problem is scoping.hence I used qualifiedname
now ,another problem encountered. onlly ct1 comes in the ContentType's parent .ct2 is not come in the ContentType's parent.hence not comes elements are defined below in the contenttype's parent.such as I define a contenttype in the same customlist but not come in the contenttype's parent. How can I solved this scoping problem.There are top-down scop.if I defined contenttype in the ebove ,they comes in the below contenttype's parent.

Best regrads,

[Updated on: Thu, 06 June 2013 07:39]

Report message to a moderator

Re: Fillter predicate [message #1062133 is a reply to message #1062131] Thu, 06 June 2013 07:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i cannot answer until you provide what i asked for.
you have to customize naming if you want to use simple names globally.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Fillter predicate [message #1062135 is a reply to message #1062133] Thu, 06 June 2013 07:49 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian
I used Qualified name .I used my other project simplename and I solved global scop problem in the workflow.How can I solved with qualified name.Iqualifiednameprovider solved ?
Re: Fillter predicate [message #1062141 is a reply to message #1062135] Thu, 06 June 2013 08:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Customize the nameprovider

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Fillter predicate [message #1062164 is a reply to message #1062141] Thu, 06 June 2013 10:41 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian,

I try this for remove own contenttype but not work.I load screenshot.My aim is get only defined contenttype in the same sitecollection.hence must gets ct2.I tried to use my code :

IScope scope_ContentType_parentContentType(final ContentType ctx, EReference r) {

final ArrayList<ContentType> possiblecontenttype = ContentTypeUtil.getPossibleParentContentType(ctx);
System.out.println("possible"+ possiblecontenttype);
--> gets onlly ct2 but I don't reflected in the editor


Christian Dietrich wrote on Wed, 05 June 2013 07:21
Hi,

why do youn still not post the scopeprovider??????

IScope scope_ContentType_parentContentType(final ContentType ctx, EReference r) {

//alternatively do your aglo here and call Scopes.scopeFor
return new FilteringScope(delegateGetScope(ctx, r), new Predicate<IEObjectDescription>() {
public boolean apply(IEObjectDescription d) {
return !ctx.getName().equals(d.getName().toString());
};
});
}

(DID not try that)
Re: Fillter predicate [message #1062166 is a reply to message #1062164] Thu, 06 June 2013 10:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Please post the complete Scopeing Method

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Fillter predicate [message #1062172 is a reply to message #1062166] Thu, 06 June 2013 11:41 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi,

I want to call returned value from the ContentTypeUtil.getPossibleParentContentType(ctx);


Scope class:


public class ContentModelScopeProvider extends AbstractDeclarativeScopeProvider {
	IScope scope_ContentType_parentContentType(final ContentType ctx, EReference r) {
		final EObject parent = ctx;
		
		//System.out.println("parennnnnnnnnnnnnnnnnttttttttttttttttt"+parent);
		final ArrayList<ContentType> possiblecontenttype = ContentTypeUtil.getPossibleParentContentType(ctx);
		//System.out.println("possible"+ possiblecontenttype);
		
	return new FilteringScope(delegateGetScope(ctx, r), new Predicate<IEObjectDescription>() {
		public boolean apply(IEObjectDescription d) {
			System.out.println("........................."+d.getName().toString());
		return possiblecontenttype;  //I receive an error because not returns 
		};
		});
	}
		
	
	
}





I want to use my util class because there are a lots of constraints my system:( and I write code for this (my util class)


public static ArrayList<ContentType> getPossibleParentContentType(ContentType content){
		//Oncelikle rootWeb bulunur Buradanda tüm ContentTypelar cekilecek.
		Web web = ((Web)((CustomList)content.eContainer()).eContainer());
		while(web.eContainer().eClass().getName().equals("Web")){
			web = (Web) web.eContainer();
		}
		ArrayList<ContentType> allContentTypes = new ArrayList<>();
		//Burada Dokumandakı tum ContentTypelar cekilir.
		allContentTypes = returnAllContentTypeFromGivenWeb(web, allContentTypes);
		
		//Burada kendi dışındaki contentTypeları getirip seçmesini isterim.
		allContentTypes.remove(content);
		
		return allContentTypes;
	}
	
	public static ArrayList<ContentType> returnAllContentTypeFromGivenWeb(Web rootWeb, ArrayList<ContentType> returnAllContentTypesFromWeb){
		
		EList<CustomList> ownedLists = rootWeb.getOwnedList();
		for (Iterator<CustomList> iterator = ownedLists.iterator(); iterator.hasNext();) {
			CustomList customList = (CustomList) iterator.next();
			EList<ContentType> ownedContentTypes = customList.getOwnedContentType();
			
			for (Iterator<ContentType> iterator2 = ownedContentTypes.iterator(); iterator2
					.hasNext();) {
				ContentType contentType = (ContentType) iterator2.next();
				returnAllContentTypesFromWeb.add(contentType);
			}
		}
		
		EList<Web> ownedWebs = rootWeb.getOwnedWeb();
		
		for (Iterator<Web> iterator = ownedWebs.iterator(); iterator.hasNext();) {
			Web web = (Web) iterator.next();
			returnAllContentTypeFromGivenWeb(web, returnAllContentTypesFromWeb);
		}	
		return returnAllContentTypesFromWeb;
	}
}



[Updated on: Thu, 06 June 2013 11:43]

Report message to a moderator

Re: Fillter predicate [message #1062183 is a reply to message #1062172] Thu, 06 June 2013 12:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Looks like you mixed up two things once more.
you have to choose possibility a or possibility b

public class ContentModelScopeProvider extends AbstractDeclarativeScopeProvider {
	IScope scope_ContentType_parentContentType(final ContentType ctx, EReference r) {
		final EObject parent = ctx;
		
		//System.out.println("parennnnnnnnnnnnnnnnnttttttttttttttttt"+parent);
		final ArrayList<ContentType> possiblecontenttype = ContentTypeUtil.getPossibleParentContentType(ctx);
		return Scopes.scopeFor(possiblecontenttype );
	}
		
	
	
}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Fillter predicate [message #1062188 is a reply to message #1062183] Thu, 06 June 2013 12:49 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian,

Not get nothing in the contenttype's parent :(I load screen shot.I want to gets onlly ct2.When I enter ctrl+space onlly comes ct2
hence,What is the a and b Sad I do not understand
  • Attachment: scoping2.png
    (Size: 41.50KB, Downloaded 122 times)

[Updated on: Thu, 06 June 2013 12:54]

Report message to a moderator

Re: Fillter predicate [message #1062191 is a reply to message #1062188] Thu, 06 June 2013 13:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Please share a reproducing zip file

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Fillter predicate [message #1062200 is a reply to message #1062191] Thu, 06 June 2013 13:37 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian,

I do not understand.What do you mean:(

I share all of the related part .

Hence I try below code .When I enter the CTRL+SPACE ,comes nothing element.but I write ct1 in the contenttype's parent ,receive an error and get a quickfix.I load screenshot
  • Attachment: scop2.png
    (Size: 47.57KB, Downloaded 128 times)

[Updated on: Thu, 06 June 2013 13:37]

Report message to a moderator

Re: Fillter predicate [message #1062207 is a reply to message #1062200] Thu, 06 June 2013 13:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
I want you to export the complete project and share it with me. If I
take the time to start the debugger I do want to do it with your code

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Fillter predicate [message #1062219 is a reply to message #1062207] Thu, 06 June 2013 14:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Btw the screenshot does look good doesnt it?
i thought you wanted to filter out ct1


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Fillter predicate [message #1062602 is a reply to message #1062183] Sun, 09 June 2013 20:23 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian,

I can solved my problem.I call my util class for filtering.but I want to use my other class .I wrote my view util class but I debug it not enter this code:(I do not understand. I can not works it Sad My aim : if the related contettype's fields.comes all field now,but I filterinn showField .(onlly comes selected contenttype's fields)


my related rule in the grammar :

LookUp returns LookUp:
'LookUp'
name=QualifiedName
'{'
'guID' '=' guID=STRING
'displayName' '=' displayName=STRING
('contentType' '=' contentType=[ContentType|QualifiedName])
('showField' '=' showField=[Field|QualifiedName])
'}';




IScope scope_Lookup_contenttype(final ContentType ct, EReference r) {
		//final EObject parent = ctx;
		
		//System.out.println("parennnnnnnnnnnnnnnnnttttttttttttttttt"+parent);
		final ArrayList<Field> possiblefield = LookUpUtil.returnSourceContentTypeNotLookUpFields(ct);
		//System.out.println("possible"+ possiblecontenttype);
		
		return Scopes.scopeFor(possiblefield);
	
		
		
		
	}



My utill class for Lookup:




public class LookUpUtil {
	
	public static EList<Field> returnSourceContentTypeFields(ContentType contentTarget){
		return contentTarget.getOwnedField();
	}
	
	public static ArrayList<Field> returnSourceContentTypeNotLookUpFields(ContentType contentTarget){
		EList<Field> ownedFields = contentTarget.getOwnedField();
		ArrayList<Field> fields = new ArrayList<Field>();
		for (Iterator<Field> iterator = ownedFields.iterator(); iterator.hasNext();) {
			Field field = (Field) iterator.next();
			if(!field.eClass().getName().equals("LookUp")){
				fields.add(field);
			}
		}
		return fields;
	}
}









Christian Dietrich wrote on Thu, 06 June 2013 08:18
Looks like you mixed up two things once more.
you have to choose possibility a or possibility b

public class ContentModelScopeProvider extends AbstractDeclarativeScopeProvider {
	IScope scope_ContentType_parentContentType(final ContentType ctx, EReference r) {
		final EObject parent = ctx;
		
		//System.out.println("parennnnnnnnnnnnnnnnnttttttttttttttttt"+parent);
		final ArrayList<ContentType> possiblecontenttype = ContentTypeUtil.getPossibleParentContentType(ctx);
		return Scopes.scopeFor(possiblecontenttype );
	}
		
	
	
}


[Updated on: Sun, 09 June 2013 21:24]

Report message to a moderator

Re: Fillter predicate [message #1062612 is a reply to message #1062602] Mon, 10 June 2013 04:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Same answer: I need at least a complete runnable grammar and example
model. The best is if you create a new project with a simple grammar
that reproduces the problem.

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Fillter predicate [message #1062621 is a reply to message #1062612] Mon, 10 June 2013 06:45 Go to previous message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian,

I load my little project and screenshot.My aim is :Lookup field's type and showfield.

screenshot:if the user select T,gets onlly A
if the user select T1 in the type,gets onlly B.

Best regrads
Previous Topic:How to get ecore and genmodel?
Next Topic:Migrating Xbase-using language to Xtext 2.4
Goto Forum:
  


Current Time: Thu Apr 25 16:41:36 GMT 2024

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

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

Back to the top