@Override public PreviewProperty[] getProperties() { return new PreviewProperty[]{ PreviewProperty.createProperty(this, ENABLE_NODE_GLOW, Boolean.class, "Show glow effect", "Glow effect around the node", PreviewProperty.CATEGORY_NODES).setValue(false) }; }
public ChildPreviewPropertyWrapper(PreviewProperty previewProperty, PreviewProperty[] parents) { super(previewProperty.getName(), previewProperty.getType(), previewProperty.getDisplayName(), previewProperty.getDescription()); this.property = previewProperty; this.parents = parents; }
@Override public void setValue(Object t) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { property.setValue(t); } }
@Override public void savePreset(String name) { if (model != null) { PreviewModel previewModel = previewController.getModel(); Map<String, Object> map = new HashMap<>(); for (PreviewProperty p : previewModel.getProperties().getProperties()) { map.put(p.getName(), p.getValue()); } for (Entry<String, Object> p : previewModel.getProperties().getSimpleValues()) { map.put(p.getKey(), p.getValue()); } PreviewPreset preset = new PreviewPreset(name, map); presetUtils.savePreset(preset); model.setCurrentPreset(preset); } }
/** * Add <code>property</code> to the properties. * <p> * The property should have a unique name and the method will throw an exception * if not. * @param property the property to add to the properties * @throws IllegalArgumentException if <code>property</code> already exists */ public void addProperty(PreviewProperty property) { if (properties.containsKey(property.getName())) { throw new RuntimeException("The property " + property.getName() + " already exists. Each property name should be unique."); } for (String parent : property.dependencies) { PreviewProperty p = properties.get(parent); if (p != null && !p.getType().equals(Boolean.class)) { throw new IllegalArgumentException("The property " + property.getName() + " has dependencies to non-boolean property " + p.getName()); } } properties.put(property.getName(), property); }
@Override public Object getValue() throws IllegalAccessException, InvocationTargetException { return property.getValue(); }
Object source = property.getSource(); boolean propertyEnabled = true; if (source instanceof Renderer) { String category = property.getCategory(); Sheet.Set sheetSet = sheetSets.get(category); if (sheetSet == null) {
public void removeProperty(PreviewProperty property) { properties.remove(property.getName()); }
/** * Returns all properties with <code>source</code> as source. A property * can belong to only one source. * @param source the source properties belong to * @return all properties in <code>source</code> */ public PreviewProperty[] getProperties(Object source) { List<PreviewProperty> props = new ArrayList<>(); for (PreviewProperty p : properties.values()) { if (p.getSource().equals(source)) { props.add(p); } } return props.toArray(new PreviewProperty[0]); }
/** * Returns all properties with <code>category</code> as category. A property * can belong to only one category. Default categories names are defined in * {@link PreviewProperty}. * @param category the category properties belong to * @return all properties in <code>category</code> */ public PreviewProperty[] getProperties(String category) { List<PreviewProperty> props = new ArrayList<>(); for (PreviewProperty p : properties.values()) { if (p.getCategory().equals(category)) { props.add(p); } } return props.toArray(new PreviewProperty[0]); }
@Override public void setValue(Object t) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { property.setValue(t); }
@Override public void duplicate(Workspace source, Workspace destination) { PreviewController previewController=Lookup.getDefault().lookup(PreviewController.class); PreviewModel sourceModel=previewController.getModel(source); PreviewModel destModel=previewController.getModel(destination); destModel.setManagedRenderers(sourceModel.getManagedRenderers()); for(PreviewProperty property:sourceModel.getProperties().getProperties()){ destModel.getProperties().putValue(property.getName(), property.getValue()); } for(Entry<String,Object> property:sourceModel.getProperties().getSimpleValues()){ destModel.getProperties().putValue(property.getKey(), property.getValue()); } } }
@Override public Object getValue() throws IllegalAccessException, InvocationTargetException { return property.getValue(); }
/** * Returns all properties which defined <code>property</code> as a dependency. * @param property the parent property * @return all properties with <code>property</code> as a parent property */ public PreviewProperty[] getChildProperties(PreviewProperty property) { List<PreviewProperty> props = new ArrayList<>(); for (PreviewProperty p : properties.values()) { for (String pn : p.dependencies) { if (pn.equals(property.getName())) { props.add(p); } } } return props.toArray(new PreviewProperty[0]); }
@Override public PreviewProperty[] getProperties() { return new PreviewProperty[]{ PreviewProperty.createProperty(this, MUTUALEGDE_HIGHLIGHT, Boolean.class, "Highlight mutual edges", "Color the mutual edges with a custom color", PreviewProperty.CATEGORY_EDGES).setValue(defaultHighlightMutualEdges), PreviewProperty.createProperty(this, MUTUALEGDE_HIGHLIGHT_COLOR, Color.class, "Highlight mutual edges color", "Set highlight color", PreviewProperty.CATEGORY_EDGES, MUTUALEGDE_HIGHLIGHT).setValue(defaultHighlightColor) }; }
public ParentPreviewPropertyWrapper(PreviewProperty previewProperty, PreviewProperty[] children) { super(previewProperty.getName(), previewProperty.getType(), previewProperty.getDisplayName(), previewProperty.getDescription()); this.property = previewProperty; this.children = children; }