Compiling and debugging an example plugin for gvSIG 2.1.0 from an IDE (NetBeans)

English translation of the article by Joaquin del Cerro.

Hi everyone,

I´m back to explain to you, how download the sources of one of the gvSIG project´s example and how compile it and debug it.

In this article, I will use as IDE Netbeans 8, which is the IDE that normally I use for developing with gvSIG long time ago. In the future, I will install an Eclipse and in another post I will tell you how to work with it. Anyway, if you are a developer used to Eclipse, it would not be difficult to take the explained ideas.

Keep in mind that this post doesn´t want to be a NetBeans tutorial, just to explain the steps to follow for being able to download and compile gvSIG plugin with it.

Once you have already followed the steps described in the post  “Como descargar y compilar gvSIG 2.1.0 en Linux y Windows“ and we have all the basic tools installed and set up, we can carry on.

To follow this post, we need internet access. In general, for compiling gvSIG we need internet access. And also:

  • An Installable of gvSIG, in my case “gvSIG-desktop-2.1.0-2262-testing-win-x86-standard-withjre.exe”
  • An Installable of NetBeans

First of all, we install IDE, NetBeans.

I´ve downloaded it from the NetBeans official website, in downloads:

https://netbeans.org/downloads/

We will find a few distributions availables for downloading:

  • Java SE
  • Java EE
  • C/C++
  • HTML5 & PHP
  • All

With the distribution “Java SE” will be enough for compiling the majority of gvSIG projects (excluding the ones requiring natives, because they are out of this post´s scope)

Simply we will download it and proceed to install it.

Through the initial set up, it will ask us for two things, where are we going to install it and where is the JDK to use. In this case, we will choose the JDK which we have already installed like it was explained in “Como descargar y compilar gvSIG 2.1.0 en Linux y Windows“.

Once we have installed NetBeans, we will install gvSIG. It will be a standard setup but we will not install it in “Program Files”;, I advise you to install it inside c:/devel, folder, where we have already downloaded the gvSIG sources. I have installed in :

c:/devel/gvsig/2.1.0-2262

The reason of installing it out of “Program Files” is because in my Windows installation, the user doesn´t have administrator privileges and if I do it in there, I will have problems later when I try to deploy the plugin binaries over that installation. Writing on c:/devel folder (created by me), I will not have any privilege problems at all.

Once we have these two things installed, we change the pathfile on “.gvsig-devel.properties” for pointing to the installation of gvSIG which we have just done in “c:/devel”.

Well, one more thing to do. The actual distribution for Windows of gvSIG-desktop doesn´t include a launcher in gvSIG.sh of gvSIG. The launcher is only included in Linux distribution( in future distributions we will include it as well for Windows). Well, for the moment is not present, so we have two options, if we have alredy compiled “org.gvsig.desktop”, we can take it from “org.gvsig.desktop/target/product” folder or if we don´t have it on hand, we can download it from:

http://devel.gvsig.org/svn/gvsig-desktop/trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/resources-application/gvSIG.sh

We will leave it in the folder where we have installed gvSIG, along with the “gvsig-desktop.exe”.

Once we have these three things, we will boot NetBeans, then, downwnload the project “org.gvsig.landregistryviewer” and we will compile it. We will download it from the url:

http://devel.gvsig.org/svn/gvsig-plugintemplates/org.gvsig.landregistryviewer/trunk/org.gvsig.landregistryviewer/

To do it, we will go to menu:

Team->Subversion->Checkout…

netbeans-checkout1 It will show us the following screen:

netbeans-checkout2

Then, we will write in the field “Repository url” the value of the url (previously indicated) in where is the example project “org.gvsig.landregistryviewer”. We click on “Next”. It will show us the next page of the assistant, in which we should introduce the folder where we want to download the project. In our case, we will introduce “c:/devel”, and click on “Finish”.

netbeans-checkout3

When the project´s download finish, it will tell us about the maven projects presents in the donloaded project and it will ask us if we want to open any of them. The screen dialogue will be something like:

netbeans-checkout4 We click on “Open project…” to indicate which of the projects we want to open and it will show us:

netbeans-checkout5 We will select the project “org.gvsig.landregistryviewer” and click on “Open”.

When we try to load the project for the first time, probably some error will appear due to the fact that some dependencies are not downloaded, showing us a message like:

netbeans-checkout6 We only clik on “Close”.

Now, we will compile the downloaded project. To do that, we select it in the “proyectos” view and click on “Build project” of the toolbar.

netbeans-checkout7 The bottom console will be showing the compiling messages and once the process finishes, we will have our plugin compiled and deployed over the gvSIG installation.

netbeans-checkout8

So far, we have seen how to prepare our work environment, download and compile the plugin. If we want to see our plugin in action, simply we will boot Console2, go to gvSIG installation folder, c:/devel/gvsig/2.1.0-2262, and run gvSIG.sh.

$ cd c:/devel/gvsig/2.1.0-2262
$ ./gvSIG.sh

Let´s see how to debug our plugin.

We will open the subproject “org.gvsig.landregistryviewer.app.mainplugin”.

netbeans-abrir-proyecto1 It could happen that the plugin doesn´t realise that there are all the dependencies needed, already downloades when the project has been compiled.If this happens, iw will show us:

netbeans-abrir-proyecto2 In this case, we click on “Resolve Problems…” for updating the dependencies. It will show us:

netbeans-abrir-proyecto3 We click on “Resolve…” and wait until the project update. When the update is finished, the atención signal should dissapear and we will close the dialog clicking on “Close”.

Now, we will load the class LandRegistryViewerExtension and put a breaking point at method´s start CreateViewWindow. To do this, we click twice in the line´s number.

netbeans-debug1 Once done the breaking point, we will go to Console2 and we will go to boot gvSIG, but passing before the parameters “–debug –pause”.

netbeans-debug4 This boots the JVM activating the debug for being able to connect with it.

netbeans-debug5 It is possible that depending of the firewall setting, it will show us a message or even that doesn´t work. We need to make sure that we allow the app java.exe to access to 8765 port.

Then, we will back to NetBeans, and connect to gvSIG in debug mode.

netbeans-debug2 It will ask us for connection data…..

netbeans-debug3 When click on “OK”, it will carry on with the running of gvSIG in debug. As we have put a breaking point, it will stop on it and we will be able to debug our plugin.

netbeans-debug7 If we need to see the code of gvSIG, we click on Ctrl-O and type the class name which we want to locate.For instance, if wew want to put a breaking point in the proect creation, we will type Ctrl-O y “DefaultProject”

netbeans-debug8 And click on “OK”.

netbeans-debug9 If it doesn´t show us the source code (automatically downloaded, well, depending of our NetBeans setting), we can click on “Attach Sources…” and then “Download”.

netbeans-debug10 Once all the sources needed have been downloaded, we close the window clicking on “OK”. It will show us the code for the class “DefaultProject” and we can put a breaking point in its builder.

netbeans-debug11 Well, that´s it for today…..

All I have talked about is related to Windows 7. For Linux developers, it´s quite easy to follow and you just need to change the path c:/devel for the one that you use to leave the sources.

For Eclipse developers, the steps to follow are similars, the most complicated issue could be the support setting of maven which has already NetBeans.

It´s a post quite long (a lot of screenshots), but I think that they could be helpful to follow up the article.

I hope it was useful,
Greetings to all and thank you!

Posted in development, english, gvSIG Desktop, gvSIG development | 1 Comment

How to download and compile a gvSIG 2.1.0 plugin

English translation of the article by Joaquin del Cerro.

Hello again,
In the previous article, Como descargar y compilar gvSIG 2.1.0 en Linux y Windows “How to download and compile gvSIG 2.1.0 on Linux and Windows” I left some stuff unclear. Among them, I didn´t comment at all on how to download and compile a gvSIG plugin.

Assuming that we have already been able to install and set up the development tools mentioned in the article, from that point, compile a plugin is pretty simple, the most complicated issue it could be to get the plugin sources to compile.

In the gvSIG project, as a platform for managing development projects tool, we use “redmine”, which can be found at:

In the “redmine”, we already have registered several projects, including the one for the gvSIG kernel, “Application: gvSIG desktop”. We can get a projects list at:

In almost all of them, we will find the url from which we can download the sources.
We have to consider that a “redmine” project can store more than one development project and this one, in turn, can contain several gvSIG plugins.

Let’s see now, how we would do to download and compile the gvSIG data provider for PostgreSQL.

Looking at the projects list, we will find one named “gvSIG data provider for PostgreSQL”.
We click on the link and it will show us the project page in the redmine. Right there, we will have a link that says something like:

SVN: http://devel.gvsig.org/svn/gvsig-postgresql

We surf to it, and we will find an url like:

http://devel.gvsig.org/svn/gvsig-postgresql/trunk/org.gvsig.postgresql/

We will have a “pom.xml” file, which would be the root of our plugin project. We have to get used that gvSIG projects are multimodule maven projects.

To compile it and run it is pretty simple.
First, we will need to have a previously installed gvSIG 2.1.0. We can use a normal installation of gvSIG or the gvSIG binaries that they were generated as described in the previous article.

If we already have them, we should go to our user HOME and check if there exists a file “.gvsig-devel.properties”. This file contains the path where to find our gvSIG installation to deploy in it the gvSIG binaries plugins that we will compile. If we have compiled the gvSIG kernel in that process, it will be have been created with the appropriate values. We will have in it, something like:

~ $ cd
~ $ cat .gvsig-devel.properties
#Fri Dec 12 00:13:47 CET 2014
gvsig.product.folder.path=C\:/devel/org.gvsig.desktop/target/product
~ $

If we do not have the file already created, simply we will just create it, allowing the entry “gvsig.product.folder.path” point to the gvSIG installation on which we want to deploy the plugin.

Once all of this has been set, simply we will open our Console2 with Busybox (already set up) and run:

~ $ cd c:/devel
~ $ svn checkout http://devel.gvsig.org/svn/gvsig-postgresql/trunk/org.gvsig.postgresql/
... exit svn command...
~ $ cd org.gvsig.postgresql
~ $ mvn install
... exit install command...

If we are in Linux, we only change the command “cd” to adapt to the folder where we want to leave the sources.

Well, this process downloads the sources, compiles them and deploys the binaries of our plugin on the folder which we will indicate in the file “.gvsig-devel.properties”.

On the one hand it will leave us:

    • In gvSIG/add-ons the plugin already installed and ready to be loaded at the next start of gvSIG.
    • In install the package with our plugin “.gvspkg” if we want to hand it to another user to install it with the Plugin Manager.

Now, we just have to start the gvSIG and it will boot with our plugin.

Keep in mind that if deployed on a gvSIG binaries generated from the source, to boot gvSIG we should boot it running the gvSIG.sh file (even in a Windows system), as it was remarked in the previous article, while if we want to deploy it in a standard installation, we will boot it as normally boots that distribution.

Well, that´s all for now.

As always, I hope that it would be useful for you.

Shortly, I will try to talk about “How to work with an IDE and debug gvSIG”/como trabajar con un IDE y depurar gvSIG.

Greetings to all and thank you

Posted in development, english, gvSIG Desktop | 1 Comment

Ejemplos realizados en el Taller de Scripting en las 10as Jornadas Internacionales de gvSIG

Buenas, teníamos pendiente de publicar los ejemplos realizados durante el Taller de Scripting en las 10as Jornadas Internacionales gvSIG el pasado Diciembre en Valencia.

Durante el taller vimos varios ejemplos sobre geoprocesos, empezando con el cálculo de un área de influencia e ir poco a poco añadiendo funcionalidades según nuestras necesidades.

Adjunto aquí la cartografía necesaria para seguir los siguientes scripts. Solo es necesario una capa de polígonos y una capa de puntos, podéis probarlos con vuestras capas propias.

Si no conoces el Módulo de Scripting, te explicamos paso a paso como cargar los scripts en este vídeo. En el código solamente deberéis de modificar la parte que aparece como ‘datos iniciales’, indicando la ruta donde se grabará la nueva capa. Estos scripts no modificarán las capas que tengáis cargadas. Para su correcto funcionamiento debéis tener la Vista activa y una capa seleccionada.

En los dos primeros ejemplos, podemos ver primero la creación de un área de influencia, y segundo, añadiendo un campo nuevo indicando la distancia de esos puntos a un punto de referencia.

Script 1: Buffer

Script 2: Buffer y nuevo campo con información espacial

taller_scripting_ejer_02

Script 2

Además, en el tercer ejemplo, añadimos una condición espacial. Esta condición es que solamente cree el área de influencia en aquellos puntos que intersectan con algún polígono de la capa seleccionada. En el ejemplo hace referencia a la capa ‘manzanas’, pero esta puede ser sustituida por cualquier capa de polígonos. Podemos ver en la simbología como evoluciona esta variable, pensando que el punto de referencia del ejemplo se encontraría en la parte inferior izquierda. También vemos que hay puntos donde no ha generado los buffers.

Script 3: Buffer, nuevo campo distancia y que cumplan la intersección.

taller_scripting_ejer_03

Script 3

Otra de las funciones que vimos fue, partiendo de una capa de puntos, crear una capa nueva de tipo línea que contuviera (en este caso una sola entidad para facilitar las cosas) una geometría con la unión de todos los puntos como vértices de la línea.

En el primer ejemplo pasando los vértices utilizando el orden de un campo ID que sería aleatorio, y en el segundo ejemplo, utilizando la capa de buffer creada en el script 3 y tomando como orden el campo de distancia para crear los vértices en la geometría línea.

Script 4: Convertir puntos a línea

taller_scripting_ejer_04

Script 4

 

Script 5: Convertir capa buffer a línea

taller_scripting_ejer_05

Script 5

Por último, un ejemplo que no dio tiempo de explicar durante el taller, la generación de líneas que proyectan a ese punto de referencia, haciendo distinción según la capa inicial sea de tipo puntos, líneas o polígonos.

Script 6: Líneas proyectadas

Capa inicial de líneas

Script 6: Capa inicial de líneas

Capa inicial de polígonos

Script 6: Capa inicial de polígonos

Podéis ver los vídeos del taller, en español e inglés, en los siguientes enlaces:

  • Español: 10as Jornadas Internacionales gvSIG: Taller 5, Scripting en gvSIG 2.1:

  • Inglés: 10th Int. gvSIG Conference: Workshop 5, Scripting on gvSIG 2.1:

Cualquier otra duda podéis preguntar por aquí, por las Listas de usuarios gvSIG o si es alguna duda concreta podéis contactar conmigo directamente en: omartinez@gvsig.com

Si estáis interesados en ver el resto de ponencias realizadas durante las Jornadas podéis consultarlas en el siguiente listado.

Espero que os sean de utilidad estos ejemplos.

Un saludo,

Óscar

Posted in development, events, gvSIG Desktop, scripting, spanish | 3 Comments

gvSIG 2.1: Biblioteca de símbolos de meteorología

Entre el gran número de novedades que encontraremos en gvSIG 2.1, además de todas las nuevas funcionalidades, migración de funcionalidades existentes en versiones anteriores y corrección de errores, el usuario de gvSIG encontrará un buen número de bibliotecas de símbolos que se unen a las ya existentes.

Estas bibliotecas de símbolos no vienen instaladas por defecto en gvSIG, ya que en muchos casos se trata de simbologías temáticas o específicas de determinadas áreas de aplicación; pero todas ellas van en la instalación base, con lo que no es necesaria la conexión a internet para poder instalarlas en nuestro gvSIG.

Hoy vamos a comentar una de estas librerías temáticas. Se trata de la denominada “Weather” y que permite integrar en gvSIG simbología para realizar mapas climáticos acorde al estándar definido por la Organización Meteorológica Mundial en su documento “WMO No. 485 – Manual on the Global Data Processing and Forecasting System Manual” (con versiones en inglés, español, francés y ruso).

Adicionalmente se ha tenido en cuenta el trabajo del grupo MetOceanDWG de OGC en relación a la simbología para representar la climatología.

Veamos en el siguiente vídeo como instalar la biblioteca “Weather”:

Posted in opinion | 3 Comments

Geocoding in gvSIG 2.1 using scripting and GeoPy

English translation of the article by Joaquin del Cerro.

Hi, I ‘m here again.
This time to speak about a very quick scripting .


A few days ago Oscar Martinez told me that he had seen a python library to access geocoding services , 
GeoPy ; but there was the problem that he was unable to use it in gvSIG … as it was designed for a newer python version than the one used in gvSIG.


While we were glancing , we realised that by changing few small things, it could become usable for the python version of gvSIG 2.1.0 .


To use
GeoPy you have just to install the library , which can be done by unzipping the  “geopy-1.7.1-patched-for-gvSIG-2.1.0.zip” file in the folder:

gvSIG/plugins/org.gvsig.scripting.app.extension/lib/

located in user home. If you have already executed gvSIG, it should be closed and restart .

In Linux you can find this folder in $ HOME , and for Windows in :

C: \ Document and Settings \ my_user
or
C: \ Users \ my_user

Once installed the library GeoPy it can be used quite simply. If you execute the gvSIG scripts “Composer” , and create a new one with the following code , then you can start testing without any problems.


from gvsig import *
from commonsdialog import *

from geopy.geocoders import get_geocoder_for_service

def main(*args):

  street = inputbox("Insert street","street")
  if street == None:
    return
    
  geolocator = get_geocoder_for_service("googlev3")

  location = geolocator().geocode(street)

  print(location.address)
  print((location.latitude, location.longitude))
 
  msgbox("Found:\n"+location.address+"\n"+str((location.latitude, location.longitude)))

You can perform more complex actions such as open a table containing street names and civic addressing, read them and go creating a shapefile with points provided by geolocalisation service, but for the moment you can go on playing with this.

Greetings to all

Posted in development, english, gvSIG Desktop, gvSIG development, scripting | Tagged , | 4 Comments

gvSIG 2.1: Biblioteca de símbolos de mapeo colectivo

“El territorio es el espacio socialmente construido”, con esta frase comienza el excelente “Manual de Mapeo Colectivo. Recursos cartográficos críticos para procesos de creación colaborativa” realizado por Iconoclasistas.

En este manual, con licencia Atribución-NoComercial-CompartirIgual 2.5, encontramos una simbología orientada a ser utilizada en los talleres de mapeo colectivo. Simbología que se aleja de la representación habitual de elementos geográficos para aportar una iconografía orientada a representaciones ideológicas.

Y aunque en origen la simbología diseñada está pensada para utilizarse de una forma más artesanal en los distintos talleres de mapeo, pensamos que puede ser muy interesante disponer de esta en un Sistema de Información Geográfica libre y que gvSIG sea también una herramienta para realizar este tipo de trabajos cartográficos colaborativos y de análisis de nuestra realidad social.

Por eso mismo ponemos a disposición de la comunidad, un nuevo complemento disponible para gvSIG 2.1, que no es otra cosa que una biblioteca de símbolos orientada al mapeo colectivo.

Esperamos que os guste.

A continuación os dejo un vídeo que muestra cómo instalar esta biblioteca (como es habitual, mediante el administrador de complementos).

Posted in gvSIG Desktop, spanish | Tagged , , | 11 Comments

Geocodificación en gvSIG 2.1 usando scripting y GeoPy

Hola, aquí estoy de nuevo.
Esta vez para contaros algo de scripting muy rapidito.

Hace un par de días Óscar Martínez me comento que había visto una librería python para acceder a servicios de geocodificación, GeoPy; pero tenía el problema que no podía usarla en gvSIG…ya que estaba pensada para una versión mas nueva de python que la que lleva gvSIG.

La cuestión es que estuvimos echándole un vistazo, y cambiando unas pequeñas cosas se podía adaptar para usarla en la versión de python que lleva gvSIG 2.1.0 .

Para usar  GeoPy simplemente hay que instalar la librería, cosa que podemos hacer descomprimiendo el archivo “geopy-1.7.1-patched-for-gvSIG-2.1.0.zip” en la carpeta:

gvSIG/plugins/org.gvsig.scripting.app.extension/lib/

que encontraremos en el home de nuestro usuario. Si tenemos ya arrancado gvSIG deberemos cerrarlo y volverlo a arrancar.

En Linux podemos encontrarla esta carpeta en $HOME, y en Windows en:

C:\Document and Settings\MI_USUARIO

O

C:\Users\MI_USUARIO

Una vez instalada la libreria GeoPy usarla es bastante simple. Si lanzamos el “Composer” de scripts de gvSIG y creamos uno nuevo con el siguiente código podremos empezar a hacer pruebas con ella fácilmente.


from gvsig import *
from commonsdialog import *

from geopy.geocoders import get_geocoder_for_service

def main(*args):

  calle = inputbox("Introduce la calle","Calle")
  if calle == None:
    return
    
  geolocator = get_geocoder_for_service("googlev3")

  location = geolocator().geocode(calle)

  print(location.address)
  print((location.latitude, location.longitude))
 
  msgbox("Encontrado:\n"+location.address+"\n"+str((location.latitude, location.longitude)))

Se pueden hacer cosas más complejas como, abrir una tabla de la que leer los nombres de calle e ir creando un shape con los puntos que nos devuelve el servicio de localización, pero de momento ya podéis ir jugando con esto.

Un saludo a todos

Posted in development, gvSIG Desktop, gvSIG development, scripting, spanish | 5 Comments

gvSIG 2.1: Dyschromatopsia / colour blindness extension

We have included an extension in gvSIG 2.1, that can be curious for a lot of users but it’s very interesting for users that have colour perception problems.

In fact we find this functionality essential in some fields, as the GIS software white book of the IACA (International Association of Crime Analysts) reflects. It includes an evaluation factor where “the system has to be prepared for the blindness common problems for colours”

The functionality of this add-on is very simple. From a view with a predetermined legend, we can transform that legend (or create a new one) in another legend that is interpretable by users with any problem related to dyschromatopsia or colour blindness

This extension can be installed from the add-ons manager in gvSIG. At this image you can see the name of the add-on:

dyschromatopsia

At this video you can see how it works:

Posted in english, gvSIG Desktop | 2 Comments

gvSIG 2.1: Symbol Library of urban interest points

As we mentioned in a previous post, for gvSIG 2.1 we have included a new set of symbol libraries. These libraries are also included among the basic installation packages (but they are not installed by default). What does that mean? We can install them at any time without even needing an internet connection.

One of these libraries, called POI Cities, includes a set of symbols that represent the main attractions of a city: parks, airports, subway stations, different types of shops, museums, monuments, etc.

It is based on the symbology that MapBox project uses and, specifically, in the library called Maki.

We show in a video how to install it and visualize the appearance of this new library. From now on your urban maps will be much more elegant.

Posted in english, gvSIG Desktop | Tagged | Comments Off on gvSIG 2.1: Symbol Library of urban interest points

Compilando y depurando un plugin de ejemplo para gvSIG 2.1.0 desde un IDE (NetBeans).

Hola a todos,
aquí estoy de vuelta para ver como podemos descargarnos los fuentes de uno de los proyectos de ejemplo de gvSIG y como podemos compilarlo y entrar en depuración de él.
En este artículo usaré como IDE Netbeans 8, que es el IDE que uso habitualmente para desarrollar con gvSIG desde hace un tiempo. Mas adelante me instalaré un Eclipse y, en otro artículo, contare como se haría con él. De todos modos si eres un desarrollador familiarizado con Eclipse no debería serte difícil trasladar las ideas que vaya exponiendo a él.

Ojo, esto no pretende ser un tutorial sobre NetBeans, solo contar los pasos para poder descargar y depurar un plugin de gvSIG con él.

Voy a suponer que ya has seguido los pasos descritos en el artículo “Como descargar y compilar gvSIG 2.1.0 en Linux y Windows“ y que ya tenemos las herramientas de base que se comentan ahí instaladas y configuradas.

Para seguir los pasos de este artículo necesitaremos acceso a internet. En general para compilar gvSIG necesitaremos acceso a internet. Y además necesitaremos:

  • Un instalable de gvSIG, en mi caso  “gvSIG-desktop-2.1.0-2262-testing-win-x86-standard-withjre.exe”
  • Un instalable de NetBeans

Lo primero instalaremos el IDE, NetBeans.
Yo me lo descargué de la web oficial de NetBeans directamente, de la sección descargas:

https://netbeans.org/downloads/

Nos encontraremos con varias distribuciones disponibles para descargar:

  • Java SE
  • Java EE
  • C/C++
  • HTML5 & PHP
  • All

Con la distribución “Java SE” será suficiente para compilar la gran mayoría de los proyectos de gvSIG (con la excepción de los proyectos que requieren nativas, que están fuera del alcance de este artículo).

Simplemente la descargaremos y procederemos a instalarla.
Durante la instalación nos solicitará básicamente dos cosas, dónde vamos a instalarlo y donde está el JDK a utilizar. En este último caso seleccionaremos el JDK que instalamos tal como comenté en “Como descargar y compilar gvSIG 2.1.0 en Linux y Windows“.

Una vez que ya tengamos instalado NetBeans, instalaremos gvSIG. Procederemos a hacer una instalación normal, pero no lo instalaremos en “Archivos de programa”; yo recomiendo instalarlo dentro de la carpeta c:/devel, donde ya descargamos los fuentes de gvSIG. Yo lo he instalado en:

c:/devel/gvsig/2.1.0-2262

El instalarlo fuera de “Archivos de programa”, es porque en mi instalación de Windows mi usuario no tiene permisos de administración y si lo hago ahí luego voy a tener algunos problemas cuando intente desplegar los binarios de mi plugin sobre esa instalación. Para escribir en la carpeta c:/devel, que he creado yo, no tendré problemas de permisos.

Una vez tengamos estas dos cosas instaladas, retocaremos el fichero “.gvsig-devel.properties” para que apunte a la instalación de gvSIG que acabamos de hacer en “c:/devel”.

Pues ya solo nos faltara una cosilla mas. En la distribución actual para Windows de gvSIG-desktop no se incluye en lanzador gvSIG.sh de gvSIG. Este solo se incluye en la distribución de Linux (en próximas distribuciones también lo incluiremos para Windows). Bueno, de momento no esta, así que tenemos dos opciones, si ya hemos compilado “org.gvsig.desktop” podemos cogerlo de la carpeta “org.gvsig.desktop/target/product” o si no lo tenemos a mano descargarlo desde:

http://devel.gvsig.org/svn/gvsig-desktop/trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/resources-application/gvSIG.sh

Y lo dejaremos en la carpeta donde instalamos gvSIG, junto al “gvsig-desktop.exe”.

Una vez tenemos ya estas tres cosas, podemos pasar a arrancar NetBeans.
Una vez arrancado descargaremos el proyecto “org.gvsig.landregistryviewer” y lo compilaremos. Lo descargaremos desde la url:

http://devel.gvsig.org/svn/gvsig-plugintemplates/org.gvsig.landregistryviewer/trunk/org.gvsig.landregistryviewer/

Para hacerlo, accederemos al menú:

Team->Subversion->Checkout…

netbeans-checkout1Nos presentará el siguiente cuadro de dialogo:

netbeans-checkout2

En el que introduciremos en el campo “Repository url” el valor de la url que he indicado antes en la que se encuentra el proyecto de ejemplo “org.gvsig.landregistryviewer”. Y le daremos a “Next”. Nos presentará la siguiente página del asistente en la que deberemos introducir la carpeta en la que queremos descargar el proyecto. En nuestro caso introduciremos “c:/devel”, y pulsaremos en “Finish”.

netbeans-checkout3

Terminada la descarga del proyecto nos informará de los proyectos maven que hay en el proyecto descargado y nos preguntará si queremos abrir alguno. El cuadro de diálogo será algo parecido al de la siguiente imagen:

netbeans-checkout4Pulsaremos en el botón “Open project…” para indicarle que proyectos queremos abrir y nos mostrara el siguiente diálogo.

netbeans-checkout5Seleccionaremos el proyecto “org.gvsig.landregistryviewer” y pulsaremos en el botón “Open”.
Al intentar cargar el proyecto la primera vez es fácil que se produzca algún error debido a que no estén descargadas algunas dependencias, mostrándonos un dialogo similar a este:

netbeans-checkout6Nos limitaremos a pulsar en “Close”.
Ahora simplemente nos limitaremos a compilar el proyecto que acabamos de descargar. Para ello lo seleccionaremos en la vista de “proyectos” y pulsaremos en el botón “Build project” de la barra de botones.

netbeans-checkout7En la consola inferior irá mostrando los mensajes de compilación y cuando termine tendremos compilado y desplegado nuestro plugin sobre la instalación de gvSIG.

netbeans-checkout8

Hasta aquí, hemos visto como preparar el entorno de trabajo, descargar y compilar el plugin. Si queremos ver en acción nuestro plugin simplemente arrancaremos Console2, iremos a la carpeta de la instalación de gvSIG, c:/devel/gvsig/2.1.0-2262, y ejecutaremos el gvSIG.sh.

$ cd c:/devel/gvsig/2.1.0-2262
$ ./gvSIG.sh

Vamos a ver como haríamos para depurar nuestro plugin.

Abriremos el subproyecto “org.gvsig.landregistryviewer.app.mainplugin”.

netbeans-abrir-proyecto1Podría suceder que el IDE no se haya percatado que ya tiene todas las dependencias que necesita y que descargo al compilar el proyecto. Si esto es así, nos presentará el siguiente cuadro de diálogo.

netbeans-abrir-proyecto2Si nos presenta este diálogo, pulsaremos en “Resolve Problems…” para que actualice las dependencias. Nos presentará el siguiente diálogo:

netbeans-abrir-proyecto3Simplemente pulsaremos en “Resolve…” y esperaremos a que termine de actualizar el proyecto. Cuando termine debería desaparecer la señal de atención de la lista de problemas, así que cerraremos el dialogo pulsando el botón “Close”.

Ahora cargaremos la clase LandRegistryViewerExtension y pondremos un punto de ruptura al inicio del método CreateViewWindow. Para ello simplemente haremos doble clic sobre el número de línea.

netbeans-debug1Una vez tengamos ya puesto el punto de ruptura, pasaremos a Console2 y nos dispondremos a arrancar gvSIG, pero le pasaremos los parámetros “–debug –pause”.

netbeans-debug4Esto arranca la JVM activando el debug para que podamos conectarnos a ella.

netbeans-debug5Es posible que según la configuración del firewall nos muestre un mensaje o incluso que no funcione esto. Deberemos asegurarnos que permitimos a la aplicación java.exe acceder al puerto 8765.

Una vez llegado aquí, volvemos al NetBeans, y nos enganchamos a gvSIG en modo depuración.

netbeans-debug2Nos pedirá los datos de conexión…

netbeans-debug3Y al darle a “OK” continuará la ejecución de gvSIG en modo depuración. Como hemos puesto un punto de ruptura se nos parará en él y podremos depurar nuestro plugin.

netbeans-debug7Si necesitamos ver el código de gvSIG, simplemente pulsamos Ctrl-O y tecleamos el nombre de la clase que queremos localizar. Por ejemplo, si quisiésemos poner un punto de ruptura en la creación del proyecto, teclearemos Ctrl-O y “DefaultProject”

netbeans-debug8Y pulsaremos en el botón “OK”.

netbeans-debug9Si no nos muestra el código fuente (que se lo descargue automáticamente depende de la configuración que tengamos en NetBeans), podremos pulsar en el botón “Attach Sources…” y pulsaremos en el botón “Download” del diálogo que nos aparezca.

netbeans-debug10Y cuando se haya descargado los fuentes que necesitemos, cerraremos la ventana pulsando en “OK”. Nos mostrará el código de la clase “DefaultProject” y podremos poner un punto de ruptura en su constructor.

netbeans-debug11Bueno, y hasta aquí llego por hoy…

Todo lo que he ido contando ha sido sobre un Windows 7. Los desarrolladores de Linux deberían poder seguirlo sin problemas, solo cambiando la ruta de c:/devel por la que utilicéis para dejar los fuentes.

Para los desarrolladores de Eclipse, los pasos son muy similares, lo mas complicado puede ser la configuración del soporte de maven que NetBeans trae ya de base. Por lo demás puede ser muy similar.

Me ha quedado un poco largo, sobre todo por las capturas de pantalla, pero he creído que podían ayudar a ir siguiendo el artículo.

Espero que os haya sido de utilidad.

Un saludo a todos.

Posted in development, gvSIG Desktop, gvSIG development, spanish | 9 Comments