Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Cstomizing ShapeListBox (Read 12937 times)
Mohammad
YaBB Newbies
*
Offline


Hello everybody :)

Posts: 32
Joined: Oct 2nd, 2009
Cstomizing ShapeListBox
Oct 3rd, 2009 at 10:24am
Print Post  
Hi

I'm going to change Icon size of ShapeListBox in client-side. javascript function is:

function onAppletStarted()
{
var applet = <%= diagramView.AppletElement %>;
var shapeListApplet = <%= shapeList.AppletElement %>;
var shapeList = shapeListApplet.getShapeListBox();
var scriptHelper = applet.getScriptHelper();
var dimension = scriptHelper.createSizeF(32,16);
shapeList.setIconSize(dimension);
}

But it doesn't work! Any idea?

In addition, how can I ask ShapeListBox to hide Shape IDs and show only Shape icons?

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Cstomizing ShapeListBox
Reply #1 - Oct 4th, 2009 at 1:06pm
Print Post  
Hi,

setIconSize expexts a Dimension instance (a size object with integer coordinates), but createSizeF returns a Dimension2D which holds floating point coordinates. Seems there isn't a createSize method to create a Dimension, but you could use createRectangle:

var dimension = scriptHelper.createRectangle(0,0,32,16).getSize();

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Mohammad
YaBB Newbies
*
Offline


Hello everybody :)

Posts: 32
Joined: Oct 2nd, 2009
Re: Cstomizing ShapeListBox
Reply #2 - Oct 5th, 2009 at 4:04am
Print Post  
Thank you Stoyan.
It works when I call the onAppletStarted() function myself. But when I assign AppletStartedScript to this function I meet this javascript error when java applet is going to be loaded:

Microsoft JScript runtime error: 'window[...]' is null or not an object

the error occurs on this line:
window[appletStartedScript].call();

Any suggestion?
Thanks.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Cstomizing ShapeListBox
Reply #3 - Oct 5th, 2009 at 7:01am
Print Post  
Are you calling this from AppletStarted for the ShapeList applet, or the one for the DiagramView applet?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Cstomizing ShapeListBox
Reply #4 - Oct 5th, 2009 at 10:18am
Print Post  
Btw. if you need to access APIs of both the Diagram and the ShapeListBox when the page loads, you must do that when both applets are loaded. E.g. you could add a counter variable to the page, and call some init method when the is equal to 2:

Code
Select All
var counter = 0;
function onAppletStarted()
{
	counter++;
	if (counter == 2)
		initApplets();
}
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Mohammad
YaBB Newbies
*
Offline


Hello everybody :)

Posts: 32
Joined: Oct 2nd, 2009
Re: Cstomizing ShapeListBox
Reply #5 - Oct 5th, 2009 at 12:34pm
Print Post  
I am calling onAppletStarted from AppletStarted for DiagramView.But there is the same problem for ShapeList applet. The problem is that the DiagramView applet can't find this javascript function. All scripts and applets are inside the same aspx page and I have no problem with other applet events except AppletStartedScript.

As I said before this error occurs on this line:

window[appletStartedScript].call();

It's not my code.It's part of your resource file.
Thanks for your tip about initiating both applets.But I can't do that before solving this problem! Sad

Thank's for your time.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Cstomizing ShapeListBox
Reply #6 - Oct 5th, 2009 at 12:59pm
Print Post  
Have you checked if the AppletStartedScript property value isn't misspelled by chance? Note that it should specify just the handler name, without parentheses. Also check if the Routing example runs on your system; it handles onAppletStarted() to create the obstacle nodes.
  
Back to top
 
IP Logged
 
Mohammad
YaBB Newbies
*
Offline


Hello everybody :)

Posts: 32
Joined: Oct 2nd, 2009
Re: Cstomizing ShapeListBox
Reply #7 - Oct 5th, 2009 at 1:07pm
Print Post  
I called the function from AppletStartedScript for both DiagramView and ShapeList and I didn't see the error!

It seems that we should call it from both applets. But I can't understand what's going on?
  
Back to top
 
IP Logged
 
Mohammad
YaBB Newbies
*
Offline


Hello everybody :)

Posts: 32
Joined: Oct 2nd, 2009
Re: Cstomizing ShapeListBox
Reply #8 - Oct 5th, 2009 at 1:20pm
Print Post  
Btw, your Routing sample works without error
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Cstomizing ShapeListBox
Reply #9 - Oct 5th, 2009 at 2:11pm
Print Post  
Since you are accessing both applets in the onAppletStarted code, calling it from the DiagramView.AppletStartedScript might not work because the second applet hasn't loaded yet. If you set it as AppletStartedScript for both applets, perhaps it's called after both are loaded - either our developers have implemented some synchronization, or that's done by the JRE. Anyway, if it works now, use the counter scheme to run the init code only once.
  
Back to top
 
IP Logged
 
Mohammad
YaBB Newbies
*
Offline


Hello everybody :)

Posts: 32
Joined: Oct 2nd, 2009
Re: Cstomizing ShapeListBox
Reply #10 - Oct 5th, 2009 at 11:30pm
Print Post  
I got it! Smiley
The onAppletStarted function must be in head section of the page not body. Because when applet is going to be loaded, it must be loaded before.

I had another question in the first post.
How can I ask ShapeListBox to hide Shape IDs and show only Shape icons? Our shapes have images that are clear for uses and we don't want to show the name of the shape in ShapeListBox.
Is there any property to set?

Thank you.
« Last Edit: Oct 6th, 2009 at 12:31am by Mohammad »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Cstomizing ShapeListBox
Reply #11 - Oct 6th, 2009 at 4:55am
Print Post  
Seems there isn't a property for this. We'll try to add one today.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Cstomizing ShapeListBox
Reply #12 - Oct 6th, 2009 at 10:33am
Print Post  
This version of the applet lets you call ShapeListBox.showLabels(false) to hide the labels:

https://mindfusion.eu/_beta/shapelist_showlabels.zip

We'll also add a ShowLabels property to the server-side ShapeListbox control in a couple of days.

Stoyan
  
Back to top
 
IP Logged
 
Mohammad
YaBB Newbies
*
Offline


Hello everybody :)

Posts: 32
Joined: Oct 2nd, 2009
Re: Cstomizing ShapeListBox
Reply #13 - Oct 7th, 2009 at 9:45am
Print Post  
Oh thank you!

I just replaced my old version of JDiagram.jar file with this version. But it raises an error on runtime:

Microsoft JScript runtime error: Object doesn't support this property or method

Code
Select All
function onAppletStarted()
            {
                var shapeListApplet = <%= shapeList.AppletElement %>;
                var shapeList = shapeListApplet.getShapeListBox();
                var scriptHelper = shapeListApplet.getScriptHelper();
                var dimension = scriptHelper.createRectangle(0,0,32,16).getSize();
                shapeList.setIconSize(dimension);
                shapeList.showLabels(false);
            }

 



Is there any thing that I missed it?

Thanks
Mohammad
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Cstomizing ShapeListBox
Reply #14 - Oct 7th, 2009 at 10:23am
Print Post  
Sorry - it should be ShapeListBox.setShowLabels(false).

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint