Exemple #1
0
  private void processReference(String prefix, SReference ref, Consumer<SReference> consumer) {
    if (!(ref instanceof StaticReference)) return;
    SNodeId target = ref.getTargetNodeId();
    if (!(target instanceof Foreign)) return;

    String targetNodeIdStr = target.toString();

    boolean found = false;
    int idx = targetNodeIdStr.indexOf(prefix);

    while (idx >= 0) {
      if (idx == 0) {
        found = true;
        break;
      }

      char c = targetNodeIdStr.charAt(idx - 1);
      if (c == '.' || Character.isLetterOrDigit(c)) {
        idx = targetNodeIdStr.indexOf(prefix, idx + 1);
        continue;
      }

      found = true;
      break;
    }

    if (found) {
      consumer.consume(ref);
    }
  }
Exemple #2
0
  private DefaultActionGroup createActionGroup() {
    DefaultActionGroup group = new DefaultActionGroup();

    final Object[] selectedValues = myList.getSelectedValues();
    if (selectedValues.length > 0) {
      StringBuilder sb = new StringBuilder();
      for (Object o : myList.getSelectedValues()) {
        sb.append(((IMessage) o).getText());
        sb.append("\n");
      }
      group.add(new CopyToClipboardAction("Copy Text").setTextToCopy(sb.toString()));
      Object hintObj;
      if (selectedValues.length == 1
          && (hintObj = ((IMessage) selectedValues[0]).getHintObject()) != null) {
        SNodeId nodeId =
            hintObj instanceof SNodeReference ? ((SNodeReference) hintObj).getNodeId() : null;
        if (nodeId != null) {
          group.add(new CopyToClipboardAction("Copy Node Id").setTextToCopy(nodeId.toString()));
        }
      }
    }

    group.addSeparator();

    group.add(
        new AnAction("Show Help for This Message", null, null) {
          @Override
          public void update(AnActionEvent e) {
            boolean enabled = getHelpUrlForCurrentMessage() != null;
            Presentation presentation = e.getPresentation();
            presentation.setEnabled(enabled);
            presentation.setVisible(enabled);
          }

          @Override
          public void actionPerformed(AnActionEvent e) {
            showHelpForCurrentMessage();
          }
        });

    group.addSeparator();
    populateActions(myList, group);
    group.addSeparator();

    group.add(
        new AnAction("Clear", null, null) {
          @Override
          public void actionPerformed(AnActionEvent e) {
            clear();
          }
        });

    return group;
  }
Exemple #3
0
 @Override
 public SNode put(SNodeId key, SNode value) {
   if (!(key instanceof Regular)) {
     LOG.error(
         "Trying to add node with id class " + key.getClass().getName() + " to a regular model");
     return null;
   }
   return myRegularMap.put(((Regular) key).getId(), value);
 }
Exemple #4
0
 @Override
 public SNode remove(SNodeId key) {
   if (!(key instanceof Regular)) {
     LOG.error(
         "Trying to remove node with id class "
             + key.getClass().getName()
             + " from a regular model");
     return null;
   }
   return myRegularMap.remove(((Regular) key).getId());
 }