/** @generated */
 public ImageDescriptor getItemImageDescriptor(Object item) {
   IItemLabelProvider labelProvider =
       (IItemLabelProvider) adapterFactory.adapt(item, IItemLabelProvider.class);
   if (labelProvider != null) {
     return ExtendedImageRegistry.getInstance().getImageDescriptor(labelProvider.getImage(item));
   }
   return null;
 }
  /** @generated */
  protected ItemPropertyDescriptor createItemPropertyDescriptor(
      AdapterFactory adapterFactory,
      ResourceLocator resourceLocator,
      String displayName,
      String description,
      EStructuralFeature feature,
      boolean isSettable,
      boolean multiLine,
      boolean sortChoices,
      Object staticImage,
      String category,
      String[] filterFlags) {

    ComposedAdapterFactory composedAdapterFactory =
        new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);

    IItemPropertyDescriptorProvider descriptorProvider =
        (IItemPropertyDescriptorProvider)
            composedAdapterFactory.adapt(getTarget(), IItemPropertyDescriptorProvider.class);

    if (descriptorProvider != null)
      return descriptorProvider.createItemPropertyDescriptor(
          adapterFactory,
          resourceLocator,
          displayName,
          description,
          feature,
          isSettable,
          multiLine,
          sortChoices,
          staticImage,
          category,
          filterFlags);

    return super.createItemPropertyDescriptor(
        adapterFactory,
        resourceLocator,
        displayName,
        description,
        feature,
        isSettable,
        multiLine,
        sortChoices,
        staticImage,
        category,
        filterFlags);
  }
Ejemplo n.º 3
0
  private IStructuredSelection buildStructuredSelection(final EObject object) {
    if (object == null) {
      return new StructuredSelection();
    }
    final IItemPropertySource source =
        (IItemPropertySource) adapterFactory.adapt(object, IItemPropertySource.class);
    return new StructuredSelection() {
      public Object[] toArray() {
        return new Object[] {
          new URIBasedPropertySource(object, source, document) {

            protected IPropertyDescriptor createPropertyDescriptor(
                EObject object, IItemPropertyDescriptor itemPropertyDescriptor) {
              return new EFactoryPropertyDescriptor(object, itemPropertyDescriptor) {
                @Override
                protected CellEditor createEDataTypeCellEditor(
                    final EDataType eDataType, Composite composite) {
                  return new EFactoryEDataTypeCellEditor(eDataType, composite);
                }

                @Override
                public CellEditor createPropertyEditor(final Composite composite) {
                  CellEditor editor = null;
                  final Object feature = itemPropertyDescriptor.getFeature(this.object);
                  if (feature instanceof EReference) {
                    final EReference eReference = (EReference) feature;
                    editor =
                        new ExtendedDialogCellEditor(composite, getEditLabelProvider()) {
                          @Override
                          protected Object openDialogBox(Control cellEditorWindow) {
                            EObject result = null;
                            XtextEObjectSearchDialog2 dlg =
                                new XtextEObjectSearchDialog2(
                                    composite.getShell(),
                                    eObjectSearch,
                                    globalDescriptionLabelProvider);
                            eReference.getClass();
                            dlg.setInitialTypePattern(
                                eReference.getEReferenceType().getName(), false);
                            dlg.open();
                            Object[] dlgResult = dlg.getResult();
                            if (dlgResult != null && dlgResult.length == 1) {
                              result = ((IEObjectDescription) dlgResult[0]).getEObjectOrProxy();
                            }
                            // This is probably more of a work-around than a fix of the actual root
                            // cause :( but it works
                            if (result != null && result.eIsProxy())
                              result = EcoreUtil.resolve(result, eReference.eResource());
                            return result;
                          }
                        };
                  } else {
                    // return the default cell editor
                    editor = super.createPropertyEditor(composite);
                  }
                  return editor;
                }
              };
            }
          }
        };
      }
    };
  }