@Override public Object getValue() throws IllegalAccessException, InvocationTargetException { return property.getValue(); }
@Override public Object getValue() throws IllegalAccessException, InvocationTargetException { return property.getValue(); }
@Override public Object getValue() throws IllegalAccessException, InvocationTargetException { return property.getValue(); }
/** * Returns the property value as a <code>Number</code>. * @param property the property's name * @param defaultValue the default value if not found * @return the property's value or <code>defaultValue</code> if not found * @throws ClassCastException if the property can't be cast to <code>Number</code> */ public Number getNumberValue(String property, Number defaultValue) { PreviewProperty p = getProperty(property); if (p != null && p.getValue() != null && p.getValue() instanceof Number) { Number value = (Number) p.getValue(); return value; } else if (simpleValues.containsKey(property) && simpleValues.get(property) instanceof Number) { return (Number) simpleValues.get(property); } return defaultValue; }
@Override public boolean canWrite() { for (PreviewProperty parent : parents) { if (parent.getType().equals(Boolean.class) && parent.getValue().equals(Boolean.FALSE)) { return false; } } return true; } }
/** * Returns the property value and cast it to the <code>T</code> type. * @param <T> the type to cast the property value to * @param property the property's name * @param defaultValue the default value if not found * @return the property's value or <code>defaultValue</code> if not found * @throws ClassCastException if the property can't be cast to <code>T</code> */ public <T> T getValue(String property, T defaultValue) { PreviewProperty p = getProperty(property); if (p != null && p.getValue() != null) { T value = (T) p.getValue(); return value; } else if (simpleValues.containsKey(property)) { return (T) simpleValues.get(property); } return defaultValue; }
/** * Returns the property value and cast it to the <code>T</code> type. * @param <T> the type to cast the property value to * @param property the property's name * @return the property's value or <code>null</code> if not found * @throws ClassCastException if the property can't be cast to <code>T</code> */ public <T> T getValue(String property) { PreviewProperty p = getProperty(property); if (p != null && p.getValue() != null) { T value = (T) p.getValue(); return value; } else if (simpleValues.containsKey(property)) { return (T) simpleValues.get(property); } return null; }
Object propertyValue = property.getValue(); if (propertyValue != null) { String text = Serialization.getValueAsText(propertyValue, property.getType());
@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); } }
@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()); } } }