промежуточный. улучшение удаления баг репортов, в процессе отображения диалогового окна

This commit is contained in:
2024-08-18 01:08:56 +03:00
parent de1d81ac33
commit 39e9c634a2
12 changed files with 244 additions and 18 deletions

14
.idea/workspace.xml generated
View File

@@ -7,10 +7,18 @@
</component>
<component name="ChangeListManager">
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/bug_1723053809" afterDir="false" />
<change afterPath="$PROJECT_DIR$/bug_1723053818" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/GlobalData/FileObject/FileObject.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/GlobalData/FileObject/FileObjectsDataSet.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/GlobalData/FileObject/FileObjectsFields.form" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/GlobalData/FileObject/FileObjectsFields.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/GetOldBugReports.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ProjectData/Files/DBProjectFile.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ProjectData/Files/DBProjectFile.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Common/UI/Menus_2023/MainMenuBar/MainMenuBar.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/UI/Menus_2023/MainMenuBar/MainMenuBar.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Common/Utils/Utils.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Utils/Utils.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/ArchivesBackupPass.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/ArchivesBackupPass.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/DeleteDownloadedBugReports.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/DeleteDownloadedBugReports.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/TestPass.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/TestPass.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PassCode_2021.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PassCode_2021.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@@ -55,7 +55,7 @@ public class MainMenuBar extends VisualiserMenuBar {
//-
setPreferredSize(new Dimension(0, 30));
//---
/*
add(new MenuBarButton() {
{
setIcon("/icons/Apply.png");
@@ -65,7 +65,6 @@ public class MainMenuBar extends VisualiserMenuBar {
});
}
});
*/
ShowProject(false);
}
public void ShowUpdatesIcon() {

View File

@@ -1249,5 +1249,42 @@ public class Utils {
}
return true;
}
//--
private static void get_newest_file_date_r(File dir, Vector<Long> dates){
Vector<File> files= new Vector(Arrays.asList(dir.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isFile();
}
})));
if (!files.isEmpty()) {
files.sort(new Comparator<File>() {
@Override
public int compare(File o1, File o2) {
return Long.compare(o1.lastModified(), o2.lastModified());
}
}.reversed());
dates.add(files.firstElement().lastModified());
}
//--
Vector<File> subdirs= new Vector(Arrays.asList(dir.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isDirectory();
}
})));
if (!subdirs.isEmpty()){
for (File subdir: subdirs)
get_newest_file_date_r(subdir, dates);
}
}
public static long getNewestFileDate(File dir){
Vector<Long> dates = new Vector<>();
dates.add(dir.lastModified());
get_newest_file_date_r(dir, dates);
Collections.sort(dates);
System.out.println(new Date(dates.lastElement()));
return dates.firstElement();
}
}

View File

@@ -0,0 +1,18 @@
package GlobalData.FileObject;
import Common.Database.DBObject;
import java.io.File;
import java.util.Date;
public class FileObject extends DBObject {
File file;
public FileObject(File file_in){
file=file;
}
@Override
public Object getPK() {
return file.getName();
}
public Date getDate(){
return new Date(file.lastModified());
}
}

View File

@@ -0,0 +1,34 @@
package GlobalData.FileObject;
import Common.Database.DataSet;
import Common.UI.DataSetControlForm;
import GlobalData.Machine.Machine;
import static Common.UI.Tables.TableRenderers.*;
public class FileObjectsDataSet extends DataSet<String, FileObject> {
public FileObjectsDataSet() {
super(String.class, FileObject.class);
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this){
@Override
protected void AdditionalInitColumns() {
// columns.get(1).setRenderer(RendererDate);
}
};
}
@Override
public String[] getUIColumnNames(){
return new String[]{
"дата изменения"};
}
@Override
public Object getFieldAt(FileObject object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.file.getName();
default:
return null;
}
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="GlobalData.FileObject.FileObjectsFields">
<grid id="27dc6" binding="content" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</form>

View File

@@ -0,0 +1,12 @@
package GlobalData.FileObject;
import Common.UI.Windows.Dialog.DialogFields;
import javax.swing.*;
import java.awt.*;
public class FileObjectsFields implements DialogFields {
public JPanel content;
@Override
public Component getContent() {
return content;
}
}

View File

@@ -9,6 +9,7 @@ import com.jcraft.jsch.ChannelSftp;
import java.io.File;
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.Vector;
public class ArchivesBackupPass extends ConnectionPass<File> {
File src;
@@ -37,7 +38,13 @@ public class ArchivesBackupPass extends ConnectionPass<File> {
}
}
//сортируем по времени обновления. по убыванию.
files.sort((o1, o2) -> (int) (o2.updateTime - o1.updateTime));
files.sort(new Comparator<RemoteFile>() {
@Override
public int compare(RemoteFile o1, RemoteFile o2) {
return Long.compare(o1.updateTime, o2.updateTime);
}
}.reversed()
);
for (int i = 2; i < files.size(); ++i) {
user.connection.sftpChannel.rm(files.get(i).full_name);
}

View File

@@ -2,13 +2,19 @@ package Visual_DVM_2021.Passes.All;
import Common.Current;
import Common.Global;
import Common.UI.UI;
import Common.UI.Windows.Dialog.Dialog;
import Common.Utils.Utils;
import GlobalData.FileObject.FileObject;
import GlobalData.FileObject.FileObjectsDataSet;
import GlobalData.FileObject.FileObjectsFields;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import Visual_DVM_2021.Passes.UI.CopyProjectFields;
import javax.swing.*;
import java.io.File;
import java.util.Arrays;
import java.util.Vector;
import java.nio.file.Paths;
import java.util.*;
public class DeleteDownloadedBugReports extends Pass_2021<Vector<File>> {
@Override
protected boolean needsAnimation() {
@@ -21,26 +27,73 @@ public class DeleteDownloadedBugReports extends Pass_2021<Vector<File>> {
@Override
protected boolean canStart(Object... args) throws Exception {
target = null;
if (passes.get(PassCode_2021.GetOldBugReports).Do()){
target = (Vector<File>) passes.get(PassCode_2021.GetOldBugReports).target;
FileObjectsDataSet set = new FileObjectsDataSet();
for (File file: target){
set.put(file.getName(),new FileObject(file));
}
//-
Dialog<Object, FileObjectsFields> dialog = new Dialog<Object, FileObjectsFields>(FileObjectsFields.class) {
@Override
public int getDefaultHeight() {
return 230;
}
@Override
public void Init(Object... params) {
set.mountUI((JPanel) content);
set.ShowUI();
}
@Override
public void validateFields() {
}
};
if (dialog.ShowDialog("Найдено "+target.size()+" загруженных баг-репортов, не использовавшихся 2 месяца и более. Удалить их?")) {
return true;
}
}
/*
else return false;
File workspace = Global.visualiser.getWorkspace();
File[] files = workspace.listFiles(pathname -> pathname.isDirectory() && pathname.getName().toLowerCase().startsWith("bugreport_"));
if (files != null) {
target = new Vector<>(Arrays.asList(files));
return UI.Warning("Будет удалено " + target.size() + " скачанных отчётов об ошибках." +
(Current.HasProject() ? "(Текущий проект будет закрыт)" : "")
);
//---
Calendar c = new GregorianCalendar();
c.setTimeInMillis(System.currentTimeMillis());
c.add(Calendar.MONTH, -2);
Date date = c.getTime();
System.out.println(date);
//---
return false;
//---
// return UI.Warning("Будет удалено " + target.size() + " скачанных отчётов об ошибках." +
// (Current.HasProject() ? "(Текущий проект будет закрыт)" : "")
// );
}
*/
return false;
}
@Override
protected void performPreparation() throws Exception {
/*
if (Current.HasProject())
passes.get(PassCode_2021.CloseCurrentProject).Do();
*/
}
@Override
protected void body() throws Exception {
/*
for (File file : target) {
ShowMessage1(file.getAbsolutePath());
Utils.forceDeleteWithCheck(file);
}
*/
UI.Info("+");
}
}

View File

@@ -0,0 +1,41 @@
package Visual_DVM_2021.Passes.All;
import Common.Global;
import Common.Utils.Utils;
import Visual_DVM_2021.Passes.Pass_2021;
import java.io.File;
import java.util.*;
public class GetOldBugReports extends Pass_2021<Vector<File>> {
@Override
protected boolean canStart(Object... args) throws Exception {
target = new Vector<>();
return true;
}
@Override
protected boolean needsAnimation() {
return true;
}
@Override
protected void body() throws Exception {
File workspace = Global.visualiser.getWorkspace();
File[] files = workspace.listFiles(pathname -> pathname.isDirectory() && pathname.getName().toLowerCase().startsWith("bugreport_"));
if (files != null) {
//---
Calendar c = new GregorianCalendar();
c.setTimeInMillis(System.currentTimeMillis());
c.add(Calendar.MONTH, -2);
Date date = c.getTime();
System.out.println(date);
long border = date.getTime();
//--
for (File file: files){
ShowMessage2(file.getName());
long mdate = Utils.getNewestFileDate(file);
if (mdate<=border){
target.add(file);
}
}
}
}
}

View File

@@ -1,10 +1,13 @@
package Visual_DVM_2021.Passes.All;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
public class TestPass extends TestingSystemPass {
import Common.Utils.Utils;
import Visual_DVM_2021.Passes.Pass_2021;
import java.io.File;
public class TestPass extends Pass_2021<File> {
@Override
protected void ServerAction() throws Exception {
// Command(new ServerExchangeUnit_2021(ServerCode.GetSapforActualVersion));
protected void body() throws Exception {
//определить дату изменения проекта.
target = new File("E:\\Tests\\bugreport_1712090719\\SP");
Utils.getNewestFileDate(target);
}
}

View File

@@ -340,12 +340,15 @@ public enum PassCode_2021 {
ShowTestingServerFile,
//--
ShowSapforCompilationOut,
ShowSapforCompilationErr;
ShowSapforCompilationErr,
GetOldBugReports;
//--
public String getDescription() {
switch (this) {
case Undefined:
return "?";
case GetOldBugReports:
return "Получить неиспользуемые баг репорты";
case SPF_RenameIncludes:
return "Переименование заголовочных файлов";
case ShowSapforCompilationOut: