no message
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
package _VisualDVM.GlobalData.CompilerEnvironment;
|
||||
import Common.Database.Objects.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package _VisualDVM.GlobalData.CompilerEnvironment;
|
||||
import Common.Database.Tables.DataSet;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import Common.Visual.Tables.TableEditors;
|
||||
import Common.Visual.Tables.TableRenderers;
|
||||
|
||||
import static Common.Visual.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);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package _VisualDVM.GlobalData.CompilerEnvironment;
|
||||
public enum EnvironmentValueType {
|
||||
String,
|
||||
Boolean,
|
||||
Integer,
|
||||
Real
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package _VisualDVM.GlobalData.CompilerEnvironment.UI;
|
||||
import Common.Visual.CommonUI;
|
||||
import Common.Visual.Tables.DBObjectEditor;
|
||||
import Common.Visual.Fonts.VisualiserFonts;
|
||||
import Common.Visual.Windows.Dialog.Text.ComboTextDialog;
|
||||
import _VisualDVM.GlobalData.CompilerEnvironment.CompilerEnvironment;
|
||||
public class CompilerEnvironmentValueEditor extends DBObjectEditor<CompilerEnvironment> {
|
||||
@Override
|
||||
public void Action() {
|
||||
setFont(CommonUI.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())
|
||||
CommonUI.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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package _VisualDVM.GlobalData.CompilerEnvironment.UI;
|
||||
import Common.Visual.CommonUI;
|
||||
import Common.Visual.Tables.DBObjectRenderer;
|
||||
import Common.Visual.Fonts.VisualiserFonts;
|
||||
import _VisualDVM.GlobalData.CompilerEnvironment.CompilerEnvironment;
|
||||
public class CompilerEnvironmentValueRenderer extends DBObjectRenderer {
|
||||
@Override
|
||||
public void Display() {
|
||||
if (value != null) {
|
||||
CompilerEnvironment environment = (CompilerEnvironment) value;
|
||||
setFont(CommonUI.getTheme().Fonts.get(VisualiserFonts.Hyperlink));
|
||||
setText(environment.value.isEmpty() ? "не задано" : environment.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.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>
|
||||
@@ -0,0 +1,12 @@
|
||||
package _VisualDVM.GlobalData.CompilerEnvironment.UI;
|
||||
import Common.Visual.Windows.Dialog.DialogFields;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class CompilerEnvironmentsFields implements DialogFields {
|
||||
private JPanel content;
|
||||
@Override
|
||||
public Component getContent() {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user