Search in sources :

Example 1 with HopGui

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);
}
Also used : MetadataManager(org.apache.hop.ui.core.metadata.MetadataManager) DataSet(org.apache.hop.testing.DataSet) HopGui(org.apache.hop.ui.hopgui.HopGui)

Example 2 with HopGui

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();
}
Also used : IVariables(org.apache.hop.core.variables.IVariables) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) HopException(org.apache.hop.core.exception.HopException) HopTransformException(org.apache.hop.core.exception.HopTransformException) HopValueException(org.apache.hop.core.exception.HopValueException) HopPluginException(org.apache.hop.core.exception.HopPluginException) HopGui(org.apache.hop.ui.hopgui.HopGui) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) GuiContextAction(org.apache.hop.core.action.GuiContextAction)

Example 3 with HopGui

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);
    }
}
Also used : HopException(org.apache.hop.core.exception.HopException) IHopMetadataProvider(org.apache.hop.metadata.api.IHopMetadataProvider) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) Combo(org.eclipse.swt.widgets.Combo) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) HopException(org.apache.hop.core.exception.HopException) HopTransformException(org.apache.hop.core.exception.HopTransformException) HopValueException(org.apache.hop.core.exception.HopValueException) HopPluginException(org.apache.hop.core.exception.HopPluginException) HopGui(org.apache.hop.ui.hopgui.HopGui) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) GuiToolbarElement(org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement)

Example 4 with HopGui

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);
    }
}
Also used : PipelineMetaModifier(org.apache.hop.testing.xp.PipelineMetaModifier) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) HopException(org.apache.hop.core.exception.HopException) HopTransformException(org.apache.hop.core.exception.HopTransformException) HopValueException(org.apache.hop.core.exception.HopValueException) HopPluginException(org.apache.hop.core.exception.HopPluginException) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) IVariables(org.apache.hop.core.variables.IVariables) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) IHopMetadataProvider(org.apache.hop.metadata.api.IHopMetadataProvider) HopGuiPipelineGraph(org.apache.hop.ui.hopgui.file.pipeline.HopGuiPipelineGraph) EnterSelectionDialog(org.apache.hop.ui.core.dialog.EnterSelectionDialog) HopGui(org.apache.hop.ui.hopgui.HopGui) GuiContextAction(org.apache.hop.core.action.GuiContextAction)

Example 5 with HopGui

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);
    }
}
Also used : ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) Combo(org.eclipse.swt.widgets.Combo) WriteToDataSetExtensionPoint(org.apache.hop.testing.xp.WriteToDataSetExtensionPoint) HopException(org.apache.hop.core.exception.HopException) HopTransformException(org.apache.hop.core.exception.HopTransformException) HopValueException(org.apache.hop.core.exception.HopValueException) HopPluginException(org.apache.hop.core.exception.HopPluginException) HopGui(org.apache.hop.ui.hopgui.HopGui) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) MessageBox(org.eclipse.swt.widgets.MessageBox) GuiToolbarElement(org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement)

Aggregations

HopGui (org.apache.hop.ui.hopgui.HopGui)62 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)42 HopException (org.apache.hop.core.exception.HopException)38 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)20 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 IHopMetadataProvider (org.apache.hop.metadata.api.IHopMetadataProvider)17 IVariables (org.apache.hop.core.variables.IVariables)15 HopTransformException (org.apache.hop.core.exception.HopTransformException)14 HopPluginException (org.apache.hop.core.exception.HopPluginException)13 HopValueException (org.apache.hop.core.exception.HopValueException)13 GuiToolbarElement (org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement)13 ArrayList (java.util.ArrayList)12 GuiContextAction (org.apache.hop.core.action.GuiContextAction)12 ProjectsConfig (org.apache.hop.projects.config.ProjectsConfig)12 TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)11 MessageBox (org.eclipse.swt.widgets.MessageBox)11 ValueMetaString (org.apache.hop.core.row.value.ValueMetaString)10 Project (org.apache.hop.projects.project.Project)10 ProjectConfig (org.apache.hop.projects.project.ProjectConfig)10 IOException (java.io.IOException)9