Revision 41796

View differences:

tags/org.gvsig.desktop-2.0.66/org.gvsig.desktop.library/org.gvsig.newlayer/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4
  <modelVersion>4.0.0</modelVersion>
5
  <artifactId>org.gvsig.newlayer</artifactId>
6
  <packaging>pom</packaging>
7
  <description>newlayer project</description>
8
  <name>${project.artifactId}</name>
9
  <parent>
10
      <groupId>org.gvsig</groupId>
11
      <artifactId>org.gvsig.desktop.library</artifactId>
12
      <version>2.0.66</version>
13
  </parent>
14

  
15
  <dependencies>
16
    <dependency>
17
      <groupId>org.gvsig</groupId>
18
      <artifactId>org.gvsig.tools.lib</artifactId>
19
    </dependency>
20
    <dependency>
21
      <groupId>org.gvsig</groupId>
22
      <artifactId>org.gvsig.tools.lib</artifactId>
23
      <type>test-jar</type>
24
    </dependency>  
25
  </dependencies>
26
  
27
  <modules>
28
    <module>org.gvsig.newlayer.lib</module>
29
    <module>org.gvsig.newlayer.prov</module>
30
  </modules>
31
</project>
0 32

  
tags/org.gvsig.desktop-2.0.66/org.gvsig.desktop.library/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/.classpath
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" output="target/classes" path="src/main/java">
4
		<attributes>
5
			<attribute name="optional" value="true"/>
6
			<attribute name="maven.pomderived" value="true"/>
7
		</attributes>
8
	</classpathentry>
9
	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
10
		<attributes>
11
			<attribute name="maven.pomderived" value="true"/>
12
		</attributes>
13
	</classpathentry>
14
	<classpathentry kind="src" output="target/test-classes" path="src/test/java">
15
		<attributes>
16
			<attribute name="optional" value="true"/>
17
			<attribute name="maven.pomderived" value="true"/>
18
		</attributes>
19
	</classpathentry>
20
	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
21
		<attributes>
22
			<attribute name="maven.pomderived" value="true"/>
23
		</attributes>
24
	</classpathentry>
25
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
26
		<attributes>
27
			<attribute name="maven.pomderived" value="true"/>
28
		</attributes>
29
	</classpathentry>
30
	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
31
		<attributes>
32
			<attribute name="maven.pomderived" value="true"/>
33
		</attributes>
34
	</classpathentry>
35
	<classpathentry kind="output" path="target/classes"/>
36
</classpath>
0 37

  
tags/org.gvsig.desktop-2.0.66/org.gvsig.desktop.library/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.gvsig.newlayer.lib.impl</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
		<buildCommand>
14
			<name>org.eclipse.m2e.core.maven2Builder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
	</buildSpec>
19
	<natures>
20
		<nature>org.eclipse.jdt.core.javanature</nature>
21
		<nature>org.eclipse.m2e.core.maven2Nature</nature>
22
	</natures>
23
</projectDescription>
0 24

  
tags/org.gvsig.desktop-2.0.66/org.gvsig.desktop.library/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/test/resources/README.txt
1
Put into this folder the resources needed by your test classes.
2

  
3
This folder is added to the Tests classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your tests classes.
0 9

  
tags/org.gvsig.desktop-2.0.66/org.gvsig.desktop.library/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2013 gvSIG Association.
7

  
8
    This program is free software; you can redistribute it and/or
9
    modify it under the terms of the GNU General Public License
10
    as published by the Free Software Foundation; either version 3
11
    of the License, or (at your option) any later version.
12

  
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
17

  
18
    You should have received a copy of the GNU General Public License
19
    along with this program; if not, write to the Free Software
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
    MA  02110-1301, USA.
22

  
23
    For any additional information, do not hesitate to contact us
24
    at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26
-->
27
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
28

  
29
<!-- 
30
Log4J configuration file for unit tests execution.
31
 -->
32
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
33

  
34
	<!-- Appender configuration to show logging messages through the console -->
35
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
36
		<layout class="org.apache.log4j.PatternLayout">
37
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
38
		</layout>
39
	</appender>
40

  
41
	<!-- 
42
	Activate logging messages of DEBUG level of higher only for the
43
	org.gvsig.tools packages.
44
	You can put full classes names or packages instead, to configure
45
	logging for all the classes and subpackages of the package.
46
	-->
47
	<category name="org.gvsig.tools">
48
		<priority value="DEBUG" />
49
	</category>
50
	<category name="org.gvsig.newlayer">
51
		<priority value="DEBUG" />
52
	</category>
53

  
54
	<!-- 
55
	By default, show only logging messages of INFO level or higher, 
56
	through the previously configured CONSOLE appender. 
57
	-->
58
	<root>
59
		<priority value="INFO" />
60
		<appender-ref ref="CONSOLE" />
61
	</root>
62
</log4j:configuration>
0 63

  
tags/org.gvsig.desktop-2.0.66/org.gvsig.desktop.library/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/main/java/org/gvsig/newlayer/impl/preferences/DefaultNewLayerPreferencesComponent.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.newlayer.impl.preferences;
25

  
26
import java.awt.GridBagConstraints;
27
import java.awt.GridBagLayout;
28
import java.awt.Insets;
29
import java.util.ArrayList;
30
import java.util.HashSet;
31
import java.util.List;
32
import java.util.Set;
33

  
34
import javax.swing.JCheckBox;
35
import javax.swing.JComponent;
36
import javax.swing.JPanel;
37
import javax.swing.event.ChangeEvent;
38
import javax.swing.event.ChangeListener;
39

  
40
import org.gvsig.newlayer.NewLayerLocator;
41
import org.gvsig.newlayer.NewLayerProviderFactory;
42
import org.gvsig.newlayer.preferences.NewLayerPreferencesComponent;
43

  
44
/**
45
 * Default implementation for the {@link NewLayerPreferencesComponent}.
46
 * 
47
 * @author gvSIG Team
48
 * @version $Id$
49
 */
50
public class DefaultNewLayerPreferencesComponent extends JPanel implements
51
    NewLayerPreferencesComponent, ChangeListener {
52

  
53
    private static final long serialVersionUID = -4392838062470171181L;
54

  
55
    private JCheckBox[] providerChecks;
56
    private List<NewLayerProviderFactory> providers;
57
    private boolean valueChanged = false;
58

  
59
    /**
60
     * Creates a new DefaultNewLayerPreferencesComponent.
61
     * 
62
     * @see JPanel#JPanel()
63
     */
64
    public DefaultNewLayerPreferencesComponent() {
65
        this(true);
66
    }
67

  
68
    /**
69
     * Creates a new DefaultNewLayerPreferencesComponent.
70
     * 
71
     * @param isDoubleBuffered
72
     *            a boolean, true for double-buffering, which
73
     *            uses additional memory space to achieve fast, flicker-free
74
     *            updates
75
     * @see JPanel#JPanel(boolean)
76
     */
77
    public DefaultNewLayerPreferencesComponent(boolean isDoubleBuffered) {
78
        super(isDoubleBuffered);
79
        initialize();
80
    }
81

  
82
    private void initialize() {
83
        this.setLayout(new GridBagLayout());
84

  
85
        Insets insets = new Insets(1, 0, 1, 0);
86

  
87
        GridBagConstraints gbc = new GridBagConstraints();
88
        gbc.gridx = 0;
89
        gbc.gridy = 1;
90
        gbc.gridheight = 1;
91
        gbc.gridwidth = GridBagConstraints.REMAINDER;
92
        gbc.fill = GridBagConstraints.NONE;
93
        gbc.anchor = GridBagConstraints.WEST;
94
        gbc.weightx = 1.0f;
95
        gbc.insets = insets;
96

  
97
        providers =
98
            new ArrayList<NewLayerProviderFactory>(NewLayerLocator.getManager()
99
                .getProviders());
100
        providerChecks = new JCheckBox[providers.size()];
101
        for (int i = 0; i < providers.size(); i++) {
102
            NewLayerProviderFactory factory = providers.get(i);
103
            providerChecks[i] =
104
                new JCheckBox(factory.getLabel(), factory.isEnabled());
105
            providerChecks[i].addChangeListener(this);
106
            providerChecks[i].setToolTipText(factory.getDescription());
107
            add(providerChecks[i], gbc);
108
            gbc.gridy++;
109
        }
110
    }
111

  
112
    public JComponent asJComponent() {
113
        return this;
114
    }
115

  
116
    public void initializeDefaults() {
117
        for (int i = 0; i < providers.size(); i++) {
118
            NewLayerProviderFactory factory = providers.get(i);
119
            providerChecks[i].setSelected(factory.isEnabled());
120
        }
121
        valueChanged = false;
122
        validate();
123
    }
124

  
125
    public Set<NewLayerProviderFactory> getDisabledProviders() {
126
        Set<NewLayerProviderFactory> disabledFactories =
127
            new HashSet<NewLayerProviderFactory>();
128

  
129
        for (int i = 0; i < providerChecks.length; i++) {
130
            if (!providerChecks[i].isSelected()) {
131
                disabledFactories.add(providers.get(i));
132
            }
133
        }
134

  
135
        return disabledFactories;
136
    }
137

  
138
    public boolean isValueChanged() {
139
        return valueChanged;
140
    }
141

  
142
    public void setChangesApplied() {
143
        valueChanged = false;
144
    }
145

  
146
    public void stateChanged(ChangeEvent e) {
147
        valueChanged = true;
148
    }
149
}
0 150

  
tags/org.gvsig.desktop-2.0.66/org.gvsig.desktop.library/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/main/java/org/gvsig/newlayer/impl/NewLayerDefaultImplLibrary.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.newlayer.impl;
25

  
26
import java.util.Locale;
27

  
28
import org.gvsig.i18n.Messages;
29
import org.gvsig.newlayer.NewLayerLibrary;
30
import org.gvsig.newlayer.NewLayerLocator;
31
import org.gvsig.tools.library.AbstractLibrary;
32
import org.gvsig.tools.library.LibraryException;
33

  
34
/**
35
 * Library for default implementation initialization and configuration.
36
 * 
37
 * @author gvSIG team
38
 * @version $Id$
39
 */
40
public class NewLayerDefaultImplLibrary extends AbstractLibrary {
41
    
42
    @Override
43
    public void doRegistration() {
44
        registerAsImplementationOf(NewLayerLibrary.class);
45
    }
46

  
47
    @Override
48
    protected void doInitialize() throws LibraryException {
49
        NewLayerLocator.registerManager(DefaultNewLayerManager.class);
50
        if (!Messages.hasLocales()) {
51
            Messages.addLocale(Locale.getDefault());
52
        }
53
        Messages.addResourceFamily("org.gvsig.newlayer.lib.impl.i18n.text",
54
            NewLayerDefaultImplLibrary.class.getClassLoader(),
55
            NewLayerDefaultImplLibrary.class.getClass().getName());
56
    }
57

  
58
    @Override
59
    protected void doPostInitialize() throws LibraryException {
60
        // Do nothing
61
    }
62

  
63
}
0 64

  
tags/org.gvsig.desktop-2.0.66/org.gvsig.desktop.library/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/main/java/org/gvsig/newlayer/impl/TypeSelectorPanel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.newlayer.impl;
25

  
26
import java.awt.BorderLayout;
27

  
28
import javax.swing.DefaultListSelectionModel;
29
import javax.swing.JList;
30
import javax.swing.JPanel;
31
import javax.swing.JScrollPane;
32
import javax.swing.ListModel;
33
import javax.swing.event.ListSelectionEvent;
34
import javax.swing.event.ListSelectionListener;
35

  
36
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException;
37
import org.gvsig.gui.beans.wizard.panel.OptionPanel;
38
import org.gvsig.i18n.Messages;
39
import org.gvsig.newlayer.NewLayerProviderFactory;
40
import org.gvsig.newlayer.NewLayerService;
41
import org.gvsig.newlayer.NewLayerWizard;
42

  
43
public class TypeSelectorPanel extends JPanel implements OptionPanel{
44
	
45
	/**
46
	 * 
47
	 */
48
	private static final long serialVersionUID = 419873365484240927L;
49
	private NewLayerWizard wizard;
50
    private NewLayerProviderFactory currentType;
51

  
52
	public TypeSelectorPanel(NewLayerWizard wizard){
53
		this.wizard = wizard;
54
		initializeComponents();
55
	}
56

  
57
	public String getPanelTitle() {
58
		return Messages.getText("_Output_format");
59
	}
60

  
61
	public void nextPanel() throws NotContinueWizardException {
62
		if (currentType!=null){
63
			this.wizard.setType(currentType);
64
			return;
65
		}
66
		throw new NotContinueWizardException("", null, false);
67
	}
68

  
69
	public void lastPanel() {
70
		// do nothing
71
		
72
	}
73

  
74
	public void updatePanel() {
75
		initializeComponents();
76
	}
77

  
78
	public JPanel getJPanel() {
79
		return this;
80
	}
81

  
82
    private void initializeComponents() {
83
        this.setLayout(new BorderLayout());
84

  
85
        JList types = new JList();     
86
        ListModel model =
87
            new org.gvsig.utils.DefaultListModel(this.getService()
88
                .getProviderFactories());
89
       
90
        types.setModel(model);
91
        types.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
92
        
93
        types.addListSelectionListener(new ListSelectionListener() {
94
			public void valueChanged(ListSelectionEvent e) {
95
				if (e.getValueIsAdjusting() == false) {
96
					JList list = (JList) e.getSource();
97
					
98
			        if (list.getSelectedIndex() > -1) {
99
                        currentType =
100
                            (NewLayerProviderFactory) list.getSelectedValue();
101
                        
102
                        wizard.setNextButtonEnabled(true);
103
			        } else {
104
			            wizard.setNextButtonEnabled(false);
105
			        }
106
			    }
107
			}
108
		});
109
        
110
        JScrollPane scrollPane = new JScrollPane();
111
        scrollPane.setViewportView(types);
112
        this.add(scrollPane, BorderLayout.CENTER);        
113
    }
114

  
115
	private NewLayerService getService() {
116
		return this.wizard.getService();
117
	} 
118
}
0 119

  
tags/org.gvsig.desktop-2.0.66/org.gvsig.desktop.library/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/main/java/org/gvsig/newlayer/impl/DefaultNewLayerManager.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.newlayer.impl;
25

  
26
import java.net.URL;
27
import java.util.ArrayList;
28
import java.util.HashMap;
29
import java.util.Iterator;
30
import java.util.List;
31
import java.util.Map;
32

  
33
import javax.swing.ImageIcon;
34

  
35
import org.slf4j.Logger;
36
import org.slf4j.LoggerFactory;
37

  
38
import org.gvsig.fmap.mapcontext.MapContext;
39
import org.gvsig.newlayer.NewLayerManager;
40
import org.gvsig.newlayer.NewLayerProviderFactory;
41
import org.gvsig.newlayer.NewLayerService;
42
import org.gvsig.newlayer.NewLayerWizard;
43
import org.gvsig.newlayer.impl.preferences.DefaultNewLayerPreferencesComponent;
44
import org.gvsig.newlayer.preferences.NewLayerPreferencesComponent;
45
import org.gvsig.tools.ToolsLocator;
46
import org.gvsig.tools.extensionpoint.ExtensionPoint;
47
import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension;
48
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
49
import org.gvsig.tools.service.ServiceException;
50

  
51
/**
52
 * Default {@link NewLayerManager} implementation.
53
 * 
54
 * @author gvSIG Team
55
 * @version $Id$
56
 */
57
public class DefaultNewLayerManager implements NewLayerManager {
58

  
59
    private static final Logger LOG = LoggerFactory
60
        .getLogger(DefaultNewLayerManager.class);
61

  
62
    final static private String EP_NEWLAYER_NAME = "NewLayer.manager.providers";
63
    final static private String EP_NEWLAYER_DESCRIPTION = "NewLayer providers";
64

  
65
    private Map<NewLayerProviderFactory, Boolean> providerStatus;
66

  
67
    /**
68
     * Empty constructor.
69
     */
70
    public DefaultNewLayerManager() {
71
        providerStatus = new HashMap<NewLayerProviderFactory, Boolean>();
72
    }
73

  
74
    public NewLayerService createNewLayerService(MapContext mapContext) {
75
        return new DefaultNewLayerService(this, mapContext);
76
    }
77

  
78
    public void registerProvider(NewLayerProviderFactory factory) {
79
        ExtensionPoint ep = getNewLayerProvidersExtensionPoint();
80
        ep.append(factory.getName(), factory.getDescription(), factory);
81
    }
82

  
83
    public NewLayerWizard createNewLayerWizard(NewLayerService service) {
84
        
85
        URL iconURL =
86
            getClass().getClassLoader().getResource(
87
                "org/gvsig/newlayer/lib/impl/images/panel/view-new-layer-illustration.png");
88
        ImageIcon logo = null;
89
        if (iconURL != null) {
90
            logo = new ImageIcon(iconURL);
91
        }
92

  
93
        return new DefaultNewLayerWizard(logo, service);
94
    }
95

  
96
    public NewLayerProviderFactory getNewLayerProviderFactory(
97
        String providerName) throws ServiceException {
98
        ExtensionPoint ep = getNewLayerProvidersExtensionPoint();
99
        try {
100
            return (NewLayerProviderFactory) ep.create(providerName);
101
        } catch (InstantiationException e) {
102
            throw new RuntimeException(e);
103
        } catch (IllegalAccessException e) {
104
            throw new RuntimeException(e);
105
        }
106
    }
107

  
108
    public void enableProvider(NewLayerProviderFactory factory, Boolean value) {
109
        providerStatus.put(factory, Boolean.valueOf(value));
110
    }
111

  
112
    public NewLayerPreferencesComponent createNewLayerProvidersPreferences() {
113
        return new DefaultNewLayerPreferencesComponent();
114
    }
115

  
116
    public List<NewLayerProviderFactory> getProviders() {
117
        ExtensionPoint ep = getNewLayerProvidersExtensionPoint();
118
        List<NewLayerProviderFactory> providers =
119
            new ArrayList<NewLayerProviderFactory>();
120
        @SuppressWarnings("unchecked")
121
        Iterator<Extension> it = ep.iterator();
122

  
123
        while (it.hasNext()) {
124
            Extension extension = (Extension) it.next();
125
            NewLayerProviderFactory factory;
126
            try {
127
                factory = (NewLayerProviderFactory) extension.create();
128
            } catch (InstantiationException e) {
129
                LOG.warn(
130
                    "Can't create NewLayerProviderFactory "
131
                        + extension.getName(), e);
132
                continue;
133
            } catch (IllegalAccessException e) {
134
                LOG.warn(
135
                    "Can't create NewLayerProviderFactory "
136
                        + extension.getName(), e);
137
                continue;
138
            }
139
            providers.add(factory);
140
        }
141

  
142
        return providers;
143
    }
144

  
145
    private ExtensionPoint getNewLayerProvidersExtensionPoint() {
146
        ExtensionPointManager epmgr = ToolsLocator.getExtensionPointManager();
147
        return
148
            epmgr.add(EP_NEWLAYER_NAME, EP_NEWLAYER_DESCRIPTION);
149
    }
150

  
151
    public List<NewLayerProviderFactory> getProviders(STORETYPE filter) {
152
        // TODO use filters
153
        // if (filter == STORETYPE.TABULAR){
154
        // if (!factory.isSpatial()){
155
        // providers.add(factory);
156
        // }
157
        // } else {
158
        // }
159
        return getProviders();
160
    }
161

  
162
    public boolean isProviderEnabled(NewLayerProviderFactory factory) {
163
        Boolean status = providerStatus.get(factory);
164
        return status == null ? true : status.booleanValue();
165
    }
166

  
167
}
0 168

  
tags/org.gvsig.desktop-2.0.66/org.gvsig.desktop.library/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/main/java/org/gvsig/newlayer/impl/AddNewLayerQuestionPanel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.newlayer.impl;
25

  
26
import java.awt.BorderLayout;
27

  
28
import javax.swing.JCheckBox;
29
import javax.swing.JPanel;
30

  
31
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException;
32
import org.gvsig.gui.beans.wizard.panel.OptionPanel;
33
import org.gvsig.i18n.Messages;
34
import org.gvsig.newlayer.NewLayerService;
35
import org.gvsig.newlayer.NewLayerWizard;
36

  
37
public class AddNewLayerQuestionPanel extends JPanel implements OptionPanel{
38
	
39
    private static final long serialVersionUID = -5251910576017225307L;
40
    private NewLayerWizard wizard;
41
	private JCheckBox questionCheckBox = null;
42
	
43
	public AddNewLayerQuestionPanel(NewLayerWizard wizard){
44
		this.wizard = wizard;
45
		initializeComponents();
46
	}
47

  
48
	public String getPanelTitle() {
49
		return Messages.getText("_Adding_layer");
50
	}
51

  
52
	public void nextPanel() throws NotContinueWizardException {
53
		getService().addLayerToView(getAddLayerToView());
54
	}
55

  
56
	public void lastPanel() {
57
		// do nothing
58
		
59
	}
60

  
61
	public void updatePanel() {
62
		initializeComponents();
63
	}
64

  
65
	public JPanel getJPanel() {
66
		return this;
67
	}
68

  
69
    private void initializeComponents() {
70
        this.setLayout(new BorderLayout());
71
        this.add(getQuestionCheckBox(), BorderLayout.NORTH);        
72
    }
73
    
74
    private JCheckBox getQuestionCheckBox(){
75
    	if (this.questionCheckBox == null){
76
    		this.questionCheckBox = new JCheckBox(
77
    		    Messages.getText("_Add_layer_to_view"), true);
78
    	}
79
    	return this.questionCheckBox;
80
    }
81

  
82
	private NewLayerService getService() {
83
		return this.wizard.getService();
84
	} 
85
	
86
	public boolean getAddLayerToView(){
87
		return getQuestionCheckBox().isSelected();
88
	}
89
}
0 90

  
tags/org.gvsig.desktop-2.0.66/org.gvsig.desktop.library/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/main/java/org/gvsig/newlayer/impl/DefaultNewLayerService.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.newlayer.impl;
25

  
26
import java.util.ArrayList;
27
import java.util.Iterator;
28
import java.util.List;
29

  
30
import org.gvsig.fmap.dal.DALLocator;
31
import org.gvsig.fmap.dal.DataManager;
32
import org.gvsig.fmap.dal.DataServerExplorer;
33
import org.gvsig.fmap.dal.DataStore;
34
import org.gvsig.fmap.dal.DataStoreParameters;
35
import org.gvsig.fmap.dal.exception.DataException;
36
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
37
import org.gvsig.fmap.dal.feature.EditableFeatureType;
38
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
39
import org.gvsig.fmap.mapcontext.MapContext;
40
import org.gvsig.fmap.mapcontext.MapContextLocator;
41
import org.gvsig.fmap.mapcontext.MapContextManager;
42
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
43
import org.gvsig.fmap.mapcontext.layers.FLayer;
44
import org.gvsig.newlayer.NewLayerManager;
45
import org.gvsig.newlayer.NewLayerProvider;
46
import org.gvsig.newlayer.NewLayerProviderFactory;
47
import org.gvsig.newlayer.NewLayerService;
48
import org.gvsig.newlayer.NewLayerServiceException;
49
import org.gvsig.tools.service.ServiceException;
50

  
51
/**
52
 * Default {@link NewLayerService} implementation.
53
 * 
54
 * @author gvSIG Team
55
 * @version $Id$
56
 */
57
public class DefaultNewLayerService implements NewLayerService {
58

  
59
    private NewLayerManager newLayerManager;
60
    private NewLayerProviderFactory type;
61
    private NewLayerProvider provider;
62
    private boolean addLayerToView = true;
63
    private MapContext mapContext;
64

  
65
    /**
66
     * {@link DefaultNewLayerService} constructor
67
     */
68
    public DefaultNewLayerService(NewLayerManager manager, MapContext mapContext) {
69
        this.newLayerManager = manager;
70
        this.mapContext = mapContext;
71
    }
72

  
73
    public NewLayerProvider getProvider() {
74
        return provider;
75
    }
76

  
77
    public void createLayer() throws NewLayerServiceException {
78
        try {
79
            this.getExplorer().add(this.getStoreName(),
80
                this.getNewStoreParameters(), true);
81
        } catch (DataException e) {
82
            throw new CantCreateNewLayerException(e);
83
        }
84
    }
85

  
86
    public void loadLayer() throws NewLayerServiceException {
87
        try {
88
            String storeName = this.getStoreName();
89
            DataStoreParameters storeParameters =
90
                this.getOpenStoreParameters();
91
            DataManager dataManager = DALLocator.getDataManager();
92
            DataStore store = dataManager.openStore(storeName, storeParameters);
93
            String layerName = store.getName();
94

  
95
            MapContextManager mapContextManager =
96
                MapContextLocator.getMapContextManager();
97
            FLayer lyr = mapContextManager.createLayer(layerName, store);
98
            lyr.setActive(true);
99
            lyr.setVisible(true);
100
            mapContext.getLayers().addLayer(lyr);
101

  
102
            lyr.dispose();
103
        } catch (DataException e) {
104
            throw new CantOpenStoreException(e);
105
        } catch (ValidateDataParametersException e) {
106
            throw new CantOpenStoreException(e);
107
        } catch (LoadLayerException e) {
108
            throw new CantLoadNewLayerException(e);
109
        }
110

  
111
    }
112

  
113
    public class CantCreateNewLayerException extends NewLayerServiceException {
114

  
115
        /**
116
		 * 
117
		 */
118
        private static final long serialVersionUID = 4208215791054246118L;
119

  
120
        public CantCreateNewLayerException(Throwable cause) {
121
            super("Can't create the layer", cause, "_cant_create_the_layer",
122
                serialVersionUID);
123
        }
124
    }
125

  
126
    public class CantOpenStoreException extends NewLayerServiceException {
127

  
128
        /**
129
		 * 
130
		 */
131
        private static final long serialVersionUID = -2245228621032918630L;
132

  
133
        public CantOpenStoreException(Throwable cause) {
134
            super("Can't open store", cause, "_cant_open_store",
135
                serialVersionUID);
136
        }
137
    }
138

  
139
    public class CantLoadNewLayerException extends NewLayerServiceException {
140

  
141
        /**
142
		 * 
143
		 */
144
        private static final long serialVersionUID = -1711950651766745963L;
145

  
146
        public CantLoadNewLayerException(Throwable cause) {
147
            super("Can't load the new layer", cause,
148
                "_cant_load_the_new_layer", serialVersionUID);
149
        }
150
    }
151

  
152
    public void setType(String type) {
153
        try {
154
            setProviderFactory(this.newLayerManager
155
                .getNewLayerProviderFactory(type));
156
        } catch (ServiceException e) {
157
            throw new RuntimeException(e);
158
        }
159
    }
160

  
161
    public DataServerExplorer getExplorer() {
162
        return getProvider().getExplorer();
163
    }
164

  
165
    public String getStoreName() {
166
        return getProvider().getStoreName();
167
    }
168

  
169
    public EditableFeatureType getFeatureType() {
170
        return getProvider().getFeatureType();
171
    }
172

  
173
    public NewFeatureStoreParameters getNewStoreParameters() {
174
        return getProvider().getNewStoreParameters();
175
    }
176

  
177
    public DataStoreParameters getOpenStoreParameters() {
178
        return getProvider().getOpenStoreParameters();
179
    }
180

  
181
    public List<String> getTypes() {
182
        List<String> types = new ArrayList<String>();
183
        List<NewLayerProviderFactory> providers = getProviderFactories();
184
        Iterator<NewLayerProviderFactory> it = providers.iterator();
185
        while (it.hasNext()) {
186
            NewLayerProviderFactory newLayerProviderFactory = it.next();
187
            types.add(newLayerProviderFactory.getName());
188
        }
189
        return types;
190
    }
191

  
192
    public String getType() {
193
        return this.type.getName();
194
    }
195

  
196
    public void addLayerToView(boolean b) {
197
        this.addLayerToView = b;
198
    }
199

  
200
    public MapContext getMapContext() {
201
        return mapContext;
202
    }
203

  
204
    public void setProviderFactory(NewLayerProviderFactory type) {
205
        this.type = type;
206
        this.provider = type.create(this);
207
    }
208

  
209
    public NewLayerProviderFactory getProviderFactory() {
210
        return type;
211
    }
212

  
213
    public List<NewLayerProviderFactory> getProviderFactories() {
214

  
215
        List<NewLayerProviderFactory> providers =
216
            new ArrayList<NewLayerProviderFactory>(
217
                this.newLayerManager
218
                    .getProviders(NewLayerManager.STORETYPE.ANY));
219

  
220
        for (Iterator<NewLayerProviderFactory> iterator = providers.iterator(); iterator
221
            .hasNext();) {
222
            NewLayerProviderFactory newLayerProviderFactory = iterator.next();
223
            if (!newLayerProviderFactory.isEnabled()) {
224
                iterator.remove();
225
            }
226
        }
227

  
228
        return providers;
229
    }
230

  
231
}
0 232

  
tags/org.gvsig.desktop-2.0.66/org.gvsig.desktop.library/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/main/java/org/gvsig/newlayer/impl/DefaultNewLayerWizard.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.newlayer.impl;
25

  
26
import java.awt.Dimension;
27
import java.util.Iterator;
28
import java.util.List;
29

  
30
import javax.swing.ImageIcon;
31
import javax.swing.JOptionPane;
32
import javax.swing.JPanel;
33

  
34
import jwizardcomponent.CancelAction;
35
import jwizardcomponent.DefaultJWizardComponents;
36
import jwizardcomponent.FinishAction;
37
import jwizardcomponent.JWizardComponents;
38

  
39
import org.slf4j.Logger;
40
import org.slf4j.LoggerFactory;
41

  
42
import org.gvsig.fmap.dal.DALLocator;
43
import org.gvsig.fmap.dal.DataStoreProviderFactory;
44
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory;
45
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException;
46
import org.gvsig.gui.beans.wizard.panel.OptionPanel;
47
import org.gvsig.i18n.Messages;
48
import org.gvsig.newlayer.NewLayerException;
49
import org.gvsig.newlayer.NewLayerProviderFactory;
50
import org.gvsig.newlayer.NewLayerProviderPanel;
51
import org.gvsig.newlayer.NewLayerService;
52
import org.gvsig.newlayer.NewLayerServiceException;
53
import org.gvsig.newlayer.NewLayerWizard;
54

  
55
public class DefaultNewLayerWizard extends NewLayerWizard {
56

  
57
	/**
58
	 * 
59
	 */
60
	private static final long serialVersionUID = -5827106636136663823L;
61
	private NewLayerService service;
62
	private AddNewLayerQuestionPanel addNewLayerQuestionPanel;
63
	private static final Logger LOG =
64
        LoggerFactory.getLogger(DefaultNewLayerWizard.class);
65

  
66
	public DefaultNewLayerWizard(ImageIcon logo, NewLayerService service) {
67
		super(logo);
68
		setPreferredSize(new Dimension(800, 400));
69
		this.service = service;
70
		this.getWizardComponents().setFinishAction(
71
				new MyFinishAction(this.getWizardComponents()));
72
		this.getWizardComponents().setCancelAction(
73
				new MyCancelAction(this.getWizardComponents()));
74
		this.createTypeSelector();
75
		
76
		// ================ disable at the start
77
        this.setFinishButtonEnabled(false);
78
        this.setBackButtonEnabled(false);
79
        this.setNextButtonEnabled(false);
80
	}
81

  
82
	public NewLayerService getService() {
83
		return this.service;
84
	}
85

  
86
	private void createTypeSelector() {
87

  
88
		TypeSelectorPanel panel = new TypeSelectorPanel(this);
89
		this.addOptionPanel(panel);
90

  
91
	}
92

  
93
	private void createFeatureTypePanel() {
94
	    
95
		FeatureTypePanel panel = new FeatureTypePanel(service);
96
		this.addOptionPanel(panel);
97
	}
98

  
99
	private void createProviderPanels() {
100
		DefaultJWizardComponents wizardComponents = this.getWizardComponents();
101
		for (int i = wizardComponents.getWizardPanelList().size() - 1; i >= 1; i--) {
102
			wizardComponents.removeWizardPanel(i);
103
		}
104
		List<NewLayerProviderPanel> panels = service.getProvider().getPanels();
105
		Iterator<NewLayerProviderPanel> it = panels.iterator();
106
		while (it.hasNext()) {
107
			NewLayerProviderPanel panel = it.next();
108
			this.addOptionPanel(new OptionPanelWrapper(panel));
109
		}
110
		this.createFeatureTypePanel();
111
		this.createAddNewLayerQuestionPanel();
112
	}
113

  
114
	private AddNewLayerQuestionPanel getAddNewLayerQuestionPanel() {
115
		if (this.addNewLayerQuestionPanel == null) {
116
			this.addNewLayerQuestionPanel = new AddNewLayerQuestionPanel(this);
117
		}
118
		return this.addNewLayerQuestionPanel;
119
	}
120

  
121
	private void createAddNewLayerQuestionPanel() {
122
		this.addOptionPanel(getAddNewLayerQuestionPanel());
123
	}
124

  
125
	private boolean getAddLayerToView() {
126
		return getAddNewLayerQuestionPanel().getAddLayerToView();
127
	}
128

  
129
	@Override
130
    public void setType(NewLayerProviderFactory currentType) {
131
        this.service.setProviderFactory(currentType);
132
		createProviderPanels();
133
	}
134

  
135
	private class OptionPanelWrapper implements OptionPanel {
136

  
137
		private NewLayerProviderPanel panel;
138

  
139
		public OptionPanelWrapper(NewLayerProviderPanel panel) {
140
			this.panel = panel;
141
		}
142

  
143
		public String getPanelTitle() {
144
			return this.panel.getTitle();
145
		}
146

  
147
		public void nextPanel() throws NotContinueWizardException {
148

  
149
		    try {
150
    			if (!this.panel.isValidPanel()) {
151
    				throw new NotContinueWizardException("Error validating the form", panel, false);
152
    			}
153
		    } catch (NewLayerException e) {
154
                LOG.info("Error validating the form", e);
155
                throw new NotContinueWizardException("Error validating the form",
156
                    e, panel);
157
            }
158
		}
159

  
160
		public void lastPanel() {
161
		}
162

  
163
		public void updatePanel() {
164
			this.panel.updatePanel();
165
		}
166

  
167
		public JPanel getJPanel() {
168
			return this.panel;
169
		}
170

  
171
	}
172

  
173
	private class MyFinishAction extends FinishAction {
174

  
175
		public MyFinishAction(JWizardComponents arg0) {
176
			super(arg0);
177
		}
178

  
179
		public void performAction() {
180

  
181
			if (getService().getStoreName() == null) {
182
				JOptionPane
183
				.showMessageDialog(
184
						null,
185
						Messages.getText("new_layer_not_store_name"),
186
						Messages.getText("new_layer"),
187
						JOptionPane.WARNING_MESSAGE);
188
				return;
189
			}
190
			if (getService().getNewStoreParameters() == null) {
191
				JOptionPane
192
				.showMessageDialog(
193
						null,
194
						Messages.getText("new_layer_parameters_missing"),
195
						Messages.getText("new_layer"),
196
						JOptionPane.WARNING_MESSAGE);
197
				return;
198
			}
199
			getService().addLayerToView(getAddLayerToView());
200
			try {
201
				getService().createLayer();
202
			} catch (NewLayerServiceException e) {
203
				LOG.info("Cannot create the new layer", e);
204
				JOptionPane
205
				.showMessageDialog(
206
						null,
207
						Messages.getText("cant_create_new_layer") + "\n" + e.getMessageStack(),
208
						Messages.getText("new_layer"),
209
						JOptionPane.ERROR_MESSAGE);
210
				return;
211
			}
212
			
213
			try {
214
				getService().loadLayer();
215
			} catch (NewLayerServiceException e) {
216
				JOptionPane
217
				.showMessageDialog(
218
						null,
219
						"The new layer has been succesfully created but can't load the new layer.\n Try load it yourshelf, please.",
220
						"Can't create a new layer",
221
						JOptionPane.WARNING_MESSAGE);
222
			}
223
			setVisible(false);
224
			return;
225
		}
226

  
227
	}
228

  
229
	private class MyCancelAction extends CancelAction {
230

  
231
		public MyCancelAction(DefaultJWizardComponents wizardComponents) {
232
			super(wizardComponents);
233
		}
234

  
235
		public void performAction() {
236
			setVisible(false);
237
		}
238

  
239
	}
240
}
0 241

  
tags/org.gvsig.desktop-2.0.66/org.gvsig.desktop.library/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/main/java/org/gvsig/newlayer/impl/FeatureTypePanel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.newlayer.impl;
25

  
26
import java.awt.BorderLayout;
27
import java.awt.Component;
28
import java.awt.GridBagConstraints;
29
import java.awt.GridBagLayout;
30
import java.awt.Insets;
31
import java.awt.event.ActionEvent;
32
import java.awt.event.ActionListener;
33
import java.awt.event.ItemEvent;
34
import java.awt.event.ItemListener;
35
import java.util.ArrayList;
36
import java.util.Iterator;
37
import java.util.List;
38

  
39
import javax.swing.ComboBoxModel;
40
import javax.swing.DefaultCellEditor;
41
import javax.swing.JButton;
42
import javax.swing.JCheckBox;
43
import javax.swing.JComboBox;
44
import javax.swing.JLabel;
45
import javax.swing.JOptionPane;
46
import javax.swing.JPanel;
47
import javax.swing.JScrollPane;
48
import javax.swing.JTable;
49
import javax.swing.JTextField;
50
import javax.swing.ListSelectionModel;
51
import javax.swing.UIManager;
52
import javax.swing.event.ListDataListener;
53
import javax.swing.event.ListSelectionEvent;
54
import javax.swing.event.ListSelectionListener;
55
import javax.swing.event.TableModelEvent;
56
import javax.swing.event.TableModelListener;
57
import javax.swing.table.DefaultTableCellRenderer;
58
import javax.swing.table.DefaultTableModel;
59
import javax.swing.table.TableCellRenderer;
60
import javax.swing.table.TableColumn;
61
import javax.swing.table.TableModel;
62

  
63
import org.cresques.cts.IProjection;
64
import org.slf4j.Logger;
65
import org.slf4j.LoggerFactory;
66

  
67
import org.gvsig.app.gui.panels.CRSSelectPanel;
68
import org.gvsig.app.gui.panels.crs.ISelectCrsPanel;
69
import org.gvsig.fmap.dal.DALLocator;
70
import org.gvsig.fmap.dal.DataManager;
71
import org.gvsig.fmap.dal.DataStoreProviderFactory;
72
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
73
import org.gvsig.fmap.dal.feature.EditableFeatureType;
74
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
75
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory;
76
import org.gvsig.fmap.dal.feature.FeatureType;
77
import org.gvsig.fmap.geom.DataTypes;
78
import org.gvsig.fmap.geom.Geometry;
79
import org.gvsig.fmap.geom.GeometryLocator;
80
import org.gvsig.fmap.geom.GeometryManager;
81
import org.gvsig.fmap.geom.type.GeometryType;
82
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException;
83
import org.gvsig.gui.beans.wizard.panel.OptionPanel;
84
import org.gvsig.i18n.Messages;
85
import org.gvsig.newlayer.NewLayerService;
86
import org.gvsig.tools.dataTypes.DataType;
87
import org.gvsig.tools.swing.api.ToolsSwingLocator;
88
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
89

  
90
public class FeatureTypePanel extends JPanel implements OptionPanel {
91
    private static final int COLUMN_FIELD = 0;
92
    private static final int COLUMN_TYPE = 1;
93
    private static final int COLUMN_LENGTH = 2;
94
    private static final int COLUMN_GEOMETRYTYPE = 3;
95
    private static final int COLUMN_GEOMETRYSUBTYPE = 4;
96
    private static final int COLUMN_CRS = 5;
97
    private static final int COLUMN_PRIMARYKEY = 6;
98
    private static final int COLUMN_MANDATORY = 7;
99
 
100
	private static final long serialVersionUID = 263541873998597624L;
101
	
102
    private FeatureType defaultFeatType = null;
103
    
104
    private NewLayerService newLayer_Service = null;
105
    private int inDefaultFeatTypeFieldCount = 0;
106
	private String inStoreName = null;
107
	private IProjection inProjection = null;
108
	private FeatureStoreProviderFactory spFactory = null;
109
	private boolean defaultHasGeometry = false;
110
	
111
	private static final Logger logger = LoggerFactory
112
			.getLogger(FeatureTypePanel.class);
113

  
114
	private JLabel jLabel = null;
115
	private JScrollPane jScrollPane = null;
116
	protected JTable jTable = null;
117
	private JPanel jPanelEast = null;
118
	private JButton addFieldButton = null;
119
	private JButton deleteFieldButton = null;
120
	protected int MAX_FIELD_LENGTH = 254;
121
	
122
	// we dont need this list
123
	// we'll clear and rebuild featureType each time
124
	// the user clicks next
125
	// private List removedFields;
126

  
127
	// private DataServerExplorer explorer = null;
128

  
129
	public FeatureTypePanel(NewLayerService new_layer_service) {
130
	    
131
	    /*
132
	    service.getFeatureType(),
133
        service.getStoreName(),
134
        service.getMapContext().getProjection();
135
        */
136
	    newLayer_Service = new_layer_service;
137
	}
138
	
139
	private boolean fieldsInited = false;
140
	
141
	private void initFields() {
142
	    
143
	    if (newLayer_Service == null) {
144
	        return;
145
	    }
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff