Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » how to change the property by only name?
how to change the property by only name? [message #889927] Wed, 20 June 2012 05:30 Go to next message
Iqbal Hossain is currently offline Iqbal Hossain
Messages: 101
Registered: May 2011
Location: Bangladesh
Senior Member
index.php/fa/10357/0/

as in the picture u can see two nodes have a connection between them.
node1 is aaa and node2 is ccc.
now if i select the transition line u can see the properties like bandwidth, name, source,target.

in source u can see is written real Node zzz. here aaa is node name and real Node in type of the node. same for target.
I want that source only shows the name aaa not the type.
so source should be aaa and target should be ccc only.
  • Attachment: 2.jpg
    (Size: 63.81KB, Downloaded 188 times)
Re: how to change the property by only name? [message #891585 is a reply to message #889927] Mon, 25 June 2012 05:52 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph Gerbig
Messages: 697
Registered: November 2009
Senior Member
Hi,

take a look at the code that is generated by emf. The xxx.edit plugin contains the providers which are responsible for displaying the text. There you can easily change what is displayed.

Ralph
Re: how to change the property by only name? [message #891590 is a reply to message #891585] Mon, 25 June 2012 06:05 Go to previous messageGo to next message
Iqbal Hossain is currently offline Iqbal Hossain
Messages: 101
Registered: May 2011
Location: Bangladesh
Senior Member
i try to change but having some error....I am not so good in coding Very Happy

i just want to omit the node type...as u can see in previous post...real Node is type and "aaa" is name...i just need to show aaa.

take a look at the code, if possible help me...


/**
* <copyright>
* </copyright>
*
* $Id$
*/
package NetworkDiagram.provider;


import NetworkDiagram.Link;
import NetworkDiagram.NetworkDiagramPackage;

import java.util.Collection;
import java.util.List;

import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.ResourceLocator;

import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
import org.eclipse.emf.edit.provider.ViewerNotification;

/**
* This is the item provider adapter for a {@link NetworkDiagram.Link} object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public class LinkItemProvider
extends ItemProviderAdapter
implements
IEditingDomainItemProvider,
IStructuredItemContentProvider,
ITreeItemContentProvider,
IItemLabelProvider,
IItemPropertySource {
/**
* This constructs an instance from a factory and a notifier.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public LinkItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}

/**
* This returns the property descriptors for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);

addNamePropertyDescriptor(object);
addBandWidthPropertyDescriptor(object);
addPropagationDelayPropertyDescriptor(object);
addSourcePropertyDescriptor(object);
addTargetPropertyDescriptor(object);
}
return itemPropertyDescriptors;
}

/**
* This adds a property descriptor for the Name feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addNamePropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Link_name_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Link_name_feature", "_UI_Link_type"),
NetworkDiagramPackage.Literals.LINK__NAME,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}

/**
* This adds a property descriptor for the Band Width feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addBandWidthPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Link_BandWidth_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Link_BandWidth_feature", "_UI_Link_type"),
NetworkDiagramPackage.Literals.LINK__BAND_WIDTH,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}

/**
* This adds a property descriptor for the Propagation Delay feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addPropagationDelayPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Link_PropagationDelay_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Link_PropagationDelay_feature", "_UI_Link_type"),
NetworkDiagramPackage.Literals.LINK__PROPAGATION_DELAY,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}

/**
* This adds a property descriptor for the Source feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSourcePropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Link_source_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Link_source_feature", "_UI_Link_type"),
NetworkDiagramPackage.Literals.LINK__SOURCE,
true,
false,
true,
null,
null,
null));
}


/**
* This adds a property descriptor for the Target feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addTargetPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Link_target_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Link_target_feature", "_UI_Link_type"),
NetworkDiagramPackage.Literals.LINK__TARGET,
true,
false,
true,
null,
null,
null));
}


/**
* This returns Link.gif.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object getImage(Object object) {
return overlayImage(object, getResourceLocator().getImage("full/obj16/Link"));
}

/**
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String getText(Object object) {
String label = ((Link)object).getName();
return label == null || label.length() == 0 ?
getString("_UI_Link_type") :
getString("_UI_Link_type") + " " + label;
}

/**
* This handles model notifications by calling {@link #updateChildren} to update any cached
* children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void notifyChanged(Notification notification) {
updateChildren(notification);

switch (notification.getFeatureID(Link.class)) {
case NetworkDiagramPackage.LINK__NAME:
case NetworkDiagramPackage.LINK__BAND_WIDTH:
case NetworkDiagramPackage.LINK__PROPAGATION_DELAY:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
}
super.notifyChanged(notification);
}

/**
* This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
* that can be created under this object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
}

/**
* Return the resource locator for this item provider's resources.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public ResourceLocator getResourceLocator() {
return NetworkDiagramEditPlugin.INSTANCE;
}

}
Re: how to change the property by only name? [message #893048 is a reply to message #891590] Mon, 02 July 2012 08:26 Go to previous message
Ralph Gerbig is currently offline Ralph Gerbig
Messages: 697
Registered: November 2009
Senior Member
Hi,

set a break point to this method:

/**
 * This returns the label text for the adapted class.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
 @Override
 public String getText(Object object) {
 String label = ((Link)object).getName();
 return label == null || label.length() == 0 ?
 getString("_UI_Link_type") :
 getString("_UI_Link_type") + " " + label;
 }


This should help you solving the problem.

Ralph
Previous Topic:Change the order of parameters that are displayed on property window in GMF
Next Topic:Drag and drop in list compartment
Goto Forum:
  


Current Time: Mon Jul 28 18:46:50 EDT 2014

Powered by FUDForum. Page generated in 0.08387 seconds