Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Visual Editor (VE) » how do i set a property for array eg: String[]
how do i set a property for array eg: String[] [message #139486] Wed, 01 August 2007 08:25
Eclipse User
Originally posted by: caye5200.yahoo.com.cn

hello, i am VE new developer. now i want devloper a property editor int
the property sheet.
i am developed a property dialog with "java.lang.Integer"
property ,eg

First i create a override file , the property is "ailgnment",
Following
..........................
<objectsToAttach xmi:id="_eStructuralFeatures" name="alignment"
unsettable="true" xsi:type="ecore:EReference">
<eAnnotations
cellEditorClassname=" com.hitachi.yokohama.dtv/com.hitachi.yokohama.dtv.editor.HLe ditor "

xsi:type=" org.eclipse.ve.internal.cde.decorators:BasePropertyDecorator "/>
</objectsToAttach>
..........................

Second i develop a Hleditror class ,Following

public class HLeditor extends DialogCellEditor implements INeedData
{
...........................
public HLeditor(Composite aComposite) {
super(aComposite);
}
//create a IJavaInstance
private static IJavaInstance createIntJavaObject(int aInt,int type)
{
String pos=pakage;
switch(aInt)
{
case 0:
switch(type)
{
case 0:
pos=pos+"HiLabel.LEFT";break;
case 1:
pos=pos+"HiLabel.FREE,10";break;
};break;
case 1:
pos=pos+"HiLabel.CENTER";break;
case 2:
pos=pos+"HiLabel.RIGHT"; break;
}
return BeanUtilities.createJavaObject(
"java.lang.Integer",
JavaEditDomainHelper.getResourceSet(fEditDomain),
BeanPropertyDescriptorAdapter.createAllocation(pos
,fEditDomain));
}


/* (non-Javadoc)
* @see
org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org .eclipse.swt.widgets.Control)
*/
protected Object openDialogBox(Control cellEditorWindow) {
....................................

if (dialog.open() != Window.CANCEL) {
return createIntJavaObject(this.postion,this.flag);
} else { return getValue();
}
}

/* (non-Javadoc)
* @see
org.eclipse.ve.internal.propertysheet.INeedData#setData(java .lang.Object)
*/
public void setData(Object data) {
fEditDomain = (EditDomain) data;
}
// A int instance varialble is created to store the value of that
property
protected void doSetValue(Object value) {
if (value != null){
INumberBeanProxy intBeanProxy = (INumberBeanProxy)
BeanProxyUtilities.getBeanProxy((IJavaInstance) value);
intValue=intBeanProxy.intValue();
}
super.doSetValue(value);
}

//update Data
protected void updateContents(Object value) {
super.updateContents(Integer.valueOf(intValue));
}
.......................................................

}

Now hava two propertis "text" and "alignment" the set Methods are
setText(String[] args) and setAlignment(int alignment ,int x)

the types how set? i try set "java.lang.Object" but
the view have error.
eg following

private IJavaInstance createStringJavaObject(String initString ) {
return BeanUtilities.createJavaObject("java.lang.Object",
JavaEditDomainHelper.getResourceSet(fEditDomain),
initString);
}

the code can genrated but the view have exception,Please tell me
,how can i do? thank you.
Previous Topic:How I can Add a component in VE toolbar
Next Topic:how do i set a property for array eg: String[]
Goto Forum:
  


Current Time: Mon Jul 28 06:24:01 EDT 2014

Powered by FUDForum. Page generated in 0.01409 seconds