Перенос.

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,76 @@
package GlobalData.CompilerEnvironment;
import Common.Database.DBObject;
import Common.Utils.TextLog;
import com.sun.org.glassfish.gmbal.Description;
import java.util.Vector;
public class CompilerEnvironment extends DBObject {
@Description("PRIMARY KEY, UNIQUE")
public String name = "";
public String value = "";
public EnvironmentValueType type = EnvironmentValueType.String;
public Vector<String> valueVariants = new Vector<>();
public Vector<String> description = new Vector<>();
@Override
public Object getPK() {
return name;
}
public void CheckDefaults() {
//определить тип. в dvm переменных он может быть указан в начале 1 строки.
if (!description.isEmpty()) {
String line = description.get(0);
if (line.startsWith("Boolean value.")) {
type = EnvironmentValueType.Boolean;
valueVariants.add("0");
valueVariants.add("1");
} else if (line.startsWith("Integer value.")) {
type = EnvironmentValueType.Integer;
} else if (line.startsWith("Real number.")) {
type = EnvironmentValueType.Real;
}
//-
if (line.endsWith("Accepted values:")) {
// все что дальше - варианты и их описания после запятой.
for (int i = 1; i < description.size(); ++i) {
String[] data = description.get(i).split(",");
if (data.length > 1)
valueVariants.add(data[0]);
}
}
}
}
public void validate(TextLog log, String new_value) {
if (new_value.isEmpty()) {
log.Writeln_("Переменная не предполагает пустого значения");
} else {
if (!valueVariants.isEmpty()) {
if (!valueVariants.contains(new_value))
log.Writeln_("Переменная : недопустимое значение. Выберите доступный вариант.");
}
switch (type) {
case Boolean:
if (!valueVariants.contains(new_value))
log.Writeln_("Переменная допускает только 0 или 1 в качестве значений");
break;
case Integer:
try {
Integer.parseInt(new_value);
} catch (NumberFormatException ex) {
log.Writeln_("Переменная допускает только целочисленные значения");
}
break;
case Real:
try {
Double.parseDouble(new_value);
} catch (NumberFormatException ex) {
log.Writeln_("Переменная допускает только числа с плавающей запятой в качестве значения");
}
break;
case String:
if (new_value.contains("\""))
log.Writeln_("Переменная не может содержать двойные кавычки в значении");
break;
}
}
}
}

View File

@@ -0,0 +1,45 @@
package GlobalData.CompilerEnvironment;
import Common.Database.DataSet;
import Common.UI.DataSetControlForm;
import Common.UI.Tables.TableEditors;
import Common.UI.Tables.TableRenderers;
import static Common.UI.Tables.TableRenderers.RendererMultiline;
public class CompilerEnvironmentsSet extends DataSet<String, CompilerEnvironment> {
public CompilerEnvironmentsSet() {
super(String.class, CompilerEnvironment.class);
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"Значение", "Описание"
};
}
@Override
public Object getFieldAt(CompilerEnvironment object, int columnIndex) {
switch (columnIndex) {
case 2:
return object.value;
case 3:
return object.description;
default:
return null;
}
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
public boolean hasCheckBox() {
return true;
}
@Override
protected void AdditionalInitColumns() {
columns.get(2).setRenderer(TableRenderers.RendererCompilerEnvironmentValue);
columns.get(2).setEditor(TableEditors.EditorCompilerEnvironmentValue);
//-
columns.get(3).setRenderer(RendererMultiline);
}
};
}
}

View File

@@ -0,0 +1,7 @@
package GlobalData.CompilerEnvironment;
public enum EnvironmentValueType {
String,
Boolean,
Integer,
Real
}

View File

@@ -0,0 +1,36 @@
package GlobalData.CompilerEnvironment.UI;
import Common.Current;
import Common.UI.Tables.DBObjectEditor;
import Common.UI.Themes.VisualiserFonts;
import Common.UI.UI;
import Common.UI.Windows.Dialog.Text.ComboTextDialog;
import GlobalData.CompilerEnvironment.CompilerEnvironment;
public class CompilerEnvironmentValueEditor extends DBObjectEditor<CompilerEnvironment> {
@Override
public void Action() {
setFont(Current.getTheme().Fonts.get(VisualiserFonts.Hyperlink));
setText(value.value.isEmpty() ? "не задано" : value.value);
//-
ComboTextDialog dialog = new ComboTextDialog() {
@Override
public void validateFields() {
super.validateFields();
if (fields.getSelectedItem() != null)
value.validate(Log, fields.getSelectedItem().toString());
}
};
dialog.fields.setEditable(value.valueVariants.isEmpty());
if (!value.value.isEmpty())
UI.TrySelect(dialog.fields, value.value);
if (dialog.ShowDialog("Изменить значение опции " + value.name,
value.valueVariants
)) {
value.value = dialog.Result;
setText(value.value.isEmpty() ? "не задано" : value.value);
}
}
@Override
public Object getCellEditorValue() {
return value.value;
}
}

View File

@@ -0,0 +1,15 @@
package GlobalData.CompilerEnvironment.UI;
import Common.Current;
import Common.UI.Tables.DBObjectRenderer;
import Common.UI.Themes.VisualiserFonts;
import GlobalData.CompilerEnvironment.CompilerEnvironment;
public class CompilerEnvironmentValueRenderer extends DBObjectRenderer {
@Override
public void Display() {
if (value != null) {
CompilerEnvironment environment = (CompilerEnvironment) value;
setFont(Current.getTheme().Fonts.get(VisualiserFonts.Hyperlink));
setText(environment.value.isEmpty() ? "не задано" : environment.value);
}
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="GlobalData.CompilerEnvironment.UI.CompilerEnvironmentsFields">
<grid id="27dc6" binding="content" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</form>

View File

@@ -0,0 +1,12 @@
package GlobalData.CompilerEnvironment.UI;
import Common.UI.Windows.Dialog.DialogFields;
import javax.swing.*;
import java.awt.*;
public class CompilerEnvironmentsFields implements DialogFields {
private JPanel content;
@Override
public Component getContent() {
return content;
}
}