[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: problem customizing edit plugin, PropertyDescriptor

Okay, could this be a GMF problem?
I observe that the property is set twice: First the correct value is set, and then it is immediately set to another value. This happens when I use the properties view of the GMF editor. When I use the tree editor's properties view, everything is fine!
I attached the two stacks of the first and the second (erroneous) call of the objects set method. Here is where the second differs from the first


...
PropertySheetViewer.applyEditorValue() line: 258	
PropertySheetViewer.setInput(Object) line: 963	
PropertySheetPage.refresh() line: 471	
TggPropertySection(AdvancedPropertySection).refresh() line: 188	
AdvancedPropertySection$1.run() line: 215	
RunnableLock.run() line: 35	
UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 133	
Display.runAsyncMessages(boolean) line: 3800	
Display.readAndDispatch() line: 3425	
...

I don't understand why GMF would be interfering here. Any why the second call of the set method only occurs when I type/filter the given choices (e.g. "EPack..." to find the class EPackage more quickly). Maybe anyone of you has an idea? Otherwise, I'll dig deeper myself when I find the time.

Thanks

Joel


Ed Merks wrote:
Joel,

As Jim suggests, we do this type of filtering all over the place (do something to returned a reduced set of choices) and have never seen this type of problem. The filtering as you type is completely orthoganal to the set of choices originally returned, so certainly the problem can't be in your properly descriptor, I don't think. All I can do is suggest you set a breakpoint where the value is being set, and then look down the stack to see where something has gone wrong in the process. That's would I'd need to do, if I could reproduce the problem, which I can't...


Joel Greenyer wrote:
Hi Jim,
here's my changed addPropertyDescriptor method from the NodeItemProvider class.
Nodes may be inside a graph pattern. One of these graph pattern may be a domain graph pattern. A domain graph pattern is associated with a typed model, which references a list of packages. I want an EClass of each of those packages to be in the list of choices. In case that something along this way is null (because the model is not consistent), I catch the NullPointerException and return an empty list.


What do you do different?
Thanks for helping

Joel


/** * This adds a property descriptor for the EType feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ protected void addETypePropertyDescriptor(Object object) { itemPropertyDescriptors.add (

new ItemPropertyDescriptor(
((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_ETypedElement_eType_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ETypedElement_eType_feature", "_UI_ETypedElement_type"),
EcorePackage.Literals.ETYPED_ELEMENT__ETYPE,
true,
null,
null,
null){



public Collection getChoiceOfValues(Object object) {

        Node node = (Node) object;
        try {
    for (GraphPattern graphPattern : node.getGraphPattern()) {

if (graphPattern instanceof DomainGraphPattern){
TypedModel typedModel = ((DomainGraphPattern) graphPattern).getTypedModel();
EList<EClass> eClassList = new BasicEList<EClass>();
for (EPackage usedPackage : typedModel.getUsedPackage()) {
for (EClassifier eClassifier : usedPackage.getEClassifiers()) {
if (eClassifier instanceof EClass){
eClassList.add((EClass) eClassifier);
}
}
}
return eClassList;
}
}


} catch (NullPointerException e) {
//nothing to worry about there. May occur if the necessary references have not been set up properly.
}
return Collections.EMPTY_LIST;
}


    }
  );
}



Jim van Dam wrote:
Hi Joel,

> My approach was overriding getChoiceOfValues(Object).
> So, my question is whether my approach to customize the
> ItemPropertyDescriptor is correct?
This is what I do all the time (generated based on custom templates or genmodel annotations) and everything works fine for us including typing.
Could you show us sourcecode?


Regards,

Jim

Joel Greenyer wrote:
Hi Ed,
mmh, I was clear :(

Alright... I have elements that are typed by an EClass. For the type feature, the drop-down in the properties view gives me the choice of all EClasses that are reachable in the current ResourceSet. But I want to narrow down this choice, since one may only select EClasses from certain EPackages (depending on the element's context). My approach was overriding getChoiceOfValues(Object). This works fine except for this typeing/filtering functionality: I can type "EPack...", then the EPackage class appears at the top. However, when I hit enter, the EPackage is not selected, but I find another element being selected instead.
So, my question is whether my approach to customize the ItemPropertyDescriptor is correct?


Thanks
Joel

Ed Merks wrote:
Joel,

Comments below.

Joel Greenyer wrote:
Hi,
in the properties view, when I want to select an element from a large list of choices, it is very helpful that I can start typing, e.g. "EPac..." to find the element "EPackage" more quickly.
In my edit plug-in, I have customized an addXXXPropertyDecriptor method to filter out values which are unnecessary in a particular context. When still large Lists of choices remain, I start typing "EPac..." and select the EPackage, but then I end up having another element selected.
I don't get this part about another element being selected. The first thing in the filtered result is selected and hitting enter should choose it...

Any idea how to avoid this? Thanks for helping

Joel

NodeImpl.setEType(EClassifier) line: 419	
NodeImpl(ETypedElementImpl).eSet(int, Object) line: 596	
NodeImpl(VariableImpl).eSet(int, Object) line: 441	
NodeImpl.eSet(int, Object) line: 542	
NodeImpl(BasicEObjectImpl).eSet(EStructuralFeature, Object) line: 1071	
SetCommand.doExecute() line: 721	
SetCommand(AbstractOverrideableCommand).execute() line: 131	
EMFCommandOperation.doExecute(IProgressMonitor, IAdaptable) line: 119	
EMFCommandOperation(AbstractEMFOperation).execute(IProgressMonitor, IAdaptable) line: 169	
DefaultOperationHistory.execute(IUndoableOperation, IProgressMonitor, IAdaptable) line: 511	
WorkspaceCommandStackImpl.doExecute(Command, Map<?,?>) line: 201	
WorkspaceCommandStackImpl(AbstractTransactionalCommandStack).execute(Command, Map<?,?>) line: 165	
WorkspaceCommandStackImpl(AbstractTransactionalCommandStack).execute(Command) line: 219	
NodeItemProvider$1(ItemPropertyDescriptor).setPropertyValue(Object, Object) line: 1427	
PropertySource.setPropertyValue(Object, Object) line: 116	
SetModelPropertyValueCommand.doExecuteWithResult(IProgressMonitor, IAdaptable) line: 104	
SetModelPropertyValueCommand(AbstractTransactionalCommand).doExecute(IProgressMonitor, IAdaptable) line: 247	
SetModelPropertyValueCommand(AbstractEMFOperation).execute(IProgressMonitor, IAdaptable) line: 169	
CompositeTransactionalCommand(CompositeEMFOperation).doExecute(IProgressMonitor, IAdaptable) line: 216	
CompositeTransactionalCommand(AbstractEMFOperation).execute(IProgressMonitor, IAdaptable) line: 169	
TriggeredOperations.execute(IProgressMonitor, IAdaptable) line: 165	
DefaultOperationHistory.execute(IUndoableOperation, IProgressMonitor, IAdaptable) line: 511	
UndoableModelPropertySheetEntry.valueChanged(UndoableModelPropertySheetEntry, ICommand) line: 244	
UndoableModelPropertySheetEntry.setValue(Object) line: 199	
UndoableModelPropertySheetEntry.applyEditorValue() line: 127	
CellEditor$1.run() line: 333	
SafeRunner.run(ISafeRunnable) line: 37	
Platform.run(ISafeRunnable) line: 880	
JFaceUtil$1.run(ISafeRunnable) line: 48	
SafeRunnable.run(ISafeRunnable) line: 175	
ExtendedComboBoxCellEditor(CellEditor).fireApplyEditorValue() line: 331	
ExtendedComboBoxCellEditor(ComboBoxCellEditor).applyEditorValueAndDeactivate() line: 273	
ComboBoxCellEditor$2.widgetDefaultSelected(SelectionEvent) line: 151	
TypedListener.handleEvent(Event) line: 113	
EventTable.sendEvent(Event) line: 84	
CCombo(Widget).sendEvent(Event) line: 1003	
CCombo(Widget).sendEvent(int, Event, boolean) line: 1027	
CCombo(Widget).sendEvent(int, Event) line: 1012	
CCombo(Widget).notifyListeners(int, Event) line: 770	
CCombo.listEvent(Event) line: 1071	
CCombo$1.handleEvent(Event) line: 110	
EventTable.sendEvent(Event) line: 84	
List(Widget).sendEvent(Event) line: 1003	
List(Widget).sendEvent(int, Event, boolean) line: 1027	
List(Widget).sendEvent(int, Event) line: 1012	
List(Widget).sendKeyEvent(int, int, int, int, Event) line: 1040	
List(Widget).sendKeyEvent(int, int, int, int) line: 1036	
List(Widget).wmChar(int, int, int) line: 1352	
List(Control).WM_CHAR(int, int) line: 3894	
List.WM_CHAR(int, int) line: 1528	
List(Control).windowProc(int, int, int, int) line: 3787	
Display.windowProc(int, int, int, int) line: 4528	
OS.DispatchMessageW(MSG) line: not available [native method]	
OS.DispatchMessage(MSG) line: 2371	
Display.readAndDispatch() line: 3420	
Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2382	
Workbench.runUI() line: 2346	
Workbench.access$4(Workbench) line: 2198	
Workbench$5.run() line: 493	
Realm.runWithDefault(Realm, Runnable) line: 288	
Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 488	
PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
IDEApplication.start(IApplicationContext) line: 113	
EclipseAppHandle.run(Object) line: 193	
EclipseAppLauncher.runApplication(Object) line: 110	
EclipseAppLauncher.start(Object) line: 79	
EclipseStarter.run(Object) line: 386	
EclipseStarter.run(String[], Runnable) line: 179	
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available	
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available	
Method.invoke(Object, Object...) line: not available	
Main.invokeFramework(String[], URL[]) line: 549	
Main.basicRun(String[]) line: 504	
Main.run(String[]) line: 1236	
Main.main(String[]) line: 1212	
NodeImpl.setEType(EClassifier) line: 419	
NodeImpl(ETypedElementImpl).eSet(int, Object) line: 596	
NodeImpl(VariableImpl).eSet(int, Object) line: 441	
NodeImpl.eSet(int, Object) line: 542	
NodeImpl(BasicEObjectImpl).eSet(EStructuralFeature, Object) line: 1071	
SetCommand.doExecute() line: 721	
SetCommand(AbstractOverrideableCommand).execute() line: 131	
EMFCommandOperation.doExecute(IProgressMonitor, IAdaptable) line: 119	
EMFCommandOperation(AbstractEMFOperation).execute(IProgressMonitor, IAdaptable) line: 169	
DefaultOperationHistory.execute(IUndoableOperation, IProgressMonitor, IAdaptable) line: 511	
WorkspaceCommandStackImpl.doExecute(Command, Map<?,?>) line: 201	
WorkspaceCommandStackImpl(AbstractTransactionalCommandStack).execute(Command, Map<?,?>) line: 165	
WorkspaceCommandStackImpl(AbstractTransactionalCommandStack).execute(Command) line: 219	
NodeItemProvider$1(ItemPropertyDescriptor).setPropertyValue(Object, Object) line: 1427	
PropertySource.setPropertyValue(Object, Object) line: 116	
SetModelPropertyValueCommand.doExecuteWithResult(IProgressMonitor, IAdaptable) line: 104	
SetModelPropertyValueCommand(AbstractTransactionalCommand).doExecute(IProgressMonitor, IAdaptable) line: 247	
SetModelPropertyValueCommand(AbstractEMFOperation).execute(IProgressMonitor, IAdaptable) line: 169	
CompositeTransactionalCommand(CompositeEMFOperation).doExecute(IProgressMonitor, IAdaptable) line: 216	
CompositeTransactionalCommand(AbstractEMFOperation).execute(IProgressMonitor, IAdaptable) line: 169	
TriggeredOperations.execute(IProgressMonitor, IAdaptable) line: 165	
DefaultOperationHistory.execute(IUndoableOperation, IProgressMonitor, IAdaptable) line: 511	
UndoableModelPropertySheetEntry.valueChanged(UndoableModelPropertySheetEntry, ICommand) line: 244	
UndoableModelPropertySheetEntry.setValue(Object) line: 199	
UndoableModelPropertySheetEntry.applyEditorValue() line: 127	
PropertySheetViewer.applyEditorValue() line: 258	
PropertySheetViewer.setInput(Object) line: 963	
PropertySheetPage.refresh() line: 471	
TggPropertySection(AdvancedPropertySection).refresh() line: 188	
AdvancedPropertySection$1.run() line: 215	
RunnableLock.run() line: 35	
UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 133	
Display.runAsyncMessages(boolean) line: 3800	
Display.readAndDispatch() line: 3425	
Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2382	
Workbench.runUI() line: 2346	
Workbench.access$4(Workbench) line: 2198	
Workbench$5.run() line: 493	
Realm.runWithDefault(Realm, Runnable) line: 288	
Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 488	
PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
IDEApplication.start(IApplicationContext) line: 113	
EclipseAppHandle.run(Object) line: 193	
EclipseAppLauncher.runApplication(Object) line: 110	
EclipseAppLauncher.start(Object) line: 79	
EclipseStarter.run(Object) line: 386	
EclipseStarter.run(String[], Runnable) line: 179	
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available	
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available	
Method.invoke(Object, Object...) line: not available	
Main.invokeFramework(String[], URL[]) line: 549	
Main.basicRun(String[]) line: 504	
Main.run(String[]) line: 1236	
Main.main(String[]) line: 1212