Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 63270 invoked from network); 21 Jun 2007 23:19:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Jun 2007 23:19:15 -0000 Received: (qmail 45019 invoked by uid 500); 21 Jun 2007 23:19:15 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 44971 invoked by uid 500); 21 Jun 2007 23:19:15 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 44901 invoked by uid 99); 21 Jun 2007 23:19:15 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Jun 2007 16:19:15 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Jun 2007 16:19:06 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 845A31A9823; Thu, 21 Jun 2007 16:18:46 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r549644 [4/8] - in /geronimo/sandbox/geronimo-netbeans-plugin: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/geronimo/ src/main/java/org/apache/geronimo/netbeans/ src/main/java/org/ap... Date: Thu, 21 Jun 2007 23:18:41 -0000 To: scm@geronimo.apache.org From: jlaskowski@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070621231846.845A31A9823@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerJVM.form URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerJVM.form?view=auto&rev=549644 ============================================================================== --- geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerJVM.form (added) +++ geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerJVM.form Thu Jun 21 16:18:31 2007 @@ -0,0 +1,192 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerJVM.form ------------------------------------------------------------------------------ svn:executable = * Added: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerJVM.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerJVM.java?view=auto&rev=549644 ============================================================================== --- geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerJVM.java (added) +++ geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerJVM.java Thu Jun 21 16:18:31 2007 @@ -0,0 +1,166 @@ +package org.apache.geronimo.netbeans.customizer; + +import org.netbeans.api.java.platform.PlatformsCustomizer; + +/** + * Customizer JVM (Platform) tab. + */ +public class CustomizerJVM extends javax.swing.JPanel { + + private CustomizerDataSupport custData; + + /** Creates new form CustomizerJVM */ + public CustomizerJVM(CustomizerDataSupport custData) { + this.custData = custData; + initComponents(); + + // mnemonics generated in the guarded block do not work + proxyCheckBox.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerJVM.class, "MNE_Proxy").charAt(0)); + } + + /** + * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The + * content of this method is always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + java.awt.GridBagConstraints gridBagConstraints; + + jPanel1 = new javax.swing.JPanel(); + jvmLabel = new javax.swing.JLabel(); + jvmButton = new javax.swing.JButton(); + jvmComboBox = new javax.swing.JComboBox(); + proxyCheckBox = new javax.swing.JCheckBox(); + jLabel1 = new javax.swing.JLabel(); + jTextField1 = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + + setLayout(new java.awt.BorderLayout()); + + jPanel1.setLayout(new java.awt.GridBagLayout()); + + jvmLabel.setLabelFor(jvmComboBox); + org.openide.awt.Mnemonics.setLocalizedText(jvmLabel, org.openide.util.NbBundle.getMessage(CustomizerJVM.class, + "TXT_JVM")); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0); + jPanel1.add(jvmLabel, gridBagConstraints); + jvmLabel.getAccessibleContext().setAccessibleName(null); + jvmLabel.getAccessibleContext().setAccessibleDescription(null); + + org.openide.awt.Mnemonics.setLocalizedText(jvmButton, org.openide.util.NbBundle.getMessage(CustomizerJVM.class, + "TXT_ManagePlatforms")); + jvmButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jvmButtonActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 0; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(12, 5, 0, 12); + jPanel1.add(jvmButton, gridBagConstraints); + jvmButton.getAccessibleContext().setAccessibleName(null); + jvmButton.getAccessibleContext().setAccessibleDescription(null); + + jvmComboBox.setModel(custData.getJvmModel()); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.insets = new java.awt.Insets(12, 5, 0, 0); + jPanel1.add(jvmComboBox, gridBagConstraints); + + proxyCheckBox.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerJVM.class, "MNE_Proxy").charAt(0)); + proxyCheckBox.setText(org.openide.util.NbBundle.getMessage(CustomizerJVM.class, "LBL_Proxy")); + proxyCheckBox.setModel(custData.getProxyModel()); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 3; + gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new java.awt.Insets(11, 12, 0, 0); + jPanel1.add(proxyCheckBox, gridBagConstraints); + proxyCheckBox.getAccessibleContext().setAccessibleName(null); + proxyCheckBox.getAccessibleContext().setAccessibleDescription(null); + + jLabel1.setLabelFor(jTextField1); + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(CustomizerJVM.class, + "TXT_VMOptions")); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 0); + jPanel1.add(jLabel1, gridBagConstraints); + jLabel1.getAccessibleContext().setAccessibleName(null); + jLabel1.getAccessibleContext().setAccessibleDescription(null); + + jTextField1.setColumns(30); + jTextField1.setDocument(custData.getJavaOptsModel()); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 1; + gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 12); + jPanel1.add(jTextField1, gridBagConstraints); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(CustomizerJVM.class, + "TXT_VMOptionsEG")); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 2; + gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0); + jPanel1.add(jLabel2, gridBagConstraints); + jLabel2.getAccessibleContext().setAccessibleName(null); + jLabel2.getAccessibleContext().setAccessibleDescription(null); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(CustomizerJVM.class, + "TXT_NoteChangesTakeAffect")); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 4; + gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(5, 12, 12, 0); + jPanel1.add(jLabel3, gridBagConstraints); + jLabel3.getAccessibleContext().setAccessibleName(null); + jLabel3.getAccessibleContext().setAccessibleDescription(null); + + add(jPanel1, java.awt.BorderLayout.CENTER); + + }// //GEN-END:initComponents + + private void jvmButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jvmButtonActionPerformed + PlatformsCustomizer.showCustomizer(null); + custData.loadJvmModel(); + }// GEN-LAST:event_jvmButtonActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JPanel jPanel1; + private javax.swing.JTextField jTextField1; + private javax.swing.JButton jvmButton; + private javax.swing.JComboBox jvmComboBox; + private javax.swing.JLabel jvmLabel; + private javax.swing.JCheckBox proxyCheckBox; + // End of variables declaration//GEN-END:variables + +} Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerJVM.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerJVM.java ------------------------------------------------------------------------------ svn:executable = * Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerJVM.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerJVM.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerSupport.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerSupport.java?view=auto&rev=549644 ============================================================================== --- geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerSupport.java (added) +++ geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerSupport.java Thu Jun 21 16:18:31 2007 @@ -0,0 +1,747 @@ +package org.apache.geronimo.netbeans.customizer; + +import java.awt.Component; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.StringTokenizer; +import javax.swing.AbstractListModel; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.filechooser.FileFilter; +import org.netbeans.modules.j2ee.deployment.common.api.J2eeLibraryTypeProvider; +import org.openide.ErrorManager; +import org.openide.NotifyDescriptor; +import org.openide.filesystems.FileUtil; +import org.openide.util.NbBundle; + +public final class CustomizerSupport { + + private static final String CLASSPATH = J2eeLibraryTypeProvider.VOLUME_TYPE_CLASSPATH; + private static final String SOURCES = J2eeLibraryTypeProvider.VOLUME_TYPE_SRC; + private static final String JAVADOC = J2eeLibraryTypeProvider.VOLUME_TYPE_JAVADOC; + + /** Do not allow to create instances of this class */ + private CustomizerSupport() { + } + + /** + * Creates non-editable customizer classes pane. + * + * @param model + * A model prepresenting the class path entries. + * + * @return A Component representing the classes pane. + * + * @throws NullPointerException + * If null model is passed in. + */ + public static Component createClassesCustomizer(PathModel model) { + if (model == null) { + throw new NullPointerException(); + } + return new PathView(model, CLASSPATH, null); + } + + /** + * Creates an editable customizer sources pane. + * + * @param model + * A model prepresenting the source path entries. + * @param currentDir + * Add sources file chooser current directory. Passing in a null represents the user's default directory. + * + * @return A Component representing the sources pane. + * + * @throws NullPointerException + * If null model is passed in. + */ + public static Component createSourcesCustomizer(PathModel model, File currentDir) { + if (model == null) { + throw new NullPointerException(); + } + return new PathView(model, SOURCES, currentDir); + } + + /** + * Creates an editable customizer javadoc pane. + * + * @param model + * A model prepresenting the javadoc entries. + * @param currentDir + * Add javadoc file chooser current directory. Passing in a null represents the user's default directory. + * + * @return A Component representing the javadoc pane. + * + * @throws NullPointerException + * If null model is passed in. + */ + public static Component createJavadocCustomizer(PathModel model, File currentDir) { + if (model == null) { + throw new NullPointerException(); + } + return new PathView(model, JAVADOC, currentDir); + } + + /** + * Creates an Ant-style path specification from the specified list of URLs. + * + * @param The + * list of URLs. + * + * @return An Ant-style path specification. + */ + public static String buildPath(List path) { + String PATH_SEPARATOR = System.getProperty("path.separator"); // NOI18N + StringBuffer sb = new StringBuffer(path.size() * 16); + for (Iterator i = path.iterator(); i.hasNext();) { + sb.append(urlToString(i.next())); + if (i.hasNext()) { + sb.append(PATH_SEPARATOR); + } + } + return sb.toString(); + } + + /** + * Splits an Ant-style path specification into the list of URLs. Tokenizes on : and ;, + * paying attention to DOS-style components such as C:\FOO. Also removes any empty components. + * + * @param path + * An Ant-style path (elements arbitrary) using DOS or Unix separators + * + * @return A tokenization of the specified path into the list of URLs. + */ + public static List tokenizePath(String path) { + try { + List l = new ArrayList(); + StringTokenizer tok = new StringTokenizer(path, ":;", true); // NOI18N + char dosHack = '\0'; + char lastDelim = '\0'; + int delimCount = 0; + while (tok.hasMoreTokens()) { + String s = tok.nextToken(); + if (s.length() == 0) { + // Strip empty components. + continue; + } + if (s.length() == 1) { + char c = s.charAt(0); + if (c == ':' || c == ';') { + // Just a delimiter. + lastDelim = c; + delimCount++; + continue; + } + } + if (dosHack != '\0') { + // #50679 - "C:/something" is also accepted as DOS path + if (lastDelim == ':' && delimCount == 1 && (s.charAt(0) == '\\' || s.charAt(0) == '/')) { + // We had a single letter followed by ':' now followed + // by \something or /something + s = "" + dosHack + ':' + s; + // and use the new token with the drive prefix... + } else { + // Something else, leave alone. + l.add(fileToUrl(new File(Character.toString(dosHack)))); + // and continue with this token too... + } + dosHack = '\0'; + } + // Reset count of # of delimiters in a row. + delimCount = 0; + if (s.length() == 1) { + char c = s.charAt(0); + if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) { + // Probably a DOS drive letter. Leave it with the next + // component. + dosHack = c; + continue; + } + } + l.add(fileToUrl(new File(s))); + } + if (dosHack != '\0') { + // the dosHack was the last letter in the input string (not + // followed by the ':') + // so obviously not a drive letter. + // Fix for issue #57304 + l.add(fileToUrl(new File(Character.toString(dosHack)))); + } + return l; + } catch (MalformedURLException e) { + ErrorManager.getDefault().notify(e); + return new ArrayList(); + } + } + + /** Return URL representation of the specified file. */ + private static URL fileToUrl(File file) throws MalformedURLException { + URL url = file.toURI().toURL(); + if (FileUtil.isArchiveFile(url)) { + url = FileUtil.getArchiveRoot(url); + } + return url; + } + + /** Return string representation of the specified URL. */ + private static String urlToString(URL url) { + if ("jar".equals(url.getProtocol())) { // NOI18N + URL fileURL = FileUtil.getArchiveFile(url); + if (FileUtil.getArchiveRoot(fileURL).equals(url)) { + // really the root + url = fileURL; + } else { + // some subdir, just show it as is + return url.toExternalForm(); + } + } + if ("file".equals(url.getProtocol())) { // NOI18N + File f = new File(URI.create(url.toExternalForm())); + return f.getAbsolutePath(); + } else { + return url.toExternalForm(); + } + } + + /** + * Path list model, supports adding, removing and moving URL entries in the list. + */ + public static final class PathModel extends AbstractListModel { + + private final List data; + + /** + * Creates a new PathModel initialized with a list of URL entries. + * + * @param data + * The list of URL entries. + * + * @throws NullPointerException + * If null data attribute is passed in. + */ + public PathModel(List data) { + if (data == null) { + throw new NullPointerException("The data attribute must not be null."); // NOI18N + } + this.data = data; + } + + /** + * Returns the number of URL entries in the list. + * + * return The number of URL entries in the list. + */ + public int getSize() { + return data.size(); + } + + /** + * Returns the element at the specified position in this list. + * + * @param index + * The element position in the list. + * + * @return The element at the specified position in this list. + */ + public Object getElementAt(int index) { + URL url = data.get(index); + if ("jar".equals(url.getProtocol())) { // NOI18N + URL fileURL = FileUtil.getArchiveFile(url); + if (FileUtil.getArchiveRoot(fileURL).equals(url)) { + // really the root + url = fileURL; + } else { + // some subdir, just show it as is + return url.toExternalForm(); + } + } + if ("file".equals(url.getProtocol())) { // NOI18N + File f = new File(URI.create(url.toExternalForm())); + return f.getAbsolutePath(); + } else { + return url.toExternalForm(); + } + } + + /** + * Removes the URL entries denotated with their respective indices from the list. + */ + public void removePath(int[] indices) { + for (int i = indices.length - 1; i >= 0; i--) { + data.remove(indices[i]); + } + fireIntervalRemoved(this, indices[0], indices[indices.length - 1]); + } + + /** + * Moves the URL entries denotated with their respective indices up in the list. + */ + public void moveUpPath(int[] indices) { + for (int i = 0; i < indices.length; i++) { + URL p2 = data.get(indices[i]); + URL p1 = data.set(indices[i] - 1, p2); + data.set(indices[i], p1); + } + fireContentsChanged(this, indices[0] - 1, indices[indices.length - 1]); + } + + /** + * Moves the URL entries denotated with their respective indices down in the list. + */ + public void moveDownPath(int[] indices) { + for (int i = indices.length - 1; i >= 0; i--) { + URL p1 = data.get(indices[i]); + URL p2 = data.set(indices[i] + 1, p1); + data.set(indices[i], p2); + } + fireContentsChanged(this, indices[0], indices[indices.length - 1] + 1); + } + + /** + * Appends the URL representing the specified file to the end of the list. + * + * @return true if the URL was appended, false otherwise. + */ + public boolean addPath(File f) { + try { + URL url = f.toURI().toURL(); + return this.addPath(url); + } catch (MalformedURLException mue) { + return false; + } + } + + /** + * Appends the specified URL to the end of the list. + * + * @return true if the URL was appended, false otherwise. + */ + public boolean addPath(URL url) { + if (FileUtil.isArchiveFile(url)) { + url = FileUtil.getArchiveRoot(url); + } else if (!url.toExternalForm().endsWith("/")) { // NOI18N + try { + url = new URL(url.toExternalForm() + "/"); // NOI18N + } catch (MalformedURLException mue) { + ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, mue); + } + } + int oldSize = data.size(); + data.add(url); + fireIntervalAdded(this, oldSize, oldSize); + return true; + } + + /** + * Returns the list of URL entries. + * + * @return The list of URL entries. + */ + public List getData() { + return data; + } + } + + // private helper classes ------------------------------------------------- + + private static class PathView extends JPanel { + + private JList resources; + private JButton addButton; + private JButton addURLButton; + private JButton removeButton; + private JButton moveUpButton; + private JButton moveDownButton; + private File currentDir; + private String type; + + public PathView(PathModel model, String type, File currentDir) { + this.type = type; + this.currentDir = currentDir; + initComponents(model); + } + + private void initComponents(PathModel model) { + setLayout(new GridBagLayout()); + JLabel label = new JLabel(); + String key = null; + String mneKey = null; + String ad = null; + if (type.equals(CLASSPATH)) { + key = "TXT_Classes"; // NOI18N + mneKey = "MNE_Classes"; // NOI18N + ad = "AD_Classes"; // NOI18N + } else if (type.equals(SOURCES)) { + key = "TXT_Sources"; // NOI18N + mneKey = "MNE_Sources"; // NOI18N + ad = "AD_Sources"; // NOI18N + } else if (type.equals(JAVADOC)) { + key = "TXT_Javadoc"; // NOI18N + mneKey = "MNE_Javadoc"; // NOI18N + ad = "AD_Javadoc"; // NOI18N + } else { + assert false : "Illegal type of panel"; // NOI18N + return; + } + label.setText(NbBundle.getMessage(CustomizerSupport.class, key)); + label.setDisplayedMnemonic(NbBundle.getMessage(CustomizerSupport.class, mneKey).charAt(0)); + GridBagConstraints c = new GridBagConstraints(); + c.gridx = GridBagConstraints.RELATIVE; + c.gridy = GridBagConstraints.RELATIVE; + c.gridwidth = GridBagConstraints.REMAINDER; + c.insets = new Insets(6, 12, 2, 0); + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1.0; + ((GridBagLayout) getLayout()).setConstraints(label, c); + add(label); + resources = new JList(model); + label.setLabelFor(resources); + resources.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerSupport.class, ad)); + resources.addListSelectionListener(new ListSelectionListener() { + public void valueChanged(ListSelectionEvent e) { + selectionChanged(); + } + }); + JScrollPane spane = new JScrollPane(this.resources); + // set the preferred size so that the size won't be set according to + // the longest row in the list by default + spane.setPreferredSize(new java.awt.Dimension(200, 100)); + c = new GridBagConstraints(); + c.gridx = GridBagConstraints.RELATIVE; + c.gridy = GridBagConstraints.RELATIVE; + c.gridwidth = 1; + c.gridheight = 5; + c.insets = new Insets(0, 12, 12, 6); + c.fill = GridBagConstraints.BOTH; + c.weightx = 1.0; + c.weighty = 1.0; + ((GridBagLayout) this.getLayout()).setConstraints(spane, c); + add(spane); + if (type == SOURCES || type == JAVADOC) { + this.addButton = new JButton(); + String text; + char mne; + if (type == SOURCES) { + text = NbBundle.getMessage(CustomizerSupport.class, "CTL_Add"); + mne = NbBundle.getMessage(CustomizerSupport.class, "MNE_Add").charAt(0); + ad = NbBundle.getMessage(CustomizerSupport.class, "AD_Add"); + } else { + text = NbBundle.getMessage(CustomizerSupport.class, "CTL_AddZip"); + mne = NbBundle.getMessage(CustomizerSupport.class, "MNE_AddZip").charAt(0); + ad = NbBundle.getMessage(CustomizerSupport.class, "AD_AddZip"); + } + this.addButton.setText(text); + this.addButton.setMnemonic(mne); + this.addButton.getAccessibleContext().setAccessibleDescription(ad); + addButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + addPathElement(); + } + }); + c = new GridBagConstraints(); + c.gridx = 1; + c.gridy = 1; + c.gridwidth = GridBagConstraints.REMAINDER; + c.fill = GridBagConstraints.HORIZONTAL; + c.anchor = GridBagConstraints.NORTHWEST; + c.insets = new Insets(0, 6, 0, 6); + ((GridBagLayout) this.getLayout()).setConstraints(addButton, c); + this.add(addButton); + // if (this.type == JAVADOC) { + // addURLButton = new JButton + // (NbBundle.getMessage(CustomizerSupport.class, "CTL_AddURL")); + // addURLButton.setMnemonic(NbBundle.getMessage(CustomizerSupport.class, + // "MNE_AddURL").charAt(0)); + // addURLButton.addActionListener(new ActionListener () { + // public void actionPerformed(ActionEvent e) { + // addURLElement (); + // } + // }); + // c = new GridBagConstraints(); + // c.gridx = 1; + // c.gridy = 2; + // c.gridwidth = GridBagConstraints.REMAINDER; + // c.fill = GridBagConstraints.HORIZONTAL; + // c.anchor = GridBagConstraints.NORTHWEST; + // c.insets = new Insets (0,6,6,12); + // ((GridBagLayout)this.getLayout()).setConstraints(addURLButton,c); + // this.add (addURLButton); + // } + removeButton = new JButton(NbBundle.getMessage(CustomizerSupport.class, "CTL_Remove")); + removeButton.setMnemonic(NbBundle.getMessage(CustomizerSupport.class, "MNE_Remove").charAt(0)); + removeButton.getAccessibleContext().setAccessibleDescription( + NbBundle.getMessage(CustomizerSupport.class, "AD_Remove")); + removeButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + removePathElement(); + } + }); + removeButton.setEnabled(false); + c = new GridBagConstraints(); + c.gridx = 1; + c.gridy = 3; + c.gridwidth = GridBagConstraints.REMAINDER; + c.fill = GridBagConstraints.HORIZONTAL; + c.anchor = GridBagConstraints.NORTHWEST; + c.insets = new Insets(12, 6, 0, 6); + ((GridBagLayout) this.getLayout()).setConstraints(removeButton, c); + this.add(removeButton); + moveUpButton = new JButton(NbBundle.getMessage(CustomizerSupport.class, "CTL_Up")); + moveUpButton.setMnemonic(NbBundle.getMessage(CustomizerSupport.class, "MNE_Up").charAt(0)); + moveUpButton.getAccessibleContext().setAccessibleDescription( + NbBundle.getMessage(CustomizerSupport.class, "AD_Up")); + moveUpButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + moveUpPathElement(); + } + }); + moveUpButton.setEnabled(false); + c = new GridBagConstraints(); + c.gridx = 1; + c.gridy = 4; + c.gridwidth = GridBagConstraints.REMAINDER; + c.fill = GridBagConstraints.HORIZONTAL; + c.anchor = GridBagConstraints.NORTHWEST; + c.insets = new Insets(12, 6, 0, 6); + ((GridBagLayout) this.getLayout()).setConstraints(moveUpButton, c); + this.add(moveUpButton); + moveDownButton = new JButton(NbBundle.getMessage(CustomizerSupport.class, "CTL_Down")); + moveDownButton.setMnemonic(NbBundle.getMessage(CustomizerSupport.class, "MNE_Down").charAt(0)); + moveDownButton.getAccessibleContext().setAccessibleDescription( + NbBundle.getMessage(CustomizerSupport.class, "AD_Down")); + moveDownButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + moveDownPathElement(); + } + }); + moveDownButton.setEnabled(false); + c = new GridBagConstraints(); + c.gridx = 1; + c.gridy = 5; + c.gridwidth = GridBagConstraints.REMAINDER; + c.fill = GridBagConstraints.HORIZONTAL; + c.anchor = GridBagConstraints.NORTHWEST; + c.insets = new Insets(5, 6, 6, 6); + ((GridBagLayout) this.getLayout()).setConstraints(moveDownButton, c); + this.add(moveDownButton); + } + } + + // private void addURLElement() { + // JPanel p = new JPanel (); + // GridBagLayout lm = new GridBagLayout(); + // p.setLayout (lm); + // GridBagConstraints c = new GridBagConstraints (); + // c.gridx = c.gridy = GridBagConstraints.RELATIVE; + // c.insets = new Insets (12,12,12,6); + // c.anchor = GridBagConstraints.NORTHWEST; + // JLabel label = new JLabel + // (NbBundle.getMessage(CustomizerSupport.class,"CTL_AddJavadocURLMessage")); + // label.setDisplayedMnemonic ('U'); + // lm.setConstraints(label,c); + // p.add (label); + // c = new GridBagConstraints (); + // c.gridx = c.gridy = GridBagConstraints.RELATIVE; + // c.gridwidth = GridBagConstraints.REMAINDER; + // c.insets = new Insets (12,0,12,6); + // c.fill = GridBagConstraints.HORIZONTAL; + // c.anchor = GridBagConstraints.NORTHWEST; + // JTextField text = new JTextField (); + // text.setColumns(30); + // text.setText + // (NbBundle.getMessage(CustomizerSupport.class,"TXT_DefaultProtocol")); + // text.selectAll(); + // label.setLabelFor(text); + // lm.setConstraints(text,c); + // p.add (text); + // JButton[] options = new JButton[] { + // new JButton + // (NbBundle.getMessage(CustomizerSupport.class,"CTL_AddJavadocURLTitle")), + // new JButton + // (NbBundle.getMessage(CustomizerSupport.class,"CTL_Cancel")) + // }; + // options[0].setMnemonic(NbBundle.getMessage(CustomizerSupport.class,"MNE_Add").charAt(0)); + // options[1].setMnemonic(NbBundle.getMessage(CustomizerSupport.class,"MNE_Cancel").charAt(0)); + // DialogDescriptor input = new DialogDescriptor ( + // p, + // NbBundle.getMessage(CustomizerSupport.class,"CTL_AddJavadocURLTitle"), + // true, options, options[0], DialogDescriptor.DEFAULT_ALIGN, null, + // null); + // if (DialogDisplayer.getDefault().notify(input) == options[0]) { + // try { + // String value = text.getText(); + // URL url = new URL (value); + // ((PathModel)this.resources.getModel()).addPath(url); + // this.resources.setSelectedIndex + // (this.resources.getModel().getSize()-1); + // } catch (MalformedURLException mue) { + // DialogDescriptor.Message message = new DialogDescriptor.Message ( + // NbBundle.getMessage(CustomizerSupport.class,"CTL_InvalidURLFormat"), + // DialogDescriptor.ERROR_MESSAGE); + // DialogDisplayer.getDefault().notify(message); + // } + // } + // } + + private void addPathElement() { + JFileChooser chooser = new JFileChooser(); + FileUtil.preventFileChooserSymlinkTraversal(chooser, null); + chooser.setMultiSelectionEnabled(true); + String title = null; + String message = null; + String approveButtonName = null; + String approveButtonNameMne = null; + if (this.type == SOURCES) { + title = NbBundle.getMessage(CustomizerSupport.class, "TXT_OpenSources"); + message = NbBundle.getMessage(CustomizerSupport.class, "TXT_Sources"); + approveButtonName = NbBundle.getMessage(CustomizerSupport.class, "TXT_OpenSources"); + approveButtonNameMne = NbBundle.getMessage(CustomizerSupport.class, "MNE_OpenSources"); + } else if (this.type == JAVADOC) { + title = NbBundle.getMessage(CustomizerSupport.class, "TXT_OpenJavadoc"); + message = NbBundle.getMessage(CustomizerSupport.class, "TXT_Javadoc"); + approveButtonName = NbBundle.getMessage(CustomizerSupport.class, "TXT_OpenJavadoc"); + approveButtonNameMne = NbBundle.getMessage(CustomizerSupport.class, "MNE_OpenJavadoc"); + } + chooser.setDialogTitle(title); + chooser.setApproveButtonText(approveButtonName); + chooser.setApproveButtonMnemonic(approveButtonNameMne.charAt(0)); + chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); + // #61789 on old macosx (jdk 1.4.1) these two method need to be + // called in this order. + chooser.setAcceptAllFileFilterUsed(false); + chooser.setFileFilter(new SimpleFileFilter(message, new String[] { "ZIP", "JAR" })); // NOI18N + if (this.currentDir != null && currentDir.exists()) { + chooser.setCurrentDirectory(this.currentDir); + } + if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { + File[] fs = chooser.getSelectedFiles(); + PathModel model = (PathModel) this.resources.getModel(); + boolean addingFailed = false; + int firstIndex = this.resources.getModel().getSize(); + for (int i = 0; i < fs.length; i++) { + File f = fs[i]; + // XXX: JFileChooser workaround (JDK bug #5075580), double + // click on folder returns wrong file + // E.g. for /foo/src it returns /foo/src/src + // Try to convert it back by removing last invalid name + // component + if (!f.exists()) { + File parent = f.getParentFile(); + if (parent != null && f.getName().equals(parent.getName()) && parent.exists()) { + f = parent; + } + } + addingFailed |= !model.addPath(f); + } + if (addingFailed) { + new NotifyDescriptor.Message(NbBundle.getMessage(CustomizerSupport.class, "TXT_CanNotAddResolve"), + NotifyDescriptor.ERROR_MESSAGE); + } + int lastIndex = this.resources.getModel().getSize() - 1; + if (firstIndex <= lastIndex) { + int[] toSelect = new int[lastIndex - firstIndex + 1]; + for (int i = 0; i < toSelect.length; i++) { + toSelect[i] = firstIndex + i; + } + this.resources.setSelectedIndices(toSelect); + } + this.currentDir = FileUtil.normalizeFile(chooser.getCurrentDirectory()); + } + } + + private void removePathElement() { + int[] indices = this.resources.getSelectedIndices(); + if (indices.length == 0) { + return; + } + PathModel model = (PathModel) this.resources.getModel(); + model.removePath(indices); + if (indices[indices.length - 1] - indices.length + 1 < this.resources.getModel().getSize()) { + this.resources.setSelectedIndex(indices[indices.length - 1] - indices.length + 1); + } else if (indices[0] > 0) { + this.resources.setSelectedIndex(indices[0] - 1); + } + } + + private void moveDownPathElement() { + int[] indices = this.resources.getSelectedIndices(); + if (indices.length == 0) { + return; + } + PathModel model = (PathModel) this.resources.getModel(); + model.moveDownPath(indices); + for (int i = 0; i < indices.length; i++) { + indices[i] = indices[i] + 1; + } + this.resources.setSelectedIndices(indices); + } + + private void moveUpPathElement() { + int[] indices = this.resources.getSelectedIndices(); + if (indices.length == 0) { + return; + } + PathModel model = (PathModel) this.resources.getModel(); + model.moveUpPath(indices); + for (int i = 0; i < indices.length; i++) { + indices[i] = indices[i] - 1; + } + this.resources.setSelectedIndices(indices); + } + + private void selectionChanged() { + if (this.type == CLASSPATH) { + return; + } + int indices[] = this.resources.getSelectedIndices(); + this.removeButton.setEnabled(indices.length > 0); + this.moveUpButton.setEnabled(indices.length > 0 && indices[0] > 0); + this.moveDownButton.setEnabled(indices.length > 0 + && indices[indices.length - 1] < this.resources.getModel().getSize() - 1); + } + } + + private static class SimpleFileFilter extends FileFilter { + + private String description; + private Collection extensions; + + public SimpleFileFilter(String description, String[] extensions) { + this.description = description; + this.extensions = Arrays.asList(extensions); + } + + public boolean accept(File f) { + if (f.isDirectory()) + return true; + String name = f.getName(); + int index = name.lastIndexOf('.'); // NOI18N + if (index <= 0 || index == name.length() - 1) + return false; + String extension = name.substring(index + 1).toUpperCase(); + return this.extensions.contains(extension); + } + + public String getDescription() { + return this.description; + } + } +} Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerSupport.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerSupport.java ------------------------------------------------------------------------------ svn:executable = * Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerSupport.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/customizer/CustomizerSupport.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoDeploymentStatus.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoDeploymentStatus.java?view=auto&rev=549644 ============================================================================== --- geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoDeploymentStatus.java (added) +++ geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoDeploymentStatus.java Thu Jun 21 16:18:31 2007 @@ -0,0 +1,51 @@ +package org.apache.geronimo.netbeans.ide; + +import javax.enterprise.deploy.shared.ActionType; +import javax.enterprise.deploy.shared.CommandType; +import javax.enterprise.deploy.shared.StateType; +import javax.enterprise.deploy.spi.status.DeploymentStatus; + +public class GeronimoDeploymentStatus implements DeploymentStatus { + + private ActionType action; + private CommandType command; + private StateType state; + + private String message; + + public GeronimoDeploymentStatus(ActionType action, CommandType command, StateType state, String message) { + this.action = action; + this.command = command; + this.state = state; + this.message = message; + } + + public String getMessage() { + return message; + } + + public StateType getState() { + return state; + } + + public CommandType getCommand() { + return command; + } + + public ActionType getAction() { + return action; + } + + public boolean isRunning() { + return StateType.RUNNING.equals(state); + } + + public boolean isFailed() { + return StateType.FAILED.equals(state); + } + + public boolean isCompleted() { + return StateType.COMPLETED.equals(state); + } + +} \ No newline at end of file Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoDeploymentStatus.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoDeploymentStatus.java ------------------------------------------------------------------------------ svn:executable = * Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoDeploymentStatus.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoDeploymentStatus.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoJ2eePlatformFactory.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoJ2eePlatformFactory.java?view=auto&rev=549644 ============================================================================== --- geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoJ2eePlatformFactory.java (added) +++ geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoJ2eePlatformFactory.java Thu Jun 21 16:18:31 2007 @@ -0,0 +1,251 @@ +package org.apache.geronimo.netbeans.ide; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.Iterator; +import java.util.List; +import java.util.WeakHashMap; +import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform; +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashSet; +import java.util.Set; +import org.netbeans.modules.j2ee.deployment.common.api.J2eeLibraryTypeProvider; +import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule; +import org.netbeans.modules.j2ee.deployment.plugins.spi.J2eePlatformFactory; +import org.netbeans.modules.j2ee.deployment.plugins.spi.J2eePlatformImpl; +import org.netbeans.spi.project.libraries.LibraryImplementation; +import org.openide.ErrorManager; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileStateInvalidException; +import org.openide.filesystems.FileUtil; +import org.openide.filesystems.URLMapper; +import org.openide.util.NbBundle; +import javax.enterprise.deploy.spi.DeploymentManager; +import java.io.FilenameFilter; +import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; +import org.apache.geronimo.netbeans.GeronimoDeploymentManager; +import org.apache.geronimo.netbeans.util.GeronimoProperties; +import org.netbeans.api.java.platform.JavaPlatform; +import org.openide.modules.InstalledFileLocator; +import org.openide.util.Utilities; + +public class GeronimoJ2eePlatformFactory extends J2eePlatformFactory { + + private static final WeakHashMap instanceCache = new WeakHashMap(); + + public synchronized J2eePlatformImpl getJ2eePlatformImpl(DeploymentManager dm) { + assert GeronimoDeploymentManager.class.isAssignableFrom(dm.getClass()) : this + + " cannot create platform for unknown deployment manager:" + dm; + // Ensure that for each server instance will be always used the same + // instance of the J2eePlatformImpl + GeronimoDeploymentManager manager = (GeronimoDeploymentManager) dm; + InstanceProperties ip = manager.getInstanceProperties(); + if (ip == null) { + throw new RuntimeException("Cannot create J2eePlatformImpl instance for " + manager.getUrl()); + } + J2eePlatformImplImpl platform = instanceCache.get(ip); + if (platform == null) { + platform = new J2eePlatformImplImpl(manager.getProperties()); + instanceCache.put(ip, platform); + } + return platform; + } + + public static class J2eePlatformImplImpl extends J2eePlatformImpl { + private static final String J2EE_API_DOC = "docs/javaee5-doc-api.zip"; // NOI18N + private static final Set MODULE_TYPES = new HashSet(); + static { + MODULE_TYPES.add(J2eeModule.EAR); + MODULE_TYPES.add(J2eeModule.WAR); + MODULE_TYPES.add(J2eeModule.EJB); + MODULE_TYPES.add(J2eeModule.CONN); + MODULE_TYPES.add(J2eeModule.CLIENT); + } + + private static final Set SPEC_VERSIONS = new HashSet(); + static { + SPEC_VERSIONS.add(J2eeModule.J2EE_14); + SPEC_VERSIONS.add(J2eeModule.JAVA_EE_5); + } + + private LibraryImplementation[] libraries; + + private static final String ICON = "org/apache/geronimo/netbeans/resources/16x16.gif"; + + private final GeronimoProperties properties; + + public J2eePlatformImplImpl(GeronimoProperties properties) { + this.properties = properties; + } + + public Set getSupportedSpecVersions() { + return SPEC_VERSIONS; + } + + public Set getSupportedSpecVersions(Object moduleType) { + return SPEC_VERSIONS; + } + + public Set getSupportedModuleTypes() { + return MODULE_TYPES; + } + + public Set/* */getSupportedJavaPlatformVersions() { + Set versions = new HashSet(); + versions.add("1.4"); // NOI18N + versions.add("1.5"); // NOI18N + return versions; + } + + public JavaPlatform getJavaPlatform() { + return null; + } + + public File[] getPlatformRoots() { + return new File[] { properties.getServerDir() }; + } + + private static class FF implements FilenameFilter { + public boolean accept(File dir, String name) { + return name.endsWith(".jar") || new File(dir, name).isDirectory(); // NOI18N + } + } + + public LibraryImplementation[] getLibraries() { + if (libraries == null) { + initLibraries(); + } + return libraries; + } + + public void notifyLibrariesChanged() { + initLibraries(); + firePropertyChange(PROP_LIBRARIES, null, libraries.clone()); + } + + public java.awt.Image getIcon() { + return Utilities.loadImage(ICON); + } + + public String getDisplayName() { + return NbBundle.getMessage(GeronimoJ2eePlatformFactory.class, "TITLE_GERONIMO_FACTORY"); + + } + + public boolean isToolSupported(String toolName) { + return true; + } + + private boolean containsPersistenceProvider(String providerName) { + return containsService(libraries, "javax.persistence.spi.PersistenceProvider", providerName); + } + + private static boolean containsService(LibraryImplementation[] libraries, String serviceName, + String serviceImplName) { + for (LibraryImplementation libImpl : libraries) { + if (containsService(libImpl, serviceName, serviceImplName)) { // NOI18N + return true; + } + } + return false; + } + + private static boolean containsService(LibraryImplementation library, String serviceName, String serviceImplName) { + List roots = library.getContent(J2eeLibraryTypeProvider.VOLUME_TYPE_CLASSPATH); + for (Iterator it = roots.iterator(); it.hasNext();) { + URL rootUrl = (URL) it.next(); + FileObject root = URLMapper.findFileObject(rootUrl); + if (root != null && "jar".equals(rootUrl.getProtocol())) { // NOI18N + FileObject archiveRoot = FileUtil.getArchiveRoot(FileUtil.getArchiveFile(root)); + String serviceRelativePath = "META-INF/services/" + serviceName; // NOI18N + FileObject serviceFO = archiveRoot.getFileObject(serviceRelativePath); + if (serviceFO != null && containsService(serviceFO, serviceName, serviceImplName)) { + return true; + } + } + } + return false; + } + + private static boolean containsService(FileObject serviceFO, String serviceName, String serviceImplName) { + try { + BufferedReader br = new BufferedReader(new InputStreamReader(serviceFO.getInputStream())); + String line; + while ((line = br.readLine()) != null) { + int ci = line.indexOf('#'); + if (ci >= 0) + line = line.substring(0, ci); + if (line.trim().equals(serviceImplName)) { + return true; + } + } + } catch (Exception ex) { + try { + ErrorManager.getDefault().annotate(ex, serviceFO.getURL().toString()); + } catch (FileStateInvalidException fsie) { + // noop + } + ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); + } + return false; + } + + public File[] getToolClasspathEntries(String toolName) { + if (J2eePlatform.TOOL_WSCOMPILE.equals(toolName)) { + File root = InstalledFileLocator.getDefault().locate("modules/ext/jaxrpc16", null, false); // NOI18N + return new File[] { new File(root, "saaj-api.jar"), // NOI18N + new File(root, "saaj-impl.jar"), // NOI18N + new File(root, "jaxrpc-api.jar"), // NOI18N + new File(root, "jaxrpc-impl.jar"), // NOI18N + }; + } + if (J2eePlatform.TOOL_APP_CLIENT_RUNTIME.equals(toolName)) { + return new File(properties.getServerDir(), "client").listFiles(new FF()); // NOI18N + } + return null; + } + + // copied from appserv plugin + private URL fileToUrl(File file) throws MalformedURLException { + URL url = file.toURI().toURL(); + if (FileUtil.isArchiveFile(url)) { + url = FileUtil.getArchiveRoot(url); + } + return url; + } + + public String getToolProperty(String toolName, String propertyName) { + if (J2eePlatform.TOOL_APP_CLIENT_RUNTIME.equals(toolName)) { + if (J2eePlatform.TOOL_PROP_MAIN_CLASS.equals(propertyName)) { + return ""; // NOI18N + } + if (J2eePlatform.TOOL_PROP_MAIN_CLASS_ARGS.equals(propertyName)) { + return ""; // NOI18N + } + if ("j2ee.clientName".equals(propertyName)) { // NOI18N + return "${jar.name}"; // NOI18N + } + if (J2eePlatform.TOOL_PROP_JVM_OPTS.equals(propertyName)) { + return "-Djava.naming.factory.initial=org.FIXME.NamingContextFactory" // NOI18N + + " -Djava.naming.provider.url=FIXME"; + } + } + return null; + } + + // private helper methods + // ------------------------------------------------- + + private void initLibraries() { + // create library + LibraryImplementation lib = new J2eeLibraryTypeProvider().createLibrary(); + lib.setName(NbBundle.getMessage(GeronimoJ2eePlatformFactory.class, "LIBRARY_TITLE")); + lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_CLASSPATH, properties.getClasses()); + lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_JAVADOC, properties.getJavadocs()); + lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_SRC, properties.getSources()); + libraries = new LibraryImplementation[] { lib }; + } + } +} Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoJ2eePlatformFactory.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoJ2eePlatformFactory.java ------------------------------------------------------------------------------ svn:executable = * Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoJ2eePlatformFactory.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoJ2eePlatformFactory.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoOptionalDeploymentManagerFactory.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoOptionalDeploymentManagerFactory.java?view=auto&rev=549644 ============================================================================== --- geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoOptionalDeploymentManagerFactory.java (added) +++ geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoOptionalDeploymentManagerFactory.java Thu Jun 21 16:18:31 2007 @@ -0,0 +1,45 @@ +package org.apache.geronimo.netbeans.ide; + +import javax.enterprise.deploy.spi.DeploymentManager; + +import org.apache.geronimo.netbeans.ide.ui.GeronimoInstantiatingIterator; +import org.netbeans.modules.j2ee.deployment.plugins.spi.DatasourceManager; +import org.netbeans.modules.j2ee.deployment.plugins.spi.FindJSPServlet; +import org.netbeans.modules.j2ee.deployment.plugins.spi.IncrementalDeployment; +import org.netbeans.modules.j2ee.deployment.plugins.spi.OptionalDeploymentManagerFactory; +import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer; +import org.openide.WizardDescriptor.InstantiatingIterator; + +/** + * An entry point to the plugin's optional functionality, such as server + * start/stop, incremental deployment, custom wizard for instance addition and + * the ability to locate the servlet for a jsp page. + * + * Factory for optional deployment functionality that a plugin can provide. + * Plugins need to register an instance of this class in module layer in folder J2EE/DeploymentPlugins/{plugin_name}. + * + * @version $Rev$ $Date$ + */ +public class GeronimoOptionalDeploymentManagerFactory extends OptionalDeploymentManagerFactory { + + public StartServer getStartServer(DeploymentManager dm) { + return new GeronimoStartServer(dm); + } + + public IncrementalDeployment getIncrementalDeployment(DeploymentManager dm) { + return null; + } + + public FindJSPServlet getFindJSPServlet(DeploymentManager dm) { + throw new IllegalArgumentException(""); + } + + public InstantiatingIterator getAddInstanceIterator() { + return new GeronimoInstantiatingIterator(); + } + + public DatasourceManager getDatasourceManager(DeploymentManager dm) { + throw new IllegalArgumentException(""); + } + +} Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoOptionalDeploymentManagerFactory.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoOptionalDeploymentManagerFactory.java ------------------------------------------------------------------------------ svn:executable = * Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoOptionalDeploymentManagerFactory.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/ide/GeronimoOptionalDeploymentManagerFactory.java ------------------------------------------------------------------------------ svn:mime-type = text/plain