diff -r 40294f922719 db.core/src/org/netbeans/modules/db/sql/execute/ui/SQLHistoryPanel.form --- a/db.core/src/org/netbeans/modules/db/sql/execute/ui/SQLHistoryPanel.form Fri Sep 04 22:43:11 2009 +0200 +++ b/db.core/src/org/netbeans/modules/db/sql/execute/ui/SQLHistoryPanel.form Sun Sep 06 23:11:37 2009 +0100 @@ -1,6 +1,9 @@
+ + + @@ -21,7 +24,7 @@ - + @@ -37,7 +40,7 @@ - + diff -r 40294f922719 db.core/src/org/netbeans/modules/db/sql/execute/ui/SQLHistoryPanel.java --- a/db.core/src/org/netbeans/modules/db/sql/execute/ui/SQLHistoryPanel.java Fri Sep 04 22:43:11 2009 +0200 +++ b/db.core/src/org/netbeans/modules/db/sql/execute/ui/SQLHistoryPanel.java Sun Sep 06 23:11:37 2009 +0100 @@ -51,12 +51,15 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.File; +import java.io.IOException; import java.text.DateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.DefaultComboBoxModel; @@ -90,9 +93,13 @@ import org.netbeans.modules.db.sql.history.SQLHistoryPersistenceManager; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; +import org.openide.loaders.DataObject; +import org.openide.loaders.XMLDataObject; import org.openide.util.Exceptions; import org.openide.util.NbBundle; import org.openide.util.NbPreferences; +import org.w3c.dom.Node; +import org.xml.sax.SAXException; /** * @@ -115,12 +122,15 @@ private SQLHistoryView view; private JEditorPane editorPane; private String currentUrl; + private Map urlAliasMap = new HashMap(); + private Map aliasUrlMap = new HashMap(); /** Creates new form SQLHistoryPanel */ public SQLHistoryPanel(final JEditorPane editorPane) { this.editorPane = editorPane; historyFilePath = FileUtil.getFileDisplayName(historyRoot) + File.separator + SQL_HISTORY_FILE_NAME + ".xml"; // NOI18N view = new SQLHistoryView(new SQLHistoryModelImpl()); + initKnownConnectionNames(); initSQLHistoryTableData(); initComponents(); initComponentData(); @@ -133,7 +143,43 @@ } }); } - + + private void initKnownConnectionNames() { + FileObject configFile = FileUtil.getConfigFile("Databases/Connections"); + for (FileObject o : configFile.getChildren()) { + if ("text/xml".equals(o.getMIMEType())) { + try { + XMLDataObject connectionData = DataObject.find(o).getLookup().lookup(XMLDataObject.class); + if (connectionData != null) { + String displayName = null; + String defaultName = null; + Node connectionPropertyNode = connectionData.getDocument().getFirstChild(); + while (connectionPropertyNode != null) { + Node propNode = connectionPropertyNode.getFirstChild(); + while (propNode != null) { + if ("database-url".equals(propNode.getNodeName())) { + defaultName = propNode.getAttributes().getNamedItem("value").getTextContent(); + } else if ("display-name".equals(propNode.getNodeName())) { + displayName = propNode.getAttributes().getNamedItem("value").getTextContent(); + } + propNode = propNode.getNextSibling(); + } + connectionPropertyNode = connectionPropertyNode.getNextSibling(); + } + if (displayName != null && defaultName != null) { + urlAliasMap.put(defaultName, displayName); + aliasUrlMap.put(displayName, defaultName); + } + } + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } catch (SAXException ex) { + Exceptions.printStackTrace(ex); + } + } + } + } + private void setupSQLSaveLimit() { // SQL statments save limit String savedLimit = NbPreferences.forModule(SQLHistoryPanel.class).get("SQL_STATEMENTS_SAVED_FOR_HISTORY", ""); // NOI18N @@ -565,9 +611,12 @@ public List getUrlList() { List urlList = new ArrayList(); for (SQLHistory sqlHistory : sqlHistoryList) { - String url = sqlHistory.getUrl(); - if (!urlList.contains(url)) { - urlList.add(url); + String connectionName = sqlHistory.getUrl(); + if (urlAliasMap.containsKey(connectionName)) { + connectionName = urlAliasMap.get(connectionName); + } + if (!urlList.contains(connectionName)) { + urlList.add(connectionName); } } return urlList; @@ -624,8 +673,12 @@ connectionUrlComboBox.setSelectedItem(defaultSelectedItem); for (SQLHistory sqlHistory : sqlHistoryList) { - if (!currentUrlList.contains(sqlHistory.getUrl())) { - currentUrlList.add(sqlHistory.getUrl()); + String connectionName = sqlHistory.getUrl(); + if (urlAliasMap.containsKey(connectionName)) { + connectionName = urlAliasMap.get(connectionName); + } + if (!currentUrlList.contains(connectionName)) { + currentUrlList.add(connectionName); } } // Initialize combo data @@ -642,6 +695,9 @@ List filteredSqlHistoryList = new ArrayList(); String match = searchTextField.getText(); String url = (String)connectionUrlComboBox.getSelectedItem(); + if (aliasUrlMap.containsKey(url)) { + url = aliasUrlMap.get(url); + } // modify list of SQL to reflect a selection from the Connection dropdown or if a match text entered for (SQLHistory sqlHistory : sqlHistoryList) { if (sqlHistory.getUrl().equals(url) || url.equals(NbBundle.getMessage(SQLHistoryPanel.class, "LBL_ConnectionCombo"))) { @@ -691,7 +747,7 @@ List dateList; int sortCol = 1; boolean sortAsc = false; - + @Override public int getRowCount() { if (sqlHistoryTable.getSelectedRow() == -1) { @@ -778,6 +834,9 @@ // Get the connection url from the combo box if (sqlHistoryList.size() > 0) { url = connectionUrlComboBox.getSelectedItem().toString(); + if (aliasUrlMap.containsKey(url)) { + url = aliasUrlMap.get(url); + } } else { url = NbBundle.getMessage(SQLHistoryPanel.class, "LBL_URLComboBoxAllConnectionsItem"); } diff -r 40294f922719 db/libsrc/org/netbeans/lib/ddl/DBConnection.java --- a/db/libsrc/org/netbeans/lib/ddl/DBConnection.java Fri Sep 04 22:43:11 2009 +0200 +++ b/db/libsrc/org/netbeans/lib/ddl/DBConnection.java Sun Sep 06 23:11:37 2009 +0100 @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common @@ -56,6 +56,13 @@ public interface DBConnection extends java.io.Serializable { + + /** Returns the name that is displayed for this connection. */ + public String getDisplayName(); + + /** Set the name that is displayed for this connection. */ + public void setDisplayName(String name); + /** Returns driver URL */ public String getDriver(); diff -r 40294f922719 db/src/org/netbeans/api/db/explorer/DatabaseConnection.java --- a/db/src/org/netbeans/api/db/explorer/DatabaseConnection.java Fri Sep 04 22:43:11 2009 +0200 +++ b/db/src/org/netbeans/api/db/explorer/DatabaseConnection.java Sun Sep 06 23:11:37 2009 +0100 @@ -113,7 +113,7 @@ * @param user the username. * @param schema the schema to use, or null for the default schema * @param password the password. - * @param rememberPassword whether to remeber the password for the current session. + * @param rememberPassword whether to remember the password for the current session. * * @return the new instance. * @@ -149,7 +149,7 @@ * Returns the JDBC driver instance that this connection uses. * * @since 1.32 - * @return the JDBC driver or null if no driver registred + * @return the JDBC driver or null if no driver registered */ public JDBCDriver getJDBCDriver() { return delegate.findJDBCDriver (); @@ -206,7 +206,7 @@ * @return the display name */ public String getDisplayName() { - return delegate.getName(); + return delegate.getDisplayName(); } /** diff -r 40294f922719 db/src/org/netbeans/api/db/explorer/node/BaseNode.java --- a/db/src/org/netbeans/api/db/explorer/node/BaseNode.java Fri Sep 04 22:43:11 2009 +0200 +++ b/db/src/org/netbeans/api/db/explorer/node/BaseNode.java Sun Sep 06 23:11:37 2009 +0100 @@ -84,6 +84,8 @@ protected static final String REMEMBERPWDESC = "RememberPasswordDescription"; // NOI18N protected static final String CATALOG = "Catalog"; // NOI18N protected static final String CATALOGDESC = "CatalogDescription"; // NOI18N + protected static final String DISPLAYNAME = "DisplayName"; // NOI18N + protected static final String DISPLAYNAMEDESC = "DisplayNameDescription"; // NOI18N protected static final String UNIQUE = "UniqueNoMnemonic"; // NOI18N protected static final String UNIQUEDESC = "UniqueDescription"; // NOI18N protected static final String NULL = "Null"; // NOI18N diff -r 40294f922719 db/src/org/netbeans/api/db/explorer/node/Bundle.properties --- a/db/src/org/netbeans/api/db/explorer/node/Bundle.properties Fri Sep 04 22:43:11 2009 +0200 +++ b/db/src/org/netbeans/api/db/explorer/node/Bundle.properties Sun Sep 06 23:11:37 2009 +0100 @@ -67,6 +67,8 @@ RememberPasswordDescription=Remember password Catalog=Catalog CatalogDescription=Catalog +DisplayName=Display name +DisplayNameDescription=Display name DefaultCatalog=Default Catalog Schema=Schema SchemaDescription=Schema diff -r 40294f922719 db/src/org/netbeans/modules/db/explorer/DatabaseConnection.java --- a/db/src/org/netbeans/modules/db/explorer/DatabaseConnection.java Fri Sep 04 22:43:11 2009 +0200 +++ b/db/src/org/netbeans/modules/db/explorer/DatabaseConnection.java Sun Sep 06 23:11:37 2009 +0100 @@ -138,6 +138,9 @@ /** Connection name */ private String name; + + /** The user-specified name that is to be displayed for this connection. */ + private String displayName; /** Error code */ private int errorCode = -1; @@ -166,6 +169,7 @@ public static final String PROP_DEFCATALOG = "defaultCatalog"; //NOI18N public static final String PROP_DRIVERNAME = "drivername"; //NOI18N public static final String PROP_NAME = "name"; //NOI18N + public static final String PROP_DISPLAY_NAME = "displayName"; //NOI18N public static final String DRIVER_CLASS_NET = "org.apache.derby.jdbc.ClientDriver"; // NOI18N public static final int DERBY_UNICODE_ERROR_CODE = 20000; private OpenConnectionInterface openConnection = null; @@ -448,6 +452,21 @@ propertySupport.firePropertyChange(PROP_NAME, old, name); } + public String getDisplayName() { + return ( displayName!=null && displayName.length()>0 ) ? displayName : getName(); + } + + public void setDisplayName(String value) { + if ( (displayName == null && value==null) || + (displayName!=null && displayName.equals(value)) ) + return; + + String old = displayName; + displayName = value; + if(propertySupport!=null) + propertySupport.firePropertyChange(PROP_NAME, old, displayName); + } + /** Returns user schema name */ public String getSchema() { if (schema == null) @@ -841,8 +860,10 @@ try { drvname = (String) in.readObject(); + displayName = (String) in.readObject(); } catch (Exception exc) { - //IGNORE - not stored in 3.6 and earlier + //IGNORE - drvname not stored in 3.6 and earlier + //IGNORE - displayName not stored in 6.7 and earlier } // boston setting/pilsen setting? @@ -866,6 +887,7 @@ out.writeObject(schema); out.writeObject(DatabaseConnection.SUPPORT); out.writeObject(drvname); + out.writeObject(displayName); } @Override diff -r 40294f922719 db/src/org/netbeans/modules/db/explorer/DatabaseConnectionConvertor.java --- a/db/src/org/netbeans/modules/db/explorer/DatabaseConnectionConvertor.java Fri Sep 04 22:43:11 2009 +0200 +++ b/db/src/org/netbeans/modules/db/explorer/DatabaseConnectionConvertor.java Sun Sep 06 23:11:37 2009 +0100 @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common @@ -55,15 +55,12 @@ import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; import java.nio.charset.CoderResult; -import java.util.Iterator; import java.util.LinkedList; import java.util.Map; -import java.util.Vector; import java.util.WeakHashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; -import org.netbeans.modules.db.explorer.node.RootNode; import org.openide.cookies.InstanceCookie; import org.openide.filesystems.FileLock; import org.openide.filesystems.FileObject; @@ -82,7 +79,6 @@ import org.openide.xml.EntityCatalog; import org.openide.xml.XMLUtil; import org.netbeans.modules.db.util.Base64; -import org.openide.util.Exceptions; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -232,6 +228,9 @@ handler.user, handler.password, handler.rememberPassword); + if ( handler.displayName!=null ) { + dbconn.setDisplayName(handler.displayName); + } return dbconn; } @@ -379,6 +378,9 @@ if (instance.getUser() != null) { pw.println(" "); //NOI18N } + if ( ! instance.getName().equals(instance.getDisplayName()) ) { + pw.println(" "); //NOI18N + } if (instance.rememberPassword() ) { String password = instance.getPassword(); @@ -407,6 +409,7 @@ private static final String ELEMENT_SCHEMA = "schema"; // NOI18N private static final String ELEMENT_USER = "user"; // NOI18N private static final String ELEMENT_PASSWORD = "password"; // NOI18N + private static final String ELEMENT_DISPLAY_NAME = "display-name"; // NOI18N private static final String ELEMENT_REMEMBER_PASSWORD = "remember-password"; private static final String ATTR_PROPERTY_VALUE = "value"; // NOI18N @@ -419,17 +422,21 @@ String user; String password; boolean rememberPassword; + String displayName; public Handler(String connectionFileName) { this.connectionFileName = connectionFileName; } + @Override public void startDocument() throws SAXException { } + @Override public void endDocument() throws SAXException { } + @Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { String value = attrs.getValue(ATTR_PROPERTY_VALUE); if (ELEMENT_DRIVER_CLASS.equals(qName)) { @@ -442,6 +449,8 @@ schema = value; } else if (ELEMENT_USER.equals(qName)) { user = value; + } else if (ELEMENT_DISPLAY_NAME.equals(qName)) { + displayName = value; } else if (ELEMENT_PASSWORD.equals(qName)) { // If the password was saved, then it means the user checked // the box to say the password should be remembered. diff -r 40294f922719 db/src/org/netbeans/modules/db/explorer/dataview/DataViewWindow.java --- a/db/src/org/netbeans/modules/db/explorer/dataview/DataViewWindow.java Fri Sep 04 22:43:11 2009 +0200 +++ b/db/src/org/netbeans/modules/db/explorer/dataview/DataViewWindow.java Sun Sep 06 23:11:37 2009 +0100 @@ -124,7 +124,7 @@ //while(!(tempInfo instanceof ConnectionNodeInfo)) // tempInfo = tempInfo.getParent(); - String title = connection.getName(); //tempInfo.getDisplayName(); + String title = connection.getDisplayName(); //tempInfo.getDisplayName(); int idx = title.indexOf(" ["); //NOI18N title = title.substring(0, idx); setName(title); diff -r 40294f922719 db/src/org/netbeans/modules/db/explorer/dlg/Bundle.properties --- a/db/src/org/netbeans/modules/db/explorer/dlg/Bundle.properties Fri Sep 04 22:43:11 2009 +0200 +++ b/db/src/org/netbeans/modules/db/explorer/dlg/Bundle.properties Sun Sep 06 23:11:37 2009 +0100 @@ -70,8 +70,9 @@ AddDriver_Chooser_Filter=Archive Files (*.jar, *.zip) NewConnectionDialogTitle=New Database Connection -NewConnectionDriverName=&Name: -NewConnectionUserName=&User Name\: +NewConnectionDriverName=Driver &Name: +NewConnectionDisplayName=Displa&y Name: +NewConnectionUserName=&User Name: NewConnectionPassword=Pass&word: NewConnectionRememberPassword=&Remember password
(see help for information on security risks) NewConnectionDatabase=&Database: @@ -92,9 +93,12 @@ NewConnection.ERR_FieldRequired=Please specify a value for the required field {0} NewConnection.MSG_SelectADriver=Please select a driver from the drop-down list NewConnection.MSG_SpecifyURL=Please specify a JDBC URL for this connection +NewConnection.MSG_DuplicateDisplayName=Display name has already been defined ACS_NewConnectionDriverNameA11yDesc=Connection name. ACS_NewConnectionDriverNameComboBoxA11yName=Connection name combo box ACS_NewConnectionDriverClassComboBoxA11yDesc=Combo box containing all driver classes. +ACS_NewConnectionDisplayNameA11yDesc=Display name. +ACS_NewConnectionDisplayNameTextFieldA11yName=Display name text field. ACS_NewConnectionUserNameA11yDesc=Database user name. ACS_NewConnectionUserNameTextFieldA11yName=Database user name text field ACS_NewConnectionPasswordA11yDesc=Database password. diff -r 40294f922719 db/src/org/netbeans/modules/db/explorer/dlg/NewConnectionPanel.form --- a/db/src/org/netbeans/modules/db/explorer/dlg/NewConnectionPanel.form Fri Sep 04 22:43:11 2009 +0200 +++ b/db/src/org/netbeans/modules/db/explorer/dlg/NewConnectionPanel.form Sun Sep 06 23:11:37 2009 +0100 @@ -6,7 +6,7 @@
- + @@ -26,32 +26,44 @@ - + + - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + - - + @@ -59,6 +71,7 @@ + @@ -70,14 +83,10 @@ - - - - + - @@ -99,6 +108,11 @@ + + + + + @@ -152,28 +166,28 @@ - + - + + - - - - + + + - + + + - - - +
@@ -355,6 +369,27 @@ + + + + + + + + + + + + + + + + + + + + + diff -r 40294f922719 db/src/org/netbeans/modules/db/explorer/dlg/NewConnectionPanel.java --- a/db/src/org/netbeans/modules/db/explorer/dlg/NewConnectionPanel.java Fri Sep 04 22:43:11 2009 +0200 +++ b/db/src/org/netbeans/modules/db/explorer/dlg/NewConnectionPanel.java Sun Sep 06 23:11:37 2009 +0100 @@ -44,9 +44,12 @@ import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.event.ItemEvent; +import java.io.IOException; import java.net.MalformedURLException; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.Map.Entry; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JComboBox; @@ -65,8 +68,14 @@ import org.netbeans.api.db.explorer.JDBCDriverManager; import org.netbeans.api.progress.ProgressHandle; import org.netbeans.api.progress.ProgressHandleFactory; +import org.netbeans.lib.ddl.DBConnection; +import org.netbeans.modules.db.explorer.DatabaseConnectionConvertor; import org.netbeans.modules.db.util.DatabaseExplorerInternalUIs; import org.netbeans.modules.db.util.JdbcUrl; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.loaders.DataObject; +import org.openide.util.Exceptions; import org.openide.util.NbBundle; public class NewConnectionPanel extends ConnectionDialog.FocusablePanel { @@ -89,6 +98,8 @@ private final LinkedHashMap urlFields = new LinkedHashMap(); + private Set knownConnectionNames = new HashSet(); + private static final String BUNDLE = "org.netbeans.modules.db.resources.Bundle"; //NOI18N private static final Logger LOGGER = Logger.getLogger(NewConnectionPanel.class.getName()); @@ -96,6 +107,7 @@ private void initFieldMap() { // These should be in the order of display on the form, so that we correctly // put focus on the first visible field. + urlFields.put(JdbcUrl.TOKEN_DISPLAY_NAME, new UrlField(displayNameField, displayNameLabel)); urlFields.put(JdbcUrl.TOKEN_HOST, new UrlField(hostField, hostLabel)); urlFields.put(JdbcUrl.TOKEN_PORT, new UrlField(portField, portLabel)); urlFields.put(JdbcUrl.TOKEN_DB, new UrlField(databaseField, databaseLabel)); @@ -142,7 +154,11 @@ userField.setText(connection.getUser()); passwordField.setText(connection.getPassword()); - + + if (!connection.getDisplayName().equals(connection.getName())) { + displayNameField.setText(connection.getDisplayName()); + } + String driver = connection.getDriver(); String driverName = connection.getDriverName(); if (driver != null && driverName != null) { @@ -227,6 +243,30 @@ userField.getDocument().addDocumentListener(docListener); passwordField.getDocument().addDocumentListener(docListener); + + initKnownConnectionNames(); + } + + private void initKnownConnectionNames() { + FileObject configFile = FileUtil.getConfigFile(DatabaseConnectionConvertor.CONNECTIONS_PATH); + for (FileObject o : configFile.getChildren()) { + if ("text/xml".equals(o.getMIMEType())) { + try { + DatabaseConnectionConvertor connectionWrapper = DataObject.find(o).getLookup().lookup(DatabaseConnectionConvertor.class); + if (connectionWrapper != null) { + DBConnection knownConnection = (DBConnection) connectionWrapper.instanceCreate(); + String displayName = knownConnection.getDisplayName(); + if (!displayName.equals(knownConnection.getName())) { + knownConnectionNames.add(displayName); + } + } + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } catch (ClassNotFoundException ex) { + Exceptions.printStackTrace(ex); + } + } + } } public void setWindow(Window window) { @@ -236,6 +276,8 @@ private void initAccessibility() { templateLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(NewConnectionPanel.class, "ACS_NewConnectionDriverNameA11yDesc")); //NOI18N templateComboBox.getAccessibleContext().setAccessibleName(NbBundle.getMessage(NewConnectionPanel.class, "ACS_NewConnectionDriverNameComboBoxA11yName")); //NOI18N + displayNameLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(NewConnectionPanel.class, "ACS_NewConnectionDisplayNameA11yDesc")); //NOI18N + displayNameField.getAccessibleContext().setAccessibleName(NbBundle.getMessage(NewConnectionPanel.class, "ACS_NewConnectionDisplayNameTextFieldA11yName")); //NOI18N userLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(NewConnectionPanel.class, "ACS_NewConnectionUserNameA11yDesc")); //NOI18N userField.getAccessibleContext().setAccessibleName(NbBundle.getMessage(NewConnectionPanel.class, "ACS_NewConnectionUserNameTextFieldA11yName")); //NOI18N passwordLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(NewConnectionPanel.class, "ACS_NewConnectionPasswordA11yDesc")); //NOI18N @@ -295,6 +337,8 @@ serverNameField = new javax.swing.JTextField(); instanceLabel = new javax.swing.JLabel(); instanceField = new javax.swing.JTextField(); + displayNameLabel = new javax.swing.JLabel(); + displayNameField = new javax.swing.JTextField(); userLabel = new javax.swing.JLabel(); userField = new javax.swing.JTextField(); passwordLabel = new javax.swing.JLabel(); @@ -368,6 +412,12 @@ instanceField.setToolTipText(org.openide.util.NbBundle.getMessage(NewConnectionPanel.class, "ACS_NewConnectionInstanceNameA11yDesc")); // NOI18N + displayNameLabel.setLabelFor(displayNameField); + org.openide.awt.Mnemonics.setLocalizedText(displayNameLabel, org.openide.util.NbBundle.getMessage(NewConnectionPanel.class, "NewConnectionDisplayName")); // NOI18N + + displayNameField.setToolTipText(org.openide.util.NbBundle.getMessage(NewConnectionPanel.class, "ACS_NewConnectionDisplayNameA11yDesc")); // NOI18N + displayNameField.setFocusCycleRoot(true); + userLabel.setLabelFor(userField); org.openide.awt.Mnemonics.setLocalizedText(userLabel, org.openide.util.NbBundle.getMessage(NewConnectionPanel.class, "NewConnectionUserName")); // NOI18N @@ -438,35 +488,44 @@ .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(errorInfoPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 676, Short.MAX_VALUE) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) - .add(inputModelLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .add(templateLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .add(hostLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .add(portLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .add(databaseLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .add(passwordLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .add(userLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .add(instanceLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .add(serverNameLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .add(dsnLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .add(tnsLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .add(serviceLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .add(sidLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)) - .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) - .add(org.jdesktop.layout.GroupLayout.TRAILING, additionalPropsLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .add(directUrlLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .add(org.jdesktop.layout.GroupLayout.TRAILING, showUrlCheckBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 132, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(showUrlCheckBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 132, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(directUrlLabel)) + .add(12, 12, 12)) + .add(layout.createSequentialGroup() + .add(additionalPropsLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE) + .add(24, 24, 24))) + .add(layout.createSequentialGroup() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false) + .add(org.jdesktop.layout.GroupLayout.LEADING, displayNameLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.LEADING, inputModelLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.LEADING, templateLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.LEADING, portLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.LEADING, databaseLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.LEADING, passwordLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.LEADING, userLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.LEADING, instanceLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.LEADING, serverNameLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.LEADING, dsnLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.LEADING, tnsLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.LEADING, serviceLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.LEADING, sidLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.LEADING, hostLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .add(25, 25, 25))) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(urlField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.TRAILING, urlField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, additionalPropsField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE) .add(layout.createSequentialGroup() .add(fieldInputCheckBox) .add(18, 18, 18) .add(directInputCheckBox)) .add(org.jdesktop.layout.GroupLayout.TRAILING, templateComboBox, 0, 532, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.TRAILING, displayNameField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, hostField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, portField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, databaseField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE) @@ -478,11 +537,8 @@ .add(org.jdesktop.layout.GroupLayout.TRAILING, instanceField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, userField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, passwordField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE) - .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() - .add(passwordCheckBox, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 393, Short.MAX_VALUE) - .add(139, 139, 139)) - .add(org.jdesktop.layout.GroupLayout.TRAILING, directUrlScroll, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE))) - .add(errorInfoPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 676, Short.MAX_VALUE)) + .add(passwordCheckBox, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.TRAILING, directUrlScroll, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE)))) .addContainerGap()) ); layout.setVerticalGroup( @@ -499,6 +555,10 @@ .add(templateComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(displayNameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(displayNameLabel)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(hostLabel) .add(hostField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) @@ -541,26 +601,28 @@ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(passwordLabel) .add(passwordField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - .add(5, 5, 5) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(passwordCheckBox) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) - .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) - .add(additionalPropsLabel) - .add(additionalPropsField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) - .add(urlField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .add(showUrlCheckBox)) + .add(additionalPropsField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(additionalPropsLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) + .add(showUrlCheckBox) + .add(urlField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(5, 5, 5) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(directUrlLabel) .add(directUrlScroll, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 84, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(9, 9, 9) + .add(errorInfoPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(errorInfoPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .addContainerGap(161, Short.MAX_VALUE)) + .addContainerGap(138, Short.MAX_VALUE)) ); + + displayNameLabel.getAccessibleContext().setAccessibleName("Displa&y name."); } // Code for dispatching events from components to event handlers. @@ -698,6 +760,8 @@ private javax.swing.JTextArea directUrlField; private javax.swing.JLabel directUrlLabel; private javax.swing.JScrollPane directUrlScroll; + private javax.swing.JTextField displayNameField; + private javax.swing.JLabel displayNameLabel; private javax.swing.JTextField dsnField; private javax.swing.JLabel dsnLabel; private org.netbeans.modules.db.util.ErrorInfoPanel errorInfoPanel; @@ -736,7 +800,7 @@ JDBCDriver driver = url.getDriver(); assert(driver != null); connection.setDriverName(driver.getName()); - connection.setDriver(driver.getClassName()); + connection.setDriver(driver.getClassName()); } if (fieldEntryMode) { @@ -748,6 +812,7 @@ connection.setUser(userField.getText()); connection.setPassword(getPassword()); connection.setRememberPassword(passwordCheckBox.isSelected()); + connection.setDisplayName(displayNameField.getText()); } private void resize() { @@ -841,6 +906,8 @@ entry.getValue().getLabel().setVisible(false); } } + displayNameField.setVisible(true); + displayNameLabel.setVisible(true); setFocus(); checkValid(); @@ -947,6 +1014,7 @@ } private void enableInput(boolean enable) { + displayNameField.setEnabled(enable); fieldInputCheckBox.setEnabled(enable); directInputCheckBox.setEnabled(enable); templateComboBox.setEnabled(enable); @@ -1033,6 +1101,9 @@ displayError(NbBundle.getMessage(NewConnectionPanel.class, "NewConnection.MSG_SpecifyURL"), false); } } + if (knownConnectionNames.contains(displayNameField.getText().trim())) { + displayError(NbBundle.getMessage(NewConnectionPanel.class, "NewConnection.MSG_DuplicateDisplayName"), false); + } } private boolean isEmpty(String str) { diff -r 40294f922719 db/src/org/netbeans/modules/db/explorer/node/ConnectionNode.java --- a/db/src/org/netbeans/modules/db/explorer/node/ConnectionNode.java Fri Sep 04 22:43:11 2009 +0200 +++ b/db/src/org/netbeans/modules/db/explorer/node/ConnectionNode.java Sun Sep 06 23:11:37 2009 +0100 @@ -135,6 +135,8 @@ connection.setSchema(val.toString()); } else if (nps.getName().equals(SCHEMA)) { connection.setSchema(val.toString()); + } else if (nps.getName().equals(DISPLAYNAME)) { + connection.setDisplayName(val.toString()); } if (refreshNode) { @@ -153,6 +155,7 @@ addProperty(USER, USERDESC, String.class, !connected, connection.getUser()); addProperty(REMEMBERPW, REMEMBERPWDESC, Boolean.class, !connected, connection.rememberPassword()); + addProperty(DISPLAYNAME, DISPLAYNAMEDESC, String.class, !connected, connection.getDisplayName()); if (connected) { Specification spec = connection.getConnector().getDatabaseSpecification(); @@ -336,7 +339,7 @@ @Override public String getDisplayName() { - return connection.getName(); + return connection.getDisplayName(); } public String getIconBase() { diff -r 40294f922719 db/src/org/netbeans/modules/db/util/JdbcUrl.java --- a/db/src/org/netbeans/modules/db/util/JdbcUrl.java Fri Sep 04 22:43:11 2009 +0200 +++ b/db/src/org/netbeans/modules/db/util/JdbcUrl.java Sun Sep 06 23:11:37 2009 +0100 @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common @@ -66,7 +66,8 @@ private HashSet supportedTokens = new HashSet(); private HashSet requiredTokens = new HashSet(); private boolean parseUrl; - + + public static final String TOKEN_DISPLAY_NAME = ""; public static final String TOKEN_DB = ""; public static final String TOKEN_HOST = ""; public static final String TOKEN_PORT = "";