2023-09-17 22:13:42 +03:00
|
|
|
package GlobalData.Machine;
|
2024-10-07 00:58:29 +03:00
|
|
|
import Common_old.Current;
|
|
|
|
|
import Common_old.UI.DataSetControlForm;
|
|
|
|
|
import Common_old.UI.UI;
|
|
|
|
|
import Common_old.UI.Windows.Dialog.DBObjectDialog;
|
|
|
|
|
import Common.Database.Objects.DBObject;
|
|
|
|
|
import Common.Database.Tables.FKBehaviour;
|
|
|
|
|
import Common.Database.Tables.FKCurrentObjectBehaviuor;
|
|
|
|
|
import Common.Database.Tables.FKDataBehaviour;
|
|
|
|
|
import Common.Database.Tables.iDBTable;
|
2023-09-17 22:13:42 +03:00
|
|
|
import GlobalData.Compiler.Compiler;
|
|
|
|
|
import GlobalData.DVMParameter.DVMParameter;
|
|
|
|
|
import GlobalData.EnvironmentValue.EnvironmentValue;
|
|
|
|
|
import GlobalData.Machine.UI.MachineFields;
|
|
|
|
|
import GlobalData.Makefile.Makefile;
|
|
|
|
|
import GlobalData.Module.Module;
|
|
|
|
|
import GlobalData.RunConfiguration.RunConfiguration;
|
|
|
|
|
import GlobalData.Tasks.CompilationTask.CompilationTask;
|
|
|
|
|
import GlobalData.Tasks.RunTask.RunTask;
|
|
|
|
|
import GlobalData.User.User;
|
|
|
|
|
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
public class MachinesDBTable extends iDBTable<Machine> {
|
|
|
|
|
public MachinesDBTable() {
|
|
|
|
|
super(Machine.class);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public String getSingleDescription() {
|
|
|
|
|
return "машина";
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public String getPluralDescription() {
|
|
|
|
|
return "машины";
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public DBObjectDialog<Machine, MachineFields> getDialog() {
|
|
|
|
|
return new DBObjectDialog<Machine, MachineFields>(MachineFields.class) {
|
|
|
|
|
@Override
|
|
|
|
|
public int getDefaultHeight() {
|
|
|
|
|
return 250;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void validateFields() {
|
|
|
|
|
if (fields.tfAddress.getText().isEmpty())
|
|
|
|
|
Log.Writeln("Адрес машины не может быть пустым");
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void fillFields() {
|
|
|
|
|
fields.tfName.setText(Result.name);
|
|
|
|
|
fields.tfAddress.setText(Result.address);
|
|
|
|
|
fields.sPort.setValue(Result.port);
|
|
|
|
|
UI.TrySelect(fields.cbMachineType, Result.type);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void ProcessResult() {
|
|
|
|
|
Result.name = fields.tfName.getText();
|
|
|
|
|
Result.address = fields.tfAddress.getText();
|
|
|
|
|
Result.port = (int) fields.sPort.getValue();
|
|
|
|
|
Result.type = (MachineType) fields.cbMachineType.getSelectedItem();
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void SetEditLimits() {
|
|
|
|
|
fields.cbMachineType.setEnabled(false);
|
|
|
|
|
}
|
2023-12-11 18:29:15 +03:00
|
|
|
|
2023-09-17 22:13:42 +03:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
|
|
|
|
|
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
|
|
|
|
|
//-
|
|
|
|
|
res.put(User.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
|
|
|
|
|
res.put(Compiler.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
|
|
|
|
|
res.put(Makefile.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
|
|
|
|
|
res.put(RunConfiguration.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
|
|
|
|
|
//-
|
|
|
|
|
res.put(Module.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.PASSIVE));
|
|
|
|
|
res.put(EnvironmentValue.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.PASSIVE));
|
|
|
|
|
res.put(DVMParameter.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.PASSIVE));
|
|
|
|
|
res.put(CompilationTask.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
|
|
|
|
|
res.put(RunTask.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.PASSIVE));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected DataSetControlForm createUI() {
|
|
|
|
|
return new DataSetControlForm(this) {
|
|
|
|
|
@Override
|
|
|
|
|
public void ShowCurrentObject() throws Exception {
|
|
|
|
|
super.ShowCurrentObject();
|
2023-12-11 18:52:23 +03:00
|
|
|
UI.getMainWindow().getTestingWindow().ShowCurrentCompiler();
|
2024-03-15 12:32:49 +03:00
|
|
|
UI.credentialsBar.ShowMachine();
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void ShowNoCurrentObject() throws Exception {
|
|
|
|
|
super.ShowNoCurrentObject();
|
2023-12-11 18:52:23 +03:00
|
|
|
UI.getMainWindow().getTestingWindow().ShowCurrentCompiler();
|
2024-03-15 12:32:49 +03:00
|
|
|
UI.credentialsBar.ShowNoMachine();
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void AdditionalInitColumns() {
|
|
|
|
|
columns.get(0).setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public String[] getUIColumnNames() {
|
|
|
|
|
return new String[]{"URL"};
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public Object getFieldAt(Machine object, int columnIndex) {
|
|
|
|
|
switch (columnIndex) {
|
|
|
|
|
case 1:
|
|
|
|
|
return object.getURL();
|
|
|
|
|
default:
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public Current CurrentName() {
|
|
|
|
|
return Current.Machine;
|
|
|
|
|
}
|
|
|
|
|
public boolean LocalMachineExists() {
|
|
|
|
|
return Data.values().stream().anyMatch(machine -> machine.type.equals(MachineType.Local));
|
|
|
|
|
}
|
|
|
|
|
}
|