コード例 #1
0
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    DMDLMultiPageEditor multiEditor = (DMDLMultiPageEditor) HandlerUtil.getActiveEditor(event);
    DMDLTextEditor editor = (DMDLTextEditor) multiEditor.getActiveEditor();
    DMDLDocument document = editor.getDocument();
    ModelList models = document.getModelList();

    ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
    int offset = selection.getOffset();
    DMDLToken token = models.getTokenByOffset(offset);
    if (token != null && token instanceof WordToken) {
      WordToken word = (WordToken) token;
      switch (word.getWordType()) {
        case REF_MODEL_NAME:
        case REF_PROPERTY_NAME:
          DMDLHyperlink link = new DMDLHyperlink(editor, token);
          link.open();
          break;
        default:
          break;
      }
    }

    return null;
  }
コード例 #2
0
 private void replace(String value) {
   ModelToken model = page.getModel();
   WordToken name = model.getModelNameToken();
   if (name != null) {
     page.replaceDocument(name.getStart(), name.getLength(), value);
     return;
   }
   DescriptionToken desc = model.getDescriptionToken();
   if (desc != null) {
     page.replaceDocument(desc.getEnd(), 0, "\n" + value + "\n");
     return;
   }
   page.replaceDocument(model.getStart(), 0, value + "\n");
 }