2023-11-19 01:53:56 +03:00
|
|
|
|
package Common.UI.Windows.Main;
|
2023-10-30 18:28:01 +03:00
|
|
|
|
import Common.Current;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
import Common.UI.Label.ShortLabel;
|
|
|
|
|
|
import Common.UI.Menus_2023.VisualiserMenuBar;
|
|
|
|
|
|
import Common.UI.UI;
|
|
|
|
|
|
import Common.Utils.TextLog;
|
2023-11-19 01:53:56 +03:00
|
|
|
|
import Repository.TestingSystem.SAPFOR.SapforTask.SapforTask;
|
|
|
|
|
|
import Repository.TestingSystem.SAPFOR.SapforTasksPackage.SapforTasksPackage;
|
|
|
|
|
|
import Repository.TestingSystem.SAPFOR.SapforTasksPackage.UI.SapforTasksPackageTree;
|
|
|
|
|
|
import Common.Passes.PassCode_2021;
|
|
|
|
|
|
import Common.Passes.Pass_2021;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
|
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
|
public class SapforPackagesComparisonForm {
|
2023-11-11 21:41:49 +03:00
|
|
|
|
public boolean comparisonMode = false;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
//-->>
|
|
|
|
|
|
private JPanel content;
|
|
|
|
|
|
public JPanel getContent() {
|
|
|
|
|
|
return content;
|
|
|
|
|
|
}
|
|
|
|
|
|
protected JToolBar tools;
|
|
|
|
|
|
protected JLabel lObjectName;
|
|
|
|
|
|
private JButton bApplyObject;
|
|
|
|
|
|
private JButton bPrevious;
|
|
|
|
|
|
private JButton bNext;
|
|
|
|
|
|
private JButton bCompare;
|
|
|
|
|
|
private JButton bClose;
|
2023-10-30 19:21:26 +03:00
|
|
|
|
private JPanel treePanel;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
//-->>
|
|
|
|
|
|
SapforPackagesComparisonForm this_ = null; //?
|
|
|
|
|
|
SapforPackagesComparisonForm slave = null;
|
|
|
|
|
|
SapforPackagesComparisonForm master = null;
|
|
|
|
|
|
//-->>
|
2023-10-30 18:28:01 +03:00
|
|
|
|
protected SapforTasksPackage object = null;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
//-->>
|
2023-10-30 18:28:01 +03:00
|
|
|
|
// protected DataSet<String, SapforTaskResult> packageTasks;
|
2023-11-11 21:41:49 +03:00
|
|
|
|
protected SapforTasksPackageTree Body;
|
2023-11-10 02:56:35 +03:00
|
|
|
|
public JScrollPane treeScroll = null;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
//--->>
|
|
|
|
|
|
public boolean isMaster() {
|
|
|
|
|
|
return slave != null;
|
|
|
|
|
|
}
|
|
|
|
|
|
public boolean isSlave() {
|
|
|
|
|
|
return master != null;
|
|
|
|
|
|
}
|
|
|
|
|
|
//--->>
|
|
|
|
|
|
//неперегружаемые методы
|
|
|
|
|
|
protected void RemoveObject() {
|
2023-10-30 18:28:01 +03:00
|
|
|
|
object = null;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
showNoObject();
|
2023-11-11 21:41:49 +03:00
|
|
|
|
//--
|
|
|
|
|
|
if (comparisonMode) {
|
|
|
|
|
|
comparisonMode = false;
|
|
|
|
|
|
if (isMaster()) {
|
|
|
|
|
|
slave.comparisonMode = false;
|
|
|
|
|
|
slave.object = null;
|
|
|
|
|
|
slave.showNoObject();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
master.comparisonMode = false;
|
|
|
|
|
|
master.object = null;
|
|
|
|
|
|
master.showNoObject();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
public void ApplyObject() {
|
2023-11-11 21:41:49 +03:00
|
|
|
|
//---
|
2023-09-17 22:13:42 +03:00
|
|
|
|
RemoveObject();
|
2023-11-11 21:41:49 +03:00
|
|
|
|
//---
|
2023-09-17 22:13:42 +03:00
|
|
|
|
TextLog log = new TextLog();
|
2023-10-30 18:28:01 +03:00
|
|
|
|
if (Current.Check(log, Current.SapforTasksPackage)) {
|
2023-09-17 22:13:42 +03:00
|
|
|
|
object = Current.getSapforTasksPackage();
|
2023-11-11 21:41:49 +03:00
|
|
|
|
if (object.isLoaded() || (Pass_2021.passes.get(PassCode_2021.DownloadSapforTasksPackage).Do(object))) {
|
2023-11-07 19:13:07 +03:00
|
|
|
|
showObject();
|
2023-11-19 01:22:41 +03:00
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
|
} else
|
|
|
|
|
|
UI.Info(log.toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
public void Show() throws Exception {
|
|
|
|
|
|
}
|
2023-11-08 02:05:21 +03:00
|
|
|
|
public void showNoObject() {
|
2023-09-17 22:13:42 +03:00
|
|
|
|
lObjectName.setText("?");
|
|
|
|
|
|
lObjectName.setToolTipText("Объект не назначен.");
|
2023-11-08 02:05:21 +03:00
|
|
|
|
showNoTree();
|
2023-11-07 19:13:07 +03:00
|
|
|
|
if (isMaster()) {
|
2023-11-02 01:08:00 +03:00
|
|
|
|
UI.getMainWindow().getTestingWindow().ShowNoSapforPackageVersionEtalon();
|
2023-11-07 19:13:07 +03:00
|
|
|
|
} else {
|
2023-11-02 01:08:00 +03:00
|
|
|
|
UI.getMainWindow().getTestingWindow().ShowNoSapforPackageVersion();
|
|
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
2023-11-08 02:05:21 +03:00
|
|
|
|
//---
|
|
|
|
|
|
public void showCommonTree() {
|
2023-11-09 02:11:05 +03:00
|
|
|
|
//---
|
2023-11-11 21:41:49 +03:00
|
|
|
|
treePanel.add(treeScroll = new JScrollPane(
|
|
|
|
|
|
Body = new SapforTasksPackageTree(object.results.root,
|
2023-11-07 19:13:07 +03:00
|
|
|
|
isMaster() ? Current.SapforEtalonVersion : Current.SapforVersion
|
|
|
|
|
|
)));
|
2023-11-09 19:20:51 +03:00
|
|
|
|
treePanel.repaint();
|
|
|
|
|
|
treePanel.revalidate();
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
2023-11-11 21:41:49 +03:00
|
|
|
|
public void showComparisonTree() {
|
2023-11-10 02:56:35 +03:00
|
|
|
|
treePanel.add(treeScroll = new JScrollPane(
|
2023-11-11 21:41:49 +03:00
|
|
|
|
Body = new SapforTasksPackageTree(object.results.comparison_root,
|
2023-11-09 02:11:05 +03:00
|
|
|
|
isMaster() ? Current.SapforEtalonVersion : Current.SapforVersion
|
|
|
|
|
|
)));
|
2023-11-09 19:20:51 +03:00
|
|
|
|
treePanel.repaint();
|
|
|
|
|
|
treePanel.revalidate();
|
2023-11-08 02:05:21 +03:00
|
|
|
|
}
|
|
|
|
|
|
//---
|
|
|
|
|
|
public void showNoTree() {
|
|
|
|
|
|
UI.Clear(treePanel);
|
|
|
|
|
|
}
|
|
|
|
|
|
public void showObject() {
|
|
|
|
|
|
lObjectName.setText(object.getPK().toString() + (isMaster() ? "(эталон)" : ""));
|
|
|
|
|
|
lObjectName.setToolTipText(object.getPK().toString());
|
2023-11-09 02:11:05 +03:00
|
|
|
|
//--
|
|
|
|
|
|
if (object.results == null)
|
|
|
|
|
|
object.readResults();
|
|
|
|
|
|
//--
|
2023-11-08 02:05:21 +03:00
|
|
|
|
showCommonTree();
|
|
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
|
protected String getText() {
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
public SapforPackagesComparisonForm(SapforPackagesComparisonForm slave_in) {
|
|
|
|
|
|
//-
|
|
|
|
|
|
this_ = this;
|
|
|
|
|
|
slave = slave_in;
|
|
|
|
|
|
bPrevious.setVisible(isMaster());
|
|
|
|
|
|
bNext.setVisible(isMaster());
|
|
|
|
|
|
bApplyObject.addActionListener(e -> {
|
|
|
|
|
|
ApplyObject();
|
|
|
|
|
|
});
|
|
|
|
|
|
//--->>>
|
|
|
|
|
|
if (isMaster()) {
|
|
|
|
|
|
slave.master = this;
|
|
|
|
|
|
bPrevious.addActionListener(e -> {
|
|
|
|
|
|
});
|
|
|
|
|
|
bNext.addActionListener(e -> {
|
|
|
|
|
|
});
|
|
|
|
|
|
bCompare.addActionListener(e -> {
|
2023-11-07 19:13:07 +03:00
|
|
|
|
DoComparePass();
|
2023-09-17 22:13:42 +03:00
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//рабу сравнивать не положено.
|
|
|
|
|
|
bCompare.setVisible(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
//--->>>
|
|
|
|
|
|
bClose.addActionListener(e -> {
|
|
|
|
|
|
onClose();
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
//-->>
|
|
|
|
|
|
private void createUIComponents() {
|
|
|
|
|
|
// TODO: place custom component creation code here
|
|
|
|
|
|
lObjectName = new ShortLabel(40);
|
|
|
|
|
|
tools = new VisualiserMenuBar();
|
|
|
|
|
|
}
|
|
|
|
|
|
//для сравнения по кнопке.
|
|
|
|
|
|
public boolean isReady() {
|
2023-11-06 22:37:31 +03:00
|
|
|
|
return object != null;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
public void onClose() {
|
|
|
|
|
|
RemoveObject();
|
|
|
|
|
|
}
|
2023-11-07 19:13:07 +03:00
|
|
|
|
public void DoComparePass() {
|
2023-09-17 22:13:42 +03:00
|
|
|
|
Pass_2021 pass = new Pass_2021() {
|
2023-11-07 19:13:07 +03:00
|
|
|
|
SapforTasksPackage package1;
|
|
|
|
|
|
SapforTasksPackage package2;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
@Override
|
|
|
|
|
|
public String getDescription() {
|
|
|
|
|
|
return "Сравнение";
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected boolean needsAnimation() {
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public boolean needsConfirmations() {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
2023-11-07 19:13:07 +03:00
|
|
|
|
if (isReady() && slave.isReady()) {
|
2023-11-08 02:05:21 +03:00
|
|
|
|
//--
|
2023-11-07 19:13:07 +03:00
|
|
|
|
package1 = object;
|
|
|
|
|
|
package2 = slave.object;
|
2023-11-08 02:05:21 +03:00
|
|
|
|
//--
|
2023-11-07 19:13:07 +03:00
|
|
|
|
if (!package1.testsIds.equals(package2.testsIds)) {
|
|
|
|
|
|
Log.Writeln_("Наборы тестов пакетов не совпадают!");
|
2023-11-08 02:05:21 +03:00
|
|
|
|
return false;
|
2023-11-07 19:13:07 +03:00
|
|
|
|
}
|
|
|
|
|
|
if (!package1.configurationsIds.equals(package2.configurationsIds)) {
|
|
|
|
|
|
Log.Writeln_("Наборы конфигураций не совпадают!");
|
2023-11-08 02:05:21 +03:00
|
|
|
|
return false;
|
2023-11-07 19:13:07 +03:00
|
|
|
|
}
|
2023-11-09 01:47:46 +03:00
|
|
|
|
for (String key1 : package1.results.allTasks.keySet()) {
|
|
|
|
|
|
if (!package2.results.allTasks.containsKey(key1)) {
|
|
|
|
|
|
Log.Writeln_("Задача эталона " + key1 + "не найдена в сравниваемом пакете!");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return Log.isEmpty();
|
2023-11-07 19:13:07 +03:00
|
|
|
|
}
|
|
|
|
|
|
return false;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
2023-11-08 03:05:29 +03:00
|
|
|
|
protected void performPreparation() throws Exception {
|
2023-11-11 21:41:49 +03:00
|
|
|
|
comparisonMode = false;
|
|
|
|
|
|
slave.comparisonMode = false;
|
2023-11-10 02:56:35 +03:00
|
|
|
|
//--
|
|
|
|
|
|
treeScroll = null;
|
|
|
|
|
|
slave.treeScroll = null;
|
|
|
|
|
|
//--
|
2023-11-09 15:20:34 +03:00
|
|
|
|
package1.results.DropComparison();
|
|
|
|
|
|
package2.results.DropComparison();
|
2023-11-08 03:05:29 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
2023-11-08 02:05:21 +03:00
|
|
|
|
protected void showPreparation() throws Exception {
|
|
|
|
|
|
showNoTree();
|
|
|
|
|
|
slave.showNoTree();
|
|
|
|
|
|
//--->>>
|
2023-11-11 20:07:14 +03:00
|
|
|
|
UI.getMainWindow().getTestingWindow().ShowNoSapforPackageVersionEtalon();
|
|
|
|
|
|
UI.getMainWindow().getTestingWindow().ShowNoSapforPackageVersion();
|
2023-11-08 02:05:21 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
2023-09-17 22:13:42 +03:00
|
|
|
|
protected void body() throws Exception {
|
2023-11-09 15:20:34 +03:00
|
|
|
|
System.out.println(package1.results.allTasks.size());
|
|
|
|
|
|
System.out.println(package2.results.allTasks.size());
|
2023-11-09 01:47:46 +03:00
|
|
|
|
//теперь сравниваем задачи
|
2023-11-09 15:20:34 +03:00
|
|
|
|
int i = 1;
|
2023-11-09 01:47:46 +03:00
|
|
|
|
for (String key1 : package1.results.allTasks.keySet()) {
|
2023-11-09 15:20:34 +03:00
|
|
|
|
System.out.println(i + "=" + key1);
|
2023-11-09 01:47:46 +03:00
|
|
|
|
SapforTask task1 = package1.results.allTasks.get(key1);
|
|
|
|
|
|
SapforTask task2 = package2.results.allTasks.get(key1);
|
|
|
|
|
|
//--
|
|
|
|
|
|
task1.checkMatch(task2);
|
2023-11-09 15:20:34 +03:00
|
|
|
|
//--
|
|
|
|
|
|
++i;
|
2023-11-08 02:05:21 +03:00
|
|
|
|
}
|
2023-11-09 02:11:05 +03:00
|
|
|
|
//--
|
2023-11-09 19:20:51 +03:00
|
|
|
|
package1.results.SortTasksForComparison();
|
|
|
|
|
|
package2.results.SortTasksForComparison();
|
2023-11-09 02:11:05 +03:00
|
|
|
|
//-
|
2023-11-09 19:20:51 +03:00
|
|
|
|
package1.results.buildComparisonTree(package1);
|
|
|
|
|
|
package2.results.buildComparisonTree(package2);
|
2023-11-08 02:05:21 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected boolean validate() {
|
|
|
|
|
|
return Log.isEmpty();
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void showFail() throws Exception {
|
|
|
|
|
|
showCommonTree();
|
|
|
|
|
|
slave.showCommonTree();
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
2023-11-11 21:41:49 +03:00
|
|
|
|
protected void performDone() throws Exception {
|
|
|
|
|
|
comparisonMode = true;
|
|
|
|
|
|
slave.comparisonMode = true;
|
|
|
|
|
|
//--
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
2023-11-11 21:41:49 +03:00
|
|
|
|
protected void showDone() throws Exception {
|
|
|
|
|
|
showComparisonTree();
|
|
|
|
|
|
slave.showComparisonTree();
|
|
|
|
|
|
SynchronizeTrees();
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
pass.Do();
|
|
|
|
|
|
}
|
2023-11-11 21:41:49 +03:00
|
|
|
|
public void SynchronizeTrees() {
|
|
|
|
|
|
if (slave.Body!=null) {
|
|
|
|
|
|
Body.setSlaveTree(slave.Body);
|
|
|
|
|
|
slave.treeScroll.getVerticalScrollBar().setModel(treeScroll.getVerticalScrollBar().getModel());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|