Metadata Perspective: sort by metadata type name (+code format)
package org.apache.hop.ui.hopgui.perspective.metadata;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
import org.apache.commons.lang.StringUtils;
import org.apache.hop.core.Const;
import org.apache.hop.core.Props;
@@ -80,12 +75,16 @@ import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
@HopPerspectivePlugin(
id = "200-HopMetadataPerspective",
name = "Metadata",
description = "The Hop Metatada Perspective",
- image = "ui/images/metadata.svg"
-)
+ image = "ui/images/metadata.svg")
@GuiPlugin(description = "This perspective allows you to see and edit all available metadata")
public class MetadataPerspective implements IHopPerspective {
@@ -190,18 +189,17 @@ public class MetadataPerspective implements IHopPerspective {
// refresh the metadata when it changes.
//
- hopGui.getEventsHandler().addEventListener(
- getClass().getName(),
- e->refresh(),
- HopGuiEvents.MetadataChanged.name()
- );
-
+ hopGui
+ .getEventsHandler()
+ .addEventListener(
+ getClass().getName(), e -> refresh(), HopGuiEvents.MetadataChanged.name());
}
protected MetadataManager<IHopMetadata> getMetadataManager(String objectKey) throws HopException {
IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();
Class<IHopMetadata> metadataClass = metadataProvider.getMetadataClassForKey(objectKey);
- return new MetadataManager<>(HopGui.getInstance().getVariables(), metadataProvider, metadataClass);
+ return new MetadataManager<>(
+ HopGui.getInstance().getVariables(), metadataProvider, metadataClass);
}
protected void createTree(Composite parent) {
@@ -509,12 +507,10 @@ public class MetadataPerspective implements IHopPerspective {
String objectKey;
if (treeItem.getParentItem() == null) {
objectKey = (String) treeItem.getData();
- }
- else {
+ } else {
objectKey = (String) treeItem.getParentItem().getData();
}
-
try {
IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();
Class<IHopMetadata> metadataClass = metadataProvider.getMetadataClassForKey(objectKey);
@@ -708,6 +704,15 @@ public class MetadataPerspective implements IHopPerspective {
//
IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();
List<Class<IHopMetadata>> metadataClasses = metadataProvider.getMetadataClasses();
+ // Sort by name
+ Collections.sort(
+ metadataClasses,
+ (cl1, cl2) -> {
+ HopMetadata a1 = HopMetadataUtil.getHopMetadataAnnotation(cl1);
+ HopMetadata a2 = HopMetadataUtil.getHopMetadataAnnotation(cl2);
+ return a1.name().compareTo(a2.name());
+ });
+
for (Class<IHopMetadata> metadataClass : metadataClasses) {
HopMetadata annotation = HopMetadataUtil.getHopMetadataAnnotation(metadataClass);
Image image =
