Changeset 53 for domaineditor
- Timestamp:
- 12/18/24 13:28:59 (4 days ago)
- Location:
- domaineditor
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
domaineditor/pom.xml
r52 r53 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>domaineditor</artifactId> 8 <version>2. 1.6</version>8 <version>2.2.1</version> <!-- equals the geniusweb version --> 9 9 <packaging>jar</packaging> 10 10 … … 53 53 <groupId>tudelft.utilities</groupId> 54 54 <artifactId>utilities</artifactId> 55 <version>1. 2.1</version>55 <version>1.3.1</version> 56 56 </dependency> 57 57 <dependency> 58 58 <groupId>tudelft.utilities</groupId> 59 59 <artifactId>logging</artifactId> 60 <version>1.0. 1</version>60 <version>1.0.2</version> 61 61 </dependency> 62 62 <dependency> 63 63 <groupId>tudelft.utilities</groupId> 64 64 <artifactId>mvc</artifactId> 65 <version> 1.1.0</version>65 <version>2.0.5</version> 66 66 </dependency> 67 67 -
domaineditor/src/main/java/geniusweb/domaineditor/ProfileEditor.java
r52 r53 15 15 import geniusweb.domaineditor.panels.profile.ProfileEditorPanel; 16 16 import tudelft.utilities.logging.Reporter; 17 import tudelft.utilities.mvc.model.ModelTime; 18 import tudelft.utilities.mvc.model.NoModelTime; 17 19 import tudelft.utilities.mvc.panels.PopupReporter; 18 20 … … 24 26 @SuppressWarnings("serial") 25 27 public class ProfileEditor extends JFrame { 28 public static ModelTime TIME = new NoModelTime(); 29 26 30 private final Reporter log; 27 31 private final LinearAdditiveUtilitySpaceModel model; -
domaineditor/src/main/java/geniusweb/domaineditor/model/BidModel.java
r52 r53 7 7 import java.util.logging.Level; 8 8 9 import geniusweb.domaineditor.ProfileEditor; 9 10 import geniusweb.issuevalue.Bid; 10 11 import geniusweb.issuevalue.DiscreteValue; 11 12 import geniusweb.issuevalue.NumberValue; 12 13 import geniusweb.issuevalue.Value; 13 import tudelft.utilities.listener.DefaultListenable; 14 import tudelft.utilities.listener.DefaultThrowingListenable; 15 import tudelft.utilities.listener.Unacceptable; 14 16 import tudelft.utilities.logging.Reporter; 15 17 import tudelft.utilities.mvc.model.BasicModel; … … 18 20 import tudelft.utilities.mvc.model.MapFromKeys; 19 21 import tudelft.utilities.mvc.model.MapModel; 22 import tudelft.utilities.mvc.model.Model; 23 import tudelft.utilities.mvc.model.ModelTime; 20 24 import tudelft.utilities.mvc.model.SelectionModel; 21 25 import tudelft.utilities.mvc.model.StringModel; 22 import tudelft.utilities.mvc.model.TypedModel;23 26 import tudelft.utilities.mvc.model.events.Added; 24 27 import tudelft.utilities.mvc.model.events.Changed; … … 38 41 * 39 42 */ 40 public class BidModel extends Default Listenable<Event> implements41 MapModel<StringModel, SelectionModel<BasicModel>>, TypedModel<Bid>{43 public class BidModel extends DefaultThrowingListenable<Event> 44 implements MapModel<StringModel, SelectionModel<BasicModel>>, Model { 42 45 private final MapModel<StringModel, ValueSetModel> issuevalues; 43 46 private final Map<StringModel, SelectionModel<BasicModel>> selections = new HashMap<>(); … … 66 69 67 70 private void add(StringModel key, ListModel value) { 68 selections.put(key, new DefaultSelectionModel(value ));71 selections.put(key, new DefaultSelectionModel(value, log, true)); 69 72 } 70 73 71 74 /** 72 75 * Domain change occured. Handle it. 76 * 77 * @throws Unacceptable 73 78 */ 74 private void handleChange(Event e) {79 private void handleChange(Event e) throws Unacceptable { 75 80 // we only handle add/remove of issues. If a value is removed, 76 81 // this should automatically reflect into the selectionmodel. 77 if (!(e instanceof Changed)) { 78 System.out.println("Unexpected event " + e); 79 return; 80 } 82 if (!(e instanceof Changed)) 83 throw new Unacceptable("Unexpected event " + e); 81 84 e = e.getChildEvent(); 82 85 if (e instanceof Removed) { … … 101 104 } 102 105 103 @Override104 106 public void remove(StringModel key) { 105 107 throw new UnsupportedOperationException(); … … 121 123 } 122 124 123 @Override124 125 public Bid getCurrentValue() throws IllegalStateException { 125 126 Map<String, Value> selectionmap = new HashMap<>(); … … 134 135 } 135 136 136 @Override137 137 public void setCurrentValue(Bid bid) throws IllegalArgumentException { 138 138 ListModel<StringModel> issues = issuevalues.getKeys(); … … 186 186 } 187 187 188 @Override 189 public ModelTime getTime() { 190 return ProfileEditor.TIME; 191 } 192 188 193 } -
domaineditor/src/main/java/geniusweb/domaineditor/model/DiscreteValueSetModel.java
r52 r53 7 7 import java.util.logging.Level; 8 8 9 import geniusweb.domaineditor.ProfileEditor; 9 10 import geniusweb.issuevalue.DiscreteValue; 10 11 import geniusweb.issuevalue.DiscreteValueSet; … … 25 26 26 27 public DiscreteValueSetModel(List<StringModel> values, Reporter log) { 27 super(values, log );28 super(values, log, ProfileEditor.TIME); 28 29 } 29 30 30 31 public DiscreteValueSetModel(Reporter log) { 31 super(Arrays.asList(new StringModel("value", log)), log); 32 super(Arrays.asList(new StringModel("value", log, ProfileEditor.TIME)), 33 log, ProfileEditor.TIME); 32 34 } 33 35 … … 78 80 // first add the new vals because minimum size. 79 81 for (DiscreteValue val : valset.getValues()) { 80 add(new StringModel(val.getValue(), log ));82 add(new StringModel(val.getValue(), log, ProfileEditor.TIME)); 81 83 } 82 84 for (StringModel old : oldvals) { -
domaineditor/src/main/java/geniusweb/domaineditor/model/DomainModel.java
r52 r53 16 16 import geniusweb.issuevalue.Domain; 17 17 import geniusweb.issuevalue.ValueSet; 18 import tudelft.utilities.listener.Default Listenable;18 import tudelft.utilities.listener.DefaultThrowingListenable; 19 19 import tudelft.utilities.logging.Reporter; 20 20 import tudelft.utilities.mvc.model.DefaultMapModel; 21 21 import tudelft.utilities.mvc.model.MapModel; 22 22 import tudelft.utilities.mvc.model.Model; 23 import tudelft.utilities.mvc.model.ModelTime; 23 24 import tudelft.utilities.mvc.model.StringModel; 24 import tudelft.utilities.mvc.model.TypedModel;25 25 import tudelft.utilities.mvc.model.events.Changed; 26 26 import tudelft.utilities.mvc.model.events.Event; … … 33 33 * 34 34 */ 35 public class DomainModel extends Default Listenable<Event>36 implements TypedModel<Domain> {35 public class DomainModel extends DefaultThrowingListenable<Event> 36 implements Model { // model<Domain> 37 37 private static final ObjectMapper jackson = new ObjectMapper(); 38 38 private final StringModel domainname; … … 57 57 this(new SimpleStringModel("domainname", log), 58 58 new DefaultMapModel<StringModel, ValueSetModel>( 59 Collections.singletonMap(new StringModel("issue", log), 59 Collections.singletonMap( 60 new StringModel("issue", log, 61 ProfileEditor.TIME), 60 62 new DiscreteValueSetModel(log)), 61 log ) {63 log, ProfileEditor.TIME) { 62 64 @Override 63 65 public int getMinimumSize() { … … 88 90 Domain domain = jackson.readValue(file, Domain.class); 89 91 // FIXME 90 return new DomainModel(new StringModel(domain.getName(), log), null, 91 log); 92 return new DomainModel( 93 new StringModel(domain.getName(), log, ProfileEditor.TIME), 94 null, log); 92 95 } 93 96 … … 112 115 * @return the {@link Domain} contained in this model. 113 116 */ 114 @Override115 117 public Domain getCurrentValue() throws IllegalStateException { 116 118 Map<String, ValueSet> issues = new HashMap<>(); … … 131 133 * {@link Model}s are created where needed. 132 134 */ 133 @Override134 135 public void setCurrentValue(Domain dom) throws IllegalArgumentException { 135 136 domainname.setValue(dom.getName()); … … 145 146 ValueSetModelType.fromModel(dom.getValues(iss)), log); 146 147 valsetmodel.setCurrentValue(dom.getValues(iss)); 147 issuesmodel.put(new StringModel(iss, log), valsetmodel); 148 issuesmodel.put(new StringModel(iss, log, ProfileEditor.TIME), 149 valsetmodel); 148 150 } 149 151 // remove the old issues 150 152 for (StringModel iss : oldissues) 151 issuesmodel.remove(iss); 153 issuesmodel.getKeys().remove(iss); 154 } 155 156 @Override 157 public ModelTime getTime() { 158 return ProfileEditor.TIME; 152 159 } 153 160 } -
domaineditor/src/main/java/geniusweb/domaineditor/model/NumberValueSetModel.java
r52 r53 5 5 import java.util.Map; 6 6 7 import geniusweb.domaineditor.ProfileEditor; 7 8 import geniusweb.issuevalue.NumberValueSet; 8 9 import geniusweb.issuevalue.ValueSet; 9 10 import tudelft.utilities.immutablelist.Range; 10 import tudelft.utilities.listener.DefaultListenable; 11 import tudelft.utilities.listener.DefaultThrowingListenable; 12 import tudelft.utilities.listener.Unacceptable; 11 13 import tudelft.utilities.logging.Reporter; 12 14 import tudelft.utilities.mvc.model.BasicModel; 13 15 import tudelft.utilities.mvc.model.ListModel; 16 import tudelft.utilities.mvc.model.ModelTime; 14 17 import tudelft.utilities.mvc.model.NumberModel; 15 18 import tudelft.utilities.mvc.model.events.Changed; … … 20 23 * 21 24 */ 22 public class NumberValueSetModel extends Default Listenable<Event>25 public class NumberValueSetModel extends DefaultThrowingListenable<Event> 23 26 implements ValueSetModel { 24 27 … … 27 30 28 31 public NumberValueSetModel(NumberModel lowv, NumberModel highv, 29 NumberModel stepv, Reporter log) {32 NumberModel stepv, Reporter log) throws Unacceptable { 30 33 this.low = lowv; 31 34 this.high = highv; … … 41 44 } 42 45 43 private void check() throws IllegalStateException{46 private void check() throws Unacceptable { 44 47 if (low.getValue().compareTo(high.getValue()) > 0) 45 throw new IllegalStateException("low must be <= high");48 throw new Unacceptable("low must be <= high"); 46 49 if (step.getValue().compareTo(BigDecimal.ZERO) <= 0) 47 throw new IllegalStateException("step must be >0");50 throw new Unacceptable("step must be >0"); 48 51 notifyListeners(new Changed(this, null)); 49 52 } … … 51 54 /* 52 55 * Default, bit arbitrary values. 56 * 57 * @throws something that should never happen 53 58 */ 54 public NumberValueSetModel(Reporter log) {55 this(new NumberModel(BigDecimal.ZERO, log ),56 new NumberModel(BigDecimal.TEN, log ),57 new NumberModel(BigDecimal.ONE, log ), log);59 public NumberValueSetModel(Reporter log) throws Unacceptable { 60 this(new NumberModel(BigDecimal.ZERO, log, ProfileEditor.TIME), 61 new NumberModel(BigDecimal.TEN, log, ProfileEditor.TIME), 62 new NumberModel(BigDecimal.ONE, log, ProfileEditor.TIME), log); 58 63 } 59 64 … … 116 121 } 117 122 123 @Override 124 public ModelTime getTime() { 125 return ProfileEditor.TIME; 126 } 127 118 128 } 119 129 … … 122 132 * 123 133 */ 124 class MyListModel extends Default Listenable<Event>134 class MyListModel extends DefaultThrowingListenable<Event> 125 135 implements ListModel<NumberModel> { 126 136 … … 143 153 BigDecimal val = numvalset.getCurrentValue().getRange().get(n); 144 154 if (!itemsCache.containsKey(val)) 145 itemsCache.put(val, new NumberModel(val, numvalset.log)); 155 itemsCache.put(val, 156 new NumberModel(val, numvalset.log, ProfileEditor.TIME)); 146 157 return itemsCache.get(val); 147 158 } … … 168 179 } 169 180 181 @Override 182 public ModelTime getTime() { 183 return ProfileEditor.TIME; 184 } 185 170 186 } -
domaineditor/src/main/java/geniusweb/domaineditor/model/SimpleStringModel.java
r52 r53 1 1 package geniusweb.domaineditor.model; 2 2 3 import geniusweb.domaineditor.ProfileEditor; 4 import tudelft.utilities.listener.Unacceptable; 3 5 import tudelft.utilities.logging.Reporter; 4 6 import tudelft.utilities.mvc.model.StringModel; … … 10 12 11 13 public SimpleStringModel(String val, Reporter log) { 12 super(val, log );14 super(val, log, ProfileEditor.TIME); 13 15 } 14 16 15 17 @Override 16 protected void check() throws IllegalStateException{18 protected void check() throws Unacceptable { 17 19 if (!(getValue().matches("[a-zA-Z0-9]+"))) 18 throw new IllegalStateException(20 throw new Unacceptable( 19 21 "Only lower and upper case letters and numbers are allowed"); 20 22 super.check(); -
domaineditor/src/main/java/geniusweb/domaineditor/model/ValueSetModel.java
r52 r53 4 4 import tudelft.utilities.mvc.model.BasicModel; 5 5 import tudelft.utilities.mvc.model.ListModel; 6 import tudelft.utilities.mvc.model. TypedModel;6 import tudelft.utilities.mvc.model.Model; 7 7 8 8 /** … … 11 11 * 12 12 */ 13 public interface ValueSetModel extends TypedModel<ValueSet>{13 public interface ValueSetModel extends Model { 14 14 /** 15 15 * … … 25 25 public ListModel<? extends BasicModel> getList(); 26 26 27 /** 28 * 29 * @return the currently contained value in the model. We do NOT specify the 30 * type of the returned object because it would have to be a type 31 * parameter added to Model, which leads to all kinds of issues with 32 * excessive parameterization and issues when a class extends eg a 33 * MapModel. NOTE: also derived classes like ListModel should not 34 * specify that they return {@link List} or so: further subclassing 35 * of eg a ListModel might be eg a ValueSet which would not return a 36 * List again. 37 * @throws IllegalStateException if the model is not correctly filled in at 38 * this moment. 39 */ 40 public ValueSet getCurrentValue() throws IllegalStateException; 41 42 /** 43 * Sets the current value based on the proviced obj 44 * 45 * @param obj the object to load the model with. Mirror of 46 * {@link #getCurrentValue()} and the Object is the same type. 47 * @throws IllegalArgumentException if the object is not the expected object 48 * type 49 */ 50 public void setCurrentValue(ValueSet obj) throws IllegalArgumentException; 51 27 52 } -
domaineditor/src/main/java/geniusweb/domaineditor/model/ValueSetModelType.java
r52 r53 4 4 import geniusweb.issuevalue.NumberValueSet; 5 5 import geniusweb.issuevalue.ValueSet; 6 import tudelft.utilities.listener.Unacceptable; 6 7 import tudelft.utilities.logging.Reporter; 7 8 … … 57 58 return new DiscreteValueSetModel(log); 58 59 case NUMBER: 59 return new NumberValueSetModel(log); 60 try { 61 return new NumberValueSetModel(log); 62 } catch (Unacceptable e) { 63 throw new RuntimeException(e);// shouldn't happen 64 } 60 65 } 61 66 return null; // unreachable code -
domaineditor/src/main/java/geniusweb/domaineditor/model/profile/DiscreteValueSetUtilitiesModel.java
r52 r53 5 5 import java.util.Map; 6 6 7 import geniusweb.domaineditor.ProfileEditor; 7 8 import geniusweb.domaineditor.model.DiscreteValueSetModel; 8 9 import geniusweb.issuevalue.DiscreteValue; 9 10 import geniusweb.profile.utilityspace.DiscreteValueSetUtilities; 10 11 import geniusweb.profile.utilityspace.ValueSetUtilities; 11 import tudelft.utilities.listener.DefaultListenable; 12 import tudelft.utilities.listener.DefaultThrowingListenable; 13 import tudelft.utilities.listener.Unacceptable; 12 14 import tudelft.utilities.logging.Reporter; 13 15 import tudelft.utilities.mvc.model.ListModel; 14 16 import tudelft.utilities.mvc.model.MapModel; 17 import tudelft.utilities.mvc.model.ModelTime; 15 18 import tudelft.utilities.mvc.model.NumberModel; 16 19 import tudelft.utilities.mvc.model.RestrictedNumberModel; … … 26 29 * 27 30 */ 28 public class DiscreteValueSetUtilitiesModel extends DefaultListenable<Event> 29 implements MapModel<StringModel, RestrictedNumberModel>, 30 ValueSetUtilitiesModel { 31 public class DiscreteValueSetUtilitiesModel 32 extends DefaultThrowingListenable<Event> implements 33 MapModel<StringModel, RestrictedNumberModel>, ValueSetUtilitiesModel { 34 31 35 private final ListModel<StringModel> values; 32 36 private final Map<StringModel, RestrictedNumberModel> utilities = new HashMap<>(); … … 37 41 private final static Reporter dummylog = new PopupReporter(null); 38 42 private final static NumberModel LOW = new NumberModel(BigDecimal.ZERO, 39 dummylog );43 dummylog, ProfileEditor.TIME); 40 44 private final static NumberModel HIGH = new NumberModel(BigDecimal.ONE, 41 dummylog );45 dummylog, ProfileEditor.TIME); 42 46 43 47 public DiscreteValueSetUtilitiesModel(DiscreteValueSetModel values, … … 50 54 public RestrictedNumberModel getValue(StringModel key) { 51 55 if (!utilities.containsKey(key)) { 52 utilities.put(key, 53 new RestrictedNumberModel(DEFAULT, LOW, HIGH, log)); 56 try { 57 utilities.put(key, new RestrictedNumberModel(DEFAULT, LOW, HIGH, 58 log, ProfileEditor.TIME)); 59 } catch (Unacceptable e) { 60 throw new RuntimeException(e);// this should not happen 61 } 54 62 } 55 63 return utilities.get(key); … … 61 69 } 62 70 63 @Override64 71 public void remove(StringModel key) { 65 72 throw new UnsupportedOperationException(); … … 113 120 } 114 121 122 @Override 123 public ModelTime getTime() { 124 return ProfileEditor.TIME; 125 } 126 115 127 } -
domaineditor/src/main/java/geniusweb/domaineditor/model/profile/LinearAdditiveUtilitySpaceModel.java
r52 r53 8 8 import java.util.stream.Collectors; 9 9 10 import geniusweb.domaineditor.ProfileEditor; 10 11 import geniusweb.domaineditor.model.BidModel; 11 12 import geniusweb.domaineditor.model.DiscreteValueSetModel; … … 16 17 import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace; 17 18 import geniusweb.profile.utilityspace.ValueSetUtilities; 18 import tudelft.utilities.listener.DefaultListenable; 19 import tudelft.utilities.listener.DefaultThrowingListenable; 20 import tudelft.utilities.listener.Unacceptable; 19 21 import tudelft.utilities.logging.Reporter; 20 22 import tudelft.utilities.mvc.model.ListModel; 21 23 import tudelft.utilities.mvc.model.MapFromKeys; 22 24 import tudelft.utilities.mvc.model.MapModel; 25 import tudelft.utilities.mvc.model.Model; 26 import tudelft.utilities.mvc.model.ModelTime; 23 27 import tudelft.utilities.mvc.model.NumberModel; 24 28 import tudelft.utilities.mvc.model.RestrictedNumberModel; 25 29 import tudelft.utilities.mvc.model.StringModel; 26 import tudelft.utilities.mvc.model.TypedModel;27 30 import tudelft.utilities.mvc.model.events.Event; 28 31 import tudelft.utilities.mvc.panels.PopupReporter; … … 31 34 * Model containing a {@link LinearAdditiveUtilitySpace} 32 35 */ 33 public class LinearAdditiveUtilitySpaceModel extends DefaultListenable<Event>34 implements ProfileModel, TypedModel<LinearAdditiveUtilitySpace> {36 public class LinearAdditiveUtilitySpaceModel extends 37 DefaultThrowingListenable<Event> implements ProfileModel, Model { // Model<<LinearAdditiveUtilitySpace>> 35 38 private final SimpleStringModel name; 36 39 /** … … 87 90 // we should never allow editing of these constants. 88 91 protected static final NumberModel CONSTANT0 = new NumberModel( 89 BigDecimal.ZERO, dummylog );92 BigDecimal.ZERO, dummylog, ProfileEditor.TIME); 90 93 protected static final NumberModel CONSTANT1 = new NumberModel( 91 BigDecimal.ONE, dummylog );94 BigDecimal.ONE, dummylog, ProfileEditor.TIME); 92 95 93 96 public LinearAdditiveUtilitySpaceModel(DomainModel domain, … … 108 111 final DomainModel domain2, final Reporter log) { 109 112 return new MapFromKeys<StringModel, RestrictedNumberModel>( 110 domain2.getIssues().getKeys(), log, true ) {113 domain2.getIssues().getKeys(), log, true, ProfileEditor.TIME) { 111 114 112 115 @Override 113 116 public RestrictedNumberModel create(StringModel key) { 114 return new RestrictedNumberModel(N05, CONSTANT0, CONSTANT1, 115 log); 117 try { 118 return new RestrictedNumberModel(N05, CONSTANT0, CONSTANT1, 119 log, ProfileEditor.TIME); 120 } catch (Unacceptable e) { 121 throw new RuntimeException(e); // shouldn't happen 122 } 116 123 } 117 124 … … 129 136 // different type 130 137 return new MapFromKeys<StringModel, ValueSetUtilitiesModel>( 131 domain2.getIssues().getKeys(), log, false ) {138 domain2.getIssues().getKeys(), log, false, ProfileEditor.TIME) { 132 139 @Override 133 140 public ValueSetUtilitiesModel create(StringModel key) { … … 137 144 (DiscreteValueSetModel) val, log); 138 145 if (val instanceof NumberValueSetModel) 139 return new NumberValueSetUtilitiesModel( 140 (NumberValueSetModel) val, log); 146 try { 147 return new NumberValueSetUtilitiesModel( 148 (NumberValueSetModel) val, log); 149 } catch (Unacceptable e) { 150 throw new RuntimeException(e); // shouldn't happen 151 } 141 152 throw new RuntimeException( 142 153 "Unsupported type " + val + "for key" + key); … … 190 201 } 191 202 192 @Override193 203 public LinearAdditiveUtilitySpace getCurrentValue() 194 204 throws IllegalStateException { … … 212 222 } 213 223 214 @Override215 224 public void setCurrentValue(LinearAdditiveUtilitySpace obj) 216 225 throws IllegalArgumentException { … … 258 267 } 259 268 269 @Override 270 public ModelTime getTime() { 271 return ProfileEditor.TIME; 272 } 273 260 274 } -
domaineditor/src/main/java/geniusweb/domaineditor/model/profile/NumberValueSetUtilitiesModel.java
r52 r53 3 3 import java.math.BigDecimal; 4 4 5 import geniusweb.domaineditor.ProfileEditor; 5 6 import geniusweb.domaineditor.model.NumberValueSetModel; 6 7 import geniusweb.profile.utilityspace.NumberValueSetUtilities; 7 8 import geniusweb.profile.utilityspace.ValueSetUtilities; 8 import tudelft.utilities.listener.DefaultListenable; 9 import tudelft.utilities.listener.DefaultThrowingListenable; 10 import tudelft.utilities.listener.Unacceptable; 9 11 import tudelft.utilities.logging.Reporter; 12 import tudelft.utilities.mvc.model.ModelTime; 10 13 import tudelft.utilities.mvc.model.NumberModel; 11 14 import tudelft.utilities.mvc.model.RestrictedNumberModel; … … 17 20 * 18 21 */ 19 public class NumberValueSetUtilitiesModel extends DefaultListenable<Event>20 implements ValueSetUtilitiesModel {22 public class NumberValueSetUtilitiesModel extends 23 DefaultThrowingListenable<Event> implements ValueSetUtilitiesModel { 21 24 22 25 private static final BigDecimal DEFAULT = new BigDecimal("0.5"); … … 25 28 private final static Reporter dummylog = new PopupReporter(null); 26 29 private final static NumberModel LOW = new NumberModel(BigDecimal.ZERO, 27 dummylog );30 dummylog, ProfileEditor.TIME); 28 31 private final static NumberModel HIGH = new NumberModel(BigDecimal.ONE, 29 dummylog );32 dummylog, ProfileEditor.TIME); 30 33 private final NumberModel lowValue; 31 34 private final RestrictedNumberModel lowUtility; … … 49 52 } 50 53 51 NumberValueSetUtilitiesModel(NumberValueSetModel valuesmodel, 52 Reporter log){54 NumberValueSetUtilitiesModel(NumberValueSetModel valuesmodel, Reporter log) 55 throws Unacceptable { 53 56 this(valuesmodel.getLow(), 54 new RestrictedNumberModel(DEFAULT, LOW, HIGH, log), 55 valuesmodel.getHigh(), 56 new RestrictedNumberModel(DEFAULT, LOW, HIGH, log)); 57 new RestrictedNumberModel(DEFAULT, LOW, HIGH, log, 58 ProfileEditor.TIME), 59 valuesmodel.getHigh(), new RestrictedNumberModel(DEFAULT, LOW, 60 HIGH, log, ProfileEditor.TIME)); 57 61 } 58 62 … … 95 99 highUtility.setValue(utils.getHighUtility()); 96 100 } 101 102 @Override 103 public ModelTime getTime() { 104 return ProfileEditor.TIME; 105 } 97 106 }; -
domaineditor/src/main/java/geniusweb/domaineditor/model/profile/ValueSetUtilitiesModel.java
r52 r53 2 2 3 3 import geniusweb.profile.utilityspace.ValueSetUtilities; 4 import tudelft.utilities.mvc.model. TypedModel;4 import tudelft.utilities.mvc.model.Model; 5 5 6 6 /** … … 8 8 * 9 9 */ 10 public interface ValueSetUtilitiesModel extends TypedModel<ValueSetUtilities> { 10 public interface ValueSetUtilitiesModel extends Model { 11 12 void setCurrentValue(ValueSetUtilities valueSetUtilities); 13 14 ValueSetUtilities getCurrentValue(); 11 15 12 16 } -
domaineditor/src/main/java/geniusweb/domaineditor/panels/DiscreteValueSetPanel.java
r52 r53 5 5 import javax.swing.JPanel; 6 6 7 import geniusweb.domaineditor.ProfileEditor; 7 8 import geniusweb.domaineditor.model.DiscreteValueSetModel; 8 9 import tudelft.utilities.logging.Reporter; … … 24 25 setLayout(new BorderLayout()); 25 26 add(new EditableListViewPanel(model.getList()) { 27 26 28 @Override 27 29 protected void addItem() { 28 model.add(new StringModel("value " + (n++), log)); 30 model.add(new StringModel("value " + (n++), log, 31 ProfileEditor.TIME)); 29 32 30 33 } -
domaineditor/src/main/java/geniusweb/domaineditor/panels/DomainEditorPanel.java
r52 r53 9 9 import javax.swing.JPanel; 10 10 11 import geniusweb.domaineditor.ProfileEditor; 11 12 import geniusweb.domaineditor.model.DiscreteValueSetModel; 12 13 import geniusweb.domaineditor.model.DomainModel; 13 14 import geniusweb.domaineditor.model.NumberValueSetModel; 14 15 import geniusweb.domaineditor.model.ValueSetModel; 16 import tudelft.utilities.listener.Unacceptable; 15 17 import tudelft.utilities.logging.Reporter; 16 18 import tudelft.utilities.mvc.model.MapModel; … … 39 41 40 42 add(new LabeledPanel("domain name ", 41 new StringPanel(domainmodel.getName())), 42 BorderLayout.NORTH); 43 new StringPanel(domainmodel.getName())), BorderLayout.NORTH); 43 44 add(new IssuesMapEditor(domainmodel.getIssues(), log), 44 45 BorderLayout.CENTER); … … 82 83 panel.add(combo, BorderLayout.CENTER); 83 84 JOptionPane.showMessageDialog(this, panel); 84 StringModel issuename = new StringModel("issue " + (n++), logger); 85 StringModel issuename = new StringModel("issue " + (n++), logger, 86 ProfileEditor.TIME); 85 87 ValueSetModel valuesetmodel; 86 88 if (combo.getSelectedItem().equals("discrete")) 87 89 valuesetmodel = new DiscreteValueSetModel(logger); 88 90 else 89 valuesetmodel = new NumberValueSetModel(logger); 91 try { 92 valuesetmodel = new NumberValueSetModel(logger); 93 } catch (Unacceptable e) { 94 throw new RuntimeException(e);// shouldn't happen 95 } 90 96 getModel().put(issuename, valuesetmodel); 91 97 -
domaineditor/src/test/java/geniusweb/domaineditor/DomainEditorPanelTest.java
r52 r53 12 12 import geniusweb.domaineditor.model.ValueSetModel; 13 13 import geniusweb.domaineditor.panels.DomainEditorPanel; 14 import tudelft.utilities.listener. Listener;14 import tudelft.utilities.listener.ThrowingListener; 15 15 import tudelft.utilities.logging.Reporter; 16 16 import tudelft.utilities.mvc.model.DefaultMapModel; … … 28 28 f.setLayout(new BorderLayout()); 29 29 30 StringModel namemodel = new StringModel("issue1", log); 30 StringModel namemodel = new StringModel("issue1", log, 31 ProfileEditor.TIME); 31 32 ValueSetModel valuesmmodel = new DiscreteValueSetModel(log); 32 33 DefaultMapModel<StringModel, ValueSetModel> issuesmodel = new DefaultMapModel<StringModel, ValueSetModel>( 33 Collections.singletonMap(namemodel, valuesmmodel), log) { 34 Collections.singletonMap(namemodel, valuesmmodel), log, 35 ProfileEditor.TIME) { 34 36 35 37 @Override … … 50 52 51 53 }; 52 DomainModel model = new DomainModel(new StringModel("testdomain", log), 54 DomainModel model = new DomainModel( 55 new StringModel("testdomain", log, ProfileEditor.TIME), 53 56 issuesmodel, log); 54 model.addListener(new Listener<Event>() {57 model.addListener(new ThrowingListener<Event>() { 55 58 56 59 @Override -
domaineditor/src/test/java/geniusweb/model/NumberValueSetModelTest.java
r52 r53 11 11 import org.junit.Test; 12 12 13 import geniusweb.domaineditor.ProfileEditor; 13 14 import geniusweb.domaineditor.model.NumberValueSetModel; 14 15 import geniusweb.issuevalue.NumberValueSet; 15 16 import geniusweb.issuevalue.ValueSet; 16 17 import tudelft.utilities.immutablelist.Range; 18 import tudelft.utilities.listener.Unacceptable; 17 19 import tudelft.utilities.logging.Reporter; 18 20 import tudelft.utilities.mvc.model.NumberModel; … … 22 24 23 25 @Test 24 public void smoke() {26 public void smoke() throws Unacceptable { 25 27 new NumberValueSetModel(log); 26 28 } 27 29 28 30 @Test 29 public void testSomeGoodValues() {31 public void testSomeGoodValues() throws Unacceptable { 30 32 NumberValueSetModel model = new NumberValueSetModel(log); 31 33 assertEquals(11, model.getList().getSize()); // default is 0...10 … … 33 35 assertEquals(9, model.getList().getSize()); // 2..10 34 36 model.getHigh().setValue(new BigDecimal("3")); 37 assertEquals(2, model.getLow().getValue().intValue()); 38 assertEquals(3, model.getHigh().getValue().intValue()); 35 39 assertEquals(2, model.getList().getSize()); // 2..3 36 40 model.getStep().setValue(new BigDecimal("0.1")); … … 38 42 } 39 43 40 @Test(expected = IllegalStateException.class) 41 public void testIllegal1() { 42 new NumberValueSetModel(new NumberModel(BigDecimal.TEN, log), 43 new NumberModel(BigDecimal.ONE, log), 44 new NumberModel(BigDecimal.ONE, log), log); 44 @Test(expected = Unacceptable.class) 45 public void testIllegal1() throws Unacceptable { 46 new NumberValueSetModel( 47 new NumberModel(BigDecimal.TEN, log, ProfileEditor.TIME), 48 new NumberModel(BigDecimal.ONE, log, ProfileEditor.TIME), 49 new NumberModel(BigDecimal.ONE, log, ProfileEditor.TIME), log); 45 50 } 46 51 47 52 @Test 48 public void testIllegal12() {53 public void testIllegal12() throws Unacceptable { 49 54 NumberValueSetModel n = new NumberValueSetModel(log); 50 55 // change low above high must log problem … … 53 58 } 54 59 55 @Test(expected = IllegalStateException.class)56 public void testIllegal3() {60 @Test(expected = Unacceptable.class) 61 public void testIllegal3() throws Unacceptable { 57 62 NumberValueSetModel model = new NumberValueSetModel( 58 new NumberModel(BigDecimal.TEN, log ),59 new NumberModel(BigDecimal.ONE, log ),60 new NumberModel(BigDecimal.ONE, log ), log);63 new NumberModel(BigDecimal.TEN, log, ProfileEditor.TIME), 64 new NumberModel(BigDecimal.ONE, log, ProfileEditor.TIME), 65 new NumberModel(BigDecimal.ONE, log, ProfileEditor.TIME), log); 61 66 model.getLow().setValue(BigDecimal.valueOf(20)); 62 67 } 63 68 64 69 @Test 65 public void testLowIncrease() {70 public void testLowIncrease() throws Unacceptable { 66 71 NumberValueSetModel set = new NumberValueSetModel( 67 new NumberModel(BigDecimal.ZERO, log ),68 new NumberModel(BigDecimal.TEN, log ),69 new NumberModel(BigDecimal.ONE, log ), log);72 new NumberModel(BigDecimal.ZERO, log, ProfileEditor.TIME), 73 new NumberModel(BigDecimal.TEN, log, ProfileEditor.TIME), 74 new NumberModel(BigDecimal.ONE, log, ProfileEditor.TIME), log); 70 75 ValueSet v = new NumberValueSet( 71 76 new Range(BigDecimal.ONE, BigDecimal.TEN, BigDecimal.ONE)); … … 75 80 76 81 @Test 77 public void testHighDecrease() {82 public void testHighDecrease() throws Unacceptable { 78 83 NumberValueSetModel set = new NumberValueSetModel( 79 new NumberModel(BigDecimal.ZERO, log ),80 new NumberModel(BigDecimal.TEN, log ),81 new NumberModel(BigDecimal.ONE, log ), log);84 new NumberModel(BigDecimal.ZERO, log, ProfileEditor.TIME), 85 new NumberModel(BigDecimal.TEN, log, ProfileEditor.TIME), 86 new NumberModel(BigDecimal.ONE, log, ProfileEditor.TIME), log); 82 87 ValueSet v = new NumberValueSet( 83 88 new Range(BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.ONE)); … … 87 92 88 93 @Test 89 public void testIncreaseBoth() {94 public void testIncreaseBoth() throws Unacceptable { 90 95 NumberValueSetModel set = new NumberValueSetModel( 91 new NumberModel(BigDecimal.ZERO, log ),92 new NumberModel(BigDecimal.ONE, log ),93 new NumberModel(BigDecimal.ONE, log ), log);96 new NumberModel(BigDecimal.ZERO, log, ProfileEditor.TIME), 97 new NumberModel(BigDecimal.ONE, log, ProfileEditor.TIME), 98 new NumberModel(BigDecimal.ONE, log, ProfileEditor.TIME), log); 94 99 ValueSet v = new NumberValueSet( 95 100 new Range(BigDecimal.ONE, BigDecimal.TEN, BigDecimal.ONE)); … … 98 103 99 104 @Test 100 public void testIncreaseBothMuch() {105 public void testIncreaseBothMuch() throws Unacceptable { 101 106 NumberValueSetModel set = new NumberValueSetModel( 102 new NumberModel(BigDecimal.ZERO, log ),103 new NumberModel(BigDecimal.ONE, log ),104 new NumberModel(BigDecimal.ONE, log ), log);107 new NumberModel(BigDecimal.ZERO, log, ProfileEditor.TIME), 108 new NumberModel(BigDecimal.ONE, log, ProfileEditor.TIME), 109 new NumberModel(BigDecimal.ONE, log, ProfileEditor.TIME), log); 105 110 ValueSet v = new NumberValueSet(new Range(new BigDecimal("20"), 106 111 new BigDecimal("80"), BigDecimal.ONE)); … … 109 114 110 115 @Test 111 public void testDecreaseBoth() {116 public void testDecreaseBoth() throws Unacceptable { 112 117 NumberValueSetModel set = new NumberValueSetModel( 113 new NumberModel(BigDecimal.ONE, log ),114 new NumberModel(BigDecimal.TEN, log ),115 new NumberModel(BigDecimal.ONE, log ), log);118 new NumberModel(BigDecimal.ONE, log, ProfileEditor.TIME), 119 new NumberModel(BigDecimal.TEN, log, ProfileEditor.TIME), 120 new NumberModel(BigDecimal.ONE, log, ProfileEditor.TIME), log); 116 121 ValueSet v = new NumberValueSet( 117 122 new Range(BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.ONE)); … … 120 125 121 126 @Test 122 public void testDecreaseBothMuch() {127 public void testDecreaseBothMuch() throws Unacceptable { 123 128 NumberValueSetModel set = new NumberValueSetModel( 124 new NumberModel(new BigDecimal("20"), log ),125 new NumberModel(new BigDecimal("80"), log ),126 new NumberModel(BigDecimal.ONE, log ), log);129 new NumberModel(new BigDecimal("20"), log, ProfileEditor.TIME), 130 new NumberModel(new BigDecimal("80"), log, ProfileEditor.TIME), 131 new NumberModel(BigDecimal.ONE, log, ProfileEditor.TIME), log); 127 132 ValueSet v = new NumberValueSet( 128 133 new Range(BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.ONE)); -
domaineditor/src/test/java/geniusweb/panels/ComboBoxTest.java
r52 r53 14 14 import org.junit.Test; 15 15 16 import geniusweb.domaineditor.ProfileEditor; 16 17 import geniusweb.domaineditor.model.DiscreteValueSetModel; 17 18 import geniusweb.domaineditor.model.DomainModel; … … 32 33 public void GuiTest() throws InterruptedException { 33 34 34 StringModel a = new StringModel("apples", log );35 StringModel b = new StringModel("bears", log );36 StringModel c = new StringModel("carrots", log );35 StringModel a = new StringModel("apples", log, ProfileEditor.TIME); 36 StringModel b = new StringModel("bears", log, ProfileEditor.TIME); 37 StringModel c = new StringModel("carrots", log, ProfileEditor.TIME); 37 38 38 39 JFrame f = new JFrame(); … … 40 41 f.getContentPane().add(panel); 41 42 DefaultListModel<StringModel> model = new DefaultListModel( 42 Arrays.asList(a, b, c), log) { 43 44 }; 43 Arrays.asList(a, b, c), log, ProfileEditor.TIME); 45 44 DefaultSelectionModel<StringModel> selectionmodel1 = new DefaultSelectionModel( 46 model );45 model, log, true); 47 46 panel.add(new ComboBox<StringModel>(selectionmodel1), 48 47 BorderLayout.NORTH); … … 60 59 public void testEqualsDeep() { 61 60 62 StringModel redvalue = new StringModel("red", log); 63 StringModel greenvalue = new StringModel("green", log); 61 StringModel redvalue = new StringModel("red", log, ProfileEditor.TIME); 62 StringModel greenvalue = new StringModel("green", log, 63 ProfileEditor.TIME); 64 64 DiscreteValueSetModel issue1values = new DiscreteValueSetModel( 65 65 Arrays.asList(redvalue, greenvalue), log); 66 66 67 StringModel issue1 = new StringModel("issue", log );67 StringModel issue1 = new StringModel("issue", log, ProfileEditor.TIME); 68 68 69 SelectionModel issue1valuessel = new DefaultSelectionModel( 70 issue1values);69 SelectionModel issue1valuessel = new DefaultSelectionModel(issue1values, 70 log, true); 71 71 Map<StringModel, SelectionModel> a = Collections.singletonMap(issue1, 72 72 issue1valuessel); 73 73 DefaultMapModel<StringModel, SelectionModel> issuevalues = new DefaultMapModel<StringModel, SelectionModel>( 74 a, log ) {74 a, log, ProfileEditor.TIME) { 75 75 76 76 @Override … … 92 92 93 93 MapModel<StringModel, ValueSetModel> issuevaluesmodel = new DefaultMapModel<StringModel, ValueSetModel>( 94 Collections.singletonMap(issue1, issue1values), log) { 94 Collections.singletonMap(issue1, issue1values), log, 95 ProfileEditor.TIME) { 95 96 96 97 @Override … … 110 111 111 112 }; 112 DomainModel domain = new DomainModel(new StringModel("testdomain", log), 113 DomainModel domain = new DomainModel( 114 new StringModel("testdomain", log, ProfileEditor.TIME), 113 115 issuevaluesmodel, log); 114 116
Note:
See TracChangeset
for help on using the changeset viewer.