2023-11-19 02:12:44 +03:00
|
|
|
package Visual_DVM_2021.Passes.All;
|
2024-10-11 00:00:30 +03:00
|
|
|
import Common.Utils.Utils_;
|
2024-10-09 22:01:19 +03:00
|
|
|
import _VisualDVM.Current;
|
2024-10-09 22:21:57 +03:00
|
|
|
import _VisualDVM.GlobalData.GlobalDatabase;
|
2024-10-07 00:58:29 +03:00
|
|
|
import _VisualDVM.Global;
|
2024-10-09 22:01:19 +03:00
|
|
|
import _VisualDVM.Visual.UI;
|
2024-10-08 22:33:49 +03:00
|
|
|
import Common.Visual.Windows.Dialog.PercentsForm;
|
|
|
|
|
import Common.Visual.Windows.Dialog.SliderNumberForm;
|
|
|
|
|
import Common.Visual.Windows.Dialog.SpinnerNumberForm;
|
|
|
|
|
import Common.Visual.Windows.Dialog.Text.TextFieldDialog;
|
2024-10-08 23:45:06 +03:00
|
|
|
import Common.Visual.Windows.Dialog.VDirectoryChooser;
|
|
|
|
|
import Common.Visual.Windows.Dialog.VFileChooser;
|
2024-10-09 22:01:19 +03:00
|
|
|
import _VisualDVM.Utils;
|
2024-10-09 22:21:57 +03:00
|
|
|
import _VisualDVM.GlobalData.Settings.DBSetting;
|
2024-10-09 23:37:58 +03:00
|
|
|
import Visual_DVM_2021.Passes.PassCode;
|
2024-10-10 23:57:36 +03:00
|
|
|
import Common.Passes.Pass;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
import java.io.File;
|
2024-10-09 23:37:58 +03:00
|
|
|
public class UpdateSetting extends Pass<DBSetting> {
|
2023-09-17 22:13:42 +03:00
|
|
|
String NewValue;
|
|
|
|
|
VDirectoryChooser directoryChooser = new VDirectoryChooser("");
|
|
|
|
|
VFileChooser fileChooser = new VFileChooser("", "exe");
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
2024-10-12 00:17:51 +03:00
|
|
|
target = (Global.mainModule.getDb()).settings.get(args[0]);
|
2023-09-17 22:13:42 +03:00
|
|
|
NewValue = target.Value;
|
|
|
|
|
if (args.length == 1) {
|
|
|
|
|
//интерфейсный режим. получение по клику на пункт меню.
|
|
|
|
|
switch (target.settingType) {
|
|
|
|
|
case SapforFlag:
|
|
|
|
|
NewValue = target.toBoolean() ? "0" : "1";
|
|
|
|
|
break;
|
|
|
|
|
case PercentField:
|
|
|
|
|
PercentsForm f = new PercentsForm();
|
|
|
|
|
if (f.ShowDialog(target.Name.getDescription(), target.toInt32()))
|
|
|
|
|
NewValue = String.valueOf(f.Result);
|
|
|
|
|
break;
|
|
|
|
|
case StringField:
|
|
|
|
|
switch (target.Name) {
|
|
|
|
|
case Workspace:
|
|
|
|
|
directoryChooser.setTitle(target.Name.getDescription());
|
|
|
|
|
directoryChooser.SetCurrentDirectory(
|
|
|
|
|
target.Value.isEmpty() ? Global.ProjectsDirectory : new File(target.Value));
|
|
|
|
|
File dir = directoryChooser.ShowDialog();
|
|
|
|
|
if (dir != null)
|
|
|
|
|
NewValue = dir.getAbsolutePath();
|
|
|
|
|
break;
|
|
|
|
|
case LocalMakePathWindows:
|
|
|
|
|
fileChooser.setTitle(target.Name.getDescription());
|
|
|
|
|
File file = fileChooser.ShowDialog();
|
|
|
|
|
if (file != null)
|
|
|
|
|
NewValue = file.getAbsolutePath();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
TextFieldDialog ff = new TextFieldDialog();
|
|
|
|
|
if (ff.ShowDialog(target.Name.getDescription(), target.Value)) {
|
|
|
|
|
NewValue = ff.Result;
|
|
|
|
|
if (NewValue.length() == 0)
|
|
|
|
|
NewValue = " ";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case IntField:
|
|
|
|
|
int min = 0;
|
|
|
|
|
int max = 0;
|
|
|
|
|
switch (target.Name) {
|
|
|
|
|
case LastOpenedProjectsCount:
|
|
|
|
|
SpinnerNumberForm f_ = new SpinnerNumberForm() {
|
|
|
|
|
@Override
|
|
|
|
|
public void InitFields() {
|
|
|
|
|
fields.setModel(new SpinnerNumberModel(
|
|
|
|
|
target.toInt32(),
|
|
|
|
|
1,
|
|
|
|
|
50,
|
|
|
|
|
1));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
if (f_.ShowDialog(target.Name.getDescription()))
|
|
|
|
|
NewValue = String.valueOf(f_.Result);
|
|
|
|
|
break;
|
2024-09-10 01:50:44 +03:00
|
|
|
case BugReportsAgeLimit:
|
|
|
|
|
min = 1;
|
|
|
|
|
max = 12;
|
|
|
|
|
SliderNumberForm fffff = new SliderNumberForm();
|
|
|
|
|
if (fffff.ShowDialog(target.Name.getDescription(), target.toInt32(), min, max))
|
|
|
|
|
NewValue = String.valueOf(fffff.Result);
|
|
|
|
|
break;
|
2023-09-17 22:13:42 +03:00
|
|
|
case FastAccessPassesCount:
|
|
|
|
|
min = 5;
|
|
|
|
|
max = 15;
|
|
|
|
|
SliderNumberForm fff = new SliderNumberForm();
|
|
|
|
|
if (fff.ShowDialog(target.Name.getDescription(), target.toInt32(), min, max))
|
|
|
|
|
NewValue = String.valueOf(fff.Result);
|
|
|
|
|
break;
|
|
|
|
|
case Kernels:
|
|
|
|
|
min = 1;
|
|
|
|
|
max = Utils.getMaxKernels();
|
|
|
|
|
SliderNumberForm ffff = new SliderNumberForm();
|
|
|
|
|
if (ffff.ShowDialog(target.Name.getDescription(), target.toInt32(), min, max))
|
|
|
|
|
NewValue = String.valueOf(ffff.Result);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
NewValue = args[1].toString();
|
|
|
|
|
}
|
|
|
|
|
//программный, тихий режим.}
|
|
|
|
|
return !NewValue.equals(target.Value);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void body() throws Exception {
|
|
|
|
|
target.Value = NewValue;
|
2024-10-12 00:17:51 +03:00
|
|
|
Global.mainModule.getDb().Update(target);
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void showDone() throws Exception {
|
|
|
|
|
if (target.Visible) {
|
|
|
|
|
target.Mark();
|
|
|
|
|
switch (target.Name) {
|
|
|
|
|
case GCOVLimit:
|
|
|
|
|
if (Current.HasFile())
|
|
|
|
|
Current.getFile().form.ShowGCOV();
|
|
|
|
|
break;
|
|
|
|
|
case FastAccessPassesCount:
|
|
|
|
|
if (Current.HasProject())
|
|
|
|
|
UI.fastAccessMenuBar.Refresh();
|
|
|
|
|
break;
|
|
|
|
|
case ShowFullArraysDeclarations:
|
|
|
|
|
if (Current.HasProject())
|
|
|
|
|
Current.getProject().declaratedArrays.ShowUI();
|
|
|
|
|
break;
|
|
|
|
|
case ShowFullTabsNames:
|
|
|
|
|
UI.getMainWindow().getTestingWindow().RefreshTabsNames();
|
|
|
|
|
if (Current.HasProject())
|
|
|
|
|
UI.getMainWindow().getProjectWindow().RefreshTabsNames();
|
|
|
|
|
if (Current.HasFile())
|
|
|
|
|
Current.getFile().form.RefreshTabsNames();
|
|
|
|
|
break;
|
|
|
|
|
case MPI_PROGRAM:
|
2024-10-09 23:37:58 +03:00
|
|
|
Pass.passes.get(PassCode.CleanAnalyses).Do();
|
2024-04-02 23:35:54 +03:00
|
|
|
((SPF_GetArrayDistributionOnlyAnalysis)
|
2024-10-09 23:37:58 +03:00
|
|
|
Pass.passes.get(PassCode.SPF_GetArrayDistributionOnlyAnalysis)).RefreshControls();
|
2023-09-17 22:13:42 +03:00
|
|
|
break;
|
|
|
|
|
case SmallScreen:
|
|
|
|
|
boolean small = target.toBoolean();
|
|
|
|
|
if (Current.HasProject())
|
|
|
|
|
UI.getMainWindow().getProjectWindow().SwitchScreen(small);
|
|
|
|
|
UI.getMainWindow().getCallbackWindow().SwitchScreen(small);
|
|
|
|
|
break;
|
|
|
|
|
case Precompilation:
|
|
|
|
|
Current.getSapfor().ResetAllAnalyses();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|