Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to get nationalized feature name(How to get nationalized feature name)
How to get nationalized feature name [message #903362] Thu, 23 August 2012 10:49 Go to next message
Markus Jo is currently offline Markus JoFriend
Messages: 83
Registered: January 2012
Member
Hi,
I think its an easy question if its possible....can anybody tell me how to get the internationalized name for a feature ?

I am in a command and want to create I nice label. I have the feature and its owner...something like this:


private String getLabelInternal(){
		String valueString;
		if(value instanceof EObject){
			valueString = EpaUtilModel.getDescription(((EObject) value));
		} else {
			valueString = value.toString();
		}
		Object eGet = owner.eGet(feature);

		String featureString = feature.getName();
		
		EList<Adapter> eAdapters = owner.eAdapters();
		for (Adapter adapter : eAdapters) {
			if(adapter instanceof ItemProviderAdapter){
				ItemProviderAdapter itemProviderAdapter = (ItemProviderAdapter) adapter;
				itemProviderAdapter.getString(feature.toString());
			}
		}
		
		return "-> Changed " + feature.getName() + " of " + EpaUtilModel.getDescription(owner) + " to '" + valueString + "'";
	}




Thanks
Re: How to get nationalized feature name [message #903364 is a reply to message #903362] Thu, 23 August 2012 11:10 Go to previous messageGo to next message
Markus Jo is currently offline Markus JoFriend
Messages: 83
Registered: January 2012
Member
To make it easier to read.....this is the relevant snippet.....but it does not work.....the parameter for "getString" is wrong... it shoild be something like "_UI_TimeTable_period_feature" but I dont know how to get this when I have only the feature and its owner.


String featureString = feature.getName();
		
		EList<Adapter> eAdapters = owner.eAdapters();
		for (Adapter adapter : eAdapters) {
			if(adapter instanceof ItemProviderAdapter){
				ItemProviderAdapter itemProviderAdapter = (ItemProviderAdapter) adapter;
				itemProviderAdapter.getString(feature.toString());
			}
		}
Re: How to get nationalized feature name [message #903373 is a reply to message #903364] Thu, 23 August 2012 11:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26285
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Markus,<br>
<br>
This is how ItemProviderAdapter does it:<br>
<blockquote><small>  protected String getFeatureText(Object feature)</small><br>
<small>  {</small><br>
<small>    String featureKey;</small><br>
<small>    if (feature instanceof EStructuralFeature)</small><br>
<small>    {</small><br>
<small>      EStructuralFeature eFeature =
(EStructuralFeature)feature;</small><br>
<small>      featureKey = eFeature.getEContainingClass().getName()
+ "_" + eFeature.getName();</small><br>
<small>    }</small><br>
<small>    else</small><br>
<small>    {</small><br>
<small>      featureKey = "Unknown";</small><br>
<small>    }</small><br>
<small>    return getResourceLocator().getString("_UI_" +
featureKey + "_feature");</small><br>
<small>  }</small><br>
</blockquote>
<br>
<br>
<div class="moz-cite-prefix">On 23/08/2012 1:10 PM, Markus Jo wrote:<br>
</div>
<blockquote cite="mid:k1533j$jo0$1@xxxxxxxxe.org" type="cite">To
make it easier to read.....this is the relevant snippet.....but it
does not work.....the parameter for "getString" is wrong... it
shoild be something like "_UI_TimeTable_period_feature" but I dont
know how to get this when I have only the feature and its owner.
<br>
<br>
<br>
<br>
String featureString = feature.getName();
<br>
        <br>
        EList&lt;Adapter&gt; eAdapters = owner.eAdapters();
<br>
        for (Adapter adapter : eAdapters) {
<br>
            if(adapter instanceof ItemProviderAdapter){
<br>
                ItemProviderAdapter itemProviderAdapter =
(ItemProviderAdapter) adapter;
<br>
                itemProviderAdapter.getString(feature.toString());
<br>
            }
<br>
        }
<br>
<br>
</blockquote>
<br>
</body>
</html>
Re: How to get nationalized feature name [message #903575 is a reply to message #903373] Fri, 24 August 2012 11:53 Go to previous message
Markus Jo is currently offline Markus JoFriend
Messages: 83
Registered: January 2012
Member
Super, danke
Previous Topic:Tabbed Properties
Next Topic:EAnnotation references between ecore models
Goto Forum:
  


Current Time: Sat Dec 20 21:41:55 GMT 2014

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

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