コード例 #1
0
    /*
     * (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;
    }
コード例 #2
0
    @Override
    public void init(SapphireAction action, ISapphireActionHandlerDef def) {
      super.init(action, def);
      final IModelElement rootModel = action.getPart().getModelElement();
      final ModelProperty modelProperty =
          rootModel.getModelElementType().getProperty(this.strModelProperty);

      String labelText = modelProperty.getLabel(false, CapitalizationType.FIRST_WORD_ONLY, true);
      String actionLabel = getActionLabel(labelText);
      setLabel(actionLabel);

      ModelElementType propModelElementType = modelProperty.getType();
      addImage(propModelElementType.image());
    }