Example: Editing a Component

A sample template is included with your Isight installation. This template creates a simple component and associated editor. The component allows you to enter two values and to calculate a third value. Using Isight Developer, you can edit this component to perform additional calculations.

The sample template is used to create a simple component that provides a basic editor that allows you to enter a “height” value and a “width” value. The component is functional, and it can be created and executed without any further configuration. When executed, the component uses these values to produce an output parameter for the calculated “area” value. In this example you will change the component to calculate the “volume” value as well as the “area” value.

  1. Create a new Isight project called Area as described in Creating an Eclipse Project to Store the Extension.

  2. When the Isight Project Templates screen appears on the New Project wizard, select the Example / Area Component template.

    This template is used to create the simple component.

  3. Once you have completed creating the extension, generate a .jar file so that you can view it in Isight as described in Packaging Your Extension for Use in Isight.

  4. Publish the component to your Isight library, and open it in the Design Gateway. For more information, see Publishing Objects to the Isight Library in the Isight User’s Guide. The component editor should appear as shown below.



  5. If necessary, re-open the extension’s project in Eclipse.

    Now you’ll alter the component to calculate the “volume” value in addition to the “area” value.

  6. Using the Project Explorer, navigate to the following location:

    \src\com\company\component\volume

  7. Double-click the Common.java file.

    The file’s contents appear in a new tab on the right side of the Isight Developer Perspective.

  8. Add the following two lines to the file:

    public static final String TAG_DEPTH = "Depth";

    public static final String TAG_VOLUME = "Volume";

  9. Double-click the AreaEditor.java file.

    The file’s contents appear in a new tab on the right side of the Isight Developer Perspective.

  10. Edit the AreaEditor.java file, as follows:

    1. Immediately following the two existing private JTextField entries, add a new entry called depthField.
    2. Add the following entries to the open method:

      Value dVal = getScalarValueByTag(Common.TAG_DEPTH);

      Double d = dVal.getAsReal()

      depthField.setText(d.toString());

    3. Add the following entries to the apply method:

      Value dVal = getScalarValueByTag(Common.TAG_DEPTH);

      double d = Double.parseDouble(depthField.getText());

      dVal.setValue(d)

    4. Locate the existing JLabel entries.
    5. In the appropriate locations, add the following entries:

      JLabel depthLabel = new JLabel("Depth: ");

      depthField = new JTextField(10);

      depthField.getDocument().addDocumentListener(new NumberDocumentValidator(depthField));

    6. Immediately below the JLabel entries, change GridLayout(2,2) to GridLayout(3,2).
    7. Below the existing add entries, add the following entries:

      add(depthLabel)

      add(depthField)

  11. Double-click the AreaExecutor.java file.

    The file’s contents appear in a new tab on the right side of the Isight Developer Perspective.

  12. Add the following entries to the execute method:

    ScalarVariable depthVar = runEnv.getScalarPropertyByTag(Common.TAG_DEPTH);

    ScalarVariable volumeVar = runEnv.getContext().getScalarByTag(Common.TAG_VOLUME);

    double d = depthVar.getValueObj().getAsReal();

    volumeVar.getValueObj().setValue(h * w * d);

  13. On the Isight Project Editor tab on the right side of the Isight Developer Perspective, click the Overview tab.

  14. Update the following settings for the modified component:

    1. At the end of the com.company.component string in the Name text box, replace the existing entry (Area) with Volume.
    2. In the Display Name text box, replace the existing entry (Area) with Volume.

  15. Click to save your changes to the extension.

  16. Create a .jar file for the updated component as described in Packaging Your Extension for Use in Isight.

  17. Publish the component’s .jar file to your Isight library, and open it in the Design Gateway. For more information, see Publishing Objects to the Isight Library in the Isight User’s Guide.

    The component editor should now contain a new text box for entering the Depth value and allow you to calculate the value of the Volume parameter.