Revision 38023
tags/v2_0_0_Build_2045/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.newlayer.NewLayerLibrary |
tags/v2_0_0_Build_2045/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.api/src/main/resources/filters.txt | ||
---|---|---|
1 |
point_geometries_only= |
|
2 |
curve_geometries_only= |
|
3 |
surface_geometries_only= |
tags/v2_0_0_Build_2045/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.api/src/main/java/org/gvsig/newlayer/NewLayerManager.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
package org.gvsig.newlayer; |
|
23 |
|
|
24 |
import java.util.List; |
|
25 |
|
|
26 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
27 |
import org.gvsig.newlayer.preferences.NewLayerPreferencesComponent; |
|
28 |
import org.gvsig.tools.service.ServiceException; |
|
29 |
|
|
30 |
/** |
|
31 |
* This class is responsible of the management of the library's business logic. |
|
32 |
* It is the library's main entry point, and provides all the services to manage |
|
33 |
* {@link NewLayerService}s. |
|
34 |
* |
|
35 |
* @see NewLayerService |
|
36 |
* @author gvSIG team |
|
37 |
* @version $Id$ |
|
38 |
*/ |
|
39 |
public interface NewLayerManager { |
|
40 |
|
|
41 |
public enum STORETYPE{ANY,TABULAR,SPATIAL}; |
|
42 |
|
|
43 |
|
|
44 |
/** |
|
45 |
* Create an instance of a {@link NewLayerService}. |
|
46 |
* @return {@link NewLayerService} |
|
47 |
* @throws ServiceException |
|
48 |
* if there is an error getting the service |
|
49 |
*/ |
|
50 |
public NewLayerService createNewLayerService(MapContext mapContext); |
|
51 |
|
|
52 |
public void registerProvider(NewLayerProviderFactory factory); |
|
53 |
|
|
54 |
public List<NewLayerProviderFactory> getProviders(STORETYPE filter); |
|
55 |
|
|
56 |
public List<NewLayerProviderFactory> getProviders(); |
|
57 |
|
|
58 |
public NewLayerWizard createNewLayerWizard(NewLayerService service); |
|
59 |
|
|
60 |
/** |
|
61 |
* Returns the provider factory with the given name. |
|
62 |
* |
|
63 |
* @param name |
|
64 |
* of the provider |
|
65 |
* @return the provider factory |
|
66 |
* @throws ServiceException |
|
67 |
* if there is an error getting the provider factory |
|
68 |
*/ |
|
69 |
public NewLayerProviderFactory getNewLayerProviderFactory( |
|
70 |
String providerName) throws ServiceException; |
|
71 |
|
|
72 |
/** |
|
73 |
* Enables or disables a new layer provider. |
|
74 |
* |
|
75 |
* @param factory |
|
76 |
* of the provider to enable or disable |
|
77 |
* @param value |
|
78 |
* if the provider must be enabled or disabled |
|
79 |
*/ |
|
80 |
public void enableProvider(NewLayerProviderFactory factory, Boolean false1); |
|
81 |
|
|
82 |
/** |
|
83 |
* Creates a preferences component to manage the export to properties. |
|
84 |
* |
|
85 |
* @return a preferences component |
|
86 |
*/ |
|
87 |
public NewLayerPreferencesComponent createNewLayerProvidersPreferences(); |
|
88 |
|
|
89 |
/** |
|
90 |
* Returns if the provider whose factory is provided is enabled. |
|
91 |
* |
|
92 |
* @param factory |
|
93 |
* of the provider to check |
|
94 |
* @return if the provider whose factory is provided is enabled |
|
95 |
*/ |
|
96 |
public boolean isProviderEnabled(NewLayerProviderFactory factory); |
|
97 |
|
|
98 |
} |
tags/v2_0_0_Build_2045/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.api/src/main/java/org/gvsig/newlayer/NewLayerProvider.java | ||
---|---|---|
1 |
package org.gvsig.newlayer; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
6 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
7 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
|
8 |
import org.gvsig.tools.service.spi.Provider; |
|
9 |
|
|
10 |
public interface NewLayerProvider extends Provider{ |
|
11 |
|
|
12 |
public NewLayerService getService(); |
|
13 |
|
|
14 |
public DataServerExplorer getExplorer(); |
|
15 |
|
|
16 |
public String getStoreName(); |
|
17 |
|
|
18 |
public EditableFeatureType getFeatureType(); |
|
19 |
|
|
20 |
public NewFeatureStoreParameters getNewStoreParameters(); |
|
21 |
|
|
22 |
public List<NewLayerProviderPanel> getPanels(); |
|
23 |
} |
tags/v2_0_0_Build_2045/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.api/src/main/java/org/gvsig/newlayer/NewLayerProviderPanel.java | ||
---|---|---|
1 |
package org.gvsig.newlayer; |
|
2 |
|
|
3 |
import javax.swing.JPanel; |
|
4 |
|
|
5 |
|
|
6 |
public abstract class NewLayerProviderPanel extends JPanel{ |
|
7 |
|
|
8 |
|
|
9 |
protected NewLayerProvider provider; |
|
10 |
|
|
11 |
protected NewLayerProviderPanel(NewLayerProvider provider){ |
|
12 |
this.provider = provider; |
|
13 |
} |
|
14 |
|
|
15 |
public abstract String getTitle(); |
|
16 |
|
|
17 |
public abstract boolean isValidPanel() throws NewLayerException; |
|
18 |
|
|
19 |
public abstract void updatePanel(); |
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
} |
tags/v2_0_0_Build_2045/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.api/src/main/java/org/gvsig/newlayer/preferences/NewLayerPreferencesComponent.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
package org.gvsig.newlayer.preferences; |
|
23 |
|
|
24 |
import java.util.Set; |
|
25 |
|
|
26 |
import org.gvsig.newlayer.NewLayerProviderFactory; |
|
27 |
import org.gvsig.tools.swing.api.Component; |
|
28 |
|
|
29 |
/** |
|
30 |
* API for the Export to swing preferences component panel. |
|
31 |
* |
|
32 |
* @author gvSIG Team |
|
33 |
* @version $Id$ |
|
34 |
*/ |
|
35 |
public interface NewLayerPreferencesComponent extends Component { |
|
36 |
|
|
37 |
/** |
|
38 |
* Returns the providers disabled by the user. |
|
39 |
* |
|
40 |
* @return the providers disabled by the user |
|
41 |
*/ |
|
42 |
Set<NewLayerProviderFactory> getDisabledProviders(); |
|
43 |
|
|
44 |
/** |
|
45 |
* Undoes all the user changes in the preferences. |
|
46 |
*/ |
|
47 |
void initializeDefaults(); |
|
48 |
|
|
49 |
/** |
|
50 |
* Is the user has made any change in the preferences. |
|
51 |
* |
|
52 |
* @return the user has made any change |
|
53 |
*/ |
|
54 |
boolean isValueChanged(); |
|
55 |
|
|
56 |
/** |
|
57 |
* Tells the component the changes made by the user to the properties |
|
58 |
* had been performed. |
|
59 |
*/ |
|
60 |
void setChangesApplied(); |
|
61 |
} |
tags/v2_0_0_Build_2045/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.api/src/main/java/org/gvsig/newlayer/NewLayerException.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
package org.gvsig.newlayer; |
|
23 |
|
|
24 |
import org.gvsig.tools.exception.BaseException; |
|
25 |
|
|
26 |
/** |
|
27 |
* Generic exception thrown in the NewLayer API when the exception or error |
|
28 |
* may be dealt by the program or the user of the program which is a client of |
|
29 |
* the NewLayer API. |
|
30 |
* |
|
31 |
* @see {@link NewLayerService} |
|
32 |
* @see {@link NewLayerManager} |
|
33 |
* @author gvSIG team. |
|
34 |
* @version $Id$ |
|
35 |
*/ |
|
36 |
public class NewLayerException extends BaseException { |
|
37 |
|
|
38 |
/** |
|
39 |
* |
|
40 |
*/ |
|
41 |
private static final long serialVersionUID = -2954242107118688337L; |
|
42 |
|
|
43 |
private static final String MESSAGE = |
|
44 |
"An error has been produced in the NewLayer library"; |
|
45 |
|
|
46 |
private static final String KEY = "_NewLayerException"; |
|
47 |
|
|
48 |
/** |
|
49 |
* Constructor to be used in rare cases, usually you must create a new child |
|
50 |
* exception class for each case. |
|
51 |
* <strong>Don't use this constructor in child classes.</strong> |
|
52 |
*/ |
|
53 |
public NewLayerException() { |
|
54 |
super(MESSAGE, KEY, serialVersionUID); |
|
55 |
} |
|
56 |
|
|
57 |
/** |
|
58 |
* Constructor to be used in rare cases, usually you must create a new child |
|
59 |
* exception class for each case. |
|
60 |
* <p> |
|
61 |
* <strong>Don't use this constructor in child classes.</strong> |
|
62 |
* </p> |
|
63 |
* |
|
64 |
* @param cause |
|
65 |
* the original cause of the exception |
|
66 |
*/ |
|
67 |
public NewLayerException(Exception cause) { |
|
68 |
super(MESSAGE, cause, KEY, serialVersionUID); |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* @see BaseException#BaseException(String, String, long). |
|
73 |
* @param message |
|
74 |
* the default messageFormat to describe the exception |
|
75 |
* @param key |
|
76 |
* the key to use to search a localized messageFormnata |
|
77 |
* @param code |
|
78 |
* the unique code to identify the exception |
|
79 |
*/ |
|
80 |
protected NewLayerException(String message, String key, long code) { |
|
81 |
super(message, key, code); |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* @see BaseException#BaseException(String, Throwable, String, long). |
|
86 |
* @param message |
|
87 |
* the default messageFormat to describe the exception |
|
88 |
* @param cause |
|
89 |
* the original cause of the exception |
|
90 |
* @param key |
|
91 |
* the key to use to search a localized messageFormnata |
|
92 |
* @param code |
|
93 |
* the unique code to identify the exception |
|
94 |
*/ |
|
95 |
protected NewLayerException(String message, Throwable cause, |
|
96 |
String key, long code) { |
|
97 |
super(message, cause, key, code); |
|
98 |
} |
|
99 |
} |
tags/v2_0_0_Build_2045/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.api/src/main/java/org/gvsig/newlayer/NewLayerServiceException.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
package org.gvsig.newlayer; |
|
23 |
|
|
24 |
import org.gvsig.tools.exception.BaseException; |
|
25 |
import org.gvsig.tools.service.ServiceException; |
|
26 |
|
|
27 |
/** |
|
28 |
* Exception thrown when there is an error getting a NewLayer message. |
|
29 |
* |
|
30 |
* @author gvSIG team |
|
31 |
* @version $Id$ |
|
32 |
*/ |
|
33 |
public class NewLayerServiceException extends ServiceException { |
|
34 |
/** |
|
35 |
* |
|
36 |
*/ |
|
37 |
private static final long serialVersionUID = -4395786952326742397L; |
|
38 |
|
|
39 |
private static final String MESSAGE = |
|
40 |
"An error has been produced creating a store"; |
|
41 |
|
|
42 |
private static final String KEY = "_NewLayerServiceException"; |
|
43 |
|
|
44 |
/** |
|
45 |
* @see BaseException#BaseException(String, String, long) |
|
46 |
*/ |
|
47 |
protected NewLayerServiceException(String message, String key, long code) { |
|
48 |
super(message, key, code); |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* @see BaseException#BaseException(String, Throwable, String, long) |
|
53 |
*/ |
|
54 |
protected NewLayerServiceException(String message, Throwable cause, String key, |
|
55 |
long code) { |
|
56 |
super(message, cause, key, code); |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* Creates a new {@link NewLayerServiceException}. |
|
61 |
* |
|
62 |
* @param cause |
|
63 |
* the original cause |
|
64 |
*/ |
|
65 |
public NewLayerServiceException(Throwable cause) { |
|
66 |
super(MESSAGE, cause, KEY, serialVersionUID); |
|
67 |
} |
|
68 |
|
|
69 |
} |
tags/v2_0_0_Build_2045/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.api/src/main/java/org/gvsig/newlayer/NewLayerService.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
|
|
23 |
package org.gvsig.newlayer; |
|
24 |
|
|
25 |
import java.util.List; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
28 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
29 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
30 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
|
31 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
32 |
|
|
33 |
/** |
|
34 |
* <p> |
|
35 |
* This service is used to create a new {@link FeatureStore}. |
|
36 |
* </p> |
|
37 |
* |
|
38 |
* @author gvSIG team |
|
39 |
* @version $Id$ |
|
40 |
*/ |
|
41 |
public interface NewLayerService { |
|
42 |
|
|
43 |
/** |
|
44 |
* @deprecated use {@link #setProviderFactory(NewLayerProviderFactory)} |
|
45 |
* instead |
|
46 |
*/ |
|
47 |
public void setType(String type); |
|
48 |
|
|
49 |
/** |
|
50 |
* @deprecated use {@link #getProviderFactory()} instead |
|
51 |
*/ |
|
52 |
public String getType(); |
|
53 |
|
|
54 |
/** |
|
55 |
* @deprecated use {@link #getProviderFactories()} instead |
|
56 |
*/ |
|
57 |
public List<String> getTypes(); |
|
58 |
|
|
59 |
public void setProviderFactory(NewLayerProviderFactory type); |
|
60 |
|
|
61 |
public NewLayerProviderFactory getProviderFactory(); |
|
62 |
|
|
63 |
public List<NewLayerProviderFactory> getProviderFactories(); |
|
64 |
|
|
65 |
public void createLayer() throws NewLayerServiceException; |
|
66 |
|
|
67 |
public void loadLayer() throws NewLayerServiceException; |
|
68 |
|
|
69 |
public DataServerExplorer getExplorer(); |
|
70 |
|
|
71 |
public String getStoreName(); |
|
72 |
|
|
73 |
public EditableFeatureType getFeatureType(); |
|
74 |
|
|
75 |
public NewFeatureStoreParameters getNewStoreParameters(); |
|
76 |
|
|
77 |
public NewLayerProvider getProvider(); |
|
78 |
|
|
79 |
public void addLayerToView(boolean b); |
|
80 |
|
|
81 |
public MapContext getMapContext(); |
|
82 |
|
|
83 |
} |
tags/v2_0_0_Build_2045/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.api/src/main/java/org/gvsig/newlayer/NewLayerWizard.java | ||
---|---|---|
1 |
package org.gvsig.newlayer; |
|
2 |
|
|
3 |
import javax.swing.ImageIcon; |
|
4 |
|
|
5 |
import org.gvsig.gui.beans.wizard.WizardPanelWithLogo; |
|
6 |
|
|
7 |
|
|
8 |
public abstract class NewLayerWizard extends WizardPanelWithLogo{ |
|
9 |
|
|
10 |
private static final long serialVersionUID = -9070328984844239279L; |
|
11 |
|
|
12 |
public NewLayerWizard(ImageIcon logo) { |
|
13 |
super(logo); |
|
14 |
} |
|
15 |
|
|
16 |
public abstract NewLayerService getService(); |
|
17 |
|
|
18 |
public abstract void setType(NewLayerProviderFactory currentType); |
|
19 |
|
|
20 |
} |
tags/v2_0_0_Build_2045/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.api/src/main/java/org/gvsig/newlayer/NewLayerProviderFactory.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
package org.gvsig.newlayer; |
|
23 |
|
|
24 |
import org.gvsig.tools.service.spi.ProviderFactory; |
|
25 |
|
|
26 |
/** |
|
27 |
* @author gvSIG Team |
|
28 |
* @version $Id$ |
|
29 |
*/ |
|
30 |
public interface NewLayerProviderFactory extends ProviderFactory { |
|
31 |
|
|
32 |
public boolean isSpatial(); |
|
33 |
|
|
34 |
public NewLayerProvider create(NewLayerService service); |
|
35 |
|
|
36 |
/** |
|
37 |
* If the provider this factory creates is enabled. This option might |
|
38 |
* be used as a way to show or not some providers to the user. |
|
39 |
* |
|
40 |
* @return if the provider is enabled |
|
41 |
*/ |
|
42 |
public boolean isEnabled(); |
|
43 |
|
|
44 |
/** |
|
45 |
* Enable or disable this provider factory. |
|
46 |
* |
|
47 |
* @param value |
|
48 |
* if to enable or disable the factory |
|
49 |
*/ |
|
50 |
public void setEnabled(boolean value); |
|
51 |
|
|
52 |
/** |
|
53 |
* Returns a description of the provider. |
|
54 |
* |
|
55 |
* @return a description for the provider |
|
56 |
*/ |
|
57 |
public String getDescription(); |
|
58 |
|
|
59 |
/** |
|
60 |
* Returns a label or short description for the provider. |
|
61 |
* |
|
62 |
* @return a label or short description for the provider |
|
63 |
*/ |
|
64 |
public String getLabel(); |
|
65 |
} |
tags/v2_0_0_Build_2045/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.api/src/main/java/org/gvsig/newlayer/NewLayerLocator.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
package org.gvsig.newlayer; |
|
23 |
|
|
24 |
import org.gvsig.tools.locator.BaseLocator; |
|
25 |
import org.gvsig.tools.locator.Locator; |
|
26 |
import org.gvsig.tools.locator.LocatorException; |
|
27 |
|
|
28 |
/** |
|
29 |
* This locator is the entry point for the NewLayer library, providing |
|
30 |
* access to all NewLayer services through the {@link NewLayerManager} |
|
31 |
* . |
|
32 |
* |
|
33 |
* @author gvSIG team |
|
34 |
* @version $Id$ |
|
35 |
*/ |
|
36 |
public class NewLayerLocator extends BaseLocator { |
|
37 |
|
|
38 |
/** |
|
39 |
* NewLayer manager name. |
|
40 |
*/ |
|
41 |
public static final String MANAGER_NAME = "NewLayer.manager"; |
|
42 |
|
|
43 |
/** |
|
44 |
* NewLayer manager description. |
|
45 |
*/ |
|
46 |
public static final String MANAGER_DESCRIPTION = "NewLayer Manager"; |
|
47 |
|
|
48 |
private static final String LOCATOR_NAME = "NewLayer.locator"; |
|
49 |
|
|
50 |
/** |
|
51 |
* Unique instance. |
|
52 |
*/ |
|
53 |
private static final NewLayerLocator INSTANCE = |
|
54 |
new NewLayerLocator(); |
|
55 |
|
|
56 |
/** |
|
57 |
* Return the singleton instance. |
|
58 |
* |
|
59 |
* @return the singleton instance |
|
60 |
*/ |
|
61 |
public static NewLayerLocator getInstance() { |
|
62 |
return INSTANCE; |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* Return the Locator's name. |
|
67 |
* |
|
68 |
* @return a String with the Locator's name |
|
69 |
*/ |
|
70 |
public final String getLocatorName() { |
|
71 |
return LOCATOR_NAME; |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* Return a reference to the NewLayerManager. |
|
76 |
* |
|
77 |
* @return a reference to the NewLayerManager |
|
78 |
* @throws LocatorException |
|
79 |
* if there is no access to the class or the class cannot be |
|
80 |
* instantiated |
|
81 |
* @see Locator#get(String) |
|
82 |
*/ |
|
83 |
public static NewLayerManager getManager() throws LocatorException { |
|
84 |
return (NewLayerManager) getInstance().get(MANAGER_NAME); |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* Registers the Class implementing the NewLayerManager interface. |
|
89 |
* |
|
90 |
* @param clazz |
|
91 |
* implementing the NewLayerManager interface |
|
92 |
*/ |
|
93 |
public static void registerManager( |
|
94 |
Class<? extends NewLayerManager> clazz) { |
|
95 |
getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz); |
|
96 |
} |
|
97 |
|
|
98 |
} |
tags/v2_0_0_Build_2045/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.api/src/main/java/org/gvsig/newlayer/NewLayerLibrary.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
package org.gvsig.newlayer; |
|
23 |
|
|
24 |
import org.gvsig.tools.library.AbstractLibrary; |
|
25 |
import org.gvsig.tools.library.LibraryException; |
|
26 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
|
27 |
|
|
28 |
/** |
|
29 |
* Library for API initialization and configuration. |
|
30 |
* |
|
31 |
* @author gvSIG team |
|
32 |
* @version $Id$ |
|
33 |
*/ |
|
34 |
public class NewLayerLibrary extends AbstractLibrary { |
|
35 |
|
|
36 |
@Override |
|
37 |
public void doRegistration() { |
|
38 |
registerAsAPI(NewLayerLibrary.class); |
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
protected void doInitialize() throws LibraryException { |
|
43 |
// Do nothing |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
protected void doPostInitialize() throws LibraryException { |
|
48 |
// Validate there is any implementation registered. |
|
49 |
NewLayerManager manager = NewLayerLocator.getManager(); |
|
50 |
if (manager == null) { |
|
51 |
throw new ReferenceNotRegisteredException( |
|
52 |
NewLayerLocator.MANAGER_NAME, NewLayerLocator |
|
53 |
.getInstance()); |
|
54 |
} |
|
55 |
} |
|
56 |
|
|
57 |
} |
tags/v2_0_0_Build_2045/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.api/src/main/java/org/gvsig/newlayer/spi/AbstractNewLayerProviderFactory.java | ||
---|---|---|
1 |
package org.gvsig.newlayer.spi; |
|
2 |
|
|
3 |
import org.gvsig.newlayer.NewLayerLocator; |
|
4 |
import org.gvsig.newlayer.NewLayerProviderFactory; |
|
5 |
import org.gvsig.tools.dynobject.DynClass; |
|
6 |
import org.gvsig.tools.dynobject.DynObject; |
|
7 |
import org.gvsig.tools.service.ServiceException; |
|
8 |
import org.gvsig.tools.service.spi.Provider; |
|
9 |
import org.gvsig.tools.service.spi.ProviderServices; |
|
10 |
|
|
11 |
public abstract class AbstractNewLayerProviderFactory implements NewLayerProviderFactory{ |
|
12 |
|
|
13 |
public final Provider doCreate(DynObject parameters, ProviderServices services) { |
|
14 |
throw new UnsupportedOperationException(); |
|
15 |
} |
|
16 |
|
|
17 |
public DynObject createParameters() { |
|
18 |
throw new UnsupportedOperationException(); |
|
19 |
} |
|
20 |
|
|
21 |
public void initialize() { |
|
22 |
throw new UnsupportedOperationException(); |
|
23 |
} |
|
24 |
|
|
25 |
protected DynClass createParametersDynClass() { |
|
26 |
throw new UnsupportedOperationException(); |
|
27 |
} |
|
28 |
|
|
29 |
public Provider create(DynObject parameters, ProviderServices services) |
|
30 |
throws ServiceException { |
|
31 |
throw new UnsupportedOperationException(); |
|
32 |
} |
|
33 |
|
|
34 |
public boolean isEnabled() { |
|
35 |
return NewLayerLocator.getManager().isProviderEnabled(this); |
|
36 |
} |
|
37 |
|
|
38 |
public void setEnabled(boolean value) { |
|
39 |
NewLayerLocator.getManager().enableProvider(this, value); |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public String toString() { |
|
44 |
return getLabel(); |
|
45 |
} |
|
46 |
} |
tags/v2_0_0_Build_2045/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.api/src/main/java/org/gvsig/newlayer/spi/AbstractNewLayerProvider.java | ||
---|---|---|
1 |
package org.gvsig.newlayer.spi; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
4 |
import org.gvsig.newlayer.NewLayerProvider; |
|
5 |
import org.gvsig.newlayer.NewLayerService; |
|
6 |
import org.gvsig.tools.service.spi.ProviderServices; |
|
7 |
|
|
8 |
public abstract class AbstractNewLayerProvider implements NewLayerProvider{ |
|
9 |
|
|
10 |
private NewLayerService service; |
|
11 |
protected DataServerExplorer explorer; |
|
12 |
protected String storeName; |
|
13 |
|
|
14 |
protected AbstractNewLayerProvider(NewLayerService service){ |
|
15 |
this.service = service; |
|
16 |
} |
|
17 |
|
|
18 |
public NewLayerService getService() { |
|
19 |
return service; |
|
20 |
} |
|
21 |
|
|
22 |
public DataServerExplorer getExplorer() { |
|
23 |
return explorer; |
|
24 |
} |
|
25 |
|
|
26 |
public String getStoreName() { |
|
27 |
return storeName; |
|
28 |
} |
|
29 |
|
|
30 |
public void setProviderServices(ProviderServices services) { |
|
31 |
throw new UnsupportedOperationException(); |
|
32 |
} |
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
} |
tags/v2_0_0_Build_2045/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.api/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
3 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.newlayer.lib.api</artifactId> |
|
6 |
<packaging>jar</packaging> |
|
7 |
<name>org.gvsig.newlayer.lib.api</name> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.newlayer.lib</artifactId> |
|
11 |
<version>1.0.0-SNAPSHOT</version> |
|
12 |
</parent> |
|
13 |
<dependencies> |
|
14 |
<dependency> |
|
15 |
<groupId>org.gvsig</groupId> |
|
16 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
17 |
<scope>compile</scope> |
|
18 |
</dependency> |
|
19 |
<dependency> |
|
20 |
<groupId>org.gvsig</groupId> |
|
21 |
<artifactId>org.gvsig.tools.swing.api</artifactId> |
|
22 |
<scope>compile</scope> |
|
23 |
</dependency> |
|
24 |
<dependency> |
|
25 |
<groupId>org.gvsig</groupId> |
|
26 |
<artifactId>org.gvsig.fmap.dal</artifactId> |
|
27 |
<scope>compile</scope> |
|
28 |
</dependency> |
|
29 |
<dependency> |
|
30 |
<groupId>org.gvsig</groupId> |
|
31 |
<artifactId>org.gvsig.projection</artifactId> |
|
32 |
<scope>compile</scope> |
|
33 |
</dependency> |
|
34 |
<dependency> |
|
35 |
<groupId>org.gvsig</groupId> |
|
36 |
<artifactId>org.gvsig.ui</artifactId> |
|
37 |
<version>2.0.1-SNAPSHOT</version> |
|
38 |
<scope>compile</scope> |
|
39 |
</dependency> |
|
40 |
<dependency> |
|
41 |
<groupId>jwizardcomponent</groupId> |
|
42 |
<artifactId>jwizardcomponent</artifactId> |
|
43 |
<scope>compile</scope> |
|
44 |
</dependency> |
|
45 |
<dependency> |
|
46 |
<groupId>org.gvsig</groupId> |
|
47 |
<artifactId>org.gvsig.fmap.mapcontext</artifactId> |
|
48 |
<version>2.0-SNAPSHOT</version> |
|
49 |
<scope>compile</scope> |
|
50 |
</dependency> |
|
51 |
</dependencies> |
|
52 |
<build> |
|
53 |
<plugins> |
|
54 |
<plugin> |
|
55 |
<groupId>org.apache.maven.plugins</groupId> |
|
56 |
<artifactId>maven-jar-plugin</artifactId> |
|
57 |
<configuration> |
|
58 |
</configuration> |
|
59 |
<executions> |
|
60 |
<!-- Generates a jar file only with the test classes --> |
|
61 |
<execution> |
|
62 |
<goals> |
|
63 |
<goal>test-jar</goal> |
|
64 |
</goals> |
|
65 |
</execution> |
|
66 |
</executions> |
|
67 |
</plugin> |
|
68 |
</plugins> |
|
69 |
</build> |
|
70 |
</project> |
|
0 | 71 |
tags/v2_0_0_Build_2045/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
3 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 |
|
4 |
http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
5 |
|
|
6 |
<modelVersion>4.0.0</modelVersion> |
|
7 |
<artifactId>org.gvsig.newlayer.lib</artifactId> |
|
8 |
<packaging>pom</packaging> |
|
9 |
<name>org.gvsig.newlayer.lib</name> |
|
10 |
<parent> |
|
11 |
<groupId>org.gvsig</groupId> |
|
12 |
<artifactId>org.gvsig.newlayer</artifactId> |
|
13 |
<version>1.0.0-SNAPSHOT</version> |
|
14 |
</parent> |
|
15 |
|
|
16 |
<modules> |
|
17 |
<module>org.gvsig.newlayer.lib.api</module> |
|
18 |
<module>org.gvsig.newlayer.lib.impl</module> |
|
19 |
</modules> |
|
20 |
</project> |
tags/v2_0_0_Build_2045/libraries/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. |
tags/v2_0_0_Build_2045/libraries/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 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
3 |
|
|
4 |
<!-- |
|
5 |
Log4J configuration file for unit tests execution. |
|
6 |
--> |
|
7 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
8 |
|
|
9 |
<!-- Appender configuration to show logging messages through the console --> |
|
10 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
11 |
<layout class="org.apache.log4j.PatternLayout"> |
|
12 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
13 |
</layout> |
|
14 |
</appender> |
|
15 |
|
|
16 |
<!-- |
|
17 |
Activate logging messages of DEBUG level of higher only for the |
|
18 |
org.gvsig.tools packages. |
|
19 |
You can put full classes names or packages instead, to configure |
|
20 |
logging for all the classes and subpackages of the package. |
|
21 |
--> |
|
22 |
<category name="org.gvsig.tools"> |
|
23 |
<priority value="DEBUG" /> |
|
24 |
</category> |
|
25 |
<category name="org.gvsig.newlayer"> |
|
26 |
<priority value="DEBUG" /> |
|
27 |
</category> |
|
28 |
|
|
29 |
<!-- |
|
30 |
By default, show only logging messages of INFO level or higher, |
|
31 |
through the previously configured CONSOLE appender. |
|
32 |
--> |
|
33 |
<root> |
|
34 |
<priority value="INFO" /> |
|
35 |
<appender-ref ref="CONSOLE" /> |
|
36 |
</root> |
|
37 |
</log4j:configuration> |
tags/v2_0_0_Build_2045/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/main/java/org/gvsig/newlayer/impl/FeatureTypePanel.java | ||
---|---|---|
1 |
package org.gvsig.newlayer.impl; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Component; |
|
5 |
import java.awt.event.ActionEvent; |
|
6 |
import java.awt.event.ActionListener; |
|
7 |
import java.util.ArrayList; |
|
8 |
import java.util.Iterator; |
|
9 |
import java.util.List; |
|
10 |
|
|
11 |
import javax.swing.ComboBoxModel; |
|
12 |
import javax.swing.DefaultCellEditor; |
|
13 |
import javax.swing.JButton; |
|
14 |
import javax.swing.JCheckBox; |
|
15 |
import javax.swing.JComboBox; |
|
16 |
import javax.swing.JLabel; |
|
17 |
import javax.swing.JPanel; |
|
18 |
import javax.swing.JScrollPane; |
|
19 |
import javax.swing.JTable; |
|
20 |
import javax.swing.ListSelectionModel; |
|
21 |
import javax.swing.UIManager; |
|
22 |
import javax.swing.event.ListDataListener; |
|
23 |
import javax.swing.event.ListSelectionEvent; |
|
24 |
import javax.swing.event.ListSelectionListener; |
|
25 |
import javax.swing.event.TableModelEvent; |
|
26 |
import javax.swing.event.TableModelListener; |
|
27 |
import javax.swing.table.DefaultTableModel; |
|
28 |
import javax.swing.table.TableCellRenderer; |
|
29 |
import javax.swing.table.TableColumn; |
|
30 |
|
|
31 |
import org.cresques.cts.IProjection; |
|
32 |
import org.slf4j.Logger; |
|
33 |
import org.slf4j.LoggerFactory; |
|
34 |
|
|
35 |
import org.gvsig.app.gui.panels.CRSSelectPanel; |
|
36 |
import org.gvsig.app.gui.panels.crs.ISelectCrsPanel; |
|
37 |
import org.gvsig.fmap.dal.DALLocator; |
|
38 |
import org.gvsig.fmap.dal.DataManager; |
|
39 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
40 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
41 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
42 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
43 |
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory; |
|
44 |
import org.gvsig.fmap.geom.DataTypes; |
|
45 |
import org.gvsig.fmap.geom.Geometry; |
|
46 |
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException; |
|
47 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
|
48 |
import org.gvsig.i18n.Messages; |
|
49 |
import org.gvsig.newlayer.NewLayerService; |
|
50 |
import org.gvsig.newlayer.NewLayerWizard; |
|
51 |
import org.gvsig.tools.dataTypes.DataType; |
|
52 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
53 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
54 |
|
|
55 |
public class FeatureTypePanel extends JPanel implements OptionPanel { |
|
56 |
private static final int COLUMN_FIELD = 0; |
|
57 |
private static final int COLUMN_TYPE = 1; |
|
58 |
private static final int COLUMN_LENGTH = 2; |
|
59 |
private static final int COLUMN_GEOMETRYTYPE = 3; |
|
60 |
private static final int COLUMN_GEOMETRYSUBTYPE = 4; |
|
61 |
private static final int COLUMN_CRS = 5; |
|
62 |
private static final int COLUMN_PRIMARYKEY = 6; |
|
63 |
private static final int COLUMN_MANDATORY = 7; |
|
64 |
|
|
65 |
private static final long serialVersionUID = 263541873998597624L; |
|
66 |
private NewLayerWizard wizard; |
|
67 |
private static final Logger logger = LoggerFactory |
|
68 |
.getLogger(FeatureTypePanel.class); |
|
69 |
|
|
70 |
private JLabel jLabel = null; |
|
71 |
private JScrollPane jScrollPane = null; |
|
72 |
protected JTable jTable = null; |
|
73 |
private JPanel jPanelEast = null; |
|
74 |
private JButton jButtonAddField = null; |
|
75 |
private JButton jButtonDeleteField = null; |
|
76 |
protected int MAX_FIELD_LENGTH = 254; |
|
77 |
private List removedFields; |
|
78 |
|
|
79 |
private DataServerExplorer explorer = null; |
|
80 |
|
|
81 |
public FeatureTypePanel(NewLayerWizard wizard) { |
|
82 |
this.wizard = wizard; |
|
83 |
removedFields = new ArrayList<String>(); |
|
84 |
} |
|
85 |
|
|
86 |
private void initializeComponents() { |
|
87 |
jLabel = new JLabel(); |
|
88 |
jLabel.setText(Messages.getText("define_fields")); |
|
89 |
this.setLayout(new BorderLayout(5, 5)); |
|
90 |
this.setSize(new java.awt.Dimension(499, 232)); |
|
91 |
this.add(jLabel, java.awt.BorderLayout.NORTH); |
|
92 |
this.add(getJScrollPane(), java.awt.BorderLayout.CENTER); |
|
93 |
this.add(getJPanelEast(), java.awt.BorderLayout.EAST); |
|
94 |
|
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* This method initializes jScrollPane |
|
99 |
* |
|
100 |
* @return javax.swing.JScrollPane |
|
101 |
*/ |
|
102 |
private JScrollPane getJScrollPane() { |
|
103 |
if (jScrollPane == null) { |
|
104 |
jScrollPane = new JScrollPane(); |
|
105 |
jScrollPane.setViewportView(getJTable()); |
|
106 |
} |
|
107 |
return jScrollPane; |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* This method initializes jTable |
|
112 |
* |
|
113 |
* @return javax.swing.JTable |
|
114 |
*/ |
|
115 |
private JTable getJTable() { |
|
116 |
if (jTable == null) { |
|
117 |
jTable = new JTable(){ |
|
118 |
public boolean isCellEditable(int row,int column){ |
|
119 |
Object o = getValueAt(row,column); |
|
120 |
|
|
121 |
if ((column == COLUMN_GEOMETRYTYPE) || |
|
122 |
(column == COLUMN_GEOMETRYSUBTYPE) || |
|
123 |
(column == COLUMN_CRS)) { |
|
124 |
DataType dataType = |
|
125 |
((ComboItemDataType) getValueAt(row, COLUMN_TYPE)).dataType; |
|
126 |
return dataType.getType() == DataTypes.GEOMETRY; |
|
127 |
} |
|
128 |
return true; |
|
129 |
} |
|
130 |
}; |
|
131 |
|
|
132 |
DefaultTableModel tm = (DefaultTableModel) jTable.getModel(); |
|
133 |
tm.addColumn(Messages.getText("field")); |
|
134 |
|
|
135 |
tm.addColumn(Messages.getText("type")); |
|
136 |
tm.addColumn(Messages.getText("length")); |
|
137 |
tm.addColumn(Messages.getText("geomType")); |
|
138 |
tm.addColumn(Messages.getText("geomSubtype")); |
|
139 |
tm.addColumn(Messages.getText("CRS")); |
|
140 |
tm.addColumn(Messages.getText("primaryKey")); |
|
141 |
tm.addColumn(Messages.getText("mandatory")); |
|
142 |
|
|
143 |
// Ask to be notified of selection changes. |
|
144 |
ListSelectionModel rowSM = jTable.getSelectionModel(); |
|
145 |
rowSM.addListSelectionListener(new ListSelectionListener() { |
|
146 |
public void valueChanged(ListSelectionEvent e) { |
|
147 |
// Ignore extra messages. |
|
148 |
if (e.getValueIsAdjusting()) |
|
149 |
return; |
|
150 |
|
|
151 |
ListSelectionModel lsm = (ListSelectionModel) e.getSource(); |
|
152 |
if (lsm.isSelectionEmpty()) { |
|
153 |
// no rows are selected |
|
154 |
jButtonDeleteField.setEnabled(false); |
|
155 |
} else { |
|
156 |
jButtonDeleteField.setEnabled(true); |
|
157 |
} |
|
158 |
} |
|
159 |
}); |
|
160 |
jTable.getColumn(Messages.getText("field")).setWidth(180); |
|
161 |
|
|
162 |
jTable.getModel().addTableModelListener(new TableModelListener() { |
|
163 |
public void tableChanged(TableModelEvent e) { |
|
164 |
if (e.getColumn() == COLUMN_TYPE){ |
|
165 |
jTable.repaint(); |
|
166 |
} |
|
167 |
} |
|
168 |
}); |
|
169 |
|
|
170 |
// Rellenado de la tabla |
|
171 |
EditableFeatureType featureType = this.wizard.getService() |
|
172 |
.getFeatureType(); |
|
173 |
if (featureType != null) { |
|
174 |
int row = 0; |
|
175 |
tm.setRowCount(featureType.size()); |
|
176 |
Iterator it = featureType.iterator(); |
|
177 |
while (it.hasNext()) { |
|
178 |
FeatureAttributeDescriptor descriptor = (FeatureAttributeDescriptor) it |
|
179 |
.next(); |
|
180 |
tm.setValueAt(descriptor.getName(), row, COLUMN_FIELD); |
|
181 |
tm.setValueAt(descriptor.getType(), row, COLUMN_TYPE); |
|
182 |
tm.setValueAt(descriptor.getSize(), row, COLUMN_LENGTH); |
|
183 |
tm.setValueAt(descriptor.getGeometryType(), row, COLUMN_GEOMETRYTYPE); |
|
184 |
tm.setValueAt(descriptor.getGeometrySubType(), row, COLUMN_GEOMETRYSUBTYPE); |
|
185 |
tm.setValueAt(descriptor.getSRS(), row, COLUMN_CRS); |
|
186 |
tm.setValueAt(descriptor.isPrimaryKey(), row, COLUMN_PRIMARYKEY); |
|
187 |
tm.setValueAt(descriptor.isMandatory(), row, COLUMN_MANDATORY); |
|
188 |
row++; |
|
189 |
} |
|
190 |
} |
|
191 |
|
|
192 |
} |
|
193 |
jTable.setEnabled(allowEditableFeatureType()); |
|
194 |
return jTable; |
|
195 |
} |
|
196 |
|
|
197 |
/** |
|
198 |
* This method initializes jPanelWest |
|
199 |
* |
|
200 |
* @return javax.swing.JPanel |
|
201 |
*/ |
|
202 |
private JPanel getJPanelEast() { |
|
203 |
if (jPanelEast == null) { |
|
204 |
jPanelEast = new JPanel(); |
|
205 |
jPanelEast.setLayout(null); |
|
206 |
jPanelEast.setPreferredSize(new java.awt.Dimension(170, 100)); |
|
207 |
jPanelEast.add(getJButtonAddField(), null); |
|
208 |
jPanelEast.add(getJButtonDeleteField(), null); |
|
209 |
} |
|
210 |
return jPanelEast; |
|
211 |
} |
|
212 |
|
|
213 |
/** |
|
214 |
* This method initializes jButtonAddField |
|
215 |
* |
|
216 |
* @return javax.swing.JButton |
|
217 |
*/ |
|
218 |
private JButton getJButtonAddField() { |
|
219 |
if (jButtonAddField == null) { |
|
220 |
jButtonAddField = new JButton(); |
|
221 |
jButtonAddField.setText(Messages.getText("add_field")); |
|
222 |
jButtonAddField.setLocation(new java.awt.Point(7, 5)); |
|
223 |
jButtonAddField.setSize(new java.awt.Dimension(145, 23)); |
|
224 |
jButtonAddField.setPreferredSize(new java.awt.Dimension(100, 26)); |
|
225 |
jButtonAddField |
|
226 |
.addActionListener(new java.awt.event.ActionListener() { |
|
227 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
228 |
DefaultTableModel tm = (DefaultTableModel) jTable |
|
229 |
.getModel(); |
|
230 |
|
|
231 |
// Figure out a suitable field name |
|
232 |
ArrayList fieldNames = new ArrayList(); |
|
233 |
for (int i = 0; i < jTable.getRowCount(); i++) { |
|
234 |
fieldNames.add(tm.getValueAt(i, COLUMN_FIELD)); |
|
235 |
} |
|
236 |
String[] currentFieldNames = (String[]) fieldNames |
|
237 |
.toArray(new String[0]); |
|
238 |
String newField = Messages.getText("field") |
|
239 |
.replaceAll(" +", "_"); |
|
240 |
int index = 0; |
|
241 |
for (int i = 0; i < currentFieldNames.length; i++) { |
|
242 |
if (currentFieldNames[i].startsWith(newField)) { |
|
243 |
try { |
|
244 |
index = Integer |
|
245 |
.parseInt(currentFieldNames[i] |
|
246 |
.replaceAll(newField, |
|
247 |
"")); |
|
248 |
} catch (Exception ex) { /* we don't care */ |
|
249 |
} |
|
250 |
} |
|
251 |
} |
|
252 |
String newFieldName = newField + (++index); |
|
253 |
|
|
254 |
// Esto lo a?ado aqu? porque si no tiene registros, |
|
255 |
// no hace caso. (Por eso no |
|
256 |
// lo pongo en getJTable() |
|
257 |
TableColumn typeColumn = jTable.getColumnModel() |
|
258 |
.getColumn(COLUMN_TYPE); |
|
259 |
DataManager dataManager = DALLocator |
|
260 |
.getDataManager(); |
|
261 |
ComboModelDataType model = new ComboModelDataType( |
|
262 |
dataManager.getDataTypes()); |
|
263 |
JComboBox comboBox = new JComboBox(model); |
|
264 |
typeColumn.setCellEditor(new DefaultCellEditor( |
|
265 |
comboBox)); |
|
266 |
|
|
267 |
TableColumn widthColumn = jTable.getColumnModel() |
|
268 |
.getColumn(COLUMN_LENGTH); |
|
269 |
|
|
270 |
TableColumn geomTypeColumn = jTable |
|
271 |
.getColumnModel().getColumn(COLUMN_GEOMETRYTYPE); |
|
272 |
ComboModelGeomType geomTypeModel = new ComboModelGeomType( |
|
273 |
getGeomTypes()); |
|
274 |
JComboBox geomTypeComboBox = new JComboBox( |
|
275 |
geomTypeModel); |
|
276 |
geomTypeColumn.setCellEditor(new DefaultCellEditor( |
|
277 |
geomTypeComboBox)); |
|
278 |
geomTypeColumn.setCellRenderer(new GeometryComboCellRenderer()); |
|
279 |
|
|
280 |
|
|
281 |
TableColumn geomSubTypeColumn = jTable |
|
282 |
.getColumnModel().getColumn(COLUMN_GEOMETRYSUBTYPE); |
|
283 |
ComboModelGeomType geomSubTypeModel = new ComboModelGeomType( |
|
284 |
getGeomSubtypes()); |
|
285 |
JComboBox geomSubTypeComboBox = new JComboBox( |
|
286 |
geomSubTypeModel); |
|
287 |
geomSubTypeColumn |
|
288 |
.setCellEditor(new DefaultCellEditor( |
|
289 |
geomSubTypeComboBox)); |
|
290 |
geomSubTypeColumn.setCellRenderer(new GeometryComboCellRenderer()); |
|
291 |
|
|
292 |
TableColumn crsColumn = jTable.getColumnModel() |
|
293 |
.getColumn(COLUMN_CRS); |
|
294 |
crsColumn.setCellEditor(new ButtonEditor( |
|
295 |
new JCheckBox())); |
|
296 |
CrsRenderer crsButtonRenderer = new CrsRenderer(); |
|
297 |
crsColumn.setCellRenderer(crsButtonRenderer); |
|
298 |
|
|
299 |
TableColumn primaryKeyColumn = jTable |
|
300 |
.getColumnModel().getColumn(COLUMN_PRIMARYKEY); |
|
301 |
JCheckBox primaryKeyCheckBox = new JCheckBox(); |
|
302 |
primaryKeyColumn |
|
303 |
.setCellEditor(new DefaultCellEditor( |
|
304 |
primaryKeyCheckBox)); |
|
305 |
CheckBoxRenderer primaryKeyCheckBoxRenderer = new CheckBoxRenderer(); |
|
306 |
primaryKeyColumn |
|
307 |
.setCellRenderer(primaryKeyCheckBoxRenderer); |
|
308 |
|
|
309 |
TableColumn mandatoryColumn = jTable |
|
310 |
.getColumnModel().getColumn(COLUMN_MANDATORY); |
|
311 |
JCheckBox mandatoryCheckBox = new JCheckBox(); |
|
312 |
mandatoryColumn |
|
313 |
.setCellEditor(new DefaultCellEditor( |
|
314 |
mandatoryCheckBox)); |
|
315 |
CheckBoxRenderer mandatoryCheckBoxRenderer = new CheckBoxRenderer(); |
|
316 |
mandatoryColumn |
|
317 |
.setCellRenderer(mandatoryCheckBoxRenderer); |
|
318 |
|
|
319 |
// Add a new row |
|
320 |
Object[] newRow = new Object[tm.getColumnCount()]; |
|
321 |
newRow[COLUMN_FIELD] = newFieldName; |
|
322 |
newRow[COLUMN_TYPE] = model.getElementAt(0); |
|
323 |
newRow[COLUMN_LENGTH] = "20"; |
|
324 |
newRow[COLUMN_GEOMETRYTYPE] = geomTypeModel.getElementAt(0); |
|
325 |
newRow[COLUMN_GEOMETRYSUBTYPE] = geomSubTypeModel.getElementAt(0); |
|
326 |
// Por defecto, la proyeccion de la vista |
|
327 |
newRow[COLUMN_CRS] = wizard.getService().getMapContext() |
|
328 |
.getProjection(); |
|
329 |
newRow[COLUMN_PRIMARYKEY] = primaryKeyCheckBox.isSelected(); |
|
330 |
newRow[COLUMN_MANDATORY] = mandatoryCheckBox.isSelected(); |
|
331 |
tm.addRow(newRow); |
|
332 |
} |
|
333 |
}); |
|
334 |
|
|
335 |
} |
|
336 |
jButtonAddField.setEnabled(allowEditableFeatureType()); |
|
337 |
return jButtonAddField; |
|
338 |
} |
|
339 |
|
|
340 |
private boolean allowEditableFeatureType(){ |
|
341 |
NewLayerService service = this.wizard.getService(); |
|
342 |
DataManager dataManager = DALLocator.getDataManager(); |
|
343 |
FeatureStoreProviderFactory factory = (FeatureStoreProviderFactory) dataManager.getStoreProviderFactory(service.getStoreName()); |
|
344 |
if (factory.allowEditableFeatureType()==FeatureStoreProviderFactory.NO) { |
|
345 |
return false; |
|
346 |
} |
|
347 |
return true; |
|
348 |
} |
|
349 |
|
|
350 |
private class ComboItemDataType { |
|
351 |
private DataType dataType; |
|
352 |
|
|
353 |
public ComboItemDataType(DataType dataType) { |
|
354 |
this.dataType = dataType; |
|
355 |
} |
|
356 |
|
|
357 |
@Override |
|
358 |
public String toString() { |
|
359 |
return this.dataType.getName(); |
|
360 |
} |
|
361 |
} |
|
362 |
|
|
363 |
private class ComboModelDataType implements ComboBoxModel { |
|
364 |
|
|
365 |
private List<ComboItemDataType> dataTypes; |
|
366 |
private ComboItemDataType selected; |
|
367 |
|
|
368 |
public ComboModelDataType(List<DataType> dataTypes) { |
|
369 |
this.dataTypes = new ArrayList<ComboItemDataType>(); |
|
370 |
for (Iterator iterator = dataTypes.iterator(); iterator.hasNext();) { |
|
371 |
DataType dataType = (DataType) iterator.next(); |
|
372 |
this.dataTypes.add(new ComboItemDataType(dataType)); |
|
373 |
} |
|
374 |
} |
|
375 |
|
|
376 |
public void addListDataListener(ListDataListener arg0) { |
|
377 |
// DO NOTHING |
|
378 |
} |
|
379 |
|
|
380 |
public Object getElementAt(int arg0) { |
|
381 |
return this.dataTypes.get(arg0); |
|
382 |
} |
|
383 |
|
|
384 |
public int getSize() { |
|
385 |
return this.dataTypes.size(); |
|
386 |
} |
|
387 |
|
|
388 |
public void removeListDataListener(ListDataListener arg0) { |
|
389 |
// DO NOTHING |
|
390 |
} |
|
391 |
|
|
392 |
public Object getSelectedItem() { |
|
393 |
return this.selected; |
|
394 |
} |
|
395 |
|
|
396 |
public void setSelectedItem(Object anItem) { |
|
397 |
this.selected = (ComboItemDataType) anItem; |
|
398 |
} |
|
399 |
|
|
400 |
} |
|
401 |
|
|
402 |
class CrsRenderer extends JButton implements TableCellRenderer { |
|
403 |
private static final long serialVersionUID = -573793294070515376L; |
|
404 |
private JLabel label = null; |
|
405 |
|
|
406 |
public CrsRenderer() { |
|
407 |
setOpaque(true); |
|
408 |
label = new JLabel(Messages.getText("not_applicable")); |
|
409 |
} |
|
410 |
|
|
411 |
public Component getTableCellRendererComponent(JTable table, |
|
412 |
Object value, boolean isSelected, boolean hasFocus, int row, |
|
413 |
int column) { |
|
414 |
|
|
415 |
DataType dataType = |
|
416 |
((ComboItemDataType) table.getValueAt(row, COLUMN_TYPE)).dataType; |
|
417 |
|
|
418 |
if (dataType.getType() != DataTypes.GEOMETRY) { |
|
419 |
return label; |
|
420 |
} |
|
421 |
|
|
422 |
if (isSelected) { |
|
423 |
setForeground(table.getSelectionForeground()); |
|
424 |
setBackground(table.getSelectionBackground()); |
|
425 |
} else { |
|
426 |
setForeground(table.getForeground()); |
|
427 |
setBackground(UIManager.getColor("Button.background")); |
|
428 |
} |
|
429 |
setText((value == null) ? "" : ((IProjection) value).getFullCode()); |
|
430 |
return this; |
|
431 |
} |
|
432 |
} |
|
433 |
|
|
434 |
private class GeometryComboCellRenderer extends JLabel implements TableCellRenderer{ |
|
435 |
|
|
436 |
public Component getTableCellRendererComponent(JTable table, |
|
437 |
Object value, boolean isSelected, boolean hasFocus, int row, |
|
438 |
int column) { |
|
439 |
|
|
440 |
DataType dataType = |
|
441 |
((ComboItemDataType) table.getValueAt(row, COLUMN_TYPE)).dataType; |
|
442 |
|
|
443 |
if (dataType.getType() == DataTypes.GEOMETRY) { |
|
444 |
ComboItemGeomType geomType = (ComboItemGeomType)value; |
|
445 |
if (geomType != null) { |
|
446 |
this.setText(geomType.toString()); |
|
447 |
} |
|
448 |
} else { |
|
449 |
this.setText(Messages.getText("not_applicable")); |
|
450 |
} |
|
451 |
|
|
452 |
return this; |
|
453 |
} |
|
454 |
|
|
455 |
} |
|
456 |
|
|
457 |
class ButtonEditor extends DefaultCellEditor { |
|
458 |
/** |
|
459 |
* |
|
460 |
*/ |
|
461 |
private static final long serialVersionUID = -2820892672026188802L; |
|
462 |
|
|
463 |
protected JButton button; |
|
464 |
|
|
465 |
private String label; |
|
466 |
|
|
467 |
private boolean isPushed; |
|
468 |
|
|
469 |
private Object value; |
|
470 |
|
Also available in: Unified diff