<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dgb2312">
<META content=3D"MSHTML 6.00.2900.3059" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Hi, all!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I have a problem during my development =
now.. That=20
is how to create a null IJavaInstance?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I want the VE to generate a statement =
by editing=20
property editor like this:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT size=3D2><FONT face=3DArial> <FONT=20
color=3D#0000ff>myCustomizedText.setFormatter(<FONT color=3D#ff0000>new=20
DateFormatter("dd/mm/yyyy")</FONT>);</FONT></FONT></FONT ></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>and I write a method to generate a=20
IJavaInstance I want to set in the statement:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> private =
IJavaInstance=20
createObject(){</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> =20
.......</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> =
//strClass is=20
the class name("DateFormatter", including package path), and initString =
is the=20
init string of the class("DateFormatter")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> =
return=20
BeanUtilities.createJavaObject(strClass, JavaEditDo mainHelper.getRes=
ourceSet(editDomain),=20
BeanPropertyDescriptorAdapter.createAllocation(initString,=2 0
editDomain));</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> }</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>and now I want to generate a statement =
like=20
this:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT size=3D2><FONT face=3DArial> <FONT=20
color=3D#0000ff>myCustomizedText.setFormatter(<FONT=20
color=3D#ff0000>null</FONT>);</FONT></FONT></FONT></DIV >
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>How to generate the "null" =
parameter?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I write a new method to generate this =
statement,=20
but I come across some mistake.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> </FONT>
<DIV><FONT face=3DArial size=3D2> private =
IJavaInstance=20
createObject(){</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> =20
.......</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> =
//strClass is=20
the class name(including package)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> =
return=20
BeanUtilities.createJavaObject(strClass, JavaEditDo mainHelper.getRes=
ourceSet(editDomain),=20
<FONT=20
color=3D#ff0000>InstantiationFactory.eINSTANCE.createParseTreeAllocation(=
InstantiationFactory.eINSTANCE.createPTNullLiteral())</FONT ><FONT=20
color=3D#000000>);</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> }</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>The statement has been generated with a =
warning:=20
<FONT color=3D#0000ff>java.lang.IllegalStateException(IWAV0190E: No bean =
instantiated for some reason);</FONT></FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>What's wrong with my code? Why this =
warning=20
appears? And how to generate the "null" parameter?</FONT></DIV><FONT =
face=3DArial=20
size=3D2></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial =
size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Appreciate for your help!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Hexise</FONT></DIV>
<DIV><BR></DIV></BODY></HTML>
------=_NextPart_000_0024_01C77CF8.4D236F50--]]>Allen Wang2007-04-12T03:47:09-00:00Re: How to create a null IJavaInstance instance?
https://www.eclipse.org/forums/index.php/mv/msg/42187/615193/#msg_615193
Originally posted by: richkulp.us.NO_SPAM.ibm.com
Try returning just null. (Not the string but the value).
I'm not sure from your code who is calling createObject() so I'm not
sure if it can handle null. But in the rest of the VE, a null is used
for null IJavaInstance.
--
Thanks,
Rich Kulp]]>2007-04-16T15:00:20-00:00Re: How to create a null IJavaInstance instance?
https://www.eclipse.org/forums/index.php/mv/msg/42187/137274/#msg_137274
Originally posted by: richkulp.us.NO_SPAM.ibm.com
Try returning just null. (Not the string but the value).
I'm not sure from your code who is calling createObject() so I'm not
sure if it can handle null. But in the rest of the VE, a null is used
for null IJavaInstance.
--
Thanks,
Rich Kulp]]>2007-04-16T15:00:20-00:00Re: How to create a null IJavaInstance instance?
https://www.eclipse.org/forums/index.php/mv/msg/42187/615194/#msg_615194
------=_NextPart_000_0015_01C780E4.0FF85420
Content-Type: text/plain;
charset="gb2312"
Content-Transfer-Encoding: quoted-printable
It is a abstract method of DialogCellEditor, and my editor extends from =
DialogCellEditor.
And if I return null in openDialogBox() method, It seems nothing =
happened. I want the statement to be changed from =
myCustomizedText.setDataFormat("dd/mm/yyyy") to =
myCustomizedText.setDataFormat(null), or to delete this statement, but =
the myCustomizedText.setDataFormat("dd/mm/yyyy") statement still exists =
after I returned null in openDialogBox() method.
Did I miss something?
Best regards,
Hexise
"Rich Kulp" <richkulp@us.NO_SPAM.ibm.com> wrote in message =
news:f00325$dtq$1@build.eclipse.org...
> Try returning just null. (Not the string but the value).
>=20
> private IJavaInstance createObject() {
> return null;
> }
>=20
> I'm not sure from your code who is calling createObject() so I'm not
> sure if it can handle null. But in the rest of the VE, a null is used
> for null IJavaInstance.
>=20
> --=20
> Thanks,
> Rich Kulp
------=_NextPart_000_0015_01C780E4.0FF85420
Content-Type: text/html;
charset="gb2312"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dgb2312">
<META content=3D"MSHTML 6.00.2900.3059" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Hi, Rich,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I call the createObject() in =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>protected Object openDialogBox(Control=20
cellEditorWindow){</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> return=20
createObject(......);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>It is a abstract method of =
DialogCellEditor, and my=20
editor extends from DialogCellEditor.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>And if I return null in openDialogBox() =
method, It=20
seems nothing happened. I want the statement to be changed from <FONT=20
color=3D#0000ff>myCustomizedText.setDataFormat("dd/mm/yyyy ")</FONT> to =
<FONT=20
color=3D#0000ff>myCustomizedText.setDataFormat(null)</FONT >, or to =
delete this=20
statement, but the myCustomizedText.setDataFormat("dd/mm/yyyy") =
statement still=20
exists after I returned null in openDialogBox() method.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Did I miss something?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Best regards,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Hexise</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial =
size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>"Rich Kulp" <</FONT><A=20
href=3D"mailto:richkulp@us.NO_SPAM.ibm.com"><FONT face=3DArial=20
size=3D2>richkulp@us.NO_SPAM.ibm.com</FONT></A><FONT face=3DArial =
size=3D2>> wrote=20
in message </FONT><A href=3D"news:f00325$dtq$1@build.eclipse.org"><FONT =
face=3DArial=20
size=3D2>news:f00325$dtq$1@build.eclipse.org</FONT></A><FONT =
face=3DArial=20
size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>> Try returning =
just null.=20
(Not the string but the value).<BR>> <BR>> private IJavaInstance=20
createObject() {<BR>> return null;<BR>> }<BR>> <BR>> =
I'm not=20
sure from your code who is calling createObject() so I'm not<BR>> =
sure if it=20
can handle null. But in the rest of the VE, a null is used<BR>> for =
null=20
IJavaInstance.<BR>> <BR>> -- <BR>> Thanks,<BR>> Rich=20
Kulp</FONT></BODY></HTML>
------=_NextPart_000_0015_01C780E4.0FF85420--]]>Allen Wang2007-04-17T03:32:18-00:00Re: How to create a null IJavaInstance instance?
https://www.eclipse.org/forums/index.php/mv/msg/42187/137284/#msg_137284
------=_NextPart_000_0015_01C780E4.0FF85420
Content-Type: text/plain;
charset="gb2312"
Content-Transfer-Encoding: quoted-printable
It is a abstract method of DialogCellEditor, and my editor extends from =
DialogCellEditor.
And if I return null in openDialogBox() method, It seems nothing =
happened. I want the statement to be changed from =
myCustomizedText.setDataFormat("dd/mm/yyyy") to =
myCustomizedText.setDataFormat(null), or to delete this statement, but =
the myCustomizedText.setDataFormat("dd/mm/yyyy") statement still exists =
after I returned null in openDialogBox() method.
Did I miss something?
Best regards,
Hexise
"Rich Kulp" <richkulp@us.NO_SPAM.ibm.com> wrote in message =
news:f00325$dtq$1@build.eclipse.org...
> Try returning just null. (Not the string but the value).
>=20
> private IJavaInstance createObject() {
> return null;
> }
>=20
> I'm not sure from your code who is calling createObject() so I'm not
> sure if it can handle null. But in the rest of the VE, a null is used
> for null IJavaInstance.
>=20
> --=20
> Thanks,
> Rich Kulp
------=_NextPart_000_0015_01C780E4.0FF85420
Content-Type: text/html;
charset="gb2312"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dgb2312">
<META content=3D"MSHTML 6.00.2900.3059" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Hi, Rich,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I call the createObject() in =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>protected Object openDialogBox(Control=20
cellEditorWindow){</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> return=20
createObject(......);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>It is a abstract method of =
DialogCellEditor, and my=20
editor extends from DialogCellEditor.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>And if I return null in openDialogBox() =
method, It=20
seems nothing happened. I want the statement to be changed from <FONT=20
color=3D#0000ff>myCustomizedText.setDataFormat("dd/mm/yyyy ")</FONT> to =
<FONT=20
color=3D#0000ff>myCustomizedText.setDataFormat(null)</FONT >, or to =
delete this=20
statement, but the myCustomizedText.setDataFormat("dd/mm/yyyy") =
statement still=20
exists after I returned null in openDialogBox() method.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Did I miss something?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Best regards,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Hexise</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial =
size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>"Rich Kulp" <</FONT><A=20
href=3D"mailto:richkulp@us.NO_SPAM.ibm.com"><FONT face=3DArial=20
size=3D2>richkulp@us.NO_SPAM.ibm.com</FONT></A><FONT face=3DArial =
size=3D2>> wrote=20
in message </FONT><A href=3D"news:f00325$dtq$1@build.eclipse.org"><FONT =
face=3DArial=20
size=3D2>news:f00325$dtq$1@build.eclipse.org</FONT></A><FONT =
face=3DArial=20
size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>> Try returning =
just null.=20
(Not the string but the value).<BR>> <BR>> private IJavaInstance=20
createObject() {<BR>> return null;<BR>> }<BR>> <BR>> =
I'm not=20
sure from your code who is calling createObject() so I'm not<BR>> =
sure if it=20
can handle null. But in the rest of the VE, a null is used<BR>> for =
null=20
IJavaInstance.<BR>> <BR>> -- <BR>> Thanks,<BR>> Rich=20
Kulp</FONT></BODY></HTML>
------=_NextPart_000_0015_01C780E4.0FF85420--]]>Allen Wang2007-04-17T03:32:18-00:00Re: How to create a null IJavaInstance instance?
https://www.eclipse.org/forums/index.php/mv/msg/42187/615195/#msg_615195
Originally posted by: richkulp.us.NO_SPAM.ibm.com
You are inheriting directly from JFace Dialog cell editor. The JFace
dialog cell editor doesn't allow null as a value. This is in the JFace
dialog cell editor:
public void widgetSelected(SelectionEvent event) {
// Remove the button's focus listener since it's guaranteed
// to lose focus when the dialog opens
button.removeFocusListener(getButtonFocusListener());
Object newValue = openDialogBox(editor);
// Re-add the listener once the dialog closes
button.addFocusListener(getButtonFocusListener());
if (newValue != null) {
boolean newValidState = isCorrect(newValue);
As you can see if the new value is null it is ignored.
I don't see a direct simple way around this other than in your
"myCustomizedTextClass" you do the following:
package mypackage;
public class CustomizedTextClass ... {
public static final String DEFAULT_DATA_FORMAT = "";
public void setDataFormat(String format) {
if (DEFAULT_DATA_FORMAT.equals(format)) {
... treat as you would of treated null
} else {
... do normal
}
}
}
Do not use null as DEFAULT_DATA_FORMAT, it won't work correctly in the
VE. The VE has a bug where if an initialization string evaluates to null
then it throws some errors. It expects an initialization string to
always evaluate to some value.
--
Thanks,
Rich Kulp]]>2007-04-17T14:15:45-00:00Re: How to create a null IJavaInstance instance?
https://www.eclipse.org/forums/index.php/mv/msg/42187/137293/#msg_137293
Originally posted by: richkulp.us.NO_SPAM.ibm.com
You are inheriting directly from JFace Dialog cell editor. The JFace
dialog cell editor doesn't allow null as a value. This is in the JFace
dialog cell editor:
public void widgetSelected(SelectionEvent event) {
// Remove the button's focus listener since it's guaranteed
// to lose focus when the dialog opens
button.removeFocusListener(getButtonFocusListener());
Object newValue = openDialogBox(editor);
// Re-add the listener once the dialog closes
button.addFocusListener(getButtonFocusListener());
if (newValue != null) {
boolean newValidState = isCorrect(newValue);
As you can see if the new value is null it is ignored.
I don't see a direct simple way around this other than in your
"myCustomizedTextClass" you do the following:
package mypackage;
public class CustomizedTextClass ... {
public static final String DEFAULT_DATA_FORMAT = "";
public void setDataFormat(String format) {
if (DEFAULT_DATA_FORMAT.equals(format)) {
... treat as you would of treated null
} else {
... do normal
}
}
}
Do not use null as DEFAULT_DATA_FORMAT, it won't work correctly in the
VE. The VE has a bug where if an initialization string evaluates to null
then it throws some errors. It expects an initialization string to
always evaluate to some value.