Just as with the editor, it is a good practice to obtain and to store
a reference to the properties and parameters in the shapeProp = ((DtScalarVariable)component.getProperty("Shape")); materialProp = ((DtScalarVariable)component.getProperty("Material")); thicknessParam=((DtScalarVariable)component.getParameter("Thickness")); In the // Only interested in Variable events for my component DtComponent eventComp = event.getParentCompForEvent(); if (eventComp == myComponent && dtme instanceof Variable) { Variable eVar = (Variable)dtme; Variable rootVar = VariableUtil.getRootVariable(eVar); String rootVarName = rootVar.getName(); // if one of our predefined parameter names changes, change it back if (event.getChangeType() == DtModelEvent.CHANGED_VARNAME) { String oldName = (String)event.getOldValue(); String newName = VariableUtil.getVariablePathAsString(eVar); if (oldName.equals("Dimensions")) { ((DtVariable)eVar).setName("Dimensions"); } else if (oldName.equals("Area")) { ((DtVariable)eVar).setName("Area"); } else if (oldName.equals("Volume")) { ((DtVariable)eVar).setName("Volume"); } else if (oldName.equals("Weight")) { ((DtVariable)eVar).setName("Weight"); } } // if a pre-defined parameter is deleted, add it back if (event.getEventType() == DtModelEvent.ELEMENT_REMOVED) { String varName = eVar.getName(); DtVariable dtVar = (DtVariable)eVar; if (varName.equals("Dimensions") || varName.equals("Area") || varName.equals("Weight") || varName.equals("Volume")) { myComponent.addParameter(dtVar); } } // if a pre-defined parameter is changed to an inappropriate type if (event.getChangeType() == DtModelEvent.CHANGED_TYPE) { String varName = eVar.getName(); DtVariable dtVar = (DtVariable)eVar; if (varName.equals("Dimensions")) { dtVar.setMode(Variable.MODE_INPUT); } else if (varName.equals("Area") || varName.equals("Weight") || varName.equals("Volume")) { dtVar.setMode(Variable.MODE_OUTPUT); } } In the public void validate(java.util.List validationList) throws SDKException { try { String name = myComponent.getName(); MetaModel myMM = myComponent.getMetaModel(); // warn if no application specified if (shapeProp.getValueObj().getAsString().length() == 0) { validationList.add(new ValidationResult(ValidationEvent.SEVERITY_WARNING, myComponent, new IString(CLASS, 0, "{0}: No shape specified for the plate", name), "shape")); } if (materialProp.getValueObj().getAsString().length() == 0) { validationList.add(new ValidationResult(ValidationEvent.SEVERITY_WARNING, myComponent, new IString(CLASS, 0, "{0}: No material specified for the plate", name), "material"));\ if (thicknessParam.getValueObj().getAsString().length() == 0) { validationList.add(new ValidationResult(ValidationEvent.SEVERITY_WARNING, myComponent, new IString(CLASS, 0, "{0}: No thickness specified for the plate", name), "thickness")); } } catch (Exception e) { throw new SDKException(e, e.getMessage()); } } The complete code for the editor for this Plate component can be found in Component Development Reference. If your component requires interaction with files that must be made known to Isight (e.g., to be passed to/from other components), you will most likely need to represent them using File Parameters. For more information on programming with file parameters, see File Parameters Reference. |