-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
200 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/diff/DeltaItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.evolveum.midpoint.studio.ui.diff; | ||
|
||
import com.evolveum.midpoint.prism.ModificationType; | ||
import com.evolveum.midpoint.prism.PrismValue; | ||
|
||
public record DeltaItem(ModificationType modificationType, PrismValue value) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/diff/DiffStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.evolveum.midpoint.studio.ui.diff; | ||
|
||
import com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy; | ||
import com.evolveum.midpoint.prism.equivalence.ParameterizedEquivalenceStrategy; | ||
|
||
public enum DiffStrategy { | ||
|
||
LITERAL("Literal", ParameterizedEquivalenceStrategy.LITERAL), | ||
|
||
DATA("Data", ParameterizedEquivalenceStrategy.DATA), | ||
|
||
IGNORE_METADATA("Ignore Metadata", ParameterizedEquivalenceStrategy.IGNORE_METADATA), | ||
|
||
DEFAULT("Default Compare", ParameterizedEquivalenceStrategy.FOR_DELTA_ADD_APPLICATION), | ||
|
||
REAL_VALUE("Real Value", ParameterizedEquivalenceStrategy.REAL_VALUE), | ||
|
||
NATURAL_KEYS("Natural Keys", EquivalenceStrategy.REAL_VALUE_CONSIDER_DIFFERENT_IDS_NATURAL_KEYS); | ||
|
||
private final String label; | ||
|
||
private final ParameterizedEquivalenceStrategy strategy; | ||
|
||
DiffStrategy(String label, ParameterizedEquivalenceStrategy strategy) { | ||
this.label = label; | ||
this.strategy = strategy; | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public ParameterizedEquivalenceStrategy getStrategy() { | ||
return strategy; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...ea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/diff/DiffStrategyComboAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.evolveum.midpoint.studio.ui.diff; | ||
|
||
import com.evolveum.midpoint.studio.ui.CustomComboBoxAction; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class DiffStrategyComboAction extends CustomComboBoxAction<DiffStrategy> { | ||
|
||
public DiffStrategyComboAction(DiffStrategy defaultStrategy) { | ||
super(defaultStrategy); | ||
} | ||
|
||
@Override | ||
public List<DiffStrategy> getItems() { | ||
return Arrays.asList(DiffStrategy.values()); | ||
} | ||
|
||
@Override | ||
protected String createItemLabel(DiffStrategy item) { | ||
return item != null ? item.getLabel() : ""; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/diff/ObjectDeltaTree.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,63 @@ | ||
package com.evolveum.midpoint.studio.ui.diff; | ||
|
||
import com.evolveum.midpoint.prism.delta.ItemDelta; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; | ||
import com.intellij.ui.JBColor; | ||
import com.intellij.ui.render.LabelBasedRenderer; | ||
import com.intellij.ui.treeStructure.Tree; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import javax.swing.*; | ||
import javax.swing.tree.DefaultMutableTreeNode; | ||
import java.awt.*; | ||
|
||
public class ObjectDeltaTree<O extends ObjectType> extends Tree { | ||
|
||
public ObjectDeltaTree(@NotNull ObjectDeltaTreeModel<O> model) { | ||
super(model); // todo implement | ||
|
||
setup(); | ||
} | ||
|
||
private void setup() { | ||
setCellRenderer(new LabelBasedRenderer.Tree() { | ||
|
||
@Override | ||
public @NotNull Component getTreeCellRendererComponent(@NotNull JTree tree, @Nullable Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean focused) { | ||
Component c = super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, focused); | ||
|
||
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; | ||
if (!(node.getUserObject() instanceof DeltaItem di)) { | ||
return c; | ||
} | ||
|
||
switch (di.modificationType()) { | ||
case ADD: | ||
c.setForeground(JBColor.GREEN); | ||
break; | ||
case DELETE: | ||
c.setForeground(JBColor.RED); | ||
break; | ||
case REPLACE: | ||
c.setForeground(JBColor.BLUE); | ||
break; | ||
} | ||
|
||
return c; | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { | ||
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; | ||
if (node.getUserObject() instanceof DeltaItem di) { | ||
value = di.value(); | ||
} else if (node.getUserObject() instanceof ItemDelta<?,?> id) { | ||
value = id.getPath().toString(); | ||
} | ||
|
||
return super.convertValueToText(value, selected, expanded, leaf, row, hasFocus); | ||
} | ||
} |
Oops, something went wrong.