Перенос.

This commit is contained in:
2023-09-17 22:13:42 +03:00
parent dd2e0ca7e0
commit 629d8b8477
1239 changed files with 61161 additions and 1 deletions

View File

@@ -0,0 +1,47 @@
package GlobalData.RemoteSapfor;
import Common.Current;
import Common.Database.iDBObject;
import Common.Utils.Utils;
import GlobalData.Machine.Machine;
import ProjectData.LanguageName;
import com.sun.org.glassfish.gmbal.Description;
public class RemoteSapfor extends iDBObject {
//---------------------------------------------------------------------
@Description("IGNORE")
public static String version_command = "-ver";//команда запроса версии компилятора.
@Description("IGNORE")
public static String help_command = "-help";// команда запроса help
//----------------------------------------------------------------------
public int machine_id = -1;
public String description = "";
public LanguageName languageName = LanguageName.fortran;
public String home_path = ""; //домашняя папка.
public String call_command = ""; //полная команда вызова.
public String version = "?";
public RemoteSapfor() {
}
public RemoteSapfor(Machine machine,
String description_in,
LanguageName languageName_in,
String call_command_in
) {
machine_id = machine.id;
description = description_in;
languageName = languageName_in;
call_command = call_command_in;
}
@Override
public boolean isVisible() {
return Current.HasMachine() && Current.getMachine().id == machine_id;
}
@Override
public String toString() {
return call_command;
}
public String getDescription() {
return description;
}
public String getVersionCommand() {
return Utils.DQuotes(call_command) + " " + version_command;
}
}

View File

@@ -0,0 +1,126 @@
package GlobalData.RemoteSapfor;
import Common.Current;
import Common.Database.iDBTable;
import Common.UI.DataSetControlForm;
import Common.UI.UI;
import Common.UI.Windows.Dialog.DBObjectDialog;
import Common.Utils.Utils;
import Common.Utils.Validators.PathValidator;
import GlobalData.RemoteSapfor.UI.RemoteSapforFields;
import ProjectData.LanguageName;
public class RemoteSapforsDBTable extends iDBTable<RemoteSapfor> {
public RemoteSapforsDBTable() {
super(RemoteSapfor.class);
}
@Override
public String getSingleDescription() {
return "SAPFOR";
}
@Override
public String getPluralDescription() {
return "SAPFOR";
}
@Override
public Current CurrentName() {
return Current.RemoteSapfor;
}
@Override
public String[] getUIColumnNames() {
return new String[]{"описание", "команда вызова", "версия"};
}
@Override
public Object getFieldAt(RemoteSapfor object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.description;
case 2:
return object.call_command;
case 3:
return object.version;
}
return null;
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
protected void AdditionalInitColumns() {
columns.get(0).setVisible(false);
}
};
}
//---
@Override
public DBObjectDialog<RemoteSapfor, RemoteSapforFields> getDialog() {
return new DBObjectDialog<RemoteSapfor, RemoteSapforFields>(RemoteSapforFields.class) {
@Override
public void validateFields() {
//<editor-fold desc="расположение">
String home = fields.tfHome.getText();
if (!home.isEmpty()) {
if (home.startsWith("/")) {
if (Utils.ContainsCyrillic(home))
Log.Writeln("Расположение системы SAPFOR не может содержать кириллицу");
else {
new PathValidator(home, "Расположение системы SAPFOR", Log).Validate();
}
} else
Log.Writeln("Расположение системы SAPFOR может быть либо пустой строкой, либо путём к файлу");
}
//</editor-fold>
//<editor-fold desc="команда вызова">
String call_command = fields.tfCallCommand.getText();
if (call_command.isEmpty()) Log.Writeln("Команда вызова системы SAPFOR не может быть пустой");
else if (Utils.ContainsCyrillic(call_command))
Log.Writeln("Команда вызова системы SAPFOR не может содержать кириллицу");
else {
switch (call_command.charAt(0)) {
case ' ':
Log.Writeln("Команда вызова системы SAPFOR не может начинаться с пробела.");
break;
case '/':
if (call_command.endsWith("/"))
Log.Writeln("Каталог не может быть указан в качестве команды.");
else new PathValidator(call_command, "Команда вызова системы SAPFOR", Log).Validate();
break;
default:
//это команда.
//самое опасное место. теоретически тут можно ввести любую команду ОС, в том числе rm -rf
if (call_command.contains(" "))
Log.Writeln("Прямая команда вызова системы SAPFOR не может содержать пробелы");
if (!call_command.contains("+") && Utils.ContainsForbiddenName(call_command))
Log.Writeln("Прямая команда вызова системы SAPFOR содержит запрещённые символы");
else {
if (Utils.isLinuxSystemCommand(call_command))
Log.Writeln(Utils.DQuotes(call_command) + " является системной командой Linux");
}
break;
}
}
//</editor-fold>
}
@Override
public void fillFields() {
fields.tfDescription.setText(Result.description);
fields.tfCallCommand.setText(Result.call_command);
fields.tfHome.setText(Result.home_path);
UI.TrySelect(fields.cbLanguageName, Result.languageName);
fields.tfVersion.setText(Result.version);
fields.events_on = true;
}
@Override
public void ProcessResult() {
Result.machine_id = Current.getMachine().id;
Result.description = fields.tfDescription.getText();
Result.call_command = fields.tfCallCommand.getText();
Result.home_path = fields.tfHome.getText();
Result.languageName = (LanguageName) fields.cbLanguageName.getSelectedItem();
Result.version = fields.tfVersion.getText();
}
@Override
public int getDefaultHeight() {
return 300;
}
};
}
}

View File

@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="GlobalData.RemoteSapfor.UI.RemoteSapforFields">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="6" column-count="3" 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="a4409" 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>
<vspacer id="ff938">
<constraints>
<grid row="5" column="0" 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="d8b80" class="javax.swing.JTextField" binding="tfDescription" 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>
<component id="38f55" 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="4599c" class="javax.swing.JTextField" binding="tfHome" 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="92f09" class="javax.swing.JButton" binding="bBrowse">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="true"/>
<icon value="icons/LastOpened.png"/>
<text value=""/>
</properties>
</component>
<component id="66fe1" 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="bb2d7" class="javax.swing.JTextField" binding="tfCallCommand" custom-create="true">
<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">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="99516" 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="113b3" class="javax.swing.JComboBox" binding="cbLanguageName" 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>
<component id="3f186" class="javax.swing.JLabel">
<constraints>
<grid row="4" 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="acebb" class="javax.swing.JTextField" binding="tfVersion" custom-create="true">
<constraints>
<grid row="4" 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>
</children>
</grid>
</form>

View File

@@ -0,0 +1,65 @@
package GlobalData.RemoteSapfor.UI;
import Common.Current;
import Common.UI.TextField.StyledTextField;
import Common.UI.Windows.Dialog.DialogFields;
import ProjectData.LanguageName;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
public class RemoteSapforFields implements DialogFields {
private JPanel content;
public JTextField tfDescription;
public JTextField tfHome;
private JButton bBrowse;
public JTextField tfCallCommand;
public JComboBox<LanguageName> cbLanguageName;
public JTextField tfVersion;
public boolean events_on = false;
@Override
public Component getContent() {
return content;
}
private void createUIComponents() {
// TODO: place custom component creation code here
tfDescription = new StyledTextField();
tfHome = new StyledTextField();
tfCallCommand = new StyledTextField();
cbLanguageName = new JComboBox<>();
cbLanguageName.addItem(LanguageName.fortran);
tfVersion = new StyledTextField();
}
public RemoteSapforFields() {
bBrowse.addActionListener(e -> {
// LanguageName languageName = (LanguageName) cbLanguageName.getSelectedItem();
String dst = null;
if (Pass_2021.passes.get(PassCode_2021.SelectRemoteFile).Do(true))
dst = Current.getRemoteFile().full_name;
if (dst != null)
tfHome.setText(dst);
});
tfHome.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
TryRestoreCallCommand();
}
@Override
public void removeUpdate(DocumentEvent e) {
TryRestoreCallCommand();
}
@Override
public void changedUpdate(DocumentEvent e) {
}
}
);
}
public void TryRestoreCallCommand() {
if (events_on && (cbLanguageName.getSelectedItem() != null))
tfCallCommand.setText(tfHome.getText() +
(tfHome.getText().endsWith("/") ? "" : "/") +
"Sapfor_F");
}
}