no message
This commit is contained in:
13
src/_VisualDVM/TestingSystem/Common/Test/Json/TestJson.java
Normal file
13
src/_VisualDVM/TestingSystem/Common/Test/Json/TestJson.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package _VisualDVM.TestingSystem.Common.Test.Json;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.io.Serializable;
|
||||
public class TestJson implements Serializable {
|
||||
@Expose
|
||||
public int id;
|
||||
public TestJson(Test test){
|
||||
id=test.id;
|
||||
}
|
||||
public TestJson(){}
|
||||
}
|
||||
19
src/_VisualDVM/TestingSystem/Common/Test/Json/TestsJson.java
Normal file
19
src/_VisualDVM/TestingSystem/Common/Test/Json/TestsJson.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package _VisualDVM.TestingSystem.Common.Test.Json;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
public class TestsJson implements Serializable {
|
||||
@Expose
|
||||
public List<TestJson> array = new Vector<>();
|
||||
public TestsJson() {
|
||||
}
|
||||
//при создании пакета.
|
||||
public TestsJson(Vector<Test> tests) {
|
||||
array = new Vector<>();
|
||||
for (Test test : tests)
|
||||
array.add(new TestJson(test));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package _VisualDVM.TestingSystem.Common.Test;
|
||||
import _VisualDVM.ProjectData.Files.DBProjectFile;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
public class ProjectFiles_json {
|
||||
@Expose
|
||||
public List<DBProjectFile> files = new Vector<>();
|
||||
}
|
||||
135
src/_VisualDVM/TestingSystem/Common/Test/Test.java
Normal file
135
src/_VisualDVM/TestingSystem/Common/Test/Test.java
Normal file
@@ -0,0 +1,135 @@
|
||||
package _VisualDVM.TestingSystem.Common.Test;
|
||||
import Common.CommonConstants;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common.Visual.CommonUI;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Objects.riDBObject;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Visual.UI;
|
||||
import _VisualDVM.ProjectData.Files.FileState;
|
||||
import _VisualDVM.ProjectData.Files.FileType;
|
||||
import _VisualDVM.ProjectData.Files.ProjectFile;
|
||||
import _VisualDVM.ProjectData.LanguageName;
|
||||
import _VisualDVM.Repository.RepositoryRefuseException;
|
||||
import Visual_DVM_2021.Passes.All.UnzipFolderPass;
|
||||
import Visual_DVM_2021.Passes.All.ZipFolderPass;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class Test extends riDBObject {
|
||||
@Description("DEFAULT 0")
|
||||
public int min_dim = 0; //мин размерность теста.
|
||||
@Description("DEFAULT 0")
|
||||
public int max_dim = 0; //макс размерность теста.
|
||||
@Description("DEFAULT ''")
|
||||
public String args = ""; //аргументы командной строки. на всякий случай поле зарезервирую. пусть будут.
|
||||
@Description("DEFAULT -1")
|
||||
public int group_id = CommonConstants.Nan;
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject src) {
|
||||
super.SynchronizeFields(src);
|
||||
Test t = (Test) src;
|
||||
min_dim = t.min_dim;
|
||||
max_dim = t.max_dim;
|
||||
args = t.args;
|
||||
group_id = t.group_id;
|
||||
}
|
||||
@Description("DEFAULT ''")
|
||||
public String files = ""; //файлы теста
|
||||
//--------------------------------------------->>>
|
||||
@Description("IGNORE")
|
||||
public String temp_project_name = "";
|
||||
@Description("IGNORE")
|
||||
public byte[] project_archive_bytes = null;
|
||||
//--------------------------------------------->>>
|
||||
public Test(Test test) {
|
||||
this.SynchronizeFields(test);
|
||||
}
|
||||
public Test() {
|
||||
}
|
||||
@Override
|
||||
public void select(boolean flag) {
|
||||
super.select(flag);
|
||||
if (CommonUI.isActive())
|
||||
UI.getMainWindow().ShowCheckedTestsCount();
|
||||
}
|
||||
//---
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return Current.HasGroup() && (Current.getGroup().id == group_id);
|
||||
}
|
||||
//-
|
||||
public File getArchive() {
|
||||
return new File(Global.TestsDirectory, id + ".zip");
|
||||
}
|
||||
//-
|
||||
public File getServerPath() {
|
||||
return new File(Global.TestsDirectory, String.valueOf(id));
|
||||
}
|
||||
public File getHomePath() {
|
||||
return new File(Global.visualiser.getWorkspace(), String.valueOf(id));
|
||||
}
|
||||
//--
|
||||
public File getTempArchive() {
|
||||
return new File(Global.TempDirectory, temp_project_name + ".zip");
|
||||
}
|
||||
public File getTempProject() {
|
||||
return new File(Global.TempDirectory, temp_project_name);
|
||||
}
|
||||
public boolean unpackProjectOnServer() throws Exception {
|
||||
File tmpArchive = new File(Global.TempDirectory, temp_project_name + ".zip");
|
||||
File tmpProject = new File(Global.TempDirectory, temp_project_name);
|
||||
File testProject = new File(Global.TestsDirectory, String.valueOf(id));
|
||||
File testArchive = new File(Global.TestsDirectory, id + ".zip");
|
||||
//--
|
||||
if (tmpArchive.exists())
|
||||
FileUtils.forceDelete(tmpArchive);
|
||||
if (tmpProject.exists())
|
||||
FileUtils.forceDelete(tmpProject);
|
||||
if (testProject.exists())
|
||||
FileUtils.forceDelete(testProject);
|
||||
if (testArchive.exists())
|
||||
FileUtils.forceDelete(testArchive);
|
||||
//--
|
||||
CommonUtils.bytesToFile(project_archive_bytes, tmpArchive); // распаковка байтов.
|
||||
//--
|
||||
UnzipFolderPass unzipFolderPass = new UnzipFolderPass();
|
||||
if (!unzipFolderPass.Do(
|
||||
tmpArchive.getAbsolutePath(),
|
||||
Global.TempDirectory.getAbsolutePath())) {
|
||||
return false;
|
||||
}
|
||||
//--
|
||||
FileUtils.moveDirectory(tmpProject, testProject);
|
||||
//--
|
||||
ZipFolderPass zip = new ZipFolderPass();
|
||||
if (!zip.Do(testProject.getAbsolutePath(), testArchive.getAbsolutePath()))
|
||||
throw new RepositoryRefuseException("Не удалось переписать архив проекта");
|
||||
return true;
|
||||
}
|
||||
public String getFilesForTable() {
|
||||
return files.replace("\n", ";");
|
||||
}
|
||||
public LinkedHashMap<LanguageName, Vector<ProjectFile>> getPrograms() {
|
||||
LinkedHashMap<LanguageName, Vector<ProjectFile>> res = new LinkedHashMap<>();
|
||||
//--
|
||||
res.put(LanguageName.fortran, new Vector<>());
|
||||
res.put(LanguageName.c, new Vector<>());
|
||||
res.put(LanguageName.cpp, new Vector<>());
|
||||
//--
|
||||
String[] files_names = files.split("\n");
|
||||
for (String file_name : files_names) {
|
||||
ProjectFile file = new ProjectFile(new File(file_name));
|
||||
//--
|
||||
if (!file.state.equals(FileState.Excluded) &&
|
||||
file.fileType.equals(FileType.program) &&
|
||||
(!file.languageName.equals(LanguageName.n)))
|
||||
res.get(file.languageName).add(file);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
126
src/_VisualDVM/TestingSystem/Common/Test/TestDBTable.java
Normal file
126
src/_VisualDVM/TestingSystem/Common/Test/TestDBTable.java
Normal file
@@ -0,0 +1,126 @@
|
||||
package _VisualDVM.TestingSystem.Common.Test;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Database.Tables.iDBTable;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import Common.Visual.Windows.Dialog.DBObjectDialog;
|
||||
import _VisualDVM.TestingSystem.Common.Group.Group;
|
||||
import _VisualDVM.TestingSystem.Common.Test.UI.TestFields;
|
||||
|
||||
import java.util.Vector;
|
||||
public class TestDBTable extends iDBTable<Test> {
|
||||
public TestDBTable() {
|
||||
super(Test.class);
|
||||
}
|
||||
@Override
|
||||
public String getSingleDescription() {
|
||||
return "тест DVM";
|
||||
}
|
||||
@Override
|
||||
public String getPluralDescription() {
|
||||
return "тесты";
|
||||
}
|
||||
@Override
|
||||
protected DataSetControlForm createUI() {
|
||||
return new DataSetControlForm(this) {
|
||||
@Override
|
||||
protected void AdditionalInitColumns() {
|
||||
//columns.get(0).setVisible(false);
|
||||
}
|
||||
@Override
|
||||
public boolean hasCheckBox() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public Object getFieldAt(Test object, int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 2:
|
||||
return object.description;
|
||||
case 3:
|
||||
return object.min_dim;
|
||||
case 4:
|
||||
return object.max_dim;
|
||||
case 5:
|
||||
return object.getFilesForTable();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String[] getUIColumnNames() {
|
||||
return new String[]{
|
||||
"имя",
|
||||
"min_dim",
|
||||
"max_dim",
|
||||
"файлы"
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public Current CurrentName() {
|
||||
return Current.Test;
|
||||
}
|
||||
@Override
|
||||
public DBObjectDialog<Test, TestFields> getDialog() {
|
||||
return new DBObjectDialog<Test, TestFields>(TestFields.class) {
|
||||
@Override
|
||||
public int getDefaultHeight() {
|
||||
return 200;
|
||||
}
|
||||
@Override
|
||||
public int getDefaultWidth() {
|
||||
return 400;
|
||||
}
|
||||
@Override
|
||||
public void validateFields() {
|
||||
if (!edit) {
|
||||
if (!Current.getGroup().language.equals(Current.getProject().languageName))
|
||||
Log.Writeln_("В текущую группу могут войти только тесты на языке " + Current.getGroup().language);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void fillFields() {
|
||||
fields.tfName.setText(Result.description);
|
||||
fields.sMinDim.setValue(Result.min_dim);
|
||||
fields.sMaxDim.setValue(Result.max_dim);
|
||||
}
|
||||
@Override
|
||||
public void ProcessResult() {
|
||||
Result.description = fields.tfName.getText();
|
||||
Result.min_dim = (int) fields.sMinDim.getValue();
|
||||
Result.max_dim = (int) fields.sMaxDim.getValue();
|
||||
if (!edit) {
|
||||
Result.sender_name = Current.getAccount().name;
|
||||
Result.sender_address = Current.getAccount().email;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
public boolean containsTestWithDescription(String description_in) {
|
||||
for (Test test : Data.values()) {
|
||||
if (test.description.equalsIgnoreCase(description_in))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public Test getTestByDescription(int group_id_in, String description_in) {
|
||||
for (Test test : Data.values()) {
|
||||
if (test.sender_address.equals("vmk-post@yandex.ru")&&
|
||||
(test.group_id==group_id_in)&&(test.description.equalsIgnoreCase(description_in)))
|
||||
return test;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public Vector<Test> getSelectedGroupTests(Group group) {
|
||||
Vector<Test> allTests = new Vector<>();
|
||||
Vector<Test> selectedTests = new Vector<>();
|
||||
//--
|
||||
for (Test test : Data.values()) {
|
||||
if (test.group_id == group.id) {
|
||||
allTests.add(test);
|
||||
if (test.isSelected()) selectedTests.add(test);
|
||||
}
|
||||
}
|
||||
return selectedTests.isEmpty()?allTests:selectedTests;
|
||||
}
|
||||
}
|
||||
22
src/_VisualDVM/TestingSystem/Common/Test/TestType.java
Normal file
22
src/_VisualDVM/TestingSystem/Common/Test/TestType.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package _VisualDVM.TestingSystem.Common.Test;
|
||||
public enum TestType {
|
||||
Default,
|
||||
Correctness,
|
||||
Performance,
|
||||
SAPFOR,
|
||||
;
|
||||
public String getDescription(){
|
||||
switch (this){
|
||||
case Correctness:
|
||||
return "Корректность";
|
||||
case Performance:
|
||||
return "Производительность";
|
||||
case Default:
|
||||
return "Без типа";
|
||||
case SAPFOR:
|
||||
return "SAPFOR";
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
}
|
||||
12
src/_VisualDVM/TestingSystem/Common/Test/TestsMenuBar.java
Normal file
12
src/_VisualDVM/TestingSystem/Common/Test/TestsMenuBar.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package _VisualDVM.TestingSystem.Common.Test;
|
||||
import Common.Visual.Menus.DataMenuBar;
|
||||
import _VisualDVM.TestingSystem.Common.Test.UI.AddTestMenu;
|
||||
import _VisualDVM.TestingSystem.Common.Test.UI.EditTestMenu;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
public class TestsMenuBar extends DataMenuBar {
|
||||
public TestsMenuBar() {
|
||||
super("тесты");
|
||||
addMenus(new AddTestMenu(), new EditTestMenu());
|
||||
addPasses(PassCode_2021.DownloadTest,PassCode_2021.DeleteTest);
|
||||
}
|
||||
}
|
||||
13
src/_VisualDVM/TestingSystem/Common/Test/UI/AddTestMenu.java
Normal file
13
src/_VisualDVM/TestingSystem/Common/Test/UI/AddTestMenu.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package _VisualDVM.TestingSystem.Common.Test.UI;
|
||||
import _VisualDVM.Visual.Menus.VisualiserMenu;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
public class AddTestMenu extends VisualiserMenu {
|
||||
public AddTestMenu() {
|
||||
super("Добавление теста", "/icons/RedAdd.png", false);
|
||||
add(Pass_2021.passes.get(PassCode_2021.CreateTestFromProject).createMenuItem());
|
||||
add(Pass_2021.passes.get(PassCode_2021.CreateTestFromDirectory).createMenuItem());
|
||||
add(Pass_2021.passes.get(PassCode_2021.CreateTestsFromFiles).createMenuItem());
|
||||
add(Pass_2021.passes.get(PassCode_2021.CreateTestFromSelectedFiles).createMenuItem());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package _VisualDVM.TestingSystem.Common.Test.UI;
|
||||
import _VisualDVM.Visual.Menus.VisualiserMenu;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
public class EditTestMenu extends VisualiserMenu {
|
||||
public EditTestMenu() {
|
||||
super("Редактирование теста", "/icons/Edit.png", false);
|
||||
add(Pass_2021.passes.get(PassCode_2021.EditTest).createMenuItem());
|
||||
add(Pass_2021.passes.get(PassCode_2021.ReplaceTestProject).createMenuItem());
|
||||
}
|
||||
}
|
||||
73
src/_VisualDVM/TestingSystem/Common/Test/UI/TestFields.form
Normal file
73
src/_VisualDVM/TestingSystem/Common/Test/UI/TestFields.form
Normal file
@@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.TestingSystem.Common.Test.UI.TestFields">
|
||||
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="4" 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="e9479" 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="9a439">
|
||||
<constraints>
|
||||
<grid row="3" 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="ddf02" 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>
|
||||
<enabled value="true"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="fbef6" 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="2b54" class="javax.swing.JSpinner" binding="sMaxDim">
|
||||
<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="50" height="-1"/>
|
||||
<maximum-size width="50" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="82807" 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="c59e6" class="javax.swing.JSpinner" binding="sMinDim">
|
||||
<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="50" height="-1"/>
|
||||
<maximum-size width="50" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
24
src/_VisualDVM/TestingSystem/Common/Test/UI/TestFields.java
Normal file
24
src/_VisualDVM/TestingSystem/Common/Test/UI/TestFields.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package _VisualDVM.TestingSystem.Common.Test.UI;
|
||||
import Common.Visual.TextField.StyledTextField;
|
||||
import Common.Visual.Windows.Dialog.DialogFields;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class TestFields implements DialogFields {
|
||||
public JTextField tfName;
|
||||
private JPanel content;
|
||||
public JSpinner sMinDim;
|
||||
public JSpinner sMaxDim;
|
||||
@Override
|
||||
public Component getContent() {
|
||||
return content;
|
||||
}
|
||||
private void createUIComponents() {
|
||||
// TODO: place custom component creation code here
|
||||
tfName = new StyledTextField();
|
||||
}
|
||||
public TestFields(){
|
||||
sMinDim.setModel(new SpinnerNumberModel(1, 0, 16,1));
|
||||
sMaxDim.setModel(new SpinnerNumberModel(1, 0, 16,1));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user