промежуточный. улучшение удаления баг репортов, в процессе отображения диалогового окна
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
18
src/GlobalData/FileObject/FileObject.java
Normal file
18
src/GlobalData/FileObject/FileObject.java
Normal 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());
|
||||
}
|
||||
}
|
||||
34
src/GlobalData/FileObject/FileObjectsDataSet.java
Normal file
34
src/GlobalData/FileObject/FileObjectsDataSet.java
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
src/GlobalData/FileObject/FileObjectsFields.form
Normal file
11
src/GlobalData/FileObject/FileObjectsFields.form
Normal 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>
|
||||
12
src/GlobalData/FileObject/FileObjectsFields.java
Normal file
12
src/GlobalData/FileObject/FileObjectsFields.java
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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("+");
|
||||
}
|
||||
}
|
||||
|
||||
41
src/Visual_DVM_2021/Passes/All/GetOldBugReports.java
Normal file
41
src/Visual_DVM_2021/Passes/All/GetOldBugReports.java
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user