PageRenderTime 38ms CodeModel.GetById 0ms RepoModel.GetById 1ms app.codeStats 0ms

/projects/netbeans-7.3/web.jsf/src/org/netbeans/modules/web/jsf/wizards/JSFConfigurationPanelVisual.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus
Java | 969 lines | 790 code | 94 blank | 85 comment | 140 complexity | dc9660eaed5c055bf21ff519cdcfcc77 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-2007 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.web.jsf.wizards;
  45. import java.awt.Component;
  46. import java.awt.event.ActionEvent;
  47. import java.awt.event.ActionListener;
  48. import java.awt.event.MouseAdapter;
  49. import java.awt.event.MouseEvent;
  50. import java.io.File;
  51. import java.io.IOException;
  52. import java.net.MalformedURLException;
  53. import java.net.URI;
  54. import java.net.URL;
  55. import java.util.ArrayList;
  56. import java.util.Arrays;
  57. import java.util.Collection;
  58. import java.util.Collections;
  59. import java.util.HashMap;
  60. import java.util.HashSet;
  61. import java.util.List;
  62. import java.util.Map;
  63. import java.util.Set;
  64. import java.util.TreeMap;
  65. import java.util.TreeSet;
  66. import java.util.Vector;
  67. import java.util.logging.Level;
  68. import java.util.logging.Logger;
  69. import java.util.regex.Pattern;
  70. import javax.swing.DefaultComboBoxModel;
  71. import javax.swing.DefaultListModel;
  72. import javax.swing.JButton;
  73. import javax.swing.JComponent;
  74. import javax.swing.JFileChooser;
  75. import javax.swing.JTable;
  76. import javax.swing.ListSelectionModel;
  77. import javax.swing.SwingUtilities;
  78. import javax.swing.UIManager;
  79. import javax.swing.event.ChangeEvent;
  80. import javax.swing.event.ChangeListener;
  81. import javax.swing.event.DocumentListener;
  82. import javax.swing.event.TableModelEvent;
  83. import javax.swing.event.TableModelListener;
  84. import javax.swing.filechooser.FileFilter;
  85. import javax.swing.table.AbstractTableModel;
  86. import javax.swing.table.DefaultTableCellRenderer;
  87. import javax.swing.table.TableCellRenderer;
  88. import org.netbeans.api.annotations.common.CheckForNull;
  89. import org.netbeans.api.j2ee.core.Profile;
  90. import org.netbeans.api.java.classpath.ClassPath;
  91. import org.netbeans.api.project.FileOwnerQuery;
  92. import org.netbeans.api.project.Project;
  93. import org.netbeans.api.project.libraries.Library;
  94. import org.netbeans.api.project.libraries.LibraryManager;
  95. import org.netbeans.modules.j2ee.common.Util;
  96. import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
  97. import org.netbeans.modules.j2ee.deployment.common.api.J2eeLibraryTypeProvider;
  98. import org.netbeans.modules.j2ee.deployment.common.api.Version;
  99. import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
  100. import org.netbeans.modules.j2ee.deployment.devmodules.api.InstanceRemovedException;
  101. import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform;
  102. import org.netbeans.modules.j2ee.deployment.devmodules.api.ServerInstance;
  103. import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
  104. import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary;
  105. import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryDependency;
  106. import org.netbeans.modules.web.api.webmodule.ExtenderController;
  107. import org.netbeans.modules.web.api.webmodule.ExtenderController.Properties;
  108. import org.netbeans.modules.web.jsf.JSFUtils;
  109. import org.netbeans.modules.web.jsf.api.facesmodel.JSFVersion;
  110. import org.netbeans.modules.web.jsf.spi.components.JsfComponentCustomizer;
  111. import org.netbeans.modules.web.jsf.spi.components.JsfComponentImplementation;
  112. import org.netbeans.modules.web.jsf.spi.components.JsfComponentProvider;
  113. import org.netbeans.modules.web.jsf.wizards.JSFConfigurationPanel.LibraryType;
  114. import org.netbeans.modules.web.jsf.wizards.JSFConfigurationPanel.PreferredLanguage;
  115. import org.netbeans.spi.java.classpath.ClassPathProvider;
  116. import org.openide.DialogDescriptor;
  117. import org.openide.DialogDisplayer;
  118. import org.openide.WizardDescriptor;
  119. import org.openide.filesystems.URLMapper;
  120. import org.openide.util.*;
  121. import org.openide.util.lookup.Lookups;
  122. /**
  123. *
  124. * @author Petr Pisl, Radko Najman, alexeybutenko, Martin Fousek
  125. */
  126. public class JSFConfigurationPanelVisual extends javax.swing.JPanel implements HelpCtx.Provider, DocumentListener {
  127. private static final RequestProcessor RP = new RequestProcessor("JSF worker", 1);
  128. private static final Logger LOG = Logger.getLogger(JSFConfigurationPanelVisual.class.getName());
  129. private static final String JSF_SERVLET_NAME="Faces Servlet"; //NOI18N
  130. private String jsfServletName=null;
  131. private JSFConfigurationPanel panel;
  132. private boolean isFrameworkAddition;
  133. private boolean inCustomizer;
  134. private final List<LibraryItem> jsfLibraries = new ArrayList<LibraryItem>();
  135. // private final List<JsfComponentDescriptor> componentsLibraries = new ArrayList<JsfComponentDescriptor>();
  136. private final Map<JSFVersion, List<JsfComponentImplementation>> componentsMap = new HashMap<JSFVersion, List<JsfComponentImplementation>>();
  137. /**
  138. * Do not modify it directly, use setJsfVersion method
  139. */
  140. private JSFVersion currentJSFVersion = null;
  141. private final Set<ServerLibraryItem> serverJsfLibraries = new TreeSet<ServerLibraryItem>();
  142. private volatile boolean libsInitialized;
  143. private volatile boolean jsfComponentsInitialized;
  144. private String serverInstanceID;
  145. private final List<PreferredLanguage> preferredLanguages = new ArrayList<PreferredLanguage>();
  146. private String currentServerInstanceID;
  147. private boolean isWebLogicServer = false;
  148. // Jsf component libraries related
  149. private JSFComponentsTableModel jsfComponentsTableModel;
  150. private TreeMap<String, JsfComponentCustomizer> jsfComponentCustomizers = new TreeMap<String, JsfComponentCustomizer>();
  151. private static final Collection<? extends JsfComponentProvider> jsfComponentProviders =
  152. new ArrayList<JsfComponentProvider>(Lookups.forPath(JsfComponentProvider.COMPONENTS_PATH).
  153. lookupResult(JsfComponentProvider.class).allInstances());
  154. private final ChangeSupport changeSupport = new ChangeSupport(this);
  155. /** Libraries excluded from panel's {@link #jsfLibraries}. Libraries offered as registered in the IDE. */
  156. private static final Set<String> EXCLUDE_FROM_REGISTERED_LIBS = new HashSet<String>(Arrays.asList(
  157. "javaee-web-api-6.0", //NOI18N
  158. "javaee-api-6.0", //NOI18N
  159. "jsp-compilation", //NOI18N
  160. "jsp-compilation-syscp", //NOI18N
  161. "javaee-api-5.0")); //NOI18N
  162. /**
  163. * Creates new form JSFConfigurationPanelVisual.
  164. * @param panel panel to which is this visual component binded
  165. * @param isFrameworkAddition {@code true} if it's addition of JSF framework, {@code false} otherwise
  166. * @param inCustomizer {@code true} if the panel is called in customizer, {@code false} otherwise
  167. */
  168. public JSFConfigurationPanelVisual(JSFConfigurationPanel panel, boolean isFrameworkAddition, boolean inCustomizer) {
  169. this.panel = panel;
  170. this.isFrameworkAddition = isFrameworkAddition;
  171. this.inCustomizer = inCustomizer;
  172. this.jsfComponentsTableModel = new JSFComponentsTableModel();
  173. initComponents();
  174. tURLPattern.getDocument().addDocumentListener(this);
  175. cbPackageJars.setVisible(false);
  176. // update JSF components list
  177. jsfComponentsTable.setModel(jsfComponentsTableModel);
  178. JsfComponentsTableCellRenderer renderer = new JsfComponentsTableCellRenderer();
  179. renderer.setBooleanRenderer(jsfComponentsTable.getDefaultRenderer(Boolean.class));
  180. renderer.setJButtonRenderer(new JTableButtonRenderer());
  181. jsfComponentsTable.setDefaultRenderer(JsfComponentImplementation.class, renderer);
  182. jsfComponentsTable.setDefaultRenderer(Boolean.class, renderer);
  183. jsfComponentsTable.setDefaultRenderer(JButton.class, renderer);
  184. jsfComponentsTable.addMouseListener(new JsfComponentsMouseListener());
  185. jsfComponentsTableModel.addTableModelListener(new JsfComponentsTableModelListener());
  186. initJsfComponentTableVisualProperties(jsfComponentsTable);
  187. panel.addChangeListener(new ChangeListener() {
  188. @Override
  189. public void stateChanged(ChangeEvent e) {
  190. changeSupport.fireChange();
  191. }
  192. });
  193. }
  194. @Override
  195. public void addNotify() {
  196. super.addNotify();
  197. initLibraries();
  198. initJsfComponentsLibraries();
  199. // in customizer preselected included JSF library
  200. if (!isFrameworkAddition) {
  201. preselectJsfLibrary();
  202. }
  203. if (!isFrameworkAddition) {
  204. enableComponents(false);
  205. } else {
  206. updateLibrary();
  207. }
  208. }
  209. private void preselectJsfLibrary() {
  210. Runnable jsfLibararyUiSwitcher = new Runnable() {
  211. @Override
  212. public void run() {
  213. // searching in IDE registered JSF libraries
  214. Project project = FileOwnerQuery.getOwner(panel.getWebModule().getDocumentBase());
  215. ClassPathProvider cpp = project.getLookup().lookup(ClassPathProvider.class);
  216. ClassPath compileClassPath = cpp.findClassPath(panel.getWebModule().getDocumentBase(), ClassPath.COMPILE);
  217. compileClassPath.entries();
  218. for (ClassPath.Entry entry : compileClassPath.entries()) {
  219. for (final LibraryItem jsfLibrary : jsfLibraries) {
  220. try {
  221. List<URI> cps = jsfLibrary.getLibrary().getURIContent(J2eeLibraryTypeProvider.VOLUME_TYPE_CLASSPATH);
  222. for (URI uri : cps) {
  223. if (entry.getRoot() != null
  224. && entry.getRoot().equals(URLMapper.findFileObject(uri.toURL()))) {
  225. Mutex.EVENT.readAccess(new Runnable() {
  226. @Override
  227. public void run() {
  228. rbRegisteredLibrary.setSelected(true);
  229. enableComponents(false);
  230. cbLibraries.setSelectedItem(jsfLibrary.getLibrary().getDisplayName());
  231. }
  232. });
  233. return;
  234. }
  235. }
  236. } catch (MalformedURLException ex) {
  237. Exceptions.printStackTrace(ex);
  238. }
  239. }
  240. }
  241. // searching in server registered JSF libraries
  242. J2eeModuleProvider jmp = (J2eeModuleProvider) project.getLookup().lookup(J2eeModuleProvider.class);
  243. Set<ServerLibraryDependency> deps = getServerDependencies(jmp);
  244. for (ServerLibraryDependency serverLibraryDependency : deps) {
  245. if (serverLibraryDependency.getName().startsWith("jsf")) { //NOI18N
  246. ServerLibraryItem candidate = null;
  247. for (final ServerLibraryItem serverLibraryItem : serverJsfLibraries) {
  248. if (serverLibraryItem.getLibrary() != null) {
  249. Version implVersion = serverLibraryItem.getLibrary().getImplementationVersion();
  250. Version specVersion = serverLibraryItem.getLibrary().getSpecificationVersion();
  251. if ((implVersion != null && implVersion.equals(serverLibraryDependency.getImplementationVersion()))
  252. || specVersion != null && specVersion.equals(serverLibraryDependency.getSpecificationVersion())) {
  253. selectServerLibraryItem(serverLibraryItem);
  254. return;
  255. }
  256. } else {
  257. // IDE didn't recognize library correctly
  258. candidate = serverLibraryItem;
  259. }
  260. }
  261. if (candidate != null) {
  262. selectServerLibraryItem(candidate);
  263. }
  264. }
  265. }
  266. }
  267. private void selectServerLibraryItem(final ServerLibraryItem item) {
  268. Mutex.EVENT.readAccess(new Runnable() {
  269. @Override
  270. public void run() {
  271. rbServerLibrary.setSelected(true);
  272. enableComponents(false);
  273. serverLibraries.setSelectedItem(item);
  274. }
  275. });
  276. }
  277. };
  278. RP.post(jsfLibararyUiSwitcher);
  279. }
  280. private static Set<ServerLibraryDependency> getServerDependencies(J2eeModuleProvider jmp) {
  281. try {
  282. return jmp.getConfigSupport().getLibraries();
  283. } catch (ConfigurationException e) {
  284. return Collections.emptySet();
  285. }
  286. }
  287. public void addChangeListener(ChangeListener listener) {
  288. changeSupport.addChangeListener(listener);
  289. }
  290. public void removeChangeListener(ChangeListener listener) {
  291. changeSupport.removeChangeListener(listener);
  292. }
  293. void initLibraries() {
  294. long time = System.currentTimeMillis();
  295. if (libsInitialized) {
  296. return;
  297. }
  298. // init server libraries first
  299. initServerLibraries(false);
  300. final Vector<String> registeredItems = new Vector<String>();
  301. jsfLibraries.clear();
  302. final Runnable libraryFinder = new Runnable() {
  303. @Override
  304. public void run() {
  305. synchronized (this) {
  306. long time = System.currentTimeMillis();
  307. List<URL> content;
  308. for (Library library : LibraryManager.getDefault().getLibraries()) {
  309. if (!"j2se".equals(library.getType())) { // NOI18N
  310. continue;
  311. }
  312. if (library.getName().startsWith("facelets-") && !library.getName().endsWith("el-api") //NOI18N
  313. && !library.getName().endsWith("jsf-ri") && !library.getName().endsWith("myfaces")) { //NOI18N
  314. String displayName = library.getDisplayName();
  315. registeredItems.add(displayName);
  316. //TODO XX Add correct version
  317. jsfLibraries.add(new LibraryItem(library, JSFVersion.JSF_1_2));
  318. }
  319. content = library.getContent("classpath"); //NOI18N
  320. try {
  321. if (Util.containsClass(content, JSFUtils.FACES_EXCEPTION)
  322. && !EXCLUDE_FROM_REGISTERED_LIBS.contains(library.getName())) {
  323. registeredItems.add(library.getDisplayName());
  324. boolean isJSF12 = Util.containsClass(content, JSFUtils.JSF_1_2__API_SPECIFIC_CLASS);
  325. boolean isJSF20 = Util.containsClass(content, JSFUtils.JSF_2_0__API_SPECIFIC_CLASS);
  326. boolean isJSF21 = Util.containsClass(content, JSFUtils.JSF_2_1__API_SPECIFIC_CLASS);
  327. if (isJSF21) {
  328. jsfLibraries.add(new LibraryItem(library, JSFVersion.JSF_2_1));
  329. } else if (isJSF20) {
  330. jsfLibraries.add(new LibraryItem(library, JSFVersion.JSF_2_0));
  331. } else if (isJSF12) {
  332. jsfLibraries.add(new LibraryItem(library, JSFVersion.JSF_1_2));
  333. } else {
  334. jsfLibraries.add(new LibraryItem(library, JSFVersion.JSF_1_1));
  335. }
  336. }
  337. } catch (IOException exception) {
  338. LOG.log(Level.INFO, "", exception);
  339. }
  340. }
  341. // if maven, exclude user defined libraries
  342. if (panel.isMaven()) {
  343. removeUserDefinedLibraries(registeredItems);
  344. }
  345. SwingUtilities.invokeLater(new Runnable() {
  346. @Override
  347. public void run() {
  348. setRegisteredLibraryModel(registeredItems);
  349. updatePreferredLanguages();
  350. updateJsfComponents();
  351. }
  352. });
  353. LOG.log(Level.FINEST, "Time spent in initLibraries in Runnable = {0} ms", (System.currentTimeMillis()-time)); //NOI18N
  354. }
  355. }
  356. };
  357. RP.post(libraryFinder);
  358. libsInitialized = true;
  359. // repaint();
  360. LOG.log(Level.FINEST, "Time spent in {0} initLibraries = {1} ms", new Object[]{this.getClass().getName(), System.currentTimeMillis()-time}); //NOI18N
  361. }
  362. private void initJsfComponentsLibraries() {
  363. if (jsfComponentsInitialized)
  364. return;
  365. List<JsfComponentImplementation> jsfComponentDescriptors = new ArrayList<JsfComponentImplementation>();
  366. for (JsfComponentProvider provider: jsfComponentProviders) {
  367. jsfComponentDescriptors.addAll(provider.getJsfComponents());
  368. }
  369. for (JSFVersion jsfVersion : JSFVersion.values()) {
  370. List<JsfComponentImplementation> list = componentsMap.get(jsfVersion);
  371. if (list == null) {
  372. list = new ArrayList<JsfComponentImplementation>();
  373. componentsMap.put(jsfVersion, list);
  374. }
  375. for (JsfComponentImplementation jsfImplementation : jsfComponentDescriptors) {
  376. if (jsfImplementation.getJsfVersion().contains(jsfVersion)) {
  377. list.add(jsfImplementation);
  378. }
  379. }
  380. }
  381. jsfComponentsInitialized = true;
  382. if (currentJSFVersion != null) {
  383. updateJsfComponentsModel(currentJSFVersion);
  384. }
  385. }
  386. private void removeUserDefinedLibraries(Vector<String> registeredItems) {
  387. for (LibraryItem item : jsfLibraries) {
  388. Map<String, String> properties = item.getLibrary().getProperties();
  389. if (!properties.containsKey("maven-dependencies") //NOI18N
  390. || properties.get("maven-dependencies").trim().isEmpty()) { //NOI18N
  391. registeredItems.remove(item.getLibrary().getDisplayName());
  392. }
  393. }
  394. }
  395. private void initServerLibraries(boolean updateUI) {
  396. serverJsfLibraries.clear();
  397. synchronized (this) {
  398. Set<JSFVersion> found = new HashSet<JSFVersion>();
  399. if (isServerRegistered(serverInstanceID)) {
  400. try {
  401. ServerInstance.LibraryManager libManager = Deployment.getDefault().getServerInstance(serverInstanceID).getLibraryManager();
  402. if (libManager != null) {
  403. Set<ServerLibrary> libs = new HashSet<ServerLibrary>();
  404. libs.addAll(libManager.getDeployedLibraries());
  405. libs.addAll(libManager.getDeployableLibraries());
  406. for (ServerLibrary lib : libs) {
  407. // FIXME optimize
  408. if ("JavaServer Faces".equals(lib.getSpecificationTitle())) { // NOI18N
  409. if (Version.fromJsr277NotationWithFallback("2.1").equals(lib.getSpecificationVersion())) { //NOI18N
  410. serverJsfLibraries.add(new ServerLibraryItem(lib, JSFVersion.JSF_2_1));
  411. found.add(JSFVersion.JSF_2_1);
  412. } else if (Version.fromJsr277NotationWithFallback("2.0").equals(lib.getSpecificationVersion())) { // NOI18N
  413. serverJsfLibraries.add(new ServerLibraryItem(lib, JSFVersion.JSF_2_0));
  414. found.add(JSFVersion.JSF_2_0);
  415. } else if (Version.fromJsr277NotationWithFallback("1.2").equals(lib.getSpecificationVersion())) { // NOI18N
  416. serverJsfLibraries.add(new ServerLibraryItem(lib, JSFVersion.JSF_1_2));
  417. found.add(JSFVersion.JSF_1_2);
  418. } else if (Version.fromJsr277NotationWithFallback("1.1").equals(lib.getSpecificationVersion())) { // NOI18N
  419. serverJsfLibraries.add(new ServerLibraryItem(lib, JSFVersion.JSF_1_1));
  420. found.add(JSFVersion.JSF_1_1);
  421. } else {
  422. LOG.log(Level.INFO, "Unknown JSF version {0}", lib.getSpecificationVersion());
  423. }
  424. }
  425. }
  426. }
  427. } catch (InstanceRemovedException ex) {
  428. LOG.log(Level.INFO, null, ex);
  429. // use the old way
  430. }
  431. }
  432. File[] cp;
  433. J2eePlatform platform = null;
  434. try {
  435. if (isServerRegistered(serverInstanceID)) { //NOI18N
  436. platform = Deployment.getDefault().getServerInstance(serverInstanceID).getJ2eePlatform();
  437. }
  438. } catch (InstanceRemovedException ex) {
  439. platform = null;
  440. LOG.log(Level.INFO, org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "SERVER_INSTANCE_REMOVED"), ex);
  441. }
  442. // j2eeplatform can be null, when the target server is not accessible.
  443. if (platform != null) {
  444. cp = platform.getClasspathEntries();
  445. } else {
  446. cp = new File[0];
  447. }
  448. try {
  449. // XXX: there should be a utility class for this:
  450. boolean isJSF = Util.containsClass(Arrays.asList(cp), JSFUtils.FACES_EXCEPTION);
  451. boolean isJSF12 = Util.containsClass(Arrays.asList(cp), JSFUtils.JSF_1_2__API_SPECIFIC_CLASS);
  452. boolean isJSF20 = Util.containsClass(Arrays.asList(cp), JSFUtils.JSF_2_0__API_SPECIFIC_CLASS);
  453. boolean isJSF21 = Util.containsClass(Arrays.asList(cp), JSFUtils.JSF_2_1__API_SPECIFIC_CLASS);
  454. JSFVersion jsfVersion = null;
  455. if (isJSF21) {
  456. jsfVersion = JSFVersion.JSF_2_1;
  457. } else if (isJSF20) {
  458. jsfVersion = JSFVersion.JSF_2_0;
  459. } else if (isJSF12) {
  460. jsfVersion = JSFVersion.JSF_1_2;
  461. } else if (isJSF) {
  462. jsfVersion = JSFVersion.JSF_1_1;
  463. }
  464. if (jsfVersion != null && !found.contains(jsfVersion)) {
  465. serverJsfLibraries.add(new ServerLibraryItem(null, jsfVersion));
  466. }
  467. } catch (IOException ex) {
  468. LOG.log(Level.INFO, "", ex);
  469. }
  470. setServerLibraryModel(serverJsfLibraries);
  471. if (updateUI) {
  472. //updatePreferredLanguages();
  473. }
  474. }
  475. }
  476. private static boolean isServerRegistered(String serverInstanceID) {
  477. if (serverInstanceID != null && !"".equals(serverInstanceID) && !"DEV-NULL".equals(serverInstanceID)) {
  478. return true;
  479. }
  480. return false;
  481. }
  482. private void setRegisteredLibraryModel(Vector<String> items) {
  483. long time = System.currentTimeMillis();
  484. cbLibraries.setModel(new DefaultComboBoxModel(items));
  485. if (items.size() == 0) {
  486. rbRegisteredLibrary.setEnabled(false);
  487. cbLibraries.setEnabled(false);
  488. rbNewLibrary.setSelected(true);
  489. panel.setLibrary((Library) null);
  490. } else if (items.size() != 0 && panel.getLibraryType() == LibraryType.USED){
  491. if (isFrameworkAddition) {
  492. rbRegisteredLibrary.setEnabled(true);
  493. cbLibraries.setEnabled(true);
  494. }
  495. rbRegisteredLibrary.setSelected(true);
  496. if (jsfLibraries.size() > 0){
  497. panel.setLibrary(jsfLibraries.get(cbLibraries.getSelectedIndex()).getLibrary());
  498. setJsfVersion(jsfLibraries.get(cbLibraries.getSelectedIndex()).getVersion());
  499. }
  500. }
  501. // libsInitialized = true;
  502. repaint();
  503. LOG.finest("Time spent in "+this.getClass().getName() +" setLibraryModel = "+(System.currentTimeMillis()-time) +" ms"); //NOI18N
  504. }
  505. private void setServerLibraryModel(Collection<ServerLibraryItem> items) {
  506. serverLibraries.setModel(new DefaultComboBoxModel(items.toArray()));
  507. if (items.isEmpty()) {
  508. rbServerLibrary.setEnabled(false);
  509. serverLibraries.setEnabled(false);
  510. rbRegisteredLibrary.setSelected(true);
  511. panel.setServerLibrary((ServerLibrary) null);
  512. } else if (!items.isEmpty() && panel.getLibraryType() == LibraryType.SERVER){
  513. if (isFrameworkAddition) {
  514. rbServerLibrary.setEnabled(true);
  515. serverLibraries.setEnabled(true);
  516. }
  517. rbServerLibrary.setSelected(true);
  518. if (!serverJsfLibraries.isEmpty()) {
  519. ServerLibraryItem item = (ServerLibraryItem) serverLibraries.getSelectedItem();
  520. if (item != null) {
  521. panel.setServerLibrary(item.getLibrary());
  522. setJsfVersion(item.getVersion());
  523. }
  524. }
  525. }
  526. repaint();
  527. }
  528. /**
  529. * Init Preferred Languages check box with "JSP" and/or "Facelets"
  530. * according to choosen library
  531. */
  532. private void updatePreferredLanguages() {
  533. boolean faceletsPresent = false;
  534. Library jsfLibrary = null;
  535. LibraryType libraryType = panel.getLibraryType();
  536. if (libraryType == null) {
  537. return;
  538. }
  539. if (libraryType == LibraryType.USED) {
  540. if (!libsInitialized) {
  541. initLibraries();
  542. }
  543. jsfLibrary = panel.getLibrary();
  544. } else if (libraryType == LibraryType.NEW) {
  545. if (panel.getNewLibraryName() != null) {
  546. jsfLibrary = LibraryManager.getDefault().getLibrary(panel.getNewLibraryName());
  547. }
  548. } else if (libraryType == LibraryType.SERVER) {
  549. //XXX: need to find lib version
  550. ServerLibraryItem item = (ServerLibraryItem) serverLibraries.getSelectedItem();
  551. if (item != null
  552. && (item.getVersion() == JSFVersion.JSF_2_0 || item.getVersion() == JSFVersion.JSF_2_1)) {
  553. faceletsPresent = true;
  554. }
  555. }
  556. if (jsfLibrary != null) {
  557. if (jsfLibraries.get(cbLibraries.getSelectedIndex()).getVersion() == JSFVersion.JSF_2_0
  558. || jsfLibraries.get(cbLibraries.getSelectedIndex()).getVersion() == JSFVersion.JSF_2_1) {
  559. faceletsPresent = true;
  560. } else {
  561. List<URL> content = jsfLibrary.getContent("classpath"); //NOI18N
  562. try {
  563. faceletsPresent = Util.containsClass(content, "com.sun.facelets.Facelet") || //NOI18N
  564. Util.containsClass(content, "com.sun.faces.facelets.Facelet"); //NOI18N
  565. }catch(Exception e) {
  566. e.printStackTrace();
  567. }
  568. }
  569. }
  570. preferredLanguages.clear();
  571. preferredLanguages.add(PreferredLanguage.JSP);
  572. if (faceletsPresent) {
  573. if (isFrameworkAddition) {
  574. panel.setEnableFacelets(true);
  575. }
  576. if (panel.isEnableFacelets()) {
  577. preferredLanguages.add(0, PreferredLanguage.Facelets);
  578. } else {
  579. preferredLanguages.add(PreferredLanguage.Facelets);
  580. }
  581. } else {
  582. panel.setEnableFacelets(false);
  583. }
  584. cbPreferredLang.setModel(new DefaultComboBoxModel(preferredLanguages.toArray()));
  585. repaint();
  586. }
  587. /** This method is called from within the constructor to
  588. * initialize the form.
  589. * WARNING: Do NOT modify this code. The content of this method is
  590. * always regenerated by the Form Editor.
  591. */
  592. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  593. private void initComponents() {
  594. buttonGroup1 = new javax.swing.ButtonGroup();
  595. jsfTabbedPane = new javax.swing.JTabbedPane();
  596. libPanel = new javax.swing.JPanel();
  597. rbServerLibrary = new javax.swing.JRadioButton();
  598. rbRegisteredLibrary = new javax.swing.JRadioButton();
  599. cbLibraries = new javax.swing.JComboBox();
  600. rbNewLibrary = new javax.swing.JRadioButton();
  601. lDirectory = new javax.swing.JLabel();
  602. customBundleTextField = new javax.swing.JTextField();
  603. jbBrowse = new javax.swing.JButton();
  604. lVersion = new javax.swing.JLabel();
  605. jtNewLibraryName = new javax.swing.JTextField();
  606. serverLibraries = new javax.swing.JComboBox();
  607. cbPackageJars = new javax.swing.JCheckBox();
  608. confPanel = new javax.swing.JPanel();
  609. lURLPattern = new javax.swing.JLabel();
  610. tURLPattern = new javax.swing.JTextField();
  611. cbPreferredLang = new javax.swing.JComboBox();
  612. jLabel1 = new javax.swing.JLabel();
  613. componentsPanel = new javax.swing.JPanel();
  614. jsfComponentsLabel = new javax.swing.JLabel();
  615. jsfComponentsScrollPane = new javax.swing.JScrollPane();
  616. jsfComponentsTable = new javax.swing.JTable();
  617. setLayout(new java.awt.CardLayout());
  618. jsfTabbedPane.setMinimumSize(new java.awt.Dimension(106, 62));
  619. jsfTabbedPane.setPreferredSize(new java.awt.Dimension(483, 210));
  620. libPanel.setAlignmentX(0.2F);
  621. libPanel.setAlignmentY(0.2F);
  622. buttonGroup1.add(rbServerLibrary);
  623. rbServerLibrary.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/jsf/wizards/Bundle").getString("MNE_rbNoAppend").charAt(0));
  624. java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/web/jsf/wizards/Bundle"); // NOI18N
  625. rbServerLibrary.setText(bundle.getString("LBL_Any_Library")); // NOI18N
  626. rbServerLibrary.addItemListener(new java.awt.event.ItemListener() {
  627. public void itemStateChanged(java.awt.event.ItemEvent evt) {
  628. rbServerLibraryItemStateChanged(evt);
  629. }
  630. });
  631. buttonGroup1.add(rbRegisteredLibrary);
  632. rbRegisteredLibrary.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/jsf/wizards/Bundle").getString("MNE_rbRegLibs").charAt(0));
  633. rbRegisteredLibrary.setSelected(true);
  634. rbRegisteredLibrary.setText(bundle.getString("LBL_REGISTERED_LIBRARIES")); // NOI18N
  635. rbRegisteredLibrary.addItemListener(new java.awt.event.ItemListener() {
  636. public void itemStateChanged(java.awt.event.ItemEvent evt) {
  637. rbRegisteredLibraryItemStateChanged(evt);
  638. }
  639. });
  640. cbLibraries.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Search Libraries..." }));
  641. cbLibraries.addActionListener(new java.awt.event.ActionListener() {
  642. public void actionPerformed(java.awt.event.ActionEvent evt) {
  643. cbLibrariesActionPerformed(evt);
  644. }
  645. });
  646. buttonGroup1.add(rbNewLibrary);
  647. rbNewLibrary.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/jsf/wizards/Bundle").getString("MNE_rbCrNewLib").charAt(0));
  648. rbNewLibrary.setText(bundle.getString("LBL_CREATE_NEW_LIBRARY")); // NOI18N
  649. rbNewLibrary.setToolTipText(bundle.getString("MSG_CreatingLibraries")); // NOI18N
  650. rbNewLibrary.addItemListener(new java.awt.event.ItemListener() {
  651. public void itemStateChanged(java.awt.event.ItemEvent evt) {
  652. rbNewLibraryItemStateChanged(evt);
  653. }
  654. });
  655. lDirectory.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/jsf/wizards/Bundle").getString("MNE_lJSFDir").charAt(0));
  656. lDirectory.setLabelFor(customBundleTextField);
  657. lDirectory.setText(bundle.getString("LBL_INSTALL_DIR")); // NOI18N
  658. lDirectory.setToolTipText(bundle.getString("HINT_JSF_Directory")); // NOI18N
  659. customBundleTextField.setToolTipText(bundle.getString("HINT_JSF_Directory")); // NOI18N
  660. customBundleTextField.addKeyListener(new java.awt.event.KeyAdapter() {
  661. public void keyPressed(java.awt.event.KeyEvent evt) {
  662. customBundleTextFieldKeyPressed(evt);
  663. }
  664. });
  665. jbBrowse.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/jsf/wizards/Bundle").getString("MNE_Browse").charAt(0));
  666. jbBrowse.setText(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_Browse")); // NOI18N
  667. jbBrowse.setToolTipText(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "HINT_JSF_BROWSE_BTN")); // NOI18N
  668. jbBrowse.addActionListener(new java.awt.event.ActionListener() {
  669. public void actionPerformed(java.awt.event.ActionEvent evt) {
  670. jbBrowseActionPerformed(evt);
  671. }
  672. });
  673. lVersion.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/jsf/wizards/Bundle").getString("MNE_lJSFVer").charAt(0));
  674. lVersion.setLabelFor(jtNewLibraryName);
  675. lVersion.setText(bundle.getString("LBL_VERSION")); // NOI18N
  676. lVersion.setToolTipText(bundle.getString("HINT_Version")); // NOI18N
  677. jtNewLibraryName.setToolTipText(bundle.getString("HINT_Version")); // NOI18N
  678. jtNewLibraryName.addKeyListener(new java.awt.event.KeyAdapter() {
  679. public void keyReleased(java.awt.event.KeyEvent evt) {
  680. jtNewLibraryNameKeyReleased(evt);
  681. }
  682. });
  683. serverLibraries.addActionListener(new java.awt.event.ActionListener() {
  684. public void actionPerformed(java.awt.event.ActionEvent evt) {
  685. serverLibrariesActionPerformed(evt);
  686. }
  687. });
  688. cbPackageJars.setSelected(true);
  689. cbPackageJars.setText(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "CB_Package_JARs")); // NOI18N
  690. javax.swing.GroupLayout libPanelLayout = new javax.swing.GroupLayout(libPanel);
  691. libPanel.setLayout(libPanelLayout);
  692. libPanelLayout.setHorizontalGroup(
  693. libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  694. .addGroup(libPanelLayout.createSequentialGroup()
  695. .addContainerGap()
  696. .addGroup(libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  697. .addComponent(rbNewLibrary, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE)
  698. .addGroup(libPanelLayout.createSequentialGroup()
  699. .addGap(22, 22, 22)
  700. .addGroup(libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  701. .addComponent(cbPackageJars)
  702. .addComponent(lVersion)
  703. .addComponent(lDirectory))
  704. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 206, Short.MAX_VALUE))
  705. .addGroup(libPanelLayout.createSequentialGroup()
  706. .addGroup(libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
  707. .addComponent(rbServerLibrary, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  708. .addComponent(rbRegisteredLibrary, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  709. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  710. .addGroup(libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  711. .addComponent(cbLibraries, 0, 316, Short.MAX_VALUE)
  712. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, libPanelLayout.createSequentialGroup()
  713. .addGroup(libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  714. .addComponent(jtNewLibraryName, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE)
  715. .addComponent(customBundleTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE))
  716. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  717. .addComponent(jbBrowse))
  718. .addComponent(serverLibraries, 0, 295, Short.MAX_VALUE))))
  719. .addContainerGap())
  720. );
  721. libPanelLayout.setVerticalGroup(
  722. libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  723. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, libPanelLayout.createSequentialGroup()
  724. .addContainerGap()
  725. .addGroup(libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  726. .addComponent(rbServerLibrary)
  727. .addComponent(serverLibraries, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  728. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  729. .addGroup(libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  730. .addComponent(rbRegisteredLibrary)
  731. .addComponent(cbLibraries, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  732. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  733. .addComponent(rbNewLibrary)
  734. .addGroup(libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  735. .addComponent(jbBrowse)
  736. .addComponent(customBundleTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  737. .addComponent(lDirectory))
  738. .addGroup(libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  739. .addComponent(jtNewLibraryName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  740. .addComponent(lVersion))
  741. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  742. .addComponent(cbPackageJars)
  743. .addContainerGap(22, Short.MAX_VALUE))
  744. );
  745. cbPackageJars.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "ACSD_PackageJarToWar")); // NOI18N
  746. jsfTabbedPane.addTab(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_TAB_Libraries"), libPanel); // NOI18N
  747. lURLPattern.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/jsf/wizards/Bundle").getString("MNE_lURLPattern").charAt(0));
  748. lURLPattern.setLabelFor(tURLPattern);
  749. lURLPattern.setText(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_URL_Pattern")); // NOI18N
  750. tURLPattern.setText(panel.getFacesMapping());
  751. cbPreferredLang.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
  752. cbPreferredLang.addActionListener(new java.awt.event.ActionListener() {
  753. public void actionPerformed(java.awt.event.ActionEvent evt) {
  754. cbPreferredLangActionPerformed(evt);
  755. }
  756. });
  757. jLabel1.setLabelFor(cbPreferredLang);
  758. jLabel1.setText(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_PREFERRED_LANGUAGE")); // NOI18N
  759. javax.swing.GroupLayout confPanelLayout = new javax.swing.GroupLayout(confPanel);
  760. confPanel.setLayout(confPanelLayout);
  761. confPanelLayout.setHorizontalGroup(
  762. confPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  763. .addGroup(confPanelLayout.createSequentialGroup()
  764. .addContainerGap()
  765. .addGroup(confPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  766. .addGroup(confPanelLayout.createSequentialGroup()
  767. .addComponent(lURLPattern)
  768. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  769. .addComponent(tURLPattern, javax.swing.GroupLayout.DEFAULT_SIZE, 326, Short.MAX_VALUE))
  770. .addGroup(confPanelLayout.createSequentialGroup()
  771. .addComponent(jLabel1)
  772. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  773. .addComponent(cbPreferredLang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
  774. .addContainerGap())
  775. );
  776. confPanelLayout.setVerticalGroup(
  777. confPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  778. .addGroup(confPanelLayout.createSequentialGroup()
  779. .addContainerGap()
  780. .addGroup(confPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  781. .addComponent(lURLPattern)
  782. .addComponent(tURLPattern, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  783. .addGap(33, 33, 33)
  784. .addGroup(confPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  785. .addComponent(jLabel1)
  786. .addComponent(cbPreferredLang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  787. .addGap(98, 98, 98))
  788. );
  789. tURLPattern.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "ACSD_Mapping")); // NOI18N
  790. jsfTabbedPane.addTab(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_TAB_Configuration"), confPanel); // NOI18N
  791. jsfComponentsLabel.setText(getJsfComponentsLabelText());
  792. jsfComponentsTable.setModel(new javax.swing.table.DefaultTableModel(
  793. new Object [][] {
  794. {null, null, null, null},
  795. {null, null, null, null},
  796. {null, null, null, null},
  797. {null, null, null, null}
  798. },
  799. new String [] {
  800. "Title 1", "Title 2", "Title 3", "Title 4"
  801. }
  802. ));
  803. jsfComponentsScrollPane.setViewportView(jsfComponentsTable);
  804. javax.swing.GroupLayout componentsPanelLayout = new javax.swing.GroupLayout(componentsPanel);
  805. componentsPanel.setLayout(componentsPanelLayout);
  806. componentsPanelLayout.setHorizontalGroup(
  807. componentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  808. .addGroup(componentsPanelLayout.createSequentialGroup()
  809. .addContainerGap()
  810. .addGroup(componentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  811. .addComponent(jsfComponentsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 479, Short.MAX_VALUE)
  812. .addComponent(jsfComponentsLabel))
  813. .addContainerGap())
  814. );
  815. componentsPanelLayout.setVerticalGroup(
  816. componentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  817. .addGroup(componentsPanelLayout.createSequentialGroup()
  818. .addContainerGap()
  819. .addComponent(jsfComponentsLabel)
  820. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  821. .addComponent(jsfComponentsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
  822. .addContainerGap())
  823. );
  824. jsfTabbedPane.addTab(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_TAB_Components"), componentsPanel); // NOI18N
  825. add(jsfTabbedPane, "card10");
  826. jsfTabbedPane.getAccessibleContext().setAccessibleName("");
  827. }// </editor-fold>//GEN-END:initComponents
  828. private void rbServerLibraryItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_rbServerLibraryItemStateChanged
  829. updateLibrary();
  830. if (rbServerLibrary.isSelected()) {
  831. panel.fireChangeEvent();
  832. }
  833. }//GEN-LAST:event_rbServerLibraryItemStateChanged
  834. private void jtNewLibraryNameKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtNewLibraryNameKeyReleased
  835. panel.setNewLibraryName(jtNewLibraryName.getText().trim());
  836. }//GEN-LAST:event_jtNewLibraryNameKeyReleased
  837. private void rbNewLibraryItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_rbNewLibraryItemStateChanged
  838. updateLibrary();
  839. if (rbNewLibrary.isSelected()) {
  840. panel.fireChangeEvent();
  841. }
  842. }//GEN-LAST:event_rbNewLibraryItemStateChanged
  843. private void cbLibrariesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbLibrariesActionPerformed
  844. panel.setLibrary(jsfLibraries.get(cbLibraries.getSelectedIndex()).getLibrary());
  845. setJsfVersion(jsfLibraries.get(cbLibraries.getSelectedIndex()).getVersion());
  846. updatePreferredLanguages();
  847. }//GEN-LAST:event_cbLibrariesActionPerformed
  848. private void rbRegisteredLibraryItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_rbRegisteredLibraryItemStateChanged
  849. updateLibrary();
  850. if (rbRegisteredLibrary.isSelected()) {
  851. panel.fireChangeEvent();
  852. }
  853. }//GEN-LAST:event_rbRegisteredLibraryItemStateChanged
  854. private void jbBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbBrowseActionPerformed
  855. JFileChooser chooser = new JFileChooser();
  856. chooser.setDialogTitle(NbBundle.getMessage(JSFConfigurationPanelVisual.class,"LBL_SelectLibraryLocation")); //NOI18N
  857. chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
  858. chooser.setFileFilter(new FileFilter() {
  859. @Override
  860. public boolean accept(File f) {
  861. if (f.getName().endsWith(".jar") || f.isDirectory()) { //N0I18N
  862. return true;
  863. }
  864. return false;
  865. }
  866. @Override
  867. public String getDescription() {
  868. return NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_FileTypeInChooser"); //NOI18N
  869. }
  870. });
  871. chooser.setCurrentDirectory(new File(customBundleTextField.getText().trim()));
  872. if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
  873. File selectedEntry = chooser.getSelectedFile();
  874. customBundleTextField.setText(selectedEntry.getAbsolutePath());
  875. setN