diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 32392c8d..49279948 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -9,12 +9,7 @@
-
-
-
-
-
diff --git a/properties b/properties
index 08ea5f45..a4c284ef 100644
--- a/properties
+++ b/properties
@@ -48,5 +48,5 @@
"FortranWrapsOn": false,
"ExtensionsOn": false,
"ComparsionDiffMergeOn": true,
- "BugReportsAgeLimit": 3
+ "BugReportsAgeLimit": 6
}
\ No newline at end of file
diff --git a/src/_VisualDVM/GlobalProperties.java b/src/_VisualDVM/GlobalProperties.java
index 73ddd34d..e4b3ab87 100644
--- a/src/_VisualDVM/GlobalProperties.java
+++ b/src/_VisualDVM/GlobalProperties.java
@@ -7,10 +7,14 @@ import _VisualDVM.Passes.PassCode;
import com.google.gson.annotations.Expose;
import javax.swing.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.io.File;
import java.lang.reflect.Field;
import java.nio.file.Paths;
+import java.util.LinkedHashMap;
public class GlobalProperties {
+ LinkedHashMap controls= new LinkedHashMap<>();
@Expose
public _VisualDVM.Mode Mode = _VisualDVM.Mode.Normal;
@Expose
@@ -274,24 +278,87 @@ public class GlobalProperties {
});
menu.add(menu_item);
}
- public void addIntSliderMenuItem(JMenu menu, String fieldName, int min, int max) {
+ public Object getValue(String fieldName){
+ Object res=null;
try {
- String description = getFieldDescription(fieldName);
- Object oldValue = this.getClass().getField(fieldName).get(this);
- JMenuItem menu_item = new StableMenuItem(description + " : " + oldValue);
- //-
- menu_item.addActionListener(e -> {
- SliderNumberForm f = new SliderNumberForm();
- if (f.ShowDialog(description, oldValue, min, max)) {
- int newValue = f.Result;
- if (Global.mainModule.getPass(PassCode.UpdateProperty).Do(fieldName, newValue)) {
- menu_item.setText(description + " : " + newValue);
+ res = this.getClass().getField(fieldName).get(this);
+ }
+ catch (Exception ex){
+ ex.printStackTrace();
+ }
+ return res;
+ }
+ //создать контрол
+ public JMenuItem getMenuItem(String fieldName){
+ final JMenuItem menuItem;
+ if (controls.containsKey(fieldName))
+ menuItem = controls.get(fieldName);
+ else {
+ menuItem = new StableMenuItem();
+ Mark(fieldName,menuItem);
+ menuItem.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ switch (fieldName){
+ case "BugReportsAgeLimit":
+ SliderNumberForm f = new SliderNumberForm();
+ if (f.ShowDialog(getFieldDescription(fieldName), getValue(fieldName), 1, 12)) {
+ int newValue = f.Result;
+ if (Global.mainModule.getPass(PassCode.UpdateProperty).Do(fieldName, newValue)) {
+ Mark(fieldName, menuItem);
+ }
+ }
+ break;
}
}
});
- menu.add(menu_item);
- } catch (Exception ex) {
+ controls.put(fieldName,menuItem);
+ }
+ return menuItem;
+ }
+ //отобразить на контроле значение поля.
+ public void Mark(String fieldName, JMenuItem control){
+ String description= getFieldDescription(fieldName);
+ try {
+ Object value = this.getClass().getField(fieldName).get(this);
+ if (value instanceof Boolean){
+ Boolean flag = (Boolean) value;
+ control.setText(description);
+ control.setIcon(Utils_.getIcon(flag? "/Common/icons/Pick.png" : "/Common/icons/NotPick.png"));
+ }else {
+ control.setText(description+" : "+value);
+ }
+ }
+ catch (Exception ex){
ex.printStackTrace();
}
}
+/*
+ public ActionListener getChangeAction(String fieldName){
+ try {
+ String description = getFieldDescription(fieldName);
+ Object oldValue = this.getClass().getField(fieldName).get(this);
+ return new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ switch (fieldName) {
+ case "BugReportsAgeLimit":
+ SliderNumberForm f = new SliderNumberForm();
+ if (f.ShowDialog(description, oldValue, 1, 12)) {
+ int newValue = f.Result;
+ if (Global.mainModule.getPass(PassCode.UpdateProperty).Do(fieldName, newValue)) {
+ menu_item.setText(description + " : " + newValue);
+ }
+ }
+ break;
+ }
+ }
+ };
+ }
+ catch (Exception ex){
+ ex.printStackTrace();
+ }
+ }
+
+ */
}
diff --git a/src/_VisualDVM/Visual/Menus/MainMenuBar/VisualiserSettingsMenu/VisualiserSettingsMenu.java b/src/_VisualDVM/Visual/Menus/MainMenuBar/VisualiserSettingsMenu/VisualiserSettingsMenu.java
index 80714ad9..a005fcb9 100644
--- a/src/_VisualDVM/Visual/Menus/MainMenuBar/VisualiserSettingsMenu/VisualiserSettingsMenu.java
+++ b/src/_VisualDVM/Visual/Menus/MainMenuBar/VisualiserSettingsMenu/VisualiserSettingsMenu.java
@@ -30,6 +30,6 @@ public class VisualiserSettingsMenu extends VisualiserMenu {
add(new SynchronizationSettingsMenu());
add(new VersionsComparisonMenu());
add((Global.mainModule.getDb()).settings.get(SettingName.Workspace).getMenuItem());
- Global.properties.addIntSliderMenuItem(this, "BugReportsAgeLimit",1,12);
+ add(Global.properties.getMenuItem("BugReportsAgeLimit"));
}
}