1 19 package org.openharmonise.him.configuration.searchin; 20 21 import java.awt.*; 22 import java.util.*; 23 import java.util.List ; 24 25 import javax.swing.*; 26 27 import org.openharmonise.him.configuration.*; 28 import org.openharmonise.him.harmonise.HarmonisePaths; 29 import org.openharmonise.him.swing.resourcetree.formresourcetree.*; 30 import org.openharmonise.vfs.VirtualFile; 31 import org.openharmonise.vfs.servers.*; 32 33 34 41 public class SearchInOptions 42 extends JPanel 43 implements LayoutManager, FormResourceTreeListener, ApplyChangesListener { 44 45 48 private ConfigDialog m_dialog = null; 49 50 53 private FormResourceTree m_tree = null; 54 55 58 private boolean m_bChanged = false; 59 60 private static List m_hiddenRootPaths = new ArrayList(); 61 62 static { 63 m_hiddenRootPaths.add(HarmonisePaths.PATH_ARCHIVE); 64 m_hiddenRootPaths.add(HarmonisePaths.PATH_WORKFLOW_DEFINITIONS); 65 m_hiddenRootPaths.add(HarmonisePaths.PATH_WORKFLOW_PROPS); 66 m_hiddenRootPaths.add(HarmonisePaths.PATH_WORKFLOW_STAGES); 67 } 68 69 74 public SearchInOptions(ConfigDialog dialog) { 75 super(); 76 this.m_dialog = dialog; 77 this.setup(); 78 } 79 80 private boolean isPathHiddenRoot(String sPath) { 81 boolean bHidden = false; 82 83 Iterator itor = SearchInOptions.m_hiddenRootPaths.iterator(); 84 while (itor.hasNext()) { 85 String sRootPath = (String ) itor.next(); 86 if(sPath.equals(sRootPath) || sPath.startsWith(sRootPath)) { 87 bHidden=true; 88 } 89 } 90 91 return bHidden; 92 } 93 94 98 private void setup() { 99 this.m_dialog.addApplyChangesListener(this); 100 101 this.setLayout(this); 102 103 List aValues = ConfigStore.getInstance().getPropertyVals("SEARCHPATHS"); 104 Server server = ServerList.getInstance().getHarmoniseServer(); 105 106 if(aValues!=null) { 107 108 ArrayList aRemovePaths = new ArrayList(); 109 110 Iterator itor = aValues.iterator(); 111 while (itor.hasNext()) { 112 String sTempPath = (String ) itor.next(); 113 if(server.getVFS().getVirtualFile(sTempPath)==null) { 114 aRemovePaths.add(sTempPath); 115 } 116 } 117 if(aRemovePaths.size()>0) { 118 aValues.removeAll(aRemovePaths); 119 ConfigStore.getInstance().setProperty("SEARCHPATHS", (ArrayList) aValues); 120 } 121 } else { 122 aValues = new ArrayList(); 123 } 124 125 m_tree = new FormResourceTree(aValues); 126 m_tree.setShowLeafNodes(false); 127 m_tree.setBorder(BorderFactory.createLineBorder(Color.BLACK)); 128 m_tree.addFormResourceTreeListener(this); 129 130 this.add(m_tree); 131 132 String fontName = "Dialog"; 133 int fontSize = 11; 134 Font font = new Font(fontName, Font.PLAIN, fontSize); 135 136 VirtualFile vfFile = 137 server.getVFS().getVirtualFile( 138 "/" + server.getVFS().getRootPathSegment() + "/").getResource(); 139 List children = vfFile.getChildren(); 140 Iterator itor2 = children.iterator(); 141 while (itor2.hasNext()) { 142 VirtualFile vfDir = 143 server.getVFS().getVirtualFile((String ) itor2.next()).getResource(); 144 if (vfDir.isDirectory() && !this.isPathHiddenRoot(vfDir.getFullPath())) { 145 this.m_tree.addCollection(vfDir); 146 } 147 } 148 } 149 150 153 public Dimension getPreferredSize() { 154 return new Dimension(this.getParent().getSize().width, 200); 155 } 156 157 160 public boolean applyChanges() { 161 if(this.m_bChanged) { 162 163 ConfigStore.getInstance().setProperty("SEARCHPATHS", (ArrayList) this.m_tree.getPathValues()); 164 165 this.m_bChanged = false; 166 } 167 return true; 168 } 169 170 173 public void layoutContainer(Container arg0) { 174 int nHeight = 0; 175 176 this.m_tree.setSize(this.getParent().getSize().width-20, 280); 177 this.m_tree.setLocation(10, nHeight + 20); 178 179 } 180 181 184 public Dimension minimumLayoutSize(Container arg0) { 185 return this.getPreferredSize(); 186 } 187 188 191 public Dimension preferredLayoutSize(Container arg0) { 192 return this.getPreferredSize(); 193 } 194 195 198 public void removeLayoutComponent(Component arg0) { 199 } 200 201 204 public void addLayoutComponent(String arg0, Component arg1) { 205 } 206 207 210 private SearchInOptions(boolean arg0) { 211 super(arg0); 212 } 213 214 217 private SearchInOptions(LayoutManager arg0) { 218 super(arg0); 219 } 220 221 225 private SearchInOptions(LayoutManager arg0, boolean arg1) { 226 super(arg0, arg1); 227 } 228 229 232 public void discardChanges() { 233 234 } 235 236 239 public void pathValuesChanged(List pathValues) { 240 this.m_bChanged = true; 241 } 242 243 } 244 | Popular Tags |