/** * @see net.sourceforge.squirrel_sql.client.session.DefaultSQLExecuterHandler#sqlToBeExecuted(java.lang.String) */ @Override public void sqlToBeExecuted(final String sql) { if (s_log.isDebugEnabled()) { s_log.debug("Statement to be executed: " + sql); } if (sql.startsWith("ALTER")) { cb.setLoadingPrefix(i18n.DROPPING_CONSTRAINT_PREFIX); // Hack!!! hopefully the FK name will always be the last token! final String[] parts = StringUtilities.split(sql, ' '); cb.currentlyLoading(parts[parts.length - 1]); } else { cb.setLoadingPrefix(i18n.DROPPING_TABLE_PREFIX); if (tableCount < DropTablesCommand.this.orderedTables.size()) { final ITableInfo ti = DropTablesCommand.this.orderedTables.get(tableCount); cb.currentlyLoading(ti.getSimpleName()); } tableCount++; } } }
private List<ITableInfo> getOrderedTables(final List<ITableInfo> tables) throws SQLException { if (tables.size() < 2) { // No point to ordering less than 2 tables return tables; } final SQLDatabaseMetaData md = _session.getSQLConnection().getSQLMetaData(); ProgressCallBack getOrderedTablesCallBack = progressCallBackFactory.create(customDialog, i18n.PROGRESS_DIALOG_ANALYZE_TITLE, tables.size()); getOrderedTablesCallBack.setLoadingPrefix(i18n.LOADING_PREFIX); // Now, get the drop order (same as delete) and update the dialog // status while doing so. final List<ITableInfo> result = SQLUtilities.getDeletionOrder(tables, md, getOrderedTablesCallBack); getOrderedTablesCallBack.setVisible(false); getOrderedTablesCallBack.dispose(); getOrderedTablesCallBack = null; return result; }
/** * Delete records from the selected tables in the object tree. */ public void execute() { ProgressCallBack cb = progressCallBackFactory.create(_session.getApplication().getMainFrame(), i18n.PROGRESS_DIALOG_TITLE, _tables.size()); cb.setLoadingPrefix(i18n.LOADING_PREFIX); DeleteExecuter executer = new DeleteExecuter(cb); _session.getApplication().getThreadPool().addTask(executer); }
/** * Delete records from the selected tables in the object tree. */ public void execute() { ProgressCallBack cb = progressCallBackFactory.create(_session.getApplication().getMainFrame(), i18n.PROGRESS_DIALOG_TITLE, _tables.size()); cb.setLoadingPrefix(i18n.LOADING_PREFIX); DeleteExecuter executer = new DeleteExecuter(cb); _session.getApplication().getThreadPool().addTask(executer); }
private void getInsertionOrder(IDatabaseObjectInfo[] dbObjs, SQLDatabaseMetaData md) throws SQLException { List<ITableInfo> selectedTables = DBUtil.convertObjectArrayToTableList(dbObjs); // Only concerned about order when more than one table. if (selectedTables.size() > 1) { ProgressCallBack cb = progressCallBackFactory.create(_session.getApplication().getMainFrame(), i18n.PROGRESS_DIALOG_TITLE, dbObjs.length); cb.setLoadingPrefix(i18n.LOADING_PREFIX); selectedTables = SQLUtilities.getInsertionOrder(selectedTables, md, cb); cb.setVisible(false); cb.dispose(); _plugin.setSourceDatabaseObjects(DBUtil.convertTableToObjectList(selectedTables)); } else { _plugin.setSourceDatabaseObjects(DBUtil.convertTableToObjectList(selectedTables)); } }