Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/merge
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Mar 19, 2024
2 parents 8bf4f21 + 7dd7b14 commit 2819362
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.evolveum.midpoint.studio.impl.lang.annotation;

import com.evolveum.midpoint.schema.SchemaConstantsGenerated;
import com.evolveum.midpoint.prism.PrismConstants;
import com.evolveum.midpoint.studio.util.PsiUtils;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.lang.annotation.AnnotationHolder;
Expand All @@ -9,7 +9,6 @@
import com.intellij.psi.PsiElement;
import com.intellij.psi.xml.XmlElement;
import com.intellij.psi.xml.XmlTag;
import com.intellij.psi.xml.XmlTagValue;
import com.intellij.xml.util.XmlTagUtil;
import org.jetbrains.annotations.NotNull;

Expand All @@ -30,18 +29,11 @@ public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder hold
return;
}

XmlTag annotation = getFirstSubTag(xsd, "annotation", SchemaConstantsGenerated.NS_XSD);
if (annotation == null) {
return;
}

XmlTag appinfo = getFirstSubTag(annotation, "appinfo", SchemaConstantsGenerated.NS_XSD);
if (appinfo == null) {
return;
}
XmlTag deprecatedTag = PsiUtils.getAppinfoElement(xsd, PrismConstants.A_DEPRECATED);
XmlTag deprecatedSinceTag = PsiUtils.getAppinfoElement(xsd, PrismConstants.A_DEPRECATED_SINCE);

String deprecated = getSubTagValue(appinfo, "deprecated", SchemaConstantsGenerated.NS_ANNOTATION);
String deprecatedSince = getSubTagValue(appinfo, "deprecatedSince", SchemaConstantsGenerated.NS_ANNOTATION);
String deprecated = deprecatedTag != null ? deprecatedTag.getValue().getText() : null;
String deprecatedSince = deprecatedSinceTag != null ? deprecatedSinceTag.getValue().getText() : null;
if (deprecatedSince == null) {
deprecatedSince = "unknown";
}
Expand All @@ -68,25 +60,4 @@ private void createNewAnnotation(XmlElement element, AnnotationHolder holder, St
.highlightType(ProblemHighlightType.LIKE_DEPRECATED)
.create();
}

private XmlTag getFirstSubTag(XmlTag tag, String localName, String namespace) {
XmlTag[] tags = tag.findSubTags(localName, namespace);
if (tags == null || tags.length == 0) {
return null;
}

return tags[0];
}


private String getSubTagValue(XmlTag tag, String localName, String namespace) {
XmlTag[] tags = tag.findSubTags(localName, namespace);
if (tags == null || tags.length == 0) {
return null;
}

XmlTagValue value = tags[0].getValue();
return value != null ? value.getTrimmedText() : null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import java.util.Objects;

public class ShadowRefAnnotation implements Annotator, MidPointAnnotator {
public class ShadowRefAnnotator implements Annotator, MidPointAnnotator {

private static final String MESSAGE =
"shadowRef element could represent possible problem when moving this midPoint " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.evolveum.midpoint.studio.util.Pair;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.intellij.ide.util.treeView.NodeRenderer;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.ui.TreeTableSpeedSearch;
import com.intellij.ui.treeStructure.treetable.TreeTable;
Expand Down Expand Up @@ -78,16 +79,27 @@ public void actionPerformed(ActionEvent e) {
}
});

JPopupMenu popup = new JPopupMenu();
JMenuItem item = new JMenuItem("Copy oids");
item.addActionListener(e -> copySelectedObjectOids());
popup.add(item);
setupPopupMenu();
}

item = new JMenuItem("Copy names");
item.addActionListener(e -> copySelectedObjectNames());
popup.add(item);
private void setupPopupMenu() {
DefaultActionGroup group = new DefaultActionGroup();
group.add(new AnAction("Copy oids") {

setComponentPopupMenu(popup);
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
copySelectedObjectOids();
}
});
group.add(new AnAction("Copy names") {

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
copySelectedObjectNames();
}
});
ActionPopupMenu menu = ActionManager.getInstance().createActionPopupMenu("ObjectTreeTablePopupMenu", group);
setComponentPopupMenu(menu.getComponent());
}

private void setupSpeedSearch() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.evolveum.midpoint.studio.util;

import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.intellij.openapi.project.Project;
Expand Down Expand Up @@ -114,6 +115,20 @@ public static QName getTagXsdType(XmlElement tag) {
return convertTextToQName(value, reference);
}

public static XmlTag getAppinfoElement(XmlTag xsd, QName annotationName) {
XmlTag annotation = MidPointUtils.findSubTag(xsd, DOMUtil.XSD_ANNOTATION_ELEMENT);
if (annotation == null) {
return null;
}

XmlTag appinfo = MidPointUtils.findSubTag(annotation, DOMUtil.XSD_APPINFO_ELEMENT);
if (appinfo == null) {
return null;
}

return MidPointUtils.findSubTag(appinfo, annotationName);
}

public static XmlTag getXsdReference(XmlElement tag) {
PsiReference ref = tag.getReference();
if (!(ref instanceof TagNameReference tagNameReference)) {
Expand Down
2 changes: 1 addition & 1 deletion studio-idea-plugin/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
<annotator language="XML"
implementationClass="com.evolveum.midpoint.studio.impl.lang.intention.ReplaceShadowRefAnnotatorIntention"/>
<annotator language="XML"
implementationClass="com.evolveum.midpoint.studio.impl.lang.annotation.ShadowRefAnnotation"/>
implementationClass="com.evolveum.midpoint.studio.impl.lang.annotation.ShadowRefAnnotator"/>
<annotator language="XML"
implementationClass="com.evolveum.midpoint.studio.impl.lang.intention.ProtectedStringAnnotatorIntention"/>

Expand Down

0 comments on commit 2819362

Please sign in to comment.