Commit 6c431b53 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

DSE.UI: Sort synth category names alphabetically

Issue-Ref: 4062
Issue-Url: https://af3-developer.fortiss.org/issues/4062

Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent 66f5c928
......@@ -4,4 +4,4 @@ SolverSettingsTreeTableViewer.java 279e92b20a6b48e8e99ea7a2039fef419ea42826 GREE
SynthesisCategoryExplorationTargetContentProvider.java 410f00e07b5f4208b762b80baf563b2b73a93a71 GREEN
SynthesisCategoryRuleSetContentProvider.java 039913dba18b0248d10a77275258bc9acf9526cf GREEN
SynthesisFXContentController.java 50e97d06c11c2bb24cd8da4d975191e269b6188f GREEN
SynthesisFXViewPart.java e8e56445ae35f017700ff561557a2aa7c8cbd16d GREEN
SynthesisFXViewPart.java e40c2bd501d87b41c6324ab80fd34e64410db644 YELLOW
......@@ -15,6 +15,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.perspective.synthesis;
import static java.util.Collections.sort;
import static java.util.stream.Collectors.toList;
import static javafx.collections.FXCollections.observableList;
import static org.fortiss.af3.exploration.ui.perspective.process.IProcessManager.EProcessStep.SYNTHESIS;
......@@ -23,7 +24,9 @@ import static org.fortiss.af3.exploration.ui.perspective.service.IEventListener.
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.controlsfx.control.CheckComboBox;
import org.fortiss.af3.exploration.model.synthesiscategory.ISynthesisCategory;
......@@ -51,10 +54,11 @@ import javafx.scene.text.Font;
*/
public class SynthesisFXViewPart extends ExplorationUIFXViewPart {
/** The available synthesis types by the registered backends. */
protected final List<Class<? extends ISynthesisCategory>> synthCategories;
/** Mapping of names of the available synthesis types to the {@link ISynthesisCategory}s. */
protected final Map<String, Class<? extends ISynthesisCategory>> synthCategoryMapping =
new HashMap<>();
/** Names of the available synthesis types. Order must match {@link #synthCategories}. */
/** Names of the available synthesis types. */
protected final List<String> synthCategoryNames;
/** References the {@link IDSEBackendService}. */
......@@ -67,9 +71,13 @@ public class SynthesisFXViewPart extends ExplorationUIFXViewPart {
public SynthesisFXViewPart() throws Exception {
super(new ExplorationUIFXController<>(new SynthesisFXContentController(), new HBox()),
"synthesis_icon.gif", null);
synthCategories = new ArrayList<>(dseBackendSrv.getDSESynthesises());
synthCategoryNames = synthCategories.stream().map(c -> dseBackendSrv.getSynthesisName(c))
.collect(toList());
List<Class<? extends ISynthesisCategory>> synthCategories =
new ArrayList<>(dseBackendSrv.getDSESynthesises());
synthCategories.stream()
.forEach(c -> synthCategoryMapping.put(dseBackendSrv.getSynthesisName(c), c));
synthCategoryNames = synthCategoryMapping.keySet().stream().collect(toList());
sort(synthCategoryNames);
@SuppressWarnings("unchecked") HBox titleBox =
((ExplorationUIFXController<HBox>)controller).getTitleNode();
......@@ -95,15 +103,13 @@ public class SynthesisFXViewPart extends ExplorationUIFXViewPart {
while(c.next()) {
if(c.wasAdded()) {
Collection<Class<? extends ISynthesisCategory>> added = c.getAddedSubList()
.stream()
.map(str -> synthCategories.get(synthCategoryNames.indexOf(str)))
.stream().map(str -> synthCategoryMapping.get(str))
.collect(toList());
evBroker.firePropertyChanged(added, SYNTH_CAT_ADDED);
} else if(c.wasRemoved()) {
Collection<Class<? extends ISynthesisCategory>> removed = c.getRemoved()
.stream()
.map(str -> synthCategories.get(synthCategoryNames.indexOf(str)))
.collect(toList());
Collection<Class<? extends ISynthesisCategory>> removed =
c.getRemoved().stream().map(str -> synthCategoryMapping.get(str))
.collect(toList());
evBroker.firePropertyChanged(removed, SYNTH_CAT_REMOVED);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment