Files
VisualSapfor/src/_VisualDVM/ProjectData/Files/ProjectFile.java
02090095 0b5f8c6ec7 ++
рефакторинг бд файлов тестов.
2025-03-20 17:48:18 +03:00

71 lines
2.3 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package _VisualDVM.ProjectData.Files;
import Common.CommonConstants;
import Common.Database.Objects.DBObject;
import Common.Utils.Utils_;
import _VisualDVM.Constants;
import _VisualDVM.ProjectData.LanguageName;
import javax.swing.*;
import java.io.File;
import java.net.URL;
public class ProjectFile extends projectFile_ {
public File file = null; //собственно, файл на который ссылаемся.
public FileState state = FileState.Undefined; //состояние файла.
public ProjectFile() {
}
public ProjectFile(File file_in) {
super(file_in);
file = file_in;
}
@Override
public Object getPK() {
return file.getName();
}
@Override
public void AutoDetectProperties(String name_in) {
super.AutoDetectProperties(name_in);
if (fileType.equals(FileType.forbidden) || fileType.equals(FileType.none))
state= FileState.Excluded;
}
public String ImageKey() {
//icons/files/Excludeddata.png
String pref = "/icons/files/";
String body;
switch (fileType) {
case program:
body = state.toString() + languageName.toString();
break;
case data:
body = "Undefined"; // иных состояний у данных не бывает. ситуация возникает если по ошибке поменяли тип
//нормальных файлов с сообщениями на дату.
break;
default:
body = state.toString();
break;
}
return pref + body + fileType + ".png";
}
public ImageIcon GetIcon() {
URL imageUrl = getClass().getResource(ImageKey());
if (imageUrl == null) {
System.out.println(ImageKey() + "not found");
}
return new ImageIcon(imageUrl);
}
public String getUnixName() {
return Utils_.toU(file.getName());
}
@Override
public String toString() {
return file.getName();
}
public String getQSourceName() {
return Utils_.DQuotes(getUnixName());
}
public boolean isNotExcludedProgram() {
return fileType.equals(FileType.program) && !languageName.equals(LanguageName.n) && !state.equals(FileState.Excluded);
}
}