@@ -96,15 +96,16 @@ public void start(Stage stage) throws Exception {
9696 // create combo box
9797 comboBox = new ComboBox <>(damageList );
9898 comboBox .setMaxWidth (Double .MAX_VALUE );
99- comboBox .setTooltip (new Tooltip ("Type of Damage" ));
10099 comboBox .setDisable (true );
101100
102101 // handle type damage selection
103- comboBox .showingProperty ().addListener ((obs , wasShowing , isShowing ) -> {
104- try {
105- updateAttributes (selected );
106- } catch (Exception e ) {
107- displayMessage ("Cannot update attributes" , e .getCause ().getMessage ());
102+ comboBox .getSelectionModel ().selectedItemProperty ().addListener ((o , p , n ) -> {
103+ if (!selected .getAttributes ().get ("typdamage" ).equals (n )) {
104+ try {
105+ updateAttributes (selected );
106+ } catch (Exception e ) {
107+ displayMessage ("Cannot update attributes" , e .getCause ().getMessage ());
108+ }
108109 }
109110 });
110111
@@ -151,7 +152,7 @@ public void start(Stage stage) throws Exception {
151152 selected .loadAsync ();
152153 selected .addDoneLoadingListener (() -> {
153154 if (selected .getLoadStatus () == LoadStatus .LOADED ) {
154- selectAttribute ( selected );
155+ comboBox . getSelectionModel (). select (( String ) selected . getAttributes (). get ( "typdamage" ) );
155156 } else {
156157 Alert alert = new Alert (Alert .AlertType .ERROR , "Element Failed to Load!" );
157158 alert .show ();
@@ -180,11 +181,6 @@ public void start(Stage stage) throws Exception {
180181 }
181182 }
182183
183- private void selectAttribute (ArcGISFeature feature ) {
184-
185- Platform .runLater (() -> comboBox .getSelectionModel ().select ((String ) feature .getAttributes ().get ("typdamage" )));
186- }
187-
188184 /**
189185 * Applies changes to the feature, Service Feature Table, and server.
190186 */
0 commit comments