Search in sources :

Example 1 with GuiToolbarElement

use of org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement 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 2 with GuiToolbarElement

use of org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement 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)

Example 3 with GuiToolbarElement

use of org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement in project hop by apache.

the class TestingGuiPlugin method editPipelineUnitTest.

@GuiToolbarElement(root = HopGuiPipelineGraph.GUI_PLUGIN_TOOLBAR_PARENT_ID, id = ID_TOOLBAR_UNIT_TESTS_LABEL, type = GuiToolbarElementType.LABEL, label = "i18n::TestingGuiPlugin.ToolbarElement.UnitTest.Label", toolTip = "i18n::TestingGuiPlugin.ToolbarElement.UnitTest.Tooltip", separator = true)
public void editPipelineUnitTest() {
    HopGui hopGui = HopGui.getInstance();
    Combo combo = getUnitTestsCombo();
    if (combo == null) {
        return;
    }
    String unitTestName = combo.getText();
    try {
        MetadataManager<PipelineUnitTest> manager = new MetadataManager<>(hopGui.getVariables(), hopGui.getMetadataProvider(), PipelineUnitTest.class);
        if (manager.editMetadata(unitTestName)) {
            refreshUnitTestsList();
            selectUnitTestInList(unitTestName);
        }
    } catch (Exception e) {
        new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "TestingGuiPlugin.ToolbarElement.UnitTest.Error.Header"), BaseMessages.getString(PKG, "TestingGuiPlugin.ToolbarElement.UnitTest.Error.Message", unitTestName), e);
    }
}
Also used : MetadataManager(org.apache.hop.ui.core.metadata.MetadataManager) 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) GuiToolbarElement(org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement)

Example 4 with GuiToolbarElement

use of org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement in project hop by apache.

the class TestingGuiPlugin method createUnitTest.

@GuiToolbarElement(root = HopGuiPipelineGraph.GUI_PLUGIN_TOOLBAR_PARENT_ID, id = ID_TOOLBAR_ITEM_UNIT_TESTS_CREATE, toolTip = "i18n::TestingGuiPlugin.ToolbarElement.UnitTest.Create.Tooltip", image = "Test_tube_icon_create.svg", separator = true)
public void createUnitTest() {
    HopGui hopGui = HopGui.getInstance();
    PipelineMeta pipelineMeta = getActivePipelineMeta();
    if (pipelineMeta == null) {
        return;
    }
    MetadataManager<PipelineUnitTest> manager = new MetadataManager<>(hopGui.getVariables(), hopGui.getMetadataProvider(), PipelineUnitTest.class);
    PipelineUnitTest test = manager.newMetadata();
    if (test != null) {
        // Activate the test
        refreshUnitTestsList();
        selectUnitTest(pipelineMeta, test);
    }
}
Also used : MetadataManager(org.apache.hop.ui.core.metadata.MetadataManager) HopGui(org.apache.hop.ui.hopgui.HopGui) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) GuiToolbarElement(org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement)

Example 5 with GuiToolbarElement

use of org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement in project hop by apache.

the class ProjectsGuiPlugin method addNewProject.

@GuiToolbarElement(root = HopGui.ID_MAIN_TOOLBAR, id = ID_TOOLBAR_PROJECT_ADD, toolTip = "i18n::HopGui.Toolbar.Project.Add.Tooltip", image = "project-add.svg")
public void addNewProject() {
    HopGui hopGui = HopGui.getInstance();
    IVariables variables = hopGui.getVariables();
    try {
        ProjectsConfig config = ProjectsConfigSingleton.getConfig();
        String standardProjectsFolder = variables.resolve(config.getStandardProjectsFolder());
        String defaultProjectConfigFilename = variables.resolve(config.getDefaultProjectConfigFile());
        ProjectConfig projectConfig = new ProjectConfig("", standardProjectsFolder, defaultProjectConfigFilename);
        Project project = new Project();
        project.setParentProjectName(config.getStandardParentProject());
        ProjectDialog projectDialog = new ProjectDialog(hopGui.getShell(), project, projectConfig, variables, false);
        String projectName = projectDialog.open();
        if (projectName != null) {
            config.addProjectConfig(projectConfig);
            HopConfig.getInstance().saveToFile();
            // Save the project-config.json file as well in the project itself
            // 
            FileObject configFile = HopVfs.getFileObject(projectConfig.getActualProjectConfigFilename(variables));
            if (!configFile.exists()) {
                // Create the empty configuration file if it does not exists
                project.saveToFile();
            } else {
                // If projects exists load configuration
                MessageBox box = new MessageBox(hopGui.getShell(), SWT.ICON_QUESTION | SWT.OK);
                box.setText(BaseMessages.getString(PKG, "ProjectGuiPlugin.ProjectExists.Dialog.Header"));
                box.setMessage(BaseMessages.getString(PKG, "ProjectGuiPlugin.ProjectExists.Dialog.Message"));
                box.open();
                project.readFromFile();
            }
            refreshProjectsList();
            selectProjectInList(projectName);
            enableHopGuiProject(projectName, project, null);
            // Now see if these project contains any local run configurations.
            // If not we can add those automatically
            // 
            // First pipeline
            // 
            IHopMetadataSerializer<PipelineRunConfiguration> prcSerializer = hopGui.getMetadataProvider().getSerializer(PipelineRunConfiguration.class);
            List<PipelineRunConfiguration> pipelineRunConfigs = prcSerializer.loadAll();
            boolean localFound = false;
            for (PipelineRunConfiguration pipelineRunConfig : pipelineRunConfigs) {
                if (pipelineRunConfig.getEngineRunConfiguration() instanceof LocalPipelineRunConfiguration) {
                    localFound = true;
                }
            }
            if (!localFound) {
                PipelineExecutionConfigurationDialog.createLocalPipelineConfiguration(hopGui.getShell(), prcSerializer);
            }
            // Then the local workflow runconfig
            // 
            IHopMetadataSerializer<WorkflowRunConfiguration> wrcSerializer = hopGui.getMetadataProvider().getSerializer(WorkflowRunConfiguration.class);
            localFound = false;
            List<WorkflowRunConfiguration> workflowRunConfigs = wrcSerializer.loadAll();
            for (WorkflowRunConfiguration workflowRunConfig : workflowRunConfigs) {
                if (workflowRunConfig.getEngineRunConfiguration() instanceof LocalWorkflowRunConfiguration) {
                    localFound = true;
                }
            }
            if (!localFound) {
                MessageBox box = new MessageBox(HopGui.getInstance().getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
                box.setText(BaseMessages.getString(PKG, "ProjectGuiPlugin.LocalWFRunConfig.Dialog.Header"));
                box.setMessage(BaseMessages.getString(PKG, "ProjectGuiPlugin.LocalWFRunConfig.Dialog.Message"));
                int anwser = box.open();
                if ((anwser & SWT.YES) != 0) {
                    LocalWorkflowRunConfiguration localWorkflowRunConfiguration = new LocalWorkflowRunConfiguration();
                    localWorkflowRunConfiguration.setEnginePluginId("Local");
                    WorkflowRunConfiguration local = new WorkflowRunConfiguration("local", BaseMessages.getString(PKG, "ProjectGuiPlugin.LocalWFRunConfigDescription.Text"), localWorkflowRunConfiguration);
                    wrcSerializer.save(local);
                }
            }
            // Ask to put the project in a lifecycle environment
            // 
            MessageBox box = new MessageBox(HopGui.getInstance().getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
            box.setText(BaseMessages.getString(PKG, "ProjectGuiPlugin.Lifecycle.Dialog.Header"));
            box.setMessage(BaseMessages.getString(PKG, "ProjectGuiPlugin.Lifecycle.Dialog.Message1") + Const.CR + BaseMessages.getString(PKG, "ProjectGuiPlugin.Lifecycle.Dialog.Message2"));
            int anwser = box.open();
            if ((anwser & SWT.YES) != 0) {
                addNewEnvironment();
            }
        }
    } catch (Exception e) {
        new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "ProjectGuiPlugin.AddProject.Error.Dialog.Header"), BaseMessages.getString(PKG, "ProjectGuiPlugin.AddProject.Error.Dialog.Message"), e);
    }
}
Also used : ProjectDialog(org.apache.hop.projects.project.ProjectDialog) LocalPipelineRunConfiguration(org.apache.hop.pipeline.engines.local.LocalPipelineRunConfiguration) PipelineRunConfiguration(org.apache.hop.pipeline.config.PipelineRunConfiguration) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint) HopException(org.apache.hop.core.exception.HopException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) MessageBox(org.eclipse.swt.widgets.MessageBox) LocalPipelineRunConfiguration(org.apache.hop.pipeline.engines.local.LocalPipelineRunConfiguration) ProjectConfig(org.apache.hop.projects.project.ProjectConfig) LocalWorkflowRunConfiguration(org.apache.hop.workflow.engines.local.LocalWorkflowRunConfiguration) Project(org.apache.hop.projects.project.Project) LocalWorkflowRunConfiguration(org.apache.hop.workflow.engines.local.LocalWorkflowRunConfiguration) WorkflowRunConfiguration(org.apache.hop.workflow.config.WorkflowRunConfiguration) IVariables(org.apache.hop.core.variables.IVariables) ProjectsConfig(org.apache.hop.projects.config.ProjectsConfig) FileObject(org.apache.commons.vfs2.FileObject) HopGui(org.apache.hop.ui.hopgui.HopGui) GuiToolbarElement(org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement)

Aggregations

GuiToolbarElement (org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement)39 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)23 HopException (org.apache.hop.core.exception.HopException)21 HopGui (org.apache.hop.ui.hopgui.HopGui)12 Combo (org.eclipse.swt.widgets.Combo)10 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 ProjectsConfig (org.apache.hop.projects.config.ProjectsConfig)9 IOException (java.io.IOException)8 FileObject (org.apache.commons.vfs2.FileObject)7 ProjectConfig (org.apache.hop.projects.project.ProjectConfig)7 IHopMetadata (org.apache.hop.metadata.api.IHopMetadata)6 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)6 LifecycleEnvironment (org.apache.hop.projects.environment.LifecycleEnvironment)6 FileSystemException (org.apache.commons.vfs2.FileSystemException)5 HopPluginException (org.apache.hop.core.exception.HopPluginException)5 HopTransformException (org.apache.hop.core.exception.HopTransformException)5 HopValueException (org.apache.hop.core.exception.HopValueException)5 GuiKeyboardShortcut (org.apache.hop.core.gui.plugin.key.GuiKeyboardShortcut)5 GuiOsxKeyboardShortcut (org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut)5 Project (org.apache.hop.projects.project.Project)5