001: /*
002: * This file is part of the GeOxygene project source files.
003: *
004: * GeOxygene aims at providing an open framework which implements OGC/ISO specifications for
005: * the development and deployment of geographic (GIS) applications. It is a open source
006: * contribution of the COGIT laboratory at the Institut Géographique National (the French
007: * National Mapping Agency).
008: *
009: * See: http://oxygene-project.sourceforge.net
010: *
011: * Copyright (C) 2005 Institut Géographique National
012: *
013: * This library is free software; you can redistribute it and/or modify it under the terms
014: * of the GNU Lesser General Public License as published by the Free Software Foundation;
015: * either version 2.1 of the License, or any later version.
016: *
017: * This library is distributed in the hope that it will be useful, but WITHOUT ANY
018: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
019: * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
020: *
021: * You should have received a copy of the GNU Lesser General Public License along with
022: * this library (see file LICENSE if present); if not, write to the Free Software
023: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024: *
025: */
026:
027: package fr.ign.cogit.geoxygene.util.browser;
028:
029: import java.awt.BorderLayout;
030: import java.awt.Dimension;
031: import java.awt.HeadlessException;
032: import java.awt.event.WindowAdapter;
033: import java.awt.event.WindowEvent;
034: import java.util.Locale;
035: import java.util.ResourceBundle;
036:
037: import javax.swing.JFrame;
038: import javax.swing.JLabel;
039: import javax.swing.JTextField;
040:
041: /**
042: * Cette classe rend possible l'affichage de l'argument de retour (pour l'instant de type primitif ou chaîne de caractère)
043: * renvoyé par une méthode déclenchée depuis le navigateur d'objet graphique de GeOxygene.
044: *
045: * @author Thierry Badard & Arnaud Braun
046: * @version 1.0
047: *
048: */
049:
050: public class ObjectBrowserPrimitiveFrame extends JFrame {
051:
052: /** Localisation des fichiers d'internationalisation de l'interface. */
053: private static final String I18N_LANGUAGE_FILE_LOCATION = "fr.ign.cogit.geoxygene.util.browser.ObjectBrowserLanguageFile";
054: /** Taille par défaut du champ texte affichant le résultat de la méthode.*/
055: private static final int PRIMITIVE_FRAME_DEFAULT_TEXTFIELD_SIZE = 35;
056: /** Locale courante. */
057: private Locale currentLocale;
058: /** RessourceBundle lié à la Locale et au fichier d'internationalisation. */
059: private ResourceBundle i18nLanguageFile;
060:
061: /**
062: * Constructeur principal de ObjectBrowserPrimitiveFrame.
063: *
064: * @param title titre de la fenêtre
065: * @param value valeur transtypée en chaîne de caractères de l'argument de retour de la méthode déclenchée.
066: * @throws HeadlessException
067: */
068: public ObjectBrowserPrimitiveFrame(String title, String value)
069: throws HeadlessException {
070: super ();
071:
072: currentLocale = Locale.getDefault();
073: i18nLanguageFile = ResourceBundle.getBundle(
074: I18N_LANGUAGE_FILE_LOCATION, currentLocale);
075: //i18nLanguageFile = ResourceBundle.getBundle(I18N_LANGUAGE_FILE_LOCATION,new Locale("en", "US"));
076:
077: setTitle(i18nLanguageFile
078: .getString("PrimitiveFrameDefaultTitle")
079: + title + "()");
080:
081: JTextField returnedValue = new JTextField(value,
082: PRIMITIVE_FRAME_DEFAULT_TEXTFIELD_SIZE);
083: returnedValue.setSize(returnedValue.getPreferredSize());
084: this .getContentPane().add(returnedValue, BorderLayout.CENTER);
085:
086: JLabel returnedValueLabel = new JLabel(i18nLanguageFile
087: .getString("PrimitiveFrameDefaultLabel"));
088: returnedValueLabel.setSize(returnedValueLabel
089: .getPreferredSize());
090: this .getContentPane()
091: .add(returnedValueLabel, BorderLayout.WEST);
092: this .getContentPane().setSize(
093: this .getContentPane().getPreferredSize());
094:
095: Dimension frameSize = new Dimension(this .getPreferredSize());
096: this .setSize(new Dimension((int) frameSize.getWidth(),
097: (int) frameSize.getHeight() + 30));
098:
099: this .addWindowListener(new WindowAdapter() {
100: public void windowClosing(WindowEvent e) {
101: dispose();
102: }
103: });
104:
105: this .setVisible(true);
106: }
107:
108: }
|