Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Custom Property dialog
Custom Property dialog [message #1220432] Wed, 11 December 2013 17:30 Go to next message
Phil H is currently offline Phil H
Messages: 267
Registered: November 2012
Senior Member
Hi,

I've created a custom property dialog for one of my properties. Within this dialog, I'm able to add elements, as you can see here:

index.php/fa/16997/0/

I've realised this through an AddCommand:

EditingDomain editingDomain = org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain.getEditingDomainFor(fm);
Command cmdRequiredConstraint = AddCommand.create(editingDomain, fm, PldPackage.Literals.FEATURE_MODEL__INTERNAL_CONSTRAINTS,constraint);									editingDomain.getCommandStack().execute(cmdRequiredConstraint);


This works fine so far, but when I'm saving my file, close it and open it again, the properties are removed:

index.php/fa/16998/0/

What can be the problem?

nother thing which doesn't work is deleting elements. I tried, accordingly to the AddCommand, remove eleemnts via the RemoveCommand, which doesn't work:

EditingDomain editingDomain = org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain.getEditingDomainFor(fm);

Command cmdDeleteConstraint = RemoveCommand.create(editingDomain, constraint);
editingDomain.getCommandStack().execute(cmdDeleteConstraint);


I also tried the DeleteCommand, which has the same effect. Why is adding elements working and deleting not?

Cheers,
Phil
Re: Custom Property dialog [message #1220438 is a reply to message #1220432] Wed, 11 December 2013 17:49 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26152
Registered: July 2009
Senior Member
Phil,

Are
On 11/12/2013 6:30 PM, Phil H wrote:
> Hi,
>
> I've created a custom property dialog for one of my properties. Within this dialog, I'm able to add elements, as you can see here:
>
>
>
> I've realised this through an AddCommand:
>
> EditingDomain editingDomain = org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain.getEditingDomainFor(fm);
> Command cmdRequiredConstraint = AddCommand.create(editingDomain, fm, PldPackage.Literals.FEATURE_MODEL__INTERNAL_CONSTRAINTS,constraint); editingDomain.getCommandStack().execute(cmdRequiredConstraint);
>
> This works fine so far, but when I'm saving my file, close it and open it again, the properties are removed:
>
>
>
> What can be the problem?
Is this a containment reference or a non-containment reference?
>
> nother thing which doesn't work is deleting elements. I tried, accordingly to the AddCommand, remove eleemnts via the RemoveCommand, which doesn't work:
>
>
> EditingDomain editingDomain = org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain.getEditingDomainFor(fm);
>
> Command cmdDeleteConstraint = RemoveCommand.create(editingDomain, constraint);
> editingDomain.getCommandStack().execute(cmdDeleteConstraint);
>
>
> I also tried the DeleteCommand, which has the same effect. Why is adding elements working and deleting not?
>
> Cheers,
> Phil
Re: Custom Property dialog [message #1220442 is a reply to message #1220438] Wed, 11 December 2013 18:44 Go to previous messageGo to next message
Phil H is currently offline Phil H
Messages: 267
Registered: November 2012
Senior Member
I think this is a containment reference?:

class FeatureM{
  .....
  ref VariantConstraint[*] internalConstraints;
}
Re: Custom Property dialog [message #1220444 is a reply to message #1220442] Wed, 11 December 2013 19:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26152
Registered: July 2009
Senior Member
Perhaps you can make sure. It sounds to me more like it's
non-containment and that you're creating dangling references that can't
be saved.


On 11/12/2013 7:44 PM, Phil H wrote:
> I think this is a containment reference?:
>
>
> class FeatureM{
> .....
> ref VariantConstraint[*] internalConstraints;
> }
>
Re: Custom Property dialog [message #1220445 is a reply to message #1220444] Wed, 11 December 2013 19:15 Go to previous messageGo to next message
Phil H is currently offline Phil H
Messages: 267
Registered: November 2012
Senior Member
Hmm, It's odd for me then that this references are shown in the property descriptor. Shouldn't this be a sign, that this references are correct?


Is this meant by a non-containment reference?:

class FeatureM{
  .....
  ref VariantConstraint[*] internalConstraints;
}

class VariantConstraint{ 
  ...
  ref FeatureM featureM; 
}

[Updated on: Wed, 11 December 2013 19:17]

Report message to a moderator

Re: Custom Property dialog [message #1220476 is a reply to message #1220445] Thu, 12 December 2013 04:25 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26152
Registered: July 2009
Senior Member
Phil,

Yes, if it downs up as having a property descriptor by default, it's a
cross reference.

On 11/12/2013 8:15 PM, Phil H wrote:
> Hmm, It's odd for me then that this references are shown in the
> property descriptor. Shouldn't this be a sign, that this references
> are correct?
>
>
Re: Custom Property dialog [message #1220989 is a reply to message #1220476] Mon, 16 December 2013 14:26 Go to previous messageGo to next message
Phil H is currently offline Phil H
Messages: 267
Registered: November 2012
Senior Member
Hmm, so when I remove

ref FeatureM featureM;


from VariantConstraint it should work, because it's no non-containment reference anymore?
I tried this, but it still doesn't work. Maybe I haven't understand the context really..
Re: Custom Property dialog [message #1220997 is a reply to message #1220989] Mon, 16 December 2013 15:05 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26152
Registered: July 2009
Senior Member
Phil,

Comments below.

On 16/12/2013 3:26 PM, Phil H wrote:
> Hmm, so when I remove
> ref FeatureM featureM;
>
> from VariantConstraint it should work, because it's no non-containment
> reference anymore?
I can't say what the syntax you're using implies in terms of an Ecore model.
> I tried this, but it still doesn't work.
If you add to a containment reference it can't possibly end up being a
dangling reference so something must work differently.
> Maybe I haven't understand the context really..
That may be, but you've also not told me enough about the context for me
to tell you more.
Re: Custom Property dialog [message #1222758 is a reply to message #1220997] Sat, 21 December 2013 09:25 Go to previous messageGo to next message
Phil H is currently offline Phil H
Messages: 267
Registered: November 2012
Senior Member
Ok I'll try to give you a clearer view about my context. As already mentioned in the first post, I've customized the normal property dialog for one of my elements. To call my custom dialog, I've provided my own implementation of PropertySource:

public class ProductLinePropertySource extends PropertySource {

	public ProductLinePropertySource(Object object,
			IItemPropertySource itemPropertySource) {
		super(object, itemPropertySource);
	}

	@Override
	protected IPropertyDescriptor createPropertyDescriptor(
			IItemPropertyDescriptor itemPropertyDescriptor) {
		PldPackage pkg = PldPackage.eINSTANCE;
		Object obj = itemPropertyDescriptor.getFeature(object);
		if (pkg.getFeatureModel_InternalConstraints().equals(obj)) {
			return new ConstraintPropertyDescriptor(object, itemPropertyDescriptor);
		} else {
			// Else, default EMF behavior
			return super.createPropertyDescriptor(itemPropertyDescriptor);
		}
	}


Inside my PropertyDescriptor, I'm calling my custom dialog:

public class ConstraintPropertyDescriptor extends PropertyDescriptor {

	public ConstraintPropertyDescriptor(Object object,
			IItemPropertyDescriptor itemPropertyDescriptor) {
		super(object, itemPropertyDescriptor);
	}

	@Override
	public CellEditor createPropertyEditor(Composite parent) {
		return new ExtendedDialogCellEditor(parent, getLabelProvider()) {
			@Override
			protected Object openDialogBox(Control cellEditorWindow) {
				Shell shell = Display.getCurrent().getActiveShell();
				if (object instanceof FeatureModel) {
					FeatureModel fm = (FeatureModel) object;
					ConstraintDialog dialog = new ConstraintDialog(fm, shell);
					dialog.open();
				}
				return null;
			}
		};
	}
}


Whereas my custom dialog allows to add properties to the element, as realizes in the add and delete buttons.
As shown in the the first post, the add command seems to work, while the delete command has no affect.

protected Control createDialogArea(final Composite parent) {
		final Composite container = (Composite) super.createDialogArea(parent);
		........
		btnAddConstraint.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent event) {
				VariantConstraint constraint = PldFactory.eINSTANCE.createVariantConstraint();
				constraint.setConstraintType(ConstraintType.EXCLUDE);
				EditingDomain editingDomain = org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain.getEditingDomainFor(fm);

				Command cmdRequiredConstraint = AddCommand.create(editingDomain, fm, PldPackage.Literals.FEATURE_MODEL__INTERNAL_CONSTRAINTS, constraint);
				editingDomain.getCommandStack().execute(cmdRequiredConstraint);			
			}
		});

		.......
		btnDeleteConstraint.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent event) {
				StructuredSelection constraintSelection = (StructuredSelection) lvConstraints.getSelection();
				VariantConstraint constraint = (VariantConstraint) constraintSelection.getFirstElement();
				EditingDomain editingDomain = org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain.getEditingDomainFor(fm);

				Command cmdDeleteConstraint = RemoveCommand.create(editingDomain, constraint);
				editingDomain.getCommandStack().execute(cmdDeleteConstraint);
			}
		});
	return container;
}
Re: Custom Property dialog [message #1228564 is a reply to message #1222758] Tue, 07 January 2014 14:02 Go to previous message
Phil H is currently offline Phil H
Messages: 267
Registered: November 2012
Senior Member
Any further comments on this? Unfortunately I haven't solved this yet.
Previous Topic:Prevent generation of DocumentRoot Java class
Next Topic:[CDO] loading resources and package registration.
Goto Forum:
  


Current Time: Fri Oct 31 08:37:11 GMT 2014

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

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