Revision 1702

View differences:

branches/CorePlugin_pilotoDWG/libraries/libCorePlugin/.cvsignore
1
bin
0 2

  
branches/CorePlugin_pilotoDWG/libraries/libCorePlugin/build.xml
1
<project name="Core plugin" default="dist" basedir=".">
2
    <description>
3
        Instala el plugin
4
    </description>
5
  <!-- set global properties for this build -->
6
  <property name="src" location="src"/>
7
  <property name="build" location="bin"/>
8
  <property name="dist"  location="dist"/>
9
  <property name="plugin" value="com.iver.core"/>
10
  <property name="targetDir" location="../Andami/gvSIG/extensiones"/>
11

  
12
  <target name="init">
13
    <!-- Create the time stamp -->
14
    <tstamp/>
15
    <!-- Create the build directory structure used by compile -->
16
    <mkdir dir="${build}"/>
17
  </target>
18

  
19
  <target name="dist" description="generate the distribution" >
20
    <!-- Create the distribution directory -->
21
    <mkdir dir="${dist}"/>
22

  
23
    <!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
24
    <copy todir="${build}">
25
    	<fileset dir="${src}" includes="**"/>
26
    </copy>
27
    <jar jarfile="${dist}/${plugin}.jar" basedir="${build}"/>
28
    <copy file="config.xml" todir="${dist}"/>
29
    <copy todir="${dist}">
30
    	<fileset dir="." includes="text*.properties"/>
31
    </copy>
32
    <copy todir="${dist}/images">
33
    	<fileset dir="images/" includes="*"/>
34
    </copy>
35
    <copy todir="${dist}">
36
    	<fileset dir="." includes="*.jar"/>
37
    </copy>
38

  
39
    <move todir="${targetDir}/${plugin}/">
40
    	<fileset dir="${dist}" includes="**/**"/>
41
    </move>
42
  </target>
43

  
44
  <target name="clean"
45
        description="clean up" >
46
    <!-- Delete the ${build} and ${dist} directory trees -->
47
    <delete dir="${build}"/>
48
    <delete dir="${dist}"/>
49
  </target>
50
</project>
51

  
0 52

  
branches/CorePlugin_pilotoDWG/libraries/libCorePlugin/text.properties
1
Ver=Ver
2
Consola=Consola
3
Tile=Mosaico
4
Cascada=Cascada
5
Window=Ventana
6
cascada_tooltip=Organiza las ventanas en cascada
7
cascada_enable=Debe haber al menos una ventana abierta
8
tile_tooltip=Organiza las ventanas en mosaico
9
titulo_consola=Consola de informacion
10
todos=Todos
11
info=Informacion
12
warnings=Avisos
13
errores=Errores
14
configurar_ANDAMI=Di?logo de configuraci?n de ANDAMI.
15
extension_activada=Extensi?n activada.
16
examinar=Examinar
17
directorio_extensiones=Directorio de las extensiones.
18
prioridad=Prioridad
19
opciones=Opciones
20
general=General
21
descripcion=Descripci?n
22
directorio=Directorio
23
aceptar=Aceptar
24
cancelar=Cancelar
25
ventana=Ventana
26
Configurar=Configurar
27
__catalan=valenciano
28
muestra_consola_tooltip=Muestra la consola
29
configuracion_andami_tooltip=Configuraci?n de Andami
30
debe_estar_activada=deber?a estar activada
31
mosaico_tooltip=Mosaico
0 32

  
branches/CorePlugin_pilotoDWG/libraries/libCorePlugin/.classpath
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5
	<classpathentry kind="lib" path="/Andami/lib/log4j-1.2.8.jar"/>
6
	<classpathentry kind="src" path="/Andami"/>
7
	<classpathentry kind="lib" path="/Andami/lib/castor-0.9.5.3-xml.jar"/>
8
	<classpathentry kind="lib" path="/Andami/lib/iver-utiles.jar"/>
9
	<classpathentry kind="output" path="bin"/>
10
</classpath>
0 11

  
branches/CorePlugin_pilotoDWG/libraries/libCorePlugin/text_en.properties
1
Ver=View
2
Consola=Console
3
Tile=Tile
4
Cascada=Cascade
5
Window=Window
6
cascada_tooltip=Arrange the windows in cascade
7
cascada_enable=There must be at least un visible frame
8
tile_tooltip=Arrange the windows in tile
9
titulo_consola=Information console
10
todos=All
11
info=Information
12
warnings=Warnings
13
errores=Errors
14
configurar_ANDAMI=ANDAMI configuration dialog.
15
extension_activada=Active extension.  
16
examinar=Examine
17
directorio_extensiones=Extensions directory.
18
prioridad=Priority
19
opciones=Options
20
general=General
21
descripcion=Description
22
directorio=Directory
23
aceptar=OK
24
cancelar=Cancel
25
ventana=Window
26
Configurar=Configure
27
__catalan=Valencian
0 28

  
branches/CorePlugin_pilotoDWG/libraries/libCorePlugin/text_ca.properties
1
Ver=Veure
2
Consola=Consola
3
Tile=Mosaic
4
Cascada=Cascada
5
Window=Finestra
6
cascada_tooltip=Organitzar les finestres en cascada
7
cascada_enable=Ha d'haver-hi almenys una finestra oberta
8
tile_tooltip=Organitzar les finestres en mosaic
9
titulo_consola=Consola d'informaci?
10
todos=Tots
11
info=Informaci?
12
warnings=Avisos
13
errores=Errors
14
configurar_ANDAMI=Di?leg de configuraci? d'ANDAMI
15
extension_activada=Extensi? activada
16
examinar=Examinar
17
directorio_extensiones=Directori de les extensions
18
prioridad=Prioritat
19
opciones=Opcions
20
general=General
21
descripcion=Descripci?
22
directorio=Directori
23
aceptar=Acceptar
24
cancelar=Cancel?lar
25
ventana=Finestra
26
Configurar=Configurar
27
__catalan=valenci?
0 28

  
branches/CorePlugin_pilotoDWG/libraries/libCorePlugin/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>CorePlugin</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
	</buildSpec>
14
	<natures>
15
		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
16
		<nature>org.eclipse.jdt.core.javanature</nature>
17
		<nature>org.eclipse.jem.beaninfo.BeanInfoNature</nature>
18
	</natures>
19
</projectDescription>
0 20

  
branches/CorePlugin_pilotoDWG/libraries/libCorePlugin/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugin-config>
3
	<libraries library-dir="."/>
4
	<resourceBundle name="text"/>
5
	<extensions>
6
		<extension class-name="com.iver.core.Consola" 
7
			description="Extensi?n encargada de abrir la ventana de la consola."
8
			active="true" priority="1">
9
			<menu text="Ver/Consola" action-command="unico" key="s"
10
				mnemonic="c" icon="images/console.png" 
11
				tooltip="muestra_consola_tooltip"
12
				position="0"/>
13
			<tool-bar name="core">
14
				<action-tool icon="images/console.png"
15
					action-command="consola" tooltip="muestra_consola_tooltip"
16
					enable-text="debe_estar_activada" last="true"/>
17
			</tool-bar>
18
		</extension>
19
		<extension class-name="com.iver.core.ConfigExtension" 
20
			description="Extensi?n encargada de abrir la ventana de configuraci?n de ANDAMI."
21
			active="true" priority="2">
22
			<menu text="ventana/Configurar" action-command="config" key="s"
23
				mnemonic="p" icon="images/config.png" 
24
				tooltip="configuracion_andami_tooltip"
25
				position="2"/>
26
			<tool-bar name="core">
27
				<action-tool icon="images/config.png"
28
					action-command="configuracion" tooltip="configuracion_andami_tooltip"
29
					enable-text="debe_estar_activada"/>
30
			</tool-bar>
31
		</extension>
32
			
33
		<extension class-name="com.iver.core.StatusBar" 
34
			description="Recoge los mensajes del NotificationManager y los muestra por la StatusBar"
35
			active="true">
36
		</extension>
37
		<skin-extension class-name="com.iver.core.mdiManager.NewSkin">
38
			<menu text="ventana/Cascada" action-command="cascada" key="c"
39
				mnemonic="c" tooltip="cascada_tooltip"/>
40
			<menu text="ventana/Tile" action-command="mosaico" key="m"
41
				mnemonic="c" tooltip="mosaico_tooltip"/>
42
		</skin-extension>
43
	</extensions>
44
</plugin-config>
45

  
46
<!--
47
<?xml version="1.0" encoding="ISO-8859-1"?>
48
<!DOCTYPE plugin SYSTEM "../../plugin.dtd">
49
<plugin>
50
	<libraries>
51
		<library file="com.iver.core.jar"/>
52
		<library file="prulib.jar"/>
53
	</libraries>
54
	<resourceBundle name="text"/>
55
	<labelSet class="com.iver.core.ConsolaFrame">
56
		<label text="label1"/>
57
		<label text="label2"/>
58
	</labelSet>
59
	<extension>
60
		<class name="com.iver.core.Consola"/>
61
		<menu text="Ver/Consola" key="s"/>
62
		<toolBar name="Ver">
63
			<tool icon="images/console.jpg"
64
				actionCommand="CONSOLA"/>
65
		</toolBar>
66
	</extension>
67
	<extension>
68
		<class name="com.iver.core.Cascade"/>
69
		<menu text="Window/Tile" key="t" mnemonic="t"
70
			tooltip="tile_tooltip" 
71
			enableText="cascada_enable"
72
			actionCommand="TILE"/>
73
		<menu text="Window/Cascada" key="c" mnemonic="c" 
74
			tooltip="cascada_tooltip" 
75
			enableText="cascada_enable"
76
			actionCommand="CASCADA"/>
77
		<toolBar name="Window">
78
			<tool icon="images/cascada.gif" 
79
				tooltip="cascada_tooltip" 
80
				enableText="cascada_enable"
81
				actionCommand="CASCADA"/>
82
			<tool icon="images/tile.gif"
83
				tooltip="tile_tooltip" 
84
				enableText="cascada_enable"
85
				actionCommand="TILE"/>
86
		</toolBar>
87
		<popupMenu name="cascada">
88
			<entry text="Cascada" 
89
				tooltip="cascada_tooltip" 
90
				enableText="cascada_enable" actionCommand="CASCADA"/>
91
			<entry text="Tile" 
92
				tooltip="tile_tooltip" 
93
				enableText="cascada_enable" actionCommand="CASCADA"/>
94
		</popupMenu>
95
	</extension>
96
	<extension>
97
		<class name="com.iver.core.StatusBar"/>
98
	</extension>
99
</plugin>
100
-->
0 101

  
branches/CorePlugin_pilotoDWG/libraries/libCorePlugin/text_fr.properties
1
Ver=Afficher
2
Consola=Console
3
Tile=Mosa?que
4
Cascada=Cascade
5
Window=Fen?tre
6
cascada_tooltip=Organiser les fen?tres en cascade
7
cascada_enable=Au moins une fen?tre doit ?tre ouverte
8
tile_tooltip=Organiser les fen?tres en mosa?que
9
titulo_consola=Console d'information
10
todos=Tous
11
info=Information
12
warnings=Attention
13
errores=Erreurs
14
configurar_ANDAMI=Fen?tre de configuration d'ANDAMI.
15
extension_activada=Extension activ?e.
16
examinar=Examiner
17
directorio_extensiones=R?pertoire des extensions
18
prioridad=Priorit?
19
opciones=Options
20
general=G?n?ral
21
descripcion=Description
22
directorio=R?pertoire
23
aceptar=Accepter
24
cancelar=Annuler
25
ventana=Fen?tre
26
Configurar=Configurer
27
__catalan=valencien
0 28

  
branches/CorePlugin_pilotoDWG/libraries/libCorePlugin/src/com/iver/core/Consola.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.core;
42

  
43
import com.iver.andami.PluginServices;
44
import com.iver.andami.messages.NotificationManager;
45
import com.iver.andami.plugins.Extension;
46
import com.iver.andami.ui.mdiManager.ViewInfo;
47
import com.iver.utiles.XMLEntity;
48

  
49

  
50
/**
51
 * Extensi?n que registra un frame en la aplicaci?n que recibe los eventos de
52
 * la consola de la aplicaci?n y los muestra en el frame
53
 */
54
public class Consola implements Extension {
55
	static PluginServices ps;
56
    private ConsolaFrame consolaFrame;
57

  
58
    /**
59
     * @see com.iver.mdiApp.Extension#inicializar()
60
     */
61
    public void inicializar() {
62
    	ps = PluginServices.getPluginServices(this);
63
    	consolaFrame = new ConsolaFrame();
64
    	NotificationManager.addNotificationListener(consolaFrame);
65
    }
66

  
67
	/* (non-Javadoc)
68
	 * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
69
	 */
70
	public void execute(String actionCommand) {
71
        PluginServices.getMDIManager().addView(consolaFrame);
72
	}
73

  
74
	/* (non-Javadoc)
75
	 * @see com.iver.andami.plugins.Extension#isEnabled()
76
	 */
77
	public boolean isEnabled() {
78
		return true;
79
	}
80

  
81
	/* (non-Javadoc)
82
	 * @see com.iver.andami.plugins.Extension#isVisible()
83
	 */
84
	public boolean isVisible() {
85
		return true;
86
	}
87
}
0 88

  
branches/CorePlugin_pilotoDWG/libraries/libCorePlugin/src/com/iver/core/ConfigExtension.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.core;
42

  
43

  
44
/**
45
 */
46
import com.iver.andami.PluginServices;
47
import com.iver.andami.plugins.Extension;
48
import com.iver.core.configExtensions.ConfigPlugins;
49

  
50

  
51

  
52
/**
53
 * Extensi?n para abrir el di?logo de configuraci?n de ANDAMI.
54
 *
55
 * @author Vicente Caballero Navarro
56
 * 
57
 * 
58
 */
59
public class ConfigExtension implements Extension {
60
   
61
	/* (non-Javadoc)
62
	 * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
63
	 */
64
	public void execute(String actionCommand) {
65
		ConfigPlugins cp=new ConfigPlugins();
66
		PluginServices.getMDIManager().addView(cp);
67
	}
68

  
69
    /**
70
     * DOCUMENT ME!
71
     *
72
     * @return DOCUMENT ME!
73
     */
74
    public boolean isVisible() {
75
    	return true;
76
    }
77

  
78
    /**
79
     * @see com.iver.mdiApp.plugins.Extension#isEnabled()
80
     */
81
    public boolean isEnabled() {
82
        return true;
83
    }
84

  
85
	/**
86
	 * @see com.iver.andami.plugins.Extension#inicializar()
87
	 */
88
	public void inicializar() {
89
	}
90
}
0 91

  
branches/CorePlugin_pilotoDWG/libraries/libCorePlugin/src/com/iver/core/mdiManager/ViewStackSupport.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.core.mdiManager;
42

  
43
import java.awt.event.ActionEvent;
44
import java.awt.event.ActionListener;
45
import java.lang.reflect.InvocationTargetException;
46
import java.util.Hashtable;
47
import java.util.Vector;
48

  
49
import javax.swing.SwingUtilities;
50

  
51
import com.iver.andami.PluginServices;
52
import com.iver.andami.persistence.generate.PluginsStatus;
53
import com.iver.andami.plugins.config.generate.Menu;
54
import com.iver.andami.ui.mdiManager.View;
55
import com.iver.andami.ui.mdiManager.ViewInfo;
56

  
57
/**
58
 * 
59
 */
60
public class ViewStackSupport {
61
	private Vector vistas = new Vector();
62
	
63
	private ViewInfoSupport vis;
64
	
65
	private Hashtable viewMenu = new Hashtable();
66
	
67
	/**
68
	 * @param vis
69
	 */
70
	public ViewStackSupport(ViewInfoSupport vis) {
71
		this.vis = vis;
72
	}
73

  
74
	public void add(View v, final ActionListener listener) {
75
		vistas.add(v);
76
		ViewInfo vi = vis.getViewInfo(v);
77
		int id = vi.getId();
78
		Menu m = new Menu();
79
		m.setActionCommand(""+id);
80
		m.setTooltip("activa la ventana");
81
		m.setText("ventana/"+vi.getTitle());
82
		viewMenu.put(v, m);
83
		PluginServices.getMainFrame().addMenu(m, listener, PluginServices.getPluginServices(this).getClassLoader() );
84
	}
85
	
86
	public void remove(View v){
87
		Menu m = (Menu) viewMenu.get(v);
88
		if (m == null) return;
89
		PluginServices.getMainFrame().removeMenu(m);
90
		viewMenu.remove(v);
91
		vistas.remove(v);
92
	}
93
	
94
	public void ctrltab(){
95
		View v = (View) vistas.remove(vistas.size() - 1);
96
		vistas.add(0, v);
97
	}
98
	
99
	public View getActiveView(){
100
		if (vistas.size() == 0) return null;
101
		return (View) vistas.get(vistas.size() - 1);
102
	}
103
}
0 104

  
branches/CorePlugin_pilotoDWG/libraries/libCorePlugin/src/com/iver/core/mdiManager/NewSkin.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.core.mdiManager;
42

  
43
import java.awt.BorderLayout;
44
import java.awt.Component;
45
import java.awt.Cursor;
46
import java.awt.event.ActionEvent;
47
import java.awt.event.ActionListener;
48
import java.awt.event.WindowAdapter;
49
import java.awt.event.WindowEvent;
50
import java.beans.PropertyVetoException;
51
import java.util.ArrayList;
52
import java.util.Iterator;
53

  
54
import javax.swing.DefaultDesktopManager;
55
import javax.swing.DesktopManager;
56
import javax.swing.FocusManager;
57
import javax.swing.JDesktopPane;
58
import javax.swing.JDialog;
59
import javax.swing.JInternalFrame;
60
import javax.swing.event.InternalFrameEvent;
61
import javax.swing.event.InternalFrameListener;
62

  
63
import org.apache.log4j.Logger;
64

  
65
import com.iver.andami.plugins.Extension;
66
import com.iver.andami.ui.mdiFrame.GlassPane;
67
import com.iver.andami.ui.mdiFrame.MDIFrame;
68
import com.iver.andami.ui.mdiManager.MDIManager;
69
import com.iver.andami.ui.mdiManager.MDIUtilities;
70
import com.iver.andami.ui.mdiManager.SingletonDialogAlreadyShownException;
71
import com.iver.andami.ui.mdiManager.SingletonView;
72
import com.iver.andami.ui.mdiManager.View;
73
import com.iver.andami.ui.mdiManager.ViewInfo;
74
import com.iver.andami.ui.mdiManager.ViewListener;
75

  
76

  
77
/**
78
 *
79
 */
80
public class NewSkin implements MDIManager, Extension {
81
	/**
82
	 * Variable privada <code>desktopManager</code> para usarlo cuando sale una
83
	 * ventana que no queremos que nos restaure las que tenemos maximizadas.
84
	 * Justo antes de usar el setMaximize(false), le pegamos el cambiazo.
85
	 */
86
	private static DesktopManager desktopManager = new DefaultDesktopManager();
87

  
88
	/** log */
89
	private static Logger logger = Logger.getLogger(NewSkin.class.getName());
90

  
91
	/** Panel de la MDIFrame */
92
	private JDesktopPane panel;
93

  
94
	/** MDIFrame */
95
	private MDIFrame mainFrame;
96
	private GlassPane glassPane = new GlassPane();
97
	private DialogStackSupport dss;
98
	private FrameViewSupport fvs;
99
	private ViewInfoSupport vis;
100
	private ViewStackSupport vss;
101
	private SingletonViewSupport svs;
102
	
103
	/**
104
	 * @see com.iver.andami.ui.mdiManager.MDIManager#init(com.iver.andami.ui.mdiFrame.MDIFrame)
105
	 */
106
	public void init(MDIFrame f) {
107
		//Inicializa el Frame y la consola
108
		mainFrame = f;
109
		mainFrame.setGlassPane(glassPane);
110
		panel = mainFrame.getDesktopPane();
111
		panel.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
112

  
113
		panel.setDesktopManager(desktopManager);
114

  
115
		fvs = new FrameViewSupport(mainFrame);
116
		dss = new DialogStackSupport(mainFrame);
117
		svs = new SingletonViewSupport(vis, fvs);
118
		vis = new ViewInfoSupport(mainFrame, fvs, svs);
119
		fvs.setVis(vis);
120
		vss = new ViewStackSupport(vis);
121
	}
122

  
123
	/**
124
	 * @see com.iver.andami.ui.mdiManager.MDIManager#addView(com.iver.andami.ui.mdiManager.View)
125
	 */
126
	public View addView(View p) throws SingletonDialogAlreadyShownException {
127
		//se obtiene la informaci?n de la vista
128
		ViewInfo vi = vis.getViewInfo(p);
129

  
130
		//Se comprueban las incompatibilidades que pudieran haber en la vista
131
		MDIUtilities.checkViewInfo(vi);
132
		if ((p instanceof SingletonView) && (vi.isModal())){
133
			throw new RuntimeException("A modal view cannot be a SingletonView");			
134
		}
135

  
136
		/*
137
		 * Se obtiene la referencia a la vista anterior por si es una singleton y est?
138
		 * siendo mostrada. Se obtiene su informaci?n si ya fue mostrada
139
		 */
140
		boolean singletonPreviouslyAdded = false;
141
		
142
		if (p instanceof SingletonView){
143
			SingletonView sv = (SingletonView) p;
144
			if (svs.registerView(sv.getClass(), sv.getViewModel(), vis.getViewInfo(sv))){
145
				singletonPreviouslyAdded = true;
146
			}
147
		}
148

  
149
		if (singletonPreviouslyAdded){
150
			//Si la vista no est? actualmente abierta
151
			if (!svs.contains((SingletonView)p)){
152
				JInternalFrame frame = fvs.getJInternalFrame(p);
153
				svs.openSingletonView((SingletonView)p, frame);
154
				addJInternalFrame(frame, vi);
155
				vss.add(p,
156
						new ActionListener() {
157
							public void actionPerformed(ActionEvent e) {
158
								View v = vis.getViewById(Integer.parseInt(
159
											e.getActionCommand()));
160
								JInternalFrame f = fvs.getJInternalFrame(v);
161
								activateJInternalFrame(f);
162
							}
163
						});
164
				return p;
165
			}else{
166
				//La vista est? actualmente abierta
167
				JInternalFrame frame = (JInternalFrame) svs.getFrame((SingletonView)p);
168
				activateJInternalFrame((JInternalFrame) frame);
169
				return fvs.getView((JInternalFrame) frame);
170
			}
171
		} else {
172
			if (vi.isModal()) {
173
				addJDialog(p);
174
			} else {
175
				//Se sit?a la vista en la pila de vistas
176
				vss.add(p,
177
					new ActionListener() {
178
						public void actionPerformed(ActionEvent e) {
179
							View v = vis.getViewById(Integer.parseInt(
180
										e.getActionCommand()));
181
							JInternalFrame f = fvs.getJInternalFrame(v);
182
							activateJInternalFrame(f);
183
						}
184
					});
185
				addJInternalFrame(p);
186
			}
187

  
188
			return p;
189
		}
190
	}
191

  
192
	/**
193
	 * DOCUMENT ME!
194
	 *
195
	 * @param wnd DOCUMENT ME!
196
	 * @param vi DOCUMENT ME!
197
	 */
198
	private void addJInternalFrame(JInternalFrame wnd, ViewInfo vi) {
199
		wnd.addInternalFrameListener(new FrameListener());
200

  
201
		wnd.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
202
		
203
		if (vi.isModeless()) {
204
			panel.add(wnd, JDesktopPane.PALETTE_LAYER);
205
		} else {
206
			panel.add(wnd);
207
		}
208

  
209
		activateJInternalFrame(wnd);
210
	}
211

  
212
	/**
213
	 * DOCUMENT ME!
214
	 *
215
	 * @param p
216
	 */
217
	private void addJInternalFrame(View p) {
218
		ViewInfo vi = vis.getViewInfo(p);
219

  
220
		JInternalFrame wnd = fvs.getJInternalFrame(p);
221

  
222
		if (p instanceof SingletonView){
223
			SingletonView sv = (SingletonView) p;
224
			svs.openSingletonView(sv, wnd);
225
		}
226

  
227
		addJInternalFrame(wnd, vi);
228
	}
229

  
230
	/**
231
	 * DOCUMENT ME!
232
	 *
233
	 * @param wnd
234
	 */
235
	private void activateJInternalFrame(JInternalFrame wnd) {
236
		try {
237
			wnd.moveToFront();
238
			wnd.setSelected(true);
239
			wnd.setIcon(false);
240
		} catch (PropertyVetoException e) {
241
			logger.error(e);
242
		}
243
	}
244

  
245
	/**
246
	 * Situa un di?logo modal en el centro de la pantalla
247
	 *
248
	 * @param d Di?logo que se quiere situar
249
	 */
250
	private void centerDialog(JDialog d) {
251
		int offSetX = d.getWidth() / 2;
252
		int offSetY = d.getHeight() / 2;
253

  
254
		d.setLocation((mainFrame.getWidth() / 2) - offSetX,
255
			(mainFrame.getHeight() / 2) - offSetY);
256
	}
257

  
258
	/**
259
	 * DOCUMENT ME!
260
	 *
261
	 * @param p
262
	 */
263
	private void addJDialog(View p) {
264
		JDialog dlg = fvs.getJDialog(p);
265

  
266
		centerDialog(dlg);
267

  
268
		dlg.addWindowListener(new DialogWindowListener());
269
		dss.pushDialog(dlg);
270

  
271
		dlg.setVisible(vis.getViewInfo(p).isVisible());
272
	}
273

  
274
	/**
275
	 * @see com.iver.andami.ui.mdiManager.MDIManager#getActiveView()
276
	 */
277
	public View getActiveView() {
278
		JInternalFrame jif = panel.getSelectedFrame();
279

  
280
		if (jif != null) {
281
			return fvs.getView(jif);
282
		}
283

  
284
		return null;
285
	}
286

  
287
	/**
288
	 * @see com.iver.andami.ui.mdiManager.MDIManager#closeView(com.iver.andami.ui.mdiManager.View)
289
	 */
290
	public void closeView(View p) {
291
		//Si es un di?logo modal 
292
		if (p.getViewInfo().isModal()) {
293
			closeJDialog();
294
		} else { //Si no es modal se cierra el JInternalFrame
295
			closeJInternalFrame(fvs.getJInternalFrame(p));
296
		}
297
	}
298

  
299
	/**
300
	 * @see com.iver.andami.ui.mdiManager.MDIManager#closeAllViews()
301
	 */
302
	public void closeAllViews() {
303
		ArrayList eliminar = new ArrayList();
304
		Iterator i = fvs.getViewIterator();
305

  
306
		while (i.hasNext()) {
307
			eliminar.add((View) i.next());
308
		}
309

  
310
		for (Iterator iter = eliminar.iterator(); iter.hasNext();) {
311
			View vista = (View) iter.next();
312
			closeView(vista);
313
		}
314
	}
315

  
316
	/**
317
	 * @see com.iver.andami.ui.mdiManager.MDIManager#getViewInfo(com.iver.andami.ui.mdiManager.View)
318
	 */
319
	public ViewInfo getViewInfo(View v) {
320
		return vis.getViewInfo(v);
321
	}
322

  
323
	/**
324
	 * DOCUMENT ME!
325
	 *
326
	 * @param dialog
327
	 *
328
	 * @throws RuntimeException DOCUMENT ME!
329
	 */
330
	private void closeJDialog() {
331
		JDialog dlg = dss.popDialog();
332

  
333
		dlg.setVisible(false);
334

  
335
		View s = (View) fvs.getView(dlg);
336

  
337
		callViewClosed(s);
338

  
339
		fvs.closeView(s);
340

  
341
		//Si es singleton se desasocia el modelo con la vista
342
		if (s instanceof SingletonView) {
343
			svs.closeView((SingletonView) s);
344
		}
345
	}
346

  
347
	/**
348
	 * DOCUMENT ME!
349
	 *
350
	 * @param view DOCUMENT ME!
351
	 */
352
	private void callViewClosed(View view) {
353
		if (view instanceof ViewListener) {
354
			((ViewListener) view).viewClosed();
355
		}
356
	}
357

  
358
	/**
359
	 * DOCUMENT ME!
360
	 *
361
	 * @param view DOCUMENT ME!
362
	 */
363
	private void callViewActivated(View view) {
364
		if (view instanceof ViewListener) {
365
			((ViewListener) view).viewActivated();
366
		}
367
	}
368

  
369
	/**
370
	 * DOCUMENT ME!
371
	 *
372
	 * @param frame
373
	 */
374
	private void closeJInternalFrame(JInternalFrame frame) {
375
		try {
376
			View s = (View) fvs.getView(frame);
377

  
378
			frame.setClosed(true);
379
			callViewClosed(s);
380
		} catch (PropertyVetoException e) {
381
			logger.error("Not compatible with property veto's. Use ViewInfo instead.",
382
				e);
383
		}
384
	}
385

  
386
	/**
387
	 * @see com.iver.andami.plugins.Extension#inicializar()
388
	 */
389
	public void inicializar() {
390
	}
391

  
392
	/**
393
	 * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
394
	 */
395
	public void execute(String actionCommand) {
396
		if (actionCommand.equals("cascada")) {
397
		} else if (actionCommand.equals("mosaico")) {
398
		}
399
	}
400

  
401
	/**
402
	 * @see com.iver.andami.plugins.Extension#isEnabled()
403
	 */
404
	public boolean isEnabled() {
405
		// TODO Auto-generated method stub
406
		return false;
407
	}
408

  
409
	/**
410
	 * @see com.iver.andami.plugins.Extension#isVisible()
411
	 */
412
	public boolean isVisible() {
413
		// TODO Auto-generated method stub
414
		return true;
415
	}
416

  
417
	/**
418
	 * @see com.iver.andami.ui.mdiManager.MDIManager#setWaitCursor()
419
	 */
420
	public void setWaitCursor() {
421
		if (mainFrame != null) {
422
			glassPane.setVisible(true);
423
			mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
424
			dss.setWaitCursor();
425
		}
426
	}
427

  
428
	/**
429
	 * @see com.iver.andami.ui.mdiManager.MDIManager#restoreCursor()
430
	 */
431
	public void restoreCursor() {
432
		if (mainFrame != null) {
433
			glassPane.setVisible(false);
434
			mainFrame.setCursor(null);
435
			dss.restoreCursor();
436
		}
437
	}
438

  
439
	/**
440
	 * Listener para los eventos de cerrado de los di?logos. Tiene su raz?n de
441
	 * ser en que los di?logos han de devolverse al pool cuando se cierran
442
	 *
443
	 * @author Fernando Gonz?lez Cort?s
444
	 */
445
	public class DialogWindowListener extends WindowAdapter {
446
		/**
447
		 * Captura el evento de cerrado de los di?logos con el fin de realizar
448
		 * tareas de mantenimiento
449
		 *
450
		 * @param e evento
451
		 */
452
		public void windowClosing(WindowEvent e) {
453
			closeJDialog();
454
		}
455
	}
456

  
457
	/**
458
	 * DOCUMENT ME!
459
	 */
460
	public class FrameListener implements InternalFrameListener {
461
		/**
462
		 * @see javax.swing.event.InternalFrameListener#internalFrameActivated(javax.swing.event.InternalFrameEvent)
463
		 */
464
		public void internalFrameActivated(InternalFrameEvent e) {
465
			View panel = fvs.getView((JInternalFrame) e.getSource());
466
			ViewInfo vi = vis.getViewInfo(panel);
467

  
468
			JInternalFrame frame = fvs.getJInternalFrame(panel);
469

  
470
			if (!frame.isMaximizable() && frame.isMaximum()) {
471
				try {
472
					frame.setMaximum(false);
473
				} catch (PropertyVetoException e1) {
474
				}
475
			}
476
			mainFrame.enableControls();
477
			callViewActivated(panel);
478

  
479
			
480
		}
481

  
482
		/**
483
		 * @see javax.swing.event.InternalFrameListener#internalFrameClosed(javax.swing.event.InternalFrameEvent)
484
		 */
485
		public void internalFrameClosed(InternalFrameEvent e) {
486
		}
487

  
488
		/**
489
		 * @see javax.swing.event.InternalFrameListener#internalFrameClosing(javax.swing.event.InternalFrameEvent)
490
		 */
491
		public void internalFrameClosing(InternalFrameEvent e) {
492
			// Se elimina la memoria del JInternalFrame si no es ALWAYS_LIVE
493
			JInternalFrame c = (JInternalFrame) e.getSource();
494
			ViewInfo vi = vis.getViewInfo((View) fvs.getView(c));
495

  
496
			View view = fvs.getView(c);
497

  
498
			boolean alwaysLive;
499
			if (view instanceof SingletonView) {
500
				svs.closeView((SingletonView) view);
501
			}
502

  
503
			fvs.closeView(view);
504

  
505
			panel.remove(c);
506

  
507
			vss.remove(view);
508

  
509
			mainFrame.enableControls();
510

  
511
			panel.repaint();
512
		}
513

  
514
		/**
515
		 * @see javax.swing.event.InternalFrameListener#internalFrameDeactivated(javax.swing.event.InternalFrameEvent)
516
		 */
517
		public void internalFrameDeactivated(InternalFrameEvent e) {
518
		}
519

  
520
		/**
521
		 * @see javax.swing.event.InternalFrameListener#internalFrameDeiconified(javax.swing.event.InternalFrameEvent)
522
		 */
523
		public void internalFrameDeiconified(InternalFrameEvent e) {
524
			mainFrame.enableControls();
525
		}
526

  
527
		/**
528
		 * @see javax.swing.event.InternalFrameListener#internalFrameIconified(javax.swing.event.InternalFrameEvent)
529
		 */
530
		public void internalFrameIconified(InternalFrameEvent e) {
531
			mainFrame.enableControls();
532
		}
533

  
534
		/**
535
		 * @see javax.swing.event.InternalFrameListener#internalFrameOpened(javax.swing.event.InternalFrameEvent)
536
		 */
537
		public void internalFrameOpened(InternalFrameEvent e) {
538
		}
539
	}
540

  
541
	/**
542
	 * @see com.iver.andami.ui.mdiManager.MDIManager#closeSingletonView(java.lang.Class, java.lang.Object)
543
	 */
544
	public boolean closeSingletonView(Class viewClass, Object model) {
545
		JInternalFrame frame = svs.getFrame(viewClass, model);
546
		if (frame == null) return false;
547
		closeJInternalFrame(frame);
548
		return true;
549
	}
550

  
551
	/**
552
	 * @see com.iver.andami.ui.mdiManager.MDIManager#closeSingletonView(java.lang.Object)
553
	 */
554
	public boolean closeSingletonView(Object model) {
555
		JInternalFrame[] frames = svs.getFrames(model);
556
		if (frames.length == 0) return false;
557
		for (int i = 0; i < frames.length; i++) {
558
			closeJInternalFrame(frames[i]);
559
		}
560
		return true;
561
	}
562
}
0 563

  
branches/CorePlugin_pilotoDWG/libraries/libCorePlugin/src/com/iver/core/mdiManager/DialogStackSupport.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.core.mdiManager;
42

  
43
import java.awt.Cursor;
44
import java.util.ArrayList;
45
import java.util.Iterator;
46

  
47
import javax.swing.JDialog;
48

  
49
import org.apache.log4j.Logger;
50

  
51
import com.iver.andami.ui.mdiFrame.MDIFrame;
52

  
53

  
54
/**
55
 *
56
 */
57
public class DialogStackSupport{
58
    /** log */
59
    private static Logger logger = Logger.getLogger(DialogStackSupport.class.getName());
60

  
61
    /** Pila de di?logos modales mostrados */
62
    private ArrayList dialogStack = new ArrayList(0);
63

  
64
    public DialogStackSupport(MDIFrame frame){
65
    }
66
    
67
    public void pushDialog(JDialog dlg){
68
    	dialogStack.add(dlg);
69
    }
70
    
71
    public JDialog popDialog(){
72
    	return (JDialog) dialogStack.remove(dialogStack.size() - 1);
73
    }
74

  
75
	/**
76
	 * @return
77
	 */
78
	public void setWaitCursor() {
79
		for (Iterator iter = dialogStack.iterator(); iter.hasNext();) {
80
			JDialog dlg = (JDialog) iter.next();
81
			dlg.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
82
 	        dlg.getGlassPane().setVisible(true);
83
 	   }
84
	}
85

  
86
	/**
87
	 * 
88
	 */
89
	public void restoreCursor() {
90
		for (Iterator iter = dialogStack.iterator(); iter.hasNext();) {
91
			JDialog dlg = (JDialog) iter.next();
92
            dlg.setCursor(null);
93
		    dlg.getGlassPane().setVisible(false);
94
		}
95
	}
96
}
0 97

  
branches/CorePlugin_pilotoDWG/libraries/libCorePlugin/src/com/iver/core/mdiManager/FrameViewSupport.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff