Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Visible or Invisible Properties When model changed(How can i make Visible or Invisible Properties When model changed?)
Visible or Invisible Properties When model changed [message #1112833] Fri, 20 September 2013 08:32 Go to next message
serhat gezgin is currently offline serhat gezginFriend
Messages: 243
Registered: January 2013
Location: Izmir
Senior Member
Hi all,

my model;

Table
  columns : Column (0..*)
  type : SQLType

Column
  autoIncrement : Boolean

Enum SQLType
  int
  varChar
  numeric
  ..


i want to constraint property view when i change Table type to numeric or int i want to show autoIncrement boolean part on properties view to user.

But when i chande type to varChar, .. i don't want to show this property to user.

I can make constraint to user for can't edit this property;

@Override
public boolean canSetProperty(Object object) {
     Column element = (Column) object;
     return ColumnUtil.isAutoIncrementSettable(element); //bool			}


but i want when item type nvarchar, .. i dont show this property to user.

so how can i implement this behaviour to my edit project.

Regards.
Re: Visible or Invisible Properties When model changed [message #1113456 is a reply to message #1112833] Sat, 21 September 2013 05:48 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Serhat,

You can specialize the generated getPropertyDescriptors(Object) of the
item provider to either include the property descriptor or not; note the
default generated code will compute the property descriptors just once
the first time that method is called, so you'd need to ensure that you
recompute it each time the method is called.

On 20/09/2013 10:32 AM, serhat gezgin wrote:
> Hi all,
>
> my model;
>
>
> Table
> columns : Column (0..*)
> type : SQLType
>
> Column
> autoIncrement : Boolean
>
> Enum SQLType
> int
> varChar
> numeric
> ..
>
>
> i want to constraint property view when i change Table type to numeric
> or int i want to show autoIncrement boolean part on properties view to
> user.
>
> But when i chande type to varChar, .. i don't want to show this
> property to user.
>
> I can make constraint to user for can't edit this property;
>
>
> @Override
> public boolean canSetProperty(Object object) {
> Column element = (Column) object;
> return ColumnUtil.isAutoIncrementSettable(element);
> //bool }
>
>
> but i want when item type nvarchar, .. i dont show this property to user.
>
> so how can i implement this behaviour to my edit project.
>
> Regards.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Visible or Invisible Properties When model changed [message #1114453 is a reply to message #1113456] Sun, 22 September 2013 19:24 Go to previous message
serhat gezgin is currently offline serhat gezginFriend
Messages: 243
Registered: January 2013
Location: Izmir
Senior Member
Thanks a lot i solve this like;

@Override
	public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
		itemPropertyDescriptors = null;
		super.getPropertyDescriptors(object);

		addTypePropertyDescriptor(object);
		addNullablePropertyDescriptor(object);
		addDefaultValuePropertyDescriptor(object);
		addPrimaryKeyPropertyDescriptor(object);
		if (ColumnUtil.isAutoIncrementSettable(((Column) object)))
			addAutoIncrementPropertyDescriptor(object);

		return itemPropertyDescriptors;
	}


and when model changed;

	public void notifyChanged(Notification notification) {
		updateChildren(notification);

		switch (notification.getFeatureID(Column.class)) {
		case ContentPackage.COLUMN__TYPE:
			getPropertyDescriptors(notification.getNotifier());
		case ContentPackage.COLUMN__NULLABLE:
		case ContentPackage.COLUMN__DEFAULT_VALUE:
		case ContentPackage.COLUMN__PRIMARY_KEY:
		case ContentPackage.COLUMN__AUTO_INCREMENT:
			fireNotifyChanged(new ViewerNotification(notification,
					notification.getNotifier(), false, true));
			return;
		}
		super.notifyChanged(notification);
	}


Regards

[Updated on: Sun, 22 September 2013 19:40]

Report message to a moderator

Previous Topic:[Texo] Working with Text entities
Next Topic:Best way to listen to eclipse Notification
Goto Forum:
  


Current Time: Fri Apr 19 15:15:34 GMT 2024

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

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

Back to the top