Skip to content

Commit

Permalink
#7548 - make delete button on sparkUI unavailable if default profile …
Browse files Browse the repository at this point in the history
…is selected
  • Loading branch information
Lukasz Mitusinski committed Jun 20, 2018
1 parent 670a761 commit 6b71ae9
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class SparkUIForm extends VBox {
private SparkEngine sparkEngine;
private SparkUI.OnSparkButtonAction onStartAction;
private Button connectButton;
private Button removeButton;
private Spinner spinner;
private HBox spinnerPanel;
private SparkUiDefaults sparkUiDefaults;
Expand Down Expand Up @@ -128,11 +129,13 @@ private HBox createProfileManagement() {
newButton.setDomClasses(asList("bx-button", "icon-add"));
newButton.setTooltip(NEW_PROFILE_TOOLTIP);

Button removeButton = new Button();
removeButton = new Button();
removeButton.registerOnClick((content, message) -> removeProfile());
removeButton.setDomClasses(asList("bx-button", "icon-close"));
removeButton.setTooltip(REMOVE_PROFILE_TOOLTIP);

refreshElementsAvailability();

return new HBox(Arrays.asList(profileDropdown, saveButton, newButton, removeButton));
}

Expand All @@ -142,9 +145,7 @@ private void loadProfile() {
return;
}
sparkUiDefaults.loadProfiles();
Map<String, Object> profileData =
(Map<String, Object>) sparkUiDefaults
.getProfileByName(profileName);
Map<String, Object> profileData = sparkUiDefaults.getProfileByName(profileName);
if (profileData.size() > 0) {
this.masterURL.setValue(profileData.getOrDefault(SparkUI.SPARK_MASTER, SparkUI.SPARK_MASTER_DEFAULT));
this.executorCores.setValue(profileData.getOrDefault(SparkUI.SPARK_EXECUTOR_CORES, SparkUI.SPARK_EXECUTOR_CORES_DEFAULT));
Expand All @@ -157,6 +158,7 @@ private void loadProfile() {
});
this.advancedOption.setConfiguration(advancedSettings);
}
refreshElementsAvailability();
}

private void saveProfile() {
Expand All @@ -181,6 +183,7 @@ private void createProfileOK(HashMap hashMap, Message message) {
profile.setValue(newProfileName.getValue());
saveProfile();
newProfileName.setValue("");
refreshElementsAvailability();
}

private void createProfileCancel(HashMap hashMap, Message message) {
Expand Down Expand Up @@ -321,6 +324,11 @@ public void setAllToDisabled() {
public void setAllToEnabled() {
this.profileManagement.getChildren().stream().map(x -> (ValueWidget) x).forEach(x -> x.setDisabled(false));
this.advancedOption.setEnabledToAll();
refreshElementsAvailability();
}

public void refreshElementsAvailability(){
removeButton.setDisabled(this.profile.getValue().equals(DEFAULT_PROFILE));
}

}

0 comments on commit 6b71ae9

Please sign in to comment.