Java源码示例:org.geotools.styling.FeatureTypeConstraint
示例1
@Override
public void populate(SelectedSymbol selectedSymbol) {
if (selectedSymbol != null) {
StyledLayer styledLayer = selectedSymbol.getStyledLayer();
if (styledLayer instanceof NamedLayerImpl) {
NamedLayerImpl namedLayer = (NamedLayerImpl) styledLayer;
fieldConfigVisitor.populateTextField(FieldIdEnum.NAME, namedLayer.getName());
// Feature layer constraint
List<FeatureTypeConstraint> ftcList = namedLayer.layerFeatureConstraints();
fieldConfigVisitor.populateFieldTypeConstraint(
FieldIdEnum.LAYER_FEATURE_CONSTRAINTS, ftcList);
}
}
}
示例2
/**
* Update extents of a feature type constraint.
*
* @param ftc the feature type constraint to update
*/
public void updateExtent(FeatureTypeConstraint ftc) {
if (ftc == null) {
return;
}
if (!extentList.isEmpty()) {
Extent[] extentArray = new Extent[extentList.size()];
int index = 0;
for (Extent extent : extentList) {
Extent newExtent = styleFactory.createExtent(extent.getName(), extent.getValue());
extentArray[index] = newExtent;
index++;
}
ftc.setExtents(extentArray);
}
}
示例3
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
if ((rowIndex < 0) || (rowIndex >= getRowCount())) {
return null;
}
if ((columnIndex < 0) || (columnIndex >= getColumnCount())) {
return null;
}
FeatureTypeConstraint ftc = ftcList.get(rowIndex);
switch (columnIndex) {
case COL_NAME:
return ftc.getFeatureTypeName();
case COL_FILTER:
if (ftc.getFilter() != null) {
return ftc.getFilter().toString();
}
break;
default:
break;
}
return null;
}
示例4
/**
* Test method for {@link
* com.sldeditor.ui.detail.config.featuretypeconstraint.ExtentModel#updateExtent(org.geotools.styling.FeatureTypeConstraint)}.
*/
@Test
public void testUpdateExtent() {
ExtentModel model = new ExtentModel(null);
Extent[] extentArray = null;
model.populate(extentArray);
extentArray = new Extent[2];
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
extentArray[0] = styleFactory.createExtent("extent 1", "1 1 1 1");
extentArray[1] = styleFactory.createExtent("extent 2", "2 2 2 2");
model.populate(extentArray);
FeatureTypeConstraint ftc =
styleFactory.createFeatureTypeConstraint("feature type name", Filter.INCLUDE, null);
model.updateExtent(null);
model.updateExtent(ftc);
assertNotNull(ftc.getExtents());
assertEquals(2, ftc.getExtents().length);
}
示例5
@Override
public void populate(SelectedSymbol selectedSymbol) {
if (selectedSymbol != null) {
StyledLayer styledLayer = selectedSymbol.getStyledLayer();
if (styledLayer instanceof UserLayerImpl) {
UserLayerImpl userLayer = (UserLayerImpl) styledLayer;
fieldConfigVisitor.populateTextField(FieldIdEnum.NAME, userLayer.getName());
// Feature layer constraint
List<FeatureTypeConstraint> ftcList = userLayer.layerFeatureConstraints();
fieldConfigVisitor.populateFieldTypeConstraint(
FieldIdEnum.LAYER_FEATURE_CONSTRAINTS, ftcList);
// Source
GroupConfigInterface group = getGroup(GroupIdEnum.USER_LAYER_SOURCE);
if (group != null) {
MultiOptionGroup userLayerSourceGroup = (MultiOptionGroup) group;
if (userLayer.getInlineFeatureDatastore() == null) {
populateRemoteOWS(userLayer, userLayerSourceGroup);
} else {
userLayerSourceGroup.setOption(GroupIdEnum.INLINE_FEATURE_OPTION);
// Inline features
fieldConfigVisitor.populateUserLayer(FieldIdEnum.INLINE_FEATURE, userLayer);
}
}
}
}
}
示例6
/** Update symbol. */
private void updateSymbol() {
if (!Controller.getInstance().isPopulating()) {
String name = fieldConfigVisitor.getText(FieldIdEnum.NAME);
NamedLayer namedLayer = getStyleFactory().createNamedLayer();
namedLayer.setName(name);
// Feature type constraints
List<FeatureTypeConstraint> ftcList =
fieldConfigVisitor.getFeatureTypeConstraint(
FieldIdEnum.LAYER_FEATURE_CONSTRAINTS);
if ((ftcList != null) && !ftcList.isEmpty()) {
FeatureTypeConstraint[] ftcArray = new FeatureTypeConstraint[ftcList.size()];
namedLayer.setLayerFeatureConstraints(ftcList.toArray(ftcArray));
}
StyledLayer existingStyledLayer = SelectedSymbol.getInstance().getStyledLayer();
if (existingStyledLayer instanceof NamedLayerImpl) {
NamedLayerImpl existingNamedLayer = (NamedLayerImpl) existingStyledLayer;
for (Style style : existingNamedLayer.styles()) {
namedLayer.addStyle(style);
}
}
SelectedSymbol.getInstance().replaceStyledLayer(namedLayer);
this.fireUpdateSymbol();
}
}
示例7
/**
* Undo action.
*
* @param undoRedoObject the undo/redo object
*/
@Override
public void undoAction(UndoInterface undoRedoObject) {
if ((filterTable != null) && (undoRedoObject != null)) {
try {
@SuppressWarnings("unchecked")
List<FeatureTypeConstraint> oldValue =
(List<FeatureTypeConstraint>) undoRedoObject.getOldValue();
populateField(oldValue);
} catch (ClassCastException e) {
// Ignore
}
}
}
示例8
/**
* Redo action.
*
* @param undoRedoObject the undo/redo object
*/
@Override
public void redoAction(UndoInterface undoRedoObject) {
if ((filterTable != null) && (undoRedoObject != null)) {
try {
@SuppressWarnings("unchecked")
List<FeatureTypeConstraint> newValue =
(List<FeatureTypeConstraint>) undoRedoObject.getNewValue();
populateField(newValue);
} catch (ClassCastException e) {
// Ignore
}
}
}
示例9
/**
* Populate field.
*
* @param valueList the value list
*/
@Override
public void populateField(List<FeatureTypeConstraint> valueList) {
if (valueList != null) {
filterModel.populate(valueList);
if (!isSuppressUndoEvents()) {
UndoManager.getInstance()
.addUndoEvent(new UndoEvent(this, getFieldId(), oldValueObj, valueList));
oldValueObj = valueList;
}
valueUpdated();
}
}
示例10
@Override
public void featureTypeConstraintUpdated() {
if (!isSuppressUndoEvents()) {
List<FeatureTypeConstraint> ftc = filterModel.getFeatureTypeConstraint();
UndoManager.getInstance()
.addUndoEvent(new UndoEvent(this, getFieldId(), oldValueObj, ftc));
oldValueObj = ftc;
}
valueUpdated();
}
示例11
@Override
public void extentUpdated() {
if (filterTable != null) {
FeatureTypeConstraint ftc =
filterModel.getFeatureTypeConstraint(filterTable.getSelectedRow());
if (ftc != null) {
extentModel.updateExtent(ftc);
}
featureTypeConstraintUpdated();
}
}
示例12
/** Filter table item selected. */
protected void filterTableItemSelected() {
FeatureTypeConstraint ftc =
filterModel.getFeatureTypeConstraint(filterTable.getSelectedRow());
if (ftc != null) {
extentModel.populate(ftc.getExtents());
addExtentButton.setEnabled(true);
removeFTCButton.setEnabled(true);
int[] selectedColumns = filterTable.getSelectedColumns();
if (filterModel.isFilterColumn(selectedColumns)) {
FilterPanelInterface filterPanel = ExpressionPanelFactory.getFilterPanel(null);
String panelTitle =
Localisation.getString(
FieldConfigBase.class,
"FieldConfigFeatureTypeConstraint.filterPanel");
filterPanel.configure(
panelTitle, Object.class, SelectedSymbol.getInstance().isRasterSymbol());
filterPanel.populate(ftc.getFilter());
if (filterPanel.showDialog()) {
ftc.setFilter(filterPanel.getFilter());
filterModel.fireTableDataChanged();
featureTypeConstraintUpdated();
}
}
}
}
示例13
/** Adds the new entry. */
public void addNewEntry() {
FeatureTypeConstraint ftc =
styleFactory.createFeatureTypeConstraint(
DEFAULT_NAME, Filter.INCLUDE, new Extent[0]);
ftcList.add(ftc);
this.fireTableDataChanged();
if (parentObj != null) {
parentObj.featureTypeConstraintUpdated();
}
}
示例14
/**
* Sets the value at.
*
* @param aValue the a value
* @param rowIndex the row index
* @param columnIndex the column index
*/
@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
if ((rowIndex < 0) || (rowIndex >= getRowCount())) {
return;
}
if ((columnIndex < 0) || (columnIndex >= getColumnCount())) {
return;
}
FeatureTypeConstraint ftc = ftcList.get(rowIndex);
switch (columnIndex) {
case COL_NAME:
setName(aValue, ftc);
break;
case COL_FILTER:
break;
default:
break;
}
this.fireTableDataChanged();
if (parentObj != null) {
parentObj.featureTypeConstraintUpdated();
}
}
示例15
/**
* Populate.
*
* @param ftcList the ftc list
*/
public void populate(List<FeatureTypeConstraint> ftcList) {
this.ftcList.clear();
if (ftcList != null) {
for (FeatureTypeConstraint ftc : ftcList) {
FeatureTypeConstraint newFTC =
styleFactory.createFeatureTypeConstraint(
ftc.getFeatureTypeName(), ftc.getFilter(), new Extent[0]);
this.ftcList.add(newFTC);
}
}
this.fireTableDataChanged();
}
示例16
/**
* Gets the feature type constraint.
*
* @param row the row
* @return the feature type constraint
*/
public FeatureTypeConstraint getFeatureTypeConstraint(int row) {
if ((row >= 0) && (row < ftcList.size())) {
return ftcList.get(row);
}
return null;
}
示例17
/**
* Populate feature type constraint field.
*
* @param fieldId the field id
* @param ftcList the ftc list
*/
public void populateFieldTypeConstraint(
FieldIdEnum fieldId, List<FeatureTypeConstraint> ftcList) {
if (fieldConfigManager == null) {
return;
}
FieldConfigBase fieldConfig = fieldConfigManager.get(fieldId);
if (fieldConfig != null) {
fieldConfig.populateField(ftcList);
}
}
示例18
/**
* Gets the list of feature type constraints.
*
* @param fieldId the field id
* @return the list of feature type constraints
*/
public List<FeatureTypeConstraint> getFeatureTypeConstraint(FieldIdEnum fieldId) {
if (fieldConfigManager != null) {
FieldConfigValuePopulateInterface fieldConfig = fieldConfigManager.get(fieldId);
if (fieldConfig != null) {
return fieldConfig.getFeatureTypeConstraint();
}
}
return null;
}
示例19
/**
* (non-Javadoc)
*
* @see
* org.geotools.styling.visitor.DuplicatingStyleVisitor#visit(org.geotools.styling.UserLayer)
*/
@Override
public void visit(UserLayer layer) {
Style[] style = layer.getUserStyles();
int length = style.length;
Style[] styleCopy = new Style[length];
for (int i = 0; i < length; i++) {
if (style[i] != null) {
style[i].accept(this);
styleCopy[i] = (Style) pages.pop();
}
}
FeatureTypeConstraint[] lfc = layer.getLayerFeatureConstraints();
FeatureTypeConstraint[] lfcCopy = new FeatureTypeConstraint[lfc.length];
length = lfc.length;
for (int i = 0; i < length; i++) {
if (lfc[i] != null) {
lfc[i].accept(this);
lfcCopy[i] = (FeatureTypeConstraint) pages.pop();
}
}
UserLayer copy = sf.createUserLayer();
copy.setName(layer.getName());
copy.setUserStyles(styleCopy);
copy.setLayerFeatureConstraints(lfcCopy);
// Reuse the existing inline feature data store
copy.setInlineFeatureDatastore(layer.getInlineFeatureDatastore());
copy.setInlineFeatureType(layer.getInlineFeatureType());
if (STRICT && !copy.equals(layer)) {
throw new IllegalStateException("Was unable to duplicate provided UserLayer:" + layer);
}
pages.push(copy);
}
示例20
/**
* Test method for {@link
* com.sldeditor.ui.detail.config.FieldConfigPopulation#FieldConfigPopulation(com.sldeditor.ui.detail.GraphicPanelFieldManager)}.
*/
@Test
public void testFieldConfigPopulation() {
FieldIdEnum fieldId = FieldIdEnum.UNKNOWN;
FieldConfigPopulation obj = new FieldConfigPopulation(null);
obj.populateBooleanField(fieldId, Boolean.TRUE);
obj.populateComboBoxField(fieldId, "");
obj.populateColourField(fieldId, null);
obj.populateColourMapField(FieldIdEnum.ANCHOR_POINT_V, (ColorMap) null);
obj.populateFontField(FieldIdEnum.ANCHOR_POINT_V, (Font) null);
obj.populateTextField(fieldId, (String) null);
obj.populateDoubleField(fieldId, (Double) null);
obj.populateIntegerField(fieldId, (Integer) null);
obj.populateField(fieldId, (Expression) null);
obj.populateUserLayer(fieldId, (UserLayer) null);
obj.populateFieldTypeConstraint(fieldId, (List<FeatureTypeConstraint>) null);
assertNull(obj.getExpression(fieldId));
assertFalse(obj.getBoolean(fieldId));
assertEquals(0, obj.getInteger(fieldId));
assertTrue(Math.abs(obj.getDouble(fieldId) - 0.0) < 0.001);
assertTrue(obj.getText(fieldId).compareTo("") == 0);
assertNull(obj.getComboBox(fieldId));
assertNull(obj.getColourMap(fieldId));
assertNull(obj.getFieldConfig(fieldId));
assertNull(obj.getFeatureTypeConstraint(fieldId));
}
示例21
/**
* Test method for {@link
* com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#generateExpression()}.
* Test method for {@link
* com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#populateExpression(java.lang.Object)}.
* Test method for {@link
* com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#setTestValue(com.sldeditor.ui.detail.config.FieldId,
* java.util.List)}. Test method for {@link
* com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#populateField(java.util.List)}.
* Test method for {@link
* com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#getFeatureTypeConstraint()}.
*/
@Test
public void testGenerateExpression() {
FieldConfigFeatureTypeConstraint field =
new FieldConfigFeatureTypeConstraint(
new FieldConfigCommonData(
Geometry.class, FieldIdEnum.NAME, "label", true, false));
List<FeatureTypeConstraint> testValue = null;
field.populate(null);
field.setTestValue(FieldIdEnum.UNKNOWN, testValue);
field.populateField(testValue);
field.createUI();
assertNull(field.getStringValue());
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
FeatureTypeConstraint expectedValue1 =
styleFactory.createFeatureTypeConstraint("Feature", Filter.INCLUDE, new Extent[0]);
testValue = new ArrayList<FeatureTypeConstraint>();
testValue.add(expectedValue1);
field.populateField(testValue);
assertEquals(expectedValue1, field.getFeatureTypeConstraint().get(0));
field.setTestValue(FieldIdEnum.UNKNOWN, testValue);
assertEquals(expectedValue1, field.getFeatureTypeConstraint().get(0));
field.populateExpression((String) null);
}
示例22
@Test
public void testUndoActionSuppress() {
FieldConfigFeatureTypeConstraint field =
new FieldConfigFeatureTypeConstraint(
new FieldConfigCommonData(
Geometry.class, FieldIdEnum.NAME, "label", true, true));
field.createUI();
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
FeatureTypeConstraint expectedValue1 =
styleFactory.createFeatureTypeConstraint("Feature", Filter.INCLUDE, new Extent[0]);
List<FeatureTypeConstraint> testValue = new ArrayList<FeatureTypeConstraint>();
testValue.add(expectedValue1);
int undoListSize = UndoManager.getInstance().getUndoListSize();
field.populateField(testValue);
assertEquals(expectedValue1, field.getFeatureTypeConstraint().get(0));
FeatureTypeConstraint expectedValue2 =
styleFactory.createFeatureTypeConstraint("Feature2", Filter.INCLUDE, new Extent[0]);
List<FeatureTypeConstraint> testValue2 = new ArrayList<FeatureTypeConstraint>();
testValue2.add(expectedValue1);
testValue2.add(expectedValue2);
field.populateField(testValue2);
field.featureTypeConstraintUpdated();
assertEquals(undoListSize, UndoManager.getInstance().getUndoListSize());
}
示例23
/**
* Converts a style to its string representation to be written to file.
*
* @param style the style to convert.
* @return the style string.
* @throws Exception
*/
public static String styleToString( Style style ) throws Exception {
StyledLayerDescriptor sld = sf.createStyledLayerDescriptor();
UserLayer layer = sf.createUserLayer();
layer.setLayerFeatureConstraints(new FeatureTypeConstraint[]{null});
sld.addStyledLayer(layer);
layer.addUserStyle(style);
SLDTransformer aTransformer = new SLDTransformer();
aTransformer.setIndentation(4);
String xml = aTransformer.transform(sld);
return xml;
}
示例24
/**
* Converts a style to its string representation to be written to file.
*
* @param style the style to convert.
* @return the style string.
* @throws Exception
*/
public static String styleToString( Style style ) throws Exception {
StyledLayerDescriptor sld = sf.createStyledLayerDescriptor();
UserLayer layer = sf.createUserLayer();
layer.setLayerFeatureConstraints(new FeatureTypeConstraint[]{null});
sld.addStyledLayer(layer);
layer.addUserStyle(style);
SLDTransformer aTransformer = new SLDTransformer();
aTransformer.setIndentation(4);
String xml = aTransformer.transform(sld);
return xml;
}
示例25
/**
* Converts a style to its string representation to be written to file.
*
* @param style the style to convert.
* @return the style string.
* @throws Exception
*/
public String toXml() throws Exception {
StyledLayerDescriptor sld = sf.createStyledLayerDescriptor();
UserLayer layer = sf.createUserLayer();
layer.setLayerFeatureConstraints(new FeatureTypeConstraint[] { null });
sld.addStyledLayer(layer);
layer.addUserStyle(style);
SLDTransformer aTransformer = new SLDTransformer();
aTransformer.setIndentation(4);
String xml = aTransformer.transform(sld);
return xml;
}
示例26
/**
* Update symbol.
*
* @param changedField the changed field
*/
private void updateSymbol(FieldIdEnum changedField) {
if (!Controller.getInstance().isPopulating()) {
UserLayer userLayer = getStyleFactory().createUserLayer();
String name = fieldConfigVisitor.getText(FieldIdEnum.NAME);
userLayer.setName(name);
// Feature type constraints
List<FeatureTypeConstraint> ftcList =
fieldConfigVisitor.getFeatureTypeConstraint(
FieldIdEnum.LAYER_FEATURE_CONSTRAINTS);
if ((ftcList != null) && !ftcList.isEmpty()) {
FeatureTypeConstraint[] ftcArray = new FeatureTypeConstraint[ftcList.size()];
userLayer.setLayerFeatureConstraints(ftcList.toArray(ftcArray));
}
// Source
GroupConfigInterface group = getGroup(GroupIdEnum.USER_LAYER_SOURCE);
if (group != null) {
MultiOptionGroup userLayerSourceGroup = (MultiOptionGroup) group;
OptionGroup selectedOption = userLayerSourceGroup.getSelectedOptionGroup();
switch (selectedOption.getId()) {
case REMOTE_OWS_OPTION:
updateRemoteOWS(userLayer);
break;
case INLINE_FEATURE_OPTION:
updateInlineFeatureOption(userLayer);
break;
default:
break;
}
}
StyledLayer existingStyledLayer = SelectedSymbol.getInstance().getStyledLayer();
if (existingStyledLayer instanceof UserLayerImpl) {
UserLayerImpl existingUserLayer = (UserLayerImpl) existingStyledLayer;
for (Style style : existingUserLayer.userStyles()) {
userLayer.addUserStyle(style);
}
}
SelectedSymbol.getInstance().replaceStyledLayer(userLayer);
// Update inline data sources if the inline data changed,
// reduces creation of datasources
updateInLineFeature(changedField);
this.fireUpdateSymbol();
}
}
示例27
/**
* Test method for {@link
* com.sldeditor.ui.detail.config.FieldConfigBase#populateField(java.lang.String)}.
*/
@Test
public void testPopulateFieldString() {
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
String expectedLabel = "test label";
TestFieldConfigBase field =
new TestFieldConfigBase(
new FieldConfigCommonData(
String.class, expectedFieldId, expectedLabel, false, false));
field.populateField("");
field.setTestValue(expectedFieldId, "");
field.populateField(42);
field.setTestValue(expectedFieldId, 42);
assertEquals(0, field.getIntValue());
field.populateField(3.142);
field.setTestValue(expectedFieldId, 3.142);
assertTrue(Math.abs(field.getDoubleValue()) < 0.0001);
field.populateField(ZonedDateTime.now());
field.populateField((ReferencedEnvelope) null);
field.setTestValue(expectedFieldId, (ReferencedEnvelope) null);
field.populateField((Id) null);
field.populateField((TimePeriod) null);
field.populateField((ProcessFunction) null);
assertNull(field.getProcessFunction());
field.populateField(true);
field.setTestValue(expectedFieldId, true);
assertEquals(false, field.getBooleanValue());
field.populateField((ColorMap) null);
field.setTestValue(expectedFieldId, (ColorMap) null);
assertNull(field.getColourMap());
field.populateField((List<FeatureTypeConstraint>) null);
field.setTestValue(expectedFieldId, (List<FeatureTypeConstraint>) null);
assertNull(field.getFeatureTypeConstraint());
field.populateField((Font) null);
assertNull(field.getFont());
field.setTestValue(expectedFieldId, (Expression) null);
assertNull(field.getEnumValue());
}
示例28
/**
* Test method for {@link
* com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for {@link
* com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
FieldConfigFeatureTypeConstraint field =
new FieldConfigFeatureTypeConstraint(
new FieldConfigCommonData(
Geometry.class, FieldIdEnum.NAME, "label", true, false));
field.undoAction(null);
field.redoAction(null);
field.createUI();
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
FeatureTypeConstraint expectedValue1 =
styleFactory.createFeatureTypeConstraint("Feature", Filter.INCLUDE, new Extent[0]);
List<FeatureTypeConstraint> testValue = new ArrayList<FeatureTypeConstraint>();
testValue.add(expectedValue1);
field.populateField(testValue);
assertEquals(expectedValue1, field.getFeatureTypeConstraint().get(0));
FeatureTypeConstraint expectedValue2 =
styleFactory.createFeatureTypeConstraint("Feature2", Filter.INCLUDE, new Extent[0]);
List<FeatureTypeConstraint> testValue2 = new ArrayList<FeatureTypeConstraint>();
testValue2.add(expectedValue1);
testValue2.add(expectedValue2);
field.populateField(testValue2);
UndoManager.getInstance().undo();
assertEquals(1, field.getFeatureTypeConstraint().size());
assertEquals(expectedValue1, field.getFeatureTypeConstraint().get(0));
UndoManager.getInstance().redo();
assertEquals(2, field.getFeatureTypeConstraint().size());
assertEquals(expectedValue2, field.getFeatureTypeConstraint().get(1));
// Increase the code coverage
field.undoAction(null);
field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
field.redoAction(null);
field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
示例29
/**
* Test method for {@link
* com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel#populate(java.util.List)}.
* Test method for {@link
* com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel#removeEntries(int,
* int)}. Test method for {@link
* com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel#getFeatureTypeConstraint(int)}.
*/
@Test
public void testPopulate() {
TestModelUpdate testUpdate = new TestModelUpdate();
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
FeatureTypeConstraintModel model = new FeatureTypeConstraintModel(testUpdate);
List<FeatureTypeConstraint> ftcList = null;
model.populate(ftcList);
ftcList = new ArrayList<FeatureTypeConstraint>();
ftcList.add(
styleFactory.createFeatureTypeConstraint("ftc1", Filter.INCLUDE, new Extent[0]));
ftcList.add(
styleFactory.createFeatureTypeConstraint("ftc2", Filter.INCLUDE, new Extent[0]));
ftcList.add(
styleFactory.createFeatureTypeConstraint("ftc3", Filter.INCLUDE, new Extent[0]));
ftcList.add(
styleFactory.createFeatureTypeConstraint("ftc4", Filter.INCLUDE, new Extent[0]));
ftcList.add(
styleFactory.createFeatureTypeConstraint("ftc5", Filter.INCLUDE, new Extent[0]));
model.populate(ftcList);
List<FeatureTypeConstraint> actualList = model.getFeatureTypeConstraint();
assertEquals(5, actualList.size());
assertTrue(actualList.get(2).getFeatureTypeName().compareTo("ftc3") == 0);
assertFalse(testUpdate.hasFTCUpdatedBeenCalled());
model.removeEntries(-1, 2);
assertFalse(testUpdate.hasFTCUpdatedBeenCalled());
model.removeEntries(2, 22);
assertFalse(testUpdate.hasFTCUpdatedBeenCalled());
model.removeEntries(22, 2);
assertFalse(testUpdate.hasFTCUpdatedBeenCalled());
model.removeEntries(2, 2);
assertTrue(testUpdate.hasFTCUpdatedBeenCalled());
actualList = model.getFeatureTypeConstraint();
assertEquals(4, actualList.size());
assertTrue(actualList.get(2).getFeatureTypeName().compareTo("ftc4") == 0);
assertNull(model.getFeatureTypeConstraint(-1));
assertNull(model.getFeatureTypeConstraint(6));
FeatureTypeConstraint actualFTC = model.getFeatureTypeConstraint(1);
assertTrue(actualFTC.getFeatureTypeName().compareTo("ftc2") == 0);
}
示例30
/**
* Populate feature type constraint map field, overridden if necessary.
*
* @param value the value
*/
public void populateField(List<FeatureTypeConstraint> value);