CTRL+SPACE action [message #1063181] |
Wed, 12 June 2013 10:41  |
Eclipse User |
|
|
|
Hi all,
I want to remove duplicat names and same type in the View 's fields.How can I do this.I want to use my util class.
related part for this topic :http://www.eclipse.org/forums/index.php/m/1063178/#msg_1063178
Could you help me
My grammar is below :
View returns View:
'View'
name=QualifiedName
'{'
'guID' '=' guID=STRING
'displayName' '=' displayName=STRING
('description' '=' description=STRING)?
'type' '=' type= ViewType
('fields' '=' ownedViewField+=ViewField (','ownedViewField+=ViewField)*)?
'}';
ViewField returns ViewField:
(field= [Field|QualifiedName]);
my util class is below :
public static ArrayList<Field> possibleFieldForViewField(View view){
ArrayList<Field> uniqueFields = returnUniqueParenListFields(view);
EList<ViewField> ownedViewFields = view.getOwnedViewField();
for (Iterator<ViewField> iterator = ownedViewFields.iterator(); iterator.hasNext();) {
ViewField viewField = (ViewField) iterator.next();
Field alreadyAddedField = viewField.getField();
for(int i = 0; i < uniqueFields.size(); i++){
Field field = uniqueFields.get(i);
if(field.eClass().getName().equals(alreadyAddedField.eClass().getName()) && field.getName().equals(alreadyAddedField.getName())){
uniqueFields.remove(i);
}
}
}
return uniqueFields;
}
}
public static ArrayList<Field> returnUniqueParenListFields(View view){
ArrayList<Field> allFields = returnAllParenListFields(view);
for(int i = 0; i < allFields.size(); i++){
Field field1 = allFields.get(i);
for(int j = i+1; j < allFields.size(); j++){
Field field2 = allFields.get(j);
if(field1.eClass().getName().equals(field2.eClass().getName()) && field1.getName().equals(field2.getName())){
allFields.remove(j);
}
}
}
return allFields;
}
public static ArrayList<Field> returnAllParenListFields(View view){
ArrayList<Field> allFields = new ArrayList<>();
CustomList parentList = (CustomList) view.eContainer();
EList<ContentType> ownedContentTypes = parentList.getOwnedContentType();
for (Iterator<ContentType> iterator = ownedContentTypes.iterator(); iterator
.hasNext();) {
ContentType contentType = (ContentType) iterator.next();
EList<Field> fields = contentType.getOwnedField();
for (Iterator<Field> iterator2 = fields.iterator(); iterator2.hasNext();) {
Field field = (Field) iterator2.next();
allFields.add(field);
}
}
return allFields;
}
|
|
|
Re: CTRL+SPACE action [message #1063214 is a reply to message #1063181] |
Wed, 12 June 2013 12:37   |
Eclipse User |
|
|
|
Hi,
once more your grammar is incomplete.
let us asume it looks like
Model:
fields+=Field*
views+=View*;
Field:
"Field" name=ID
;
View returns View:
'View'
name=QualifiedName
'{'
'guID' '=' guID=STRING
'displayName' '=' displayName=STRING
('description' '=' description=STRING)?
('fields' '=' ownedViewField+=ViewField (','ownedViewField+=ViewField)*)?
'}';
ViewField returns ViewField:
(field= [Field|QualifiedName]);
QualifiedName: ID ("." ID)*;
then the Proposal Provider could look like (written in Xtend):
class MyDslProposalProvider extends AbstractMyDslProposalProvider {
override completeViewField_Field(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
val view = EcoreUtil2::getContainerOfType(model, typeof(View))
val names = view.ownedViewField.map[vw|vw.field?.name].filter[v|v!=null].toList
println (names)
lookupCrossReference(assignment.terminal as CrossReference, context, acceptor, [
IEObjectDescription d | names.contains(d.qualifiedName.toString)
])
}
}
|
|
|
|
|
|
Re: CTRL+SPACE action [message #1063269 is a reply to message #1063265] |
Wed, 12 June 2013 17:35   |
Eclipse User |
|
|
|
Hi Christian,
I remove some rules in the grammar.I do it simplify .
Fistly :!names.contains(d.qualifiedName.toString) not understand it :( I use DefaultDeclarativeQualifiedNameProvider :retuns all field names :This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
******text
******created
******createdBy
******contentTYPE
******numberfield
******bool
@Inject
IQualifiedNameConverter qnc;
QualifiedName qualifiedName(Field f) {
System.out.println("******"+f.getName());
return qnc.toQualifiedName(f.getName());
}
Secondly :I want to say with (it but not comes in the View's fields ) :When I enter CTRL+SPACE,does not come nothing in the View's fields attribute. :(:(:(I used below code
override completeViewField_Field(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
val view = EcoreUtil2::getContainerOfType(model, typeof(View))
println ("viewwwww"+view)
val names = view.ownedViewField.map[vw|vw.field?.name].filter[v|v!=null].toList
println ("namessss"+names)
lookupCrossReference(assignment.terminal as CrossReference, context, acceptor, [
IEObjectDescription d | names.contains(d.qualifiedName.toString)
])
}
really ,I am very confised :( Hence I allready duplicate name check with NamesAreUniqueValidator.My aim is:remove fields that has same type and same name in the View's ownedFields
(such as There are two Lookup field ,must get one lookupfield)
[Updated on: Wed, 12 June 2013 17:39] by Moderator
|
|
|
|
|
|
|
|
Re: CTRL+SPACE action [message #1063278 is a reply to message #1063274] |
Wed, 12 June 2013 17:59   |
Eclipse User |
|
|
|
Hi,
I tried this code .my result is below screenshot. gets all field
Christian Dietrich wrote on Wed, 12 June 2013 17:51here is my current version
class MyDslProposalProvider extends AbstractMyDslProposalProvider {
override completeViewField_Field(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
val view = EcoreUtil2::getContainerOfType(model, typeof(View))
val names = view.ownedViewField.map[vw|vw.field?.name].filter[v|v!=null].toList
println (names)
lookupCrossReference(assignment.terminal as CrossReference, context, acceptor, [
IEObjectDescription d | println(d.qualifiedName);!names.contains(d.qualifiedName.toString)
])
}
}
|
|
|
|
|
|
|
|
Re: CTRL+SPACE action [message #1063294 is a reply to message #1063278] |
Wed, 12 June 2013 18:36   |
Eclipse User |
|
|
|
Hi,
I used this code and duplicate names are remove.
but I use for field qualifiedname : overridequalifiedname screenshot
@Inject
IQualifiedNameConverter qnc;
QualifiedName qualifiedName(Field f) {
System.out.println("******"+f.getName());
return qnc.toQualifiedName(f.getName());
}
if I do not use QualifiedName qualifiedName(Field f),result screenshot:withoutqualifiednameoverride:gets all field.
must I use IQualifiedNameConverter qnc?
junior developer wrote on Wed, 12 June 2013 17:59Hi,
I tried this code .my result is below screenshot. gets all field
Christian Dietrich wrote on Wed, 12 June 2013 17:51here is my current version
class MyDslProposalProvider extends AbstractMyDslProposalProvider {
override completeViewField_Field(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
val view = EcoreUtil2::getContainerOfType(model, typeof(View))
val names = view.ownedViewField.map[vw|vw.field?.name].filter[v|v!=null].toList
println (names)
lookupCrossReference(assignment.terminal as CrossReference, context, acceptor, [
IEObjectDescription d | println(d.qualifiedName);!names.contains(d.qualifiedName.toString)
])
}
}
[Updated on: Wed, 12 June 2013 18:39] by Moderator
|
|
|
|
|
|
|
Re: CTRL+SPACE action [message #1063538 is a reply to message #1063408] |
Thu, 13 June 2013 07:50   |
Eclipse User |
|
|
|
Hi Christian,
now,My problem is qualifiedname.
I used qualifiedname :
public class QNP extends DefaultDeclarativeQualifiedNameProvider{
QualifiedName qualifiedName(Field f) {
System.out.println("++++++++++++++++++++++++"+f.getName());
return qualifiedName(f.getName());
}
}
Result:
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.text
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.created
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.createdBy
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.contentTYPE
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.numberfield
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.bool
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.text
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.creaated
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.createdBy
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.contentTYPE
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.lookup1
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.text
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.created
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.createdBy
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.contentTYPE
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.numberfield
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.bool
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.text
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.creaated
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.createdBy
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.contentTYPE
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.lookup1
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.text
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.created
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.createdBy
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.contentTYPE
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.numberfield
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.bool
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.text
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.creaated
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.createdBy
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.contentTYPE
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.lookup1
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE
++++++++++++++++++++++++text
++++++++++++++++++++++++created
++++++++++++++++++++++++createdBy
++++++++++++++++++++++++contentTYPE
++++++++++++++++++++++++numberfield
++++++++++++++++++++++++bool
++++++++++++++++++++++++text
++++++++++++++++++++++++creaated
++++++++++++++++++++++++createdBy
++++++++++++++++++++++++contentTYPE
++++++++++++++++++++++++lookup1
++++++++++++++++++++++++title
++++++++++++++++++++++++creaated
++++++++++++++++++++++++createdBy
++++++++++++++++++++++++contentTYPE
++++++++++++++++++++++++lookuppp
++++++++++++++++++++++++title
++++++++++++++++++++++++created
++++++++++++++++++++++++createdBy
++++++++++++++++++++++++contentTYPE
++++++++++++++++++++++++title
++++++++++++++++++++++++created
++++++++++++++++++++++++createdBy
++++++++++++++++++++++++contentTYPE
Hence if I used this code in the DefaultDeclarativeQualifiedNameProvider
public class QNP extends DefaultDeclarativeQualifiedNameProvider{
@Inject
IQualifiedNameConverter qnc;
QualifiedName qualifiedName(Field f) {
return qnc.toQualifiedName(f.getName());
}
}
my below code works :
class MyDsl2ProposalProvider extends AbstractMyDsl2ProposalProvider {
override completeViewField_Field(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
val view = EcoreUtil2::getContainerOfType(model, typeof(View))
val names = view.ownedViewField.map[vw|vw.field?.name].filter[v|v!=null].toList
println (names)
lookupCrossReference(assignment.terminal as CrossReference, context, acceptor, [
IEObjectDescription d | println(d.qualifiedName);!names.contains(d.qualifiedName)
])
}
|
|
|
|
|
|
|
|
|
|
|
Re: CTRL+SPACE action [message #1063704 is a reply to message #1063702] |
Thu, 13 June 2013 15:37   |
Eclipse User |
|
|
|
Hi Christian
I solved http://www.eclipse.org/forums/index.php/t/488676/-> this topic's problem.Hence My grammar hierarch and scop same in this project (zip)http://www.eclipse.org/forums/index.php/t/488676/->
My onlly problem qualifiedname and below post(this thread).
My aim is :I dont get duplicate name and same type field in the View's ViewField.(fields).and I want to gets field with qualifiedname.
Hence,I do not use my util class,I share it above.I hope I explain my problem 
if I use qualifiedname ,My result is below screenshot.I can't use x.y.z now
junior developer wrote on Thu, 13 June 2013 15:09Hi Christian,
I try it but gets all field :(
val view = EcoreUtil2::getContainerOfType(model, typeof(View))
val names = view.ownedViewField.map[vw|vw.field?.fullyQualifiedName?.toString].filter[v|v!=null].toList
println ("viewfielddddddddddddddd"+names)
lookupCrossReference(assignment.terminal as CrossReference, context, acceptor, [
IEObjectDescription d | println(d.qualifiedName);!names.contains(d.qualifiedName.toString)
])
}
println ("viewfielddddddddddddddd"+names) result : gets all field ,I do not solved my problem still
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE
Attachment: 11111.png
(Size: 42.10KB, Downloaded 310 times)
[Updated on: Thu, 13 June 2013 15:41] by Moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: CTRL+SPACE action [message #1063810 is a reply to message #1063785] |
Fri, 14 June 2013 07:02   |
Eclipse User |
|
|
|
Hi,
I want to use my qualifiedname .I want to qualifiedname starts from the Method.
public class MQNP extends DefaultDeclarativeQualifiedNameProvider{
public static QualifiedName returnQualifiedNameOfElement(EObject object) {
String qualifiedName = "";
ArrayList<String> names = new ArrayList<String>();
while (object.eContainer() != null && !(object.eContainer() instanceof Collection)) {
if (object.eContainer() instanceof ContentextUnit)
names.add(((ContentextUnit) object.eContainer()).getName());
object = object.eContainer();
}
for (int i = names.size() - 1; i >= 0; i--) {
qualifiedName += names.get(i) + ".";
}
return QualifiedName.create(qualifiedName);
}
}
and I inject it in the scope class:
public class MyScoping extends AbstractDeclarativeScopeProvider {
//@Inject IQualifiedNameProvider qnp;
@Inject MQNP myqualified;
IScope scope_Type_parentType(final Type ctx, EReference r) {
final ArrayList<Type> possiblecontenttype = org.xtext.example.mydsl6.myDsl6.util.ContentTypeUtil.getPossibleParentContentType(ctx);
//final ArrayList<Field> possiblefieldview = ViewUtil.possibleFieldForViewField(ctx) ;
//final ArrayList<Field> possiblefield = LookUpUtil.returnSourceContentTypeNotLookUpFields(ctx);
return Scopes.scopeFor( possiblecontenttype, myqualified, IScope.NULLSCOPE);
}
my util class I shared before it :
public class ContentTypeUtil {
public static boolean isContentTypeParentOk(Type contentSource, Type contentTarget){
if(contentSource.equals(contentTarget)){
return false;
}
return true;
}
public static ArrayList<Type> getPossibleParentContentType(Type content){
Method web = ((Method)((Function)content.eContainer()).eContainer());
while(web.eContainer().eClass().getName().equals("Web")){
web = (Method) web.eContainer();
}
ArrayList<Type> allContentTypes = new ArrayList<>();
allContentTypes = returnAllContentTypeFromGivenWeb(web, allContentTypes);
allContentTypes.remove(content);
return allContentTypes;
}
public static ArrayList<Type> returnAllContentTypeFromGivenWeb(Method rootWeb, ArrayList<Type> returnAllContentTypesFromWeb){
EList<Function> ownedLists = rootWeb.getList();
for (Iterator<Function> iterator = ownedLists.iterator(); iterator.hasNext() {
Function customList = (Function) iterator.next();
EList<Type> ownedContentTypes = customList.getType();
for (Iterator<Type> iterator2 = ownedContentTypes.iterator(); iterator2
.hasNext() {
Type contentType = (Type) iterator2.next();
returnAllContentTypesFromWeb.add(contentType);
}
}
EList<Method> ownedWebs = rootWeb.getOwnmethod();
for (Iterator<Method> iterator = ownedWebs.iterator(); iterator.hasNext() {
Method web = (Method) iterator.next();
returnAllContentTypeFromGivenWeb(web, returnAllContentTypesFromWeb);
}
return returnAllContentTypesFromWeb;
}
}
[Updated on: Fri, 14 June 2013 07:03] by Moderator
|
|
|
|
|
|
|
|
|
|
|
|
Re: CTRL+SPACE action [message #1063934 is a reply to message #1063924] |
Sun, 16 June 2013 05:07   |
Eclipse User |
|
|
|
You need to traverse up the eContainer() of the Function F to get to the
Method M1, and the eContainer() of that Method to get to Method M.
You'll need to cast the returned value from eContainer() to the correct
type. From that information you can compose a qualified name.
On 16/06/2013 12:02 AM, junior developer wrote:
>
> Hi Christian,
>
> I start my qualifiedname with Method .but My Method rule is
> recursive.hence if I define one Method ,below code (return
> qnc.toQualifiedName(f.getName())) return second Method name.How can I
> solved this.
> I want to fields =M. M1.F.T1.created for every referenced name.
> such as :
>
>
>
> method M {
> method M1{
> function F {
> type T {
> fields {
> Text text {
>
> displayName = "displayName" property =
> "Property"
> }
> Text created {
> displayName = "displayName" property =
> "Property"
> }
> Text createdby {
> displayName = "displayName" property =
> "Property"
> }
> LookUp Look {
> type = T showField = created
> }
>
> } }type T1 {
>
> fields {
> Text created {
> displayName = "displayName" property =
> "Property"
> }
> Text createdby {
> displayName = "displayName" property =
> "Property"
> }
> Text created {
> displayName=" ewfg" property= "Property"
> }
> }
> }View V {
> type = "Type" fields = M1.F.T1.created
> }
> }
>
>
>
>
> Best Regards,
> Christian Dietrich wrote on Fri, 14 June 2013 07:55
>> Sorry i cannot reproduce that
>>
>> public class MyQNP extends DefaultDeclarativeQualifiedNameProvider {
>>
>> @Inject IQualifiedNameConverter qnc;
>>
>> QualifiedName qualifiedName(Function f) {
>> return qnc.toQualifiedName(f.getName());
>> }
>> }
>>
>> class MyDsl6ScopeProvider extends AbstractDeclarativeScopeProvider {
>>
>> @Inject IQualifiedNameProvider qnp
>>
>> def IScope scope_ViewField_field(Function v, EReference ref) {
>> Scopes::scopeFor(v.type.map[fields].flatten, qnp,
>> IScope::NULLSCOPE)
>> }
>>
>> def List<Field> getFields(Type t) {
>> val res = <Field>newArrayList()
>> res.addAll(t.ownedField)
>> if (t.parentType != null) {
>> res.addAll(getFields(t.parentType))
>> }
>> res
>> }
>>
>> }
>
|
|
|
|
|
|
|
|
|
Re: CTRL+SPACE action [message #1064040 is a reply to message #1063956] |
Mon, 17 June 2013 07:42  |
Eclipse User |
|
|
|
Hi,
I will create a new topic.I know far too long.I solved my problem and then I have another problem so I ask my question previously topic.Thank you
Best regards
|
|
|