Skip to main content

Plugin para verificar el estado de un sitio web

Desarrollaremos un simple plugin para NetBeans que verifica si un sitio web esta activo, es un modulo de carácter educativo por lo cual me he enfocado en la simplicidad desarrollando Action atraves de clases directas sin utilizar el asistente Action.
Creamos un proyecto Modulo

Indicamos el nombre


indicamos el nombre del paquete ,marcamos Generar capa XML


El IDE crea el proyecto



Crear una clase MyAccion.java


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
Definimos los tipos de
mensajes a desplegar
/**
*
* @author avbravo
*/
public class MyAccion implements ActionListener {
public void actionPerformed(ActionEvent e) {
// TODO implement action body
String msg = "Servidor Gbi funcionando!";
int msgType = NotifyDescriptor.INFORMATION_MESSAGE;
int msgTypeError = NotifyDescriptor.ERROR_MESSAGE;
try {
URL url = new URL("http://www.google.com/");
URLConnection urlConnection = url.openConnection();
Indicamos el sitio a conectarse
BufferedReader in = new BufferedReader(new
InputStreamReader(urlConnection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
//System.out.println("" + inputLine);
break;
}
Mensaje("Conexión a google exitosa", msgType);
} catch (MalformedURLException me) {
Mensaje("MalformedURLException: " + me.getLocalizedMessage().toString(),
msgTypeError);
} catch (IOException ioe) {
Mensaje("IOException: " + ioe.getLocalizedMessage().toString(), msgTypeError);
}
}

private void Mensaje(String msg, int msgType) {
try {
NotifyDescriptor d = new NotifyDescriptor.Message(msg, msgType);
DialogDisplayer.getDefault().notify(d);
} catch (Exception ex) {
}
}
}

Agregamos las bibliotecas



Agregamos una imagen de 16x16 pixeles


Editamos el archivo layer.xml


Instalamos el plugin


Se carga el icono en el barra del IDE

Al darle click nos muestra el mensaje

Comments

Anonymous said…
mil gracias por la informacion
trompeteandos said…
Puedes facilitar el contenido de layer.xml
Trompe said…
Puedes publicar el contenido del fichero layer.xml

Popular posts from this blog

Primefaces v13

 La versión nueva de primefaces v13.0 elimina el componente <p:repeat>  Consulte los cambios en  https://github.com/primefaces/primefaces/releases/tag/13.0.0 por lo tanto si necesita una solución similar considere utilizar  <p:carousel>  o  <ui:repeat> En la versión 13 genera una excepción

Jmoordb-Core @UpdateMany y @DeleteMany

 Jmoordb-Core @UpdateMany y @DeleteMany Estoy trabajando en una versión nueva de jmoordb-core en la cual se estará implementando nuevas funcionalidades como lo son @DeleteMany y    @UpdateMany con la finalidad de hacer operaciones sobre múltiples documentos de la colección.