1 19 20 package org.netbeans.modules.web.project.ui; 21 22 import java.awt.Dialog ; 23 import java.awt.Image ; 24 import java.awt.event.ActionEvent ; 25 import java.beans.BeanInfo ; 26 import java.beans.PropertyChangeEvent ; 27 import java.beans.PropertyChangeListener ; 28 import java.io.IOException ; 29 import java.io.File ; 30 import java.net.MalformedURLException ; 31 import java.net.URI ; 32 import java.net.URL ; 33 import java.text.MessageFormat ; 34 import java.util.ArrayList ; 35 import java.util.Arrays ; 36 import java.util.Collections ; 37 import java.util.HashSet ; 38 import java.util.Iterator ; 39 import java.util.LinkedList ; 40 import java.util.List ; 41 import java.util.Set ; 42 import javax.swing.AbstractAction ; 43 import javax.swing.Action ; 44 import javax.swing.Icon ; 45 import javax.swing.ImageIcon ; 46 import javax.swing.JButton ; 47 import javax.swing.JFileChooser ; 48 import javax.swing.filechooser.FileFilter ; 49 import org.netbeans.modules.web.project.ui.customizer.AntArtifactChooser.ArtifactItem; 50 import org.netbeans.modules.web.project.ui.customizer.WebClassPathUi; 51 import org.openide.DialogDescriptor; 52 import org.openide.DialogDisplayer; 53 import org.openide.ErrorManager; 54 import org.openide.filesystems.FileObject; 55 import org.openide.filesystems.FileUtil; 56 import org.openide.filesystems.Repository; 57 import org.openide.filesystems.URLMapper; 58 import org.openide.loaders.DataFolder; 59 import org.openide.nodes.AbstractNode; 60 import org.openide.nodes.Children; 61 import org.openide.nodes.Node; 62 import org.openide.util.NbBundle; 63 import org.openide.util.RequestProcessor; 64 import org.openide.util.Utilities; 65 import org.openide.windows.WindowManager; 66 import org.netbeans.api.project.FileOwnerQuery; 67 import org.netbeans.api.project.SourceGroup; 68 import org.netbeans.api.project.Project; 69 import org.netbeans.api.project.ant.AntArtifact; 70 import org.netbeans.api.project.libraries.Library; 71 import org.netbeans.api.project.libraries.LibraryManager; 72 import org.netbeans.api.java.classpath.ClassPath; 73 import org.netbeans.api.java.project.JavaProjectConstants; 74 import org.netbeans.spi.project.support.ant.AntProjectHelper; 75 import org.netbeans.spi.project.support.ant.EditableProperties; 76 import org.netbeans.spi.project.support.ant.PropertyEvaluator; 77 import org.netbeans.spi.project.support.ant.PropertyUtils; 78 import org.netbeans.spi.project.support.ant.ReferenceHelper; 79 import org.netbeans.spi.java.project.support.ui.PackageView; 80 import org.netbeans.spi.java.classpath.support.ClassPathSupport; 81 import org.netbeans.modules.web.project.UpdateHelper; 82 import org.netbeans.modules.web.api.webmodule.WebModule; 83 import org.netbeans.modules.web.project.classpath.WebProjectClassPathExtender; 84 import org.netbeans.modules.web.project.ui.customizer.AntArtifactChooser; 85 import org.netbeans.modules.web.project.ui.customizer.WebProjectProperties; 86 import org.netbeans.modules.web.project.ui.customizer.LibrariesChooser; 87 import org.openide.util.lookup.Lookups; 88 89 93 final class LibrariesNode extends AbstractNode { 94 95 private static final Image ICON_BADGE = Utilities.loadImage("org/netbeans/modules/web/project/ui/resources/libraries-badge.png"); static final RequestProcessor rp = new RequestProcessor (); 97 private static Icon folderIconCache; 98 private static Icon openedFolderIconCache; 99 100 private final String displayName; 101 private final Action [] librariesNodeActions; 102 103 104 118 LibrariesNode (String displayName, Project project, PropertyEvaluator eval, UpdateHelper helper, ReferenceHelper refHelper, 119 String classPathProperty, String [] classPathIgnoreRef, String platformProperty, String j2eePlatformProperty, 120 Action [] librariesNodeActions, String webModuleElementName) { 121 super (new LibrariesChildren (eval, helper, refHelper, classPathProperty, classPathIgnoreRef, platformProperty, j2eePlatformProperty, webModuleElementName), Lookups.singleton(project)); 122 this.displayName = displayName; 123 this.librariesNodeActions = librariesNodeActions; 124 } 125 126 public String getDisplayName () { 127 return this.displayName; 128 } 129 130 public String getName () { 131 return this.getDisplayName(); 132 } 133 134 public Image getIcon( int type ) { 135 return computeIcon( false, type ); 136 } 137 138 public Image getOpenedIcon( int type ) { 139 return computeIcon( true, type ); 140 } 141 142 public Action [] getActions(boolean context) { 143 return this.librariesNodeActions; 144 } 145 146 public boolean canCopy() { 147 return false; 148 } 149 150 public static Action createAddProjectAction (Project p, String classPathId, String webModuleElementName) { 152 return new AddProjectAction (p, classPathId, webModuleElementName); 153 } 154 155 public static Action createAddLibraryAction (Project p, String classPathId, String webModuleElementName) { 156 return new AddLibraryAction (p, classPathId, webModuleElementName); 157 } 158 159 public static Action createAddFolderAction (Project p, String classPathId, String webModuleElementName) { 160 return new AddFolderAction (p, classPathId, webModuleElementName); 161 } 162 163 168 static synchronized Icon getFolderIcon (boolean opened) { 169 if (openedFolderIconCache == null) { 170 Node n = DataFolder.findFolder(Repository.getDefault().getDefaultFileSystem().getRoot()).getNodeDelegate(); 171 openedFolderIconCache = new ImageIcon (n.getOpenedIcon(BeanInfo.ICON_COLOR_16x16)); 172 folderIconCache = new ImageIcon (n.getIcon(BeanInfo.ICON_COLOR_16x16)); 173 } 174 if (opened) { 175 return openedFolderIconCache; 176 } 177 else { 178 return folderIconCache; 179 } 180 } 181 182 private Image computeIcon( boolean opened, int type ) { 183 Icon icon = getFolderIcon(opened); 184 Image image = ((ImageIcon )icon).getImage(); 185 image = Utilities.mergeImages(image, ICON_BADGE, 7, 7 ); 186 return image; 187 } 188 189 private static class LibrariesChildren extends Children.Keys implements PropertyChangeListener { 191 192 193 196 private static final String LIBRARY_PREFIX = "${libs."; 198 201 private static final String ANT_ARTIFACT_PREFIX = "${reference."; 205 private static final String FILE_REF_PREFIX = "${file.reference."; 209 private static final String REF_PREFIX = "${"; 211 private static final String LIBRARIES_ICON = "org/netbeans/modules/web/project/ui/resources/libraries.gif"; private static final String ARCHIVE_ICON = "org/netbeans/modules/web/project/ui/resources/jar.gif"; 214 private final PropertyEvaluator eval; 215 private final UpdateHelper helper; 216 private final ReferenceHelper refHelper; 217 private final String classPathProperty; 218 private final String platformProperty; 219 private final String j2eePlatformProperty; 220 private final Set classPathIgnoreRef; 221 private final String webModuleElementName; 222 223 private ClassPath fsListener; 227 228 229 LibrariesChildren (PropertyEvaluator eval, UpdateHelper helper, ReferenceHelper refHelper, 230 String classPathProperty, String [] classPathIgnoreRef, String platformProperty, String j2eePlatformProperty, String webModuleElementName) { 231 this.eval = eval; 232 this.helper = helper; 233 this.refHelper = refHelper; 234 this.classPathProperty = classPathProperty; 235 this.classPathIgnoreRef = new HashSet (Arrays.asList(classPathIgnoreRef)); 236 this.platformProperty = platformProperty; 237 this.j2eePlatformProperty = j2eePlatformProperty; 238 this.webModuleElementName = webModuleElementName; 239 } 240 241 public void propertyChange(PropertyChangeEvent evt) { 242 String propName = evt.getPropertyName(); 243 if (classPathProperty.equals(propName) || ClassPath.PROP_ROOTS.equals(propName)) { 244 synchronized (this) { 245 if (fsListener!=null) { 246 fsListener.removePropertyChangeListener (this); 247 } 248 } 249 rp.post (new Runnable () { 250 public void run () { 251 setKeys(getKeys()); 252 } 253 }); 254 } 255 } 256 257 protected void addNotify() { 258 this.eval.addPropertyChangeListener (this); 259 this.setKeys(getKeys ()); 260 } 261 262 protected void removeNotify() { 263 this.eval.removePropertyChangeListener(this); 264 synchronized (this) { 265 if (fsListener!=null) { 266 fsListener.removePropertyChangeListener (this); 267 fsListener = null; 268 } 269 } 270 this.setKeys(Collections.EMPTY_SET); 271 } 272 273 protected Node[] createNodes(Object obj) { 274 Node[] result = null; 275 if (obj instanceof Key) { 276 Key key = (Key) obj; 277 switch (key.getType()) { 278 case Key.TYPE_PLATFORM: 279 result = new Node[] {PlatformNode.create(eval, platformProperty)}; 280 break; 281 case Key.TYPE_J2EE_PLATFORM: 282 Project p = FileOwnerQuery.getOwner(helper.getAntProjectHelper().getProjectDirectory()); 283 result = new Node[] {J2eePlatformNode.create(p, eval, j2eePlatformProperty)}; 284 break; 285 case Key.TYPE_PROJECT: 286 result = new Node[] {new ProjectNode(key.getProject(), key.getArtifactLocation(), helper, eval, refHelper, key.getClassPathId(), 287 key.getEntryId(), webModuleElementName)}; 288 break; 289 case Key.TYPE_LIBRARY: 290 result = new Node[] {ActionFilterNode.create(PackageView.createPackageView(key.getSourceGroup()), 291 helper, eval, refHelper, key.getClassPathId(), key.getEntryId(), webModuleElementName)}; 292 break; 293 } 294 } 295 if (result == null) { 296 assert false : "Unknown key type"; result = new Node[0]; 298 } 299 return result; 300 } 301 302 private List getKeys () { 303 EditableProperties projectSharedProps = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 304 EditableProperties projectPrivateProps = helper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH); 305 EditableProperties privateProps = PropertyUtils.getGlobalProperties(); 306 List rootsList = new ArrayList (); 307 List result = getKeys (projectSharedProps, projectPrivateProps, privateProps, classPathProperty, rootsList); 308 if (platformProperty!=null) { 309 result.add (new Key()); 310 } 311 if (j2eePlatformProperty != null) { 312 result.add(new Key(true)); 313 } 314 ClassPath cp = ClassPathSupport.createClassPath ((URL [])rootsList.toArray(new URL [rootsList.size()])); 317 cp.addPropertyChangeListener (this); 318 cp.getRoots(); 319 synchronized (this) { 320 fsListener = cp; 321 } 322 return result; 323 } 324 325 private List getKeys (EditableProperties projectSharedProps, EditableProperties projectPrivateProps, 326 EditableProperties privateProps, String currentClassPath, List rootsList) { 327 List result = new ArrayList (); 328 String raw = projectSharedProps.getProperty (currentClassPath); 329 if (raw == null) { 330 raw = projectPrivateProps.getProperty(currentClassPath); 331 } 332 if (raw == null) { 333 raw = privateProps.getProperty(currentClassPath); 334 } 335 if (raw == null) { 336 return result; 337 } 338 List pe = new ArrayList (Arrays.asList(PropertyUtils.tokenizePath( raw ))); 339 while (pe.size()>0){ 340 String prop = (String ) pe.remove(0); 341 String propName = WebProjectProperties.getAntPropertyName (prop); 342 if (classPathIgnoreRef.contains(propName)) { 343 continue; 344 } 345 else if (prop.startsWith( LIBRARY_PREFIX )) { 346 String eval = prop.substring( LIBRARY_PREFIX.length(), prop.lastIndexOf('.') ); Library lib = LibraryManager.getDefault().getLibrary (eval); 349 if (lib != null) { 350 List roots = lib.getContent("classpath"); Icon libIcon = new ImageIcon (Utilities.loadImage(LIBRARIES_ICON)); 352 for (Iterator it = roots.iterator(); it.hasNext();) { 353 URL rootUrl = (URL ) it.next(); 354 rootsList.add (rootUrl); 355 FileObject root = URLMapper.findFileObject (rootUrl); 356 if (root != null) { 357 String displayName; 358 if ("jar".equals(rootUrl.getProtocol())) { FileObject file = FileUtil.getArchiveFile (root); 360 displayName = file.getNameExt(); 361 } 362 else { 363 File file = FileUtil.toFile (root); 364 if (file != null) { 365 displayName = file.getAbsolutePath(); 366 } 367 else { 368 displayName = root.getNameExt(); 369 } 370 } 371 displayName = MessageFormat.format ( 372 NbBundle.getMessage (LibrariesNode.class,"TXT_LibraryPartFormat"), 373 new Object [] {lib.getDisplayName(), displayName}); 374 SourceGroup sg = new LibrariesSourceGroup (root, displayName, libIcon, libIcon); 375 result.add (new Key(sg,currentClassPath, propName)); 376 } 377 } 378 } 379 } 381 else if (prop.startsWith(ANT_ARTIFACT_PREFIX)) { 382 Object [] ref = refHelper.findArtifactAndLocation(prop); 384 if (ref[0] != null && ref[1] != null) { 385 AntArtifact artifact = (AntArtifact)ref[0]; 386 URI uri = (URI )ref[1]; 387 result.add(new Key(artifact, uri, currentClassPath, propName)); 388 } 389 } 390 else if (prop.startsWith(FILE_REF_PREFIX)) { 391 String evaluatedRef = eval.getProperty(propName); 393 File file = helper.getAntProjectHelper().resolveFile(evaluatedRef); 394 SourceGroup sg = createFileSourceGroup(file,rootsList); 395 if (sg !=null) { 396 result.add (new Key(sg,currentClassPath, propName)); 397 } 398 } 399 else if (prop.startsWith(REF_PREFIX)) { 400 result.addAll(getKeys(projectSharedProps, projectPrivateProps, privateProps,propName, rootsList)); 402 } 403 else { 404 File file = helper.getAntProjectHelper().resolveFile(prop); 406 SourceGroup sg = createFileSourceGroup(file,rootsList); 407 if (sg !=null) { 408 result.add ( new Key(sg,currentClassPath, propName)); 409 } 410 } 411 } 412 return result; 413 } 414 415 private static SourceGroup createFileSourceGroup (File file, List rootsList) { 416 Icon icon; 417 Icon openedIcon; 418 String displayName; 419 try { 420 URL url = file.toURI().toURL(); 421 if (FileUtil.isArchiveFile(url)) { 422 url = FileUtil.getArchiveRoot(url); 423 icon = openedIcon = new ImageIcon (Utilities.loadImage(ARCHIVE_ICON)); 424 displayName = file.getName(); 425 } 426 else { 427 String sURL = url.toExternalForm(); 428 if (!sURL.endsWith("/")) { url = new URL (sURL+"/"); } 431 icon = getFolderIcon (false); 432 openedIcon = getFolderIcon (true); 433 displayName = file.getAbsolutePath(); 434 } 435 rootsList.add (url); 436 FileObject root = URLMapper.findFileObject (url); 437 if (root != null) { 438 return new LibrariesSourceGroup (root,displayName,icon,openedIcon); 439 } 440 } catch (MalformedURLException e) { 441 ErrorManager.getDefault().notify(e); 442 } 443 return null; 444 } 445 } 446 447 private static class Key { 448 static final int TYPE_PLATFORM = 0; 449 static final int TYPE_LIBRARY = 1; 450 static final int TYPE_PROJECT = 2; 451 static final int TYPE_J2EE_PLATFORM = 3; 452 453 private int type; 454 private String classPathId; 455 private String entryId; 456 private SourceGroup sg; 457 private AntArtifact antArtifact; 458 private URI uri; 459 460 Key () { 461 this(false); 462 } 463 464 Key (boolean j2ee) { 465 this.type = j2ee ? TYPE_J2EE_PLATFORM : TYPE_PLATFORM; 466 } 467 468 Key (SourceGroup sg, String classPathId, String entryId) { 469 this.type = TYPE_LIBRARY; 470 this.sg = sg; 471 this.classPathId = classPathId; 472 this.entryId = entryId; 473 } 474 475 Key (AntArtifact a, URI uri, String classPathId, String entryId) { 476 this.type = TYPE_PROJECT; 477 this.antArtifact = a; 478 this.uri = uri; 479 this.classPathId = classPathId; 480 this.entryId = entryId; 481 } 482 483 public int getType () { 484 return this.type; 485 } 486 487 public String getClassPathId () { 488 return this.classPathId; 489 } 490 491 public String getEntryId () { 492 return this.entryId; 493 } 494 495 public SourceGroup getSourceGroup () { 496 return this.sg; 497 } 498 499 public AntArtifact getProject() { 500 return this.antArtifact; 501 } 502 503 public URI getArtifactLocation() { 504 return this.uri; 505 } 506 507 public int hashCode() { 508 int hashCode = this.type<<16; 509 switch (this.type) { 510 case TYPE_LIBRARY: 511 hashCode ^= this.sg == null ? 0 : this.sg.hashCode(); 512 break; 513 case TYPE_PROJECT: 514 hashCode ^= this.antArtifact == null ? 0 : this.antArtifact.hashCode(); 515 break; 516 } 517 return hashCode; 518 } 519 520 public boolean equals(Object obj) { 521 if (!(obj instanceof Key)) { 522 return false; 523 } 524 Key other = (Key) obj; 525 if (other.type != type) { 526 return false; 527 } 528 switch (type) { 529 case TYPE_LIBRARY: 530 return (this.sg == null ? other.sg == null : this.sg.equals(other.sg)) && 531 (this.classPathId == null ? other.classPathId == null : this.classPathId.equals (other.classPathId)) && 532 (this.entryId == null ? other.entryId == null : this.entryId.equals (other.entryId)); 533 case TYPE_PROJECT: 534 return (this.antArtifact == null ? other.antArtifact == null : this.antArtifact.equals(other.antArtifact)) && 535 (this.classPathId == null ? other.classPathId == null : this.classPathId.equals (other.classPathId)) && 536 (this.entryId == null ? other.entryId == null : this.entryId.equals (other.entryId)); 537 case TYPE_PLATFORM: 538 case TYPE_J2EE_PLATFORM: 539 return true; 540 default: 541 throw new IllegalStateException (); 542 } 543 } 544 } 545 546 private static class AddProjectAction extends AbstractAction { 547 548 private final Project project; 549 private final String classPathId; 550 private final String webModuleElementName; 551 552 public AddProjectAction (Project project, String classPathId, String webModuleElementName) { 553 super( NbBundle.getMessage( LibrariesNode.class, "LBL_AddProject_Action" ) ); 554 this.project = project; 555 this.classPathId = classPathId; 556 this.webModuleElementName = webModuleElementName; 557 } 558 559 public void actionPerformed(ActionEvent e) { 560 ArtifactItem artifacts[] = AntArtifactChooser.showDialog(JavaProjectConstants.ARTIFACT_TYPE_JAR, project, null); 561 if ( artifacts != null ) { 562 addArtifacts( artifacts ); 563 } 564 } 565 566 private void addArtifacts (ArtifactItem[] artifactItems) { 567 WebProjectClassPathExtender cpExtender = (WebProjectClassPathExtender) project.getLookup().lookup(WebProjectClassPathExtender.class); 568 if (cpExtender != null) { 569 try { 570 cpExtender.addAntArtifacts(classPathId, artifactItems, webModuleElementName); 571 } catch (IOException ioe) { 572 ErrorManager.getDefault().notify(ioe); 573 } 574 } 575 else { 576 ErrorManager.getDefault().log ("WebProjectClassPathExtender not found in the project lookup of project: "+project.getProjectDirectory().getPath()); } 578 } 579 } 580 581 private static class AddLibraryAction extends AbstractAction { 582 583 private final Project project; 584 private final String classPathId; 585 private final String webModuleElementName; 586 587 public AddLibraryAction (Project project, String classPathId, String webModuleElementName) { 588 super( NbBundle.getMessage( LibrariesNode.class, "LBL_AddLibrary_Action" ) ); 589 this.project = project; 590 this.classPathId = classPathId; 591 this.webModuleElementName = webModuleElementName; 592 } 593 594 public void actionPerformed(ActionEvent e) { 595 Object [] options = new Object [] { 596 new JButton (NbBundle.getMessage (LibrariesNode.class,"LBL_AddLibrary")), 597 DialogDescriptor.CANCEL_OPTION 598 }; 599 ((JButton )options[0]).setEnabled(false); 600 ((JButton )options[0]).getAccessibleContext().setAccessibleDescription (NbBundle.getMessage (WebClassPathUi.class,"AD_AddLibrary")); 601 602 WebModule wm = WebModule.getWebModule(project.getProjectDirectory()); 603 String j2eeVersion = wm.getJ2eePlatformVersion(); 604 LibrariesChooser panel = new LibrariesChooser ((JButton )options[0], j2eeVersion); 605 DialogDescriptor desc = new DialogDescriptor(panel,NbBundle.getMessage( LibrariesNode.class, "LBL_CustomizeCompile_Classpath_AddLibrary" ), 606 true, options, options[0], DialogDescriptor.DEFAULT_ALIGN,null,null); 607 Dialog dlg = DialogDisplayer.getDefault().createDialog(desc); 608 dlg.setVisible(true); 609 if (desc.getValue() == options[0]) { 610 addLibraries (panel.getSelectedLibraries()); 611 } 612 dlg.dispose(); 613 } 614 615 private void addLibraries (Library[] libraries) { 616 WebProjectClassPathExtender cpExtender = (WebProjectClassPathExtender) project.getLookup().lookup(WebProjectClassPathExtender.class); 617 if (cpExtender != null) { 618 try { 619 cpExtender.addLibraries(classPathId, libraries, webModuleElementName); 620 } catch (IOException ioe) { 621 ErrorManager.getDefault().notify(ioe); 622 } 623 } 624 else { 625 ErrorManager.getDefault().log ("WebProjectClassPathExtender not found in the project lookup of project: "+project.getProjectDirectory().getPath()); } 627 } 628 629 } 630 631 private static class AddFolderAction extends AbstractAction { 632 633 private final Project project; 634 private final String classPathId; 635 private final String webModuleElementName; 636 637 public AddFolderAction (Project project, String classPathId, String webModuleElementName) { 638 super( NbBundle.getMessage( LibrariesNode.class, "LBL_AddFolder_Action" ) ); 639 this.project = project; 640 this.classPathId = classPathId; 641 this.webModuleElementName = webModuleElementName; 642 } 643 644 public void actionPerformed(ActionEvent e) { 645 JFileChooser chooser = new JFileChooser (); 646 FileUtil.preventFileChooserSymlinkTraversal(chooser, null); 647 chooser.setFileSelectionMode( JFileChooser.FILES_AND_DIRECTORIES ); 648 chooser.setMultiSelectionEnabled( true ); 649 chooser.setDialogTitle( NbBundle.getMessage( LibrariesNode.class, "LBL_AddJar_DialogTitle" ) ); chooser.setAcceptAllFileFilterUsed( false ); 652 FileFilter fileFilter = new SimpleFileFilter ( 653 NbBundle.getMessage( WebClassPathUi.class, "LBL_ZipJarFolderFilter" )); chooser.setFileFilter(fileFilter); 655 File curDir = FoldersListSettings.getDefault().getLastUsedClassPathFolder(); 656 chooser.setCurrentDirectory (curDir); 657 int option = chooser.showOpenDialog( WindowManager.getDefault().getMainWindow() ); 658 if ( option == JFileChooser.APPROVE_OPTION ) { 659 File files[] = chooser.getSelectedFiles(); 660 addJarFiles( files, fileFilter ); 661 curDir = FileUtil.normalizeFile(chooser.getCurrentDirectory()); 662 FoldersListSettings.getDefault().setLastUsedClassPathFolder(curDir); 663 } 664 } 665 666 private void addJarFiles (File [] files, FileFilter fileFilter) { 667 WebProjectClassPathExtender cpExtender = (WebProjectClassPathExtender) project.getLookup().lookup(WebProjectClassPathExtender.class); 668 if (cpExtender != null) { 669 List fileObjects = new LinkedList (); 670 for (int i = 0; i < files.length; i++) { 671 if (fileFilter.accept(files[i])) { 672 FileObject fo = FileUtil.toFileObject (files[i]); 673 assert fo != null : files[i]; 674 fileObjects.add(fo); 675 } 676 } 677 try { 678 FileObject[] fileObjectArray = new FileObject[fileObjects.size()]; 679 fileObjects.toArray(fileObjectArray); 680 cpExtender.addArchiveFiles(classPathId, fileObjectArray, webModuleElementName); 681 } catch (IOException ioe) { 682 ErrorManager.getDefault().notify(ioe); 683 } 684 } 685 else { 686 ErrorManager.getDefault().log ("WebProjectClassPathExtender not found in the project lookup of project: "+project.getProjectDirectory().getPath()); } 688 } 689 690 } 691 692 private static class SimpleFileFilter extends FileFilter { 693 694 private String description; 695 696 697 public SimpleFileFilter (String description) { 698 this.description = description; 699 } 700 701 public boolean accept(File f) { 702 if (f.isDirectory()) 703 return true; 704 try { 705 return FileUtil.isArchiveFile(f.toURI().toURL()); 706 } catch (MalformedURLException mue) { 707 ErrorManager.getDefault().notify(mue); 708 return false; 709 } 710 } 711 712 public String getDescription() { 713 return this.description; 714 } 715 } 716 } 717 | Popular Tags |