Пример #1
0
 @Override
 public void bnaModelChanged(BNAModelEvent evt) {
   if (evt.getEventType() == BNAModelEvent.EventType.THING_REMOVED) {
     EditTextLogicData data = evt.getTargetThing().get(DATA_KEY);
     if (data != null) {
       SWTTextThing tt = (SWTTextThing) evt.getTargetThing();
       IThing t = evt.getSource().getThing(data.thingID);
       if (t instanceof IHasMutableText
           && UserEditableUtils.isEditableForAnyQualities(t, IHasMutableText.USER_MAY_EDIT_TEXT)) {
         BNAOperations.set("Text", getBNAModel(), t, IHasText.TEXT_KEY, tt.getText());
       } else if (t != null
           && UserEditableUtils.isEditableForAnyQualities(t, IHasToolTip.USER_MAY_EDIT_TOOL_TIP)) {
         BNAOperations.set("Text", getBNAModel(), t, IHasToolTip.TOOL_TIP_KEY, tt.getText());
       }
     }
   }
 }
Пример #2
0
  private void initEdit(IThing forThing) {
    checkNotNull(forThing);

    IBNAModel model = getBNAModel();
    if (model != null) {
      Point p = checkNotNull(BNAUtils.getCentralPoint(forThing));

      SWTTextThing tt = model.addThing(new SWTTextThing(null), forThing);
      tt.set(DATA_KEY, new EditTextLogicData(forThing.getID()));
      String text = "";
      if (forThing instanceof IHasText) {
        text = ((IHasText) forThing).getText();
      } else {
        text = ToolTipLogic.getToolTip(forThing);
      }
      tt.setText(text);
      tt.setBoundingBox(new Rectangle(p.x, p.y, 0, 0));
    }
  }