package _VisualDVM.Passes.All; import Common.MainModule_; import Common.Passes.Pass; import Common.Visual.Windows.Dialog.SliderNumberForm; import Common.Visual.Windows.Dialog.VDirectoryChooser; import Common.Visual.Windows.Dialog.VFileChooser; import _VisualDVM.Global; import _VisualDVM.GlobalProperties; import _VisualDVM.Passes.PassCode; import java.io.File; import java.lang.reflect.Field; public class UpdateProperty extends Pass { //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]; String description = Global.properties.getFieldDescription(name); field = GlobalProperties.class.getField(name); oldValue = field.get(Global.properties); newValue = null; SliderNumberForm sliderNumberForm = new SliderNumberForm(); VDirectoryChooser directoryChooser = new VDirectoryChooser(""); VFileChooser fileChooser = new VFileChooser("", "exe"); //- if (args.length==1){ switch (name){ case "BugReportsAgeLimit": if (sliderNumberForm.ShowDialog(description, oldValue, 1, 12)) newValue=sliderNumberForm.Result; break; case "FastAccessPassesCount": if (sliderNumberForm.ShowDialog(description, oldValue, 5, 15)) newValue=sliderNumberForm.Result; break; 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; } }else newValue = args[1]; //-- return newValue!=null&&!newValue.equals(oldValue); } @Override protected void body() throws Exception { field.set(Global.properties, newValue); Global.properties.Update(); } @Override protected void showDone() throws Exception { switch (name) { case "collapseProjectTrees": if (Global.mainModule.HasProject()) { if ((boolean) newValue) Global.mainModule.getUI().getMainWindow().getProjectWindow().CollapseProjectTrees(); else Global.mainModule.getUI().getMainWindow().getProjectWindow().ExpandProjectTrees(); } break; case "collapseFileGraphs": if (Global.mainModule.HasFile()) { if ((boolean) newValue) Global.mainModule.getFile().form.CollapseGraphs(); else Global.mainModule.getFile().form.ExpandGraphs(); } break; case "collapseFileMessages": if (Global.mainModule.HasFile()) { if ((boolean) newValue) Global.mainModule.getFile().form.CollapseMessages(); else Global.mainModule.getFile().form.ExpandMessages(); } break; case "FastAccessPassesCount": MainModule_.instance.getUI().getFastAccessMenuBar().Refresh(); break; } } }