⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 objectbrowsermethodlistener.java

📁 用于GIS(全球地理系统)的分析和处理的代码。
💻 JAVA
字号:
/*

 * This file is part of the GeOxygene project source files. 

 * 

 * GeOxygene aims at providing an open framework which implements OGC/ISO specifications for 

 * the development and deployment of geographic (GIS) applications. It is a open source 

 * contribution of the COGIT laboratory at the Institut G閛graphique National (the French 

 * National Mapping Agency).

 * 

 * See: http://oxygene-project.sourceforge.net 

 *  

 * Copyright (C) 2005 Institut G閛graphique National

 *

 * This library is free software; you can redistribute it and/or modify it under the terms

 * of the GNU Lesser General Public License as published by the Free Software Foundation; 

 * either version 2.1 of the License, or any later version.

 *

 * This library is distributed in the hope that it will be useful, but WITHOUT ANY 

 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 

 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

 *

 * You should have received a copy of the GNU Lesser General Public License along with 

 * this library (see file LICENSE if present); if not, write to the Free Software 

 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

 *  

 */



package fr.ign.cogit.geoxygene.util.browser;



import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.lang.reflect.Method;



/**

  * Cette classe fournit l'impl閙entation de l'閏outeur d'関閚ement pour les objets cliquables de type m閠hode.

  * <BR/>Elle permet l'invocation g閚閞ique des m閠hodes, sans param鑤res, en utilisant le package reflection du J2SDK. 

  *

  * @author Thierry Badard & Arnaud Braun

  * @version 1.0

  * 

  */



public class ObjectBrowserMethodListener implements ActionListener {

	

	/** Objet porteur de la m閠hode qui doit 阾re invoqu閑.*/

	private Object obj;

	/** M閠hode qui doit 阾re invoqu閑.*/

	private Method method;

	/** Nom de la m閠hode qui doit 阾re invoqu閑.*/

	private String methodName;



	/**

	 * Constructeur principal de l'閏outeur d'関閚ement ObjectBrowserMethodListener.

	 * 

	 * @param obj l'objet porteur de la m閠hode qui doit 阾re invoqu閑.

	 * @param method la m閠hode qui doit 阾re invoqu閑.

	 */

	public ObjectBrowserMethodListener(Object obj, Method method) {

		this.obj = obj;

		this.method = method;

		this.methodName = method.getName();

	}



	/**

	 * Red閒inition de la m閠hode actionPerformed() fournie par l'interface ActionListener, afin de d閏lencher 

	 * l'affichage de l'argument de retour de la m閠hode (instance de la classe ObjectBrowserPrimitiveFrame).

	 */

	public void actionPerformed(ActionEvent e) {

		

		Object[] nulObjArray = {};

		Class methodReturnType = this.method.getReturnType();

		String returnedStringValue;



		if ((methodReturnType.getName() == "java.lang.String")

			|| (methodReturnType.isPrimitive())) {

			try {

				try {

					returnedStringValue =

						(this.method.invoke(this.obj, nulObjArray)).toString();

					ObjectBrowserPrimitiveFrame result =

						new ObjectBrowserPrimitiveFrame(

							methodName,

							returnedStringValue);

				} catch (NullPointerException npex) {

					ObjectBrowserNullPointerFrame nullFrame =

						new ObjectBrowserNullPointerFrame();

				}

			} catch (Exception ex) {

				ObjectBrowserIllegalAccessFrame illegalAccessFrame =

					new ObjectBrowserIllegalAccessFrame();

				//ex.printStackTrace();

			}

		} else {

			try {

				try {

					ObjectBrowser.browse(

						this.method.invoke(this.obj, nulObjArray));

				} catch (NullPointerException npex) {

					ObjectBrowserNullPointerFrame nullFrame =

						new ObjectBrowserNullPointerFrame();

				}

			} catch (Exception ex) {

				ObjectBrowserIllegalAccessFrame illegalAccessFrame =

					new ObjectBrowserIllegalAccessFrame();

				//ex.printStackTrace();

			}

		}



	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -