use of org.apache.hop.ui.hopgui.HopGui in project hop by apache.
the class LocationMouseDoubleClickExtensionPoint method openDataSet.
private void openDataSet(String dataSetName) {
HopGui hopGui = HopGui.getInstance();
MetadataManager<DataSet> manager = new MetadataManager<>(hopGui.getVariables(), hopGui.getMetadataProvider(), DataSet.class);
manager.editMetadata(dataSetName);
}
use of org.apache.hop.ui.hopgui.HopGui in project hop by apache.
the class TestingGuiPlugin method clearGoldenDataSet.
/**
* We set an golden data set on the selected unit test
*/
@GuiContextAction(id = ACTION_ID_PIPELINE_GRAPH_TRANSFORM_CLEAR_GOLDEN_DATA_SET, parentId = HopGuiPipelineTransformContext.CONTEXT_ID, type = GuiActionType.Delete, name = "i18n::TestingGuiPlugin.ContextAction.ClearGoldenDataset.Name", tooltip = "i18n::TestingGuiPlugin.ContextAction.ClearGoldenDataset.Tooltip", image = "clear-golden-dataset.svg", category = "i18n::TestingGuiPlugin.Category", categoryOrder = "8")
public void clearGoldenDataSet(HopGuiPipelineTransformContext context) {
HopGui hopGui = HopGui.getInstance();
PipelineMeta pipelineMeta = context.getPipelineMeta();
TransformMeta transformMeta = context.getTransformMeta();
IVariables variables = context.getPipelineGraph().getVariables();
if (checkTestPresent(hopGui, pipelineMeta)) {
return;
}
try {
PipelineUnitTest currentUnitTest = getCurrentUnitTest(pipelineMeta);
PipelineUnitTestSetLocation goldenLocation = currentUnitTest.findGoldenLocation(transformMeta.getName());
if (goldenLocation != null) {
currentUnitTest.getGoldenDataSets().remove(goldenLocation);
}
saveUnitTest(variables, hopGui.getMetadataProvider(), currentUnitTest, pipelineMeta);
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.ClearGoldenDataset.Error.Header"), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.ClearGoldenDataset.Error.Message"), e);
}
pipelineMeta.setChanged();
context.getPipelineGraph().updateGui();
}
use of org.apache.hop.ui.hopgui.HopGui in project hop by apache.
the class TestingGuiPlugin method selectUnitTest.
@GuiToolbarElement(root = HopGuiPipelineGraph.GUI_PLUGIN_TOOLBAR_PARENT_ID, id = ID_TOOLBAR_UNIT_TESTS_COMBO, type = GuiToolbarElementType.COMBO, comboValuesMethod = "getUnitTestsList", extraWidth = 200, toolTip = "i18n::TestingGuiPlugin.ToolbarElement.GetUnitTestList.Tooltip")
public void selectUnitTest() {
HopGui hopGui = HopGui.getInstance();
try {
PipelineMeta pipelineMeta = getActivePipelineMeta();
if (pipelineMeta == null) {
return;
}
IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();
Combo combo = getUnitTestsCombo();
if (combo == null) {
return;
}
IHopMetadataSerializer<PipelineUnitTest> testSerializer = metadataProvider.getSerializer(PipelineUnitTest.class);
String testName = combo.getText();
if (testName != null) {
PipelineUnitTest unitTest = testSerializer.load(testName);
if (unitTest == null) {
throw new HopException(BaseMessages.getString(PKG, "TestingGuiPlugin.ToolbarElement.GetUnitTestList.Exception", testName));
}
selectUnitTest(pipelineMeta, unitTest);
// Update the pipeline graph
//
hopGui.getActiveFileTypeHandler().updateGui();
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "TestingGuiPlugin.ToolbarElement.GetUnitTestList.Error.Header"), BaseMessages.getString(PKG, "TestingGuiPlugin.ToolbarElement.GetUnitTestList.Error.Message"), e);
}
}
use of org.apache.hop.ui.hopgui.HopGui in project hop by apache.
the class TestingGuiPlugin method setGoldenDataSet.
/**
* We set an golden data set on the selected unit test
*/
@GuiContextAction(id = ACTION_ID_PIPELINE_GRAPH_TRANSFORM_DEFINE_GOLDEN_DATA_SET, parentId = HopGuiPipelineTransformContext.CONTEXT_ID, type = GuiActionType.Modify, name = "i18n::TestingGuiPlugin.ContextAction.SetGoldenDataset.Name", tooltip = "i18n::TestingGuiPlugin.ContextAction.SetGoldenDataset.Tooltip", image = "set-golden-dataset.svg", category = "i18n::TestingGuiPlugin.Category", categoryOrder = "8")
public void setGoldenDataSet(HopGuiPipelineTransformContext context) {
PipelineMeta sourcePipelineMeta = context.getPipelineMeta();
TransformMeta transformMeta = context.getTransformMeta();
HopGuiPipelineGraph pipelineGraph = context.getPipelineGraph();
IVariables variables = pipelineGraph.getVariables();
HopGui hopGui = HopGui.getInstance();
IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();
if (checkTestPresent(hopGui, sourcePipelineMeta)) {
return;
}
PipelineUnitTest unitTest = getCurrentUnitTest(sourcePipelineMeta);
try {
// Create a copy and modify the pipeline
// This way we have
PipelineMetaModifier modifier = new PipelineMetaModifier(variables, sourcePipelineMeta, unitTest);
PipelineMeta pipelineMeta = modifier.getTestPipeline(LogChannel.UI, variables, metadataProvider);
IHopMetadataSerializer<DataSet> setSerializer = metadataProvider.getSerializer(DataSet.class);
List<String> setNames = setSerializer.listObjectNames();
Collections.sort(setNames);
EnterSelectionDialog esd = new EnterSelectionDialog(hopGui.getShell(), setNames.toArray(new String[setNames.size()]), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.SetGoldenDataset.Header"), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.SetGoldenDataset.Message"));
String setName = esd.open();
if (setName != null) {
DataSet dataSet = setSerializer.load(setName);
boolean changed = setGoldenDataSetOnTransform(variables, metadataProvider, pipelineMeta, transformMeta, unitTest, dataSet);
if (changed) {
pipelineGraph.updateGui();
}
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.SetGoldenDataset.Error.Header"), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.SetGoldenDataset.Error.Message"), e);
}
}
use of org.apache.hop.ui.hopgui.HopGui in project hop by apache.
the class TestingGuiPlugin method deleteUnitTest.
@GuiToolbarElement(root = HopGuiPipelineGraph.GUI_PLUGIN_TOOLBAR_PARENT_ID, id = ID_TOOLBAR_ITEM_UNIT_TESTS_DELETE, toolTip = "i18n::TestingGuiPlugin.ToolbarElement.UnitTest.Delete.Tooltip", image = "Test_tube_icon_delete.svg", separator = true)
public void deleteUnitTest() {
HopGui hopGui = HopGui.getInstance();
PipelineMeta pipelineMeta = getActivePipelineMeta();
if (pipelineMeta == null) {
return;
}
Combo combo = getUnitTestsCombo();
if (combo == null) {
return;
}
if (StringUtils.isEmpty(combo.getText())) {
return;
}
//
try {
IHopMetadataSerializer<PipelineUnitTest> testSerializer = hopGui.getMetadataProvider().getSerializer(PipelineUnitTest.class);
PipelineUnitTest pipelineUnitTest = testSerializer.load(combo.getText());
if (pipelineUnitTest == null) {
// doesn't exist
return;
}
MessageBox box = new MessageBox(hopGui.getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
box.setMessage(BaseMessages.getString(PKG, "TestingGuiPlugin.ToolbarElement.Delete.Confirmation.Message", pipelineUnitTest.getName()));
box.setText(BaseMessages.getString(PKG, "TestingGuiPlugin.ToolbarElement.Delete.Confirmation.Header"));
int answer = box.open();
if ((answer & SWT.YES) == 0) {
return;
}
// First detach it.
//
detachUnitTest();
// Then delete it.
//
testSerializer.delete(pipelineUnitTest.getName());
refreshUnitTestsList();
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "TestingGuiPlugin.ToolbarElement.Delete.Error.Header"), BaseMessages.getString(PKG, "TestingGuiPlugin.ToolbarElement.Delete.Error.Message"), e);
}
}
Aggregations