упорядочил папки с кодом.

This commit is contained in:
2023-11-19 01:53:56 +03:00
parent 4883b4af51
commit 44c6daffa3
596 changed files with 2140 additions and 1569 deletions

View File

@@ -1,77 +0,0 @@
package Repository.BugReport;
import Common.Current;
import Common.Database.DBObject;
import Common.Database.rDBObject;
import Common.Global;
import Repository.Component.ComponentType;
import com.sun.org.glassfish.gmbal.Description;
import java.io.File;
import java.util.Date;
public class BugReport extends rDBObject {
public String project_version = "";
public long visualiser_version = -1;
public long sapfor_version = -1;
public String sapfor_settings = "";
public String comment = "";
public String targets = "";
public String executor = "";
@Description("DEFAULT ''")
public String executor_address = "";
public BugReportState state;
public int percentage = 0;
//-
@Description("IGNORE")
public String descriptionAdditionDraft = "";
@Description("IGNORE")
public String commentAdditionDraft = "";
@Description("IGNORE")
public File owner = null;
public BugReport() {
}
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
BugReport b = (BugReport) src;
change_date = b.change_date;
description = b.description;
comment = b.comment;
targets = b.targets;
state = b.state;
percentage = b.percentage;
//-
executor = b.executor;
executor_address = b.executor_address;
project_version = b.project_version;
visualiser_version = b.visualiser_version;
sapfor_version = b.sapfor_version;
sapfor_settings = b.sapfor_settings;
//-
descriptionAdditionDraft = b.descriptionAdditionDraft;
commentAdditionDraft = b.commentAdditionDraft;
owner = b.owner;
}
public BugReport(BugReport src) {
this.SynchronizeFields(src);
}
public BugReport(String sender_name_in, String sender_address_in, String description_in, String version_in) {
genName();
sender_name = sender_name_in;
sender_address = sender_address_in;
project_version = version_in;
visualiser_version = Global.visualiser.version;
sapfor_version = Global.Components.get(ComponentType.Sapfor_F).version;
sapfor_settings = Global.db.settings.getSapforSettingsText();
percentage = 0;
description = description_in;
date = new Date().getTime();
change_date = new Date().getTime();
state = BugReportState.draft;
owner = Current.getProject().Home;
}
@Override
public boolean isVisible() {
return BugReportInterface.isVisible(this);
}
}

View File

@@ -1,126 +0,0 @@
package Repository.BugReport;
import Common.Current;
import Common.Global;
import Common.Utils.TextLog;
import Common.Utils.Utils;
import Repository.RepositoryServer;
import Repository.Subscribes.Subscriber;
import java.io.File;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Vector;
public class BugReportInterface {
public static String filterKey = "";
public static String filterSenderName = "";
public static String filterDescription = "";
public static String filterComment = "";
public static String filterExecutor = "";
public static String filterVersion = "";
public static boolean filterOpenedOnly = false;
public static boolean filterMyOnly = false;
public static boolean isVisible(BugReport object) {
return
object.state.equals(BugReportState.draft) ||
object.id.toUpperCase().contains(filterKey.toUpperCase())
&& object.sender_name.toUpperCase().contains(filterSenderName.toUpperCase())
&& object.description.toUpperCase().contains(filterDescription.toUpperCase())
&& object.comment.toUpperCase().contains(filterComment.toUpperCase())
&& object.executor.toUpperCase().contains(filterExecutor.toUpperCase())
&& object.project_version.toUpperCase().contains(filterVersion.toUpperCase())
&& (!filterOpenedOnly || object.state.equals(BugReportState.active))
&& (!filterMyOnly ||
(object.sender_address.equalsIgnoreCase(Current.getAccount().email) ||
object.executor_address.equalsIgnoreCase(Current.getAccount().email)
)
);
}
public static String getPackedTargets() {
Vector<String> selected = new Vector<>();
for (Subscriber subscriber : Global.componentsServer.db.subscribers.Data.values())
if (subscriber.isSelected()) selected.add(subscriber.address);
return String.join("\n", selected);
}
public static File getArchiveFile(BugReport object) {
return Paths.get(System.getProperty("user.dir"), "Bugs", object.id + ".zip").toFile();
}
public static String getDescriptionHeader(BugReport object) {
if (object.description != null) {
String[] data = object.description.split("\n");
return (data.length > 0) ? data[0] : "";
} else return "";
}
public static void CheckSubscribers(BugReport object) {
for (Subscriber subscriber : Global.componentsServer.db.subscribers.Data.values())
subscriber.Select(object.targets.contains(subscriber.address));
}
public static boolean CheckNotDraft(BugReport object, TextLog log) {
if (object.state.equals(BugReportState.draft)) {
log.Writeln_("Отчёт об ошибке является черновиком");
return false;
}
return true;
}
public static String getMailTitlePrefix(BugReport object) {
return "Ошибка " + Utils.Brackets(object.id) + ", автор " + Utils.Brackets(object.sender_name) + " : ";
}
public static Vector<String> getRecipients(BugReport object, boolean add_defaults) {
Vector<String> res = new Vector<>();
String[] data = object.targets.split("\n");
for (String a : data)
if (a.length() > 0)
res.add(a);
if (add_defaults) {
// res.add(Email.full_address); //служебный ящик
//добавить админов если их там нет.
Arrays.stream(Global.admins_mails).filter(adm -> !res.contains(adm)).forEach(res::add);
// и себя
if (!res.contains(Current.getAccount().email))
res.add(Current.getAccount().email);
}
return res;
}
public static File[] getAttachements(BugReport object) {
File[] project_attachements = Current.getProject().getAttachmentsDirectory().listFiles();
File[] res = new File[project_attachements.length + 1];
res[0] = getArchiveFile(object);
for (int i = 0; i < project_attachements.length; ++i)
res[i + 1] = project_attachements[i];
return res;
}
public static boolean CheckDraft(BugReport object, TextLog log) {
if (!object.state.equals(BugReportState.draft)) {
log.Writeln("Отчёт об ошибке не является черновиком. Он уже опубликован");
return false;
}
return true;
}
public static String getNewMailText(BugReport object) {
String res = String.join("\n",
"Описание:", object.description,
getPassport(object)
);
return res;
}
public static String getSettingsSummary(BugReport object) {
return
(Current.HasAccount() ? (Current.getAccount().isAdmin() ? ("Адрес отправителя: " + object.sender_address + "\n") : "") : "") +
"Версия SAPFOR: " + object.sapfor_version + "\n" +
"Версия визуализатора: " + object.visualiser_version + "\n" +
"----------------------------------\n" +
object.sapfor_settings;
}
public static String getPassport(BugReport object) {
return String.join("\n",
RepositoryServer.separator,
"Отправитель: " + object.sender_name,
"Исполнитель: " + object.executor,
"Проект: " + object.project_version,
RepositoryServer.separator,
getSettingsSummary(object),
RepositoryServer.separator);
}
public static boolean isNoneProject(BugReport object) {
return object.project_version.isEmpty();
}
}

View File

@@ -1,35 +0,0 @@
package Repository.BugReport;
import Common.Current;
import Common.UI.StatusEnum;
import Common.UI.Themes.VisualiserFonts;
import java.awt.*;
import java.io.Serializable;
public enum BugReportState implements Serializable, StatusEnum {
active,
closed,
draft;
@Override
public Font getFont() {
switch (this) {
case active:
return Current.getTheme().Fonts.get(VisualiserFonts.BadState);
case closed:
return Current.getTheme().Fonts.get(VisualiserFonts.GoodState);
default:
return StatusEnum.super.getFont();
}
}
public String getDescription() {
switch (this) {
case draft:
return "черновик";
case active:
return "открыт";
case closed:
return "закрыт";
default:
return StatusEnum.super.getDescription();
}
}
}

View File

@@ -1,115 +0,0 @@
package Repository.BugReport;
import Common.Current;
import Common.Database.DBTable;
import Common.UI.DataSetControlForm;
import Common.UI.UI;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.Comparator;
import java.util.Vector;
import java.util.stream.Collectors;
import static Common.UI.Tables.TableRenderers.*;
public class BugReportsDBTable extends DBTable<String, BugReport> {
public BugReportsDBTable() {
super(String.class, BugReport.class);
}
@Override
public String getSingleDescription() {
return "отчёт об ошибке";
}
@Override
public String getPluralDescription() {
return "отчёты об ошибках";
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
public void ShowCurrentObject() throws Exception {
super.ShowCurrentObject();
UI.getMainWindow().getCallbackWindow().ShowCurrentBugReport();
}
@Override
public void ShowNoCurrentObject() throws Exception {
super.ShowNoCurrentObject();
UI.getMainWindow().getCallbackWindow().ShowNoCurrentBugReport();
}
@Override
protected void AdditionalInitColumns() {
columns.get(1).setMaxWidth(600);
columns.get(5).setRenderer(RendererProgress);
columns.get(6).setRenderer(RendererDate);
columns.get(7).setRenderer(RendererDate);
columns.get(8).setRenderer(RendererStatusEnum);
}
@Override
public void MouseAction2() throws Exception {
Pass_2021.passes.get(PassCode_2021.OpenBugReportTestProject).Do();
}
@Override
public void CreateControl() {
//https://stackoverflow.com/questions/9091208/jtable-enter-key
super.CreateControl();
final String solve = "Solve";
KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
control.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(enter, solve);
control.getActionMap().put(solve, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
Pass_2021.passes.get(PassCode_2021.OpenBugReportTestProject).Do();
}
});
}
};
}
@Override
public Comparator<BugReport> getComparator() {
return (o1, o2) -> -(o1.getDate().compareTo(o2.getDate()));
}
@Override
public String[] getUIColumnNames() {
return new String[]{"Описание",
"Отправитель",
"Исполнитель",
"Проект",
"Завершенность",
"Дата создания",
"Дата изменения",
"Статус"};
}
@Override
public Object getFieldAt(BugReport object, int columnIndex) {
switch (columnIndex) {
case 1:
return BugReportInterface.getDescriptionHeader(object);
case 2:
return object.sender_name;
case 3:
return object.executor;
case 4:
return object.project_version;
case 5:
return object.percentage;
case 6:
return object.getDate();
case 7:
return object.getChangeDate();
case 8:
return object.state;
default:
return null;
}
}
@Override
public Current CurrentName() {
return Current.BugReport;
}
public Vector<BugReport> getAllDrafts() throws Exception {
return Data.values().stream().filter(bugReport -> bugReport.state.equals(BugReportState.draft)).collect(Collectors.toCollection(Vector::new));
}
}