Skip to main content



      Home
Home » Archived » Visual Editor (VE) » V.E not writing the code returned by property editor --urgent :please help its
V.E not writing the code returned by property editor --urgent :please help its [message #125378] Tue, 30 May 2006 01:51 Go to next message
Eclipse UserFriend
Originally posted by: rashmi_h_r.rediffmail.com

Hi All,
I am facing a problem with the custom property editor that, I have
written for my custom widgets.
The type of the property that I am trying to edit is a double dimension
String array. All the other property editors which are used to edit a
simple string/list are working fine. The ‘getJavaInitialization ()' method
is called for them.

Only in the property editor with the complex data type (Double dimension
String array) the getJavaInitialization () method is not called.
’getAsText ()' method is called directly and anything returned from that
method is not reflected (written) on to the code in the Editor window.
The return string from the ‘getAsText ()' Method is of the form as given
below
return

"new String [][]{{\"ssss\",\"ssss\"}}";

The string returned from the ‘getAsText ()'method for the property is
visible correctly as the cell value in the Properties View, but the
property is not set with that value. When I press ‘<-|Enter’ key on the
cell value, I get a error message saying

‘IWVA0086E Error: "new String [][]{{\"ssss\",\"ssss\"}}";

Note: When I explicitly invoke the 'setValue()' method from getAsText()
method of the property editor class with a dummy value, the string is
written to the code in the editor window. But, explicit invocation of the
‘setValue ()' method is not advised in the API.

My custom property editor implementation is working fine in another IDE.

I have also tried clearing all the bean info cache (from
...metadata\.plugins\org.eclipse.jem.beaninfo and
...metadata\.plugins\org.eclipse.core.resources\.projects\<yourproject >\org.eclipse.jem.beaninfo).
But it is still not working.

Please please help It's very urgent:((((((((((

Thank you in advance.
Rashm H.R

Please find the code sampl below.


package mypackage1;
import java.beans.PropertyEditorSupport;
public class ContentTextEditor extends PropertyEditorSupport
{
/**
* Constructor for the ContentTextEditor object
*/
public ContentTextEditor()
{
}
public String getAsText() {
Object obj = this.getValue();
if ( obj instanceof String[])
{
return "new String[]{\"aaaa\",\"bbbb\",\"cccc\"}";
}
return ("" + obj);
}
public void setAsText(String text) throws
java.lang.IllegalArgumentException {
if (this.getValue() instanceof String) {
setValue(text);
return;
}
throw new java.lang.IllegalArgumentException(text);
}
public String getJavaInitializationString()
{
return "\""+getAsText()+"\"";
}
}
Re: V.E not writing the code returned by property editor --urgent :please help its [message #125494 is a reply to message #125378] Fri, 02 June 2006 05:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rashmi_h_r.rediffmail.com

hi All,
I have posted this query for 2nd time already. Can anybody atleast poit
me to the correct forum. If this question does belong to this forum.

thanks
Rashmi H.R
Re: V.E not writing the code returned by property editor --urgent :please help its [message #126150 is a reply to message #125494] Wed, 14 June 2006 15:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fun2program8.yahoo.com

You are in the right forum. Unfortunately no-one either has the time or
the knowledge to answer your question. I myself cannot because I have
never done this before.

Rashmi H.R wrote:
> hi All,
> I have posted this query for 2nd time already. Can anybody atleast
> poit me to the correct forum. If this question does belong to this forum.
>
> thanks
> Rashmi H.R
>
Re: V.E not writing the code returned by property editor --urgent :please help its [message #126176 is a reply to message #125378] Wed, 14 June 2006 16:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

I'm missing something because this editor sample given here can't work.

This editor only works with "String" values, but your are trying to
return a "String[]".

This won't work because the this.value will be set to an "String[][]"
instance. So the setAsText will fail because the value is not an
instanceof String.


>
> package mypackage1;
> import java.beans.PropertyEditorSupport;
> public class ContentTextEditor extends PropertyEditorSupport
> {
> /**
> * Constructor for the ContentTextEditor object
> */
> public ContentTextEditor()
> {
> }
> public String getAsText() {
> Object obj = this.getValue();
> if ( obj instanceof String[]) {
> return "new String[]{\"aaaa\",\"bbbb\",\"cccc\"}";
> }
> return ("" + obj);
> }
> public void setAsText(String text) throws
> java.lang.IllegalArgumentException {
> if (this.getValue() instanceof String) {
> setValue(text);
> return;
> }
> throw new java.lang.IllegalArgumentException(text);
> }
> public String getJavaInitializationString()
> {
> return "\""+getAsText()+"\"";
> }
> }
>
>

--
Thanks,
Rich Kulp
Re: V.E not writing the code returned by property editor --urgent :please help its [message #126189 is a reply to message #126176] Wed, 14 June 2006 16:31 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Here is an editor that works correctly for String[][]:

package t;
import java.beans.PropertyEditorSupport;
import java.util.ArrayList;
import java.util.List;
public class ContentTextEditor extends PropertyEditorSupport
{

public String getJavaInitializationString() {
Object value = getValue();
if (value == null)
return "null";
else {
StringBuffer b = new StringBuffer("new String[][] {");
String[][] sv = (String[][]) value;
for (int i = 0; i < sv.length; i++) {
if (i > 0)
b.append(',');
b.append('{');
String[] ssv = sv[i];
for (int j = 0; j < ssv.length; j++) {
if (j>0)
b.append(',');
b.append('"');
b.append(ssv[j]);
b.append('"');
}
b.append('}');
}
b.append('}');
return b.toString();
}

}

public String getAsText() {
Object value = getValue();
if (value == null)
return "null";
else if (value instanceof String[][]) {
StringBuffer sb = new StringBuffer();
String[][] v = (String[][]) value;
for (int i = 0; i < v.length; i++) {
String[] vv = v[i];
if (i>0)
sb.append('/');
for (int j = 0; j < vv.length; j++) {
if (j>0)
sb.append(',');
sb.append(vv[j]);
}
}
return sb.toString();
} else
return "???";
}

public void setAsText(String text) throws IllegalArgumentException {
List vl = new ArrayList();
int i = text.indexOf('/');
int b = 0;
while (i >= 0) {
vl.add(getSv(text.substring(b, i)));
b = i+1;
i = text.indexOf('/', b);
}
if (b<text.length())
vl.add(getSv(text.substring(b)));
setValue((String[][]) vl.toArray(new String[vl.size()][]));
}

private String[] getSv(String s) {
List vl = new ArrayList();
int i = s.indexOf(',');
int b = 0;
while (i >= 0) {
vl.add(s.substring(b, i));
b = i+1;
i = s.indexOf(',', b);
}
if (b<s.length())
vl.add(s.substring(b));
return (String[]) vl.toArray(new String[vl.size()]);
}
}
--
Thanks,
Rich Kulp
Re: V.E not writing the code returned by property editor --urgent :please help its [message #612996 is a reply to message #125378] Fri, 02 June 2006 05:13 Go to previous message
Eclipse UserFriend
Originally posted by: rashmi_h_r.rediffmail.com

hi All,
I have posted this query for 2nd time already. Can anybody atleast poit
me to the correct forum. If this question does belong to this forum.

thanks
Rashmi H.R
Re: V.E not writing the code returned by property editor --urgent :please help its [message #613343 is a reply to message #125494] Wed, 14 June 2006 15:10 Go to previous message
Eclipse UserFriend
You are in the right forum. Unfortunately no-one either has the time or
the knowledge to answer your question. I myself cannot because I have
never done this before.

Rashmi H.R wrote:
> hi All,
> I have posted this query for 2nd time already. Can anybody atleast
> poit me to the correct forum. If this question does belong to this forum.
>
> thanks
> Rashmi H.R
>
Re: V.E not writing the code returned by property editor --urgent :please help its [message #613345 is a reply to message #125378] Wed, 14 June 2006 16:08 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

I'm missing something because this editor sample given here can't work.

This editor only works with "String" values, but your are trying to
return a "String[]".

This won't work because the this.value will be set to an "String[][]"
instance. So the setAsText will fail because the value is not an
instanceof String.


>
> package mypackage1;
> import java.beans.PropertyEditorSupport;
> public class ContentTextEditor extends PropertyEditorSupport
> {
> /**
> * Constructor for the ContentTextEditor object
> */
> public ContentTextEditor()
> {
> }
> public String getAsText() {
> Object obj = this.getValue();
> if ( obj instanceof String[]) {
> return "new String[]{\"aaaa\",\"bbbb\",\"cccc\"}";
> }
> return ("" + obj);
> }
> public void setAsText(String text) throws
> java.lang.IllegalArgumentException {
> if (this.getValue() instanceof String) {
> setValue(text);
> return;
> }
> throw new java.lang.IllegalArgumentException(text);
> }
> public String getJavaInitializationString()
> {
> return "\""+getAsText()+"\"";
> }
> }
>
>

--
Thanks,
Rich Kulp
Re: V.E not writing the code returned by property editor --urgent :please help its [message #613346 is a reply to message #126176] Wed, 14 June 2006 16:31 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Here is an editor that works correctly for String[][]:

package t;
import java.beans.PropertyEditorSupport;
import java.util.ArrayList;
import java.util.List;
public class ContentTextEditor extends PropertyEditorSupport
{

public String getJavaInitializationString() {
Object value = getValue();
if (value == null)
return "null";
else {
StringBuffer b = new StringBuffer("new String[][] {");
String[][] sv = (String[][]) value;
for (int i = 0; i < sv.length; i++) {
if (i > 0)
b.append(',');
b.append('{');
String[] ssv = sv[i];
for (int j = 0; j < ssv.length; j++) {
if (j>0)
b.append(',');
b.append('"');
b.append(ssv[j]);
b.append('"');
}
b.append('}');
}
b.append('}');
return b.toString();
}

}

public String getAsText() {
Object value = getValue();
if (value == null)
return "null";
else if (value instanceof String[][]) {
StringBuffer sb = new StringBuffer();
String[][] v = (String[][]) value;
for (int i = 0; i < v.length; i++) {
String[] vv = v[i];
if (i>0)
sb.append('/');
for (int j = 0; j < vv.length; j++) {
if (j>0)
sb.append(',');
sb.append(vv[j]);
}
}
return sb.toString();
} else
return "???";
}

public void setAsText(String text) throws IllegalArgumentException {
List vl = new ArrayList();
int i = text.indexOf('/');
int b = 0;
while (i >= 0) {
vl.add(getSv(text.substring(b, i)));
b = i+1;
i = text.indexOf('/', b);
}
if (b<text.length())
vl.add(getSv(text.substring(b)));
setValue((String[][]) vl.toArray(new String[vl.size()][]));
}

private String[] getSv(String s) {
List vl = new ArrayList();
int i = s.indexOf(',');
int b = 0;
while (i >= 0) {
vl.add(s.substring(b, i));
b = i+1;
i = s.indexOf(',', b);
}
if (b<s.length())
vl.add(s.substring(b));
return (String[]) vl.toArray(new String[vl.size()]);
}
}
--
Thanks,
Rich Kulp
Previous Topic:Property editor problems
Next Topic:In which state is creating of new tutorials for VE
Goto Forum:
  


Current Time: Wed Jun 18 18:01:39 EDT 2025

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

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

Back to the top