Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Issue #31, #19
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcasters committed Aug 1, 2019
1 parent dfa09a8 commit 7af53f8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/main/java/org/kettle/env/spoon/EnvironmentHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ public static void editActiveEnvironment() {
if ( dialog.open() ) {
MetaStoreFactory<Environment> factory = EnvironmentSingleton.getEnvironmentFactory();
factory.saveElement( environment );
if (!environment.getName().equals( activeEnvironment )) {
factory.deleteElement( activeEnvironment );
}
EnvironmentUtil.enableEnvironment( environment, spoon.getMetaStore() );
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/kettle/env/util/EnvironmentUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ public static void enableEnvironment( Environment environment, DelegatingMetaSto

// Refresh the currently active graph
//
spoon.refreshGraph();
if (spoon.getActiveMeta()!=null) {
spoon.refreshGraph();
}
}
}

Expand Down
26 changes: 21 additions & 5 deletions src/main/java/org/kettle/env/xp/SpoonStartEnvironmentPrompt.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,35 @@ public class SpoonStartEnvironmentPrompt implements ExtensionPointInterface {
EnvironmentsDialog environmentsDialog = new EnvironmentsDialog( spoon.getShell(), spoon.getMetaStore() );
selectedEnvironment = environmentsDialog.open();
}

if ( StringUtils.isNotEmpty( selectedEnvironment ) ) {

Environment environment = EnvironmentSingleton.getEnvironmentFactory().loadElement( selectedEnvironment );
if (environment==null) {
// Environment no longer exists, pop up dialog
//
EnvironmentsDialog environmentsDialog = new EnvironmentsDialog( spoon.getShell(), spoon.getMetaStore() );
selectedEnvironment = environmentsDialog.open();
if (selectedEnvironment==null) {
return; // Canceled
}
environment = EnvironmentSingleton.getEnvironmentFactory().loadElement( selectedEnvironment );
}

// Save the last used configuration
//
EnvironmentConfigSingleton.getConfig().setLastUsedEnvironment( selectedEnvironment );
EnvironmentConfigSingleton.saveConfig();

Environment environment = EnvironmentSingleton.getEnvironmentFactory().loadElement( selectedEnvironment );
logChannelInterface.logBasic( "Setting environment : '" + environment.getName() + "'" );

// Set system variables for KETTLE_HOME, PENTAHO_METASTORE_FOLDER, ...
// Double check!
//
EnvironmentUtil.enableEnvironment( environment, spoon.getMetaStore() );
if (environment!=null) {
logChannelInterface.logBasic( "Setting environment : '" + environment.getName() + "'" );

// Set system variables for KETTLE_HOME, PENTAHO_METASTORE_FOLDER, ...
//
EnvironmentUtil.enableEnvironment( environment, spoon.getMetaStore() );
}
}
}
} catch ( Exception e ) {
Expand Down

0 comments on commit 7af53f8

Please sign in to comment.