@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); } }); } }
@Override protected EllipseGlassThing addThing(List<ObjRef> relLineageRefs, ObjRef objRef) { Point newPointSpot = ArchipelagoUtils.findOpenSpotForNewThing(getBNAWorld().getBNAModel()); EllipseThing edge = getBNAModel().addThing(new EllipseThing(null)); edge.setLineWidth(2); edge.setColor(null); EllipseGlassThing thing = Assemblies.createEllipse(getBNAWorld(), null, edge); thing.setBoundingBox( new Rectangle(newPointSpot.x, newPointSpot.y, defaultSize.width, defaultSize.height)); Assemblies.BACKGROUND_KEY .get(thing, getBNAModel()) .set(IHasColor.COLOR_KEY, new RGB(32, 32, 32)); Assemblies.BACKGROUND_KEY.get(thing, getBNAModel()).set(IHasCount.COUNT_KEY, defaultCount); Assemblies.BACKGROUND_KEY .get(thing, getBNAModel()) .set(IHasLocalInsets.LOCAL_INSETS_KEY, new Insets(4, 4, 4, 4)); Assemblies.markPart(thing, EDGE_KEY, edge); mvl.mirrorValue( Assemblies.BACKGROUND_KEY.get(thing, getBNAModel()), IHasColor.COLOR_KEY, Assemblies.BACKGROUND_KEY.get(thing, getBNAModel()), IHasSecondaryColor.SECONDARY_COLOR_KEY, new Function<RGB, RGB>() { @Override @Nullable public RGB apply(@Nullable RGB input) { return BNAUtils.adjustBrightness(input, 1.5f); } }); mvl.mirrorValue(thing, IHasBoundingBox.BOUNDING_BOX_KEY, edge); UserEditableUtils.addEditableQualities( thing, IHasMutableSelected.USER_MAY_SELECT, IRelativeMovable.USER_MAY_MOVE); return thing; }
@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); } } }