Revision 37781

View differences:

branches/v2_0_0_prep/extensions/org.gvsig.exportto.app/org.gvsig.exportto.app.extension/src/main/java/org/gvsig/exportto/app/extension/LoadLayerAction.java
36 36
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
37 37
import org.gvsig.fmap.mapcontext.layers.FLayer;
38 38

  
39

  
40 39
/**
41 40
 * @author gvSIG Team
42 41
 * @version $Id$
43
 *
42
 * 
44 43
 */
45
public class LoadLayerAction implements ExporttoServiceFinishAction{
46
    private static final Logger LOG = LoggerFactory.getLogger(LoadLayerAction.class);
47
    private static final MapContextManager MAP_CONTEXT_MANAGER = MapContextLocator.getMapContextManager();    
48
    
44
public class LoadLayerAction implements ExporttoServiceFinishAction {
45

  
46
    private static final Logger LOG = LoggerFactory
47
        .getLogger(LoadLayerAction.class);
48
    private static final MapContextManager MAP_CONTEXT_MANAGER =
49
        MapContextLocator.getMapContextManager();
50

  
49 51
    private MapContext mapContext = null;
50 52

  
51 53
    public LoadLayerAction(MapContext mapContext) {
......
53 55
        this.mapContext = mapContext;
54 56
    }
55 57

  
56
    public void finished(String layerName, DataStoreParameters dataStoreParameters) {
58
    public void finished(String layerName,
59
        DataStoreParameters dataStoreParameters) {
57 60
        try {
58
            int res = JOptionPane.showConfirmDialog((JComponent) PluginServices.getMDIManager()
59
                .getActiveWindow(),
60
                PluginServices.getText(this,
61
                    "insertar_en_la_vista_la_capa_creada"),
61
            int res =
62
                JOptionPane.showConfirmDialog((JComponent) PluginServices
63
                    .getMDIManager().getActiveWindow(), PluginServices.getText(
64
                    this, "insertar_en_la_vista_la_capa_creada"),
62 65
                    PluginServices.getText(this, "insertar_capa"),
63 66
                    JOptionPane.YES_NO_OPTION);
64 67

  
65
            if (res == JOptionPane.YES_OPTION) {               
66
                FLayer layer = MAP_CONTEXT_MANAGER.createLayer(layerName, dataStoreParameters);
67
                mapContext.getLayers().addLayer(layer);           
68
            if (res == JOptionPane.YES_OPTION) {
69
                FLayer layer =
70
                    MAP_CONTEXT_MANAGER.createLayer(layerName,
71
                        dataStoreParameters);
72
                mapContext.getLayers().addLayer(layer);
68 73
            }
69 74

  
70 75
        } catch (LoadLayerException e) {
71 76
            LOG.error("Error loading the exported layer", e);
72
        }        
77
        }
73 78
    }
74 79
}
branches/v2_0_0_prep/extensions/org.gvsig.exportto.app/org.gvsig.exportto.app.extension/src/main/java/org/gvsig/exportto/app/extension/ExporttoLayerExtension.java
25 25

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

  
28
import org.gvsig.andami.PluginServices;
29 28
import org.gvsig.andami.messages.NotificationManager;
30 29
import org.gvsig.andami.plugins.Extension;
31 30
import org.gvsig.andami.ui.mdiManager.IWindow;
32 31
import org.gvsig.app.ApplicationLocator;
33 32
import org.gvsig.app.ApplicationManager;
34
import org.gvsig.app.project.documents.Document;
35 33
import org.gvsig.app.project.documents.view.ViewDocument;
36 34
import org.gvsig.app.project.documents.view.ViewManager;
37 35
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
......
44 42
import org.gvsig.fmap.mapcontext.layers.FLayers;
45 43
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
46 44
import org.gvsig.i18n.Messages;
47
import org.w3c.dom.views.DocumentView;
48 45

  
49

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

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

  
60 57
    public void initialize() {
61 58
        if (!Messages.hasLocales()) {
62 59
            Messages.addLocale(Locale.getDefault());
63 60
        }
64
        Messages.addResourceFamily("org.gvsig.exportto.app.extension.i18n.text",
61
        Messages.addResourceFamily(
62
            "org.gvsig.exportto.app.extension.i18n.text",
65 63
            ExporttoLayerExtension.class.getClassLoader(),
66 64
            ExporttoLayerExtension.class.getClass().getName());
67 65
    }
68 66

  
69 67
    @Override
70 68
    public void postInitialize() {
71
        super.postInitialize();     
69
        super.postInitialize();
72 70
        // Asignamos el locator e iniciamos la instancia
73 71
        swingManager = ExporttoSwingLocator.getSwingManager();
74 72

  
75
        swingManager
76
        .registerWindowManager(new GvSIGExporttoWindowManager());
73
        swingManager.registerWindowManager(new GvSIGExporttoWindowManager());
77 74
    }
78 75

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

  
99
    public int showExportto(FLyrVect fLyrVect, IProjection projection, MapContext mapContext) {
98
    public int showExportto(FLyrVect fLyrVect, IProjection projection,
99
        MapContext mapContext) {
100 100

  
101 101
        JExporttoServicePanel panel =
102
            swingManager.createExportto(fLyrVect.getFeatureStore(), projection, new LoadLayerAction(mapContext), 
103
                new int[]{ExporttoSwingManager.VECTORIAL_TABLE_WITH_GEOMETRY});
104
               
102
            swingManager
103
                .createExportto(
104
                    fLyrVect.getFeatureStore(),
105
                    projection,
106
                    new LoadLayerAction(mapContext),
107
                    new int[] { ExporttoSwingManager.VECTORIAL_TABLE_WITH_GEOMETRY });
108

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

  
......
110 114
    }
111 115

  
112 116
    public boolean isEnabled() {
113
    	ApplicationManager application = ApplicationLocator.getManager();
114
    	ViewDocument view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
115
    	if (view!=null){
116
    		FLayer[] actives = view.getMapContext().getLayers().getActives();
117
        ApplicationManager application = ApplicationLocator.getManager();
118
        ViewDocument view =
119
            (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
120
        if (view != null) {
121
            FLayer[] actives = view.getMapContext().getLayers().getActives();
117 122
            for (int i = 0; i < actives.length; i++) {
118 123
                if (actives[i] instanceof FLyrVect) {
119 124
                    return true;
120 125
                }
121 126
            }
122
    	}
127
        }
123 128
        return false;
124 129
    }
125 130

  
branches/v2_0_0_prep/extensions/org.gvsig.exportto.app/org.gvsig.exportto.app.extension/src/main/java/org/gvsig/exportto/app/extension/ExporttoWindowListener.java
25 25
import org.gvsig.andami.ui.mdiManager.IWindow;
26 26
import org.gvsig.exportto.swing.JExporttoServicePanelListener;
27 27

  
28

  
29 28
/**
30 29
 * @author gvSIG Team
31 30
 * @version $Id$
32
 *
31
 * 
33 32
 */
34
public class ExporttoWindowListener implements JExporttoServicePanelListener{
33
public class ExporttoWindowListener implements JExporttoServicePanelListener {
34

  
35 35
    private IWindow exporttoWindow = null;
36
        
36

  
37 37
    public ExporttoWindowListener(IWindow exporttoWindow) {
38 38
        super();
39 39
        this.exporttoWindow = exporttoWindow;
40 40
    }
41 41

  
42 42
    public void close() {
43
       PluginServices.getMDIManager().closeWindow(exporttoWindow);        
43
        PluginServices.getMDIManager().closeWindow(exporttoWindow);
44 44
    }
45 45

  
46 46
}
branches/v2_0_0_prep/extensions/org.gvsig.exportto.app/org.gvsig.exportto.app.extension/src/main/java/org/gvsig/exportto/app/extension/LoadTableAction.java
42 42
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
43 43
import org.gvsig.fmap.dal.feature.FeatureStore;
44 44

  
45

  
46 45
/**
47 46
 * @author gvSIG Team
48 47
 * @version $Id$
49
 *
48
 * 
50 49
 */
51
public class LoadTableAction implements ExporttoServiceFinishAction{
52
    private static final Logger LOG = LoggerFactory.getLogger(LoadLayerAction.class);   
50
public class LoadTableAction implements ExporttoServiceFinishAction {
51

  
52
    private static final Logger LOG = LoggerFactory
53
        .getLogger(LoadLayerAction.class);
53 54
    private static final DataManager DATA_MANAGER = DALLocator.getDataManager();
54 55

  
55 56
    public LoadTableAction() {
56
        super();      
57
        super();
57 58
    }
58 59

  
59 60
    public void finished(String tableName,
60 61
        DataStoreParameters dataStoreParameters) {
61 62

  
62
        int res = JOptionPane.showConfirmDialog((JComponent) PluginServices.getMDIManager().getActiveWindow(),
63
            PluginServices.getText(this,"add_table_to_project"),
64
            PluginServices.getText(this, "add_table"),
65
            JOptionPane.YES_NO_OPTION);
63
        int res =
64
            JOptionPane.showConfirmDialog((JComponent) PluginServices
65
                .getMDIManager().getActiveWindow(), PluginServices.getText(
66
                this, "add_table_to_project"), PluginServices.getText(this,
67
                "add_table"), JOptionPane.YES_NO_OPTION);
66 68

  
67
        if (res == JOptionPane.YES_OPTION) {  
68
            try{
69
                FeatureStore featureStore = (FeatureStore)DATA_MANAGER.openStore(dataStoreParameters.getDataStoreName(), dataStoreParameters);
70
                TableDocument tableDocument = (TableDocument) ProjectManager.getInstance().createDocument(
71
                    TableManager.TYPENAME, tableName);                
69
        if (res == JOptionPane.YES_OPTION) {
70
            try {
71
                FeatureStore featureStore =
72
                    (FeatureStore) DATA_MANAGER.openStore(
73
                        dataStoreParameters.getDataStoreName(),
74
                        dataStoreParameters);
75
                TableDocument tableDocument =
76
                    (TableDocument) ProjectManager.getInstance()
77
                        .createDocument(TableManager.TYPENAME, tableName);
72 78
                tableDocument.setStore(featureStore);
73 79

  
74
                ApplicationLocator.getManager().getProjectManager().getCurrentProject().add(tableDocument);
75
                //               FeatureTableDocumentPanel featureTableDocumentPanel =
76
                //                    new FeatureTableDocumentPanel(tableDocument);
80
                ApplicationLocator.getManager().getProjectManager()
81
                    .getCurrentProject().add(tableDocument);
82
                // FeatureTableDocumentPanel featureTableDocumentPanel =
83
                // new FeatureTableDocumentPanel(tableDocument);
77 84
                //
78
                //                MDI_MANAGER.addWindow(featureTableDocumentPanel);                      
85
                // MDI_MANAGER.addWindow(featureTableDocumentPanel);
79 86
            } catch (ValidateDataParametersException e) {
80 87
                LOG.error("Error opening the exported table", e);
81 88
            } catch (InitializeException e) {
branches/v2_0_0_prep/extensions/org.gvsig.exportto.app/org.gvsig.exportto.app.extension/src/main/java/org/gvsig/exportto/app/extension/GvSIGExporttoWindowManager.java
40 40
 * @author gvSIG Team
41 41
 * @version $Id$
42 42
 */
43
public class GvSIGExporttoWindowManager implements
44
    ExporttoWindowManager, ComponentListener {
43
public class GvSIGExporttoWindowManager implements ExporttoWindowManager,
44
    ComponentListener {
45 45

  
46 46
    private Map<JPanel, IWindow> panelToWindow = new HashMap<JPanel, IWindow>();
47
    
47

  
48 48
    public void showWindow(JExporttoServicePanel panel, String title, int mode) {
49
        ExporttoWindow window =
50
            new ExporttoWindow(panel, title, mode);
51
        panel.setExporttoServicePanelListener(new ExporttoWindowListener(window));
52
        
49
        ExporttoWindow window = new ExporttoWindow(panel, title, mode);
50
        panel
51
            .setExporttoServicePanelListener(new ExporttoWindowListener(window));
52

  
53 53
        panel.addComponentListener(this);
54
        
54

  
55 55
        panelToWindow.put(panel, window);
56 56

  
57 57
        PluginServices.getMDIManager().addCentredWindow(window);
branches/v2_0_0_prep/extensions/org.gvsig.exportto.app/org.gvsig.exportto.app.extension/src/main/java/org/gvsig/exportto/app/extension/ExporttoTableExtension.java
34 34
import org.gvsig.exportto.swing.JExporttoServicePanel;
35 35
import org.gvsig.fmap.dal.feature.FeatureStore;
36 36

  
37

  
38 37
/**
39 38
 * @author gvSIG Team
40 39
 * @version $Id$
41
 *
40
 * 
42 41
 */
43
public class ExporttoTableExtension extends Extension{
42
public class ExporttoTableExtension extends Extension {
43

  
44 44
    private ExporttoSwingManager swingManager;
45
    private static final ApplicationManager APPLICATION_MANAGER = 
45
    private static final ApplicationManager APPLICATION_MANAGER =
46 46
        ApplicationLocator.getManager();
47
    
47

  
48 48
    public void initialize() {
49
        
49

  
50 50
    }
51 51

  
52 52
    @Override
53 53
    public void postInitialize() {
54
        super.postInitialize();        
54
        super.postInitialize();
55 55
        swingManager = ExporttoSwingLocator.getSwingManager();
56 56
    }
57 57

  
58 58
    public void execute(String actionCommand) {
59
        org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
60
        .getActiveWindow();
59
        org.gvsig.andami.ui.mdiManager.IWindow f =
60
            PluginServices.getMDIManager().getActiveWindow();
61 61

  
62 62
        if (f instanceof FeatureTableDocumentPanel) {
63
            FeatureTableDocumentPanel featureTableDocumentPanel = (FeatureTableDocumentPanel) f;
64
            TableDocument tableDocument = (TableDocument)featureTableDocumentPanel.getDocument();
65
            showExportto(tableDocument.getStore());   
63
            FeatureTableDocumentPanel featureTableDocumentPanel =
64
                (FeatureTableDocumentPanel) f;
65
            TableDocument tableDocument =
66
                (TableDocument) featureTableDocumentPanel.getDocument();
67
            showExportto(tableDocument.getStore());
66 68
        }
67 69
    }
68 70

  
69 71
    private void showExportto(FeatureStore featureStore) {
70 72
        JExporttoServicePanel panel =
71
            swingManager.createExportto(featureStore, null, new LoadTableAction(),
72
                new int[]{ExporttoSwingManager.VECTORIAL_TABLE_WITHOUT_GEOMETRY});
73
            swingManager
74
                .createExportto(
75
                    featureStore,
76
                    null,
77
                    new LoadTableAction(),
78
                    new int[] { ExporttoSwingManager.VECTORIAL_TABLE_WITHOUT_GEOMETRY });
73 79

  
74 80
        swingManager.getWindowManager().showWindow(panel, "Exportto",
75 81
            ExporttoWindowManager.MODE_WINDOW);
......
77 83
    }
78 84

  
79 85
    public boolean isEnabled() {
80
        return true;       
86
        return true;
81 87
    }
82 88

  
83 89
    public boolean isVisible() {
......
87 93
            return false;
88 94
        }
89 95

  
90
        if (window instanceof FeatureTableDocumentPanel) {            
96
        if (window instanceof FeatureTableDocumentPanel) {
91 97
            return true;
92 98
        }
93 99
        return false;
94 100
    }
95
}
101
}

Also available in: Unified diff