Revision 41494

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.exportto.app/org.gvsig.exportto.app.mainplugin/src/main/resources-plugin/config.xml
26 26
-->
27 27
<plugin-config>
28 28
    <alternativeNames name="org.gvsig.exportto.app.extension"/>
29
	<depends plugin-name="org.gvsig.app.mainplugin" />
29
    <depends plugin-name="org.gvsig.app.mainplugin" />
30 30
    <depends plugin-name="org.gvsig.app.document.table.app.mainplugin" />
31 31
    <depends plugin-name="org.gvsig.geodb.app.mainplugin" />
32 32
    <depends plugin-name="org.gvsig.shp.app.mainplugin" />
33 33

  
34
	<resourceBundle name="text"/>
35
	<libraries library-dir="lib"/>
36
	<extensions>
37
		<extension class-name="org.gvsig.exportto.app.extension.ExporttoLayerExtension"
38
			description=""
39
			active="true"
40
			priority="1">
41
			<menu text="Layer/export_to"
42
				position="600500000"
43
				action-command="Exportto"
44
				icon="layer-export" />				
45
		</extension>		
46
		<extension class-name="org.gvsig.exportto.app.extension.ExporttoTableExtension"
47
            description=""
48
            active="true"
49
            priority="1">
50
            <menu text="Table/export_to"
51
                position="600850000"
34
    <resourceBundle name="text"/>
35
    <libraries library-dir="lib"/>
36
    <extensions>
37
        <extension class-name="org.gvsig.exportto.app.extension.ExporttoLayerExtension"
38
                   description=""
39
                   active="true"
40
                   priority="1">
41
            <action 
42
                name="layer-exportto"
43
                label="export_to" 
44
                position="600500000"  
45
                tooltip="export_to" 
52 46
                action-command="Exportto"
53
                icon="table-export" />             
47
                icon="layer-export"
48
                accelerator=""
49
            />    
50

  
51
            <menu 
52
                name="layer-exportto"
53
                text="Layer/export_to" 
54
            />              
55
        </extension>	
56
                
57
                        	
58
        <extension class-name="org.gvsig.exportto.app.extension.ExporttoTableExtension"
59
                   description=""
60
                   active="true"
61
                   priority="1">
62

  
63
            <action 
64
                name="table-exportto"
65
                label="export_to" 
66
                position="600500000"  
67
                tooltip="export_to" 
68
                action-command="Exportto"
69
                icon="table-export"
70
                accelerator=""
71
            />    
72

  
73
            <menu 
74
                name="table-exportto"
75
                text="Table/export_to" 
76
            />              
77

  
54 78
        </extension>        
55 79
        <extension class-name="org.gvsig.exportto.app.extension.ExporttoPreferencesExtension"
56
            description=""
57
            active="true"
58
            priority="1">
80
                   description=""
81
                   active="true"
82
                   priority="1">
59 83
        </extension>        
60
	</extensions>
84
    </extensions>
61 85
</plugin-config>
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.exportto.app/org.gvsig.exportto.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml
63 63
        <include>org.gvsig:org.gvsig.exportto.swing.prov.shape</include>
64 64
        <include>org.gvsig:org.gvsig.exportto.swing.prov.dxf</include>
65 65
        <include>org.gvsig:org.gvsig.exportto.swing.prov.jdbc</include>
66
        <!--
66 67
        <include>org.gvsig:org.gvsig.exportto.swing.prov.postgresql</include>
67 68
        <include>org.gvsig:org.gvsig.exportto.swing.prov.mysql</include>
69
        -->
68 70
        <include>org.gvsig:org.gvsig.exportto.swing.prov.dbf</include>
69 71
      </includes>
70 72
    </dependencySet>
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.exportto.app/org.gvsig.exportto.app.mainplugin/src/main/java/org/gvsig/exportto/app/extension/ExporttoLayerExtension.java
10 10
 *
11 11
 * This program is distributed in the hope that it will be useful,
12 12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 14
 * GNU General Public License for more details.
15 15
 *
16 16
 * You should have received a copy of the GNU General Public License
17 17
 * along with this program; if not, write to the Free Software
18 18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
19
 * MA 02110-1301, USA.
20 20
 *
21 21
 * For any additional information, do not hesitate to contact us
22 22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23 23
 */
24 24
package org.gvsig.exportto.app.extension;
25 25

  
26
import java.util.Locale;
27

  
28 26
import org.cresques.cts.IProjection;
29 27

  
30 28
import org.gvsig.andami.IconThemeHelper;
......
33 31
import org.gvsig.andami.ui.mdiManager.IWindow;
34 32
import org.gvsig.app.ApplicationLocator;
35 33
import org.gvsig.app.ApplicationManager;
34
import org.gvsig.app.project.ProjectManager;
36 35
import org.gvsig.app.project.documents.view.ViewDocument;
37 36
import org.gvsig.app.project.documents.view.ViewManager;
38 37
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
......
44 43
import org.gvsig.fmap.mapcontext.layers.FLayer;
45 44
import org.gvsig.fmap.mapcontext.layers.FLayers;
46 45
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
47
import org.gvsig.i18n.Messages;
46
import org.gvsig.tools.swing.api.ToolsSwingLocator;
47
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
48 48

  
49 49
/**
50 50
 * @author gvSIG Team
51 51
 * @version $Id$
52
 * 
52
 *
53 53
 */
54 54
public class ExporttoLayerExtension extends Extension {
55 55

  
56 56
    private ExporttoSwingManager swingManager;
57
    private static final ApplicationManager APPLICATION_MANAGER =
58
        ApplicationLocator.getManager();
57
    private static final ApplicationManager APPLICATION_MANAGER
58
            = ApplicationLocator.getManager();
59 59

  
60 60
    public void initialize() {
61 61
        IconThemeHelper.registerIcon("action", "layer-export", this);
......
68 68
        swingManager = ExporttoSwingLocator.getSwingManager();
69 69

  
70 70
        swingManager.registerWindowManager(new GvSIGExporttoWindowManager());
71

  
72
        ProjectManager projectManager = ApplicationLocator.getProjectManager();
73
        ViewManager viewManager = (ViewManager) projectManager.getDocumentManager(ViewManager.TYPENAME);
74
        viewManager.addTOCContextAction("layer-exportto");
75

  
71 76
    }
72 77

  
73 78
    public void execute(String actionCommand) {
74 79
        ApplicationManager application = ApplicationLocator.getManager();
75
        ViewDocument view =
76
            (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
77
        if (view != null) {
80
        ViewDocument view
81
                = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
82
        if ( view != null ) {
78 83
            MapContext mapContext = view.getMapContext();
79 84
            FLayers layers = mapContext.getLayers();
80 85
            FLayer[] actives = layers.getActives();
81 86
            try {
82
                for (int i = 0; i < actives.length; i++) {
83
                    if (actives[i] instanceof FLyrVect) {
84
                        FLyrVect fLyrVect = (FLyrVect) actives[i];
87
                if ( actives.length == 1 ) {
88
                    if ( actives[0] instanceof FLyrVect ) {
89
                        FLyrVect fLyrVect = (FLyrVect) actives[0];
85 90
                        showExportto(fLyrVect, mapContext.getProjection(),
86
                            mapContext);
91
                                mapContext, WindowManager.MODE.WINDOW);
87 92
                    }
93
                } else {
94
                    for ( int i = 0; i < actives.length; i++ ) {
95
                        if ( actives[i] instanceof FLyrVect ) {
96
                            FLyrVect fLyrVect = (FLyrVect) actives[i];
97
                            showExportto(fLyrVect, mapContext.getProjection(),
98
                                    mapContext, WindowManager.MODE.DIALOG);
99
                        }
100
                    }
88 101
                }
89 102
            } catch (Exception e) {
90 103
                NotificationManager.showMessageError(e.getMessage(), e);
......
93 106
    }
94 107

  
95 108
    public int showExportto(FLyrVect fLyrVect, IProjection projection,
96
        MapContext mapContext) {
109
            MapContext mapContext, WindowManager.MODE mode) {
97 110

  
98
        JExporttoServicePanel panel =
99
            swingManager
111
        JExporttoServicePanel panel
112
                = swingManager
100 113
                .createExportto(
101
                    fLyrVect,
102
                    new LoadLayerAction(mapContext),
103
                    new int[] { ExporttoSwingManager.VECTORIAL_TABLE_WITH_GEOMETRY });
114
                        fLyrVect,
115
                        new LoadLayerAction(mapContext),
116
                        new int[]{ExporttoSwingManager.VECTORIAL_TABLE_WITH_GEOMETRY});
104 117

  
105
        swingManager.getWindowManager().showWindow(panel, "Exportto",
106
            ExporttoWindowManager.MODE_WINDOW);
107

  
118
        WindowManager winmgr = ToolsSwingLocator.getWindowManager();
119
        winmgr.showWindow(panel, "Exportto", mode);
108 120
        return panel.getStatus();
109 121

  
110 122
    }
111 123

  
112 124
    public boolean isEnabled() {
113 125
        ApplicationManager application = ApplicationLocator.getManager();
114
        ViewDocument view =
115
            (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
116
        if (view != null) {
126
        ViewDocument view
127
                = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
128
        if ( view != null ) {
117 129
            FLayer[] actives = view.getMapContext().getLayers().getActives();
118
            for (int i = 0; i < actives.length; i++) {
119
                if (actives[i] instanceof FLyrVect) {
130
            for ( int i = 0; i < actives.length; i++ ) {
131
                if ( actives[i] instanceof FLyrVect ) {
120 132
                    return true;
121 133
                }
122 134
            }
......
127 139
    public boolean isVisible() {
128 140
        IWindow window = APPLICATION_MANAGER.getUIManager().getActiveWindow();
129 141

  
130
        if (window == null) {
142
        if ( window == null ) {
131 143
            return false;
132 144
        }
133 145

  
134
        if (window instanceof DefaultViewPanel) {
146
        if ( window instanceof DefaultViewPanel ) {
135 147
            return true;
136 148
        }
137 149
        return false;
138 150
    }
151

  
139 152
}

Also available in: Unified diff