Merge branch 'subtree'
authorNiki Roo <niki@nikiroo.be>
Sat, 25 Apr 2020 13:11:32 +0000 (15:11 +0200)
committerNiki Roo <niki@nikiroo.be>
Sat, 25 Apr 2020 13:11:32 +0000 (15:11 +0200)
src/be/nikiroo/utils/resources/Meta.java
src/be/nikiroo/utils/resources/MetaInfo.java

index 8ed74dc565b9994f1a6ec7a1b530525dbcd4bdbb..fb4d4915015e2c1efbf4021c8dd7ef4d2623c98e 100644 (file)
@@ -60,6 +60,16 @@ public @interface Meta {
         * @return what it is
         */
        String description() default "";
+       
+       /**
+        * This item should be hidden from the user (she will still be able to
+        * modify it if she opens the file manually).
+        * <p>
+        * Defaults to FALSE (visible).
+        * 
+        * @return TRUE if it should stay hidden
+        */
+       boolean hidden() default false;
 
        /**
         * This item is only used as a group, not as an option.
index 917c21001c14482bc9292be0eaede3cd1c707bd5..70c6c43181bbff8f8885c1eca15a792eef03eac1 100644 (file)
@@ -27,6 +27,7 @@ public class MetaInfo<E extends Enum<E>> implements Iterable<MetaInfo<E>> {
        private List<Runnable> saveListeners = new ArrayList<Runnable>();
 
        private String name;
+       private boolean hidden;
        private String description;
 
        private boolean dirty;
@@ -90,6 +91,7 @@ public class MetaInfo<E extends Enum<E>> implements Iterable<MetaInfo<E>> {
                }
 
                this.name = name;
+               this.hidden = meta.hidden();
                this.description = description;
 
                reload();
@@ -110,6 +112,16 @@ public class MetaInfo<E extends Enum<E>> implements Iterable<MetaInfo<E>> {
        public String getName() {
                return name;
        }
+       
+       /**
+        * This item should be hidden from the user (she will still be able to
+        * modify it if she opens the file manually).
+        * 
+        * @return TRUE if it should stay hidden
+        */
+       public boolean isHidden() {
+               return hidden;
+       }
 
        /**
         * A description for this item: what it is or does, how to explain that item
@@ -682,8 +694,10 @@ public class MetaInfo<E extends Enum<E>> implements Iterable<MetaInfo<E>> {
                List<MetaInfo<E>> shadow = new ArrayList<MetaInfo<E>>();
                for (E id : type.getEnumConstants()) {
                        MetaInfo<E> info = new MetaInfo<E>(type, bundle, id);
-                       list.add(info);
-                       shadow.add(info);
+                       if (!info.hidden) {
+                               list.add(info);
+                               shadow.add(info);
+                       }
                }
 
                for (int i = 0; i < list.size(); i++) {