return dialectExt.supportsAddForeignKeyConstraint();
}
private void showCustomDialog() throws SQLException
{
final ITableInfo selectedTable = (ITableInfo) _info[0];
String schema = selectedTable.getSchemaName();
String catalog = selectedTable.getCatalogName();
ITableInfo[] tables = _session.getSchemaInfo().getITableInfos(catalog, schema);
TableColumnInfo[] tableColumnInfos = _session.getMetaData().getColumnInfo(selectedTable);
if (tableColumnInfos == null || tableColumnInfos.length == 0)
{
_session.showErrorMessage(s_stringMgr.getString("AddForeignKeyCommand.noColumns",
selectedTable.getSimpleName()));
return;
}
final TreeSet<String> localColumns = new TreeSet<String>();
for (TableColumnInfo columns : tableColumnInfos)
{
localColumns.add(columns.getColumnName());
}
final HashMap<String, TableColumnInfo[]> allTables = new HashMap<String, TableColumnInfo[]>();
for (ITableInfo table : tables)
{
if (table.getDatabaseObjectType() == DatabaseObjectType.TABLE)
{
TableColumnInfo[] columnInfos = _session.getMetaData().getColumnInfo(table);
if (columnInfos != null && columnInfos.length > 0)
{
allTables.put(table.getSimpleName(), _session.getMetaData().getColumnInfo(table));
}
}
}
_session.getApplication().getThreadPool().addTask(new Runnable()
{
public void run()
{
GUIUtils.processOnSwingEventThread(new Runnable()
{
public void run()
{
customDialog =
new AddForeignKeyDialog(selectedTable.getSimpleName(),
localColumns.toArray(new String[] {}),
allTables);
customDialog.addExecuteListener(new ExecuteListener());
customDialog.addEditSQLListener(new EditSQLListener(customDialog));
customDialog.addShowSQLListener(new ShowSQLListener(i18n.SHOWSQL_DIALOG_TITLE, customDialog));