use of org.apache.hop.projects.environment.LifecycleEnvironmentDialog in project hop by apache.
the class ProjectsGuiPlugin method addNewEnvironment.
@GuiToolbarElement(root = HopGui.ID_MAIN_TOOLBAR, id = ID_TOOLBAR_ENVIRONMENT_ADD, toolTip = "i18n::HopGui.Toolbar.Environment.Add.Tooltip", image = "environment-add.svg")
public void addNewEnvironment() {
HopGui hopGui = HopGui.getInstance();
try {
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
// The default is the active project
String projectName = getProjectsCombo().getText();
LifecycleEnvironment environment = new LifecycleEnvironment(null, "", projectName, new ArrayList<>());
LifecycleEnvironmentDialog dialog = new LifecycleEnvironmentDialog(hopGui.getShell(), environment, hopGui.getVariables());
String environmentName = dialog.open();
if (environmentName != null) {
config.addEnvironment(environment);
ProjectsConfigSingleton.saveConfig();
refreshEnvironmentsList();
selectEnvironmentInList(environmentName);
ProjectConfig projectConfig = config.findProjectConfig(projectName);
if (projectConfig != null) {
Project project = projectConfig.loadProject(hopGui.getVariables());
enableHopGuiProject(projectName, project, environment);
}
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "ProjectGuiPlugin.AddEnvironment.Error.Dialog.Header"), BaseMessages.getString(PKG, "ProjectGuiPlugin.AddEnvironment.Error.Dialog.Message"), e);
}
}
use of org.apache.hop.projects.environment.LifecycleEnvironmentDialog in project hop by apache.
the class ProjectsGuiPlugin method editEnvironment.
// ////////////////////////////////////////////////////////////////////////////////
// Environment toolbar items...
//
// ////////////////////////////////////////////////////////////////////////////////
@GuiToolbarElement(root = HopGui.ID_MAIN_TOOLBAR, id = ID_TOOLBAR_ENVIRONMENT_LABEL, type = GuiToolbarElementType.LABEL, label = "i18n::HopGui.Toolbar.Environment.Label", toolTip = "i18n::HopGui.Toolbar.Environment.Tooltip", separator = true)
public void editEnvironment() {
HopGui hopGui = HopGui.getInstance();
Combo combo = getEnvironmentsCombo();
if (combo == null) {
return;
}
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
String environmentName = combo.getText();
if (StringUtils.isEmpty(environmentName)) {
return;
}
LifecycleEnvironment environment = config.findEnvironment(environmentName);
if (environment == null) {
return;
}
try {
LifecycleEnvironmentDialog dialog = new LifecycleEnvironmentDialog(hopGui.getShell(), environment, hopGui.getVariables());
if (dialog.open() != null) {
config.addEnvironment(environment);
ProjectsConfigSingleton.saveConfig();
refreshEnvironmentsList();
selectEnvironmentInList(environmentName);
}
//
if (dialog.isNeedingEnvironmentRefresh() && askAboutProjectRefresh(hopGui)) {
// Refresh the loaded environment
//
selectEnvironment();
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "ProjectGuiPlugin.EditEnvironment.Error.Dialog.Header"), BaseMessages.getString(PKG, "ProjectGuiPlugin.EditEnvironment.Error.Dialog.Message", environmentName), e);
}
}
Aggregations