2024-10-14 12:14:01 +03:00
|
|
|
package _VisualDVM.Passes.All;
|
2025-01-11 19:32:54 +03:00
|
|
|
import Common.MainModule_;
|
2024-10-14 15:19:13 +03:00
|
|
|
import Common.Passes.Pass;
|
2025-01-11 02:09:44 +03:00
|
|
|
import Common.Visual.Windows.Dialog.SliderNumberForm;
|
2025-01-11 14:26:24 +03:00
|
|
|
import Common.Visual.Windows.Dialog.VDirectoryChooser;
|
|
|
|
|
import Common.Visual.Windows.Dialog.VFileChooser;
|
2024-10-07 00:58:29 +03:00
|
|
|
import _VisualDVM.Global;
|
2024-10-09 22:01:19 +03:00
|
|
|
import _VisualDVM.GlobalProperties;
|
2025-01-11 02:09:44 +03:00
|
|
|
import _VisualDVM.Passes.PassCode;
|
2023-11-13 21:07:44 +03:00
|
|
|
|
2025-01-11 14:26:24 +03:00
|
|
|
import java.io.File;
|
2023-11-13 21:07:44 +03:00
|
|
|
import java.lang.reflect.Field;
|
2024-10-09 23:37:58 +03:00
|
|
|
public class UpdateProperty extends Pass<Object> {
|
2023-11-13 21:07:44 +03:00
|
|
|
//todo в дальнейшем, все настройки перевести в properties, и перенести сюда функционал UpdateSetting (?)
|
|
|
|
|
String name = "";
|
|
|
|
|
Field field = null;
|
|
|
|
|
Object oldValue = null;
|
|
|
|
|
Object newValue = null;
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
|
|
|
|
name = (String) args[0];
|
2025-01-11 02:09:44 +03:00
|
|
|
String description = Global.properties.getFieldDescription(name);
|
2023-11-13 21:07:44 +03:00
|
|
|
field = GlobalProperties.class.getField(name);
|
|
|
|
|
oldValue = field.get(Global.properties);
|
2025-01-11 02:09:44 +03:00
|
|
|
newValue = null;
|
|
|
|
|
SliderNumberForm sliderNumberForm = new SliderNumberForm();
|
2025-01-11 14:26:24 +03:00
|
|
|
VDirectoryChooser directoryChooser = new VDirectoryChooser("");
|
|
|
|
|
VFileChooser fileChooser = new VFileChooser("", "exe");
|
2025-01-11 02:09:44 +03:00
|
|
|
//-
|
|
|
|
|
if (args.length==1){
|
|
|
|
|
switch (name){
|
|
|
|
|
case "BugReportsAgeLimit":
|
|
|
|
|
if (sliderNumberForm.ShowDialog(description, oldValue, 1, 12))
|
|
|
|
|
newValue=sliderNumberForm.Result;
|
|
|
|
|
break;
|
2025-01-11 19:32:54 +03:00
|
|
|
case "FastAccessPassesCount":
|
|
|
|
|
if (sliderNumberForm.ShowDialog(description, oldValue, 5, 15))
|
|
|
|
|
newValue=sliderNumberForm.Result;
|
|
|
|
|
break;
|
2025-01-11 14:26:24 +03:00
|
|
|
case "Workspace":
|
|
|
|
|
directoryChooser.setTitle(description);
|
|
|
|
|
directoryChooser.SetCurrentDirectory(
|
|
|
|
|
Global.properties.Workspace.isEmpty() ? Global.ProjectsDirectory : new File(Global.properties.Workspace));
|
|
|
|
|
File dir = directoryChooser.ShowDialog();
|
|
|
|
|
if (dir != null)
|
|
|
|
|
newValue = dir.getAbsolutePath();
|
|
|
|
|
break;
|
2025-01-11 02:09:44 +03:00
|
|
|
}
|
|
|
|
|
}else
|
|
|
|
|
newValue = args[1];
|
|
|
|
|
//--
|
|
|
|
|
return newValue!=null&&!newValue.equals(oldValue);
|
2023-11-13 21:07:44 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void body() throws Exception {
|
|
|
|
|
field.set(Global.properties, newValue);
|
|
|
|
|
Global.properties.Update();
|
|
|
|
|
}
|
2024-03-20 23:32:24 +03:00
|
|
|
@Override
|
|
|
|
|
protected void showDone() throws Exception {
|
|
|
|
|
switch (name) {
|
|
|
|
|
case "collapseProjectTrees":
|
2024-10-13 22:08:13 +03:00
|
|
|
if (Global.mainModule.HasProject()) {
|
2024-03-20 23:32:24 +03:00
|
|
|
if ((boolean) newValue)
|
2024-10-15 02:32:52 +03:00
|
|
|
Global.mainModule.getUI().getMainWindow().getProjectWindow().CollapseProjectTrees();
|
2024-10-15 13:35:33 +03:00
|
|
|
else Global.mainModule.getUI().getMainWindow().getProjectWindow().ExpandProjectTrees();
|
2024-03-20 23:32:24 +03:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "collapseFileGraphs":
|
2024-10-13 22:08:13 +03:00
|
|
|
if (Global.mainModule.HasFile()) {
|
2024-03-20 23:32:24 +03:00
|
|
|
if ((boolean) newValue)
|
2024-10-13 22:08:13 +03:00
|
|
|
Global.mainModule.getFile().form.CollapseGraphs();
|
2024-03-20 23:32:24 +03:00
|
|
|
else
|
2024-10-13 22:08:13 +03:00
|
|
|
Global.mainModule.getFile().form.ExpandGraphs();
|
2024-03-20 23:32:24 +03:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "collapseFileMessages":
|
2024-10-13 22:08:13 +03:00
|
|
|
if (Global.mainModule.HasFile()) {
|
2024-03-20 23:32:24 +03:00
|
|
|
if ((boolean) newValue)
|
2024-10-13 22:08:13 +03:00
|
|
|
Global.mainModule.getFile().form.CollapseMessages();
|
2024-03-20 23:32:24 +03:00
|
|
|
else
|
2024-10-13 22:08:13 +03:00
|
|
|
Global.mainModule.getFile().form.ExpandMessages();
|
2024-03-20 23:32:24 +03:00
|
|
|
}
|
|
|
|
|
break;
|
2025-01-11 19:32:54 +03:00
|
|
|
case "FastAccessPassesCount":
|
|
|
|
|
MainModule_.instance.getUI().getFastAccessMenuBar().Refresh();
|
|
|
|
|
break;
|
2024-03-20 23:32:24 +03:00
|
|
|
}
|
|
|
|
|
}
|
2023-11-13 21:07:44 +03:00
|
|
|
}
|