PageRenderTime 40ms CodeModel.GetById 11ms RepoModel.GetById 1ms app.codeStats 0ms

/projects/netbeans-7.3/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/OperationDescriptionStep.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus
Java | 576 lines | 493 code | 20 blank | 63 comment | 136 complexity | 7f18c950d3e5697933a6b41cdfb13162 MD5 | raw file
  1. /*
  2. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  3. *
  4. * Copyright 1997-2012 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-2008 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.autoupdate.ui.wizards;
  45. import java.awt.Component;
  46. import java.text.Collator;
  47. import java.util.ArrayList;
  48. import java.util.Collections;
  49. import java.util.Comparator;
  50. import java.util.HashSet;
  51. import java.util.List;
  52. import java.util.Set;
  53. import java.util.SortedMap;
  54. import java.util.TreeMap;
  55. import java.util.TreeSet;
  56. import java.util.logging.Level;
  57. import java.util.logging.Logger;
  58. import javax.swing.JPanel;
  59. import javax.swing.SwingUtilities;
  60. import javax.swing.event.ChangeEvent;
  61. import javax.swing.event.ChangeListener;
  62. import org.netbeans.api.autoupdate.OperationException;
  63. import org.netbeans.api.autoupdate.UpdateElement;
  64. import org.netbeans.api.autoupdate.UpdateManager;
  65. import org.netbeans.api.autoupdate.UpdateUnit;
  66. import org.netbeans.modules.autoupdate.ui.Containers;
  67. import org.netbeans.modules.autoupdate.ui.actions.AutoupdateCheckScheduler;
  68. import org.netbeans.modules.autoupdate.ui.actions.Installer;
  69. import org.netbeans.modules.autoupdate.ui.wizards.LazyInstallUnitWizardIterator.LazyUnit;
  70. import org.netbeans.modules.autoupdate.ui.wizards.OperationWizardModel.OperationType;
  71. import org.openide.WizardDescriptor;
  72. import org.openide.modules.Dependency;
  73. import org.openide.modules.SpecificationVersion;
  74. import org.openide.util.HelpCtx;
  75. import org.openide.util.NbBundle;
  76. import org.openide.util.RequestProcessor;
  77. /**
  78. *
  79. * @author Jiri Rechtacek
  80. */
  81. public class OperationDescriptionStep implements WizardDescriptor.Panel<WizardDescriptor> {
  82. private static final String HEAD = "OperationDescriptionStep_Header_Head";
  83. private static final String CONTENT = "OperationDescriptionStep_Header_Content";
  84. private static final String TABLE_TITLE_INSTALL = "OperationDescriptionStep_TableInstall_Title";
  85. private static final String TABLE_TITLE_UPDATE = "OperationDescriptionStep_TableUpdate_Title";
  86. private static final String HEAD_UNINSTALL = "OperationDescriptionStep_HeaderUninstall_Head";
  87. private static final String CONTENT_UNINSTALL = "OperationDescriptionStep_HeaderUninstall_Content";
  88. private static final String TABLE_TITLE_UNINSTALL = "OperationDescriptionStep_TableUninstall_Title";
  89. private static final String HEAD_ACTIVATE = "OperationDescriptionStep_HeaderActivate_Head";
  90. private static final String CONTENT_ACTIVATE = "OperationDescriptionStep_HeaderActivate_Content";
  91. private static final String TABLE_TITLE_ACTIVATE = "OperationDescriptionStepActivate_Table_Title";
  92. private static final String HEAD_DEACTIVATE = "OperationDescriptionStep_HeaderDeativate_Head";
  93. private static final String CONTENT_DEACTIVATE = "OperationDescriptionStep_HeaderDeativate_Content";
  94. private static final String TABLE_TITLE_DEACTIVATE = "OperationDescriptionStep_TableDeativate_Title";
  95. private static final String DEPENDENCIES_TITLE_INSTALL = "DependenciesResolutionStep_Table_Title";
  96. private static final String DEPENDENCIES_TITLE_UPDATE = "DependenciesResolutionStep_Table_Title";
  97. private static final String DEPENDENCIES_TITLE_UNINSTALL = "UninstallDependenciesResolutionStep_Table_Title";
  98. private static final String DEPENDENCIES_TITLE_ACTIVATE = "OperationDescriptionStep_TableInstall_Title";
  99. private static final String DEPENDENCIES_TITLE_DEACTIVATE = "UninstallDependenciesResolutionStep_Table_Title";
  100. private PanelBodyContainer component;
  101. private OperationWizardModel model = null;
  102. private boolean readyToGo = false;
  103. private final List<ChangeListener> listeners = new ArrayList<ChangeListener> ();
  104. private RequestProcessor.Task lazyDependingTask = null;
  105. /** Creates a new instance of OperationDescriptionStep */
  106. public OperationDescriptionStep (OperationWizardModel model) {
  107. this.model = model;
  108. }
  109. @Override
  110. public Component getComponent() {
  111. if (component == null) {
  112. readyToGo = false;
  113. JPanel body;
  114. String tableTitle = null;
  115. String dependenciesTitle = null;
  116. String head = null;
  117. String content = null;
  118. switch (model.getOperation ()) {
  119. case LOCAL_DOWNLOAD :
  120. if (Containers.forUpdateNbms ().listAll ().isEmpty ()) {
  121. tableTitle = getBundle (TABLE_TITLE_INSTALL);
  122. dependenciesTitle = getBundle (DEPENDENCIES_TITLE_INSTALL);
  123. } else {
  124. tableTitle = getBundle (TABLE_TITLE_UPDATE);
  125. dependenciesTitle = getBundle (DEPENDENCIES_TITLE_UPDATE);
  126. }
  127. head = getBundle (HEAD);
  128. content = getBundle (CONTENT);
  129. break;
  130. case INSTALL :
  131. tableTitle = getBundle (TABLE_TITLE_INSTALL);
  132. dependenciesTitle = getBundle (DEPENDENCIES_TITLE_INSTALL);
  133. head = getBundle (HEAD);
  134. content = getBundle (CONTENT);
  135. break;
  136. case UPDATE :
  137. tableTitle = getBundle (TABLE_TITLE_UPDATE);
  138. dependenciesTitle = getBundle (DEPENDENCIES_TITLE_UPDATE);
  139. head = getBundle (HEAD);
  140. content = getBundle (CONTENT);
  141. break;
  142. case UNINSTALL :
  143. tableTitle = getBundle (TABLE_TITLE_UNINSTALL);
  144. dependenciesTitle = getBundle (DEPENDENCIES_TITLE_UNINSTALL);
  145. head = getBundle (HEAD_UNINSTALL);
  146. content = getBundle (CONTENT_UNINSTALL);
  147. break;
  148. case ENABLE :
  149. tableTitle = getBundle (TABLE_TITLE_ACTIVATE);
  150. dependenciesTitle = getBundle (DEPENDENCIES_TITLE_ACTIVATE);
  151. head = getBundle (HEAD_ACTIVATE);
  152. content = getBundle (CONTENT_ACTIVATE);
  153. break;
  154. case DISABLE :
  155. tableTitle = getBundle (TABLE_TITLE_DEACTIVATE);
  156. dependenciesTitle = getBundle (DEPENDENCIES_TITLE_DEACTIVATE);
  157. head = getBundle (HEAD_DEACTIVATE);
  158. content = getBundle (CONTENT_DEACTIVATE);
  159. break;
  160. }
  161. body = new OperationDescriptionPanel (tableTitle,
  162. preparePluginsForShow (
  163. model.getPrimaryUpdateElements(),
  164. model.getPrimaryVisibleUpdateElements(),
  165. model.getCustomHandledComponents (),
  166. model.getOperation ()),
  167. "",
  168. "",
  169. true);
  170. component = new PanelBodyContainer (head, content, body);
  171. component.setPreferredSize (OperationWizardModel.PREFFERED_DIMENSION);
  172. component.setWaitingState (true);
  173. appendDependingLazy (tableTitle, dependenciesTitle);
  174. }
  175. return component;
  176. }
  177. private void appendDependingLazy (final String tableTitle, final String dependenciesTitle) {
  178. lazyDependingTask = Installer.RP.post (new Runnable () {
  179. @Override
  180. public void run () {
  181. JPanel body = null;
  182. // init required elements
  183. model.getRequiredUpdateElements ();
  184. if (model instanceof InstallUnitWizardModel) {
  185. ((InstallUnitWizardModel) model).allLicensesApproved ();
  186. ((InstallUnitWizardModel) model).hasCustomComponents ();
  187. ((InstallUnitWizardModel) model).hasStandardComponents ();
  188. }
  189. boolean hasBrokenDependencies = model.hasBrokenDependencies ();
  190. final String[] args = { null, null, null, null };
  191. final boolean[] barg = { false };
  192. if (hasBrokenDependencies) {
  193. args[0] = "";
  194. args[1] = "";
  195. args[2] = prepareBrokenDependenciesForShow (model);
  196. args[3] = "";
  197. barg[0] = true;
  198. } else {
  199. args[0] = tableTitle;
  200. args[1] = preparePluginsForShow (
  201. model.getPrimaryUpdateElements(),
  202. model.getPrimaryVisibleUpdateElements(),
  203. model.getCustomHandledComponents (),
  204. model.getOperation ());
  205. args[2] = dependenciesTitle;
  206. args[3] = preparePluginsForShow (
  207. model.getRequiredUpdateElements(),
  208. model.getRequiredVisibleUpdateElements(),
  209. null,
  210. model.getOperation ());
  211. barg[0] = !model.getRequiredVisibleUpdateElements().isEmpty();
  212. }
  213. readyToGo = model != null && ! hasBrokenDependencies;
  214. SwingUtilities.invokeLater (new Runnable () {
  215. @Override
  216. public void run () {
  217. JPanel p = new OperationDescriptionPanel(
  218. args[0], args[1], args[2], args[3], barg[0]
  219. );
  220. component.setBody (p);
  221. component.setWaitingState (false);
  222. fireChange ();
  223. }
  224. });
  225. }
  226. });
  227. }
  228. static String prepareBrokenDependenciesForShow (OperationWizardModel model) {
  229. String s = new String ();
  230. boolean moreBroken = false;
  231. SortedMap<String, Set<UpdateElement>> dep2plugins = model.getBrokenDependency2Plugins ();
  232. for (String brokenDep : dep2plugins.keySet ()) {
  233. if (OperationWizardModel.MORE_BROKEN_PLUGINS.equals (brokenDep)) {
  234. moreBroken = true;
  235. continue;
  236. }
  237. s += getPresentationName (brokenDep);
  238. if (dep2plugins.get (brokenDep) != null) {
  239. Set<UpdateElement> sset = new HashSet<UpdateElement> (dep2plugins.get (brokenDep));
  240. Set<UpdateElement> uniqueElements = new HashSet<UpdateElement> ();
  241. for (UpdateElement plugin : sset) {
  242. uniqueElements.addAll (model.findPrimaryPlugins (plugin));
  243. }
  244. TreeSet<String> uniqueNames = new TreeSet<String> ();
  245. for (UpdateElement plugin : uniqueElements) {
  246. uniqueNames.add (plugin.getDisplayName ());
  247. }
  248. s += uniqueNames.size () == 1 ? getBundle ("OperationDescriptionStep_AffectedPluginByBrokenDepOnce") :
  249. getBundle ("OperationDescriptionStep_AffectedPluginByBrokenDep");
  250. for (String name : uniqueNames) {
  251. s += getBundle ("OperationDescriptionStep_AffectedPlugin", name);
  252. }
  253. }
  254. }
  255. if (moreBroken) {
  256. s += getBundle (OperationWizardModel.MORE_BROKEN_PLUGINS);
  257. }
  258. return s.trim ();
  259. }
  260. private static String getPresentationName (String dep) {
  261. String presentationName = null;
  262. boolean isPending = false;
  263. String reason = null;
  264. if (dep != null && dep.startsWith ("module")) { // NOI18N
  265. String codeName = dep.substring (6).trim ();
  266. int end = codeName.indexOf ('/'); // NOI18N
  267. String releaseVersion = null;
  268. if (end == -1) {
  269. end = codeName.indexOf (' '); // NOI18N
  270. } else {
  271. int spaceIndex = codeName.indexOf(' ');
  272. int index = (spaceIndex != -1) ? spaceIndex : codeName.length();
  273. releaseVersion = codeName.substring(end + 1, index).trim();
  274. }
  275. if (end != -1) {
  276. codeName = codeName.substring (0, end);
  277. }
  278. int greater = dep.indexOf ('>');
  279. int equals = dep.indexOf ('=');
  280. int idx = Math.max (greater, equals);
  281. String version = null;
  282. if (idx > 0) {
  283. version = dep.substring (idx + 2).trim ();
  284. }
  285. UpdateElement other = null;
  286. for (UpdateUnit u : UpdateManager.getDefault ().getUpdateUnits (UpdateManager.TYPE.MODULE)) {
  287. if (codeName.equals (u.getCodeName ())) {
  288. if (u.getInstalled () != null) {
  289. other = u.getInstalled ();
  290. } else if (u.getAvailableUpdates ().size () > 0) {
  291. other = u.getAvailableUpdates ().get (0);
  292. }
  293. if (u != null) {
  294. isPending = u.isPending ();
  295. }
  296. break;
  297. }
  298. }
  299. if (idx == -1) {
  300. // COMPARE_ANY
  301. // The module named {0} was needed and not found.
  302. reason = getBundle ("OperationDescriptionStep_BrokenModuleNameDep", other == null ? codeName : other.getDisplayName ());
  303. } else if (greater > 0) {
  304. // COMPARE_SPEC
  305. if (version != null && other != null && version.equals (other.getSpecificationVersion ())) {
  306. // The module {0} would also need to be installed.
  307. reason = getBundle ("OperationDescriptionStep_BrokenModuleDep", other.getDisplayName ());
  308. } else if (version != null) {
  309. if (other != null) {
  310. // The module {0} was requested in version >= {1} but only {2} was found.
  311. int compare = new SpecificationVersion(other.getSpecificationVersion()).compareTo(new SpecificationVersion(version));
  312. if(releaseVersion!=null && (equals > 0 ? (compare>=0) : (compare>0)) ) {
  313. reason = getBundle ("OperationDescriptionStep_BrokenModuleReleaseVersionDep",
  314. other.getDisplayName (),
  315. version,
  316. releaseVersion,
  317. other.getSpecificationVersion ());
  318. } else {
  319. reason = getBundle ("OperationDescriptionStep_BrokenModuleVersionDep",
  320. other.getDisplayName (),
  321. version,
  322. other.getSpecificationVersion ());
  323. }
  324. } else {
  325. // The module {0} was requested in version >= {1}.
  326. reason = getBundle ("OperationDescriptionStep_BrokenModuleOnlyVersionDep",
  327. codeName,
  328. version);
  329. }
  330. } else {
  331. // The module {0} would also need to be installed.
  332. reason = getBundle ("OperationDescriptionStep_BrokenModuleDep", other == null ? codeName : other.getDisplayName ());
  333. }
  334. } else if (equals > 0) {
  335. // COMPARE_IMPL
  336. // The module {0} was requested in implementation version "{1}".
  337. if (version != null) {
  338. reason = getBundle ("OperationDescriptionStep_BrokenModuleImplDep",
  339. other == null ? codeName : other.getDisplayName (),
  340. version);
  341. } else {
  342. reason = getBundle ("OperationDescriptionStep_BrokenModuleDep", other == null ? codeName : other.getDisplayName ());
  343. }
  344. }
  345. if (isPending) {
  346. presentationName = getBundle ("OperationDescriptionStep_BrokenPendingModuleDepInit", other == null ? codeName : other.getDisplayName (), // NOI18N
  347. reason);
  348. } else {
  349. presentationName = getBundle ("OperationDescriptionStep_BrokenModuleDepInit", other == null ? codeName : other.getDisplayName (), // NOI18N
  350. reason);
  351. }
  352. } else if (dep != null && (dep.toLowerCase ().startsWith ("requires") || dep.toLowerCase ().startsWith ("needs"))) { // NOI18N
  353. // No module providing the capability {0} could be found.
  354. String token = dep.substring (dep.indexOf (' ') + 1);
  355. presentationName = getBundle ("OperationDescriptionStep_BrokenRequireDepInit", token,
  356. getBundle ("OperationDescriptionStep_BrokenRequiresDep", token));
  357. } else if (dep != null && dep.toLowerCase ().startsWith ("java")) { // NOI18N
  358. presentationName = getBundle ("OperationDescriptionStep_BrokenJavaDepInit",
  359. dep,
  360. getBundle ("OperationDescriptionStep_PluginBrokesJavaDependency", dep, Dependency.JAVA_SPEC));
  361. } else if (dep != null && dep.toLowerCase ().startsWith ("package")) { // NOI18N
  362. presentationName = getBundle ("OperationDescriptionStep_BrokenPackageDepInit");
  363. }
  364. return presentationName == null ? dep : presentationName;
  365. }
  366. private String preparePluginsForShow (Set <UpdateElement> allPlugins, Set<UpdateElement> visiblePlugins, Set<UpdateElement> customHandled, OperationType type) {
  367. String s = new String ();
  368. List<String> names = new ArrayList<String> ();
  369. if (OperationWizardModel.OperationType.UPDATE != type) {
  370. if (visiblePlugins != null && !visiblePlugins.isEmpty()) {
  371. for (UpdateElement el : visiblePlugins) {
  372. String updatename = "<b>" + el.getDisplayName() + "</b> "; // NOI18N
  373. updatename += getBundle("OperationDescriptionStep_PluginVersionFormat", // NOI18N
  374. el.getSpecificationVersion());
  375. updatename += "<br>"; // NOI18N
  376. String notification = el.getNotification();
  377. if (notification != null && notification.length() > 0) {
  378. updatename += "<font color=\"red\">" + notification + "</font><br><br>"; // NOI18N
  379. }
  380. names.add(updatename);
  381. }
  382. Collections.sort(names, new Comparator<String>() {
  383. @Override
  384. public int compare(String o1, String o2) {
  385. return Collator.getInstance().compare(o1, o2);
  386. }
  387. });
  388. for (String name : names) {
  389. s += name;
  390. }
  391. }
  392. } else {
  393. SortedMap<UpdateUnit, TreeSet<UpdateElement>> visible2internals =
  394. new TreeMap<UpdateUnit, TreeSet<UpdateElement>> (new Comparator<UpdateUnit>() {
  395. @Override
  396. public int compare(UpdateUnit o1, UpdateUnit o2) {
  397. UpdateElement ue1 = o1.getInstalled() != null ? o1.getInstalled() : o1.getAvailableUpdates().get(0);
  398. UpdateElement ue2 = o2.getInstalled() != null ? o2.getInstalled() : o2.getAvailableUpdates().get(0);
  399. return ue1.getDisplayName().compareTo(ue2.getDisplayName());
  400. }
  401. });
  402. for (UpdateElement el : allPlugins) {
  403. // a kit
  404. if (UpdateManager.TYPE.KIT_MODULE.equals(el.getUpdateUnit().getType())) {
  405. if (! visible2internals.containsKey(el.getUpdateUnit())) {
  406. TreeSet<UpdateElement> elements = new TreeSet<UpdateElement>(new Comparator<UpdateElement>() {
  407. @Override
  408. public int compare(UpdateElement o1, UpdateElement o2) {
  409. return o1.getDisplayName().compareTo(o2.getDisplayName());
  410. }
  411. });
  412. visible2internals.put(el.getUpdateUnit(), elements);
  413. }
  414. } else {
  415. UpdateUnit visibleUnit = el.getUpdateUnit().getVisibleAncestor();
  416. // w/ visible ancestor
  417. if (visibleUnit != null) {
  418. if (! visible2internals.containsKey(visibleUnit)) {
  419. TreeSet<UpdateElement> elements = new TreeSet<UpdateElement>(new Comparator<UpdateElement>() {
  420. @Override
  421. public int compare(UpdateElement o1, UpdateElement o2) {
  422. return o1.getDisplayName().compareTo(o2.getDisplayName());
  423. }
  424. });
  425. visible2internals.put(visibleUnit, elements);
  426. }
  427. visible2internals.get(visibleUnit).add(el);
  428. } else {
  429. // a fallback, w/o visible ancestor
  430. if (! visible2internals.containsKey(el.getUpdateUnit())) {
  431. TreeSet<UpdateElement> elements = new TreeSet<UpdateElement>(new Comparator<UpdateElement>() {
  432. @Override
  433. public int compare(UpdateElement o1, UpdateElement o2) {
  434. return o1.getDisplayName().compareTo(o2.getDisplayName());
  435. }
  436. });
  437. visible2internals.put(el.getUpdateUnit(), elements);
  438. }
  439. }
  440. }
  441. }
  442. // prepare for show
  443. UpdateElement element4showing = null;
  444. for (UpdateUnit unit : visible2internals.keySet()) {
  445. String updatename = "<b>";
  446. if (unit.getInstalled() != null) {
  447. updatename += unit.getInstalled().getDisplayName() + "</b> "; // NOI18N
  448. } else {
  449. updatename += unit.getAvailableUpdates().get(0).getDisplayName() + "</b> "; // NOI18N
  450. }
  451. if (visible2internals.get(unit).isEmpty()) {
  452. element4showing = unit.getAvailableUpdates().get(0);
  453. if (unit.getInstalled() != null) {
  454. String oldVersion = unit.getInstalled().getSpecificationVersion();
  455. String newVersion = element4showing.getSpecificationVersion();
  456. updatename += getBundle("OperationDescriptionStep_UpdatePluginVersionFormat", oldVersion, newVersion);
  457. } else {
  458. String newVersion = element4showing.getSpecificationVersion();
  459. updatename += getBundle("OperationDescriptionStep_PluginVersionFormat", newVersion);
  460. }
  461. } else {
  462. for (UpdateElement el : visible2internals.get(unit)) {
  463. element4showing = el;
  464. if (el.getUpdateUnit().getInstalled() != null) {
  465. updatename += "<br>&nbsp;&nbsp;&nbsp;&nbsp;" + el.getDisplayName()
  466. + " ["
  467. + el.getUpdateUnit().getInstalled().getSpecificationVersion() + " -> "
  468. + el.getSpecificationVersion()
  469. + "]";
  470. } else {
  471. updatename += "<br>&nbsp;&nbsp;&nbsp;&nbsp;" + el.getDisplayName()
  472. + " ["
  473. + unit.getAvailableUpdates().get(0).getSpecificationVersion()
  474. + "]";
  475. }
  476. }
  477. }
  478. updatename += "<br>"; // NOI18N
  479. String notification = element4showing == null ? "" : element4showing.getNotification();
  480. if (notification != null && notification.length() > 0) {
  481. updatename += "<font color=\"red\">" + notification + "</font><br><br>"; // NOI18N
  482. }
  483. names.add(updatename);
  484. }
  485. for (String name : names) {
  486. s += name;
  487. }
  488. }
  489. if (customHandled != null && ! customHandled.isEmpty ()) {
  490. names = new ArrayList<String> ();
  491. for (UpdateElement el : customHandled) {
  492. names.add ("<b>" + el.getDisplayName () + "</b> " // NOI18N
  493. + getBundle ("OperationDescriptionStep_PluginVersionFormat", // NOI18N
  494. el.getSpecificationVersion ()) + "<br>"); // NOI18N
  495. }
  496. Collections.sort (names);
  497. s += "<br>" + getBundle ("OperationDescriptionStep_CustomHandled_Head", customHandled.size ()) + "<br>"; // NOI18N
  498. for (String name : names) {
  499. s += name;
  500. }
  501. }
  502. return s.trim ();
  503. }
  504. @Override
  505. public HelpCtx getHelp() {
  506. return null;
  507. }
  508. @Override
  509. public void readSettings(WizardDescriptor wd) {
  510. boolean doOperation = ! (model instanceof InstallUnitWizardModel);
  511. if (doOperation) {
  512. model.modifyOptionsForDoOperation (wd);
  513. } else {
  514. model.modifyOptionsForStartWizard (wd);
  515. }
  516. }
  517. @Override
  518. public void storeSettings(WizardDescriptor wd) {
  519. if (WizardDescriptor.CANCEL_OPTION.equals (wd.getValue ()) || WizardDescriptor.CLOSED_OPTION.equals (wd.getValue ())) {
  520. try {
  521. if (lazyDependingTask != null && ! lazyDependingTask.isFinished ()) {
  522. lazyDependingTask.cancel ();
  523. }
  524. AutoupdateCheckScheduler.notifyAvailable(LazyUnit.loadLazyUnits (model.getOperation()), model.getOperation());
  525. model.doCleanup (true);
  526. } catch (OperationException x) {
  527. Logger.getLogger (InstallUnitWizardModel.class.getName ()).log (Level.INFO, x.getMessage (), x);
  528. }
  529. }
  530. }
  531. @Override
  532. public boolean isValid () {
  533. return readyToGo;
  534. }
  535. @Override
  536. public synchronized void addChangeListener (ChangeListener l) {
  537. listeners.add (l);
  538. }
  539. @Override
  540. public synchronized void removeChangeListener (ChangeListener l) {
  541. listeners.remove (l);
  542. }
  543. private void fireChange () {
  544. ChangeEvent e = new ChangeEvent (this);
  545. List<ChangeListener> templist;
  546. synchronized (this) {
  547. templist = new ArrayList<ChangeListener> (listeners);
  548. }
  549. for (ChangeListener l : templist) {
  550. l.stateChanged (e);
  551. }
  552. }
  553. private static String getBundle (String key, Object... params) {
  554. return NbBundle.getMessage (OperationDescriptionPanel.class, key, params);
  555. }
  556. }