PageRenderTime 62ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/projects/netbeans-7.3/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/SuiteCustomizerLibraries.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus
Java | 1031 lines | 835 code | 91 blank | 105 comment | 145 complexity | 8a8265278d05b4efa49aa204ce28a0cf MD5 | raw file
  1. /*
  2. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  3. *
  4. * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
  5. *
  6. * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
  7. * Other names may be trademarks of their respective owners.
  8. *
  9. * The contents of this file are subject to the terms of either the GNU
  10. * General Public License Version 2 only ("GPL") or the Common
  11. * Development and Distribution License("CDDL") (collectively, the
  12. * "License"). You may not use this file except in compliance with the
  13. * License. You can obtain a copy of the License at
  14. * http://www.netbeans.org/cddl-gplv2.html
  15. * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
  16. * specific language governing permissions and limitations under the
  17. * License. When distributing the software, include this License Header
  18. * Notice in each file and include the License file at
  19. * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
  20. * particular file as subject to the "Classpath" exception as provided
  21. * by Oracle in the GPL Version 2 section of the License file that
  22. * accompanied this code. If applicable, add the following below the
  23. * License Header, with the fields enclosed by brackets [] replaced by
  24. * your own identifying information:
  25. * "Portions Copyrighted [year] [name of copyright owner]"
  26. *
  27. * Contributor(s):
  28. *
  29. * The Original Software is NetBeans. The Initial Developer of the Original
  30. * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
  31. * Microsystems, Inc. All Rights Reserved.
  32. *
  33. * If you wish your version of this file to be governed by only the CDDL
  34. * or only the GPL Version 2, indicate your decision by adding
  35. * "[Contributor] elects to include this software in this distribution
  36. * under the [CDDL or GPL Version 2] license." If you do not indicate a
  37. * single choice of license, a recipient has the option to distribute
  38. * your version of this file under either the CDDL, the GPL Version 2 or
  39. * to extend the choice of license to its licensees as provided above.
  40. * However, if you add GPL Version 2 code and therefore, elected the GPL
  41. * Version 2 license, then the option applies only if the new code is
  42. * made subject to such option by the copyright holder.
  43. */
  44. package org.netbeans.modules.apisupport.project.ui.customizer;
  45. import java.io.CharConversionException;
  46. import javax.swing.Action;
  47. import javax.swing.table.TableColumn;
  48. import org.netbeans.modules.apisupport.project.universe.ClusterUtils;
  49. import java.awt.EventQueue;
  50. import java.beans.PropertyChangeEvent;
  51. import java.beans.PropertyChangeListener;
  52. import java.beans.PropertyEditor;
  53. import java.io.File;
  54. import java.io.IOException;
  55. import java.lang.reflect.InvocationTargetException;
  56. import java.text.Collator;
  57. import java.util.ArrayList;
  58. import java.util.Arrays;
  59. import java.util.Collection;
  60. import java.util.Collections;
  61. import java.util.Comparator;
  62. import java.util.HashMap;
  63. import java.util.HashSet;
  64. import java.util.Iterator;
  65. import java.util.LinkedHashSet;
  66. import java.util.List;
  67. import java.util.Map;
  68. import java.util.MissingResourceException;
  69. import java.util.Set;
  70. import java.util.SortedMap;
  71. import java.util.SortedSet;
  72. import java.util.TreeMap;
  73. import java.util.TreeSet;
  74. import java.util.jar.Manifest;
  75. import java.util.logging.Level;
  76. import java.util.logging.Logger;
  77. import javax.swing.ListSelectionModel;
  78. import javax.swing.event.ChangeEvent;
  79. import javax.swing.event.ChangeListener;
  80. import org.netbeans.api.annotations.common.NullAllowed;
  81. import org.netbeans.api.java.platform.JavaPlatform;
  82. import org.netbeans.api.java.platform.PlatformsCustomizer;
  83. import org.netbeans.api.project.Project;
  84. import org.netbeans.api.project.ProjectManager;
  85. import org.netbeans.api.project.ProjectUtils;
  86. import org.netbeans.modules.apisupport.project.ApisupportAntUtils;
  87. import org.netbeans.modules.apisupport.project.api.ManifestManager;
  88. import org.netbeans.modules.apisupport.project.NbModuleProject;
  89. import org.netbeans.modules.apisupport.project.NbModuleType;
  90. import org.netbeans.modules.apisupport.project.SuiteProvider;
  91. import org.netbeans.modules.apisupport.project.api.UIUtil;
  92. import org.netbeans.modules.apisupport.project.api.Util;
  93. import org.netbeans.modules.apisupport.project.spi.NbModuleProvider;
  94. import org.netbeans.modules.apisupport.project.suite.SuiteProject;
  95. import org.netbeans.modules.apisupport.project.ui.ApisupportAntUIUtils;
  96. import org.netbeans.modules.apisupport.project.ui.platform.PlatformComponentFactory;
  97. import org.netbeans.modules.apisupport.project.ui.platform.NbPlatformCustomizer;
  98. import org.netbeans.modules.apisupport.project.universe.LocalizedBundleInfo;
  99. import org.netbeans.modules.apisupport.project.universe.LocalizedBundleInfo.Provider;
  100. import org.netbeans.modules.apisupport.project.universe.ModuleEntry;
  101. import org.netbeans.modules.apisupport.project.universe.ModuleList;
  102. import org.netbeans.modules.apisupport.project.universe.NbPlatform;
  103. import org.netbeans.modules.apisupport.project.universe.HarnessVersion;
  104. import org.netbeans.spi.project.ui.support.ProjectCustomizer;
  105. import org.netbeans.swing.outline.Outline;
  106. import org.openide.DialogDisplayer;
  107. import org.openide.ErrorManager;
  108. import org.openide.NotifyDescriptor;
  109. import org.openide.explorer.ExplorerManager;
  110. import org.openide.filesystems.FileObject;
  111. import org.openide.filesystems.FileUtil;
  112. import org.openide.modules.Dependency;
  113. import org.openide.modules.SpecificationVersion;
  114. import org.openide.nodes.AbstractNode;
  115. import org.openide.nodes.Children;
  116. import org.openide.nodes.Node;
  117. import org.openide.nodes.PropertySupport;
  118. import org.openide.nodes.Sheet;
  119. import org.openide.util.NbBundle;
  120. import org.openide.util.RequestProcessor;
  121. import org.openide.util.actions.SystemAction;
  122. import org.openide.xml.XMLUtil;
  123. import org.w3c.dom.Element;
  124. /**
  125. * Represents <em>Libraries</em> panel in Suite customizer.
  126. *
  127. * @author Martin Krauskopf
  128. */
  129. public final class SuiteCustomizerLibraries extends NbPropertyPanel.Suite
  130. implements ExplorerManager.Provider, ChangeListener {
  131. private final ExplorerManager manager;
  132. private ModuleEntry[] platformModules;
  133. Set<ModuleEntry> extraBinaryModules = new HashSet<ModuleEntry>();
  134. static boolean TEST = false;
  135. private LibrariesChildren libChildren;
  136. private boolean extClustersLoaded;
  137. private AbstractNode realRoot;
  138. private AbstractNode waitRoot;
  139. public static final String WAIT_ICON_PATH =
  140. "org/netbeans/modules/apisupport/project/suite/resources/wait.png"; // NOI18N
  141. /**
  142. * Creates new form SuiteCustomizerLibraries
  143. */
  144. public SuiteCustomizerLibraries(final SuiteProperties suiteProps, ProjectCustomizer.Category cat) {
  145. super(suiteProps, SuiteCustomizerLibraries.class, cat);
  146. initComponents();
  147. resolveButton.setVisible(false);
  148. manager = new ExplorerManager();
  149. waitRoot = new AbstractNode(new Children.Array() {
  150. @Override
  151. protected Collection<Node> initCollection() {
  152. return Collections.singleton((Node) new WaitNode());
  153. }
  154. });
  155. waitRoot.setName(getMessage("LBL_ModuleListClusters"));
  156. waitRoot.setDisplayName(getMessage("LBL_ModuleListClustersModules"));
  157. manager.setRootContext(waitRoot);
  158. refresh();
  159. view.setProperties(new Node.Property[] { ENABLED_PROP_TEMPLATE, ORIGIN_PROP_TEMPLATE });
  160. Outline outline = view.getOutline();
  161. outline.setRootVisible(false);
  162. outline.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  163. TableColumn col = outline.getColumnModel().getColumn(1);
  164. col.setMinWidth(25);
  165. col.setMaxWidth(200);
  166. col.setPreferredWidth(70);
  167. col = outline.getColumnModel().getColumn(2);
  168. col.setMinWidth(25);
  169. col.setMaxWidth(300);
  170. col.setPreferredWidth(130);
  171. suiteProps.getBrandingModel().addChangeListener(this);
  172. suiteProps.addPropertyChangeListener(new PropertyChangeListener() {
  173. public void propertyChange(PropertyChangeEvent evt) {
  174. if (SuiteProperties.NB_PLATFORM_PROPERTY.equals(evt.getPropertyName())) {
  175. refresh();
  176. }
  177. }
  178. });
  179. manager.addPropertyChangeListener(new PropertyChangeListener() {
  180. public void propertyChange(PropertyChangeEvent evt) {
  181. if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())) {
  182. Node[] nodes = (Node[]) evt.getNewValue();
  183. updateButtons(nodes);
  184. }
  185. }
  186. });
  187. updateButtons(manager.getSelectedNodes());
  188. javaPlatformCombo.setRenderer(JavaPlatformComponentFactory.javaPlatformListCellRenderer());
  189. }
  190. private void addProjectCluster(ClusterInfo ci, boolean showMessages) throws MissingResourceException, IllegalArgumentException {
  191. Project project = ci.getProject();
  192. assert project != null;
  193. SuiteProject thisPrj = getProperties().getProject();
  194. if (thisPrj.getProjectDirectory().equals(project.getProjectDirectory())) {
  195. if (showMessages)
  196. DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
  197. NbBundle.getMessage(SuiteCustomizerLibraries.class, "MSG_TryingToAddMyself",
  198. ProjectUtils.getInformation(project).getDisplayName())));
  199. return;
  200. }
  201. if (libChildren.findCluster(ci.getClusterDir()) != null) {
  202. if (showMessages) {
  203. DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
  204. NbBundle.getMessage(SuiteCustomizerLibraries.class, "MSG_AlreadyOnClusterPath",
  205. ProjectUtils.getInformation(project).getDisplayName())));
  206. }
  207. return;
  208. }
  209. initNodes();
  210. ClusterNode cnode;
  211. NbModuleProvider nmtp = project.getLookup().lookup(NbModuleProvider.class);
  212. if (nmtp != null) {
  213. cnode = new ClusterNode(ci, Children.LEAF);
  214. } else {
  215. SuiteProvider sprv = project.getLookup().lookup(SuiteProvider.class);
  216. assert sprv != null;
  217. cnode = createSuiteNode(ci);
  218. }
  219. synchronized (libChildren.extraNodes) {
  220. libChildren.extraNodes.add(cnode);
  221. }
  222. libChildren.setMergedKeys();
  223. }
  224. private boolean isExternalCluster(Enabled en) {
  225. return !en.isLeaf() && en.getProject() == null && !en.isPlatformNode();
  226. }
  227. private void updateButtons(Node[] nodes) {
  228. boolean canRemove = nodes.length > 0;
  229. boolean canEdit = nodes.length == 1;
  230. for (Node node : nodes) {
  231. if (! (node instanceof Enabled)) {
  232. canRemove = canEdit = false;
  233. break;
  234. }
  235. Enabled en = (Enabled) node;
  236. canRemove &= en instanceof ClusterNode && ! en.isPlatformNode();
  237. canEdit &= isExternalCluster(en);
  238. }
  239. removeButton.setEnabled(canRemove);
  240. editButton.setEnabled(canEdit);
  241. }
  242. private RequestProcessor.Task refreshTask;
  243. protected void refresh() {
  244. refreshJavaPlatforms();
  245. refreshPlatforms();
  246. if (refreshTask == null) {
  247. refreshTask = RP.create(new Runnable() {
  248. public void run() {
  249. refreshModules();
  250. updateDependencyWarnings(true);
  251. }
  252. });
  253. }
  254. if (TEST) {
  255. refreshTask.run();
  256. } else {
  257. refreshTask.schedule(0);
  258. }
  259. updateJavaPlatformEnabled();
  260. }
  261. private void addExtCluster(ClusterInfo ci) {
  262. Set<String> disabledModuleCNB = new HashSet<String>(Arrays.asList(getProperties().getDisabledModules()));
  263. Children.SortedArray moduleCh = new Children.SortedArray();
  264. try {
  265. ModuleList ml = ModuleList.scanCluster(ci.getClusterDir(), null, false, ci);
  266. moduleCh.setComparator(MODULES_COMPARATOR);
  267. for (ModuleEntry entry : ml.getAllEntries()) {
  268. moduleCh.add(new Node[] { new BinaryModuleNode(entry,
  269. ! disabledModuleCNB.contains(entry.getCodeNameBase()) && ci.isEnabled()) });
  270. extraBinaryModules.add(entry);
  271. }
  272. } catch (IOException e) {
  273. ErrorManager.getDefault().notify(ErrorManager.WARNING, e);
  274. }
  275. initNodes();
  276. synchronized (libChildren.extraNodes) {
  277. libChildren.extraNodes.add(new ClusterNode(ci, moduleCh));
  278. }
  279. libChildren.setMergedKeys();
  280. }
  281. private ClusterNode createSuiteNode(ClusterInfo ci) {
  282. assert ci.getProject() != null;
  283. assert ci.getProject().getLookup().lookup(SuiteProvider.class) != null;
  284. Set<String> disabledModuleCNB = new HashSet<String>(Arrays.asList(getProperties().getDisabledModules()));
  285. Children.SortedArray moduleCh = new Children.SortedArray();
  286. moduleCh.setComparator(MODULES_COMPARATOR);
  287. Set<NbModuleProject> modules = SuiteUtils.getSubProjects(ci.getProject());
  288. for (NbModuleProject modPrj : modules) {
  289. if (modPrj.getModuleType() != NbModuleType.SUITE_COMPONENT) {
  290. continue;
  291. }
  292. moduleCh.add(new Node[] { new SuiteComponentNode(modPrj,
  293. ! disabledModuleCNB.contains(modPrj.getCodeNameBase()) && ci.isEnabled()) });
  294. }
  295. return new ClusterNode(ci, moduleCh);
  296. }
  297. private final class WaitNode extends AbstractNode {
  298. public WaitNode() {
  299. super(Children.LEAF);
  300. setDisplayName(UIUtil.WAIT_VALUE);
  301. setIconBaseWithExtension(WAIT_ICON_PATH);
  302. }
  303. }
  304. private void initNodes() {
  305. if (libChildren == null) {
  306. libChildren = new LibrariesChildren();
  307. realRoot = new AbstractNode(libChildren);
  308. realRoot.setName(getMessage("LBL_ModuleListClusters"));
  309. realRoot.setDisplayName(getMessage("LBL_ModuleListClustersModules"));
  310. }
  311. }
  312. private void refreshModules() {
  313. NbPlatform plaf = getProperties().getActivePlatform();
  314. if (plaf == null) {
  315. return;
  316. }
  317. // create platform modules children first
  318. platformModules = plaf.getSortedModules();
  319. initNodes();
  320. Set<String> disabledModuleCNB = new HashSet<String>(Arrays.asList(getProperties().getDisabledModules()));
  321. Set<String> enabledClusters = new HashSet<String>(Arrays.asList(getProperties().getEnabledClusters()));
  322. Map<File, ClusterNode> clusterToNode = new HashMap<File, ClusterNode>();
  323. synchronized (libChildren.platformNodes) {
  324. libChildren.platformNodes.clear();
  325. }
  326. boolean newPlaf = ((NbPlatform) platformValue.getSelectedItem()).getHarnessVersion().compareTo(HarnessVersion.V67) >= 0;
  327. for (ModuleEntry platformModule : platformModules) {
  328. File clusterDirectory = platformModule.getClusterDirectory();
  329. ClusterNode cluster = clusterToNode.get(clusterDirectory);
  330. if (cluster == null) {
  331. Children.SortedArray modules = new Children.SortedArray();
  332. modules.setComparator(MODULES_COMPARATOR);
  333. // enablement for pre-6.7 modules, for cluster path it gets resolved in load cluster.path section below
  334. boolean enabled = (newPlaf && enabledClusters.isEmpty()) || SingleModuleProperties.clusterMatch(enabledClusters, clusterDirectory.getName());
  335. ClusterInfo ci = ClusterInfo.create(clusterDirectory, true, enabled);
  336. cluster = new ClusterNode(ci, modules);
  337. clusterToNode.put(clusterDirectory, cluster);
  338. synchronized (libChildren.platformNodes) {
  339. libChildren.platformNodes.add(cluster);
  340. }
  341. }
  342. AbstractNode module = new BinaryModuleNode(platformModule,
  343. ! disabledModuleCNB.contains(platformModule.getCodeNameBase()) && cluster.isEnabled());
  344. cluster.getChildren().add(new Node[] { module });
  345. }
  346. // next, load cluster.path
  347. // XXX support "universal" "${nbplatform.active.dir}/*" entry in the cluster.path?
  348. // meaning "all platform clusters", recognized in harness and in UI;
  349. // it would allow easy switch among platforms with different clusters; probably not needed
  350. // update also code of SuiteProjectGenerator#createPlatformProperties
  351. Set<ClusterInfo> clusterPath = getProperties().getClusterPath();
  352. if (clusterPath.size() > 0) {
  353. // cluster.path exists, we enable/disabled platform nodes according to
  354. // cluster.path, not enabled.clusterPath & disabled.clusterPath
  355. for (ClusterNode node : libChildren.platformNodes()) {
  356. if (!clusterPath.contains(node.getClusterInfo())) // must not call setEnabled(true), disabled modules would be enabled
  357. {
  358. node.setEnabled(false);
  359. }
  360. }
  361. if (!extClustersLoaded) {
  362. for (ClusterInfo ci : clusterPath) {
  363. if (!ci.isPlatformCluster()) {
  364. if (ci.getProject() != null) {
  365. addProjectCluster(ci, false);
  366. } else {
  367. addExtCluster(ci);
  368. }
  369. }
  370. }
  371. extClustersLoaded = true;
  372. }
  373. } else {
  374. extClustersLoaded = true; // so that doUpdateDependencyWarnings is called even with empty cluster.path
  375. }
  376. libChildren.setMergedKeys();
  377. }
  378. private void refreshJavaPlatforms() {
  379. javaPlatformCombo.setModel(JavaPlatformComponentFactory.javaPlatformListModel());
  380. javaPlatformCombo.setSelectedItem(getProperties().getActiveJavaPlatform());
  381. }
  382. private void refreshPlatforms() {
  383. Logger logger = Logger.getLogger(SuiteCustomizerLibraries.class.getName());
  384. NbPlatform plaf = getProperties().getActivePlatform();
  385. if (plaf == null) { // #186992
  386. return;
  387. }
  388. logger.log(Level.FINE, "refreshPlatforms --> {0}", plaf.getLabel());
  389. platformValue.setModel(new PlatformComponentFactory.NbPlatformListModel(plaf)); // refresh
  390. if (getProperties().getEvaluator().getProperty("nbplatform.active") != null) {
  391. platformValue.requestFocus();
  392. } else { // custom local platform, typical with #197038
  393. platform.setEnabled(false);
  394. platformValue.setEnabled(false);
  395. managePlafsButton.setEnabled(false);
  396. }
  397. }
  398. @Override
  399. public void store() {
  400. // TODO C.P: disable buttons/show button "Upgrade"??? on old harness
  401. Set<String> enabledClusters = new TreeSet<String>();
  402. Set<String> disabledModules = new TreeSet<String>();
  403. List<ClusterInfo> clusterPath = new ArrayList<ClusterInfo>();
  404. boolean oldPlaf = getProperties().getActivePlatform().getHarnessVersion().compareTo(HarnessVersion.V67) < 0;
  405. assert refreshTask != null;
  406. if (! refreshTask.isFinished()) {
  407. // trying to store before nodes are up-to-date, just bail out
  408. return;
  409. }
  410. for (ClusterNode e : libChildren.platformNodes()) {
  411. if (e.isEnabled()) {
  412. if (oldPlaf)
  413. enabledClusters.add(e.getName());
  414. else
  415. clusterPath.add(e.getClusterInfo());
  416. for (Node module : e.getChildren().getNodes()) {
  417. Enabled m = (Enabled) module;
  418. // don't add modules in disabled cluster to disabledModules
  419. if (! m.isEnabled()) {
  420. disabledModules.add(m.getName());
  421. }
  422. }
  423. }
  424. }
  425. if (oldPlaf) {
  426. getProperties().setEnabledClusters(enabledClusters.toArray(new String[enabledClusters.size()]));
  427. } else {
  428. for (ClusterNode e : libChildren.extraNodes()) {
  429. clusterPath.add(e.getClusterInfo());
  430. if (e.isEnabled()) {
  431. for (Node module : e.getChildren().getNodes()) {
  432. Enabled m = (Enabled) module;
  433. // don't add modules in disabled cluster to disabledModules
  434. if (! m.isEnabled()) {
  435. disabledModules.add(m.getName());
  436. }
  437. }
  438. }
  439. }
  440. getProperties().setClusterPath(clusterPath);
  441. }
  442. getProperties().setDisabledModules(disabledModules.toArray(new String[disabledModules.size()]));
  443. }
  444. /** This method is called from within the constructor to
  445. * initialize the form.
  446. * WARNING: Do NOT modify this code. The content of this method is
  447. * always regenerated by the Form Editor.
  448. */
  449. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  450. private void initComponents() {
  451. javaPlatformLabel = new javax.swing.JLabel();
  452. javaPlatformCombo = new javax.swing.JComboBox();
  453. javaPlatformButton = new javax.swing.JButton();
  454. platform = new javax.swing.JLabel();
  455. platformValue = org.netbeans.modules.apisupport.project.ui.platform.PlatformComponentFactory.getNbPlatformsComboxBox();
  456. managePlafsButton = new javax.swing.JButton();
  457. viewLabel = new javax.swing.JLabel();
  458. view = new org.openide.explorer.view.OutlineView();
  459. resolveButton = new javax.swing.JButton();
  460. addProjectButton = new javax.swing.JButton();
  461. addClusterButton = new javax.swing.JButton();
  462. removeButton = new javax.swing.JButton();
  463. editButton = new javax.swing.JButton();
  464. javaPlatformLabel.setLabelFor(javaPlatformCombo);
  465. org.openide.awt.Mnemonics.setLocalizedText(javaPlatformLabel, NbBundle.getMessage(SuiteCustomizerLibraries.class, "LBL_Java_Platform")); // NOI18N
  466. javaPlatformCombo.addItemListener(new java.awt.event.ItemListener() {
  467. public void itemStateChanged(java.awt.event.ItemEvent evt) {
  468. javaPlatformComboItemStateChanged(evt);
  469. }
  470. });
  471. org.openide.awt.Mnemonics.setLocalizedText(javaPlatformButton, NbBundle.getMessage(SuiteCustomizerLibraries.class, "LBL_Manage_Java_Platforms")); // NOI18N
  472. javaPlatformButton.addActionListener(new java.awt.event.ActionListener() {
  473. public void actionPerformed(java.awt.event.ActionEvent evt) {
  474. javaPlatformButtonActionPerformed(evt);
  475. }
  476. });
  477. platform.setLabelFor(platformValue);
  478. org.openide.awt.Mnemonics.setLocalizedText(platform, org.openide.util.NbBundle.getMessage(SuiteCustomizerLibraries.class, "LBL_NetBeansPlatform")); // NOI18N
  479. platformValue.addItemListener(new java.awt.event.ItemListener() {
  480. public void itemStateChanged(java.awt.event.ItemEvent evt) {
  481. platformValueItemStateChanged(evt);
  482. }
  483. });
  484. org.openide.awt.Mnemonics.setLocalizedText(managePlafsButton, org.openide.util.NbBundle.getMessage(SuiteCustomizerLibraries.class, "CTL_ManagePlatform_a")); // NOI18N
  485. managePlafsButton.addActionListener(new java.awt.event.ActionListener() {
  486. public void actionPerformed(java.awt.event.ActionEvent evt) {
  487. managePlatforms(evt);
  488. }
  489. });
  490. viewLabel.setLabelFor(view);
  491. org.openide.awt.Mnemonics.setLocalizedText(viewLabel, org.openide.util.NbBundle.getMessage(SuiteCustomizerLibraries.class, "LBL_PlatformModules")); // NOI18N
  492. view.setBorder(javax.swing.UIManager.getBorder("ScrollPane.border"));
  493. resolveButton.setForeground(java.awt.Color.red);
  494. org.openide.awt.Mnemonics.setLocalizedText(resolveButton, org.openide.util.NbBundle.getMessage(SuiteCustomizerLibraries.class, "LBL_ResolveButton")); // NOI18N
  495. resolveButton.setToolTipText(org.openide.util.NbBundle.getMessage(SuiteCustomizerLibraries.class, "LBL_ResolveButtonTooltip")); // NOI18N
  496. resolveButton.addActionListener(new java.awt.event.ActionListener() {
  497. public void actionPerformed(java.awt.event.ActionEvent evt) {
  498. resolveButtonActionPerformed(evt);
  499. }
  500. });
  501. org.openide.awt.Mnemonics.setLocalizedText(addProjectButton, org.openide.util.NbBundle.getMessage(SuiteCustomizerLibraries.class, "LBL_AddProject")); // NOI18N
  502. addProjectButton.addActionListener(new java.awt.event.ActionListener() {
  503. public void actionPerformed(java.awt.event.ActionEvent evt) {
  504. addProjectButtonActionPerformed(evt);
  505. }
  506. });
  507. org.openide.awt.Mnemonics.setLocalizedText(addClusterButton, org.openide.util.NbBundle.getMessage(SuiteCustomizerLibraries.class, "LBL_AddCluster")); // NOI18N
  508. addClusterButton.addActionListener(new java.awt.event.ActionListener() {
  509. public void actionPerformed(java.awt.event.ActionEvent evt) {
  510. addClusterButtonActionPerformed(evt);
  511. }
  512. });
  513. org.openide.awt.Mnemonics.setLocalizedText(removeButton, org.openide.util.NbBundle.getMessage(SuiteCustomizerLibraries.class, "CTL_RemoveButton")); // NOI18N
  514. removeButton.addActionListener(new java.awt.event.ActionListener() {
  515. public void actionPerformed(java.awt.event.ActionEvent evt) {
  516. removeButtonActionPerformed(evt);
  517. }
  518. });
  519. org.openide.awt.Mnemonics.setLocalizedText(editButton, org.openide.util.NbBundle.getMessage(SuiteCustomizerLibraries.class, "CTL_EditButton")); // NOI18N
  520. editButton.addActionListener(new java.awt.event.ActionListener() {
  521. public void actionPerformed(java.awt.event.ActionEvent evt) {
  522. editButtonActionPerformed(evt);
  523. }
  524. });
  525. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
  526. this.setLayout(layout);
  527. layout.setHorizontalGroup(
  528. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  529. .addGroup(layout.createSequentialGroup()
  530. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  531. .addComponent(javaPlatformLabel)
  532. .addComponent(platform))
  533. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  534. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  535. .addComponent(javaPlatformCombo, javax.swing.GroupLayout.Alignment.TRAILING, 0, 259, Short.MAX_VALUE)
  536. .addComponent(platformValue, javax.swing.GroupLayout.Alignment.TRAILING, 0, 259, Short.MAX_VALUE))
  537. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  538. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  539. .addComponent(managePlafsButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  540. .addComponent(javaPlatformButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
  541. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  542. .addContainerGap(82, Short.MAX_VALUE)
  543. .addComponent(resolveButton)
  544. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  545. .addComponent(addProjectButton)
  546. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  547. .addComponent(addClusterButton)
  548. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  549. .addComponent(removeButton, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
  550. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  551. .addComponent(editButton))
  552. .addGroup(layout.createSequentialGroup()
  553. .addComponent(viewLabel)
  554. .addContainerGap())
  555. .addComponent(view, javax.swing.GroupLayout.DEFAULT_SIZE, 632, Short.MAX_VALUE)
  556. );
  557. layout.setVerticalGroup(
  558. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  559. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  560. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  561. .addComponent(javaPlatformLabel)
  562. .addComponent(javaPlatformCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  563. .addComponent(javaPlatformButton))
  564. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  565. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  566. .addComponent(platform)
  567. .addComponent(platformValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  568. .addComponent(managePlafsButton))
  569. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  570. .addComponent(viewLabel)
  571. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  572. .addComponent(view, javax.swing.GroupLayout.DEFAULT_SIZE, 425, Short.MAX_VALUE)
  573. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  574. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  575. .addComponent(editButton)
  576. .addComponent(removeButton)
  577. .addComponent(addClusterButton)
  578. .addComponent(addProjectButton)
  579. .addComponent(resolveButton)))
  580. );
  581. javaPlatformLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SuiteCustomizerLibraries.class, "ACSD_JavaPlatformLbl")); // NOI18N
  582. javaPlatformCombo.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SuiteCustomizerLibraries.class, "ACSD_JavaPlatformCombo")); // NOI18N
  583. javaPlatformButton.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SuiteCustomizerLibraries.class, "ACSD_JavaPlatformButton")); // NOI18N
  584. platform.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SuiteCustomizerLibraries.class, "ACSD_PlatformLbl")); // NOI18N
  585. platformValue.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SuiteCustomizerLibraries.class, "ACSD_PlatformValue")); // NOI18N
  586. managePlafsButton.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SuiteCustomizerLibraries.class, "ACSD_ManagePlafsButton")); // NOI18N
  587. }// </editor-fold>//GEN-END:initComponents
  588. private void javaPlatformButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaPlatformButtonActionPerformed
  589. PlatformsCustomizer.showCustomizer((JavaPlatform) javaPlatformCombo.getSelectedItem());
  590. }//GEN-LAST:event_javaPlatformButtonActionPerformed
  591. private void javaPlatformComboItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_javaPlatformComboItemStateChanged
  592. getProperties().setActiveJavaPlatform((JavaPlatform) javaPlatformCombo.getSelectedItem());
  593. }//GEN-LAST:event_javaPlatformComboItemStateChanged
  594. private void platformValueItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_platformValueItemStateChanged
  595. if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
  596. manager.setRootContext(waitRoot);
  597. store(); // restore the same enablement of clusters for new platform
  598. Logger logger = Logger.getLogger(SuiteCustomizerLibraries.class.getName());
  599. logger.log(Level.FINE, "platformValueItemStateChanged, setting plaf -->" + ((NbPlatform) platformValue.getSelectedItem()).getLabel());
  600. getProperties().setActivePlatform((NbPlatform) platformValue.getSelectedItem());
  601. updateJavaPlatformEnabled();
  602. }
  603. }//GEN-LAST:event_platformValueItemStateChanged
  604. private void managePlatforms(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_managePlatforms
  605. NbPlatformCustomizer.showCustomizer();
  606. refreshPlatforms();
  607. }//GEN-LAST:event_managePlatforms
  608. private void addProjectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addProjectButtonActionPerformed
  609. Project project = ApisupportAntUIUtils.chooseProject(this);
  610. if (project != null) {
  611. ClusterInfo.QueryResult res = ClusterInfo.canCreate(project);
  612. String bundleKey = null;
  613. switch (res) {
  614. case NOT_A_NBM_PROJECT:
  615. bundleKey = "MSG_TryingToAddNonNBModuleOnClusterPath"; // NOI18N
  616. break;
  617. case NBORG_PROJECT_NOT_ALLOWED:
  618. bundleKey = "MSG_TryingToAddNBORGModuleOnClusterPath"; // NOI18N
  619. break;
  620. case SUITE_COMP_NOT_ALLOWED:
  621. SuiteProvider sprv = project.getLookup().lookup(SuiteProvider.class);
  622. FileObject otherSuiteDir = FileUtil.toFileObject(sprv.getSuiteDirectory());
  623. NotifyDescriptor.Confirmation confirmation = new NotifyDescriptor.Confirmation(NbBundle.getMessage(SuiteCustomizerLibraries.class, "MSG_AddSuiteInstead", ProjectUtils.getInformation(project).getDisplayName(), ApisupportAntUtils.getDisplayName(otherSuiteDir)), NotifyDescriptor.YES_NO_OPTION);
  624. DialogDisplayer.getDefault().notify(confirmation);
  625. if (confirmation.getValue() == NotifyDescriptor.YES_OPTION) {
  626. try {
  627. project = ProjectManager.getDefault().findProject(otherSuiteDir);
  628. assert ClusterInfo.canCreate(project) == ClusterInfo.QueryResult.OK;
  629. } catch (IOException e) {
  630. ErrorManager.getDefault().notify(ErrorManager.WARNING, e);
  631. }
  632. } else {
  633. return;
  634. }
  635. // fall through to add suite instead
  636. }
  637. if (bundleKey != null) {
  638. DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(NbBundle.getMessage(
  639. SuiteCustomizerLibraries.class, bundleKey, ProjectUtils.getInformation(project).getDisplayName())));
  640. } else {
  641. addProjectCluster(ClusterInfo.create(project, true), true);
  642. }
  643. }
  644. }//GEN-LAST:event_addProjectButtonActionPerformed
  645. private void addClusterButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addClusterButtonActionPerformed
  646. ClusterInfo ci = EditClusterPanel.showAddDialog(getProperties().getProject());
  647. if (ci != null) {
  648. if (libChildren.findCluster(ci.getClusterDir()) != null) {
  649. DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
  650. NbBundle.getMessage(SuiteCustomizerLibraries.class, "MSG_ClusterAlreadyOnClusterPath",
  651. ci.getClusterDir())));
  652. return;
  653. }
  654. addExtCluster(ci);
  655. }
  656. }//GEN-LAST:event_addClusterButtonActionPerformed
  657. private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed
  658. libChildren.removeClusters(manager.getSelectedNodes());
  659. }//GEN-LAST:event_removeButtonActionPerformed
  660. private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButtonActionPerformed
  661. Node[] nodes = manager.getSelectedNodes();
  662. assert nodes.length == 1;
  663. ClusterNode node = (ClusterNode) nodes[0];
  664. assert isExternalCluster(node);
  665. ClusterInfo ci = EditClusterPanel.showEditDialog(node.getClusterInfo(), getProperties().getProject());
  666. if (ci != null)
  667. node.setClusterInfo(ci);
  668. }//GEN-LAST:event_editButtonActionPerformed
  669. private void resolveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resolveButtonActionPerformed
  670. if (resolveFixInfo == null || ! resolveFixInfo.fixable)
  671. return;
  672. for (Node node : libChildren.getNodes()) {
  673. ClusterNode cn = (ClusterNode) node;
  674. for (Node modNode : cn.getChildren().getNodes()) {
  675. String cnb = modNode.getName();
  676. if (resolveFixInfo.toAdd.contains(cnb)) {
  677. Enabled en = (Enabled) modNode;
  678. en.setState(EnabledState.FULL_ENABLED, false); // update cluster states only once
  679. }
  680. }
  681. // standalone module cluster
  682. if (cn.getProject() != null) {
  683. NbModuleProvider nbmp = cn.getProject().getLookup().lookup(NbModuleProvider.class);
  684. if (nbmp != null
  685. && resolveFixInfo.toAdd.contains(nbmp.getCodeNameBase())) {
  686. NbModuleProject prj = cn.getProject().getLookup().lookup(NbModuleProject.class);
  687. if (prj == null || prj.getModuleType() == NbModuleType.STANDALONE) {
  688. assert ! cn.isEnabled();
  689. ((Enabled) cn).setState(EnabledState.FULL_ENABLED, false); // update cluster states only once
  690. }
  691. }
  692. }
  693. }
  694. libChildren.setMergedKeys(); // update cluster states
  695. resolveButton.setEnabled(false);
  696. updateDependencyWarnings(false);
  697. }//GEN-LAST:event_resolveButtonActionPerformed
  698. // Variables declaration - do not modify//GEN-BEGIN:variables
  699. private javax.swing.JButton addClusterButton;
  700. private javax.swing.JButton addProjectButton;
  701. private javax.swing.JButton editButton;
  702. private javax.swing.JButton javaPlatformButton;
  703. private javax.swing.JComboBox javaPlatformCombo;
  704. private javax.swing.JLabel javaPlatformLabel;
  705. private javax.swing.JButton managePlafsButton;
  706. private javax.swing.JLabel platform;
  707. private javax.swing.JComboBox platformValue;
  708. private javax.swing.JButton removeButton;
  709. private javax.swing.JButton resolveButton;
  710. private org.openide.explorer.view.OutlineView view;
  711. private javax.swing.JLabel viewLabel;
  712. // End of variables declaration//GEN-END:variables
  713. private static final Comparator<Node> MODULES_COMPARATOR = new Comparator<Node>() {
  714. Collator COLL = Collator.getInstance();
  715. public int compare(Node n1, Node n2) {
  716. return COLL.compare(n1.getDisplayName(), n2.getDisplayName());
  717. }
  718. };
  719. public ExplorerManager getExplorerManager() {
  720. return manager;
  721. }
  722. public static final Set<String> DISABLED_PLATFORM_MODULES = new TreeSet<String>();
  723. static {
  724. // Probably not needed for most platform apps, and won't even work under JNLP.
  725. DISABLED_PLATFORM_MODULES.add("org.netbeans.modules.autoupdate.services"); // NOI18N
  726. DISABLED_PLATFORM_MODULES.add("org.netbeans.modules.autoupdate.ui"); // NOI18N
  727. DISABLED_PLATFORM_MODULES.add("org.netbeans.modules.autoupdate.cli"); // NOI18N
  728. // XXX the following would not be shown in regular apps anyway, because they are autoloads,
  729. // but they *are* shown in JNLP apps because currently even unused autoloads are enabled under JNLP:
  730. // Just annoying; e.g. shows Runtime tab prominently.
  731. DISABLED_PLATFORM_MODULES.add("org.openide.execution"); // NOI18N
  732. DISABLED_PLATFORM_MODULES.add("org.netbeans.core.execution"); // NOI18N
  733. // Similar - unlikely to really be wanted by typical platform apps, and show some GUI.
  734. /* XXX #107870: currently org.netbeans.core.actions.LogAction needs OW:
  735. DISABLED_PLATFORM_MODULES.add("org.openide.io"); // NOI18N
  736. DISABLED_PLATFORM_MODULES.add("org.netbeans.core.output2"); // NOI18N
  737. */
  738. // this one is useful only for writers of apps showing local disk
  739. DISABLED_PLATFORM_MODULES.add("org.netbeans.modules.favorites"); // NOI18N
  740. // And these are deprecated:
  741. DISABLED_PLATFORM_MODULES.add("org.openide.compat"); // NOI18N
  742. DISABLED_PLATFORM_MODULES.add("org.openide.util.enumerations"); // NOI18N
  743. // See issue #112931
  744. DISABLED_PLATFORM_MODULES.add("org.netbeans.modules.core.kit"); // NOI18N
  745. // #110085: some more unwanted ones...
  746. DISABLED_PLATFORM_MODULES.add("org.netbeans.modules.templates"); // NOI18N
  747. DISABLED_PLATFORM_MODULES.add("org.netbeans.libs.jsr223"); // NOI18N
  748. DISABLED_PLATFORM_MODULES.add("org.jdesktop.layout"); // NOI18N
  749. DISABLED_PLATFORM_MODULES.add("org.openide.options"); // NOI18N
  750. DISABLED_PLATFORM_MODULES.add("org.netbeans.api.visual"); // NOI18N
  751. }
  752. public void stateChanged(ChangeEvent ev) {
  753. if (getProperties().getBrandingModel().isBrandingEnabled()) {
  754. // User is turning on branded mode. Let's take a guess: they want to
  755. // exclude the usual suspects from the module list. We do not want to set
  756. // these excludes on a new suite because user might want to use real IDE as the platform
  757. // (i.e. not be creating an app, but rather be creating some modules for the IDE).
  758. // Only do this if there are no existing exclusions.
  759. Node[] clusters = getExplorerManager().getRootContext().getChildren().getNodes();
  760. for (Node cluster : clusters) {
  761. if (cluster instanceof Enabled) {
  762. Enabled e = (Enabled) cluster;
  763. if (!e.isEnabled()) {
  764. return;
  765. } else {
  766. for (Node module : e.getChildren().getNodes()) {
  767. if (module instanceof Enabled) {
  768. Enabled m = (Enabled) module;
  769. if (!m.isEnabled()) {
  770. return;
  771. }
  772. }
  773. }
  774. }
  775. }
  776. }
  777. // #64443: prompt first.
  778. if (!ApisupportAntUIUtils.showAcceptCancelDialog(
  779. getMessage("SuiteCustomizerLibraries.title.exclude_ide_modules"),
  780. getMessage("SuiteCustomizerLibraries.text.exclude_ide_modules"),
  781. getMessage("SuiteCustomizerLibraries.button.exclude"),
  782. getMessage("SuiteCustomizerLibraries.button.skip"),
  783. NotifyDescriptor.QUESTION_MESSAGE)) {
  784. return;
  785. }
  786. // OK, continue.
  787. for (Node cluster : clusters) {
  788. if (cluster instanceof Enabled) {
  789. Enabled e = (Enabled) cluster;
  790. if (e.getName().startsWith("platform")) { // NOI18N
  791. for (Node module : e.getChildren().getNodes()) {
  792. if (module instanceof Enabled) {
  793. Enabled m = (Enabled) module;
  794. if (DISABLED_PLATFORM_MODULES.contains(m.getName())) {
  795. m.setEnabled(false);
  796. }
  797. }
  798. }
  799. } else {
  800. e.setEnabled(false);
  801. }
  802. }
  803. }
  804. }
  805. }
  806. // #70724: internally, cluster nodes have 3 states now
  807. private enum EnabledState {
  808. // module / all modules in cluster selected
  809. FULL_ENABLED,
  810. // only for libChildren - some but not all modules are enabled
  811. PART_ENABLED,
  812. // module / whole cluster disabled
  813. DISABLED
  814. }
  815. private static final SystemAction[] NO_ACTIONS = new SystemAction[0];
  816. abstract class Enabled extends AbstractNode {
  817. private EnabledState state;
  818. Enabled(Children ch, boolean enabled) {
  819. super(ch);
  820. setState(enabled ? EnabledState.FULL_ENABLED : EnabledState.DISABLED, false);
  821. Sheet s = Sheet.createDefault();
  822. Sheet.Set ss = s.get(Sheet.PROPERTIES);
  823. ss.put(new EnabledProp(this));
  824. ss.put(new OriginProp(this));
  825. setSheet(s);
  826. setIconBaseWithExtension(
  827. isLeaf() ? NbModuleProject.NB_PROJECT_ICON_PATH : SuiteProject.SUITE_ICON_PATH);
  828. }
  829. public @Override String getHtmlDisplayName() {
  830. if (isDeprecated()) {
  831. try {
  832. return "<html><s>" + XMLUtil.toElementContent(getDisplayName()) + "</s>"; // NOI18N
  833. } catch (CharConversionException ex) {}
  834. }
  835. return null;
  836. }
  837. @Override
  838. public Action getPreferredAction() {
  839. return null;
  840. }
  841. @Override
  842. public SystemAction[] getActions(boolean context) {
  843. return NO_ACTIONS;
  844. }
  845. public void setEnabled(boolean s) {
  846. setState(s ? EnabledState.FULL_ENABLED : EnabledState.DISABLED, true);
  847. }
  848. public boolean isEnabled() {
  849. return state != EnabledState.DISABLED;
  850. }
  851. public EnabledState getState() {
  852. return state;
  853. }
  854. public abstract boolean isPlatformNode();
  855. public abstract String getOrigin();
  856. protected void setState(EnabledState s, boolean propagate) {
  857. if (s == state) {
  858. return;
  859. }
  860. state = s;
  861. Logger logger = Logger.getLogger(EnabledProp.class.getName());
  862. logger.log(Level.FINE, "Node '" + getName() + "', state="
  863. + (s==EnabledState.DISABLED ? "disabled" :
  864. (s==EnabledState.FULL_ENABLED ? "full enabled" : "part enabled")));
  865. if (propagate) {
  866. //refresh children
  867. EnabledState newChildState =
  868. (s == EnabledState.PART_ENABLED) ? null : s;
  869. // XXX for (Node nn : standard.getNodes()) {
  870. for (Node nn : getChildren().getNodes()) {
  871. if (nn instanceof Enabled) {
  872. Enabled en = (Enabled) nn;
  873. // #70724: checking/unchecking cluster node checks/unchecks all children
  874. if (newChildState != null) {
  875. en.setState(newChildState, false);
  876. }
  877. en.firePropertyChange(null, null, null);
  878. }
  879. }
  880. //refresh parent
  881. Node n = getParentNode();
  882. if (n instanceof Enabled) {
  883. assert s != EnabledState.PART_ENABLED : "Module node should not be passed ENABLED_PARTIALLY state";
  884. Enabled par = (Enabled) n;
  885. par.updateClusterState();
  886. par.firePropertyChange(null, null, null);
  887. }
  888. updateDependencyWarnings(false);
  889. }
  890. }
  891. void updateClusterState() {
  892. if (getChildren() == Children.LEAF)
  893. return;
  894. boolean allEnabled = true;
  895. boolean allDisabled = true;
  896. for (Node nn : getChildren().getNodes()) {
  897. if (nn instanceof Enabled) {
  898. Enabled ch = (Enabled) nn;
  899. allEnabled &= ch.isEnabled();
  900. allDisabled &= !ch.isEnabled();
  901. if (!allEnabled && !allDisabled) {
  902. break;
  903. }
  904. }
  905. }
  906. if (allEnabled) {
  907. setState(EnabledState.FULL_ENABLED, false);
  908. } else if (allDisabled) {
  909. setState(EnabledState.DISABLED, false);
  910. } else {
  911. setState(EnabledState.PART_ENABLED, false);
  912. }
  913. }
  914. /**
  915. * @return the project if any is associated
  916. */
  917. public abstract Project getProject();
  918. protected abstract boolean isDeprecated();
  919. }
  920. final class SuiteComponentNode extends Enabled {
  921. private final NbModuleProject project;
  922. public SuiteComponentNode(NbModuleProject prj, boolean enabled) {
  923. super(Children.LEAF, enabled);
  924. this.project = prj;
  925. final String cnb = prj.getCodeNameBase();
  926. setName(cnb);
  927. setDisplayName(ProjectUtils.getInformation(prj).getDisplayName());
  928. Provider provider = prj.getLookup().lookup(LocalizedBundleInfo.Provider.class);
  929. if (provider != null) {
  930. LocalizedBundleInfo bundleInfo = provider.getLocalizedBundleInfo();
  931. if (bundleInfo != null) {
  932. setShortDescription(formatEntryDesc(cnb, bundleInfo.getShortDescription()));
  933. }
  934. }
  935. }
  936. public boolean isDeprecated() {
  937. return ManifestManager.getInstance(Util.getManifest(project.getManifestFile()), false).isDeprecated();
  938. }
  939. @Override
  940. public boolean isPlatformNode() {