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); } }
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; }