упорядочил папки с кодом.
This commit is contained in:
@@ -1,140 +0,0 @@
|
||||
package Repository.Component;
|
||||
import Common.Constants;
|
||||
import Common.Database.DBObject;
|
||||
import Common.Global;
|
||||
import Common.Utils.Files.VFileChooser;
|
||||
import Common.Utils.TextLog;
|
||||
import Common.Utils.Utils;
|
||||
import Visual_DVM_2021.Passes.PassException;
|
||||
import Visual_DVM_2021.UI.Interface.Loggable;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
public abstract class Component extends DBObject implements Loggable {
|
||||
public String date_text = Constants.dateNaN;
|
||||
public long version = Constants.Nan;
|
||||
public long actual_version = Constants.Nan;
|
||||
public long minimal_version = Constants.Nan;
|
||||
//--
|
||||
public String code = "";
|
||||
public String actual_code = "";
|
||||
public boolean needs_update_minimal_version = false;
|
||||
private ComponentState state;
|
||||
public abstract ComponentType getComponentType();
|
||||
VFileChooser fileChooser = null; ///для ручной установки.
|
||||
public VFileChooser getFileChooser() {
|
||||
return (fileChooser == null) ? (fileChooser = new VFileChooser("выбор файла для компонента " +
|
||||
Utils.Brackets(getComponentType().getDescription()), Utils.getExtension(getFile())))
|
||||
: fileChooser;
|
||||
}
|
||||
//--
|
||||
public String getVersionText() {
|
||||
return String.valueOf(version);
|
||||
}
|
||||
public void CheckIfNeedsUpdateOrPublish() {
|
||||
if (actual_version != Constants.Nan) {
|
||||
if (version < minimal_version) setState(ComponentState.Old_version);
|
||||
else {
|
||||
ComponentState new_state =
|
||||
(actual_version > version) ? ComponentState.Needs_update : (
|
||||
(actual_version < version) ? ComponentState.Needs_publish : ComponentState.Actual);
|
||||
setState(new_state);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void InitialVersionCheck() {
|
||||
setState(ComponentState.Undefined);
|
||||
if (getFile().exists()) {
|
||||
GetVersionInfo();
|
||||
if (version == Constants.Nan)
|
||||
setState(ComponentState.Unknown_version);
|
||||
} else setState(ComponentState.Not_found);
|
||||
}
|
||||
public boolean CanBeUpdated() {
|
||||
return state != ComponentState.Not_found && state != ComponentState.Unknown_version && state != ComponentState.Old_version;
|
||||
}
|
||||
public void GetVersionInfo() {
|
||||
}
|
||||
public void unpackActualVersion(String v_string) {
|
||||
actual_version = Long.parseLong(v_string);
|
||||
}
|
||||
public void unpackMinimalVersion(String v_string) {
|
||||
minimal_version = Long.parseLong(v_string);
|
||||
}
|
||||
public void ReplaceOldFile() throws Exception {
|
||||
Utils.delete_with_check(getFile());
|
||||
System.out.println("old file removed");
|
||||
//-скопировать файл
|
||||
Files.move(getNewFile().toPath(), getFile().toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
//удалить новый файл.
|
||||
Utils.delete_with_check(getNewFile());
|
||||
System.out.println("new file removed");
|
||||
}
|
||||
public void Update() throws Exception {
|
||||
if (!getNewFile().setExecutable(true)) throw new PassException("Не удалось разрешить файл\n" +
|
||||
getNewFile() +
|
||||
"\nна выполнение");
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public Object getPK() {
|
||||
return getComponentType();
|
||||
}
|
||||
public boolean isValidVersion(TextLog Log, String desc) {
|
||||
if (version == Constants.Nan) {
|
||||
Log.Writeln_("Не определена версия " + desc + " компонента " + Utils.Brackets(getComponentType().getDescription()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//------------------>>>
|
||||
public String getHome() {
|
||||
return Global.ComponentsDirectory.getAbsolutePath();
|
||||
}
|
||||
public String getFileName() {
|
||||
return "";
|
||||
}
|
||||
public String getNewFileName() {
|
||||
return "";
|
||||
}
|
||||
public String getBackUpFileName() {
|
||||
return getComponentType().toString() + "_" + version;
|
||||
}
|
||||
public File getFile() {
|
||||
return Paths.get(getHome(), getFileName()).toFile();
|
||||
}
|
||||
public File getNewFile() {
|
||||
return Paths.get(getHome(), getNewFileName()).toFile();
|
||||
}
|
||||
public File getBackUpFile() {
|
||||
return Paths.get(Global.BackUpsDirectory.getAbsolutePath(), getBackUpFileName()).toFile();
|
||||
}
|
||||
public ComponentState getState() {
|
||||
return state;
|
||||
}
|
||||
public void setState(ComponentState state_in) {
|
||||
state = state_in;
|
||||
}
|
||||
public String getAssemblyCommand() {
|
||||
return "";
|
||||
}
|
||||
public File getAssemblyFile() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public String getLogHomePath() {
|
||||
return Global.ComponentsDirectory.getAbsolutePath();
|
||||
}
|
||||
@Override
|
||||
public String getLogName() {
|
||||
return getComponentType().toString();
|
||||
}
|
||||
public boolean isNecessary() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package Repository.Component;
|
||||
import Common.Current;
|
||||
import Common.UI.StatusEnum;
|
||||
import Common.UI.Themes.VisualiserFonts;
|
||||
|
||||
import java.awt.*;
|
||||
public enum ComponentState implements StatusEnum {
|
||||
Undefined,
|
||||
Actual,
|
||||
Needs_update,
|
||||
Not_found,
|
||||
Old_version,
|
||||
Needs_publish,
|
||||
Unknown_version;
|
||||
@Override
|
||||
public Font getFont() {
|
||||
switch (this) {
|
||||
case Actual:
|
||||
return Current.getTheme().Fonts.get(VisualiserFonts.GoodState);
|
||||
case Not_found:
|
||||
case Unknown_version:
|
||||
case Old_version:
|
||||
return Current.getTheme().Fonts.get(VisualiserFonts.BadState);
|
||||
case Needs_update:
|
||||
return Current.getTheme().Fonts.get(VisualiserFonts.ProgressState);
|
||||
case Needs_publish:
|
||||
return Current.getTheme().Fonts.get(VisualiserFonts.BlueState);
|
||||
default:
|
||||
return StatusEnum.super.getFont();
|
||||
}
|
||||
}
|
||||
public String getDescription() {
|
||||
switch (this) {
|
||||
case Actual:
|
||||
return "актуален";
|
||||
case Not_found:
|
||||
return "не найден";
|
||||
case Old_version:
|
||||
return "устаревшая версия";
|
||||
case Needs_update:
|
||||
return "найдено обновление";
|
||||
case Needs_publish:
|
||||
return "ожидает публикации";
|
||||
case Unknown_version:
|
||||
return "не удалось определить версию";
|
||||
default:
|
||||
return StatusEnum.super.getDescription();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package Repository.Component;
|
||||
import java.io.Serializable;
|
||||
public enum ComponentType implements Serializable {
|
||||
Undefined,
|
||||
//внутренние
|
||||
Visualiser, //возможно к нему привязать VisualSapfor.jar
|
||||
Visualizer_2,
|
||||
SapforOptions,
|
||||
ComparsionOptions,
|
||||
SapforWrapper, //todo ЗАЧЕМ???
|
||||
//---------------------
|
||||
//------------------
|
||||
Sapfor_F,
|
||||
Sapfor_C,
|
||||
Instruction,
|
||||
PerformanceAnalyzer;
|
||||
//------------------
|
||||
public String getDescription() {
|
||||
String res = "";
|
||||
switch (this) {
|
||||
case Visualiser:
|
||||
return "Визуализатор";
|
||||
case Sapfor_F:
|
||||
return "Sapfor (Fortran)";
|
||||
case Visualizer_2:
|
||||
return "Сервер";
|
||||
case Instruction:
|
||||
return "Инструкция";
|
||||
case PerformanceAnalyzer:
|
||||
return "Анализатор DVM статистик";
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package Repository.Component;
|
||||
import Common.Current;
|
||||
import Common.Database.DataSet;
|
||||
import Common.UI.DataSetControlForm;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import static Common.UI.Tables.TableRenderers.RendererMaskedInt;
|
||||
import static Common.UI.Tables.TableRenderers.RendererStatusEnum;
|
||||
public class ComponentsSet extends DataSet<ComponentType, Component> {
|
||||
public ComponentsSet() {
|
||||
super(ComponentType.class, Component.class);
|
||||
}
|
||||
@Override
|
||||
public String getSingleDescription() {
|
||||
return "компонент";
|
||||
}
|
||||
@Override
|
||||
public String getPluralDescription() {
|
||||
return "компоненты";
|
||||
}
|
||||
@Override
|
||||
protected DataSetControlForm createUI() {
|
||||
return new DataSetControlForm(this) {
|
||||
@Override
|
||||
public boolean hasCheckBox() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected void AdditionalInitColumns() {
|
||||
columns.get(0).setVisible(false);
|
||||
columns.get(3).setRenderer(RendererMaskedInt);
|
||||
columns.get(4).setRenderer(RendererMaskedInt);
|
||||
columns.get(6).setRenderer(RendererStatusEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public String[] getUIColumnNames() {
|
||||
return new String[]{"Компонент", "Текущая версия", "Актуальная версия", "Дата сборки", "Статус"};
|
||||
}
|
||||
@Override
|
||||
public Object getFieldAt(Component object, int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 2:
|
||||
return object.getComponentType().getDescription();
|
||||
case 3:
|
||||
return object.version;
|
||||
case 4:
|
||||
return object.actual_version;
|
||||
case 5:
|
||||
return object.date_text;
|
||||
case 6:
|
||||
return object.getState();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Current CurrentName() {
|
||||
return Current.Component;
|
||||
}
|
||||
@Override
|
||||
public Vector<Component> getCheckedItems() {
|
||||
Vector<Component> target = new Vector<>();
|
||||
Component visualiser = null;
|
||||
Component server = null;
|
||||
//------------------------
|
||||
for (Component component : super.getCheckedItems()) {
|
||||
switch (component.getComponentType()) {
|
||||
case Visualizer_2:
|
||||
server = component;
|
||||
break;
|
||||
case Visualiser:
|
||||
visualiser = component;
|
||||
break;
|
||||
default:
|
||||
target.add(component);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (visualiser != null)
|
||||
target.add(visualiser);
|
||||
if (server != null)
|
||||
target.add(server);
|
||||
return target;
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package Repository.Component;
|
||||
import Common.Global;
|
||||
import Common.Utils.Utils;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Locale;
|
||||
public class Instruction extends Component {
|
||||
@Override
|
||||
public String getFileName() {
|
||||
return "Instruction.pdf";
|
||||
}
|
||||
@Override
|
||||
public String getNewFileName() {
|
||||
return "Instruction_new.pdf";
|
||||
}
|
||||
@Override
|
||||
public boolean isNecessary() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public ComponentType getComponentType() {
|
||||
return ComponentType.Instruction;
|
||||
}
|
||||
public void Update() throws Exception {
|
||||
ReplaceOldFile();
|
||||
GetVersionInfo();
|
||||
actual_version = 1;
|
||||
}
|
||||
@Override
|
||||
public String getVersionText() {
|
||||
return code;
|
||||
}
|
||||
//вызывается в первую очередь
|
||||
@Override
|
||||
public void unpackActualVersion(String v_string) {
|
||||
actual_code = v_string;
|
||||
actual_version = code.isEmpty() ? 1 : ((code.equals(actual_code)) ? 1 : 2);
|
||||
if (CanBeUpdated())
|
||||
CheckIfNeedsUpdateOrPublish();
|
||||
}
|
||||
@Override
|
||||
public void unpackMinimalVersion(String v_string) {
|
||||
//--
|
||||
}
|
||||
@Override
|
||||
public void GetVersionInfo() {
|
||||
try {
|
||||
version = 1;
|
||||
code = Utils.md5Custom(Utils.ReadAllText(getFile()));
|
||||
DateFormat df = new SimpleDateFormat("MMM dd yyyy HH:mm:ss", Locale.ENGLISH);
|
||||
date_text = df.format(getFile().lastModified());
|
||||
} catch (Exception e) {
|
||||
Global.Log.PrintException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package Repository.Component;
|
||||
import Common.Global;
|
||||
public abstract class OSDComponent extends Component {
|
||||
@Override
|
||||
public String getFileName() {
|
||||
return getComponentType().toString() + (Global.isWindows ? ".exe" : "");
|
||||
}
|
||||
@Override
|
||||
public String getNewFileName() {
|
||||
return getComponentType().toString() + "_new" + (Global.isWindows ? ".exe" : "");
|
||||
}
|
||||
}
|
||||
@@ -1,171 +0,0 @@
|
||||
package Repository.Component.PerformanceAnalyzer;
|
||||
import Common.Current;
|
||||
import Common.Global;
|
||||
import analyzer.common.MessageJtoJ;
|
||||
import Common.UI.UI;
|
||||
import Common.Utils.Utils;
|
||||
import Repository.Component.Component;
|
||||
import Repository.Component.ComponentType;
|
||||
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.Callable;
|
||||
public class PerformanceAnalyzer extends Component {
|
||||
public static boolean isActive = false;
|
||||
public static Thread main_thread = null;
|
||||
ServerSocket serverSocket = null;
|
||||
Socket client = null;
|
||||
Thread process_thread = null;
|
||||
Thread server_thread = null;
|
||||
//<editor-fold desc="серверная часть">
|
||||
private int port;
|
||||
private ObjectInputStream in; // поток чтения из сокета
|
||||
private ObjectOutputStream out; // поток записи в сокет
|
||||
private MessageJtoJ message_out = null;
|
||||
private MessageJtoJ message_in = null;
|
||||
@Override
|
||||
public ComponentType getComponentType() {
|
||||
return ComponentType.PerformanceAnalyzer;
|
||||
}
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
public void Update() throws Exception {
|
||||
ReplaceOldFile();
|
||||
GetVersionInfo();
|
||||
}
|
||||
@Override
|
||||
public boolean isNecessary() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public String getFileName() {
|
||||
return "PerformanceAnalyzer.jar";
|
||||
}
|
||||
@Override
|
||||
public String getNewFileName() {
|
||||
return "PerformanceAnalyzer_new.jar";
|
||||
}
|
||||
public void Shutdown() {
|
||||
try {
|
||||
if (client != null) {
|
||||
client.setSoLinger(true, 500);
|
||||
client.close();
|
||||
}
|
||||
if (serverSocket != null) serverSocket.close();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
public void ReadMessageIn() throws Exception {
|
||||
message_in = (MessageJtoJ) in.readObject();
|
||||
System.out.println("message = " + Utils.DQuotes(message_in.getMessage()));
|
||||
System.out.println("command = " + Utils.DQuotes(message_in.getCommand()));
|
||||
}
|
||||
public void SendMessageOut(MessageJtoJ messageJtoJ) throws Exception {
|
||||
message_out = messageJtoJ;
|
||||
out.writeObject(message_out);
|
||||
}
|
||||
public void ConvertStatistic() throws Exception {
|
||||
message_in = (MessageJtoJ) in.readObject();
|
||||
System.out.println("message = " + Utils.DQuotes(message_in.getMessage()));
|
||||
System.out.println("command = " + Utils.DQuotes(message_in.getCommand()));
|
||||
String message = Current.getSapfor().readStatForAnalyzer(message_in.getMessage());
|
||||
message_out = new MessageJtoJ(message, message_in.getCommand());
|
||||
out.writeObject(message_out);
|
||||
}
|
||||
public void StartServer(Callable body) throws Exception {
|
||||
serverSocket = new ServerSocket(0, 5, InetAddress.getLoopbackAddress());
|
||||
setPort(serverSocket.getLocalPort());
|
||||
server_thread = new Thread(() -> {
|
||||
try {
|
||||
client = serverSocket.accept();
|
||||
System.out.println("Основной цикл анализатора статистик начат..");
|
||||
out = new ObjectOutputStream(client.getOutputStream());
|
||||
in = new ObjectInputStream(client.getInputStream());
|
||||
//------------------------------------------------------->>;
|
||||
body.call();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
server_thread.start();
|
||||
System.out.println("Нить сервера запущена");
|
||||
}
|
||||
@Override
|
||||
public void GetVersionInfo() {
|
||||
try {
|
||||
StartServer(() -> {
|
||||
System.out.println("Запрос версии анализатора..");
|
||||
ReadMessageIn(); //на версию.
|
||||
version = (long) Double.parseDouble(message_in.getMessage());
|
||||
ReadMessageIn(); //на дату.
|
||||
date_text = message_in.getMessage();
|
||||
System.out.println("Завершено");
|
||||
return null;
|
||||
});
|
||||
//--
|
||||
/*
|
||||
Utils.performProcess("java", "-jar",
|
||||
"-Dprism.order=sw",
|
||||
Utils.DQuotes(Global.performanceAnalyzer.getFile()), "--port", String.valueOf(getPort()), "--version");
|
||||
*/
|
||||
Utils.startScript(Global.TempDirectory, Global.ComponentsDirectory, "analyzer",
|
||||
"java -jar -Dprism.order=sw "+ Utils.DQuotes(Global.performanceAnalyzer.getFile()) + " --port "+ getPort()+ " --version" );
|
||||
//-
|
||||
server_thread.join();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
Shutdown();
|
||||
System.out.println("FINALIZE");
|
||||
}
|
||||
}
|
||||
public void ServerBody() {
|
||||
//1. нить сервера. слушать.
|
||||
try {
|
||||
StartServer(() -> {
|
||||
SendMessageOut(new MessageJtoJ(
|
||||
Current.HasProject() ? Current.getProject().getAnalyzerDirectory().getAbsolutePath() : Global.PerformanceAnalyzerDirectory.getAbsolutePath(), "StatDirPath"));
|
||||
while (true) ConvertStatistic();
|
||||
});
|
||||
// UI.Info(String.valueOf(getPort()));
|
||||
process_thread = new Thread(() -> {
|
||||
System.out.println("+");
|
||||
try {
|
||||
|
||||
Utils.startScript(Global.TempDirectory, Global.ComponentsDirectory, "analyzer",
|
||||
"java -jar -Dprism.order=sw "+ Utils.DQuotes(Global.performanceAnalyzer.getFile()) + " --port "+ getPort());
|
||||
//-
|
||||
System.out.println("++");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
process_thread.start();
|
||||
isActive = true;
|
||||
process_thread.join();
|
||||
server_thread.join();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
Shutdown();
|
||||
System.out.println("FINALIZE");
|
||||
isActive = false;
|
||||
}
|
||||
}
|
||||
public void Start() {
|
||||
if (isActive) {
|
||||
UI.Info("Анализатор уже запущен");
|
||||
} else {
|
||||
main_thread = new Thread(this::ServerBody);
|
||||
main_thread.start();
|
||||
}
|
||||
}
|
||||
//</editor-fold>
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package Repository.Component.Sapfor;
|
||||
import Common.Current;
|
||||
import Common.Global;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.InetAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
public class MessagesServer {
|
||||
ServerSocket serverSocket = null;
|
||||
Socket client = null;
|
||||
Thread thread = null;
|
||||
private int port;
|
||||
public MessagesServer() throws Exception {
|
||||
serverSocket = new ServerSocket(0, 5, InetAddress.getLoopbackAddress());
|
||||
setPort(serverSocket.getLocalPort());
|
||||
}
|
||||
public MessagesServer(int port_in) {
|
||||
port = port_in;
|
||||
}
|
||||
public void Start() {
|
||||
thread = new Thread(() -> {
|
||||
while (true) {
|
||||
try {
|
||||
client = serverSocket.accept();
|
||||
BufferedReader in = new BufferedReader(new
|
||||
InputStreamReader(client.getInputStream()));
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
if (Current.HasPassForm())
|
||||
Current.getPassForm().Result.ShowSapforMessage(line);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// UI.Print(DebugPrintLevel.MessagesServer, "соединение сброшено!");
|
||||
}
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
}
|
||||
public void Shutdown() {
|
||||
try {
|
||||
if (client != null) {
|
||||
client.setSoLinger(true, 500);
|
||||
client.close();
|
||||
}
|
||||
if (serverSocket != null)
|
||||
serverSocket.close();
|
||||
} catch (Exception e) {
|
||||
Global.Log.PrintException(e);
|
||||
}
|
||||
}
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
}
|
||||
@@ -1,489 +0,0 @@
|
||||
package Repository.Component.Sapfor;
|
||||
import Common.Constants;
|
||||
import Common.Current;
|
||||
import Common.Global;
|
||||
import Common.UI.UI;
|
||||
import Common.Utils.Utils;
|
||||
import GlobalData.Settings.SettingName;
|
||||
import ProjectData.Files.DBProjectFile;
|
||||
import ProjectData.Files.FileState;
|
||||
import ProjectData.Files.LanguageStyle;
|
||||
import ProjectData.Project.db_project_info;
|
||||
import Repository.Component.OSDComponent;
|
||||
import Repository.Component.Visualizer_2;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.PassException;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public abstract class Sapfor extends OSDComponent {
|
||||
public static final int empty_code = -100;
|
||||
public static final int canceled_code = -99;
|
||||
public static final int invalid_proj_code = -2;
|
||||
public Vector<String> Intrinsics = new Vector<>();
|
||||
public LinkedHashMap<String, String> ModifiedFiles = new LinkedHashMap<>();
|
||||
public LinkedHashMap<String, String> OldFiles = new LinkedHashMap<>();
|
||||
int size;
|
||||
int[] sizes;
|
||||
private int errorCode;
|
||||
private String result;
|
||||
private String output;
|
||||
private String outputMessage;
|
||||
private String predictorStats;
|
||||
String PID = "";
|
||||
//-
|
||||
public static String pack(String... params) {
|
||||
StringBuilder res = new StringBuilder();
|
||||
for (String param : params)
|
||||
res.append(param.length()).append(" ").append(param);
|
||||
return res.toString();
|
||||
}
|
||||
public void refreshPid() {
|
||||
try {
|
||||
// UI.Info("Calling SPF_GetCurrentPID...");
|
||||
RunAnalysis("SPF_GetCurrentPID", -1, "", "");
|
||||
PID = getResult();
|
||||
// UI.Info("PID = " + Utils.Brackets(PID));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static PassCode_2021[] getAnalysesCodes() {
|
||||
return new PassCode_2021[]{
|
||||
PassCode_2021.SPF_ParseFilesWithOrder,
|
||||
PassCode_2021.SPF_GetFileLineInfo,
|
||||
PassCode_2021.SPF_GetArrayDistributionOnlyRegions,
|
||||
PassCode_2021.SPF_GetIncludeDependencies,
|
||||
PassCode_2021.SPF_GetGraphLoops,
|
||||
PassCode_2021.SPF_GetGraphFunctions,
|
||||
PassCode_2021.SPF_GetAllDeclaratedArrays,
|
||||
PassCode_2021.SPF_GetArrayDistributionOnlyAnalysis,
|
||||
PassCode_2021.SPF_GetArrayDistribution
|
||||
};
|
||||
}
|
||||
public static PassCode_2021[] getLoopsTransformationsCodes() {
|
||||
return new PassCode_2021[]{
|
||||
PassCode_2021.SPF_LoopEndDoConverterPass,
|
||||
PassCode_2021.SPF_LoopFission,
|
||||
PassCode_2021.SPF_LoopUnion,
|
||||
PassCode_2021.SPF_LoopUnrolling
|
||||
};
|
||||
}
|
||||
public static PassCode_2021[] getPrivatesTransformationsCodes() {
|
||||
return new PassCode_2021[]{
|
||||
PassCode_2021.SPF_PrivateShrinking,
|
||||
PassCode_2021.SPF_PrivateExpansion,
|
||||
PassCode_2021.SPF_PrivateRemoving
|
||||
};
|
||||
}
|
||||
public static PassCode_2021[] getProceduresTransformationsCodes() {
|
||||
return new PassCode_2021[]{
|
||||
PassCode_2021.SPF_InlineProcedures,
|
||||
PassCode_2021.SPF_InlineProceduresH,
|
||||
PassCode_2021.SPF_DuplicateFunctionChains,
|
||||
PassCode_2021.SPF_RemoveUnusedFunctions
|
||||
};
|
||||
}
|
||||
public static PassCode_2021[] getDVMTransformationsCodes() {
|
||||
return new PassCode_2021[]{
|
||||
PassCode_2021.SPF_RemoveDvmDirectivesToComments,
|
||||
PassCode_2021.SPF_RemoveDvmDirectives
|
||||
};
|
||||
}
|
||||
public static PassCode_2021[] getIntervalsTransformationsCodes() {
|
||||
return new PassCode_2021[]{
|
||||
PassCode_2021.SPF_CreateIntervalsTree,
|
||||
PassCode_2021.SPF_RemoveDvmIntervals
|
||||
};
|
||||
}
|
||||
public static PassCode_2021[] getRegionsTransformationsCodes() {
|
||||
return new PassCode_2021[]{
|
||||
PassCode_2021.SPF_ResolveParallelRegionConflicts,
|
||||
PassCode_2021.SPF_InsertDvmhRegions
|
||||
};
|
||||
}
|
||||
public static PassCode_2021[] getPreparationTransformationsCodes() {
|
||||
return new PassCode_2021[]{
|
||||
PassCode_2021.SPF_InsertIncludesPass,
|
||||
PassCode_2021.SPF_CorrectCodeStylePass,
|
||||
PassCode_2021.SPF_ConvertStructures,
|
||||
PassCode_2021.SPF_CreateCheckpoints,
|
||||
PassCode_2021.SPF_InitDeclsWithZero,
|
||||
PassCode_2021.SPF_ExpressionSubstitution,
|
||||
PassCode_2021.EraseBadSymbols,
|
||||
PassCode_2021.CombineFiles,
|
||||
PassCode_2021.CopyProject,
|
||||
PassCode_2021.PrepareForModulesAssembly,
|
||||
PassCode_2021.DVMConvertProject,
|
||||
PassCode_2021.SPF_ResolveCommonBlockConflicts
|
||||
};
|
||||
}
|
||||
public static Vector<PassCode_2021> getAllTransformationsCodes() {
|
||||
Vector<PassCode_2021> res = new Vector<>();
|
||||
Collections.addAll(res, getLoopsTransformationsCodes());
|
||||
Collections.addAll(res, getPrivatesTransformationsCodes());
|
||||
Collections.addAll(res, getProceduresTransformationsCodes());
|
||||
Collections.addAll(res, getDVMTransformationsCodes());
|
||||
Collections.addAll(res, getIntervalsTransformationsCodes());
|
||||
Collections.addAll(res, getRegionsTransformationsCodes());
|
||||
Collections.addAll(res, getPreparationTransformationsCodes());
|
||||
return res;
|
||||
}
|
||||
//<editor-fold desc="компонент">
|
||||
@Override
|
||||
public void GetVersionInfo() {
|
||||
try {
|
||||
RunAnalysis("SPF_GetVersionAndBuildDate", -1, "", "");
|
||||
Visualizer_2.UnpackVersionInfo(this, getResult());
|
||||
} catch (Exception e) {
|
||||
Global.Log.PrintException(e);
|
||||
UI.Error("Не удалось получить версию компонента " + Utils.DQuotes(getComponentType().getDescription()));
|
||||
}
|
||||
}
|
||||
public abstract String getUpdateCommand();
|
||||
public abstract String getRestartCommand();
|
||||
@Override
|
||||
public void Update() throws Exception {
|
||||
super.Update();
|
||||
Global.visualizer_2.Command(getUpdateCommand());
|
||||
GetVersionInfo();
|
||||
ResetAllAnalyses();
|
||||
refreshPid();
|
||||
}
|
||||
//</editor-fold>
|
||||
//--------
|
||||
//<editor-fold desc="функционал">
|
||||
public String readStatForAnalyzer(String src) throws Exception {
|
||||
RunAnalysis(
|
||||
"SPF_OpenDvmStatistic",
|
||||
-Global.messagesServer.getPort(),
|
||||
Global.packSapforSettings(),
|
||||
src);
|
||||
return result;
|
||||
}
|
||||
public void readStatToTxt(File src, File dst) throws Exception {
|
||||
RunAnalysis("SPF_StatisticAnalyzer",
|
||||
-1,
|
||||
"",
|
||||
Utils.DQuotes(src.getAbsolutePath()) +
|
||||
" "
|
||||
+ Utils.DQuotes(dst.getAbsolutePath())
|
||||
);
|
||||
}
|
||||
public void Restart() throws Exception {
|
||||
ResetAllAnalyses();
|
||||
Global.visualizer_2.Command(getRestartCommand());
|
||||
refreshPid();
|
||||
}
|
||||
public void Interrupt() throws Exception {
|
||||
Utils.Kill(PID, true);
|
||||
}
|
||||
public void cd(File directory_in) throws Exception {
|
||||
if (RunAnalysis("SPF_ChangeDirectory", -1, directory_in.getAbsolutePath(), "") != 0)
|
||||
throw new PassException("Sapfor: Не удалось перейти в папку "
|
||||
+ Utils.Brackets(directory_in.getAbsolutePath()) +
|
||||
"\n" + "Код возврата: " + getErrorCode());
|
||||
}
|
||||
public String getResult() {
|
||||
return result;
|
||||
}
|
||||
public void setResult(String result) {
|
||||
this.result = result;
|
||||
}
|
||||
public int getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
public void setErrorCode(int errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
public String getOutput() {
|
||||
return output;
|
||||
}
|
||||
public void setOutput(String output) {
|
||||
this.output = output;
|
||||
}
|
||||
public String getOutputMessage() {
|
||||
return outputMessage;
|
||||
}
|
||||
public void setOutputMessage(String outputMessage) {
|
||||
this.outputMessage = outputMessage;
|
||||
}
|
||||
public String getPredictorStats() {
|
||||
return predictorStats;
|
||||
}
|
||||
public void setPredictorStats(String predictorStats) {
|
||||
this.predictorStats = predictorStats;
|
||||
}
|
||||
public void decodeString(String runResult) throws Exception {
|
||||
int codeIdx = runResult.indexOf(' ');
|
||||
if (codeIdx == -1) throw new PassException("Wrong input parameter");
|
||||
setErrorCode(Integer.parseInt(runResult.substring(0, codeIdx)));
|
||||
int lastCodeIdx = 0, count = 0;
|
||||
// for analysis and transformation
|
||||
for (int z = 0; z < 4; ++z) {
|
||||
lastCodeIdx = codeIdx;
|
||||
codeIdx = runResult.indexOf(' ', codeIdx + 1);
|
||||
if (codeIdx == -1) throw new PassException("Wrong input parameter");
|
||||
count = Integer.parseInt(runResult.substring(lastCodeIdx + 1, codeIdx));
|
||||
String sub = runResult.substring(codeIdx + 1, codeIdx + 1 + count);
|
||||
if (z == 0) setResult(sub);
|
||||
else if (z == 1) setOutput(sub);
|
||||
else if (z == 2) setOutputMessage(sub);
|
||||
else if (z == 3) setPredictorStats(sub);
|
||||
codeIdx += count;
|
||||
}
|
||||
// for modification
|
||||
String file_text = null;
|
||||
if (codeIdx + 1 + count < runResult.length())
|
||||
for (int z = 0; z < 3; ++z) {
|
||||
lastCodeIdx = codeIdx;
|
||||
codeIdx = runResult.indexOf(' ', codeIdx + 1);
|
||||
if (codeIdx == -1) throw new PassException("Wrong input parameter");
|
||||
count = Integer.parseInt(runResult.substring(lastCodeIdx + 1, codeIdx));
|
||||
String sub = runResult.substring(codeIdx + 1, codeIdx + 1 + count);
|
||||
if (z == 0) {
|
||||
String[] splited = sub.split("\\|");
|
||||
if (splited.length == 0 || sub.length() == 0)
|
||||
size = 0;
|
||||
else {
|
||||
size = splited.length - 1;
|
||||
sizes = new int[splited.length];
|
||||
for (int k = 0; k < size + 1; ++k)
|
||||
sizes[k] = Integer.parseInt(splited[k]);
|
||||
}
|
||||
} else if (z == 1) file_text = sub;
|
||||
else if (z == 2) {
|
||||
ModifiedFiles.put(Utils.toW(sub), file_text);
|
||||
file_text = null;
|
||||
}
|
||||
codeIdx += count;
|
||||
}
|
||||
}
|
||||
//-
|
||||
public void Command(String request_in) throws Exception {
|
||||
setErrorCode(empty_code);
|
||||
outputMessage = output = result = predictorStats = "";
|
||||
size = 0;
|
||||
sizes = null;
|
||||
ModifiedFiles.clear();
|
||||
//модификации.-------------------------------------------------------------->>>>
|
||||
decodeString(Global.visualizer_2.Command(request_in).replace((char) 1, '\n'));
|
||||
}
|
||||
//-
|
||||
public int RunAnalysis(String analysisName,
|
||||
int winHandler,
|
||||
String options,
|
||||
String projName) throws Exception {
|
||||
Command("analysis:" + pack(analysisName, options, projName) + winHandler);
|
||||
return getErrorCode();
|
||||
}
|
||||
public void RunTransformation(String transformName,
|
||||
int winHandler,
|
||||
String options,
|
||||
String projName,
|
||||
String folderName,
|
||||
String addOpts) throws Exception {
|
||||
Command("transformation:" + pack(transformName, options, projName, folderName, addOpts) + winHandler);
|
||||
}
|
||||
/*
|
||||
Модификации:
|
||||
SPF_ModifyArrayDistribution (addOpt1_c -> regId, addOpt2_c-> int64_t arrArrs, '|' as delimiter)
|
||||
SPF_InlineProcedure (addOpt1_c -> name | file, addOpt2_c-> line)
|
||||
*/
|
||||
public void RunModification(String modifyName, int winHandler, String options, String projName,
|
||||
String folderName, String addOpt1, String addOpt2) throws Exception {
|
||||
Command("modification:" + pack(modifyName, options, projName, folderName, addOpt1, addOpt2) + winHandler);
|
||||
}
|
||||
public void GetIntrinsics() throws Exception {
|
||||
Intrinsics.clear();
|
||||
if (RunAnalysis("SPF_GetIntrinsics", -1, "", "") >= 0) {
|
||||
String[] data = getResult().split(" ");
|
||||
Collections.addAll(Intrinsics, data);
|
||||
}
|
||||
}
|
||||
public boolean isIntrinsic(String func_name) {
|
||||
return Intrinsics.contains(func_name.toLowerCase());
|
||||
}
|
||||
//todo рефакторить. отвязать от текущего проекта.
|
||||
public void UpdateProjectFiles(boolean mode) throws Exception {
|
||||
ResetAllAnalyses();
|
||||
Current.getProject().dropLastModification();
|
||||
DBProjectFile cuf = null;
|
||||
if (Current.HasFile()) {
|
||||
cuf = Current.getFile();
|
||||
Pass_2021.passes.get(PassCode_2021.CloseCurrentFile).Do();
|
||||
}
|
||||
if (mode) //модификация
|
||||
{
|
||||
OldFiles.clear();
|
||||
for (String name : ModifiedFiles.keySet()) {
|
||||
if (Current.getProject().db.files.Data.containsKey(name)) {
|
||||
File file = Current.getProject().db.files.Data.get(name).file;
|
||||
OldFiles.put(name, Utils.ReadAllText(file));
|
||||
Utils.WriteToFile(file, ModifiedFiles.get(name));
|
||||
}
|
||||
}
|
||||
ModifiedFiles.clear();
|
||||
} else //откат.
|
||||
{
|
||||
if (OldFiles.size() > 0) {
|
||||
for (String name : OldFiles.keySet()) {
|
||||
File file = Current.getProject().db.files.Data.get(name).file;
|
||||
Utils.WriteToFile(file, OldFiles.get(name));
|
||||
}
|
||||
OldFiles.clear();
|
||||
} else UI.Info("Сохранение файлов отсутствует.");
|
||||
}
|
||||
if (cuf != null)
|
||||
Pass_2021.passes.get(PassCode_2021.OpenCurrentFile).Do(cuf);
|
||||
}
|
||||
//</editor-fold>
|
||||
public Visual_DVM_2021.Passes.SapforAnalysis getAnalysisByPhase(String phase) {
|
||||
for (PassCode_2021 analysis_code : getAnalysesCodes()) {
|
||||
Visual_DVM_2021.Passes.SapforAnalysis analysis = (Visual_DVM_2021.Passes.SapforAnalysis) Pass_2021.passes.get(analysis_code);
|
||||
if (analysis.phase().equals(phase)) return analysis;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public void ResetAllAnalyses() {
|
||||
for (PassCode_2021 code : getAnalysesCodes())
|
||||
(Pass_2021.passes.get(code)).Reset();
|
||||
//------------------------------------------------------------------------------------------>>>> пакетный режим.
|
||||
if (Current.hasUI()) {
|
||||
Pass_2021.passes.get(PassCode_2021.Precompilation).Reset();
|
||||
Pass_2021.passes.get(PassCode_2021.SPF_GetGCovInfo).Reset();
|
||||
}
|
||||
Global.enable_text_changed = false;
|
||||
Global.transformationPermission = TransformationPermission.None;
|
||||
if ((Current.hasUI()) && (UI.getMainWindow() != null) && (UI.getVersionsWindow() != null))
|
||||
UI.getVersionsWindow().BlockVariants();
|
||||
}
|
||||
//--------------------------------------------------------------------------->>
|
||||
//временный (?) проход, по тихому получить размерность теста, предварительно выполнив тихий парс.
|
||||
//тут все одноразовое. считаем что таблицы бд уже заполнены как надо.
|
||||
public int getTextMaxDim(File testFile, db_project_info target) {
|
||||
int res = Constants.Nan;
|
||||
LinkedHashMap<String, DBProjectFile> files = null;
|
||||
if (testFile != null) {
|
||||
DBProjectFile dbProjectFile = new DBProjectFile(testFile, target);
|
||||
files = new LinkedHashMap<>();
|
||||
files.put(dbProjectFile.name, dbProjectFile);
|
||||
} else
|
||||
files = target.db.files.Data;
|
||||
Vector<String> projLines = new Vector<>();
|
||||
try {
|
||||
target.CreateParserOptionsDirs();
|
||||
//-----
|
||||
Restart();
|
||||
cd(target.Home);
|
||||
//-----
|
||||
//<editor-fold desc="создание proj">
|
||||
for (DBProjectFile f : files.values()) {
|
||||
if (f.isActiveProgram()) {
|
||||
projLines.add(Utils.toU(f.file.getAbsolutePath()));
|
||||
f.CreateParserOptions();
|
||||
}
|
||||
}
|
||||
FileUtils.writeLines(target.getProjFile(), projLines, false);
|
||||
//</editor-fold>
|
||||
//-----
|
||||
RunAnalysis(
|
||||
"SPF_ParseFilesWithOrder",
|
||||
-Global.messagesServer.getPort(),
|
||||
Global.packSapforSettings(),
|
||||
target.getProjFile().getAbsolutePath());
|
||||
if (errorCode >= 0) {
|
||||
projLines.clear();
|
||||
int goodCount = 0;
|
||||
int badCount = 0;
|
||||
for (DBProjectFile f : files.values())
|
||||
if (f.isActive()) f.state = FileState.OK;
|
||||
for (DBProjectFile f : files.values()) {
|
||||
f.ReadParseMessagesNoSave(files);
|
||||
if (f.isActive()) {
|
||||
switch (f.state) {
|
||||
case OK:
|
||||
case HasNotes:
|
||||
case HasWarnings:
|
||||
if (f.isActiveProgram())
|
||||
projLines.add(Utils.toU(f.getDepFile().getAbsolutePath()));
|
||||
goodCount++;
|
||||
break;
|
||||
case HasErrors:
|
||||
badCount++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
FileUtils.writeLines(target.getProjFile(), projLines, false);
|
||||
if (badCount > 0) return res;
|
||||
if (goodCount == 0) return res;
|
||||
} else return res;
|
||||
//---
|
||||
Restart();
|
||||
cd(target.Home);
|
||||
///---
|
||||
RunAnalysis(
|
||||
"SPF_GetMaxMinBlockDistribution",
|
||||
-Global.messagesServer.getPort(),
|
||||
Global.packSapforSettings(),
|
||||
target.getProjFile().getAbsolutePath());
|
||||
if ((errorCode < 0) || target.hasErrorMessages(getOutputMessage()))
|
||||
return res;
|
||||
//--
|
||||
System.out.println(Utils.Brackets(getResult()));
|
||||
String[] data = getResult().split(" ");
|
||||
target.CreateParserOptionsDirs(); // теперь очистка.
|
||||
return Integer.parseInt(data[data.length - 1]);
|
||||
///---
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public LanguageStyle getStyle() throws Exception {
|
||||
return Global.getSetting(SettingName.FREE_FORM).toBoolean() ? LanguageStyle.free : LanguageStyle.fixed;
|
||||
}
|
||||
//----------
|
||||
public static Vector<PassCode_2021> getScenariosCodes() {
|
||||
Vector<PassCode_2021> res = new Vector<>();
|
||||
res.add(PassCode_2021.SPF_InitDeclsWithZero);
|
||||
res.add(PassCode_2021.SPF_ConvertStructures);
|
||||
res.add(PassCode_2021.SPF_ExpressionSubstitution);
|
||||
//--
|
||||
res.add(PassCode_2021.SPF_CreateCheckpoints);
|
||||
res.add(PassCode_2021.SPF_CreateIntervalsTree);
|
||||
res.add(PassCode_2021.SPF_RemoveDvmIntervals);
|
||||
//--
|
||||
res.add(PassCode_2021.SPF_RemoveDvmDirectives);
|
||||
res.add(PassCode_2021.SPF_RemoveDvmDirectivesToComments);
|
||||
//--
|
||||
res.add(PassCode_2021.SPF_LoopEndDoConverterPass);
|
||||
res.add(PassCode_2021.SPF_LoopUnion);
|
||||
res.add(PassCode_2021.SPF_LoopFission);
|
||||
//--
|
||||
res.add(PassCode_2021.SPF_PrivateShrinking);
|
||||
res.add(PassCode_2021.SPF_PrivateExpansion);
|
||||
res.add(PassCode_2021.SPF_PrivateRemoving);
|
||||
//--
|
||||
res.add(PassCode_2021.SPF_RemoveUnusedFunctions);
|
||||
res.add(PassCode_2021.SPF_DuplicateFunctionChains);
|
||||
//--
|
||||
res.add(PassCode_2021.SPF_ResolveParallelRegionConflicts);
|
||||
res.add(PassCode_2021.SPF_ResolveCommonBlockConflicts);
|
||||
//-
|
||||
res.add(PassCode_2021.SPF_InsertDvmhRegions);
|
||||
res.add(PassCode_2021.SPF_SharedMemoryParallelization);
|
||||
res.add(PassCode_2021.CreateParallelVariants);
|
||||
// res.add(PassCode_2021.SPF_InlineProceduresH);
|
||||
// res.add(PassCode_2021.SPF_InlineProcedures);
|
||||
// res.add(PassCode_2021.SPF_InsertIncludesPass);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package Repository.Component.Sapfor;
|
||||
import Common.Global;
|
||||
import Repository.Component.ComponentType;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
public class Sapfor_F extends Sapfor {
|
||||
@Override
|
||||
public ComponentType getComponentType() {
|
||||
return ComponentType.Sapfor_F;
|
||||
}
|
||||
@Override
|
||||
public String getAssemblyCommand() {
|
||||
return "cd Repo/sapfor/experts/Sapfor_2017/_bin\n" +
|
||||
"cmake ../\n" +
|
||||
"make -j 4\n";
|
||||
}
|
||||
@Override
|
||||
public File getAssemblyFile() {
|
||||
return Paths.get(
|
||||
Global.RepoDirectory.getAbsolutePath(),
|
||||
"sapfor/experts/Sapfor_2017/_bin/Sapfor_F").toFile();
|
||||
}
|
||||
@Override
|
||||
public String getUpdateCommand() {
|
||||
return "update_spf: ";
|
||||
}
|
||||
@Override
|
||||
public String getRestartCommand() {
|
||||
return "restart: ";
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package Repository.Component.Sapfor;
|
||||
public enum TransformationPermission {
|
||||
None,
|
||||
All,
|
||||
VariantsOnly
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="Repository.Component.UI.ComponentsFields">
|
||||
<grid id="27dc6" binding="content" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="802" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="a969b" binding="componentsPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -1,17 +0,0 @@
|
||||
package Repository.Component.UI;
|
||||
import Common.Global;
|
||||
import Common.UI.Windows.Dialog.DialogFields;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class ComponentsFields implements DialogFields {
|
||||
public JPanel content;
|
||||
private JPanel componentsPanel;
|
||||
public ComponentsFields() {
|
||||
Global.Components.mountUI(componentsPanel);
|
||||
}
|
||||
@Override
|
||||
public Component getContent() {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package Repository.Component.UI;
|
||||
import Common.Global;
|
||||
import Common.UI.Windows.Dialog.Dialog;
|
||||
|
||||
import java.awt.*;
|
||||
public class ComponentsForm extends Dialog<Object, ComponentsFields> {
|
||||
public ComponentsForm() {
|
||||
super(ComponentsFields.class);
|
||||
}
|
||||
@Override
|
||||
public boolean NeedsScroll() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int getDefaultWidth() {
|
||||
return Global.properties.ComponentsWindowWidth;
|
||||
}
|
||||
@Override
|
||||
public int getDefaultHeight() {
|
||||
return Global.properties.ComponentsWindowHeight;
|
||||
}
|
||||
@Override
|
||||
public void CreateButtons() {
|
||||
}
|
||||
@Override
|
||||
public void Init(Object... params) {
|
||||
Global.Components.ShowUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void LoadSize() {
|
||||
setMinimumSize(new Dimension(650, 250));
|
||||
Dimension dimension = new Dimension(getDefaultWidth(), getDefaultHeight());
|
||||
setPreferredSize(dimension);
|
||||
setSize(dimension);
|
||||
}
|
||||
@Override
|
||||
public void onClose() {
|
||||
super.onClose();
|
||||
Global.properties.ComponentsWindowWidth=getWidth();
|
||||
Global.properties.ComponentsWindowHeight=getHeight();
|
||||
Global.properties.Update();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="Repository.Component.UI.PickUpComponentFields">
|
||||
<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>
|
||||
@@ -1,12 +0,0 @@
|
||||
package Repository.Component.UI;
|
||||
import Common.UI.Windows.Dialog.DialogFields;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class PickUpComponentFields implements DialogFields {
|
||||
private JPanel content;
|
||||
@Override
|
||||
public Component getContent() {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="Repository.Component.UI.PublishFields">
|
||||
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="8" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font size="16"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="8edb0" class="javax.swing.JCheckBox" binding="cbNeedsBroadcast">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="0"/>
|
||||
<selected value="true"/>
|
||||
<text value="Включить оповещение о публикации"/>
|
||||
<verticalAlignment value="3"/>
|
||||
</properties>
|
||||
</component>
|
||||
<scrollpane id="b33e5">
|
||||
<constraints>
|
||||
<grid row="7" column="0" row-span="1" col-span="3" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="326bc" class="javax.swing.JTextArea" binding="taBroadcast" custom-create="true">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<lineWrap value="true"/>
|
||||
<wrapStyleWord value="true"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
<component id="fbdf3" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="6" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="текст оповещения"/>
|
||||
<verticalAlignment value="3"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="21340" class="javax.swing.JCheckBox" binding="cbForceMail">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="0"/>
|
||||
<selected value="false"/>
|
||||
<text value="Разослать файл всем подписчикам"/>
|
||||
<verticalAlignment value="3"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="148fa" class="javax.swing.JCheckBox" binding="cbUpdateMinimalVersion">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="0"/>
|
||||
<selected value="true"/>
|
||||
<text value="Назначить минимальную версию"/>
|
||||
<verticalAlignment value="3"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="b1e6f" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="0"/>
|
||||
<text value="Минимальная версия: "/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="7e269" class="javax.swing.JLabel" binding="lMinimalVersion">
|
||||
<constraints>
|
||||
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="1"/>
|
||||
<text value="?"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="37705">
|
||||
<constraints>
|
||||
<grid row="4" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<component id="128e5" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="0"/>
|
||||
<text value="Публикуемая версия: "/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="84e2b" class="javax.swing.JLabel" binding="lPublishingVersion">
|
||||
<constraints>
|
||||
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="1"/>
|
||||
<text value="?"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="b01cb" class="javax.swing.JCheckBox" binding="cbAssemblyOnServer">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="0"/>
|
||||
<selected value="true"/>
|
||||
<text value="Собрать на сервере"/>
|
||||
<verticalAlignment value="3"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -1,35 +0,0 @@
|
||||
package Repository.Component.UI;
|
||||
import Common.UI.Editor.BaseEditor;
|
||||
import Common.UI.Windows.Dialog.DialogFields;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
public class PublishFields implements DialogFields {
|
||||
public JPanel content;
|
||||
public JCheckBox cbNeedsBroadcast;
|
||||
public JTextArea taBroadcast;
|
||||
public JCheckBox cbForceMail;
|
||||
public JCheckBox cbUpdateMinimalVersion;
|
||||
public JLabel lMinimalVersion;
|
||||
public JLabel lPublishingVersion;
|
||||
public JCheckBox cbAssemblyOnServer;
|
||||
public PublishFields() {
|
||||
cbNeedsBroadcast.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
taBroadcast.setEnabled(cbNeedsBroadcast.isSelected());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void createUIComponents() {
|
||||
// TODO: place custom component creation code here
|
||||
taBroadcast = new BaseEditor();
|
||||
}
|
||||
@Override
|
||||
public Component getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package Repository.Component.UI;
|
||||
import Common.UI.Windows.Dialog.Dialog;
|
||||
public class PublishForm extends Dialog<String, PublishFields> {
|
||||
public PublishForm() {
|
||||
super(PublishFields.class);
|
||||
}
|
||||
@Override
|
||||
public boolean NeedsScroll() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void ProcessResult() {
|
||||
Result = fields.cbNeedsBroadcast.isSelected() ? fields.taBroadcast.getText() : null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package Repository.Component;
|
||||
import Common.Global;
|
||||
import GlobalData.Settings.SettingName;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
public class Visualiser extends Component {
|
||||
//-----------------------------------------
|
||||
private static Date getClassBuildTime() {
|
||||
Date d = null;
|
||||
Class<?> currentClass = new Object() {
|
||||
}.getClass().getEnclosingClass();
|
||||
URL resource = currentClass.getResource(currentClass.getSimpleName() + ".class");
|
||||
if (resource != null) {
|
||||
if (resource.getProtocol().equals("file")) {
|
||||
try {
|
||||
d = new Date(new File(resource.toURI()).lastModified());
|
||||
} catch (URISyntaxException ignored) {
|
||||
}
|
||||
} else if (resource.getProtocol().equals("jar")) {
|
||||
String path = resource.getPath();
|
||||
d = new Date(new File(path.substring(5, path.indexOf("!"))).lastModified());
|
||||
} else if (resource.getProtocol().equals("zip")) {
|
||||
String path = resource.getPath();
|
||||
File jarFileOnDisk = new File(path.substring(0, path.indexOf("!")));
|
||||
try (JarFile jf = new JarFile(jarFileOnDisk)) {
|
||||
ZipEntry ze = jf.getEntry(path.substring(path.indexOf("!") + 2));
|
||||
long zeTimeLong = ze.getTime();
|
||||
Date zeTimeDate = new Date(zeTimeLong);
|
||||
d = zeTimeDate;
|
||||
} catch (IOException | RuntimeException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return d;
|
||||
}
|
||||
@Override
|
||||
public String getFileName() {
|
||||
return "VisualSapfor.jar";
|
||||
}
|
||||
@Override
|
||||
public String getNewFileName() {
|
||||
return "VisualSapfor_new.jar";
|
||||
}
|
||||
@Override
|
||||
public ComponentType getComponentType() {
|
||||
return ComponentType.Visualiser;
|
||||
}
|
||||
//</editor-fold>
|
||||
//<editor-fold desc="Методы">
|
||||
//</editor-// fold>
|
||||
//http://www.seostella.com/ru/article/2012/02/05/formatirovanie-daty-v-java.html
|
||||
@Override
|
||||
public void GetVersionInfo() {
|
||||
version = 1028;
|
||||
String pattern = "MMM dd yyyy HH:mm:ss";
|
||||
DateFormat df = new SimpleDateFormat(pattern, Locale.ENGLISH);
|
||||
date_text = df.format(getClassBuildTime());
|
||||
}
|
||||
@Override
|
||||
public void Update() throws Exception {
|
||||
super.Update();
|
||||
Global.visualizer_2.SendRequest("update: ");
|
||||
System.exit(0);
|
||||
}
|
||||
public File getWorkspace() {
|
||||
if (!Global.db.settings.get(SettingName.Workspace).toString().isEmpty()) {
|
||||
File workspace = new File(Global.db.settings.get(SettingName.Workspace).toString());
|
||||
if (workspace.exists())
|
||||
return workspace;
|
||||
else
|
||||
Pass_2021.passes.get(PassCode_2021.UpdateSetting).Do(
|
||||
SettingName.Workspace, "");
|
||||
}
|
||||
return Global.ProjectsDirectory;
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
package Repository.Component;
|
||||
import Common.Global;
|
||||
import Common.UI.UI;
|
||||
import Common.Utils.Utils;
|
||||
import Visual_DVM_2021.Passes.PassException;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.nio.file.Paths;
|
||||
public class Visualizer_2 extends OSDComponent {
|
||||
//</editor-fold>
|
||||
//-
|
||||
//<editor-fold desc="функционал">
|
||||
int port;
|
||||
public String PID = "";
|
||||
Socket client = null;
|
||||
PrintWriter out = null;
|
||||
BufferedReader in = null;
|
||||
String request = "";
|
||||
String response = "";
|
||||
public Visualizer_2(int port_in) {
|
||||
port = port_in;
|
||||
}
|
||||
public static void UnpackVersionInfo(Component component, String packed) {
|
||||
String[] data = packed.split("\\|");
|
||||
//лишний пробел.
|
||||
String text = data[0].substring(0, data[0].length() - 1);
|
||||
component.date_text = data[1] + data[2] + data[3];
|
||||
component.version = Long.parseLong(text);
|
||||
}
|
||||
//<editor-fold desc="компонент">
|
||||
@Override
|
||||
public ComponentType getComponentType() {
|
||||
return ComponentType.Visualizer_2;
|
||||
}
|
||||
@Override
|
||||
public String getHome() {
|
||||
return Global.Home;
|
||||
}
|
||||
@Override
|
||||
public void GetVersionInfo() {
|
||||
try {
|
||||
Command("get_version: ");
|
||||
UnpackVersionInfo(this, response);
|
||||
} catch (Exception e) {
|
||||
Global.Log.PrintException(e);
|
||||
}
|
||||
}
|
||||
public void refreshPid(){
|
||||
try {
|
||||
// UI.Info("Getting Server PID...");
|
||||
Command("get_pid: ");
|
||||
PID = response;
|
||||
// UI.Info("SERVER PID = "+Utils.Brackets(PID));
|
||||
} catch (Exception e) {
|
||||
Global.Log.PrintException(e);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void Update() throws Exception {
|
||||
super.Update();
|
||||
SendRequest("update_server: ");
|
||||
ReplaceOldFile();
|
||||
UI.Info("Сервер успешно обновлен.\n" +
|
||||
"Визуализатор завершает работу.\n" +
|
||||
"Для продолжения перезапустите визуализатор вручную.");
|
||||
System.exit(0);
|
||||
}
|
||||
@Override
|
||||
public String getAssemblyCommand() {
|
||||
return "cd Repo/sapfor/experts/Sapfor_2017/_src/Server\n" +
|
||||
"g++ -O3 -std=c++17 checkUniq.cpp server.cpp -o Visualizer_2 -lpthread -lstdc++fs\n";
|
||||
}
|
||||
@Override
|
||||
public File getAssemblyFile() {
|
||||
return Paths.get(
|
||||
Global.RepoDirectory.getAbsolutePath(),
|
||||
"sapfor/experts/Sapfor_2017/_src/Server/Visualizer_2").toFile();
|
||||
}
|
||||
public void Connect() throws Exception {
|
||||
ClearLog();
|
||||
Print("соединение с Visualiser_2...");
|
||||
client = Utils.createClientSocket(
|
||||
InetAddress.getLoopbackAddress(),
|
||||
port, 0
|
||||
);
|
||||
Print("+");
|
||||
in = new BufferedReader(new InputStreamReader(client.getInputStream())); //то что нам приходит от сервера
|
||||
out = new PrintWriter(client.getOutputStream(), true); //то что мы пишем серверу.
|
||||
}
|
||||
public void Interrupt(){
|
||||
Utils.Kill(PID, false);
|
||||
}
|
||||
public void Shutdown() throws Exception {
|
||||
Print("завершение сеанса с Visualiser_2...");
|
||||
SendRequest("close: ");
|
||||
if (client != null)
|
||||
client.close();
|
||||
if (in != null)
|
||||
in.close();
|
||||
if (out != null)
|
||||
out.close();
|
||||
}
|
||||
//запрос.
|
||||
public void SendRequest(String request_in) throws Exception {
|
||||
Print("->" + request_in);
|
||||
out.flush();
|
||||
System.gc();
|
||||
out.println(request = request_in);
|
||||
Print("+");
|
||||
}
|
||||
//запрос-ответ. анализируются только общие ошибочные случаи.
|
||||
public String Command(String request_in) throws Exception {
|
||||
SendRequest(request_in);
|
||||
response = in.readLine();
|
||||
switch (response) {
|
||||
case "NOT_FOUND":
|
||||
case "WRONG":
|
||||
case "SEG_FAULT":
|
||||
throw new PassException("Команда серверу SAPFOR вернула " + Utils.Brackets(response));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Print("<-" + response);
|
||||
Print("+");
|
||||
out.flush();
|
||||
System.gc();
|
||||
return response;
|
||||
}
|
||||
//</editor-fold>
|
||||
}
|
||||
Reference in New Issue
Block a user