Search in sources :

Example 1 with LifecycleEnvironmentDialog

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);
    }
}
Also used : ProjectConfig(org.apache.hop.projects.project.ProjectConfig) Project(org.apache.hop.projects.project.Project) LifecycleEnvironment(org.apache.hop.projects.environment.LifecycleEnvironment) ProjectsConfig(org.apache.hop.projects.config.ProjectsConfig) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) LifecycleEnvironmentDialog(org.apache.hop.projects.environment.LifecycleEnvironmentDialog) HopException(org.apache.hop.core.exception.HopException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) HopGui(org.apache.hop.ui.hopgui.HopGui) GuiToolbarElement(org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement)

Example 2 with LifecycleEnvironmentDialog

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);
    }
}
Also used : LifecycleEnvironment(org.apache.hop.projects.environment.LifecycleEnvironment) ProjectsConfig(org.apache.hop.projects.config.ProjectsConfig) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) Combo(org.eclipse.swt.widgets.Combo) LifecycleEnvironmentDialog(org.apache.hop.projects.environment.LifecycleEnvironmentDialog) HopException(org.apache.hop.core.exception.HopException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) HopGui(org.apache.hop.ui.hopgui.HopGui) GuiToolbarElement(org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement)

Aggregations

IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 HopException (org.apache.hop.core.exception.HopException)2 GuiToolbarElement (org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement)2 ProjectsConfig (org.apache.hop.projects.config.ProjectsConfig)2 LifecycleEnvironment (org.apache.hop.projects.environment.LifecycleEnvironment)2 LifecycleEnvironmentDialog (org.apache.hop.projects.environment.LifecycleEnvironmentDialog)2 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)2 HopGui (org.apache.hop.ui.hopgui.HopGui)2 Project (org.apache.hop.projects.project.Project)1 ProjectConfig (org.apache.hop.projects.project.ProjectConfig)1 Combo (org.eclipse.swt.widgets.Combo)1