use of org.apache.hop.reflection.probe.meta.PipelineProbeEditor in project hop by apache.
the class DataProbeGuiPlugin method addDataProbeForTransform.
@GuiContextAction(id = "pipeline-graph-transform-9000-add-probe", parentId = HopGuiPipelineTransformContext.CONTEXT_ID, type = GuiActionType.Info, name = "Add data probe", tooltip = "Streams the rows to a pipeline defined in a selected pipeline probe", image = "probe.svg", category = "Preview", categoryOrder = "3")
public void addDataProbeForTransform(HopGuiPipelineTransformContext context) {
PipelineMeta pipelineMeta = context.getPipelineMeta();
TransformMeta transformMeta = context.getTransformMeta();
HopGui hopGui = HopGui.getInstance();
try {
// Present the user with a list of pipeline probes...
//
IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();
IHopMetadataSerializer<PipelineProbe> serializer = metadataProvider.getSerializer(PipelineProbe.class);
MetadataManager<PipelineProbe> manager = new MetadataManager<>(hopGui.getVariables(), metadataProvider, PipelineProbe.class);
PipelineProbe pipelineProbe = null;
List<String> pipelineProbeNames = serializer.listObjectNames();
if (pipelineProbeNames.isEmpty()) {
MessageBox box = new MessageBox(hopGui.getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
box.setText("No probes available");
box.setMessage("There are no pipeline probe objects defined yet. Do you want to create one?");
int answer = box.open();
if ((answer & SWT.YES) != 0) {
// Create a new pipeline probe...
//
pipelineProbe = new PipelineProbe();
addLocation(hopGui.getVariables(), pipelineProbe, pipelineMeta, transformMeta);
manager.newMetadata(pipelineProbe);
return;
} else {
return;
}
} else {
EnterSelectionDialog dialog = new EnterSelectionDialog(hopGui.getShell(), pipelineProbeNames.toArray(new String[0]), "Select pipeline probe", "Select the pipeline probe to add this pipeline transform to");
String pipelineProbeName = dialog.open();
if (pipelineProbeName != null) {
pipelineProbe = serializer.load(pipelineProbeName);
}
}
if (pipelineProbe != null) {
// See if it's open in the metadata perspective...
//
MetadataPerspective perspective = (MetadataPerspective) hopGui.getPerspectiveManager().findPerspective(MetadataPerspective.class);
String key = PipelineProbe.class.getAnnotation(HopMetadata.class).key();
PipelineProbeEditor editor = (PipelineProbeEditor) perspective.findEditor(key, pipelineProbe.getName());
if (editor != null) {
// We're going to change the current metadata and flag it as changed...
//
pipelineProbe = new PipelineProbe();
editor.getWidgetsContent(pipelineProbe);
// Add the location
//
addLocation(hopGui.getVariables(), pipelineProbe, pipelineMeta, transformMeta);
// Replace and refresh the dialog
//
editor.setMetadata(pipelineProbe);
editor.setWidgetsContent();
// Set changed...
//
editor.setChanged();
// Switch to the editor...
//
perspective.activate();
perspective.setActiveEditor(editor);
return;
} else {
// Not opened in the perspective, simply add the data probe location...
//
addLocation(hopGui.getVariables(), pipelineProbe, pipelineMeta, transformMeta);
// ... and save the pipeline probe
//
serializer.save(pipelineProbe);
}
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), "Error", "Error adding pipeline probe to transform '" + transformMeta.getName() + "'", e);
}
}
Aggregations