use of com.sldeditor.ui.widgets.ValueComboBoxDataGroup in project sldeditor by robward-scisys.
the class VendorOptionMenuUtilsTest method testSetSelected.
/**
* Test method for
* {@link com.sldeditor.common.vendoroption.selection.VendorOptionMenuUtils#setSelected(com.sldeditor.ui.menucombobox.MenuComboBox, com.sldeditor.common.vendoroption.VersionData)}.
*/
@Test
public void testSetSelected() {
VendorOptionMenuUtils.setSelected(null, null);
List<VersionData> listVersionData = new ArrayList<VersionData>();
listVersionData.add(VersionData.decode(GeoServerVendorOption.class, "1.3.1"));
VersionData expectedVersionData1 = VersionData.decode(GeoServerVendorOption.class, "1.2.0");
listVersionData.add(expectedVersionData1);
listVersionData.add(VersionData.decode(GeoServerVendorOption.class, "1.3.99"));
listVersionData.add(VersionData.decode(GeoServerVendorOption.class, "1.4.5"));
listVersionData.add(VersionData.decode(GeoServerVendorOption.class, "1.4.1"));
listVersionData.add(VersionData.decode(GeoServerVendorOption.class, "1.3.3"));
listVersionData.add(VendorOptionManager.getInstance().getDefaultVendorOptionVersionData());
// Expecting:
// Not Set
// 1.2.0
// 1.3.x - 1.3.1, 1.3.3, 1.3.99
// 1.4.x - 1.4.1, 1.4.5
@SuppressWarnings("unused") List<ValueComboBoxDataGroup> actual = VendorOptionMenuUtils.createMenu(listVersionData);
VendorOptionMenuUtils.setSelected(null, expectedVersionData1);
VendorOptionMenuUtils.setSelected(null, VendorOptionManager.getInstance().getDefaultVendorOptionVersionData());
}
use of com.sldeditor.ui.widgets.ValueComboBoxDataGroup in project sldeditor by robward-scisys.
the class FieldState method populateSymbolList.
/**
* Populate symbol list.
*
* @param panelDetails the panel details the configuration is for
* @param symbolList the symbol list
*/
public void populateSymbolList(Class<?> panelDetails, List<ValueComboBoxDataGroup> symbolList) {
List<SymbolTypeConfig> configList = getFieldMap().get(panelDetails);
if (configList == null) {
ConsoleManager.getInstance().error(this, "No config for panel details class : " + panelDetails.getName());
} else {
if (localSymbolList == null) {
localSymbolList = new ArrayList<ValueComboBoxData>();
} else {
localSymbolList.clear();
}
for (SymbolTypeConfig config : configList) {
List<ValueComboBoxData> groupSymbolList = new ArrayList<ValueComboBoxData>();
for (String key : config.getKeyOrderList()) {
ValueComboBoxData data = new ValueComboBoxData(key, config.getTitle(key), this.getVendorOption(), config.getPanelId());
groupSymbolList.add(data);
}
symbolList.add(new ValueComboBoxDataGroup(config.getGroupName(), groupSymbolList, config.isSeparateGroup()));
localSymbolList.addAll(groupSymbolList);
}
}
}
use of com.sldeditor.ui.widgets.ValueComboBoxDataGroup in project sldeditor by robward-scisys.
the class VersionCellEditor method getTableCellEditorComponent.
/*
* (non-Javadoc)
*
* @see javax.swing.table.TableCellEditor#getTableCellEditorComponent(javax.swing.JTable,
* java.lang.Object, boolean, int, int)
*/
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
selectedRowIndex = row;
if (value instanceof VersionData) {
this.versionData = (VersionData) value;
}
listVersionData = model.getVendorOption(row);
MenuComboBox comboVersionData = new MenuComboBox(this);
List<ValueComboBoxDataGroup> dataSelectionList = VendorOptionMenuUtils.createMenu(listVersionData);
comboVersionData.vendorOptionsUpdated(listVersionData);
comboVersionData.initialiseMenu(dataSelectionList);
VendorOptionMenuUtils.setSelected(comboVersionData, this.versionData);
if (isSelected) {
comboVersionData.setBackground(table.getSelectionBackground());
} else {
comboVersionData.setBackground(table.getSelectionForeground());
}
return comboVersionData;
}
use of com.sldeditor.ui.widgets.ValueComboBoxDataGroup in project sldeditor by robward-scisys.
the class FieldConfigMarkerTest method testAccept.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker#accept(org.opengis.style.GraphicalSymbol)}.
*/
@Test
public void testAccept() {
boolean valueOnly = true;
FieldConfigMarker field = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), null, null, null);
assertFalse(field.accept(null));
StyleBuilder styleBuilder = new StyleBuilder();
ExternalGraphicImpl externalGraphic = (ExternalGraphicImpl) styleBuilder.createExternalGraphic("test.tmp", "png");
assertFalse(field.accept(externalGraphic));
Mark marker = styleBuilder.createMark("triangle");
assertFalse(field.accept(marker));
List<ValueComboBoxData> dataList = new ArrayList<ValueComboBoxData>();
dataList.add(new ValueComboBoxData("star", "Star", this.getClass()));
dataList.add(new ValueComboBoxData("square", "Square", this.getClass()));
dataList.add(new ValueComboBoxData("triangle", "Triangle", this.getClass()));
List<ValueComboBoxDataGroup> groupList = new ArrayList<ValueComboBoxDataGroup>();
groupList.add(new ValueComboBoxDataGroup(dataList));
field.populateSymbolList(String.class, groupList);
field.populateSymbolList(PointFillDetails.class, groupList);
assertTrue(field.accept(marker));
field.populateSymbolList(PointFillDetails.class, groupList);
assertTrue(field.accept(marker));
}
use of com.sldeditor.ui.widgets.ValueComboBoxDataGroup in project sldeditor by robward-scisys.
the class FieldConfigSymbolTypeTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
UndoManager.getInstance().setPopulationCheck(Controller.getInstance());
boolean valueOnly = true;
FieldConfigSymbolType field = new FieldConfigSymbolType(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
field.undoAction(null);
field.redoAction(null);
field.createUI();
field.createUI();
FieldConfigMarker marker = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.ANGLE, "label", valueOnly), null, null, null);
marker.createUI();
List<ValueComboBoxData> dataList = new ArrayList<ValueComboBoxData>();
dataList.add(new ValueComboBoxData("key 1", "Value 1", FieldConfigMarker.class));
dataList.add(new ValueComboBoxData("key 2", "Value 2", FieldConfigMarker.class));
dataList.add(new ValueComboBoxData("key 3", "Value 3", FieldConfigMarker.class));
List<ValueComboBoxDataGroup> combinedSymbolList = new ArrayList<ValueComboBoxDataGroup>();
combinedSymbolList.add(new ValueComboBoxDataGroup(dataList));
field.createUI();
field.addField(marker);
field.populate(null, combinedSymbolList);
String expectedValue2 = "key 2";
field.populateExpression(expectedValue2);
String actualValue2 = field.getStringValue();
assertTrue(actualValue2.compareTo(field.getStringValue()) == 0);
ValueComboBoxData actualValueObj2 = field.getEnumValue();
assertNotNull(actualValueObj2.getKey());
assertTrue(actualValueObj2.getKey().compareTo(expectedValue2) == 0);
String expectedValue3 = "key 1";
field.populateField(expectedValue3);
String actualValue3 = field.getStringValue();
assertTrue(expectedValue3.compareTo(actualValue3) == 0);
String expectedValue4 = "key 3";
field.populateField(expectedValue4);
String actualValue4 = field.getStringValue();
assertTrue(expectedValue4.compareTo(actualValue4) == 0);
UndoManager.getInstance().undo();
String actualValue = field.getStringValue();
assertTrue(expectedValue3.compareTo(actualValue) == 0);
UndoManager.getInstance().redo();
actualValue = field.getStringValue();
assertTrue(expectedValue4.compareTo(actualValue) == 0);
// Increase the code coverage
field.undoAction(null);
field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(23)));
field.redoAction(null);
field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(54)));
UndoManager.getInstance().setPopulationCheck(null);
}
Aggregations