59 lines
2.0 KiB
Java
59 lines
2.0 KiB
Java
package _VisualDVM.Passes.All;
|
|
import Common.Utils.Utils_;
|
|
import _VisualDVM.Global;
|
|
import _VisualDVM.Passes.Server.ComponentsRepositoryPass;
|
|
import _VisualDVM.Repository.Component.Component;
|
|
import _VisualDVM.Repository.Server.ServerCode;
|
|
import _VisualDVM.Repository.Server.ServerExchangeUnit_2021;
|
|
import _VisualDVM.Utils;
|
|
import _VisualDVM.Visual.Windows.ReadOnlyMultilineTextForm;
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
import java.io.File;
|
|
import java.util.List;
|
|
import java.util.Vector;
|
|
public class ShowComponentChangesLog extends ComponentsRepositoryPass<Component> {
|
|
File res;
|
|
@Override
|
|
public String getIconPath() {
|
|
return "/Common/icons/Log.png";
|
|
}
|
|
@Override
|
|
public String getButtonText() {
|
|
return "";
|
|
}
|
|
@Override
|
|
protected boolean canStart(Object... args) throws Exception {
|
|
if (Global.components.getUI().CheckCurrent(Log)) {
|
|
target = Global.components.getUI().getCurrent();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
@Override
|
|
protected void performPreparation() throws Exception {
|
|
res = Utils.getTempFileName("component_changes");
|
|
}
|
|
@Override
|
|
protected void ServerAction() throws Exception {
|
|
Command(new ServerExchangeUnit_2021(ServerCode.GetComponentChangesLog, target.getComponentType().toString()));
|
|
Utils_.bytesToFile((byte[]) server_response.object, res);
|
|
}
|
|
@Override
|
|
protected boolean validate() {
|
|
return res.exists();
|
|
}
|
|
@Override
|
|
protected void showDone() throws Exception {
|
|
ReadOnlyMultilineTextForm ff = new ReadOnlyMultilineTextForm();
|
|
List<String> lines = FileUtils.readLines(res);
|
|
Vector<String> res = new Vector<>();
|
|
for (int i = lines.size() - 1; i >= 0; i--)
|
|
res.add(lines.get(i));
|
|
ff.ShowDialog("Журнал изменений компонента " +
|
|
Utils_.Brackets(target.getComponentType().getDescription()),
|
|
String.join("\n", res)
|
|
);
|
|
}
|
|
}
|