Search in sources :

Example 21 with ProjectsConfig

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);
    }
}
Also used : ProjectConfig(org.apache.hop.projects.project.ProjectConfig) Project(org.apache.hop.projects.project.Project) ProjectDialog(org.apache.hop.projects.project.ProjectDialog) 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) 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 22 with ProjectsConfig

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);
    }
}
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) Combo(org.eclipse.swt.widgets.Combo) 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 23 with ProjectsConfig

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

Example 24 with ProjectsConfig

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()));
        }
    }
}
Also used : GuiToolbarWidgets(org.apache.hop.ui.core.gui.GuiToolbarWidgets) LifecycleEnvironment(org.apache.hop.projects.environment.LifecycleEnvironment) ProjectsConfig(org.apache.hop.projects.config.ProjectsConfig) Combo(org.eclipse.swt.widgets.Combo)

Example 25 with ProjectsConfig

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);
    }
}
Also used : ProjectsConfig(org.apache.hop.projects.config.ProjectsConfig)

Aggregations

ProjectsConfig (org.apache.hop.projects.config.ProjectsConfig)33 HopException (org.apache.hop.core.exception.HopException)22 ProjectConfig (org.apache.hop.projects.project.ProjectConfig)20 HopGui (org.apache.hop.ui.hopgui.HopGui)12 IOException (java.io.IOException)11 Project (org.apache.hop.projects.project.Project)11 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)11 InvocationTargetException (java.lang.reflect.InvocationTargetException)10 GuiToolbarElement (org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement)10 LifecycleEnvironment (org.apache.hop.projects.environment.LifecycleEnvironment)9 Combo (org.eclipse.swt.widgets.Combo)9 FileObject (org.apache.commons.vfs2.FileObject)4 MessageBox (org.eclipse.swt.widgets.MessageBox)4 HopExtensionPoint (org.apache.hop.core.extension.HopExtensionPoint)3 AuditEvent (org.apache.hop.history.AuditEvent)3 LifecycleEnvironmentDialog (org.apache.hop.projects.environment.LifecycleEnvironmentDialog)3 ProjectDialog (org.apache.hop.projects.project.ProjectDialog)3 GuiToolbarWidgets (org.apache.hop.ui.core.gui.GuiToolbarWidgets)3 OutputStream (java.io.OutputStream)2 ArrayList (java.util.ArrayList)2