/*
   * (non-Javadoc)
   *
   * @see com.puppetlabs.geppetto.pp.dsl.linking.IMessageAcceptor#accept(org.eclipse.xtext.diagnostics.Severity, java.lang.String,
   * org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EStructuralFeature, int, java.lang.String, java.lang.String)
   */
  @Override
  public void accept(
      Severity severity,
      String message,
      EObject source,
      EStructuralFeature feature,
      int index,
      String issueCode,
      String... issueData) {

    if (severity == null) throw new IllegalArgumentException("severity can not be null");
    if (feature == null) throw new IllegalArgumentException("feature can not be null");
    if (source == null) throw new IllegalArgumentException("source can not be null");

    if (source.eClass().getEStructuralFeature(feature.getName()) != feature) {
      throw new IllegalArgumentException(
          "EClass '"
              + source.eClass().getName()
              + "' does not expose a feature '"
              + feature.getName()
              + //
              "' (id: "
              + feature.getFeatureID()
              + ")");
    }

    producer.setNode(getNode(source, feature, index));
    DiagnosticMessage m = new DiagnosticMessage(message, severity, issueCode, issueData);
    producer.addDiagnostic(m);
  }
예제 #2
0
  protected Declaration handleStyleFeature(Style style, EStructuralFeature feature) {
    Declaration declaration = CssFactory.eINSTANCE.createDeclaration();
    declaration.setProperty(feature.getName());

    GMFToCSSConverter converter = GMFToCSSConverter.instance;

    if (isString(feature)) {
      declaration.setExpression(converter.convert((String) style.eGet(feature)));
    }

    if (isInteger(feature)) {
      if (feature.getName().endsWith("Color")) {
        Color color = FigureUtilities.integerToColor((Integer) style.eGet(feature));
        declaration.setExpression(converter.convert(color));
        color.dispose();
      } else {
        declaration.setExpression(converter.convert((Integer) style.eGet(feature)));
      }
    }

    if (feature.getEType() == NotationPackage.eINSTANCE.getGradientData()) {
      declaration.setExpression(converter.convert((GradientData) style.eGet(feature)));
    }

    if (feature.getEType() instanceof EEnum) {
      declaration.setExpression(converter.convert((Enumerator) style.eGet(feature)));
    }

    if (isBoolean(feature)) {
      declaration.setExpression(converter.convert((Boolean) style.eGet(feature)));
    }

    return declaration;
  }
  protected boolean matchesFeature(Object featureObj) {
    if (featureObj instanceof EStructuralFeature) {
      EStructuralFeature f = (EStructuralFeature) featureObj;
      return feature.getName().equals(f.getName());
    }

    return false;
  }
예제 #4
0
 /**
  * This basically calls a setter via EMF reflection to set a structural feature.
  *
  * <ul>
  *   <li>If <code>value</code> is a {@link List} of elements, the feature <code>ref</code> must,
  *       of course, also be a list.
  *   <li>If <code>value</code> is a single element, then <code>ref</code> might have multiplicity
  *       <code>1</code> or it might also be a list. In the latter case, <code>value</code> is
  *       added to the list.
  * </ul>
  *
  * @param obj The object which holds the feature to set.
  * @param ref The feature which should be set.
  * @param value The value that should be set.
  * @return <code>true</code>, if the value could be set or <b>if it was already set</b>; <code>
  *     false</code> otherwise.
  */
 @SuppressWarnings("unchecked")
 public static boolean setStructuralFeature(EObject obj, EStructuralFeature ref, Object value) {
   if (!ref.isChangeable()) {
     throw new IllegalArgumentException(
         "Cannot set a non-changeable reference: " + obj.eClass().getName() + "." + ref.getName());
   }
   try {
     if (ref.isMany()) {
       final List<Object> list = (List<Object>) obj.eGet(ref);
       if (value instanceof List) {
         final List<Object> valueList = (List<Object>) value;
         for (final Object listValue : valueList) {
           if (!list.contains(listValue) && !list.add(listValue)) {
             return false;
           }
         }
       } else {
         if (!list.contains(value) && !list.add(value)) {
           return false;
         }
       }
       return true;
     } else {
       if (value instanceof List) {
         final List<Object> valueList = (List<Object>) value;
         if (valueList.size() > 1) {
           throw new IllegalArgumentException(
               "Cannot set a list of values to a non-many feature!");
         } else if (valueList.size() == 1) {
           if (obj.eGet(ref) == null || !obj.eGet(ref).equals(valueList.get(0))) {
             obj.eSet(ref, valueList.get(0));
           }
         } else {
           obj.eSet(ref, null);
         }
       } else {
         if (obj.eGet(ref) == null || !obj.eGet(ref).equals(value)) {
           obj.eSet(ref, value);
         }
       }
       return true;
     }
   } catch (final Exception e) {
     throw new IllegalArgumentException(
         "Could not set value ("
             + value
             + ") to: "
             + obj.eClass().getName()
             + "."
             + ref.getName()
             + " of object "
             + obj,
         e);
   }
 }
 /**
  * @param copyObjs
  * @return 转换为粘贴对象
  */
 private Collection<Object> getPasteObjs(Collection<Object> copyObjs, EClass eclass) {
   List<Object> objs = new ArrayList<Object>();
   Map<EStructuralFeature, EStructuralFeature> map =
       new HashMap<EStructuralFeature, EStructuralFeature>();
   // 由第一个复制对象,找出复制对象和粘贴对象匹配的属性
   Iterator<Object> it = copyObjs.iterator();
   if (it.hasNext()) {
     Object obj = it.next();
     if (obj instanceof EObject) {
       EObject copyObj = (EObject) obj;
       // 如果是同一个编辑器内进行粘贴,直接返回复制对象集合
       if (copyObj.eClass().equals(eclass)) {
         return copyObjs;
       }
       // name一样,则表示属性匹配
       for (EStructuralFeature copyFeature : copyObj.eClass().getEAllStructuralFeatures()) {
         if (!exclude.contains(copyFeature)) {
           for (EStructuralFeature pasteFeature : eclass.getEAllStructuralFeatures()) {
             if (StringUtils.equals(copyFeature.getName(), pasteFeature.getName())) {
               map.put(copyFeature, pasteFeature);
               break;
             }
           }
         }
       }
     }
   }
   // 如果没有匹配的属性,则返回空集合
   if (map.isEmpty()) {
     return objs;
   }
   for (Object obj : copyObjs) {
     EObject copyObj = (EObject) obj;
     EObject pasteObj = eclass.getEPackage().getEFactoryInstance().create(eclass);
     for (Entry<EStructuralFeature, EStructuralFeature> entry : map.entrySet()) {
       EStructuralFeature copyFeature = entry.getKey();
       EStructuralFeature pasteFeature = entry.getValue();
       if (copyFeature instanceof EAttribute) {
         // 设置匹配属性值
         pasteObj.eSet(pasteFeature, copyObj.eGet(copyFeature));
       } else if (copyFeature instanceof EReference) {
         // 设置匹配子集
         Collection<Object> tmp = (Collection<Object>) copyObj.eGet(copyFeature);
         if (tmp != null) {
           pasteObj.eSet(
               pasteFeature,
               getPasteObjs(
                   EcoreUtil.copyAll(tmp), ((EReference) pasteFeature).getEReferenceType()));
         }
       }
     }
     objs.add(pasteObj);
   }
   return objs;
 }
예제 #6
0
 protected String toString(IEObjectRegion region) {
   EObject obj = region.getSemanticElement();
   StringBuilder builder =
       new StringBuilder(Strings.padEnd(toClassWithName(obj), textWidth, ' ') + " ");
   EObject element = region.getGrammarElement();
   if (element instanceof AbstractElement)
     builder.append(grammarToString.apply((AbstractElement) element));
   else if (element instanceof AbstractRule) builder.append(((AbstractRule) element).getName());
   else builder.append(": ERROR: No grammar element.");
   List<String> segments = Lists.newArrayList();
   EObject current = obj;
   while (current.eContainer() != null) {
     EObject container = current.eContainer();
     EStructuralFeature containingFeature = current.eContainingFeature();
     StringBuilder segment = new StringBuilder();
     segment.append(toClassWithName(container));
     segment.append("/");
     segment.append(containingFeature.getName());
     if (containingFeature.isMany()) {
       int index = ((List<?>) container.eGet(containingFeature)).indexOf(current);
       segment.append("[" + index + "]");
     }
     current = container;
     segments.add(segment.toString());
   }
   if (!segments.isEmpty()) {
     builder.append(" path:");
     builder.append(Joiner.on("=").join(segments));
   }
   return builder.toString();
 }
 protected void copyAndAdd(
     final Set additionalObjects, final EObject container, final EStructuralFeature feature) {
   final CopyCommand.Helper helper = this.mainCopyCommand.getCopyKeyedByOriginalMap();
   final Command copyCommand =
       ModelEditorImpl.createCopyCommand(this.domain, additionalObjects, helper);
   final boolean copied = this.appendAndExecute(copyCommand);
   if (copied) {
     // Create the add command to place all of the annotations into the annotation container ...
     final Collection copiedAnnotations = copyCommand.getResult();
     final Command addCommand =
         AddCommand.create(this.domain, container, feature, copiedAnnotations);
     final boolean added = this.appendAndExecute(addCommand);
     if (!added) {
       // Failed, but the copied objects will be left without a parent
       // and will simply be garbage collected.  However, log anyway ...
       final Object[] params =
           new Object[] {new Integer(copiedAnnotations.size()), feature.getName()};
       final String msg =
           ModelerCore.Util.getString(
               "CopyWithRelatedToClipboardCommand.Failed_to_add_{0}_copied_{1}_to_clipboard",
               params); //$NON-NLS-1$
       ModelerCore.Util.log(msg);
     }
   }
 }
예제 #8
0
 @Override
 public String toString() {
   StringBuilder s = new StringBuilder();
   s.append(reference.getName());
   s.append(" : "); // $NON-NLS-1$
   //		s.append(reference.getEType().getName());
   if (requiredType != null) {
     s.append(requiredType.getName());
   }
   if (isQualifier) {
     s.append(" (qualifier)");
   }
   s.append(" \""); // $NON-NLS-1$
   if (name != null) {
     s.append(name);
   }
   s.append("\" {"); // $NON-NLS-1$
   String prefix = ""; // $NON-NLS-1$
   for (String contentName : contentsByName.keySet()) {
     s.append(prefix);
     s.append(contentName);
     Object content = contentsByName.get(contentName);
     if (content instanceof List<?>) {
       s.append("*");
       s.append(((List<?>) content).size());
     }
     prefix = ","; // $NON-NLS-1$
   }
   s.append("}"); // $NON-NLS-1$
   return s.toString();
 }
예제 #9
0
 @Override
 public String toString() {
   StringBuffer s = new StringBuffer();
   s.append(getClass().getSimpleName());
   s.append(" : ");
   if (pivotParent != null) {
     s.append(pivotParent.eClass().getName());
   } else if (csElement instanceof EObject) {
     s.append(((EObject) csElement).eClass().getName());
   } else {
     s.append("???");
   }
   s.append(".");
   s.append(pivotFeature != null ? pivotFeature.getName() : "*");
   s.append(" : ");
   String elementName = null;
   if (csElement instanceof MonikeredElementCS) {
     MonikeredElementCS csMonikeredElement = (MonikeredElementCS) csElement;
     if (csMonikeredElement.hasMoniker()) {
       elementName = csMonikeredElement.getMoniker();
     }
   }
   if (elementName == null) {
     elementName = csElement.toString();
   }
   s.append(elementName);
   return s.toString();
 }
예제 #10
0
 private void writeEmbedded(PrintWriter out, EObject eObject) throws SerializerException {
   EClass class1 = eObject.eClass();
   out.print(upperCases.get(class1));
   out.print(OPEN_PAREN);
   EStructuralFeature structuralFeature = class1.getEStructuralFeature(WRAPPED_VALUE);
   if (structuralFeature != null) {
     Object realVal = eObject.eGet(structuralFeature);
     if (structuralFeature.getEType() == ECORE_PACKAGE_INSTANCE.getEDouble()) {
       Object stringVal =
           eObject.eGet(class1.getEStructuralFeature(structuralFeature.getName() + "AsString"));
       if (stringVal != null && model.isUseDoubleStrings()) {
         out.print(stringVal);
       } else {
         if (((Double) realVal).isInfinite() || (((Double) realVal).isNaN())) {
           LOGGER.info("Serializing infinite or NaN double as 0.0");
           out.print("0.0");
         } else {
           out.print(realVal);
         }
       }
     } else {
       writePrimitive(out, realVal);
     }
   }
   out.print(CLOSE_PAREN);
 }
 /* (non-Javadoc)
  * @see org.eclipse.graphiti.features.IFeature#canExecute(org.eclipse.graphiti.features.context.IContext)
  */
 @Override
 public boolean canExecute(IContext context) {
   // TODO: clean this mess up: use {@code getWorkItemEditor()) to check if the selected task
   // has a WID and if the WID defines a customEditor
   BPMN2Editor editor =
       (BPMN2Editor)
           getFeatureProvider()
               .getDiagramTypeProvider()
               .getDiagramBehavior()
               .getDiagramContainer();
   IBpmn2RuntimeExtension rte = editor.getTargetRuntime().getRuntimeExtension();
   if (rte instanceof JBPM5RuntimeExtension && context instanceof ICustomContext) {
     PictogramElement[] pes = ((ICustomContext) context).getPictogramElements();
     if (pes.length == 1) {
       Object o = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(pes[0]);
       if (o instanceof Task) {
         Task task = (Task) o;
         List<EStructuralFeature> features = ModelDecorator.getAnyAttributes(task);
         for (EStructuralFeature f : features) {
           if ("taskName".equals(f.getName())) { // $NON-NLS-1$
             // make sure the Work Item Definition exists
             String taskName = (String) task.eGet(f);
             return ((JBPM5RuntimeExtension) rte).getWorkItemDefinition(taskName) != null;
           }
         }
       }
     }
   }
   return false;
 }
 @Override
 protected AbstractListComposite bindList(
     EObject object, EStructuralFeature feature, EClass listItemClass) {
   if ("imports".equals(feature.getName())) { // $NON-NLS-1$
     ImportListComposite importsTable = new ImportListComposite(getPropertySection());
     EStructuralFeature importsFeature =
         object.eClass().getEStructuralFeature("imports"); // $NON-NLS-1$
     importsTable.bindList(object, importsFeature);
     return importsTable;
   } else if ("relationships".equals(feature.getName())) { // $NON-NLS-1$
     DefaultListComposite table = new DefaultListComposite(getPropertySection());
     table.bindList(getBusinessObject(), feature);
     return table;
   } else {
     return super.bindList(object, feature, listItemClass);
   }
 }
 protected Task createFlowElement(ICreateContext context) {
   Task task = ModelHandler.FACTORY.createTask();
   task.setName("Email Task");
   ArrayList<EStructuralFeature> attributes = Bpmn2Preferences.getAttributes(task.eClass());
   for (EStructuralFeature eStructuralFeature : attributes) {
     if (eStructuralFeature.getName().equals("taskName")) task.eSet(eStructuralFeature, "email");
   }
   return task;
 }
예제 #14
0
 public static String getLabel(EObject object, EStructuralFeature feature) {
   String label = "";
   ExtendedPropertiesAdapter adapter =
       (ExtendedPropertiesAdapter) AdapterUtil.adapt(object, ExtendedPropertiesAdapter.class);
   if (adapter != null) label = adapter.getFeatureDescriptor(feature).getLabel(object);
   else label = ModelUtil.toDisplayName(feature.getName());
   label = label.replaceAll(" Ref$", "");
   return label;
 }
 public String syntheticName(final KeyAST b) {
   final EObject binding = b.eContainer();
   EStructuralFeature _eContainingFeature = b.eContainingFeature();
   String _name = _eContainingFeature.getName();
   String _plus = ("_" + _name);
   EObject _eContainer = binding.eContainer();
   EList<EObject> _eContents = _eContainer.eContents();
   int _indexOf = _eContents.indexOf(binding);
   return (_plus + Integer.valueOf(_indexOf));
 }
예제 #16
0
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated NOT
  */
 public String getModificationSummary() {
   try {
     final StringBuilder sb = new StringBuilder(eStructuralFeature.getName());
     sb.append(" = ");
     sb.append(getCurrentValueText());
     return sb.toString();
   } catch (RuntimeException e) {
     return "foo";
   }
 } // getModificationSummary
 public EObject resolve(
     ParseTreeNode parseTreeNode,
     Object actual,
     Object value,
     IModelCreatingContext context,
     ReferenceBinding binding)
     throws ModelCreatingException, UnresolveableReferenceErrorException {
   String id = parseTreeNode.getNodeText();
   EObject resolution = null;
   if (actual instanceof PropertyBinding) {
     EClass correspondingMetaClass =
         SyntaxHelper.findCorrespondingElementBinding(
             getContainingRule((EObject) actual),
             (Syntax) context.getResource().getContents().get(0),
             new HashSet<Rule>());
     if (correspondingMetaClass == null) {
       new UnresolvableReferenceError(
               "Cannot resolve the meta-class for the given property", parseTreeNode)
           .throwIt();
       return null;
     }
     for (EStructuralFeature feature : correspondingMetaClass.getEAllStructuralFeatures()) {
       if (feature.getName().equals(id)) {
         resolution = feature;
       }
     }
     if (resolution == null) {
       new UnresolvableReferenceError(
               "Class "
                   + correspondingMetaClass.getName()
                   + " does not contain a structural feature with the given name",
               parseTreeNode)
           .throwIt();
       return null;
     }
   } else {
     try {
       resolution =
           resolve(
               DefaultIdentificationScheme.INSTANCE,
               id,
               null,
               binding.getProperty().getEType(),
               context.getAdapter(IEcoreModel.class).getAllContents());
     } catch (AmbiguousReferenceException ex) {
       context.addError(new Error(parseTreeNode.getPosition(), "Reference is ambiguous"));
     }
   }
   if (resolution != null) {
     return resolution;
   } else {
     new UnresolvableReferenceError("Could not resolve " + id + ".", parseTreeNode).throwIt();
     return null;
   }
 }
 @SuppressWarnings("unchecked")
 private void refreshDerivedFeature() {
   logger.trace("[Notify: " + derivedFeature.getName() + "] Derived refresh.");
   try {
     if (source.eNotificationRequired()) {
       if (type == null) {
         type = derivedFeature.getEType();
       }
       if (derivedFeature.isMany()) {
         if (currentValue != null) {
           oldValue = new HashSet<EObject>((Collection<EObject>) currentValue);
         } else {
           oldValue = new HashSet<EObject>();
         }
         currentValue = new HashSet<EObject>();
         Collection<? extends Object> targets =
             (Collection<? extends Object>) source.eGet(derivedFeature);
         int position = 0;
         for (Object target : targets) {
           comprehension.traverseFeature(visitor, source, derivedFeature, target, position++);
         }
         if (currentValue instanceof Collection<?> && oldValue instanceof Collection<?>) {
           ((Collection<?>) oldValue).removeAll((Collection<?>) currentValue);
           if (((Collection<?>) oldValue).size() > 0) {
             sendRemoveManyNotification(source, derivedFeature, oldValue);
           }
         }
       } else {
         Object target = source.eGet(derivedFeature);
         comprehension.traverseFeature(visitor, source, derivedFeature, target, null);
       }
     }
   } catch (Exception ex) {
     logger.error(
         "The derived feature adapter encountered an error in processing the EMF model. "
             + "This happened while maintaining the derived feature "
             + derivedFeature.getName()
             + " of object "
             + source,
         ex);
   }
 }
 public String getId(EObject object) {
   if (object == null) return null;
   List<EStructuralFeature> features = ModelUtil.getAnyAttributes(object);
   for (EStructuralFeature f : features) {
     if ("sampleCustomTaskId".equals(f.getName())) {
       Object attrValue = object.eGet(f);
       return (String) attrValue;
     }
   }
   return null;
 }
  @SuppressWarnings("unchecked")
  private void writeTable(PrintWriter out, EObject eObject) {
    out.println("<h1>" + eObject.eClass().getName() + "</h1>");
    out.println("<table>");
    for (EStructuralFeature eStructuralFeature : eObject.eClass().getEAllStructuralFeatures()) {
      if (eStructuralFeature.getEAnnotation("hidden") == null) {
        out.println("<tr>");
        out.println("<td>" + eStructuralFeature.getName() + "</td>");
        Object eGet = eObject.eGet(eStructuralFeature);
        if (eStructuralFeature instanceof EAttribute) {
          if (eStructuralFeature.getUpperBound() == 1) {
            out.println("<td>" + eGet + "</td>");
          } else {
            List<Object> list = (List<Object>) eGet;
            out.println("<td>");
            for (Object object : list) {
              out.println(object + " ");
            }
            out.println("</td>");
          }
        } else if (eStructuralFeature instanceof EReference) {
          if (eStructuralFeature.getUpperBound() == 1) {
            if (eStructuralFeature.getEType().getEAnnotation("wrapped") != null) {
              EObject value = (EObject) eGet;
              if (value != null) {
                out.println(
                    "<td>"
                        + value.eGet(value.eClass().getEStructuralFeature("wrappedValue"))
                        + "</td>");
              }
            } else {

            }
          } else {
            if (eStructuralFeature.getEType().getEAnnotation("wrapped") != null) {
              List<EObject> list = (List<EObject>) eGet;
              out.println("<td>");
              for (EObject object : list) {
                out.println(
                    "<td>"
                        + object.eGet(object.eClass().getEStructuralFeature("wrappedValue"))
                        + "</td>");
              }
              out.println("</td>");
            } else {

            }
          }
        }
      }
      out.println("</tr>");
    }
    out.println("</table>");
  }
예제 #21
0
  public String getUnsettableFieldName(EStructuralFeature feature) {
    String name = DBAnnotation.COLUMN_NAME.getValue(feature);
    if (name != null) {
      return CDO_SET_PREFIX + name;
    }

    return getName(
        CDO_SET_PREFIX + feature.getName(),
        TYPE_PREFIX_FEATURE + getUniqueID(feature),
        getMaxFieldNameLength());
  }
예제 #22
0
  public String getFieldName(EStructuralFeature feature) {
    String name = DBAnnotation.COLUMN_NAME.getValue(feature);
    if (name == null) {
      name =
          getName(
              feature.getName(),
              TYPE_PREFIX_FEATURE + getUniqueID(feature),
              getMaxFieldNameLength());
    }

    return name;
  }
예제 #23
0
  @Override
  public String getHeaderText() {
    if (headerText != null) return headerText;

    String text = "";
    if (feature != null) {
      if (feature.eContainer() instanceof EClass) {
        EClass eclass = this.listComposite.getListItemClass();
        text = ModelUtil.getLabel(eclass, feature);
      } else text = ModelUtil.toDisplayName(feature.getName());
    }
    return text;
  }
  public void resolve(
      String identifier,
      org.emftext.language.petrinets.Setting container,
      org.eclipse.emf.ecore.EReference reference,
      int position,
      boolean resolveFuzzy,
      final org.emftext.language.petrinets.resource.petrinets.IPetrinetsReferenceResolveResult<
              org.eclipse.emf.ecore.EStructuralFeature>
          result) {
    EClassifier type;
    if (container.eContainer() instanceof ProducingArc) {
      ProducingArc arc = (ProducingArc) container.eContainer();
      type = FunctionCallAnalysisHelper.getInstance().getType(arc.getOutput());
    } else {
      ConstructorCall cc = (ConstructorCall) container.eContainer();
      type = cc.getType();
    }

    List<EStructuralFeature> candidates = new ArrayList<EStructuralFeature>();
    if (type != null && type instanceof EClass) {
      EClass c = (EClass) type;
      candidates.addAll(c.getEAllStructuralFeatures());
    } else if (type instanceof EDataType) {
      EAttribute dummy = EcoreFactory.eINSTANCE.createEAttribute();
      dummy.setName(type.getName());
      dummy.setEType(type);
      dummy.setUpperBound(1);
      dummy.setLowerBound(1);
      candidates.add(dummy);
    }
    for (EStructuralFeature eStructuralFeature : candidates) {
      if (resolveFuzzy) {
        result.addMapping(eStructuralFeature.getName(), eStructuralFeature);
      } else if (identifier.equals(eStructuralFeature.getName())) {
        result.addMapping(eStructuralFeature.getName(), eStructuralFeature);
      }
    }
  }
 /**
  * Get the metaclass label (emitted by EMF Edit generation) for given object according given
  * editing domain.
  *
  * @param object_p
  * @param provider_p
  * @return <code>null</code> if one of parameters is <code>null</code> or if no label is found.
  */
 public static String getFeatureLabel(
     EStructuralFeature feature_p, ItemProviderAdapter provider_p) {
   String label = null;
   // Preconditions.
   if ((null == feature_p) || (null == provider_p)) {
     return label;
   }
   String featureKey =
       feature_p.getEContainingClass().getName()
           + ICommonConstants.UNDERSCORE_CHARACTER
           + feature_p.getName();
   label = provider_p.getString(GENERATED_KEY_PREFIX + featureKey + FEATURE_GENERATED_KEY_SUFFIX);
   return label;
 }
예제 #26
0
 public boolean shouldFollowReference(
     EClass originalQueryClass, EClass eClass, EStructuralFeature eStructuralFeature) {
   StructuralFeatureIdentifier o =
       new StructuralFeatureIdentifier(eClass.getName(), eStructuralFeature.getName());
   boolean generalShouldIgnoreAnswer = generalIgnoreSet.contains(o);
   if (generalShouldIgnoreAnswer) {
     // If the general ignore file says ignore, we should check for a specific override
     if (specificIncludeMap.containsKey(originalQueryClass)) {
       return specificIncludeMap.get(originalQueryClass).contains(o);
     }
     return false;
   }
   return true;
 }
예제 #27
0
 private boolean isCollectInFeatureWithoutImports(
     ConcreteSyntax syntax, EStructuralFeature feature) {
   for (CompleteTokenDefinition tokenDefinition : syntax.getActiveTokens()) {
     String attributeName = tokenDefinition.getAttributeName();
     if (attributeName == null) {
       // this is not a collect-in token. thus, ignore it.
       continue;
     }
     boolean namesMatch = attributeName.equals(feature.getName());
     if (namesMatch) {
       return true;
     }
   }
   return false;
 }
예제 #28
0
 protected void displayProperties(EObject eobject) {
   if (eobject == null) {
     labelProperties.setText("");
   } else {
     StringBuffer buffer = new StringBuffer();
     ILabelProvider labelProvider = getLabelProvider();
     for (EStructuralFeature f : eobject.eClass().getEAllStructuralFeatures()) {
       if (!(f instanceof EReference && ((EReference) f).isContainment())) {
         buffer.append(f.getName()).append(" : ");
         buffer.append(getText(eobject, labelProvider, f));
         buffer.append("\n");
       }
     }
     labelProperties.setText(buffer.toString());
   }
 }
예제 #29
0
    @Override
    public String toString() {
      final StringBuilder sb = new StringBuilder(50);
      sb.append(ClassUtils.getLastClassName(this)).append('[');
      boolean first = true;
      for (final EStructuralFeature sf : myFeatures) {
        if (!first) {
          sb.append('.');
        }
        sb.append(sf.getName());
        first = false;
      }
      sb.append(']');

      return sb.toString();
    }
예제 #30
0
 public PropertiesEditionElement eStructuralFeature2EditionElement(
     List<ViewElement> concerningViews, EStructuralFeature feature) {
   PropertiesEditionElement element = ComponentsFactory.eINSTANCE.createPropertiesEditionElement();
   element.setName(feature.getName());
   element.setModel(feature);
   List<ViewElement> list = workingResolvTemp.get(feature);
   if (list != null) {
     for (ViewElement viewElement : list) {
       if (inConcerningViews(concerningViews, viewElement))
         element.getViews().add((ElementEditor) viewElement);
     }
   } else {
     System.err.println("No view found for : " + feature.toString());
     return null;
   }
   return element;
 }