no message
This commit is contained in:
79
src/_VisualDVM/Repository/BugReport/BugReport.java
Normal file
79
src/_VisualDVM/Repository/BugReport/BugReport.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package _VisualDVM.Repository.BugReport;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Objects.rDBObject;
|
||||
import _VisualDVM.GlobalData.GlobalDatabase;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.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 = ((GlobalDatabase)CommonUtils.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);
|
||||
}
|
||||
}
|
||||
119
src/_VisualDVM/Repository/BugReport/BugReportInterface.java
Normal file
119
src/_VisualDVM/Repository/BugReport/BugReportInterface.java
Normal file
@@ -0,0 +1,119 @@
|
||||
package _VisualDVM.Repository.BugReport;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Current;
|
||||
import _VisualDVM.Global;
|
||||
import Common.Utils.TextLog;
|
||||
import _VisualDVM.Repository.RepositoryServer;
|
||||
import _VisualDVM.Repository.Subscribes.Subscriber;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
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 "Ошибка " + CommonUtils.Brackets(object.id) + ", автор " + CommonUtils.Brackets(object.sender_name) + " : ";
|
||||
}
|
||||
public static Vector<String> getRecipients(BugReport object) {
|
||||
Vector<String> res = new Vector<>();
|
||||
String[] data = object.targets.split("\n");
|
||||
for (String a : data)
|
||||
if (a.length() > 0)
|
||||
res.add(a);
|
||||
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();
|
||||
}
|
||||
}
|
||||
33
src/_VisualDVM/Repository/BugReport/BugReportState.java
Normal file
33
src/_VisualDVM/Repository/BugReport/BugReportState.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package _VisualDVM.Repository.BugReport;
|
||||
import Common.Visual.StatusEnum;
|
||||
import Common.Visual.Fonts.VisualiserFonts;
|
||||
|
||||
import java.io.Serializable;
|
||||
public enum BugReportState implements Serializable, StatusEnum {
|
||||
active,
|
||||
closed,
|
||||
draft;
|
||||
@Override
|
||||
public VisualiserFonts getFont() {
|
||||
switch (this) {
|
||||
case active:
|
||||
return VisualiserFonts.BadState;
|
||||
case closed:
|
||||
return 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
115
src/_VisualDVM/Repository/BugReport/BugReportsDBTable.java
Normal file
115
src/_VisualDVM/Repository/BugReport/BugReportsDBTable.java
Normal file
@@ -0,0 +1,115 @@
|
||||
package _VisualDVM.Repository.BugReport;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Database.Tables.DBTable;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import _VisualDVM.Visual.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.Visual.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));
|
||||
}
|
||||
}
|
||||
17
src/_VisualDVM/Repository/BugReport/BugReportsMenuBar.java
Normal file
17
src/_VisualDVM/Repository/BugReport/BugReportsMenuBar.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package _VisualDVM.Repository.BugReport;
|
||||
import Common.Visual.Menus.DataMenuBar;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
public class BugReportsMenuBar extends DataMenuBar {
|
||||
public BugReportsMenuBar() {
|
||||
super("отчёты об ошибках",
|
||||
PassCode_2021.SynchronizeBugReports,
|
||||
PassCode_2021.DownloadAllBugReportsArchives,
|
||||
PassCode_2021.AddBugReport,
|
||||
PassCode_2021.PublishBugReport,
|
||||
PassCode_2021.OpenBugReportTestProject,
|
||||
PassCode_2021.OpenBugReport,
|
||||
PassCode_2021.UpdateBugReportProgress,
|
||||
PassCode_2021.CloseBugReport,
|
||||
PassCode_2021.DeleteBugReport);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user