Code Snippet: Getting a components preferences

Making your components data driven is a key area of composite applications.  This gives the assembler the ability to change the characteristics of your component at assembly time.

Getting a components preferences

One thought on “Code Snippet: Getting a components preferences

  1. What is the best practice for updating a preference? I’ve been using this:

    IEditModeController emc = AAFPlugin.getEditModeController();
    IComponentManager cm = emc.getComponentManager();
    String entityId =
    cm.getEntityIdfromObjId(part.getViewSite().getSecondaryId());

    ComponentPreferenceManager cpm = new ComponentPreferenceManager(cm.getComponentAttrList(entityId), entityId);

    ComponentPreference cp = cpm.findPreference(key);

    if (cp != null )
    cp.changeValue(value);
    else
    cpm.addPref(key, value);

    cm.setComponentAttrList(cpm.getValues(), entityId);
    cpm.updateTopology(false);

    Is there a more streamlined way? Also, ComponentData does not reflect the new/updated preference, so I have to use ComponentPreferenceManager to get preferences after updating them.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s