промежуточный. небольшой рефакторинг. наследие DBProjectFile от ProjectFile.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package ProjectData.Files;
|
||||
import Common.Constants;
|
||||
import Common.Current;
|
||||
import Common.Database.DBObject;
|
||||
import Common.Global;
|
||||
import Common.Utils.Utils;
|
||||
import ProjectData.GCOV.GCOV_info;
|
||||
@@ -17,62 +16,41 @@ import ProjectData.SapforData.Functions.FuncCall;
|
||||
import ProjectData.SapforData.Functions.FuncInfo;
|
||||
import ProjectData.SapforData.Loops.Loop;
|
||||
import Visual_DVM_2021.UI.Main.FileForm;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
import javafx.util.Pair;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
//по файлам нет смысла делать совместимость.
|
||||
//так что переименую
|
||||
public class DBProjectFile extends DBObject {
|
||||
public static final String no_data = "Нет данных";
|
||||
public static final String dep = ".dep";
|
||||
public static final String out = ".out";
|
||||
public static final String err = ".err";
|
||||
//</editor-fold>
|
||||
//<editor-fold desc="хранимые в бд поля">
|
||||
|
||||
@Description("PRIMARY KEY, UNIQUE") @Expose
|
||||
public class DBProjectFile extends ProjectFile {
|
||||
@Description("PRIMARY KEY, UNIQUE")
|
||||
public String name; //имя относительно корневой папки проекта. нужно только как ключ для бд!!
|
||||
@Description("IGNORE")
|
||||
public String last_assembly_name = ""; //имя объектника.
|
||||
//--------------------------------------
|
||||
//в сотальных случаях используем file.
|
||||
@Expose
|
||||
public FileType fileType = FileType.none;
|
||||
@Expose
|
||||
public LanguageName languageName = LanguageName.n;
|
||||
@Expose
|
||||
public LanguageStyle style = LanguageStyle.none;
|
||||
public String options = ""; //пользовательские опции для парсера.
|
||||
// public int caretPosition = 0;
|
||||
//---
|
||||
@Description("DEFAULT 0")
|
||||
public int lastLine = 0;
|
||||
@Description("DEFAULT ''")
|
||||
public String GCOVLog = "";
|
||||
//---
|
||||
public FileState state = FileState.Undefined; //состояние файла.
|
||||
public int isMain = 0; //содержит ли ГПЕ
|
||||
@Description("IGNORE")
|
||||
public int lines_count = 0;
|
||||
@Description("IGNORE")
|
||||
public boolean NeedsSave = false;
|
||||
@Description("IGNORE")
|
||||
public String LoopGraphTitle = no_data;
|
||||
public String LoopGraphTitle = Constants.no_data;
|
||||
@Description("IGNORE")
|
||||
public String CallGraphTitle = no_data;
|
||||
public String CallGraphTitle = Constants.no_data;
|
||||
@Description("IGNORE")
|
||||
public String ArrayGraphTitle = no_data;
|
||||
public String ArrayGraphTitle = Constants.no_data;
|
||||
public db_project_info father = null;
|
||||
public File file = null;
|
||||
public DefaultMutableTreeNode node = null; //узел файла в дереве
|
||||
public FileForm form = null; //отображение.
|
||||
//сообщения.
|
||||
@@ -144,111 +122,11 @@ public class DBProjectFile extends DBObject {
|
||||
//для совместимости пусть палки будут от винды всегда.
|
||||
name = path.substring(father.Home.getAbsolutePath().length() + 1).replace('/', '\\');
|
||||
}
|
||||
public void AutoDetectProperties() {
|
||||
//проверка запретных имен.
|
||||
String[] forbiddenNames = new String[]{
|
||||
Constants.INTERRUPT,
|
||||
db_project_info.launch_script_name,
|
||||
db_project_info.default_binary_name,
|
||||
//--
|
||||
Constants.DONE,
|
||||
Constants.TIMEOUT,
|
||||
Constants.out_file,
|
||||
Constants.err_file,
|
||||
Constants.time_file,
|
||||
"Makefile"
|
||||
};
|
||||
for (String forbidden : forbiddenNames) {
|
||||
if (file.getName().equalsIgnoreCase(forbidden)) {
|
||||
fileType = FileType.forbidden;
|
||||
return;
|
||||
}
|
||||
}
|
||||
//-
|
||||
switch (Utils.getExtension(file)) {
|
||||
case "f":
|
||||
case "fdv":
|
||||
case "for":
|
||||
case "f77":
|
||||
fileType = FileType.program;
|
||||
languageName = LanguageName.fortran;
|
||||
style = LanguageStyle.fixed;
|
||||
break;
|
||||
case "f90":
|
||||
fileType = FileType.program;
|
||||
languageName = LanguageName.fortran;
|
||||
style = LanguageStyle.free;
|
||||
break;
|
||||
case "c":
|
||||
case "cdv":
|
||||
fileType = FileType.program;
|
||||
languageName = LanguageName.c;
|
||||
break;
|
||||
case "cpp":
|
||||
fileType = FileType.program;
|
||||
languageName = LanguageName.cpp;
|
||||
break;
|
||||
case "h":
|
||||
fileType = FileType.header;
|
||||
break;
|
||||
case "fh":
|
||||
fileType = FileType.header;
|
||||
languageName = LanguageName.fortran;
|
||||
break;
|
||||
case "o":
|
||||
case "gcda":
|
||||
case "gcno":
|
||||
case "gcov":
|
||||
case "exe":
|
||||
case "pdf":
|
||||
fileType = FileType.forbidden;
|
||||
break;
|
||||
case "":
|
||||
if (Utils.isDigit(file.getName())) {
|
||||
fileType = FileType.forbidden;
|
||||
} else {
|
||||
state = FileState.Excluded;
|
||||
fileType = FileType.none;
|
||||
languageName = LanguageName.n;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//все остальное считаем исключенными из рассмотрения.
|
||||
//если юзеру надо сам их разблочит.
|
||||
state = FileState.Excluded;
|
||||
fileType = FileType.none;
|
||||
languageName = LanguageName.n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isMakefile() {
|
||||
return file.getName().equalsIgnoreCase("makefile");
|
||||
}
|
||||
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 boolean isActiveProgram() {
|
||||
return fileType.equals(FileType.program)
|
||||
&& languageName.equals(father.languageName) && !state.equals(FileState.Excluded);
|
||||
@@ -261,13 +139,13 @@ public class DBProjectFile extends DBObject {
|
||||
return isActiveProgram() || isActiveHeader();
|
||||
}
|
||||
public File getDepFile() {
|
||||
return Paths.get(father.getOptionsDirectory().getAbsolutePath(), getLocalName() + dep).toFile();
|
||||
return Paths.get(father.getOptionsDirectory().getAbsolutePath(), getLocalName() + Constants.dep).toFile();
|
||||
}
|
||||
public File getParserOutFile() {
|
||||
return Paths.get(father.getOptionsDirectory().getAbsolutePath(), getLocalName() + out).toFile();
|
||||
return Paths.get(father.getOptionsDirectory().getAbsolutePath(), getLocalName() + Constants.out).toFile();
|
||||
}
|
||||
public File getParserErrFile() {
|
||||
return Paths.get(father.getOptionsDirectory().getAbsolutePath(), getLocalName() + err).toFile();
|
||||
return Paths.get(father.getOptionsDirectory().getAbsolutePath(), getLocalName() + Constants.err).toFile();
|
||||
}
|
||||
public File getOptionsFile() {
|
||||
String path = file.getAbsolutePath().substring(father.Home.getAbsolutePath().length());
|
||||
@@ -340,14 +218,14 @@ public class DBProjectFile extends DBObject {
|
||||
lines_count = 0;
|
||||
isMain = 0;
|
||||
CleanMessages();
|
||||
LoopGraphTitle = no_data;
|
||||
LoopGraphTitle = Constants.no_data;
|
||||
LoopNests.clear();
|
||||
;
|
||||
AllLoops.clear();
|
||||
CallGraphTitle = no_data;
|
||||
CallGraphTitle = Constants.no_data;
|
||||
function_decls.clear();
|
||||
relativeHeaders.clear();
|
||||
ArrayGraphTitle = no_data;
|
||||
ArrayGraphTitle = Constants.no_data;
|
||||
array_decls.clear();
|
||||
gcov_info.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user