This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

Icon on Node in Tree object

Frequently asked questions about VisionX.

Icon on Node in Tree object

Postby lucdep » Thu Aug 22, 2019 6:56 pm

Hi,

Is there a way to set a specifiec icon on a tree node, reflecting the state of the row represented by the node, example: row with status OK get a green check icon, rows with status NOK get a red cross...

My status datatables, that are referenced from the main table, have already image fields with icons for each status, and in tables and forms it's easy to show them, but I can't find how I can show the images in a tree object.

Thanks for your quick reply.

Luc
lucdep
 
Posts: 47
Joined: Wed Oct 10, 2018 12:01 pm

Re: Icon on Node in Tree object

Postby johnit » Sun Aug 25, 2019 5:49 pm

Found in documentation.
johnit
 
Posts: 36
Joined: Fri Nov 16, 2012 5:58 pm

Re: Icon on Node in Tree object

Postby lucdep » Thu Aug 29, 2019 12:31 pm

Hi,

Thanks for your reply, I tried the sample code you refer to, but it shows a strange behaviour:

First test:
Code: Select all
public IImage getNodeImage(IDataBook pDataBook, IDataPage pDataPage, IDataRow pDataRow, String pColumnName, int pRow, boolean pExpanded, boolean pLeaf) throws Throwable
   {
      
      if (pDataBook == rdbPdvePdversion)
      {
         return UIImage.getImage("/be/moonfox/apps/max/images/frame.png");
      }

      return null;

   }


works as expected;

Second test:

I create a new icon named pink.png (copy from frame.png)

Code: Select all

public IImage getNodeImage(IDataBook pDataBook, IDataPage pDataPage, IDataRow pDataRow, String pColumnName, int pRow, boolean pExpanded, boolean pLeaf) throws Throwable
   {
      
      if (pDataBook == rdbPdvePdversion)
      {
         return UIImage.getImage("/be/moonfox/apps/max/images/pink.png");
      }

      return null;

   }

gives "resource unavailable" error, although the pink.png resides in the same folder as the frame.png that works well.

Third test:

As my purpose is to define the node dynamically, refering to the status of the row, I tried following code which compiles without error, but shows no icon

Code: Select all
public IImage getNodeImage(IDataBook pDataBook, IDataPage pDataPage, IDataRow pDataRow, String pColumnName, int pRow, boolean pExpanded, boolean pLeaf) throws Throwable
   {
      
      if (pDataBook == rdbPdvePdversion)
      {
         return (UIImage)(pDataRow.getValue("PDVE_DSST_ICON"));
      }

      return null;

   }


PDVE_DSST_ICON is an Image Field which show correctly as a field in the Form.

What is going wrong? Any idea?

Luc
lucdep
 
Posts: 47
Joined: Wed Oct 10, 2018 12:01 pm

Re: Icon on Node in Tree object

Postby Support@SIB » Thu Aug 29, 2019 7:31 pm

Did you press "Apply external changes" in VisionX? It's necessary to tell VisionX that you changed the application "outside". This should solve the problem with pink.png.

Are you sure that your column: PDVE_DSST_ICON contains an instance of UIImage?

If you use static images, please cache them and don't create new instances every time. It's not super fast and consumes more memory than needed. If you have dynamic images, saved in the database, it's clear but a cache could improve performance as well.
User avatar
Support@SIB
 
Posts: 315
Joined: Mon Sep 28, 2009 1:56 pm

Re: Icon on Node in Tree object

Postby lucdep » Thu Aug 29, 2019 7:44 pm

Hi,

Code: Select all
rdbPdvePdversion.getRowDefinition().getColumnDefinition("PDVE_DSST_ICON").getDataType().setCellEditor(ProjXUtil.IMAGE_VIEWER);
.....

editPdvePdversionPdveDsstIcon.setDataRow(rdbPdvePdversion);
editPdvePdversionPdveDsstIcon.setColumnName("PDVE_DSST_ICON");
editPdvePdversionPdveDsstIcon.setForeground(null);


The column PDVE_DSST_ICON contains an uploaded image and shows it OK in editPdvePdversionPdveDsstIcon field.

I want however to show the status icon of all entries in the Tree object as well.

The Icons are uploaded by the users when the create the different possible status in a linked table Dsst_Design_Status (which contains the columns ID, Status_Name and Icon)

I have catched the exception on

Code: Select all
return (UIImage)(pDataRow.getValue("PDVE_DSST_ICON"));


which is : java.lang.ClassCastException: class [B cannot be cast to class javax.rad.genui.UIImage ([B is in module java.base of loader 'bootstrap'; javax.rad.genui.UIImage is in unnamed module of loader java.net.URLClassLoader @5fd0d5ae)
Luc
lucdep
 
Posts: 47
Joined: Wed Oct 10, 2018 12:01 pm

Re: Icon on Node in Tree object

Postby Support@SIB » Thu Aug 29, 2019 8:43 pm

Clear, because it's a binary column. The Image viewer takes care of the data type and shows an image instead of the binary content. One advantage of JVx.

So, simply create an image, e.g.

Code: Select all
new UIImage(BinaryDataType.getContent(getValue("COLUMN"));

and a cache would be useful if images don't change too often. Otherwise the image will be created very often!

You could add a memory column to your databook, before open like this:

Code: Select all
book.getRowDefinition().addColumnDefinition(new ColumnDefinition("UIIMAGE", new ObjectDataType()));
book.open();

...

book.setValue("UIIMAGE", image);

if temp image is null, create a new instance, otherwise reuse it... Just an idea.
User avatar
Support@SIB
 
Posts: 315
Joined: Mon Sep 28, 2009 1:56 pm

Re: Icon on Node in Tree object

Postby lucdep » Wed Sep 11, 2019 1:02 pm

Thanks, works perfectly.
lucdep
 
Posts: 47
Joined: Wed Oct 10, 2018 12:01 pm


Return to VisionX