You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Camilo Casadiego <Ca...@adv.co> on 2012/02/14 20:57:46 UTC

TableViewMultiCellRenderer doubt

Hi there...I was guessing if someone has an example of  <content:TableViewMultiCellRenderer/>, i need to render pushButtons and some other controls on a table any ideas?


Cordialmente,

[cid:image001.png@01CCEB29.0313FD90]

Camilo Casadiego Espitia
Arquitecto de SW
* + 57 1 6393000
* camilo.casadiego@adv.com.co<ma...@adv.com.co>
* http://www.adv.com.co<http://www.adv.com.co/>
Carrera 11 No. 93 - 53 P7
Bogotá - Colombia




RE: TableViewMultiCellRenderer doubt

Posted by Camilo Casadiego <Ca...@adv.co>.
thanks a lot...a just found the row editor example and managed to get what I neede...which is a complex editable table :s again tank u very mucnh!


Cordialmente,

[cid:image002.png@01CCEB3C.E582A010]

Camilo Casadiego Espitia
Arquitecto de SW
* + 57 1 6393000
* camilo.casadiego@adv.com.co<ma...@adv.com.co>
* http://www.adv.com.co<http://www.adv.com.co/>
Carrera 11 No. 93 - 53 P7
Bogotá - Colombia



De: Roger L. Whitcomb [mailto:Roger.Whitcomb@actian.com]
Enviado el: Tuesday, February 14, 2012 4:51 PM
Para: user@pivot.apache.org
Asunto: RE: TableViewMultiCellRenderer doubt

Hi Camilo,
                Inside a TableView, each row of data is displayed with a Renderer, which is an inactive component, in that it doesn't respond to mouse or keyboard interaction.  It is only used to format and display the data.  If you want to actually interact with the data then you need to implement a TableViewRowEditor, which gets invoked (by default) when the user double clicks on a row.  There are examples in the source code on how to do this.  There are also some tricks you can use for simple interaction (such as with a checkbox) that don't require a full row editor (and again the source and tutorials have examples).  Depending on what you need the button to do in this case, you might be able to just put a ComponentMouseButtonListener on your TableView, decide what column is being clicked in and simulate what the button would do in that code.
                Hope that helps.

~Roger Whitcomb

From: Camilo Casadiego [mailto:Camilo.Casadiego@adv.co]
Sent: Tuesday, February 14, 2012 1:40 PM
To: user@pivot.apache.org<ma...@pivot.apache.org>
Subject: RE: TableViewMultiCellRenderer doubt

Actually I managed to get to it...But the button seams to be frozen :s

the page look like this...

[cid:image003.png@01CCEB3C.E582A010]

and my class goes like this... any ideas??

package co.com.adv.salarix.operations.framework.pivot.content;

import org.apache.pivot.beans.BeanAdapter;
import org.apache.pivot.collections.Dictionary;
import org.apache.pivot.wtk.BoxPane;
import org.apache.pivot.wtk.Button;
import org.apache.pivot.wtk.ButtonPressListener;
import org.apache.pivot.wtk.HorizontalAlignment;
import org.apache.pivot.wtk.PushButton;
import org.apache.pivot.wtk.TableView;
import org.apache.pivot.wtk.VerticalAlignment;

import co.com.adv.salarix.operations.framework.pivot.content.CustomTableView.ConfirmButtonAction;

public class TableViewPushButtonCellRenderer extends BoxPane implements TableView.CellRenderer{


                private PushButton pushButton = new PushButton();
    private boolean pushButtonDisabled = false;

    public TableViewPushButtonCellRenderer(){
                add(pushButton);

        getStyles().put("padding", 3);
        getStyles().put("verticalAlignment", VerticalAlignment.CENTER);
        getStyles().put("horizontalAlignment", HorizontalAlignment.CENTER);
    }

    @Override
    public void setSize(int width, int height) {
        super.setSize(width, height);

        // Since this component doesn't have a parent, it won't be validated
        // via layout; ensure that it is valid here
        validate();
    }

    @SuppressWarnings("unchecked")
    @Override
    public void render(Object row, int rowIndex, int columnIndex,
        TableView tableView, String columnName,
        boolean selected, boolean highlighted, boolean disabled) {
                if (row != null) {
            boolean checkboxSelected = false;

            // Get the row and cell data
            if (columnName != null) {
                Dictionary<String, Object> rowData;
                if (row instanceof Dictionary<?, ?>) {
                    rowData = (Dictionary<String, Object>)row;
                } else {
                    rowData = new BeanAdapter(row);
                }

                Object cellData = rowData.get(columnName);

                if (cellData instanceof String) {
                    cellData = Boolean.parseBoolean((String)cellData);
                }

                if (cellData instanceof Boolean) {
                    checkboxSelected = (Boolean)cellData;
                }else if(cellData instanceof PushButton){
                                PushButton incomingButton = (PushButton) cellData;
                                this.pushButton.setButtonData(incomingButton.getButtonData());
                                this.pushButton.getButtonPressListeners().add(new ConfirmButtonAction());
                } else {
                    System.err.println("Data for \"" + columnName + "\" is not an instance of "
                        + Boolean.class.getName());
                }
            }
            //pushButton.setSelected(checkboxSelected);
            //pushButton.setEnabled(!pushButtonDisabled && tableView.isEnabled() && !disabled);
            pushButton.setEnabled(true);
        }

                }

                @Override
                public String toString(Object row, String columnName) {
                                // TODO Auto-generated method stub
                                return null;
                }

                class ConfirmButtonAction implements ButtonPressListener {

                                @Override
                                public void buttonPressed(Button arg0) {
                                                // TODO Auto-generated method stub
                                                System.out.println("presiono el boton!");

                                }}

}


Cordialmente,

[cid:image002.png@01CCEB3C.E582A010]

Camilo Casadiego Espitia
Arquitecto de SW
* + 57 1 6393000
* camilo.casadiego@adv.com.co<ma...@adv.com.co>
* http://www.adv.com.co<http://www.adv.com.co/>
Carrera 11 No. 93 - 53 P7
Bogotá - Colombia



De: Luiz Gustavo [mailto:luizgustavoss@gmail.com]
Enviado el: Tuesday, February 14, 2012 4:28 PM
Para: user@pivot.apache.org<ma...@pivot.apache.org>
Asunto: Re: TableViewMultiCellRenderer doubt

Hi Camilo,


in the Sample Application is possible to see a table view with checkboxes, so I think it's possible to use other components in a table view. Not sure!


Luiz Gustavo S. de Souza

http://luizgustavoss.wordpress.com<http://luizgustavoss.wordpress.com/>
2012/2/14 Camilo Casadiego <Ca...@adv.co>>
Hi there...I was guessing if someone has an example of  <content:TableViewMultiCellRenderer/>, i need to render pushButtons and some other controls on a table any ideas?


Cordialmente,

[cid:image002.png@01CCEB3C.E582A010]

Camilo Casadiego Espitia
Arquitecto de SW
* + 57 1 6393000<tel:%2B%2057%201%206393000>
* camilo.casadiego@adv.com.co<ma...@adv.com.co>
* http://www.adv.com.co<http://www.adv.com.co/>
Carrera 11 No. 93 - 53 P7
Bogotá - Colombia






--

RE: TableViewMultiCellRenderer doubt

Posted by "Roger L. Whitcomb" <Ro...@actian.com>.
Hi Camilo,

                Inside a TableView, each row of data is displayed with a Renderer, which is an inactive component, in that it doesn't respond to mouse or keyboard interaction.  It is only used to format and display the data.  If you want to actually interact with the data then you need to implement a TableViewRowEditor, which gets invoked (by default) when the user double clicks on a row.  There are examples in the source code on how to do this.  There are also some tricks you can use for simple interaction (such as with a checkbox) that don't require a full row editor (and again the source and tutorials have examples).  Depending on what you need the button to do in this case, you might be able to just put a ComponentMouseButtonListener on your TableView, decide what column is being clicked in and simulate what the button would do in that code.

                Hope that helps.

 

~Roger Whitcomb

 

From: Camilo Casadiego [mailto:Camilo.Casadiego@adv.co] 
Sent: Tuesday, February 14, 2012 1:40 PM
To: user@pivot.apache.org
Subject: RE: TableViewMultiCellRenderer doubt

 

Actually I managed to get to it...But the button seams to be frozen :s 

 

the page look like this...

 

 

 

and my class goes like this... any ideas??

 

package co.com.adv.salarix.operations.framework.pivot.content;

 

import org.apache.pivot.beans.BeanAdapter;

import org.apache.pivot.collections.Dictionary;

import org.apache.pivot.wtk.BoxPane;

import org.apache.pivot.wtk.Button;

import org.apache.pivot.wtk.ButtonPressListener;

import org.apache.pivot.wtk.HorizontalAlignment;

import org.apache.pivot.wtk.PushButton;

import org.apache.pivot.wtk.TableView;

import org.apache.pivot.wtk.VerticalAlignment;

 

import co.com.adv.salarix.operations.framework.pivot.content.CustomTableView.ConfirmButtonAction;

 

public class TableViewPushButtonCellRenderer extends BoxPane implements TableView.CellRenderer{

                

                

                private PushButton pushButton = new PushButton();

    private boolean pushButtonDisabled = false;

    

    public TableViewPushButtonCellRenderer(){

                add(pushButton);

 

        getStyles().put("padding", 3);

        getStyles().put("verticalAlignment", VerticalAlignment.CENTER);

        getStyles().put("horizontalAlignment", HorizontalAlignment.CENTER);

    }

 

    @Override

    public void setSize(int width, int height) {

        super.setSize(width, height);

 

        // Since this component doesn't have a parent, it won't be validated

        // via layout; ensure that it is valid here

        validate();

    }

 

    @SuppressWarnings("unchecked")

    @Override

    public void render(Object row, int rowIndex, int columnIndex,

        TableView tableView, String columnName,

        boolean selected, boolean highlighted, boolean disabled) {

                if (row != null) {

            boolean checkboxSelected = false;

 

            // Get the row and cell data

            if (columnName != null) {

                Dictionary<String, Object> rowData;

                if (row instanceof Dictionary<?, ?>) {

                    rowData = (Dictionary<String, Object>)row;

                } else {

                    rowData = new BeanAdapter(row);

                }

 

                Object cellData = rowData.get(columnName);

 

                if (cellData instanceof String) {

                    cellData = Boolean.parseBoolean((String)cellData);

                }

 

                if (cellData instanceof Boolean) {

                    checkboxSelected = (Boolean)cellData;

                }else if(cellData instanceof PushButton){

                                PushButton incomingButton = (PushButton) cellData;

                                this.pushButton.setButtonData(incomingButton.getButtonData());

                                this.pushButton.getButtonPressListeners().add(new ConfirmButtonAction());

                } else {

                    System.err.println("Data for \"" + columnName + "\" is not an instance of "

                        + Boolean.class.getName());

                }

            }

            //pushButton.setSelected(checkboxSelected);

            //pushButton.setEnabled(!pushButtonDisabled && tableView.isEnabled() && !disabled);

            pushButton.setEnabled(true);

        }

                                

                }

 

                @Override

                public String toString(Object row, String columnName) {

                                // TODO Auto-generated method stub

                                return null;

                }

                

                class ConfirmButtonAction implements ButtonPressListener {

 

                                @Override

                                public void buttonPressed(Button arg0) {

                                                // TODO Auto-generated method stub

                                                System.out.println("presiono el boton!");

                                                

                                }}

 

}

 

 

Cordialmente,

 

 

Camilo Casadiego Espitia

Arquitecto de SW

( + 57 1 6393000 

* camilo.casadiego@adv.com.co

: http://www.adv.com.co <http://www.adv.com.co/> 

Carrera 11 No. 93 - 53 P7

Bogotá - Colombia

 

 

De: Luiz Gustavo [mailto:luizgustavoss@gmail.com] 
Enviado el: Tuesday, February 14, 2012 4:28 PM
Para: user@pivot.apache.org
Asunto: Re: TableViewMultiCellRenderer doubt

 

Hi Camilo,


in the Sample Application is possible to see a table view with checkboxes, so I think it's possible to use other components in a table view. Not sure!


Luiz Gustavo S. de Souza

http://luizgustavoss.wordpress.com <http://luizgustavoss.wordpress.com/> 

2012/2/14 Camilo Casadiego <Ca...@adv.co>

Hi there...I was guessing if someone has an example of  <content:TableViewMultiCellRenderer/>, i need to render pushButtons and some other controls on a table any ideas?

 

 

Cordialmente,

 



Camilo Casadiego Espitia

Arquitecto de SW

( + 57 1 6393000 <tel:%2B%2057%201%206393000>  

* camilo.casadiego@adv.com.co

: http://www.adv.com.co <http://www.adv.com.co/> 

Carrera 11 No. 93 - 53 P7

Bogotá - Colombia

 

 




-- 




RE: TableViewMultiCellRenderer doubt

Posted by Camilo Casadiego <Ca...@adv.co>.
Actually I managed to get to it...But the button seams to be frozen :s

the page look like this...

[cid:image002.png@01CCEB37.4478AE30]

and my class goes like this... any ideas??

package co.com.adv.salarix.operations.framework.pivot.content;

import org.apache.pivot.beans.BeanAdapter;
import org.apache.pivot.collections.Dictionary;
import org.apache.pivot.wtk.BoxPane;
import org.apache.pivot.wtk.Button;
import org.apache.pivot.wtk.ButtonPressListener;
import org.apache.pivot.wtk.HorizontalAlignment;
import org.apache.pivot.wtk.PushButton;
import org.apache.pivot.wtk.TableView;
import org.apache.pivot.wtk.VerticalAlignment;

import co.com.adv.salarix.operations.framework.pivot.content.CustomTableView.ConfirmButtonAction;

public class TableViewPushButtonCellRenderer extends BoxPane implements TableView.CellRenderer{


                private PushButton pushButton = new PushButton();
    private boolean pushButtonDisabled = false;

    public TableViewPushButtonCellRenderer(){
                add(pushButton);

        getStyles().put("padding", 3);
        getStyles().put("verticalAlignment", VerticalAlignment.CENTER);
        getStyles().put("horizontalAlignment", HorizontalAlignment.CENTER);
    }

    @Override
    public void setSize(int width, int height) {
        super.setSize(width, height);

        // Since this component doesn't have a parent, it won't be validated
        // via layout; ensure that it is valid here
        validate();
    }

    @SuppressWarnings("unchecked")
    @Override
    public void render(Object row, int rowIndex, int columnIndex,
        TableView tableView, String columnName,
        boolean selected, boolean highlighted, boolean disabled) {
                if (row != null) {
            boolean checkboxSelected = false;

            // Get the row and cell data
            if (columnName != null) {
                Dictionary<String, Object> rowData;
                if (row instanceof Dictionary<?, ?>) {
                    rowData = (Dictionary<String, Object>)row;
                } else {
                    rowData = new BeanAdapter(row);
                }

                Object cellData = rowData.get(columnName);

                if (cellData instanceof String) {
                    cellData = Boolean.parseBoolean((String)cellData);
                }

                if (cellData instanceof Boolean) {
                    checkboxSelected = (Boolean)cellData;
                }else if(cellData instanceof PushButton){
                                PushButton incomingButton = (PushButton) cellData;
                                this.pushButton.setButtonData(incomingButton.getButtonData());
                                this.pushButton.getButtonPressListeners().add(new ConfirmButtonAction());
                } else {
                    System.err.println("Data for \"" + columnName + "\" is not an instance of "
                        + Boolean.class.getName());
                }
            }
            //pushButton.setSelected(checkboxSelected);
            //pushButton.setEnabled(!pushButtonDisabled && tableView.isEnabled() && !disabled);
            pushButton.setEnabled(true);
        }

                }

                @Override
                public String toString(Object row, String columnName) {
                                // TODO Auto-generated method stub
                                return null;
                }

                class ConfirmButtonAction implements ButtonPressListener {

                                @Override
                                public void buttonPressed(Button arg0) {
                                                // TODO Auto-generated method stub
                                                System.out.println("presiono el boton!");

                                }}

}


Cordialmente,

[cid:image003.png@01CCEB37.4478AE30]

Camilo Casadiego Espitia
Arquitecto de SW
* + 57 1 6393000
* camilo.casadiego@adv.com.co<ma...@adv.com.co>
* http://www.adv.com.co<http://www.adv.com.co/>
Carrera 11 No. 93 - 53 P7
Bogotá - Colombia



De: Luiz Gustavo [mailto:luizgustavoss@gmail.com]
Enviado el: Tuesday, February 14, 2012 4:28 PM
Para: user@pivot.apache.org
Asunto: Re: TableViewMultiCellRenderer doubt

Hi Camilo,


in the Sample Application is possible to see a table view with checkboxes, so I think it's possible to use other components in a table view. Not sure!


Luiz Gustavo S. de Souza

http://luizgustavoss.wordpress.com<http://luizgustavoss.wordpress.com/>

2012/2/14 Camilo Casadiego <Ca...@adv.co>>
Hi there...I was guessing if someone has an example of  <content:TableViewMultiCellRenderer/>, i need to render pushButtons and some other controls on a table any ideas?


Cordialmente,

[cid:image003.png@01CCEB37.4478AE30]

Camilo Casadiego Espitia
Arquitecto de SW
* + 57 1 6393000<tel:%2B%2057%201%206393000>
* camilo.casadiego@adv.com.co<ma...@adv.com.co>
* http://www.adv.com.co<http://www.adv.com.co/>
Carrera 11 No. 93 - 53 P7
Bogotá - Colombia






--



Re: TableViewMultiCellRenderer doubt

Posted by Luiz Gustavo <lu...@gmail.com>.
Hi Camilo,


in the Sample Application is possible to see a table view with checkboxes,
so I think it's possible to use other components in a table view. Not sure!


Luiz Gustavo S. de Souza

http://luizgustavoss.wordpress.com


2012/2/14 Camilo Casadiego <Ca...@adv.co>

> Hi there...I was guessing if someone has an example of
>  <content:TableViewMultiCellRenderer/>, i need to render pushButtons and
> some other controls on a table any ideas?****
>
> ** **
>
> ** **
>
> *Cordialmente,*****
>
>  ****
>
> [image: ::::ADV_Logo_CMYK300_Color.png]****
>
> *Camilo Casadiego Espitia***
>
> *Arquitecto de SW*****
>
> *(* + 57 1 6393000 ****
>
> * camilo.casadiego@adv.com.co****
>
> *:* http://www.adv.com.co****
>
> Carrera 11 No. 93 – 53 P7****
>
> Bogotá - Colombia****
>
> ** **
>
> ** **
>



--