упорядочил папки с кодом.
This commit is contained in:
116
src/Repository/TestingSystem/Common/Group/Group.java
Normal file
116
src/Repository/TestingSystem/Common/Group/Group.java
Normal file
@@ -0,0 +1,116 @@
|
||||
package Repository.TestingSystem.Common.Group;
|
||||
import Common.Current;
|
||||
import Common.Database.DBObject;
|
||||
import Common.Database.riDBObject;
|
||||
import Common.Global;
|
||||
import Common.UI.UI;
|
||||
import Common.Utils.Utils;
|
||||
import ProjectData.Files.DBProjectFile;
|
||||
import ProjectData.LanguageName;
|
||||
import ProjectData.Project.db_project_info;
|
||||
import Repository.TestingSystem.Common.Test.TestType;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class Group extends riDBObject {
|
||||
@Description("DEFAULT 'Default'")
|
||||
public TestType type = TestType.Default;
|
||||
@Description("DEFAULT 'fortran'")
|
||||
public LanguageName language = LanguageName.fortran;
|
||||
//--
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return (!GroupsDBTable.filterMyOnly || Current.getAccount().email.equals(sender_address)) &&
|
||||
Global.testingServer.db.groups.applyFilters(this);
|
||||
}
|
||||
public String getSummary() {
|
||||
return description + " " + language.getDescription();
|
||||
}
|
||||
//-
|
||||
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject src) {
|
||||
super.SynchronizeFields(src);
|
||||
Group g = (Group) src;
|
||||
type = g.type;
|
||||
language = g.language;
|
||||
}
|
||||
public Group(Group group) {
|
||||
this.SynchronizeFields(group);
|
||||
}
|
||||
public Group() {
|
||||
}
|
||||
@Override
|
||||
public void select(boolean flag) {
|
||||
super.select(flag);
|
||||
if (Current.hasUI())
|
||||
UI.getMainWindow().ShowCheckedTestsCount();
|
||||
}
|
||||
//--
|
||||
//-
|
||||
public static void generateForLanguage(
|
||||
String dvm_drv,
|
||||
LinkedHashMap<LanguageName, Vector<DBProjectFile>> programs,
|
||||
LanguageName language,
|
||||
Vector<String> titles,
|
||||
Vector<String> objects,
|
||||
Vector<String> bodies,
|
||||
String flags_in
|
||||
) {
|
||||
if (!programs.get(language).isEmpty()) {
|
||||
String LANG_ = language.toString().toUpperCase() + "_";
|
||||
Vector<String> module_objects = new Vector<>();
|
||||
String module_body = "";
|
||||
int i = 1;
|
||||
for (DBProjectFile program : programs.get(language)) {
|
||||
//--
|
||||
program.last_assembly_name = language + "_" + i + ".o";
|
||||
String object = Utils.DQuotes(program.last_assembly_name);
|
||||
module_objects.add(object);
|
||||
module_body +=
|
||||
object + ":\n" +
|
||||
"\t" +
|
||||
String.join(" ",
|
||||
Utils.MFVar(LANG_ + "COMMAND"),
|
||||
Utils.MFVar(LANG_ + "FLAGS"),
|
||||
program.getStyleOptions(),
|
||||
"-c",
|
||||
program.getQSourceName(),
|
||||
"-o",
|
||||
object + "\n\n"
|
||||
);
|
||||
++i;
|
||||
}
|
||||
titles.add(String.join("\n",
|
||||
LANG_ + "COMMAND=" + Utils.DQuotes(dvm_drv) + " " +
|
||||
language.getDVMCompile(),
|
||||
LANG_ + "FLAGS=" + flags_in,
|
||||
LANG_ + "OBJECTS=" + String.join(" ", module_objects),
|
||||
""
|
||||
));
|
||||
objects.add(Utils.MFVar(LANG_ + "OBJECTS"));
|
||||
bodies.add(module_body);
|
||||
}
|
||||
}
|
||||
public String GenerateMakefile(db_project_info project, String dvm_drv, String flags_in) {
|
||||
//----->>
|
||||
LinkedHashMap<LanguageName, Vector<DBProjectFile>> programs = project.getPrograms();
|
||||
Vector<String> titles = new Vector<>();
|
||||
Vector<String> objects = new Vector<>();
|
||||
Vector<String> bodies = new Vector<>();
|
||||
String binary = Utils.DQuotes("0");
|
||||
//----->>
|
||||
generateForLanguage(dvm_drv, programs, language, titles, objects, bodies, flags_in);
|
||||
//----->>
|
||||
return String.join("\n",
|
||||
"LINK_COMMAND=" + Utils.DQuotes(dvm_drv) + " " +
|
||||
language.getDVMLink(),
|
||||
"LINK_FLAGS=" + flags_in + "\n",
|
||||
String.join("\n", titles),
|
||||
"all: " + binary,
|
||||
binary + " : " + String.join(" ", objects),
|
||||
"\t" + Utils.MFVar("LINK_COMMAND") + " " + Utils.MFVar("LINK_FLAGS") + " " + String.join(" ", objects) + " -o " + binary,
|
||||
String.join(" ", bodies));
|
||||
}
|
||||
}
|
||||
186
src/Repository/TestingSystem/Common/Group/GroupsDBTable.java
Normal file
186
src/Repository/TestingSystem/Common/Group/GroupsDBTable.java
Normal file
@@ -0,0 +1,186 @@
|
||||
package Repository.TestingSystem.Common.Group;
|
||||
import Common.Current;
|
||||
import Common.Database.*;
|
||||
import Common.UI.DataSetControlForm;
|
||||
import Common.UI.Menus_2023.GroupsMenuBar.GroupsMenuBar;
|
||||
import Common.UI.Menus_2023.VisualiserMenu;
|
||||
import Common.UI.UI;
|
||||
import Common.UI.Windows.Dialog.DBObjectDialog;
|
||||
import ProjectData.LanguageName;
|
||||
import Repository.TestingSystem.Common.Group.UI.GroupFields;
|
||||
import Repository.TestingSystem.Common.Test.Test;
|
||||
import Repository.TestingSystem.Common.Test.TestType;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
//-
|
||||
public class GroupsDBTable extends iDBTable<Group> {
|
||||
public static boolean filterMyOnly = false;
|
||||
public Vector<TableFilter<Group>> typeFilters;
|
||||
public Vector<TableFilter<Group>> languageFilters;
|
||||
//------------------------------------------------>>>
|
||||
public GroupsDBTable() {
|
||||
super(Group.class);
|
||||
if (Current.hasUI()) {
|
||||
//--
|
||||
typeFilters = new Vector<>();
|
||||
languageFilters = new Vector<>();
|
||||
//--
|
||||
for (TestType type : TestType.values()) {
|
||||
typeFilters.add(
|
||||
new TableFilter<Group>(this, type.getDescription()) {
|
||||
@Override
|
||||
protected boolean validate(Group object) {
|
||||
return object.type.equals(type);
|
||||
}
|
||||
});
|
||||
}
|
||||
//--
|
||||
for (LanguageName languageName : LanguageName.values()) {
|
||||
languageFilters.add(new TableFilter<Group>(this, languageName.getDescription()) {
|
||||
@Override
|
||||
protected boolean validate(Group object) {
|
||||
return object.language.equals(languageName);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void mountUI(JPanel content_in) {
|
||||
super.mountUI(content_in);
|
||||
//---
|
||||
GroupsMenuBar menuBar = (GroupsMenuBar) UI.menuBars.get(getClass());
|
||||
menuBar.DropFilters();
|
||||
//----
|
||||
menuBar.addFilters(
|
||||
new VisualiserMenu("Тип", "/icons/Filter.png", true) {
|
||||
{
|
||||
for (TableFilter filter : typeFilters)
|
||||
add(filter.menuItem);
|
||||
}
|
||||
},
|
||||
new VisualiserMenu("Язык", "/icons/Filter.png", true) {
|
||||
{
|
||||
for (TableFilter filter : languageFilters)
|
||||
add(filter.menuItem);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
public void ResetFiltersCount() {
|
||||
for (TableFilter filter : typeFilters)
|
||||
filter.count = 0;
|
||||
for (TableFilter filter : languageFilters)
|
||||
filter.count = 0;
|
||||
}
|
||||
public void ShowFiltersCount() {
|
||||
for (TableFilter filter : typeFilters)
|
||||
filter.ShowDescriptionAndCount();
|
||||
for (TableFilter filter : languageFilters)
|
||||
filter.ShowDescriptionAndCount();
|
||||
}
|
||||
public boolean applyFilters(Group object) {
|
||||
for (TableFilter filter : typeFilters)
|
||||
if (!filter.Validate(object)) return false;
|
||||
for (TableFilter filter : languageFilters)
|
||||
if (!filter.Validate(object)) return false;
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void ShowUI() {
|
||||
ResetFiltersCount();
|
||||
super.ShowUI();
|
||||
ShowFiltersCount();
|
||||
}
|
||||
@Override
|
||||
public void ShowUI(Object key) {
|
||||
ResetFiltersCount();
|
||||
super.ShowUI(key);
|
||||
ShowFiltersCount();
|
||||
}
|
||||
@Override
|
||||
public String getSingleDescription() {
|
||||
return "группа тестов";
|
||||
}
|
||||
@Override
|
||||
public String getPluralDescription() {
|
||||
return "группы";
|
||||
}
|
||||
@Override
|
||||
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
|
||||
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
|
||||
res.put(Test.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
|
||||
return res;
|
||||
}
|
||||
@Override
|
||||
protected DataSetControlForm createUI() {
|
||||
return new DataSetControlForm(this) {
|
||||
@Override
|
||||
public boolean hasCheckBox() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected void AdditionalInitColumns() {
|
||||
//columns.get(0).setVisible(false);
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public String[] getUIColumnNames() {
|
||||
return new String[]{
|
||||
"имя",
|
||||
"автор",
|
||||
"тип",
|
||||
"язык"
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public Object getFieldAt(Group object, int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 2:
|
||||
return object.description;
|
||||
case 3:
|
||||
return object.sender_name;
|
||||
case 4:
|
||||
return object.type.getDescription();
|
||||
case 5:
|
||||
return object.language.getDescription();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Current CurrentName() {
|
||||
return Current.Group;
|
||||
}
|
||||
@Override
|
||||
public DBObjectDialog<Group, GroupFields> getDialog() {
|
||||
return new DBObjectDialog<Group, GroupFields>(GroupFields.class) {
|
||||
@Override
|
||||
public int getDefaultHeight() {
|
||||
return 250;
|
||||
}
|
||||
@Override
|
||||
public int getDefaultWidth() {
|
||||
return 400;
|
||||
}
|
||||
@Override
|
||||
public void validateFields() {
|
||||
}
|
||||
@Override
|
||||
public void fillFields() {
|
||||
fields.tfName.setText(Result.description);
|
||||
UI.TrySelect(fields.cbType, Result.type);
|
||||
UI.TrySelect(fields.cbLanguage, Result.language);
|
||||
}
|
||||
@Override
|
||||
public void ProcessResult() {
|
||||
Result.description = fields.tfName.getText();
|
||||
Result.type = (TestType) fields.cbType.getSelectedItem();
|
||||
Result.language = (LanguageName) fields.cbLanguage.getSelectedItem();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="Repository.TestingSystem.Common.Group.UI.GroupFields">
|
||||
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="1" column-count="1" 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="385" height="181"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="a979" layout-manager="GridLayoutManager" row-count="3" 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>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="d80" 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="f2392" 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">
|
||||
<minimum-size width="200" height="30"/>
|
||||
<preferred-size width="238" height="30"/>
|
||||
<maximum-size width="200" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="c5591" 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="a5bbe" class="javax.swing.JComboBox" binding="cbType" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="200" height="30"/>
|
||||
<preferred-size width="238" height="30"/>
|
||||
<maximum-size width="200" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="8a5e9" 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="c8d4e" class="javax.swing.JComboBox" binding="cbLanguage" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="200" height="30"/>
|
||||
<preferred-size width="238" height="30"/>
|
||||
<maximum-size width="200" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,32 @@
|
||||
package Repository.TestingSystem.Common.Group.UI;
|
||||
import Common.UI.TextField.StyledTextField;
|
||||
import Common.UI.Windows.Dialog.DialogFields;
|
||||
import ProjectData.LanguageName;
|
||||
import Repository.TestingSystem.Common.Test.TestType;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class GroupFields implements DialogFields {
|
||||
public JPanel content;
|
||||
public JTextField tfName;
|
||||
public JComboBox<TestType> cbType;
|
||||
public JComboBox<LanguageName> cbLanguage;
|
||||
@Override
|
||||
public Component getContent() {
|
||||
return content;
|
||||
}
|
||||
private void createUIComponents() {
|
||||
// TODO: place custom component creation code here
|
||||
tfName = new StyledTextField();
|
||||
//-
|
||||
cbType = new JComboBox<>();
|
||||
cbType.addItem(TestType.Default);
|
||||
cbType.addItem(TestType.Performance);
|
||||
cbType.addItem(TestType.Correctness);
|
||||
cbType.addItem(TestType.SAPFOR);
|
||||
//-
|
||||
cbLanguage = new JComboBox<>();
|
||||
cbLanguage.addItem(LanguageName.fortran);
|
||||
cbLanguage.addItem(LanguageName.c);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user