no message
This commit is contained in:
65
src/_VisualDVM/GlobalData/Machine/Machine.java
Normal file
65
src/_VisualDVM/GlobalData/Machine/Machine.java
Normal file
@@ -0,0 +1,65 @@
|
||||
package _VisualDVM.GlobalData.Machine;
|
||||
import Common.Database.Objects.iDBObject;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.GlobalData.Compiler.Compiler;
|
||||
import _VisualDVM.GlobalData.User.User;
|
||||
|
||||
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(Constants.repository_machine) ? "Репозиторий визуализатора" :
|
||||
"Машина по адресу " + CommonUtils.Brackets(getURL());
|
||||
}
|
||||
public LinkedHashMap<Integer, Compiler> getCompilers() {
|
||||
return CommonUtils.db.getMapByFKi(this, Compiler.class);
|
||||
}
|
||||
public LinkedHashMap<Integer, User> getUsers() {
|
||||
return CommonUtils.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/_VisualDVM/GlobalData/Machine/MachineType.java
Normal file
20
src/_VisualDVM/GlobalData/Machine/MachineType.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package _VisualDVM.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 "";
|
||||
}
|
||||
}
|
||||
126
src/_VisualDVM/GlobalData/Machine/MachinesDBTable.java
Normal file
126
src/_VisualDVM/GlobalData/Machine/MachinesDBTable.java
Normal file
@@ -0,0 +1,126 @@
|
||||
package _VisualDVM.GlobalData.Machine;
|
||||
import Common.Visual.CommonUI;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import _VisualDVM.Visual.UI;
|
||||
import Common.Visual.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;
|
||||
import _VisualDVM.GlobalData.Compiler.Compiler;
|
||||
import _VisualDVM.GlobalData.DVMParameter.DVMParameter;
|
||||
import _VisualDVM.GlobalData.EnvironmentValue.EnvironmentValue;
|
||||
import _VisualDVM.GlobalData.Machine.UI.MachineFields;
|
||||
import _VisualDVM.GlobalData.Makefile.Makefile;
|
||||
import _VisualDVM.GlobalData.Module.Module;
|
||||
import _VisualDVM.GlobalData.RunConfiguration.RunConfiguration;
|
||||
import _VisualDVM.GlobalData.Tasks.CompilationTask.CompilationTask;
|
||||
import _VisualDVM.GlobalData.Tasks.RunTask.RunTask;
|
||||
import _VisualDVM.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);
|
||||
CommonUI.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(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().ShowCurrentCompiler();
|
||||
UI.credentialsBar.ShowMachine();
|
||||
}
|
||||
@Override
|
||||
public void ShowNoCurrentObject() throws Exception {
|
||||
super.ShowNoCurrentObject();
|
||||
UI.getMainWindow().getTestingWindow().ShowCurrentCompiler();
|
||||
UI.credentialsBar.ShowNoMachine();
|
||||
}
|
||||
@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));
|
||||
}
|
||||
}
|
||||
29
src/_VisualDVM/GlobalData/Machine/MachinesMenuBar.java
Normal file
29
src/_VisualDVM/GlobalData/Machine/MachinesMenuBar.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package _VisualDVM.GlobalData.Machine;
|
||||
import Common.Visual.Menus.DataMenuBar;
|
||||
import Common.Visual.Controls.MenuBarButton;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
public class MachinesMenuBar extends DataMenuBar {
|
||||
MenuBarButton bCollapse;
|
||||
public MachinesMenuBar() {
|
||||
super("машины",
|
||||
PassCode_2021.AddMachine,
|
||||
PassCode_2021.EditMachine,
|
||||
PassCode_2021.DeleteMachine);
|
||||
this.add(bCollapse = new MenuBarButton() {
|
||||
{
|
||||
setIcon("/icons/CollapseUp.png");
|
||||
setToolTipText("Свернуть");
|
||||
addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Pass_2021.passes.get(PassCode_2021.UpdateProperty).Do("collapseCredentials", true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
84
src/_VisualDVM/GlobalData/Machine/UI/MachineFields.form
Normal file
84
src/_VisualDVM/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="_VisualDVM.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/_VisualDVM/GlobalData/Machine/UI/MachineFields.java
Normal file
43
src/_VisualDVM/GlobalData/Machine/UI/MachineFields.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package _VisualDVM.GlobalData.Machine.UI;
|
||||
import Common.Visual.TextField.StyledTextField;
|
||||
import Common.Visual.Windows.Dialog.DialogFields;
|
||||
import _VisualDVM.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