Перенос.
This commit is contained in:
66
src/GlobalData/Machine/Machine.java
Normal file
66
src/GlobalData/Machine/Machine.java
Normal file
@@ -0,0 +1,66 @@
|
||||
package GlobalData.Machine;
|
||||
import Common.Database.iDBObject;
|
||||
import Common.Global;
|
||||
import Common.Utils.Utils;
|
||||
import GlobalData.Compiler.Compiler;
|
||||
import GlobalData.User.User;
|
||||
import Visual_DVM_2021.Passes.SSH.ConnectionPass;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
public class Machine extends iDBObject {
|
||||
public MachineType type = MachineType.Server;
|
||||
public String name = "";
|
||||
public String address = "";
|
||||
public int port = 22;
|
||||
public Machine(String name_in, String address_in, int port_in, MachineType type_in) {
|
||||
name = name_in;
|
||||
address = address_in;
|
||||
port = port_in;
|
||||
type = type_in;
|
||||
}
|
||||
public Machine() {
|
||||
}
|
||||
public String getURL() {
|
||||
return type.equals(MachineType.Local) ? name : (address + ":" + port);
|
||||
}
|
||||
public String getFullDescription() {
|
||||
return this.equals(ConnectionPass.rep_machine) ? "Репозиторий визуализатора" : "Машина по адресу " + Utils.Brackets(getURL());
|
||||
}
|
||||
public LinkedHashMap<Integer, Compiler> getCompilers() {
|
||||
return Global.db.getMapByFKi(this, Compiler.class);
|
||||
}
|
||||
public LinkedHashMap<Integer, User> getUsers() {
|
||||
return Global.db.getMapByFKi(this, User.class);
|
||||
}
|
||||
@Override
|
||||
public String getDialogName() {
|
||||
return super.getDialogName() + ":" + getURL();
|
||||
}
|
||||
/* инициализация компиляторов по умолчанию. добавить в отдельный проход.
|
||||
//todo если машина локальная и винда, их не добавлять.
|
||||
Visualiser.db.Insert(new Compiler(
|
||||
(Machine)Target,
|
||||
"gfortran",
|
||||
CompilerType.gnu,
|
||||
"gfortran",
|
||||
"--version",
|
||||
"--help"
|
||||
));
|
||||
Visualiser.db.Insert(new Compiler(
|
||||
(Machine)Target,
|
||||
"gcc",
|
||||
CompilerType.gnu,
|
||||
"gcc",
|
||||
"--version",
|
||||
"--help"
|
||||
));
|
||||
Visualiser.db.Insert(new Compiler(
|
||||
(Machine)Target,
|
||||
"g++",
|
||||
CompilerType.gnu,
|
||||
"g++",
|
||||
"--version",
|
||||
"--help"
|
||||
));
|
||||
*/
|
||||
}
|
||||
20
src/GlobalData/Machine/MachineType.java
Normal file
20
src/GlobalData/Machine/MachineType.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package GlobalData.Machine;
|
||||
public enum MachineType {
|
||||
Undefined,
|
||||
Server,
|
||||
MVS_cluster,
|
||||
Local;
|
||||
public String getDescription() {
|
||||
switch (this) {
|
||||
case Undefined:
|
||||
return "?";
|
||||
case Server:
|
||||
return "одиночный сервер";
|
||||
case MVS_cluster:
|
||||
return "MVS кластер";
|
||||
case Local:
|
||||
return "локальная";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
123
src/GlobalData/Machine/MachinesDBTable.java
Normal file
123
src/GlobalData/Machine/MachinesDBTable.java
Normal file
@@ -0,0 +1,123 @@
|
||||
package GlobalData.Machine;
|
||||
import Common.Current;
|
||||
import Common.Database.*;
|
||||
import Common.UI.DataSetControlForm;
|
||||
import Common.UI.UI;
|
||||
import Common.UI.Windows.Dialog.DBObjectDialog;
|
||||
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.RemoteSapfor.RemoteSapfor;
|
||||
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);
|
||||
}
|
||||
};
|
||||
}
|
||||
@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(RemoteSapfor.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();
|
||||
UI.getMainWindow().getTestingWindow().ShowCurrentMachine();
|
||||
UI.getMainWindow().getTestingWindow().ShowCredentials();
|
||||
}
|
||||
@Override
|
||||
public void ShowNoCurrentObject() throws Exception {
|
||||
super.ShowNoCurrentObject();
|
||||
UI.getMainWindow().getTestingWindow().ShowNoCurrentMachine();
|
||||
UI.getMainWindow().getTestingWindow().ShowCredentials();
|
||||
}
|
||||
@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));
|
||||
}
|
||||
}
|
||||
84
src/GlobalData/Machine/UI/MachineFields.form
Normal file
84
src/GlobalData/Machine/UI/MachineFields.form
Normal file
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="GlobalData.Machine.UI.MachineFields">
|
||||
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="1bb3c" class="javax.swing.JTextField" binding="tfName" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<vspacer id="aac20">
|
||||
<constraints>
|
||||
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="44036" class="javax.swing.JTextField" binding="tfAddress" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="a00bb" class="javax.swing.JSpinner" binding="sPort">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="ee3e1" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="имя"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="22dab" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="адрес"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="2dde3" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="порт"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="9d873" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="тип"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="7aab4" class="javax.swing.JComboBox" binding="cbMachineType" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<toolTipText value="выберите тип машины"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
43
src/GlobalData/Machine/UI/MachineFields.java
Normal file
43
src/GlobalData/Machine/UI/MachineFields.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package GlobalData.Machine.UI;
|
||||
import Common.UI.TextField.StyledTextField;
|
||||
import Common.UI.Windows.Dialog.DialogFields;
|
||||
import GlobalData.Machine.MachineType;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
public class MachineFields implements DialogFields {
|
||||
private static final String localName = "этот компьютер";
|
||||
public JTextField tfName;
|
||||
public JTextField tfAddress;
|
||||
public JSpinner sPort;
|
||||
public JPanel content;
|
||||
public JComboBox<MachineType> cbMachineType;
|
||||
public MachineFields() {
|
||||
sPort.setModel(new SpinnerNumberModel(22, 1, 65535, 1));
|
||||
cbMachineType.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if ((cbMachineType.getSelectedItem() != null) && (cbMachineType.getSelectedItem().equals(MachineType.Local))) {
|
||||
tfName.setText(localName);
|
||||
tfAddress.setText(localName);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
private void createUIComponents() {
|
||||
// TODO: place custom component creation code here
|
||||
tfName = new StyledTextField();
|
||||
tfAddress = new StyledTextField();
|
||||
//-
|
||||
cbMachineType = new JComboBox<>();
|
||||
cbMachineType.addItem(MachineType.Server);
|
||||
cbMachineType.addItem(MachineType.MVS_cluster);
|
||||
cbMachineType.addItem(MachineType.Local);
|
||||
}
|
||||
@Override
|
||||
public Component getContent() {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user