source: trunk/gli/src/org/greenstone/gatherer/file/WorkspaceTreeModel.java@ 6086

Last change on this file since 6086 was 6086, checked in by jmt12, 20 years ago

Moved the special folder 'shortcuts' from collection based to shared for the installation of gli. This caused some added fun when it turned out one of the workspace tree refreshes was blocking the AWTEvent thread, despite me putting tests in place to stop that from happening. It had never reared its ugly head before, as there were never any shortcut collections being mapped when a collection had been closed, or when GLI was exiting before.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1package org.greenstone.gatherer.file;
2
3import org.greenstone.gatherer.collection.CollectionManager;
4import org.greenstone.gatherer.file.FileNode;
5import org.greenstone.gatherer.gui.MirrorPane;
6import org.greenstone.gatherer.util.SynchronizedTreeModelTools;
7
8
9public class WorkspaceTreeModel
10 extends FileSystemModel {
11
12 static private FileNode workspace_tree_root = null;
13 static private WorkspaceTreeModel workspace_tree_model = null;
14 static private FileNode greenstone_collections_mapping = null;
15 static private FileNode public_web_cache_mapping = null;
16 static private FileNode private_web_cache_mapping = null;
17 static private FileNode[] collection_specific_mappings = null;
18
19
20 public WorkspaceTreeModel(FileNode root)
21 {
22 super(root);
23 }
24
25
26 static public WorkspaceTreeModel getWorkspaceTreeModel()
27 {
28 // Create a root node to contain the various nodes in the workspace tree
29 workspace_tree_root = new FileNode("ABS_ROOT");
30 workspace_tree_model = new WorkspaceTreeModel(workspace_tree_root);
31
32 // Add the Greenstone Collections mapping
33 greenstone_collections_mapping = CollectionManager.getGreenstoneCollectionsMapping();
34 workspace_tree_root.insert(greenstone_collections_mapping);
35
36 // Add the local filespace
37 workspace_tree_root.insert(FileSystem.getLocalFileSystem(workspace_tree_model));
38
39 // Add a mapping to the user home folder
40 workspace_tree_root.insert(FileSystem.getUserHomeMapping());
41
42 // Add public and private web caches if applicable
43 loadWebCacheMappings();
44
45 // Add any collection specific mappings
46 loadCollectionSpecificMappings();
47
48 return workspace_tree_model;
49 }
50
51
52 static private void loadWebCacheMappings()
53 {
54 // If mirroring is enabled show the public and private caches
55 public_web_cache_mapping = MirrorPane.getPublicWebCacheMapping();
56 if (public_web_cache_mapping != null) {
57 workspace_tree_root.insert(public_web_cache_mapping);
58 }
59 private_web_cache_mapping = MirrorPane.getPrivateWebCacheMapping();
60 if (private_web_cache_mapping != null) {
61 workspace_tree_root.insert(private_web_cache_mapping);
62 }
63 }
64
65
66 static private void loadCollectionSpecificMappings()
67 {
68 ///ystem.err.print("Load Collection Specific Mappings... ");
69 // Add the current collection specific mappings
70 collection_specific_mappings = CollectionManager.getCollectionSpecificMappings();
71 ///ystem.err.print("Retrieved Mappings... ");
72 if (collection_specific_mappings != null) {
73 for (int i = 0; i < collection_specific_mappings.length; i++) {
74 ///ystem.err.print("Setting " + i + " Mapping... ");
75 SynchronizedTreeModelTools.insertNodeInto(workspace_tree_model, workspace_tree_root, collection_specific_mappings[i], false);
76 }
77 }
78 ///ystem.err.println("Done.");
79 }
80
81
82 // !! NEEDS WORK !!
83 static public void refreshGreenstoneCollectionsMapping()
84 {
85 greenstone_collections_mapping.unmap();
86 greenstone_collections_mapping.map();
87 }
88
89
90 // !! NEEDS WORK !!
91 static public void refreshWebCacheMappings()
92 {
93 if (public_web_cache_mapping != null) {
94 SynchronizedTreeModelTools.removeNodeFromParent(workspace_tree_model,
95 public_web_cache_mapping);
96 }
97 if (private_web_cache_mapping != null) {
98 SynchronizedTreeModelTools.removeNodeFromParent(workspace_tree_model,
99 private_web_cache_mapping);
100 }
101
102 loadWebCacheMappings();
103 }
104
105
106 // !! NEEDS WORK !!
107 static public void refreshCollectionSpecificMappings()
108 {
109 // Remove all the old collection specific mappings
110 if (collection_specific_mappings != null) {
111 for (int i = 0; i < collection_specific_mappings.length; i++) {
112 SynchronizedTreeModelTools.removeNodeFromParent(workspace_tree_model,
113 collection_specific_mappings[i]);
114 }
115 }
116
117 loadCollectionSpecificMappings();
118 }
119}
Note: See TracBrowser for help on using the repository browser.