package _VisualDVM.Passes.Testing; import _VisualDVM.Passes.Server.TestingServerPass; import _VisualDVM.Repository.Server.ServerCode; import _VisualDVM.TestingSystem.Common.TestingPackage.TestingPackage; import _VisualDVM.TestingSystem.Common.TestingPackageToKill.TestingPackageToKill; public abstract class AbortTestingPackage extends TestingServerPass { TestingPackageToKill packageToKill = null; @Override public String getIconPath() { return "/Common/icons/Ban.png"; } public abstract Class currentClass(); public abstract int getAbortType(); @Override protected boolean canStart(Object... args) throws Exception { packageToKill = null; if (getServer().db.CheckCurrent(Log, currentClass())) { target = (TestingPackage) getServer().db.getTable(currentClass()).getUI().getCurrent(); switch (target.state) { case Done: case Aborted: case DoneWithErrors: Log.Writeln_("Пакет уже завершен."); break; case Inactive: Log.Writeln_("Пакет неактивен."); break; default: packageToKill = new TestingPackageToKill(); packageToKill.packageId = target.id; packageToKill.type = getAbortType(); return SendRequest(ServerCode.PublishObject, null, packageToKill); } } return false; } }