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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations