@Override
  public String[] getAllPVNames() {
    if (editpart.getWidgetModel().getPVMap().isEmpty()) return new String[] {""}; // $NON-NLS-1$
    Set<String> result = new HashSet<String>();

    for (StringProperty sp : editpart.getWidgetModel().getPVMap().keySet()) {
      if (sp.isVisibleInPropSheet() && !((String) sp.getPropertyValue()).trim().isEmpty())
        result.add((String) sp.getPropertyValue());
    }
    return result.toArray(new String[result.size()]);
  }
 public void doActivate() {
   if (editpart.getExecutionMode() == ExecutionMode.RUN_MODE) {
     pvMap.clear();
     final Map<StringProperty, PVValueProperty> pvPropertyMap =
         editpart.getWidgetModel().getPVMap();
     for (final StringProperty sp : pvPropertyMap.keySet()) {
       if (sp.getPropertyValue() == null
           || ((String) sp.getPropertyValue()).trim().length() <= 0) {
         continue;
       }
       try {
         IPV pv = BOYPVFactory.createPV((String) sp.getPropertyValue(), isAllValuesBuffered);
         pvMap.put(sp.getPropertyID(), pv);
         WidgetPVListener pvListener = new WidgetPVListener(sp.getPropertyID());
         pv.addListener(pvListener);
         pvListenerMap.put(sp.getPropertyID(), pvListener);
       } catch (Exception e) {
         OPIBuilderPlugin.getLogger()
             .log(
                 Level.WARNING,
                 "Unable to connect to PV:" + (String) sp.getPropertyValue(),
                 e); //$NON-NLS-1$
       }
     }
   }
 }
  public void registerBasePropertyChangeHandlers() {
    class PVNamePropertyChangeHandler implements IWidgetPropertyChangeHandler {
      private String pvNamePropID;

      public PVNamePropertyChangeHandler(String pvNamePropID) {
        this.pvNamePropID = pvNamePropID;
      }

      public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
        IPV oldPV = pvMap.get(pvNamePropID);
        if (oldPV != null) {
          oldPV.stop();
          oldPV.removeListener(pvListenerMap.get(pvNamePropID));
        }
        pvMap.remove(pvNamePropID);
        String newPVName = ((String) newValue).trim();
        if (newPVName.length() <= 0) return false;
        try {
          lastWriteAccess = null;
          IPV newPV = BOYPVFactory.createPV(newPVName, isAllValuesBuffered);
          WidgetPVListener pvListener = new WidgetPVListener(pvNamePropID);
          newPV.addListener(pvListener);
          pvMap.put(pvNamePropID, newPV);
          pvListenerMap.put(pvNamePropID, pvListener);

          newPV.start();
        } catch (Exception e) {
          OPIBuilderPlugin.getLogger()
              .log(
                  Level.WARNING,
                  "Unable to connect to PV:"
                      + //$NON-NLS-1$
                      newPVName,
                  e);
        }

        return false;
      }
    }
    // PV name
    for (StringProperty pvNameProperty : editpart.getWidgetModel().getPVMap().keySet()) {
      if (editpart.getExecutionMode() == ExecutionMode.RUN_MODE)
        editpart.setPropertyChangeHandler(
            pvNameProperty.getPropertyID(),
            new PVNamePropertyChangeHandler(pvNameProperty.getPropertyID()));
    }

    if (editpart.getExecutionMode() == ExecutionMode.EDIT_MODE)
      editpart
          .getWidgetModel()
          .getProperty(IPVWidgetModel.PROP_PVNAME)
          .addPropertyChangeListener(
              new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                  // reselect the widget to update feedback.
                  int selected = editpart.getSelected();
                  if (selected != EditPart.SELECTED_NONE) {
                    editpart.setSelected(EditPart.SELECTED_NONE);
                    editpart.setSelected(selected);
                  }
                }
              });
  }