How to get Properties from an EObject, similiar to the Properties View - eclipse

i have an EObject and want to get all the Properties from it. I tryed to get all Structural Features:
myEObject.eClass().getEAllStructuralFeatures()
but i get too many Properties i do not want like the object ID.
With
myEObject.eClass().getEStructuralFeatures()
there are missing some that are displayed in the Properties View.
So how can i get the same List of Properties from an EObject like the Properties View does?
Thx for your help

Just use the first option and filter out the ones you don't want (like object id) from being displayed. It's probably the easiest way.
If it must absolutely be the same as the list that is displayed in the properties view, the safest bet is to find the code used to populate the properties view and reuse it.

Related

How to add fe_group in Controller

I want to set the "standard" TYPO3 field "fe_group" in the extbase controller. As far I see there no "standard" getters and setters? https://typo3.org/api/typo3cms/class_t_y_p_o3_1_1_c_m_s_1_1_extbase_1_1_domain_object_1_1_abstract_entity.html
I tried to implement them in the model, but it does not work - I do not get any error but it is never set.
What exactly I want to do:
I have an object of type \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup and I have an object of my record type (I can set other fields without any problems).
Now I want to do something like:
$myobject->addFe_group($feusergroup);
Do I have to implement this by my own to my model? I tried to implement fe_group as ObjectStorage and also as string - does not work? :-(
Does anyone have a solution for this?
Thank you
Christian
First of all: In models please name functions and properties lowerCamelCase. So a field "fe_group" in TCA would become "feGroup" in the model and the function would be "addFeGroup".
FrontendUserGroup model has a function addSubgroup to add other groups as subobjects. Is this the right thing for your purpose or what you need those relation to another group for?
https://typo3.org/api/typo3cms/class_t_y_p_o3_1_1_c_m_s_1_1_extbase_1_1_domain_1_1_model_1_1_frontend_user_group.html

How to use properties from a child in EMF

I have a sample EMF hierarchy like this -
Parent : Shape
Child 1 : Circle
Child 2 : Square
Child 3 : Rect
Now I want to generate my properties view in Eclipse in such a way that . I have a drop down with ShapeType and based on the shape type I want to show the properties of the child element.
Essentially I want to display/edit the child properties based on the 'type' selection in the parent.
Any thoughts how I can achieve this?
You cannot solve this issue easily, as in that case the dropdown needs to change the EMF type of an object, that results in Java class changes. To have such thing working, you have to create a new EObject instance, copy all relevant attributes, and remove the old object (and possibly update the selection).
So, alltogether, I believe, what you want is not possible with basic EMF tooling, however, if you provide a custom model manipulation commands, it should be possible.
Other things, you can try (if possible in your domain):
Move all your data to properties of the parent object, add EValidators to prevent inconsistent states from appearing, and update the default EMF Edit commands to filter out unnecessary editors. Ugly, but may work.
Create custom forms/editors, that manage the object removal/addition during the manually coded editing process.

Select ObjectSet by entity type

I need a way to select objects given the name:string of the object and ObjectContext, but dont know how to do this.
I will use this to create a generic lookup dropdown editor template in ASP.MVC
So when view contains #Html.EditorFor (student=>student.School), it will show dropDown containing list of schools.
I get the target entity name from relation.ToMember, but don't know how to query data records with this input.
Currently I have added a custom method which gets string and returns innumerable and inside that I have a big switch case "School": return this.SchooleSet;
Is there a right way to do this.
I also want to add a generic method which allows me to query using syntax like ctx.Select<Teacher>().Where(...)
again here I have implemented with switch but there should be a better way to do this.
Try the CreateObjectSet method.
var q = ctx.CreateObjectSet<Teacher>().Where(...);

Pass "DirectoryInfo" object into Controller from a View?

I'm new to MVC2 and was wondering if it was possible to pass an object into a Controller Action from a View?
e.g.
I've created a ViewModel containing a list of DirectoryInfo objects and pass this to my Index view.
In the view, I loop through all of the DI objects and for each one create an ActionLink.
<%:Html.ActionLink(linkText: subfolder.Name,actionName: "Reports",
routeValues: new {folder=subfolder}, htmlAttributes:null )%>
but in my Reports action, the "folder" is always null?
public ActionResult Reports(DirectoryInfo folder)
{
//folder is always null here
Is this type of thing possible, or does the routingValue always have to be a primitive?
(ps. I have searched StackOverflow and t'internet and although I can find people asking the same question, I can't find a solution
DirectoryInfo is a complex object and I don't think you will be able to put it directly into HTML. You need to send something simple like path of directory or file from which controller can construct the required DirectoryInfo again.

Dynamically determine the name of the action I'm in from my controller base class in MVC2?

I need to dynamically determine the name of the action I'm in from my controller base class in MVC2 in my OnExecuting handler.
So if the Controller is Foo and the Action is Bar, I want the string "/Foo/Bar".
This seems like it should be pretty simple, but I haven't found anything when I STFW.
I'm hoping either one of you is better at the googles than me, or just knows this off of the top of your head.
Thanks.
Your filter has access to a filterContext parameter. Take a look at its ActionDescriptor property. You can get the name of the action method, metadata about its parameters, etc. If you want just the raw URL, try filterContext.HttpContext.Request.RawUrl (or some similar property).