Exemplo n.º 1
0
  @Override
  public void fillMenu(
      final IBNAView view, List<IThing> things, final ICoordinate location, IMenuManager m) {
    IThing editThing = null;
    if (Iterables.size(BNAUtils.getSelectedThings(view.getBNAWorld().getBNAModel())) <= 1) {
      MAIN:
      for (IThing thing : things) {
        for (IThing assemblyPartThing :
            Assemblies.getRelatedParts(view.getBNAWorld().getBNAModel(), thing)) {
          if (assemblyPartThing instanceof IHasMutableText
              && UserEditableUtils.isEditableForAnyQualities(
                  assemblyPartThing,
                  IHasMutableText.USER_MAY_EDIT_TEXT,
                  IHasToolTip.USER_MAY_EDIT_TOOL_TIP)) {
            editThing = assemblyPartThing;
            break MAIN;
          }
        }
      }
    }
    final IThing finalThing = editThing;
    if (finalThing != null) {
      m.add(
          new Action("Edit Description...") {

            @Override
            public void run() {
              initEdit(finalThing);
            }
          });
    }
  }
Exemplo n.º 2
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());
       }
     }
   }
 }
Exemplo n.º 3
0
 @Override
 public void keyReleased(IBNAView view, KeyEvent e) {
   if (SWT.F2 == e.keyCode) {
     IThing editThing = null;
     if (Iterables.size(BNAUtils.getSelectedThings(view.getBNAWorld().getBNAModel())) == 1) {
       MAIN:
       for (IThing thing : BNAUtils.getSelectedThings(view.getBNAWorld().getBNAModel())) {
         for (IThing assemblyPartThing :
             Assemblies.getRelatedParts(view.getBNAWorld().getBNAModel(), thing)) {
           if (UserEditableUtils.isEditableForAnyQualities(
               assemblyPartThing,
               IHasMutableText.USER_MAY_EDIT_TEXT,
               IHasToolTip.USER_MAY_EDIT_TOOL_TIP)) {
             editThing = assemblyPartThing;
             break MAIN;
           }
         }
       }
     }
     if (editThing != null) {
       initEdit(editThing);
     }
   }
 }