protected void addProperty( Sheet.Set sheet, Object target, Class valueType, Class editorType, String name, String description) { PropertySupport.Reflection prop = null; try { prop = new PropertySupport.Reflection(target, valueType, name); } catch (NoSuchMethodException ex) { try { prop = new PropertySupport.Reflection(target, valueType, "get" + name, null); } catch (NoSuchMethodException ex1) { // Exceptions.printStackTrace(ex1); } } if (prop != null) { prop.setName(name); prop.setShortDescription(description); if (editorType != null) prop.setPropertyEditorClass(editorType); sheet.put(prop); } }
protected PropertySupport.Reflection getProperty( String name, String description, Class clazz, Class property, Class propertyEditor, String getMethod, String setMethod, final Object defaultValue) throws NoSuchMethodException { @SuppressWarnings(value = "unchecked") PropertySupport.Reflection reflection = new PropertySupport.Reflection(getLookup().lookup(clazz), property, getMethod, setMethod) { public @Override void restoreDefaultValue() throws IllegalAccessException, InvocationTargetException { super.setValue(defaultValue); } public @Override boolean supportsDefaultValue() { return true; } }; reflection.setName(name); reflection.setDisplayName(name); reflection.setShortDescription(description); reflection.setPropertyEditorClass(propertyEditor); return reflection; }
@Override protected Sheet createSheet() { Sheet result = Sheet.createDefault(); Sheet.Set props = Sheet.createPropertiesSet(); try { Property id = new PropertySupport.Reflection(msc, int.class, "id"); Property name = new PropertySupport.Reflection(msc, String.class, "componentName"); Property type = new PropertySupport.Reflection(msc, ComponentType.class, "type"); PropertySupport.Reflection position = new PropertySupport.Reflection(msc, Point3d.class, "position"); Property scale = new PropertySupport.Reflection(msc, double.class, "scale"); PropertySupport.Reflection rotations = new PropertySupport.Reflection(msc, Point3d.class, "rotation"); Property source = new PropertySupport.Reflection(msc, File.class, "getSource", null); id.setName("ID"); name.setName("Name"); type.setName("Type"); position.setName("Position"); scale.setName("Scale"); source.setName("Source"); rotations.setName("Rotation"); position.setPropertyEditorClass(Tuple3dEditor.class); rotations.setPropertyEditorClass(Tuple3dEditor.class); // source.setPropertyEditorClass(FilePropertyEditor.clas); props.put(id); props.put(name); props.put(type); props.put(position); props.put(scale); props.put(rotations); props.put(source); } catch (NoSuchMethodException ex) { System.err.println(ex.getMessage()); } result.put(props); return result; }
@Override protected Sheet createSheet() { Sheet sheet = Sheet.createDefault(); Sheet.Set set = Sheet.createPropertiesSet(); NetworkElementApi obj = getLookup().lookup(NetworkElementApi.class); try { Property<String> valueProp = new PropertySupport.Reflection<String>(obj, String.class, "getValue", null); Property<String> caseIdListProp = new PropertySupport.Reflection<String>(obj, String.class, "getCaseIdListAsString", null); Property<NetworkElementType> elementTypeProp = new PropertySupport.Reflection<NetworkElementType>( obj, NetworkElementType.class, "getNetworkElementType", null); Property<Integer> caseIdListSizeProp = new PropertySupport.Reflection<Integer>(obj, Integer.class, "getCaseFrequency", null); Property<Double> MDPValueProp = new PropertySupport.Reflection<Double>(obj, Double.class, "getMDPValue", null); Property<Integer> ClusterIDProp = new PropertySupport.Reflection<Integer>(obj, int.class, "getClusterID", null); Property<Integer> uniqueCaseSizeProp = new PropertySupport.Reflection<Integer>(obj, Integer.class, "getUniqueFrequency", null); Property<String> uniqueCaseIdListProp = new PropertySupport.Reflection<String>( obj, String.class, "getUniqueCaseIdSetAsString", null); // Optional properties: Property<Boolean> errorProp = new PropertySupport.Reflection<Boolean>(obj, Boolean.class, "getErrorValue", null); Property<Boolean> goalProp = new PropertySupport.Reflection<Boolean>(obj, Boolean.class, "getGoalValue", null); Property<String> preConditionProp = new PropertySupport.Reflection<String>( obj, String.class, "getPreConditionStringList", null); // Property<String> postConditionProp = new PropertySupport.Reflection<String>(obj, // String.class, "getPostConditionStringList", null); PropertySupport.Reflection<MultiValueMap> postConditionProp = new PropertySupport.Reflection<MultiValueMap>( obj, MultiValueMap.class, "getPostCondition", null); postConditionProp.setPropertyEditorClass(MultiValueMapPropertyEditor.class); Property<Boolean> goalPathValueProp = new PropertySupport.Reflection<Boolean>(obj, Boolean.class, "getGoalPathValue", null); Property<Integer> goalCaseCountProp = new PropertySupport.Reflection<Integer>(obj, Integer.class, "getGoalCaseCount", null); valueProp.setName("Value"); caseIdListProp.setName("Case IDs"); elementTypeProp.setName("Type"); caseIdListSizeProp.setName("Case Count"); uniqueCaseSizeProp.setName("Unique Case Count"); uniqueCaseIdListProp.setName("Unique Case IDs"); MDPValueProp.setName("MDP Value"); ClusterIDProp.setName("ClusterID"); // TODO: it would be nice to have the list of the actions for the // currently selected node... // Optional properties: errorProp.setName("Error"); goalProp.setName("Goal"); preConditionProp.setName("Pre Condition"); postConditionProp.setName("Post Condition"); goalPathValueProp.setName("Goal Path"); goalCaseCountProp.setName("Goal Cases Count"); set.put(valueProp); set.put(caseIdListProp); set.put(elementTypeProp); set.put(caseIdListSizeProp); set.put(uniqueCaseSizeProp); set.put(uniqueCaseIdListProp); set.put(MDPValueProp); set.put(ClusterIDProp); if (mNEA.getOptionalData().contains("ERROR")) { set.put(errorProp); } if (mNEA.getOptionalData().contains("GOAL")) { set.put(goalProp); set.put(goalPathValueProp); set.put(goalCaseCountProp); } if (mNEA.getOptionalData().contains("PRE_CONDITION")) { set.put(preConditionProp); } if (mNEA.getOptionalData().contains("POST_CONDITION")) { set.put(postConditionProp); } } catch (NoSuchMethodException ex) { } sheet.put(set); return (sheet); }