use of org.apache.hop.projects.environment.LifecycleEnvironment in project hop by apache.
the class ProjectsGuiPlugin method deleteSelectedEnvironment.
@GuiToolbarElement(root = HopGui.ID_MAIN_TOOLBAR, id = ID_TOOLBAR_ENVIRONMENT_DELETE, toolTip = "i18n::HopGui.Toolbar.Environment.Delete.Tooltip", image = "environment-delete.svg", separator = true)
public void deleteSelectedEnvironment() {
Combo combo = getEnvironmentsCombo();
if (combo == null) {
return;
}
String environmentName = combo.getText();
if (StringUtils.isEmpty(environmentName)) {
return;
}
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
LifecycleEnvironment environment = config.findEnvironment(environmentName);
if (environment == null) {
return;
}
MessageBox box = new MessageBox(HopGui.getInstance().getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
box.setText(BaseMessages.getString(PKG, "ProjectGuiPlugin.DeleteEnvironment.Dialog.Header"));
box.setMessage(BaseMessages.getString(PKG, "ProjectGuiPlugin.DeleteEnvironment.Dialog.Message1", environmentName) + Const.CR + BaseMessages.getString(PKG, "ProjectGuiPlugin.DeleteEnvironment.Dialog.Message2", environment.getProjectName()));
int anwser = box.open();
if ((anwser & SWT.YES) != 0) {
try {
config.removeEnvironment(environmentName);
ProjectsConfigSingleton.saveConfig();
refreshEnvironmentsList();
selectEnvironmentInList(null);
} catch (Exception e) {
new ErrorDialog(HopGui.getInstance().getShell(), BaseMessages.getString(PKG, "ProjectGuiPlugin.DeleteEnvironment.Error.Dialog.Header"), BaseMessages.getString(PKG, "ProjectGuiPlugin.DeleteEnvironment.Error.Dialog.Message", environmentName), e);
}
}
}
use of org.apache.hop.projects.environment.LifecycleEnvironment 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.LifecycleEnvironment in project hop by apache.
the class ProjectsGuiPlugin method selectProject.
@GuiToolbarElement(root = HopGui.ID_MAIN_TOOLBAR, id = ID_TOOLBAR_PROJECT_COMBO, type = GuiToolbarElementType.COMBO, comboValuesMethod = "getProjectsList", extraWidth = 200, toolTip = "i18n::HopGui.Toolbar.ProjectsList.Tooltip")
public void selectProject() {
HopGui hopGui = HopGui.getInstance();
Combo combo = getProjectsCombo();
if (combo == null) {
return;
}
String projectName = combo.getText();
if (StringUtils.isEmpty(projectName)) {
return;
}
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
ProjectConfig projectConfig = config.findProjectConfig(projectName);
// What is the last used environment?
//
LifecycleEnvironment environment = null;
//
try {
List<AuditEvent> environmentAuditEvents = AuditManager.findEvents(ProjectsUtil.STRING_PROJECTS_AUDIT_GROUP, ProjectsUtil.STRING_ENVIRONMENT_AUDIT_TYPE, "open", 100, true);
for (AuditEvent auditEvent : environmentAuditEvents) {
String environmentName = auditEvent.getName();
if (StringUtils.isNotEmpty(environmentName)) {
environment = config.findEnvironment(environmentName);
//
if (projectName.equals(environment.getProjectName())) {
// We found what we've been looking for
break;
} else {
// The project doesn't to the last selected environment
// Since we selected the project it is the driver of the selection.
// Keep looking.
//
environment = null;
}
}
}
} catch (Exception e) {
LogChannel.UI.logError("Error reading the last used environment from the audit logs", e);
}
//
if (environment == null) {
List<LifecycleEnvironment> environments = config.findEnvironmentsOfProject(projectName);
if (!environments.isEmpty()) {
environment = environments.get(0);
}
}
try {
Project project = projectConfig.loadProject(hopGui.getVariables());
if (project != null) {
enableHopGuiProject(projectName, project, environment);
} else {
hopGui.getLog().logError("Unable to find project '" + projectName + "'");
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "ProjectGuiPlugin.ChangeProject.Error.Dialog.Header"), BaseMessages.getString(PKG, "ProjectGuiPlugin.ChangeProject.Error.Dialog.Message", projectName), e);
}
}
use of org.apache.hop.projects.environment.LifecycleEnvironment 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);
}
}
use of org.apache.hop.projects.environment.LifecycleEnvironment in project hop by apache.
the class ProjectsGuiPlugin method editProject.
@GuiToolbarElement(root = HopGui.ID_MAIN_TOOLBAR, id = ID_TOOLBAR_PROJECT_LABEL, type = GuiToolbarElementType.LABEL, label = "i18n::HopGui.Toolbar.Project.Label", toolTip = "i18n::HopGui.Toolbar.Project.Tooltip", separator = true)
public void editProject() {
HopGui hopGui = HopGui.getInstance();
Combo combo = getProjectsCombo();
if (combo == null) {
return;
}
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
String projectName = combo.getText();
ProjectConfig projectConfig = config.findProjectConfig(projectName);
if (projectConfig == null) {
return;
}
try {
Project project = projectConfig.loadProject(hopGui.getVariables());
ProjectDialog projectDialog = new ProjectDialog(hopGui.getShell(), project, projectConfig, hopGui.getVariables(), true);
if (projectDialog.open() != null) {
config.addProjectConfig(projectConfig);
if (!projectName.equals(projectConfig.getProjectName())) {
// Project got renamed
projectName = projectConfig.getProjectName();
// Refresh project reference in hop-config.json
HopConfig.getInstance().saveToFile();
}
project.saveToFile();
refreshProjectsList();
selectProjectInList(projectName);
if (projectDialog.isNeedingProjectRefresh()) {
if (askAboutProjectRefresh(hopGui)) {
// Try to stick to the same environment if we have one selected...
//
LifecycleEnvironment environment = null;
Combo environmentsCombo = getEnvironmentsCombo();
if (environmentsCombo != null) {
environment = config.findEnvironment(environmentsCombo.getText());
}
enableHopGuiProject(projectConfig.getProjectName(), project, environment);
}
}
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "ProjectGuiPlugin.EditProject.Error.Dialog.Header"), BaseMessages.getString(PKG, "ProjectGuiPlugin.EditProject.Error.Dialog.Message", projectName), e);
}
}
Aggregations