2023-11-19 02:12:44 +03:00
|
|
|
package Visual_DVM_2021.Passes.Server;
|
2023-11-20 00:15:22 +03:00
|
|
|
import Common.Database.DBObject;
|
2024-09-18 13:37:11 +03:00
|
|
|
import Common.UI.VisualCache.VisualCaches;
|
2023-11-16 22:11:58 +03:00
|
|
|
import Repository.RepositoryServer;
|
2023-11-20 00:15:22 +03:00
|
|
|
public class DeleteServerObject<S extends RepositoryServer, D extends DBObject> extends ServerObjectPass<S, D> {
|
2023-11-16 22:11:58 +03:00
|
|
|
@Override
|
|
|
|
|
public String getIconPath() {
|
|
|
|
|
return "/icons/Delete.png";
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
|
|
|
|
target = (D) getDb().tables.get(d).getCurrent();
|
|
|
|
|
return getDb().tables.get(d).CheckCurrent(Log) && getDb().tables.get(d).ShowDeleteObjectDialog(target);
|
|
|
|
|
}
|
2024-09-18 13:37:11 +03:00
|
|
|
@Override
|
|
|
|
|
protected void performPreparation() throws Exception {
|
|
|
|
|
super.performPreparation();
|
2024-09-18 22:58:38 +03:00
|
|
|
VisualCaches.DeleteCache(target);
|
2024-09-18 13:37:11 +03:00
|
|
|
}
|
2023-11-16 22:11:58 +03:00
|
|
|
//Очищаем все связанные таблицы, чтобы не допустить перерисовки во время удаления объекта.
|
|
|
|
|
@Override
|
|
|
|
|
protected void showPreparation() throws Exception {
|
|
|
|
|
getDb().tables.get(d).ClearUI();
|
|
|
|
|
for (Class dep : getDb().tables.get(d).getFKDependencies().keySet()) {
|
|
|
|
|
switch (getDb().tables.get(d).getFKDependencies().get(dep).data) {
|
|
|
|
|
case NONE:
|
|
|
|
|
case DROP:
|
|
|
|
|
break;
|
|
|
|
|
case DELETE:
|
|
|
|
|
getDb().tables.get(dep).ClearUI();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public DeleteServerObject(S server_in, Class<D> d_in) {
|
|
|
|
|
super(server_in, d_in);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void ServerAction() throws Exception {
|
|
|
|
|
DeleteObject(target);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void showDone() throws Exception {
|
|
|
|
|
getDb().tables.get(d).ui_.Show();
|
|
|
|
|
}
|
|
|
|
|
}
|