Search in sources :

Example 6 with ValueComboBoxDataGroup

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());
}
Also used : ValueComboBoxDataGroup(com.sldeditor.ui.widgets.ValueComboBoxDataGroup) GeoServerVendorOption(com.sldeditor.common.vendoroption.GeoServerVendorOption) VersionData(com.sldeditor.common.vendoroption.VersionData) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with ValueComboBoxDataGroup

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);
        }
    }
}
Also used : ValueComboBoxDataGroup(com.sldeditor.ui.widgets.ValueComboBoxDataGroup) ArrayList(java.util.ArrayList) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 8 with ValueComboBoxDataGroup

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;
}
Also used : ValueComboBoxDataGroup(com.sldeditor.ui.widgets.ValueComboBoxDataGroup) MenuComboBox(com.sldeditor.ui.menucombobox.MenuComboBox) VersionData(com.sldeditor.common.vendoroption.VersionData)

Example 9 with ValueComboBoxDataGroup

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));
}
Also used : ValueComboBoxDataGroup(com.sldeditor.ui.widgets.ValueComboBoxDataGroup) FieldConfigMarker(com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker) ExternalGraphicImpl(org.geotools.styling.ExternalGraphicImpl) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) StyleBuilder(org.geotools.styling.StyleBuilder) ArrayList(java.util.ArrayList) Mark(org.geotools.styling.Mark) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) Test(org.junit.Test)

Example 10 with ValueComboBoxDataGroup

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);
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) ValueComboBoxDataGroup(com.sldeditor.ui.widgets.ValueComboBoxDataGroup) FieldConfigMarker(com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) ArrayList(java.util.ArrayList) FieldConfigSymbolType(com.sldeditor.ui.detail.config.FieldConfigSymbolType) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) Test(org.junit.Test)

Aggregations

ValueComboBoxDataGroup (com.sldeditor.ui.widgets.ValueComboBoxDataGroup)10 ArrayList (java.util.ArrayList)8 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)7 Test (org.junit.Test)4 VersionData (com.sldeditor.common.vendoroption.VersionData)3 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)3 FieldConfigMarker (com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker)3 FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)2 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 GeoServerVendorOption (com.sldeditor.common.vendoroption.GeoServerVendorOption)1 VendorOptionVersion (com.sldeditor.common.vendoroption.VendorOptionVersion)1 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)1 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)1 MenuComboBox (com.sldeditor.ui.menucombobox.MenuComboBox)1 FlowLayout (java.awt.FlowLayout)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 HashMap (java.util.HashMap)1 List (java.util.List)1 JFrame (javax.swing.JFrame)1