Changeset 2119
- Timestamp:
- 10/10/08 11:06:55
(2 months ago)
- Author:
- dsugar
- Message:
NEW - ticket:245: Delete layer - doesn't go away
http://oss.tresys.com/projects/slide/ticket/245
Now the layer is removed from the Policy Explorer
also some cleanup
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r2116 |
r2119 |
|
| 55 | 55 | if (res instanceof IFolder) |
|---|
| 56 | 56 | { |
|---|
| 57 | | if (!res.getName().equals("policy")) |
|---|
| | 57 | if (!res.getName().equals(BaseProjectNature.DIR_POLICY)) |
|---|
| 58 | 58 | continue; |
|---|
| 59 | 59 | } |
|---|
| … | … | |
| 74 | 74 | try |
|---|
| 75 | 75 | { |
|---|
| 76 | | if (parentFolder.getName().equals("policy")) |
|---|
| 77 | | { |
|---|
| 78 | | parentFolder = parentFolder.getFolder("modules"); |
|---|
| | 76 | if (parentFolder.getName().equals(BaseProjectNature.DIR_POLICY)) |
|---|
| | 77 | { |
|---|
| | 78 | parentFolder = parentFolder.getFolder(BaseProjectNature.DIR_MODULES); |
|---|
| 79 | 79 | IResource[] childFolders = parentFolder.members(IResource.FOLDER); |
|---|
| 80 | 80 | |
|---|
| … | … | |
| 141 | 141 | { |
|---|
| 142 | 142 | // System.out.print("FullContentProvider.getParent() --> "); |
|---|
| 143 | | if( element instanceof PLayer) |
|---|
| | 143 | if (element instanceof PLayer) |
|---|
| 144 | 144 | { |
|---|
| 145 | 145 | PLayer layer = (PLayer)element; |
|---|
| … | … | |
| 149 | 149 | // return ((PLayer)mLayers.get(mLayers.indexOf(element))).getParent(); |
|---|
| 150 | 150 | } |
|---|
| 151 | | else if( element instanceof PModule) |
|---|
| | 151 | else if (element instanceof PModule) |
|---|
| 152 | 152 | { |
|---|
| 153 | 153 | // System.out.print("Module --> "); |
|---|
| … | … | |
| 210 | 210 | return !((PLayer)element).getModules().isEmpty(); |
|---|
| 211 | 211 | } |
|---|
| 212 | | else if( element instanceof IProject && ((IProject)element).isOpen() ) |
|---|
| | 212 | else if (element instanceof IProject && ((IProject)element).isOpen() ) |
|---|
| 213 | 213 | { |
|---|
| 214 | 214 | try |
|---|
| … | … | |
| 255 | 255 | { |
|---|
| 256 | 256 | SLIDEPlugin.log(ce); |
|---|
| 257 | | if( SLIDEPlugin.getDefault().isDebugging() ) |
|---|
| | 257 | if (SLIDEPlugin.getDefault().isDebugging()) |
|---|
| 258 | 258 | ce.printStackTrace(); |
|---|
| 259 | 259 | return false; |
|---|
| … | … | |
| 270 | 270 | for (int i = 0; i < children.length; i++) |
|---|
| 271 | 271 | { |
|---|
| 272 | | if(!(children[i] instanceof IFile)) |
|---|
| | 272 | if (!(children[i] instanceof IFile)) |
|---|
| 273 | 273 | continue; |
|---|
| 274 | 274 | |
|---|
| … | … | |
| 319 | 319 | private void initLayers () |
|---|
| 320 | 320 | { |
|---|
| 321 | | IFolder modulesDir = m_project.getFolder("policy/modules"); |
|---|
| | 321 | IFolder modulesDir = m_project.getFolder(BaseProjectNature.DIR_POLICY + "/" + BaseProjectNature.DIR_MODULES); |
|---|
| 322 | 322 | |
|---|
| 323 | 323 | try |
|---|
| … | … | |
| 377 | 377 | else if (rsrc instanceof IFile) |
|---|
| 378 | 378 | { |
|---|
| 379 | | if (rsrc.getName().endsWith(".if")) |
|---|
| | 379 | if (rsrc.getName().endsWith("." + BaseProjectNature.IF_EXTENSION)) |
|---|
| 380 | 380 | { |
|---|
| 381 | 381 | PLayer currLayer = null; |
|---|
| … | … | |
| 434 | 434 | } |
|---|
| 435 | 435 | // adding a new layer |
|---|
| 436 | | else if(rsrc instanceof IFolder) |
|---|
| | 436 | else if (rsrc instanceof IFolder) |
|---|
| 437 | 437 | { |
|---|
| 438 | 438 | IFolder changedFolder = (IFolder) rsrc; |
|---|
| … | … | |
| 440 | 440 | IProject proj = changedFolder.getProject(); |
|---|
| 441 | 441 | |
|---|
| 442 | | if(delta.getKind() == IResourceDelta.ADDED) |
|---|
| 443 | | { |
|---|
| 444 | | if (!changedFolder.getParent().getName().equals("modules")) |
|---|
| | 442 | if (delta.getKind() == IResourceDelta.ADDED) |
|---|
| | 443 | { |
|---|
| | 444 | if (!changedFolder.getParent().getName().equals(BaseProjectNature.DIR_MODULES)) |
|---|
| 445 | 445 | return false; |
|---|
| 446 | 446 | |
|---|
| 447 | | Iterator itr = mLayers.iterator(); |
|---|
| 448 | | |
|---|
| 449 | 447 | boolean layerMatch = false; |
|---|
| 450 | | |
|---|
| 451 | | while( !layerMatch && itr.hasNext() ) |
|---|
| | 448 | for (Iterator itr = mLayers.iterator (); !layerMatch && itr.hasNext (); ) |
|---|
| 452 | 449 | { |
|---|
| 453 | 450 | PLayer l = ((PLayer)itr.next()); |
|---|
| 454 | | if( l.getProject().equals(proj) && l.getName().equals(changedFolder.getName()) ) |
|---|
| | 451 | if (l.getProject().equals(proj) && l.getName().equals(changedFolder.getName())) |
|---|
| 455 | 452 | { |
|---|
| 456 | 453 | layerMatch = true; |
|---|
| … | … | |
| 467 | 464 | } |
|---|
| 468 | 465 | |
|---|
| | 466 | if (delta.getKind () == IResourceDelta.REMOVED) |
|---|
| | 467 | { |
|---|
| | 468 | if (!changedFolder.getParent().getName().equals(BaseProjectNature.DIR_MODULES)) |
|---|
| | 469 | return false; |
|---|
| | 470 | |
|---|
| | 471 | for (Iterator itr = mLayers.iterator (); itr.hasNext (); ) |
|---|
| | 472 | { |
|---|
| | 473 | PLayer l = ((PLayer)itr.next()); |
|---|
| | 474 | if (l.getProject().equals(proj) && l.getName().equals(changedFolder.getName())) |
|---|
| | 475 | { |
|---|
| | 476 | itr.remove (); |
|---|
| | 477 | } |
|---|
| | 478 | } |
|---|
| | 479 | } |
|---|
| | 480 | |
|---|
| 469 | 481 | return true; |
|---|
| 470 | 482 | } |
|---|
| 471 | | |
|---|
| | 483 | |
|---|
| 472 | 484 | return true; |
|---|
| 473 | 485 | } |
|---|
| r2116 |
r2119 |
|
| 153 | 153 | } |
|---|
| 154 | 154 | |
|---|
| 155 | | else if( element instanceof PModule) |
|---|
| | 155 | else if (element instanceof PModule) |
|---|
| 156 | 156 | { |
|---|
| 157 | 157 | |
|---|
| 158 | 158 | PModule mod = ((PModule)element); |
|---|
| 159 | | if( mod.getParent() == null) |
|---|
| | 159 | if (mod.getParent() == null) |
|---|
| 160 | 160 | return mod.getProject(); |
|---|
| 161 | 161 | } |
|---|
| 162 | 162 | |
|---|
| 163 | | else if( element instanceof IProject && ((IProject)element).isOpen() ) |
|---|
| 164 | | { |
|---|
| 165 | | return((IProject)element).getParent(); |
|---|
| 166 | | } |
|---|
| 167 | | |
|---|
| 168 | | else if( element instanceof IFolder) |
|---|
| | 163 | else if (element instanceof IProject && ((IProject)element).isOpen()) |
|---|
| | 164 | { |
|---|
| | 165 | return ((IProject)element).getParent(); |
|---|
| | 166 | } |
|---|
| | 167 | |
|---|
| | 168 | else if (element instanceof IFolder) |
|---|
| 169 | 169 | { |
|---|
| 170 | 170 | return ((IFolder)element).getParent(); |
|---|
| 171 | 171 | } |
|---|
| 172 | 172 | |
|---|
| 173 | | else if( element instanceof IFile) |
|---|
| | 173 | else if (element instanceof IFile) |
|---|
| 174 | 174 | { |
|---|
| 175 | 175 | return ((IFile)element).getParent(); |
|---|
| … | … | |
| 181 | 181 | public boolean hasChildren(Object element) |
|---|
| 182 | 182 | { |
|---|
| 183 | | if( element instanceof PLayer) |
|---|
| | 183 | if (element instanceof PLayer) |
|---|
| 184 | 184 | { |
|---|
| 185 | 185 | return !((PLayer)element).getModules().isEmpty(); |
|---|
| 186 | 186 | } |
|---|
| 187 | | else if( element instanceof IProject && ((IProject)element).isOpen() ) |
|---|
| | 187 | else if (element instanceof IProject && ((IProject)element).isOpen() ) |
|---|
| 188 | 188 | { |
|---|
| 189 | 189 | try |
|---|
| … | … | |
| 204 | 204 | } |
|---|
| 205 | 205 | } |
|---|
| 206 | | else if( element instanceof IFolder) |
|---|
| | 206 | else if (element instanceof IFolder) |
|---|
| 207 | 207 | { |
|---|
| 208 | 208 | try |
|---|
| … | … | |
| 298 | 298 | |
|---|
| 299 | 299 | if (children[i].getFileExtension() != null && |
|---|
| 300 | | children[i].getFileExtension().equals("if")) |
|---|
| | 300 | children[i].getFileExtension().equals(BaseProjectNature.IF_EXTENSION)) |
|---|
| 301 | 301 | { |
|---|
| 302 | 302 | PModule currModule = new PModule((IFile)children[i], layer); |
|---|
| … | … | |
| 345 | 345 | PLayer currLayer = null; |
|---|
| 346 | 346 | |
|---|
| 347 | | if (rsrc.getName().endsWith(".if")) |
|---|
| | 347 | if (rsrc.getName().endsWith("." + BaseProjectNature.IF_EXTENSION)) |
|---|
| 348 | 348 | { |
|---|
| 349 | 349 | bIsModule = true; |
|---|
| … | … | |
| 449 | 449 | // ends with |
|---|
| 450 | 450 | { |
|---|
| 451 | | if (st.endsWith(".pp")) |
|---|
| 452 | | return false; |
|---|
| 453 | | if (st.endsWith(".fc")) |
|---|
| 454 | | return false; |
|---|
| 455 | | if (st.endsWith(".te")) |
|---|
| 456 | | return false; |
|---|
| 457 | | if (st.endsWith(".conf")) |
|---|
| 458 | | return false; |
|---|
| 459 | | if (st.endsWith(".xml")) |
|---|
| | 451 | if (st.endsWith("." + BaseProjectNature.MODULE_EXTENSION)) |
|---|
| | 452 | return false; |
|---|
| | 453 | if (st.endsWith("." + BaseProjectNature.FC_EXTENSION)) |
|---|
| | 454 | return false; |
|---|
| | 455 | if (st.endsWith("." + BaseProjectNature.TE_EXTENSION)) |
|---|
| | 456 | return false; |
|---|
| | 457 | if (st.endsWith("." + BaseProjectNature.CONF_EXTENSION)) |
|---|
| | 458 | return false; |
|---|
| | 459 | if (st.endsWith("." + BaseProjectNature.XML_EXTENSION)) |
|---|
| 460 | 460 | return false; |
|---|
| 461 | 461 | } |
|---|
| r2063 |
r2119 |
|
| 24 | 24 | |
|---|
| 25 | 25 | import com.tresys.slide.plugin.SLIDEPlugin; |
|---|
| | 26 | import com.tresys.slide.plugin.nature.BaseProjectNature; |
|---|
| 26 | 27 | import com.tresys.slide.plugin.nature.SystemProjectNature; |
|---|
| 27 | 28 | import com.tresys.slide.plugin.views.policyexplorer.PLayer; |
|---|
| … | … | |
| 159 | 160 | { |
|---|
| 160 | 161 | IFolder systemDir = i_pSystem.getFolder(); |
|---|
| 161 | | IFolder modulesDir = systemDir.getFolder("policy/modules"); |
|---|
| | 162 | IFolder modulesDir = systemDir.getFolder(BaseProjectNature.DIR_POLICY + "/" + BaseProjectNature.DIR_MODULES); |
|---|
| 162 | 163 | |
|---|
| 163 | 164 | Vector layers = new Vector (); |
|---|
| … | … | |
| 298 | 299 | |
|---|
| 299 | 300 | if (children[i].getFileExtension() != null && |
|---|
| 300 | | children[i].getFileExtension().equals("if")) |
|---|
| | 301 | children[i].getFileExtension().equals(BaseProjectNature.IF_EXTENSION)) |
|---|
| 301 | 302 | { |
|---|
| 302 | 303 | PModule currModule = new PModule((IFile) children[i], layer); |
|---|
| … | … | |
| 328 | 329 | if (rsrc instanceof IProject) |
|---|
| 329 | 330 | { |
|---|
| 330 | | if( delta.getFlags() == IResourceDelta.OPEN ) |
|---|
| | 331 | if (delta.getFlags() == IResourceDelta.OPEN) |
|---|
| 331 | 332 | { |
|---|
| 332 | 333 | mNeedRefresh = true; |
|---|
| … | … | |
| 334 | 335 | } |
|---|
| 335 | 336 | |
|---|
| 336 | | if (! ((IProject) rsrc).isOpen()) |
|---|
| | 337 | if (!((IProject) rsrc).isOpen()) |
|---|
| 337 | 338 | return false; |
|---|
| 338 | 339 | |
|---|
| … | … | |
| 356 | 357 | if (rsrc instanceof IFile) |
|---|
| 357 | 358 | { |
|---|
| 358 | | if (!rsrc.getName().endsWith(".if")) |
|---|
| | 359 | if (!rsrc.getName().endsWith("." + BaseProjectNature.IF_EXTENSION)) |
|---|
| 359 | 360 | return false; |
|---|
| 360 | 361 | |
|---|
| … | … | |
| 454 | 455 | } |
|---|
| 455 | 456 | } |
|---|
| 456 | | else if (rsrc.getParent().getName().equals("modules")) |
|---|
| | 457 | else if (rsrc.getParent().getName().equals(BaseProjectNature.DIR_MODULES)) |
|---|
| 457 | 458 | { |
|---|
| 458 | 459 | // layer added |
|---|
| … | … | |
| 467 | 468 | if (layers == null) |
|---|
| 468 | 469 | return false; |
|---|
| 469 | | |
|---|
| 470 | | |
|---|
| | 470 | |
|---|
| 471 | 471 | for (Iterator itr2 = layers.iterator(); itr2.hasNext(); ) |
|---|
| 472 | 472 | { |
|---|
| … | … | |
| 475 | 475 | return false; |
|---|
| 476 | 476 | } |
|---|
| 477 | | |
|---|
| | 477 | |
|---|
| 478 | 478 | layers.add (new PLayer ((IFolder) rsrc)); |
|---|
| 479 | 479 | mNeedRefresh = true; |
|---|
| … | … | |
| 481 | 481 | } |
|---|
| 482 | 482 | } |
|---|
| | 483 | |
|---|
| | 484 | if (delta.getKind () == IResourceDelta.REMOVED) |
|---|
| | 485 | { |
|---|
| | 486 | for (Iterator itr = getSystems(m_proj).iterator (); itr.hasNext (); ) |
|---|
| | 487 | { |
|---|
| | 488 | PSystem system = (PSystem) itr.next (); |
|---|
| | 489 | if (system.contains (rsrc)) |
|---|
| | 490 | { |
|---|
| | 491 | Vector layers = (Vector) m_Layers.get (system); |
|---|
| | 492 | if (layers == null) |
|---|
| | 493 | return false; |
|---|
| | 494 | |
|---|
| | 495 | for (Iterator itr2 = layers.iterator(); itr2.hasNext(); ) |
|---|
| | 496 | { |
|---|
| | 497 | PLayer layer = (PLayer) itr2.next(); |
|---|
| | 498 | if (layer.getFolder().equals(rsrc)) |
|---|
| | 499 | { |
|---|
| | 500 | itr2.remove (); |
|---|
| | 501 | mNeedRefresh = true; |
|---|
| | 502 | return false; |
|---|
| | 503 | } |
|---|
| | 504 | } |
|---|
| | 505 | } |
|---|
| | 506 | } |
|---|
| | 507 | } |
|---|
| 483 | 508 | } |
|---|
| 484 | 509 | } |
|---|
Download in other formats:
* Generating other formats may take time.