public PersistenceUnitWizardPanelJdbc( Project project, ChangeListener changeListener, boolean editName, TableGeneration tg) { super(project); initComponents(); setTableGeneration(tg); PersistenceProviderComboboxHelper comboHelper = new PersistenceProviderComboboxHelper(project); comboHelper.connect(libraryCombo); unitNameTextField.setText(getCandidateName()); unitNameTextField.selectAll(); // unit name editing is not available when adding first PU unitNameTextField.setVisible(editName); unitNameLabel.setVisible(editName); DatabaseExplorerUIs.connect(jdbcCombo, ConnectionManager.getDefault()); jdbcCombo.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { checkValidity(); } }); unitNameTextField.getDocument().addDocumentListener(new ValidationListener()); errorMessage.setForeground(Color.RED); updateWarning(); }
public void setPreselectedDB(String db) { boolean hasItem = false; for (int i = 0; i < jdbcCombo.getItemCount(); i++) { if (jdbcCombo.getItemAt(i) instanceof DatabaseConnection) { DatabaseConnection conn = (DatabaseConnection) jdbcCombo.getItemAt(i); if (conn.getDisplayName().equals(db) || conn.toString().equals(db)) { hasItem = true; break; } } } jdbcCombo.setSelectedItem(ConnectionManager.getDefault().getConnection(db)); jdbcCombo.setEnabled(!hasItem); }