Revision 43019
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.lib/src/main/java/org/gvsig/fmap/dal/serverexplorer/filesystem/spi/FilesystemServerExplorerProviderFactory.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.serverexplorer.filesystem.spi; |
|
2 |
|
|
3 |
import java.io.FileFilter; |
|
4 |
|
|
5 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
6 |
import org.gvsig.tools.extensionpoint.ExtensionSingleton; |
|
7 |
|
|
8 |
/** |
|
9 |
* Creates File System Server Explorer Providers |
|
10 |
* @author dmartinezizquierdo |
|
11 |
* |
|
12 |
*/ |
|
13 |
public interface FilesystemServerExplorerProviderFactory extends ExtensionSingleton, |
|
14 |
FileFilter, FilesystemProviderServices { |
|
15 |
|
|
16 |
/** |
|
17 |
* Builds a specific provider |
|
18 |
* @param services |
|
19 |
* @return the provider |
|
20 |
* @throws org.gvsig.fmap.dal.exception.InitializeException |
|
21 |
*/ |
|
22 |
public FilesystemServerExplorerProvider createProvider() throws InitializeException; |
|
23 |
|
|
24 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.lib/src/main/java/org/gvsig/fmap/dal/serverexplorer/filesystem/spi/FilesystemProviderServices.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.serverexplorer.filesystem.spi; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.DataParameters; |
|
4 |
|
|
5 |
/** |
|
6 |
* Parameters to create a FilesystemServerExplorerProviderFactory |
|
7 |
* @author dmartinezizquierdo |
|
8 |
* |
|
9 |
*/ |
|
10 |
public interface FilesystemProviderServices {//extends DataParameters |
|
11 |
public static final int UNKNOWN = 0; |
|
12 |
public static final int YES = 1; |
|
13 |
public static final int NO = 2; |
|
14 |
/** |
|
15 |
* Returns the name of the provider |
|
16 |
* |
|
17 |
* @return name of the provider |
|
18 |
*/ |
|
19 |
public String getName(); |
|
20 |
|
|
21 |
/** |
|
22 |
* Return a short descripion about the provider |
|
23 |
* |
|
24 |
* @return description about the provider |
|
25 |
*/ |
|
26 |
public String getDescription(); |
|
27 |
|
|
28 |
/** |
|
29 |
* The provider can create new stores. |
|
30 |
* |
|
31 |
* @return YES if has creation support |
|
32 |
*/ |
|
33 |
public int allowCreate(); |
|
34 |
|
|
35 |
/** |
|
36 |
* Returns the mode supported |
|
37 |
* @return DataServerExplorer.MODE |
|
38 |
*/ |
|
39 |
public int getMode(); |
|
40 |
|
|
41 |
/** |
|
42 |
* Return true if any mode in the parameter is supported. |
|
43 |
* |
|
44 |
* @param mode |
|
45 |
* @return boolean |
|
46 |
*/ |
|
47 |
public boolean isMode(int mode); |
|
48 |
|
|
49 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.lib/src/main/java/org/gvsig/fmap/dal/serverexplorer/filesystem/spi/FilesystemServerExplorerManager.java | ||
---|---|---|
30 | 30 |
final public static String FILE_FILTER_EPSNAME = "FilesystemExplorerFilters"; |
31 | 31 |
final public String FILE_FILTER_EPSDESCRIPTION = "Registro de filtros asociados al explorador del sistema de ficheros."; |
32 | 32 |
|
33 |
public void registerProvider(String name, String description, |
|
34 |
Class filesystemServerProvicerClass); |
|
33 |
/** |
|
34 |
* Registers a FilesystemServerExplorerManager |
|
35 |
* @param name |
|
36 |
* @param description |
|
37 |
* @param filesystemServerProvicerClass |
|
38 |
*/ |
|
39 |
public void registerProvider(String name, String description, |
|
40 |
Class filesystemServerProvicerClass); |
|
35 | 41 |
|
36 |
public Iterator getRegisteredProviders(); |
|
42 |
/** |
|
43 |
* Registers a FilesystemServerExplorerProviderFactory |
|
44 |
* @param filesystemServerExplorerProviderFactory |
|
45 |
*/ |
|
46 |
public void registerProviderFactory( |
|
47 |
FilesystemServerExplorerProviderFactory filesystemServerExplorerProviderFactory); |
|
37 | 48 |
|
49 |
/** |
|
50 |
* Get registered FilesystemServerExplorerManager |
|
51 |
* @return |
|
52 |
*/ |
|
53 |
public Iterator getRegisteredProviders(); |
|
54 |
|
|
38 | 55 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.lib/src/main/java/org/gvsig/fmap/dal/serverexplorer/filesystem/impl/DefaultFilesystemServerExplorerManager.java | ||
---|---|---|
27 | 27 |
import java.util.Iterator; |
28 | 28 |
|
29 | 29 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerManager; |
30 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider; |
|
31 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderFactory; |
|
30 | 32 |
import org.gvsig.tools.ToolsLocator; |
33 |
import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension; |
|
31 | 34 |
|
32 | 35 |
public class DefaultFilesystemServerExplorerManager implements |
33 | 36 |
FilesystemServerExplorerManager { |
... | ... | |
39 | 42 |
|
40 | 43 |
public void registerProvider(String name, String description, |
41 | 44 |
Class filesystemServerProvicerClass) { |
42 |
ToolsLocator.getExtensionPointManager().add(FILE_FILTER_EPSNAME, |
|
43 |
FILE_FILTER_EPSDESCRIPTION).append( |
|
44 |
name, description, |
|
45 |
filesystemServerProvicerClass); |
|
45 |
//The class is wrapped into the factory |
|
46 |
FilesystemServerExplorerProviderFactory providerFactory= new FilesystemServerExplorerProviderFactoryWrapper |
|
47 |
(name, description, filesystemServerProvicerClass); |
|
48 |
//The factory is registered |
|
49 |
registerProviderFactory(providerFactory); |
|
46 | 50 |
} |
47 | 51 |
|
52 |
public void registerProviderFactory( |
|
53 |
FilesystemServerExplorerProviderFactory filesystemServerExplorerProviderFactory) { |
|
54 |
//Registers the factory |
|
55 |
ToolsLocator.getExtensionPointManager().add(FILE_FILTER_EPSNAME, |
|
56 |
FILE_FILTER_EPSDESCRIPTION).append( |
|
57 |
filesystemServerExplorerProviderFactory.getName(), |
|
58 |
filesystemServerExplorerProviderFactory.getDescription(), |
|
59 |
filesystemServerExplorerProviderFactory); |
|
60 |
} |
|
61 |
|
|
48 | 62 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.lib/src/main/java/org/gvsig/fmap/dal/serverexplorer/filesystem/impl/FilesystemServerExplorerProviderFactoryWrapper.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.serverexplorer.filesystem.impl; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
|
|
5 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
6 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemProviderServices; |
|
7 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider; |
|
8 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderFactory; |
|
9 |
|
|
10 |
/** |
|
11 |
* Class to wrap a FilesystemServerExplorerProvider into a Factory |
|
12 |
* @author dmartinezizquierdo |
|
13 |
* |
|
14 |
*/ |
|
15 |
public class FilesystemServerExplorerProviderFactoryWrapper |
|
16 |
implements FilesystemServerExplorerProviderFactory{ |
|
17 |
|
|
18 |
String name; |
|
19 |
String description; |
|
20 |
FilesystemServerExplorerProvider wrappedFilesystemServerExplorerProvider; |
|
21 |
|
|
22 |
FilesystemServerExplorerProviderFactoryWrapper(String name, String description, |
|
23 |
Class filesystemServerExplorerProviderClass){ |
|
24 |
this.name=name; |
|
25 |
this.description=description; |
|
26 |
try { |
|
27 |
this.wrappedFilesystemServerExplorerProvider=(FilesystemServerExplorerProvider) filesystemServerExplorerProviderClass.newInstance(); |
|
28 |
} catch (InstantiationException | IllegalAccessException e) { |
|
29 |
throw new RuntimeException(e);// FIXME !!! |
|
30 |
} |
|
31 |
} |
|
32 |
|
|
33 |
@Override |
|
34 |
public FilesystemServerExplorerProvider createProvider() |
|
35 |
throws InitializeException { |
|
36 |
return wrappedFilesystemServerExplorerProvider; |
|
37 |
} |
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
@Override |
|
42 |
public boolean accept(File pathname) { |
|
43 |
return wrappedFilesystemServerExplorerProvider.accept(pathname); |
|
44 |
} |
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
@Override |
|
49 |
public String getName() { |
|
50 |
return name; |
|
51 |
} |
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
@Override |
|
56 |
public String getDescription() { |
|
57 |
return description; |
|
58 |
} |
|
59 |
|
|
60 |
@Override |
|
61 |
public int allowCreate() { |
|
62 |
if (wrappedFilesystemServerExplorerProvider.canCreate()){ |
|
63 |
return FilesystemProviderServices.YES; |
|
64 |
}else{ |
|
65 |
return FilesystemProviderServices.NO; |
|
66 |
} |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
public int getMode() { |
|
71 |
return wrappedFilesystemServerExplorerProvider.getMode(); |
|
72 |
} |
|
73 |
|
|
74 |
@Override |
|
75 |
public boolean isMode(int mode) { |
|
76 |
return wrappedFilesystemServerExplorerProvider.isMode(mode); |
|
77 |
} |
|
78 |
|
|
79 |
|
|
80 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.lib/src/main/java/org/gvsig/fmap/dal/serverexplorer/filesystem/impl/DefaultFilesystemServerExplorer.java | ||
---|---|---|
49 | 49 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
50 | 50 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
51 | 51 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider; |
52 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderFactory; |
|
52 | 53 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices; |
53 | 54 |
import org.gvsig.fmap.dal.spi.AbstractDataServerExplorer; |
54 | 55 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
... | ... | |
379 | 380 |
this.serverProviders = new ArrayList(); |
380 | 381 |
Extension ext; |
381 | 382 |
FilesystemServerExplorerProvider provider; |
383 |
FilesystemServerExplorerProviderFactory factory; |
|
382 | 384 |
while (iter.hasNext()) { |
383 | 385 |
ext = (Extension) iter.next(); |
384 | 386 |
try { |
385 |
provider = (FilesystemServerExplorerProvider) ext.create();
|
|
387 |
factory = (FilesystemServerExplorerProviderFactory) ext.create();
|
|
386 | 388 |
} catch (Exception e) { |
387 | 389 |
throw new RuntimeException(e);// FIXME !!! |
388 | 390 |
} |
391 |
try { |
|
392 |
provider=factory.createProvider(); |
|
393 |
} catch (InitializeException e) { |
|
394 |
throw new RuntimeException(e);// FIXME !!! |
|
395 |
} |
|
389 | 396 |
provider.initialize(this); |
390 | 397 |
this.serverProviders.add(provider); |
391 | 398 |
} |
... | ... | |
394 | 401 |
} |
395 | 402 |
|
396 | 403 |
public List getProviders(int mode) { |
397 |
Iterator iter = DALFileLocator.getFilesystemServerExplorerManager() |
|
398 |
.getRegisteredProviders(); |
|
399 |
List providers = new ArrayList(); |
|
400 |
Extension ext; |
|
401 |
FilesystemServerExplorerProvider provider; |
|
402 |
while (iter.hasNext()) { |
|
403 |
ext = (Extension) iter.next(); |
|
404 |
try { |
|
405 |
provider = (FilesystemServerExplorerProvider) ext.create(); |
|
406 |
} catch (Exception e) { |
|
407 |
throw new RuntimeException(e);// FIXME !!! |
|
408 |
} |
|
404 |
List<FilesystemServerExplorerProvider> providers = new ArrayList(); |
|
405 |
List<FilesystemServerExplorerProvider> allProviders = getProviders(); |
|
406 |
for (FilesystemServerExplorerProvider provider:allProviders){ |
|
409 | 407 |
if (provider.isMode(mode)) { |
410 | 408 |
provider.initialize(this); |
411 | 409 |
providers.add(provider); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.lib/src/main/java/org/gvsig/fmap/dal/serverexplorer/filesystem/impl/AbstractFilesystemServerExplorerProviderFactory.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.serverexplorer.filesystem.impl; |
|
2 |
|
|
3 |
|
|
4 |
import java.io.File; |
|
5 |
|
|
6 |
import org.apache.commons.io.FilenameUtils; |
|
7 |
import org.apache.commons.lang3.StringUtils; |
|
8 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemProviderServices; |
|
9 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderFactory; |
|
10 |
|
|
11 |
/** |
|
12 |
* Abstract Factory to create File System Server Explorer Providers |
|
13 |
* @author dmartinezizquierdo |
|
14 |
* |
|
15 |
*/ |
|
16 |
public abstract class AbstractFilesystemServerExplorerProviderFactory |
|
17 |
implements FilesystemServerExplorerProviderFactory, FilesystemProviderServices{ |
|
18 |
|
|
19 |
private FilesystemProviderServices services; |
|
20 |
|
|
21 |
public AbstractFilesystemServerExplorerProviderFactory(FilesystemProviderServices services){ |
|
22 |
this.services=services; |
|
23 |
} |
|
24 |
|
|
25 |
@Override |
|
26 |
public String getName() { |
|
27 |
return this.services.getName(); |
|
28 |
} |
|
29 |
|
|
30 |
@Override |
|
31 |
public String getDescription() { |
|
32 |
return this.services.getDescription(); |
|
33 |
} |
|
34 |
|
|
35 |
@Override |
|
36 |
public int allowCreate() { |
|
37 |
return this.services.allowCreate(); |
|
38 |
} |
|
39 |
|
|
40 |
@Override |
|
41 |
public int getMode(){ |
|
42 |
return this.services.getMode(); |
|
43 |
} |
|
44 |
|
|
45 |
@Override |
|
46 |
public boolean isMode(int mode){ |
|
47 |
return this.services.isMode(mode); |
|
48 |
} |
|
49 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.lib/src/main/java/org/gvsig/fmap/dal/serverexplorer/filesystem/impl/AbstractFilesystemProviderServices.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.serverexplorer.filesystem.impl; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemProviderServices; |
|
4 |
|
|
5 |
/** |
|
6 |
* Abstract implementation of FilesystemServerExplorerProviderFactoryParameters |
|
7 |
* @author dmartinezizquierdo |
|
8 |
* |
|
9 |
*/ |
|
10 |
public abstract class AbstractFilesystemProviderServices implements FilesystemProviderServices{ |
|
11 |
|
|
12 |
String name=null; |
|
13 |
String description=null; |
|
14 |
int allowCreate=FilesystemProviderServices.UNKNOWN; |
|
15 |
int mode=-1; |
|
16 |
|
|
17 |
/** |
|
18 |
* Returns the name of the provider |
|
19 |
* |
|
20 |
* @return name of the provider |
|
21 |
*/ |
|
22 |
public String getName(){ |
|
23 |
return name; |
|
24 |
} |
|
25 |
|
|
26 |
/** |
|
27 |
* Return a short descripion about the provider |
|
28 |
* |
|
29 |
* @return description about the provider |
|
30 |
*/ |
|
31 |
public String getDescription(){ |
|
32 |
return description; |
|
33 |
} |
|
34 |
|
|
35 |
/** |
|
36 |
* The provider can create new stores. |
|
37 |
* |
|
38 |
* @return YES if has creation support |
|
39 |
*/ |
|
40 |
public int allowCreate(){ |
|
41 |
return allowCreate; |
|
42 |
} |
|
43 |
|
|
44 |
/** |
|
45 |
* Returns the mode supported |
|
46 |
* @return DataServerExplorer.MODE |
|
47 |
*/ |
|
48 |
public int getMode(){ |
|
49 |
return mode; |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* Return true if any mode in the parameter is supported. |
|
54 |
* |
|
55 |
* @param mode |
|
56 |
* @return boolean |
|
57 |
*/ |
|
58 |
public boolean isMode(int mode){ |
|
59 |
return this.mode==mode; |
|
60 |
} |
|
61 |
|
|
62 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.lib/src/main/java/org/gvsig/fmap/dal/serverexplorer/filesystem/impl/DefaultFilesystemProviderServices.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.serverexplorer.filesystem.impl; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemProviderServices; |
|
4 |
|
|
5 |
public class DefaultFilesystemProviderServices extends AbstractFilesystemProviderServices{ |
|
6 |
|
|
7 |
/** |
|
8 |
* Public constructor |
|
9 |
* @param name |
|
10 |
* @param description |
|
11 |
*/ |
|
12 |
public DefaultFilesystemProviderServices(String name, String description){ |
|
13 |
this.name=name; |
|
14 |
this.description=description; |
|
15 |
} |
|
16 |
|
|
17 |
public void setAllowCreate(int allowCreate){ |
|
18 |
if (FilesystemProviderServices.YES == allowCreate || FilesystemProviderServices.NO == allowCreate){ |
|
19 |
this.allowCreate=allowCreate; |
|
20 |
}else{ |
|
21 |
this.allowCreate=FilesystemProviderServices.UNKNOWN; |
|
22 |
} |
|
23 |
} |
|
24 |
|
|
25 |
public void setMode(int mode) { |
|
26 |
this.mode=mode; |
|
27 |
} |
|
28 |
|
|
29 |
|
|
30 |
} |
Also available in: Unified diff