Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Assertion failed, Property View with a ComboBoxDescriptor
Assertion failed, Property View with a ComboBoxDescriptor [message #202353] Tue, 08 November 2005 22:50 Go to next message
Jens Bartelheimer is currently offline Jens BartelheimerFriend
Messages: 44
Registered: July 2009
Member
Hello,

I have a problem with the property view. I have modified the generic
property adapter from the redbook with a ComboboxPropertyDescripter (see
the code under the error trace).
Every time I click on the visibility entry the following error message
arises. What is wrong? I like to use the ComboboxPropertyDescriptor to
show all elements of my EMF Enumeration VisibilityKind.

!ENTRY org.eclipse.ui 4 0 2005-11-08 23:38:59.502
!MESSAGE Assertion failed:
!STACK 0
org.eclipse.jface.util.Assert$AssertionFailedException: Assertion failed:
at org.eclipse.jface.util.Assert.isTrue(Assert.java:180)
at org.eclipse.jface.util.Assert.isTrue(Assert.java:165)
at
org.eclipse.jface.viewers.ComboBoxCellEditor.doSetValue(Comb oBoxCellEditor.java:218)
at org.eclipse.jface.viewers.CellEditor.setValue(CellEditor.jav a:815)
at
org.eclipse.ui.views.properties.PropertySheetEntry.getEditor (PropertySheetEntry.java:380)
at
org.eclipse.ui.views.properties.PropertySheetViewer.activate CellEditor(PropertySheetViewer.java:154)
at
org.eclipse.ui.views.properties.PropertySheetViewer.handleSe lect(PropertySheetViewer.java:682)
at
org.eclipse.ui.views.properties.PropertySheetViewer.access$6 (PropertySheetViewer.java:660)
at
org.eclipse.ui.views.properties.PropertySheetViewer$5.mouseD own(PropertySheetViewer.java:756)
at
org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:133)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3080)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2713)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1699)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:367)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:143)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:103)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:226)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:376)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:163)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
at org.eclipse.core.launcher.Main.run(Main.java:973)
at org.eclipse.core.launcher.Main.main(Main.java:948)
Unhandled event loop exception
Reason:
Assertion failed:

/*
* Created on Jul 20, 2003
*
* Eclipse GEF redbook sample application
* $Revision: 1.5 $
*
* (c) Copyright IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* ddean Initial version
*/
package jPDD.editparts;

import java.util.Collection;
import java.util.Iterator;
import java.util.Vector;

import model.ModelElement;
import model.ModelPackage;
import model.VisibilityKind;

import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;

/**
* This class is intended to be a generic property source for all the
objects in
* the application's model. It currently only supports String and
boolean types,
* and doesn't support reset or nested properties. It uses information
in the EMF
* EAttribute and EDataType classes to get the id, display name, and
type information.
*
* @author ddean
*
*/
public class GenericModelElementPropertySourceAdapter implements
IPropertySource {
private ModelElement element;
private ModelPackage modelPackage;

public GenericModelElementPropertySourceAdapter( ModelElement element ) {
this.element = element;

//Map registry = EPackage.Registry.INSTANCE;
//String workflowURI = WorkflowPackage.eNS_URI;
//workflowPackage = (WorkflowPackage) registry.get(workflowURI);
modelPackage = ModelPackage.eINSTANCE;
}

/* (non-Javadoc)
* @see org.eclipse.ui.views.properties.IPropertySource#getEditableV alue()
*/
public Object getEditableValue() {
return element;
}

/* (non-Javadoc)
* @see
org.eclipse.ui.views.properties.IPropertySource#getPropertyD escriptors()
*/
public IPropertyDescriptor[] getPropertyDescriptors() {
Iterator it;
EClass cls = element.eClass();
Collection descriptors = new Vector();

it = cls.getEAllAttributes().iterator();
while( it.hasNext() ) {
EAttribute attr = (EAttribute)it.next();

EDataType type = attr.getEAttributeType();
if( attr.isID() ) {
// shouldn't be editable
descriptors.add( new PropertyDescriptor( Integer.toString(
attr.getFeatureID() ),
attr.getName() ) );
}
//else if( type.getInstanceClass() == String.class &&
!(attr.getName().equals("identifier"))) {
else if( type.getInstanceClass() == String.class ) {
descriptors.add( new TextPropertyDescriptor( attr.getName() ,
attr.getName() ) );
}
else if( type.getInstanceClass() == boolean.class ) {

descriptors.add( new CheckboxPropertyDescriptor( attr.getName() ,
attr.getName() ) );
//String[] values = {"true", "false"};
//descriptors.add( new ComboBoxPropertyDescriptor( attr.getName(),
// attr.getName() , values));

}
else if (type.getInstanceClass()== VisibilityKind.class) {
System.out.println(VisibilityKind.VALUES.toArray());
String[] values = {"private", "protected", "public", "package"};
descriptors.add( new ComboBoxPropertyDescriptor( attr.getName(),
attr.getName(), values));
}
}

return (IPropertyDescriptor[])descriptors.toArray( new
IPropertyDescriptor[] {} );
}

/* (non-Javadoc)
* @see
org.eclipse.ui.views.properties.IPropertySource#getPropertyV alue(java.lang.Object)
*/
public Object getPropertyValue(Object id) {
//EStructuralFeature feature = element.eClass().getEStructuralFeature(
Integer.parseInt( (String)id ) );

EStructuralFeature feature =
element.eClass().getEStructuralFeature(id.toString());
//System.out.println(feature);
Object result = element.eGet( feature );
//System.out.println(result);
System.out.println(feature + ": " +result);
Object tmp = result != null ? result : "";
System.out.println(tmp);
return tmp;
}

/* (non-Javadoc)
* @see
org.eclipse.ui.views.properties.IPropertySource#isPropertySe t(java.lang.Object)
*/
public boolean isPropertySet(Object id) {
// TODO Auto-generated method stub
return false;
}

/* (non-Javadoc)
* @see
org.eclipse.ui.views.properties.IPropertySouce#resetProperty Value(java.lang.Object)
*/
public void resetPropertyValue(Object id) {
// TODO Auto-generated method stub

}

/* (non-Javadoc)
* @see
org.eclipse.ui.views.properties.IPropertySource#setPropertyV alue(java.lang.Object,
java.lang.Object)
*/
public void setPropertyValue(Object id, Object value) {
EStructuralFeature feature = element.eClass().getEStructuralFeature(
id.toString() );
element.eSet( feature, value );
}

}
Re: Assertion failed, Property View with a ComboBoxDescriptor [message #202437 is a reply to message #202353] Wed, 09 November 2005 16:44 Go to previous messageGo to next message
Matt is currently offline MattFriend
Messages: 40
Registered: July 2009
Member
Hi Jens,

I'm not an expert, but I've worked with ComboBoxPropertyDescriptors in the
past. You need to remember that getPropertyDescriptor() must return an
Integer and the second argument in setPropertyDescriptor() is an Integer.

So I'd change 'tmp' in getPropertyDescriptor to an Integer and make sure
that element.eSet(feature, value) can accept an Integer as its 'value'
parameter.

If this doesn't help, please point out which lines of code produce the
error.

Good luck.

Matt
Re: Assertion failed, Property View with a ComboBoxDescriptor [message #202500 is a reply to message #202437] Thu, 10 November 2005 10:19 Go to previous message
Jens Bartelheimer is currently offline Jens BartelheimerFriend
Messages: 44
Registered: July 2009
Member
Matt wrote:
> Hi Jens,
>
> I'm not an expert, but I've worked with ComboBoxPropertyDescriptors in
> the past. You need to remember that getPropertyDescriptor() must return
> an Integer and the second argument in setPropertyDescriptor() is an
> Integer.

Do you mean getPropertyValue() instead of getPropertyDescriptor()? If
yes what happens with String values if this method only returns Integers?

>
> So I'd change 'tmp' in getPropertyDescriptor to an Integer and make sure
> that element.eSet(feature, value) can accept an Integer as its 'value'
> parameter.
>
> If this doesn't help, please point out which lines of code produce the
> error.

Sorry, but I can not point out the line which produce the error. Without
the ComboxboxDescriptor no error occurs. The error occurs only if I
click the ComboBoxDesciptor in the property view. The initial value is
also ok only modifications do not work.

Thanks,
Jens
>
> Good luck.
>
> Matt
>
Previous Topic:Drag And Drop from View to Editor
Next Topic:how to access the commandstack
Goto Forum:
  


Current Time: Sun Nov 03 22:17:35 GMT 2024

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

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

Back to the top