/* * (non-Javadoc) * @see org.eclipse.sapphire.ui.SapphireActionHandler#run(org.eclipse.sapphire.ui.SapphireRenderingContext) */ @Override protected Object run(SapphireRenderingContext context) { final IModelElement rootModel = context.getPart().getModelElement(); final ModelProperty modelProperty = rootModel.getModelElementType().getProperty(this.strModelProperty); Object obj = rootModel.read(modelProperty); IModelElement mElement = null; if (obj instanceof ModelElementList<?>) { // System.out.println( "QuickActionsHandlerFactory.Handler.run()" + obj.getClass() ); ModelElementList<?> list = (ModelElementList<?>) obj; mElement = list.addNewElement(); } else { throw new UnsupportedOperationException( Resources.bind(Resources.unsuportedOperation, this.strModelProperty)); } // Select the ndoe final MasterDetailsEditorPagePart page = getPart().nearest(MasterDetailsEditorPagePart.class); final MasterDetailsContentNode root = page.getContentOutline().getRoot(); final MasterDetailsContentNode node = root.findNodeByModelElement(mElement); if (node != null) { node.select(); } return mElement; }
@Override public void init(SapphireAction action, ISapphireActionHandlerFactoryDef def) { super.init(action, def); String strModelElementNames = def.getParam("MODEL_PROPERTIES"); if (strModelElementNames != null) { this.modelProperties = strModelElementNames.split(","); } else { throw new IllegalStateException(Resources.bind(Resources.message, "MODEL_PROPERTIES")); } }