Search in sources :

Example 1 with HopDescribedVariablesDialog

use of org.apache.hop.ui.core.dialog.HopDescribedVariablesDialog in project hop by apache.

the class HopGui method menuToolsEditConfigVariables.

@GuiMenuElement(root = ID_MAIN_MENU, id = ID_MAIN_MENU_TOOLS_SYSPROPS, label = "i18n::HopGui.Menu.Tools.EditConfigVariables", parentId = ID_MAIN_MENU_TOOLS_PARENT_ID)
public void menuToolsEditConfigVariables() {
    List<DescribedVariable> describedVariables = HopConfig.getInstance().getDescribedVariables();
    String message = "Editing file: " + HopConfig.getInstance().getConfigFilename();
    HopDescribedVariablesDialog dialog = new HopDescribedVariablesDialog(shell, message, describedVariables, null);
    if (dialog.open() != null) {
        try {
            HopConfig.getInstance().setDescribedVariables(describedVariables);
            HopConfig.getInstance().saveToFile();
        } catch (Exception e) {
            new ErrorDialog(getShell(), "Error", "Error saving config variables to configuration file '" + HopConfig.getInstance().getConfigFilename() + "'", e);
        }
    }
}
Also used : DescribedVariable(org.apache.hop.core.config.DescribedVariable) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) HopDescribedVariablesDialog(org.apache.hop.ui.core.dialog.HopDescribedVariablesDialog) HopException(org.apache.hop.core.exception.HopException) GuiMenuElement(org.apache.hop.core.gui.plugin.menu.GuiMenuElement)

Example 2 with HopDescribedVariablesDialog

use of org.apache.hop.ui.core.dialog.HopDescribedVariablesDialog in project hop by apache.

the class HopGui method editConfigFile.

public static boolean editConfigFile(Shell shell, String configFilename, DescribedVariablesConfigFile variablesConfigFile, String selectedVariable) throws HopException {
    String message = "Editing configuration file: " + configFilename;
    HopDescribedVariablesDialog variablesDialog = new HopDescribedVariablesDialog(shell, message, variablesConfigFile.getDescribedVariables(), selectedVariable);
    List<DescribedVariable> vars = variablesDialog.open();
    if (vars != null) {
        variablesConfigFile.setDescribedVariables(vars);
        variablesConfigFile.saveToFile();
        return true;
    }
    return false;
}
Also used : DescribedVariable(org.apache.hop.core.config.DescribedVariable) HopDescribedVariablesDialog(org.apache.hop.ui.core.dialog.HopDescribedVariablesDialog)

Aggregations

DescribedVariable (org.apache.hop.core.config.DescribedVariable)2 HopDescribedVariablesDialog (org.apache.hop.ui.core.dialog.HopDescribedVariablesDialog)2 HopException (org.apache.hop.core.exception.HopException)1 GuiMenuElement (org.apache.hop.core.gui.plugin.menu.GuiMenuElement)1 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)1