use of org.apache.hop.projects.config.ProjectsConfig 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);
}
}
use of org.apache.hop.projects.config.ProjectsConfig in project hop by apache.
the class ProjectsGuiPlugin method selectEnvironment.
@GuiToolbarElement(root = HopGui.ID_MAIN_TOOLBAR, id = ID_TOOLBAR_ENVIRONMENT_COMBO, type = GuiToolbarElementType.COMBO, comboValuesMethod = "getEnvironmentsList", extraWidth = 200, toolTip = "i18n::HopGui.Toolbar.EnvironmentsList.Tooltip")
public void selectEnvironment() {
HopGui hopGui = HopGui.getInstance();
Combo envCombo = getEnvironmentsCombo();
if (envCombo == null) {
return;
}
String environmentName = envCombo.getText();
if (StringUtils.isEmpty(environmentName)) {
return;
}
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
LifecycleEnvironment environment = config.findEnvironment(environmentName);
if (environment == null) {
return;
}
if (StringUtils.isEmpty(environment.getProjectName())) {
return;
}
ProjectConfig projectConfig = config.findProjectConfig(environment.getProjectName());
if (projectConfig == null) {
return;
}
try {
Project project = projectConfig.loadProject(hopGui.getVariables());
if (project != null) {
enableHopGuiProject(projectConfig.getProjectName(), project, environment);
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "ProjectGuiPlugin.ChangeEnvironment.Error.Dialog.Header"), BaseMessages.getString(PKG, "ProjectGuiPlugin.ChangeEnvironment.Error.Dialog.Message", environmentName), e);
}
}
use of org.apache.hop.projects.config.ProjectsConfig in project hop by apache.
the class ProjectsGuiPlugin method deleteSelectedProject.
@GuiToolbarElement(root = HopGui.ID_MAIN_TOOLBAR, id = ID_TOOLBAR_PROJECT_DELETE, toolTip = "i18n::HopGui.Toolbar.Project.Delete.Tooltip", image = "project-delete.svg", separator = true)
public void deleteSelectedProject() {
Combo combo = getProjectsCombo();
if (combo == null) {
return;
}
String projectName = combo.getText();
if (StringUtils.isEmpty(projectName)) {
return;
}
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
ProjectConfig currentProjectConfig = config.findProjectConfig(projectName);
if (currentProjectConfig == null) {
return;
}
String projectHome = currentProjectConfig.getProjectHome();
String configFilename = currentProjectConfig.getConfigFilename();
try {
List<String> refs = ProjectsUtil.getParentProjectReferences(projectName);
if (refs.isEmpty()) {
performProjectDeletion(projectName, config, projectHome, configFilename);
} else {
String prjReferences = String.join(",", refs);
MessageBox box = new MessageBox(HopGui.getInstance().getShell(), SWT.OK | SWT.ICON_INFORMATION);
box.setText(BaseMessages.getString(PKG, "ProjectGuiPlugin.DeleteProject.ProjectReferencedAsParent.Header"));
box.setMessage(BaseMessages.getString(PKG, "ProjectGuiPlugin.DeleteProject.ProjectReferencedAsParent.Message1") + Const.CR + prjReferences + Const.CR + BaseMessages.getString(PKG, "ProjectGuiPlugin.DeleteProject.ProjectReferencedAsParent.Message2"));
box.open();
}
} catch (Exception e) {
new ErrorDialog(HopGui.getInstance().getShell(), BaseMessages.getString(PKG, "ProjectGuiPlugin.DeleteProject.Dialog.Header"), BaseMessages.getString(PKG, "ProjectGuiPlugin.DeleteProject.Error.Dialog.Message", projectName), e);
}
}
use of org.apache.hop.projects.config.ProjectsConfig in project hop by apache.
the class ProjectsGuiPlugin method selectEnvironmentInList.
public static void selectEnvironmentInList(String name) {
GuiToolbarWidgets toolbarWidgets = HopGui.getInstance().getMainToolbarWidgets();
toolbarWidgets.selectComboItem(ID_TOOLBAR_ENVIRONMENT_COMBO, name);
Combo combo = getEnvironmentsCombo();
if (combo != null) {
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
LifecycleEnvironment environment = config.findEnvironment(name);
if (environment != null) {
combo.setToolTipText(BaseMessages.getString(PKG, "ProjectGuiPlugin.FindEnvironment.Tooltip", name, environment.getProjectName(), environment.getPurpose()));
}
}
}
use of org.apache.hop.projects.config.ProjectsConfig in project hop by apache.
the class ManageLifecyclesOptionPlugin method listLifecycles.
private void listLifecycles(ILogChannel log) throws HopException {
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
log.logBasic("Project lifecycles:");
List<String> names = config.listLifecycleNames();
for (String name : names) {
ProjectLifecycle lifecycle = config.findLifecycle(name);
logLifecycleDetails(log, lifecycle);
}
}
Aggregations