Revision 34002 branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/extension/About.java

View differences:

About.java
46 46
 */
47 47
package org.gvsig.app.extension;
48 48

  
49
import java.awt.BorderLayout;
50
import java.awt.FlowLayout;
51
import java.awt.event.ActionEvent;
52
import java.awt.event.ActionListener;
53
import java.net.URL;
54

  
55
import javax.swing.JButton;
56
import javax.swing.JPanel;
57

  
58
import org.gvsig.about.AboutLocator;
59
import org.gvsig.about.AboutManager;
49 60
import org.gvsig.andami.PluginServices;
50 61
import org.gvsig.andami.plugins.Extension;
51
import org.gvsig.app.gui.panels.FPanelAbout;
62
import org.gvsig.andami.ui.mdiManager.IWindow;
63
import org.gvsig.andami.ui.mdiManager.WindowInfo;
64
import org.gvsig.app.ApplicationLocator;
65
import org.gvsig.app.ApplicationManager;
52 66

  
53 67

  
54 68

  
......
56 70
 * Extensi?n que abre una nueva ventana mostrando la informaci?n sobre el
57 71
 * gvSIG.
58 72
 *
59
 * @author Francisco Jos? Pe?arrubia
60 73
 */
61 74
public class About extends Extension {
62
    private static FPanelAbout panelAbout = new FPanelAbout();
63 75
	/**
64 76
	 * @see org.gvsig.andami.plugins.IExtension#isEnabled()
65 77
	 */
......
78 90
	 * @see org.gvsig.andami.plugins.IExtension#initialize()
79 91
	 */
80 92
	public void initialize() {
81
        java.net.URL aboutURL = About.class.getResource(
82
        "/about.htm");
83
        panelAbout.addAboutUrl("gvSIG",aboutURL);
93
	}
84 94

  
85
        // EXAMPLE TO MAKE USE OF ABOUT WINDOW FROM AN EXTERNAL
86
        // EXTENSION
87
        /* About claseAbout = (About) PluginServices.getExtension(com.iver.cit.gvsig.About.class);
88
        java.net.URL aboutURL2 = About.class.getResource(
89
        "/about.htm");
95
	private URL getResource(String name) {
96
		URL resource = this.getClass().getResource(name);
97
		return resource;
98
	}
99
	
100
	public void postInitialize() {
101
		super.postInitialize();
102
		ApplicationManager application = ApplicationLocator.getManager();
103
		
104
		Version version = application.getVersion();
105
		AboutManager about = application.getAbout();
106
		
107
		about.setProject(
108
				"gvSIG desktop", 
109
				getResource("/about.htm"), 
110
				getResource("/images/gvsig.png")
111
		);
112
		about.getProject().set("build",version.getBuildId());
113
		about.getProject().set("version",version.getFormat());
114
		
115
		about.addSponsor(
116
			"CIT GVA", //"Conselleria d'infraestructures i transport de la Generalitat Valenciana",
117
			getResource("gva-cit.html"),
118
			1
119
		);
90 120

  
91
        claseAbout.getAboutPanel().addAboutUrl("NewExtensionName", aboutURL2); */
92
        
93
        
121
		about.addDeveloper(
122
			"IVER",
123
			getResource("iver.html"),
124
			1
125
		);
126
		
127
		about.addDeveloper(
128
			"PRODEVELOP",
129
			getResource("prodevelop.html"),
130
			2
131
		);
132
		
133
		about.addDeveloper(
134
			"Software Colaborativo",
135
			getResource("scolab.html"),
136
			3
137
		);
138
		
139
		about.addDeveloper(
140
			"DISID",
141
			getResource("disid.html"),
142
			4
143
		);
94 144
	}
95 145

  
96
	/**
97
	 * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
98
	 */
99 146
	public void execute(String actionCommand) {
100
		PluginServices.getMDIManager().addWindow(panelAbout);
101
        /*
102
         * Ejemplo de c?mo crear una ventana para hacer paletas.
103
         * Cuando tenga tiempo, hay que hacerlo con Andami para
104
         * que Andami no dependa de los JInternalFrame, y alg?n
105
         * d?a (si hace falta) se cambie.
106
         *  
107
         *  JInternalFrame panel = new JInternalFrame();
108
        panel.setClosable(true);
109
        panel.setSize(200,200);
110
        panel.setTitle("Hola");
111
        
112
        MDIFrame mainFrame = (MDIFrame) PluginServices.getMainFrame();
113
        JLayeredPane lyrPane = mainFrame.getLayeredPane();
114
        lyrPane.add(panel, JDesktopPane.PALETTE_LAYER);        
115
        panel.show(); */
147
		ApplicationManager application = ApplicationLocator.getManager();
148
		
149
		application.getUIManager().addCentredWindow(new AboutWindow());
116 150
	}
117 151
    
118
    /**
119
     * An external plugin must call this method to obtain
120
     * the AboutPanel and add its own about.
121
     * Example:
122
     * In initialize, call PluginServices.getExtension and 
123
     * cast it to About class.
124
     * Then, call getAboutPanel, and addAboutUrl
125
     * PluginServices.getExtension(com.iver.cit.gvsig.About);
126
     * See the initalize method inside this extension
127
     * @return the About Panel
128
     */
129
    public FPanelAbout getAboutPanel()
130
    {
131
        return panelAbout;
132
    }
152
	class AboutWindow extends JPanel implements IWindow {
153

  
154
		/**
155
		 * 
156
		 */
157
		private static final long serialVersionUID = -3577229971045886621L;
158

  
159
		AboutWindow() {
160
			AboutManager aboutManager = AboutLocator.getManager();
161

  
162
			this.setLayout(new BorderLayout());
163
			this.add(aboutManager.getAboutPanel(), BorderLayout.CENTER);
164
			this.add(new JPanelButtons(), BorderLayout.SOUTH);
165
		}
166
		
167
		public WindowInfo getWindowInfo() {
168
			WindowInfo winfo = new WindowInfo(
169
					WindowInfo.MODALDIALOG|WindowInfo.RESIZABLE
170
			);
171
			winfo.setTitle(PluginServices.getText(this,"acerca_de"));
172
			return winfo;
173
		}
174

  
175
		public Object getWindowProfile() {
176
			return WindowInfo.DIALOG_PROFILE;
177
		}
178
		
179
		public void closeWindow() {
180
			PluginServices.getMDIManager().closeWindow(this);
181
		}
182

  
183
		class JPanelButtons extends JPanel {
184
			/**
185
			 * 
186
			 */
187
			private static final long serialVersionUID = 1529755877776747074L;
188
			JButton close = null;
189
			JButton installedPlugins = null;
190

  
191
			JPanelButtons() {
192
				this.setLayout(new FlowLayout());
193
				this.close = getCloseButton();
194
				this.installedPlugins = getInstalledPluginsButton();
195
				this.add(this.close);
196
				this.add(this.installedPlugins);
197
			}
198

  
199
			private JButton getCloseButton() {
200
				JButton button = new JButton(
201
						PluginServices.getText(this, "Close"));
202
				button.addActionListener(new ActionListener() {
203
					public void actionPerformed(ActionEvent e) {
204
						closeWindow();
205
					}
206
				});
207
				return button;
208
			}
209

  
210
			private JButton getInstalledPluginsButton() {
211
				JButton button = new JButton(PluginServices.getText(this,
212
						"Installed plugins"));
213
				button.addActionListener(new ActionListener() {
214
					public void actionPerformed(ActionEvent e) {
215
						// TODO: Need implementation
216
					}
217
				});
218
				return button;
219
			}
220

  
221
		}
222
	}
133 223
}

Also available in: Unified diff