コード例 #1
0
  @Override
  public IHyperlink[] createHyperlinksByOffset(
      XtextResource resource, int offset, boolean createMultipleHyperlinks) {
    IHyperlink[] links = super.createHyperlinksByOffset(resource, offset, createMultipleHyperlinks);

    EObject eo = eObjectAtOffsetHelper.resolveElementAt(resource, offset);
    if (eo instanceof ControllerHandledValueProperty) {
      INode n = NodeModelUtils.getNode(eo);

      if (n != null) {
        INode currentNode = NodeModelUtils.findLeafNodeAtOffset(n, offset);
        List<INode> l =
            NodeModelUtils.findNodesForFeature(
                eo, FXGraphPackage.Literals.CONTROLLER_HANDLED_VALUE_PROPERTY__METHODNAME);
        if (l.contains(currentNode)) {
          Region region = new Region(currentNode.getOffset(), currentNode.getLength());

          Model m = (Model) eo.eResource().getContents().get(0);

          if (m != null) {
            ComponentDefinition def = m.getComponentDef();
            if (def != null) {
              if (def.getController() != null && def.getController().getType() != null) {
                IType t = getJDTType(def.getController().getType());
                if (t != null) {
                  IFXCtrlClass fxClass =
                      FXPlugin.getClassmodel().findCtrlClass(t.getJavaProject(), t);
                  if (fxClass != null) {
                    IFXCtrlEventMethod fxp =
                        fxClass.getAllEventMethods().get(currentNode.getText());
                    if (fxp != null) {
                      HyperlinkImpl h = new HyperlinkImpl(region, fxp.getJavaElement());
                      if (links == null || links.length == 0) {
                        return new IHyperlink[] {h};
                      } else {
                        IHyperlink[] rv = new IHyperlink[links.length + 1];
                        System.arraycopy(links, 0, rv, 0, rv.length);
                        rv[rv.length - 1] = h;
                        return rv;
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }

    return links;
  }
コード例 #2
0
 @Override
 public QualifiedName getFullyQualifiedName(EObject obj) {
   if (obj instanceof ComponentDefinition) {
     if (obj.eContainer() instanceof Model) {
       ComponentDefinition compDef = (ComponentDefinition) obj;
       Model model = (Model) obj.eContainer();
       PackageDeclaration packageDec = model.getPackage();
       if (packageDec != null) {
         return qualifiedNameConverter.toQualifiedName(
             packageDec.getName() + "." + compDef.getName());
       } else {
         return qualifiedNameConverter.toQualifiedName(compDef.getName());
       }
     }
   }
   // TODO Auto-generated method stub
   return super.getFullyQualifiedName(obj);
 }