mainwindow-----getTool Method

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

mainwindow-----getTool Method

oceangis
hi,

the method "getTool" in mainwindow:

    public boolean getTool(TBButton tb) {
        TBButton[] buttonList;
        for (int i = 0; i < toolbars.length; i++) {
            buttonList = toolbars[i].getAllButtons();
            for (int j = 0; j < buttonList.length; j++){//All buttons in the ToolBar including all existing ones in the combo list
                if (buttonList[j].equals(tb)){
                    //Tool has been found
                    return true;
                }
            }
        }
        return false;
    }


To change "if (buttonList[j].equals(tb))" to "if (buttonList[j]!=null && buttonList[j].equals(tb))" is more suitibale, the result come from getAllButtons may contain null.

--
Xia Tao


_______________________________________________
gvSIG-desktop-devel mailing list
[hidden email]
https://lists.forge.osor.eu/listinfo/gvsig-desktop-devel
Reply | Threaded
Open this post in threaded view
|

Re: mainwindow-----getTool Method

Juan Lucas Domínguez
Hello, Xia Tao.
thanks for sharing this.
We'll change it too.
 
Regards,
Juan Lucas Domínguez Rubio
---
Prodevelop SL, Valencia (España)
Tlf.: 96.351.06.12 -- Fax: 96.351.09.68
http://www.prodevelop.es
---


De: [hidden email] en nombre de tao xia
Enviado el: lun 16/05/2011 16:19
Para: [hidden email]
Asunto: [gvSIG-devel] mainwindow-----getTool Method

hi,

the method "getTool" in mainwindow:

    public boolean getTool(TBButton tb) {
        TBButton[] buttonList;
        for (int i = 0; i < toolbars.length; i++) {
            buttonList = toolbars[i].getAllButtons();
            for (int j = 0; j < buttonList.length; j++){//All buttons in the ToolBar including all existing ones in the combo list
                if (buttonList[j].equals(tb)){
                    //Tool has been found
                    return true;
                }
            }
        }
        return false;
    }


To change "if (buttonList[j].equals(tb))" to "if (buttonList[j]!=null && buttonList[j].equals(tb))" is more suitibale, the result come from getAllButtons may contain null.

--
Xia Tao


_______________________________________________
gvSIG-desktop-devel mailing list
[hidden email]
https://lists.forge.osor.eu/listinfo/gvsig-desktop-devel
Reply | Threaded
Open this post in threaded view
|

Re: mainwindow-----getTool Method

Jorge Piera Llodrá
In reply to this post by oceangis
Cool!

You can create a ticket and attach a patch like is described in [1]

Regards,
Jorge

[1] http://www.gvsig.org/web/projects/gvsig-desktop/docs/devel/como-contribuir-en-gvsig/contribuciones-y-parches-al-codigo-de-gvsig/contributions-and-patches-to-the-gvsig-code/view?set_language=en

El 16/05/2011 16:19, tao xia escribió:
hi,

the method "getTool" in mainwindow:

    public boolean getTool(TBButton tb) {
        TBButton[] buttonList;
        for (int i = 0; i < toolbars.length; i++) {
            buttonList = toolbars[i].getAllButtons();
            for (int j = 0; j < buttonList.length; j++){//All buttons in the ToolBar including all existing ones in the combo list
                if (buttonList[j].equals(tb)){
                    //Tool has been found
                    return true;
                }
            }
        }
        return false;
    }


To change "if (buttonList[j].equals(tb))" to "if (buttonList[j]!=null && buttonList[j].equals(tb))" is more suitibale, the result come from getAllButtons may contain null.

--
Xia Tao

_______________________________________________ gvSIG-desktop-devel mailing list [hidden email] https://lists.forge.osor.eu/listinfo/gvsig-desktop-devel


-- 
Jorge Piera Llodrá
gvSIG Development Team 
PRODEVELOP 
Plaza Don Juan de Villarrasa, 14 - 5 
46001 Valencia 
Tel: +34 963510612 
Fax: +34 963510908 
e-mail: [hidden email] 
http://www.prodevelop.es 
http://www.gvsig.org 

_______________________________________________
gvSIG-desktop-devel mailing list
[hidden email]
https://lists.forge.osor.eu/listinfo/gvsig-desktop-devel