1 19 20 package org.netbeans.modules.apisupport.project.ui.customizer; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.text.Collator ; 25 import java.util.Arrays ; 26 import java.util.Collection ; 27 import java.util.Collections ; 28 import java.util.HashMap ; 29 import java.util.HashSet ; 30 import java.util.Iterator ; 31 import java.util.Map ; 32 import java.util.Set ; 33 import java.util.SortedSet ; 34 import java.util.TreeMap ; 35 import java.util.TreeSet ; 36 import javax.swing.SwingUtilities ; 37 import javax.swing.event.ListDataEvent ; 38 import javax.swing.event.ListDataListener ; 39 import org.netbeans.api.java.platform.JavaPlatform; 40 import org.netbeans.api.project.Project; 41 import org.netbeans.api.project.ProjectManager; 42 import org.netbeans.api.project.ProjectUtils; 43 import org.netbeans.modules.apisupport.project.EditableManifest; 44 import org.netbeans.modules.apisupport.project.ManifestManager; 45 import org.netbeans.modules.apisupport.project.NbModuleProject; 46 import org.netbeans.modules.apisupport.project.spi.NbModuleProvider; 47 import org.netbeans.modules.apisupport.project.ProjectXMLManager; 48 import org.netbeans.modules.apisupport.project.SuiteProvider; 49 import org.netbeans.modules.apisupport.project.Util; 50 import org.netbeans.modules.apisupport.project.suite.SuiteProject; 51 import org.netbeans.modules.apisupport.project.ui.customizer.CustomizerComponentFactory.DependencyListModel; 52 import org.netbeans.modules.apisupport.project.ui.customizer.CustomizerComponentFactory.FriendListModel; 53 import org.netbeans.modules.apisupport.project.ui.customizer.CustomizerComponentFactory.PublicPackagesTableModel; 54 import org.netbeans.modules.apisupport.project.ui.customizer.CustomizerComponentFactory.RequiredTokenListModel; 55 import org.netbeans.modules.apisupport.project.universe.LocalizedBundleInfo; 56 import org.netbeans.modules.apisupport.project.universe.ModuleEntry; 57 import org.netbeans.modules.apisupport.project.universe.ModuleList; 58 import org.netbeans.modules.apisupport.project.universe.NbPlatform; 59 import org.netbeans.spi.project.support.ant.AntProjectHelper; 60 import org.netbeans.spi.project.support.ant.PropertyEvaluator; 61 import org.openide.ErrorManager; 62 import org.openide.filesystems.FileObject; 63 import org.openide.filesystems.FileUtil; 64 import org.openide.util.Utilities; 65 66 71 public final class SingleModuleProperties extends ModuleProperties { 72 73 private static final String [] IDE_TOKENS = new String [] { 74 "org.openide.modules.os.Windows", "org.openide.modules.os.Unix", "org.openide.modules.os.MacOSX", "org.openide.modules.os.PlainUnix", "org.openide.modules.os.OS2" }; 80 81 public static final String BUILD_COMPILER_DEBUG = "build.compiler.debug"; public static final String BUILD_COMPILER_DEPRECATION = "build.compiler.deprecation"; public static final String CLUSTER_DIR = "cluster.dir"; public static final String IS_AUTOLOAD = "is.autoload"; public static final String IS_EAGER = "is.eager"; public static final String JAVAC_SOURCES = "javac.source"; public static final String JAVADOC_TITLE = "javadoc.title"; public static final String LICENSE_FILE = "license.file"; public static final String NBM_HOMEPAGE = "nbm.homepage"; public static final String NBM_MODULE_AUTHOR = "nbm.module.author"; public static final String NBM_NEEDS_RESTART = "nbm.needs.restart"; public static final String SPEC_VERSION_BASE = "spec.version.base"; 95 public static final String JAVAC_COMPILERARGS = "javac.compilerargs"; 97 static final String [] SOURCE_LEVELS = {"1.4", "1.5"}; 99 private final static Map <String , String > DEFAULTS; 100 101 private boolean majorReleaseVersionChanged; 102 private boolean specificationVersionChanged; 103 private boolean implementationVersionChange; 104 private boolean providedTokensChanged; 105 106 private boolean moduleListRefreshNeeded; 107 108 static { 109 Map <String , String > map = new HashMap <String , String >(); 111 map.put(BUILD_COMPILER_DEBUG, "true"); map.put(BUILD_COMPILER_DEPRECATION, "true"); map.put(IS_AUTOLOAD, "false"); map.put(IS_EAGER, "false"); map.put(JAVAC_SOURCES, "1.4"); map.put(NBM_NEEDS_RESTART, "false"); DEFAULTS = Collections.unmodifiableMap(map); 118 } 119 120 private NbModuleProvider.NbModuleType moduleType; 122 private SuiteProvider suiteProvider; 123 private ProjectXMLManager projectXMLManager; 124 private final LocalizedBundleInfo.Provider bundleInfoProvider; 125 private LocalizedBundleInfo bundleInfo; 126 127 private String majorReleaseVersion; 129 private String specificationVersion; 130 private String implementationVersion; 131 private String provTokensString; 132 private SortedSet <String > requiredTokens; 133 private NbPlatform activePlatform; 134 private NbPlatform originalPlatform; 135 private JavaPlatform activeJavaPlatform; 136 137 138 private SortedSet <String > availablePublicPackages; 139 140 private String [] allTokens; 141 142 143 private SortedSet <String > modCategories; 144 145 146 private Set <ModuleDependency> universeDependencies; 147 148 private PublicPackagesTableModel publicPackagesModel; 150 private DependencyListModel dependencyListModel; 151 private FriendListModel friendListModel; 152 private RequiredTokenListModel requiredTokensListModel; 153 154 public static final String NB_PLATFORM_PROPERTY = "nbPlatform"; public static final String JAVA_PLATFORM_PROPERTY = "nbjdk.active"; public static final String DEPENDENCIES_PROPERTY = "moduleDependencies"; 158 161 public static SingleModuleProperties getInstance(final NbModuleProject project) { 162 SuiteProvider sp = project.getLookup().lookup(SuiteProvider.class); 163 return new SingleModuleProperties(project.getHelper(), project.evaluator(), sp, Util.getModuleType(project), 164 project.getLookup().lookup(LocalizedBundleInfo.Provider.class)); 165 } 166 167 170 SingleModuleProperties(AntProjectHelper helper, PropertyEvaluator evaluator, 171 SuiteProvider sp, NbModuleProvider.NbModuleType moduleType, 172 LocalizedBundleInfo.Provider bundleInfoProvider) { 173 super(helper, evaluator); 175 this.bundleInfoProvider = bundleInfoProvider; 176 refresh(moduleType, sp); 177 } 178 179 protected void refresh(NbModuleProvider.NbModuleType moduleType, 180 SuiteProvider suiteProvider) { 181 reloadProperties(); 182 this.suiteProvider = suiteProvider; 184 this.moduleType = moduleType; 185 universeDependencies = null; 186 modCategories = null; 187 availablePublicPackages = null; 188 dependencyListModel = null; 189 friendListModel = null; 190 requiredTokensListModel = null; 191 projectXMLManager = null; 192 if (isSuiteComponent()) { 193 assert getSuiteDirectory() != null; 194 ModuleList.refreshSuiteModuleList(getSuiteDirectory()); 195 } 196 ManifestManager manifestManager = ManifestManager.getInstance(getManifestFile(), false); 197 majorReleaseVersion = manifestManager.getReleaseVersion(); 198 specificationVersion = manifestManager.getSpecificationVersion(); 199 implementationVersion = manifestManager.getImplementationVersion(); 200 provTokensString = manifestManager.getProvidedTokensString(); 201 originalPlatform = activePlatform = NbPlatform.getPlatformByID( 202 getEvaluator().getProperty("nbplatform.active")); String activeJdk = getEvaluator().getProperty("nbjdk.active"); if (activeJdk != null) { 205 activeJavaPlatform = ModuleProperties.findJavaPlatformByID(activeJdk); } else { 207 String activeJdkHome = getEvaluator().getProperty("nbjdk.home"); activeJavaPlatform = ModuleProperties.findJavaPlatformByLocation(activeJdkHome); 209 } 210 getPublicPackagesModel().reloadData(loadPublicPackages()); 211 requiredTokens = Collections.unmodifiableSortedSet( 212 new TreeSet <String >(Arrays.asList(manifestManager.getRequiredTokens()))); 213 bundleInfo = bundleInfoProvider.getLocalizedBundleInfo(); 214 if (bundleInfo != null) { 215 try { 216 bundleInfo.reload(); 217 } catch (IOException ioe) { 218 ErrorManager.getDefault().notify(ioe); 219 } 220 } 221 firePropertiesRefreshed(); 222 } 223 224 void libraryWrapperAdded() { 225 universeDependencies = null; 227 } 228 229 Map <String , String > getDefaultValues() { 230 return DEFAULTS; 231 } 232 233 LocalizedBundleInfo getBundleInfo() { 234 return bundleInfo; 235 } 236 237 239 240 String getCodeNameBase() { 241 return getProjectXMLManager().getCodeNameBase(); 242 } 243 244 String getJarFile() { 245 return getHelper().resolveFile(getEvaluator().evaluate("${cluster}/${module.jar}")).getAbsolutePath(); } 247 248 String getSuiteDirectoryPath() { 249 return getSuiteDirectory() != null ? getSuiteDirectory().getPath() : null; 250 } 251 252 File getSuiteDirectory() { 253 return suiteProvider != null ? suiteProvider.getSuiteDirectory() : null; 254 } 255 256 257 SuiteProject getSuite() { 258 assert isSuiteComponent(); 259 SuiteProject suite = null; 260 try { 261 suite = (SuiteProject) ProjectManager.getDefault().findProject(FileUtil.toFileObject(getSuiteDirectory())); 262 } catch (IOException e) { 263 Util.err.notify(ErrorManager.INFORMATIONAL, e); 264 } 265 return suite; 266 } 267 268 270 271 boolean isActivePlatformValid() { 272 NbPlatform plaf = getActivePlatform(); 273 return plaf == null || plaf.isValid(); 274 } 275 276 281 NbPlatform getActivePlatform() { 282 if (moduleType != NbModuleProvider.NETBEANS_ORG 283 && (activePlatform == null || !NbPlatform.getPlatforms().contains(activePlatform))) { 284 ModuleProperties.reportLostPlatform(activePlatform); 285 activePlatform = NbPlatform.getDefaultPlatform(); 286 } 287 return activePlatform; 288 } 289 290 void setActivePlatform(NbPlatform newPlaf) { 291 if (this.activePlatform != newPlaf) { 292 NbPlatform oldPlaf = this.activePlatform; 293 this.activePlatform = newPlaf; 294 this.dependencyListModel = null; 295 this.universeDependencies = null; 296 this.modCategories = null; 297 firePropertyChange(NB_PLATFORM_PROPERTY, oldPlaf, newPlaf); 298 } 299 } 300 301 JavaPlatform getActiveJavaPlatform() { 302 return activeJavaPlatform; 303 } 304 305 void setActiveJavaPlatform(JavaPlatform nue) { 306 JavaPlatform old = activeJavaPlatform; 307 if (nue != old) { 308 activeJavaPlatform = nue; 309 firePropertyChange(JAVA_PLATFORM_PROPERTY, old, nue); 310 } 311 } 312 313 String getMajorReleaseVersion() { 314 return majorReleaseVersion; 315 } 316 317 void setMajorReleaseVersion(String ver) { 318 if (!Utilities.compareObjects(majorReleaseVersion, ver)) { 319 majorReleaseVersion = ver; 320 majorReleaseVersionChanged = true; 321 } 322 } 323 324 String getSpecificationVersion() { 325 return specificationVersion; 326 } 327 328 void setSpecificationVersion(String ver) { 329 if (!Utilities.compareObjects(specificationVersion, ver)) { 330 specificationVersion = ver; 331 specificationVersionChanged = true; 332 } 333 } 334 335 String getImplementationVersion() { 336 return implementationVersion; 337 } 338 339 void setImplementationVersion(String ver) { 340 if (!Utilities.compareObjects(implementationVersion, ver)) { 341 implementationVersion = ver; 342 implementationVersionChange = true; 343 } 344 } 345 346 String getProvidedTokens() { 347 return provTokensString; 348 } 349 350 void setProvidedTokens(String tokens) { 351 if (!Utilities.compareObjects(provTokensString, tokens)) { 352 provTokensString = tokens; 353 providedTokensChanged = true; 354 } 355 } 356 357 boolean isStandalone() { 358 return moduleType == NbModuleProvider.STANDALONE; 359 } 360 361 boolean isNetBeansOrg() { 362 return moduleType == NbModuleProvider.NETBEANS_ORG; 363 } 364 365 boolean isSuiteComponent() { 366 return moduleType == NbModuleProvider.SUITE_COMPONENT; 367 } 368 369 public void setModuleListRefreshNeeded(boolean moduleListRefreshNeeded) { 370 this.moduleListRefreshNeeded = moduleListRefreshNeeded; 371 } 372 373 boolean isModuleListRefreshNeeded() { 374 return moduleListRefreshNeeded; 375 } 376 377 boolean dependingOnImplDependency() { 378 DependencyListModel depsModel = getDependenciesListModel(); 379 if (depsModel == CustomizerComponentFactory.INVALID_DEP_LIST_MODEL) { 380 return false; 381 } 382 Set <ModuleDependency> deps = depsModel.getDependencies(); 383 for (Iterator it = deps.iterator(); it.hasNext(); ) { 384 ModuleDependency dep = (ModuleDependency) it.next(); 385 if (dep.hasImplementationDepedendency()) { 386 return true; 387 } 388 } 389 return false; 390 } 391 392 private ProjectXMLManager getProjectXMLManager() { 393 if (projectXMLManager == null) { 394 try { 395 projectXMLManager = ProjectXMLManager.getInstance(getProjectDirectoryFile()); 396 } catch (IOException e) { 397 assert false : e; 398 } 399 } 400 return projectXMLManager; 401 } 402 403 407 DependencyListModel getDependenciesListModel() { 408 if (dependencyListModel == null) { 409 if (isActivePlatformValid()) { 410 try { 411 dependencyListModel = new DependencyListModel( 412 getProjectXMLManager().getDirectDependencies(getActivePlatform()), true); 413 dependencyListModel.addListDataListener(new ListDataListener () { 415 public void contentsChanged(ListDataEvent e) { 416 firePropertyChange(DEPENDENCIES_PROPERTY, null, 417 getDependenciesListModel()); 418 } 419 public void intervalAdded(ListDataEvent e) { 420 contentsChanged(null); 421 } 422 public void intervalRemoved(ListDataEvent e) { 423 contentsChanged(null); 424 } 425 }); 426 } catch (IOException ioe) { 427 ErrorManager.getDefault().notify(ioe); 428 dependencyListModel = CustomizerComponentFactory.getInvalidDependencyListModel(); 429 } 430 } else { 431 dependencyListModel = CustomizerComponentFactory.getInvalidDependencyListModel(); 432 } 433 } 434 return dependencyListModel; 435 } 436 437 453 Set <ModuleDependency> getUniverseDependencies( 454 final boolean filterExcludedModules, final boolean apiProvidersOnly) { 455 assert !SwingUtilities.isEventDispatchThread() : 456 "SingleModuleProperties.getUniverseDependencies() cannot be called from EDT"; if (universeDependencies == null) { 458 reloadModuleListInfo(); 459 } 460 Set <ModuleDependency> result = new HashSet <ModuleDependency>(universeDependencies); 461 if (filterExcludedModules && isSuiteComponent()) { 462 SuiteProject suite = getSuite(); 463 String [] disableModules = SuiteProperties.getArrayProperty( 464 suite.getEvaluator(), SuiteProperties.DISABLED_MODULES_PROPERTY); 465 String [] enableClusters = SuiteProperties.getArrayProperty( 466 suite.getEvaluator(), SuiteProperties.ENABLED_CLUSTERS_PROPERTY); 467 String [] disableClusters = SuiteProperties.getArrayProperty( 468 suite.getEvaluator(), SuiteProperties.DISABLED_CLUSTERS_PROPERTY); 469 String suiteClusterProp = getEvaluator().getProperty("cluster"); File suiteClusterDir = suiteClusterProp != null ? getHelper().resolveFile(suiteClusterProp) : null; 471 for (Iterator <ModuleDependency> it = result.iterator(); it.hasNext();) { 472 ModuleDependency dep = it.next(); 473 ModuleEntry me = dep.getModuleEntry(); 474 if (me.getClusterDirectory().equals(suiteClusterDir)) { 475 continue; 477 } 478 if (isExcluded(me, disableModules, enableClusters, disableClusters)) { 479 it.remove(); 480 } 481 } 482 } 483 if (apiProvidersOnly) { for (Iterator <ModuleDependency> it = result.iterator(); it.hasNext();) { 485 ModuleDependency dep = it.next(); 486 ModuleEntry me = dep.getModuleEntry(); 487 if (me.getPublicPackages().length == 0 || !me.isDeclaredAsFriend(getCodeNameBase())) { 488 it.remove(); 489 } 490 } 491 } 492 return Collections.unmodifiableSet(result); 493 } 494 495 499 Set <ModuleDependency> getUniverseDependencies(final boolean filterExcludedModules) { 500 return getUniverseDependencies(filterExcludedModules, false); 501 } 502 503 private static boolean isExcluded(final ModuleEntry me, 504 final String [] disableModules, final String [] enableClusters, final String [] disableClusters) { 505 if (Arrays.binarySearch(disableModules, me.getCodeNameBase()) >= 0) { 506 return true; 507 } 508 if (enableClusters.length != 0 && Arrays.binarySearch(enableClusters, me.getClusterDirectory().getName()) < 0) { 509 return true; 510 } 511 if (enableClusters.length == 0 && Arrays.binarySearch(disableClusters, me.getClusterDirectory().getName()) >= 0) { 512 return true; 513 } 514 return false; 515 } 516 517 520 String [] getAvailableFriends() { 521 SortedSet <String > set = new TreeSet <String >(); 522 if (isSuiteComponent()) { 523 for (Iterator it = SuiteUtils.getSubProjects(getSuite()).iterator(); it.hasNext();) { 524 Project prj = (Project) it.next(); 525 String cnb = ProjectUtils.getInformation(prj).getName(); 526 if (!getCodeNameBase().equals(cnb)) { 527 set.add(cnb); 528 } 529 } 530 } else if (isNetBeansOrg()) { 531 Set <ModuleDependency> deps = getUniverseDependencies(false); 532 for (Iterator it = deps.iterator(); it.hasNext();) { 533 ModuleDependency dep = (ModuleDependency) it.next(); 534 set.add(dep.getModuleEntry().getCodeNameBase()); 535 } 536 } return set.toArray(new String [set.size()]); 538 } 539 540 FriendListModel getFriendListModel() { 541 if (friendListModel == null) { 542 friendListModel = new FriendListModel(getProjectXMLManager().getFriends()); 543 } 544 return friendListModel; 545 } 546 547 RequiredTokenListModel getRequiredTokenListModel() { 548 if (requiredTokensListModel == null) { 549 requiredTokensListModel = new RequiredTokenListModel(requiredTokens); 550 } 551 return requiredTokensListModel; 552 } 553 554 String [] getAllTokens() { 556 if (allTokens == null) { 557 try { 558 SortedSet <String > provTokens = new TreeSet <String >(); 559 provTokens.addAll(Arrays.asList(IDE_TOKENS)); 560 for (Iterator it = getModuleList().getAllEntriesSoft().iterator(); it.hasNext(); ) { 561 ModuleEntry me = (ModuleEntry) it.next(); 562 provTokens.addAll(Arrays.asList(me.getProvidedTokens())); 563 } 564 String [] result = new String [provTokens.size()]; 565 return provTokens.toArray(result); 566 } catch (IOException e) { 567 allTokens = new String [0]; 568 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); 569 } 570 } 571 return allTokens; 572 } 573 574 PublicPackagesTableModel getPublicPackagesModel() { 575 if (publicPackagesModel == null) { 576 publicPackagesModel = new PublicPackagesTableModel(loadPublicPackages()); 577 } 578 return publicPackagesModel; 579 } 580 581 582 private Map <String , Boolean > loadPublicPackages() { 583 Collection <String > selectedPackages = getSelectedPackages(); 584 Map <String , Boolean > publicPackages = new TreeMap <String , Boolean >(); 585 for (Iterator <String > it = getAvailablePublicPackages().iterator(); it.hasNext(); ) { 586 String pkg = it.next(); 587 publicPackages.put(pkg, Boolean.valueOf(selectedPackages.contains(pkg))); 588 } 589 return publicPackages; 590 } 591 592 private Collection <String > getSelectedPackages() { 593 Collection <String > sPackages = new HashSet <String >(); 594 ManifestManager.PackageExport[] pexports = getProjectXMLManager().getPublicPackages(); 595 for (int i = 0; i < pexports.length; i++) { 596 ManifestManager.PackageExport pexport = pexports[i]; 597 if (pexport.isRecursive()) { 598 for (Iterator it = getAvailablePublicPackages().iterator(); it.hasNext(); ) { 599 String p = (String ) it.next(); 600 if (p.startsWith(pexport.getPackage())) { 601 sPackages.add(p); 602 } 603 } 604 } else { 605 sPackages.add(pexport.getPackage()); 606 } 607 } 608 return sPackages; 609 } 610 611 614 Set <String > getAvailablePublicPackages() { 615 if (availablePublicPackages == null) { 616 availablePublicPackages = Util.scanProjectForPackageNames(getProjectDirectoryFile()); 617 } 618 return availablePublicPackages; 619 } 620 621 void storeProperties() throws IOException { 622 super.storeProperties(); 623 624 storeManifestChanges(); 626 627 if (bundleInfo != null && bundleInfo.isModified()) { 629 bundleInfo.store(); 630 } 632 DependencyListModel dependencyListModel = getDependenciesListModel(); 635 if (dependencyListModel.isChanged()) { 636 Set <ModuleDependency> depsToSave = new TreeSet <ModuleDependency>(dependencyListModel.getDependencies()); 637 638 depsToSave.removeAll(dependencyListModel.getRemovedDependencies()); 640 641 depsToSave.addAll(dependencyListModel.getAddedDependencies()); 643 644 for (Map.Entry <ModuleDependency,ModuleDependency> entry : dependencyListModel.getEditedDependencies().entrySet()) { 646 depsToSave.remove(entry.getKey()); 647 depsToSave.add(entry.getValue()); 648 } 649 getProjectXMLManager().replaceDependencies(depsToSave); 650 } 651 String [] friends = getFriendListModel().getFriends(); 652 String [] publicPkgs = getPublicPackagesModel().getSelectedPackages(); 653 if (getPublicPackagesModel().isChanged() || getFriendListModel().isChanged()) { 654 if (friends.length > 0) { getProjectXMLManager().replaceFriends(friends, publicPkgs); 656 } else { getProjectXMLManager().replacePublicPackages(publicPkgs); 658 } 659 setModuleListRefreshNeeded(true); 660 } 661 662 if (isStandalone()) { 663 ModuleProperties.storePlatform(getHelper(), getActivePlatform()); 664 ModuleProperties.storeJavaPlatform(getHelper(), getEvaluator(), getActiveJavaPlatform(), false); 665 } else if (isNetBeansOrg()) { 666 ModuleProperties.storeJavaPlatform(getHelper(), getEvaluator(), getActiveJavaPlatform(), true); 667 } 668 } 669 670 673 private void storeManifestChanges() throws IOException { 674 FileObject manifestFO = FileUtil.toFileObject(getManifestFile()); 675 EditableManifest em; 676 if (manifestFO != null) { 677 em = Util.loadManifest(manifestFO); 678 } else { em = new EditableManifest(); 680 manifestFO = FileUtil.createData( 681 getHelper().getProjectDirectory(), "manifest.mf"); } 683 boolean changed = false; 684 if (majorReleaseVersionChanged) { 685 String module = "".equals(getMajorReleaseVersion()) ? 686 getCodeNameBase() : 687 getCodeNameBase() + '/' + getMajorReleaseVersion(); 688 setManifestAttribute(em, ManifestManager.OPENIDE_MODULE, module); 689 changed = true; 690 } 691 if (specificationVersionChanged) { 692 setManifestAttribute(em, ManifestManager.OPENIDE_MODULE_SPECIFICATION_VERSION, 693 getSpecificationVersion()); 694 changed = true; 695 } 696 if (implementationVersionChange) { 697 setManifestAttribute(em, ManifestManager.OPENIDE_MODULE_IMPLEMENTATION_VERSION, 698 getImplementationVersion()); 699 changed = true; 700 } 701 if (providedTokensChanged) { 702 setManifestAttribute(em, ManifestManager.OPENIDE_MODULE_PROVIDES, 703 getProvidedTokens()); 704 changed = true; 705 } 706 if (getRequiredTokenListModel().isChanged()) { 707 String [] reqTokens = getRequiredTokenListModel().getTokens(); 708 StringBuffer result = new StringBuffer (reqTokens.length > 1 ? "\n " : ""); for (int i = 0; i < reqTokens.length; i++) { 710 if (i != 0) { 711 result.append(",\n "); } 713 result.append(reqTokens[i]); 714 } 715 setManifestAttribute(em, ManifestManager.OPENIDE_MODULE_REQUIRES, result.toString()); 716 changed = true; 717 } 718 if (changed) { 719 Util.storeManifest(manifestFO, em); 720 } 721 } 722 723 private void setManifestAttribute(EditableManifest em, String key, String value) { 725 assert value != null; 726 if ("".equals(value)) { 727 if (em.getAttribute(key, null) != null) { 728 em.removeAttribute(key, null); 729 } 730 } else { 731 em.setAttribute(key, value, null); 732 } 733 } 734 735 File getManifestFile() { 737 return getHelper().resolveFile(getEvaluator().getProperty("manifest.mf")); } 739 740 748 SortedSet getModuleCategories() { 749 assert !SwingUtilities.isEventDispatchThread() : 750 "SingleModuleProperties.getModuleCategories() cannot be called from EDT"; if (modCategories == null && !reloadModuleListInfo()) { 752 return new TreeSet (); 753 } 754 return modCategories; 755 } 756 757 761 boolean reloadModuleListInfo() { 762 assert !SwingUtilities.isEventDispatchThread() : 763 "SingleModuleProperties.reloadModuleListInfo() cannot be called from EDT"; if (isActivePlatformValid()) { 765 try { 766 SortedSet <String > allCategories = new TreeSet <String >(Collator.getInstance()); 767 Set <ModuleDependency> allDependencies = new HashSet <ModuleDependency>(); 768 for (Iterator it = getModuleList().getAllEntriesSoft().iterator(); it.hasNext(); ) { 769 ModuleEntry me = (ModuleEntry) it.next(); 770 if (!me.getCodeNameBase().equals(getCodeNameBase())) { 771 allDependencies.add(new ModuleDependency(me)); 772 } 773 String cat = me.getCategory(); 774 if (cat != null) { 775 allCategories.add(cat); 776 } 777 } 778 modCategories = Collections.unmodifiableSortedSet(allCategories); 779 universeDependencies = Collections.unmodifiableSet(allDependencies); 780 return true; 781 } catch (IOException ioe) { 782 ErrorManager.getDefault().notify(ioe); 783 } 784 } 785 return false; 786 } 787 788 792 ModuleList getModuleList() throws IOException { 793 if (getActivePlatform() != this.originalPlatform) { 794 return ModuleList.getModuleList( 795 getProjectDirectoryFile(), getActivePlatform().getDestDir()); 796 } else { 797 return ModuleList.getModuleList(getProjectDirectoryFile()); 798 } 799 } 800 801 805 File evaluateFile(final String currentLicence) { 806 String evaluated = getEvaluator().evaluate(currentLicence); 807 return evaluated == null ? null : getHelper().resolveFile(evaluated); 808 } 809 810 Project getProject() { 811 Project p = null; 812 try { 813 p = ProjectManager.getDefault().findProject(getHelper().getProjectDirectory()); 814 } catch (IOException e) { 815 assert false : e; 816 } 817 return p; 818 } 819 820 } 821 | Popular Tags |