Search in sources :

Example 1 with ValueComboBoxDataGroup

use of com.sldeditor.ui.widgets.ValueComboBoxDataGroup in project sldeditor by robward-scisys.

the class FieldConfigSymbolTypeTest method testGenerateExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#generateExpression()}. Test
 * method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#populateField(java.lang.String)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#getEnumValue()}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#FieldConfigSymbolType(java.lang.Class, com.sldeditor.ui.detail.config.FieldId, java.lang.String, boolean)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#getStringValue()}. Test method
 * for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#addField(com.sldeditor.ui.detail.config.symboltype.SymbolTypeInterface)}.
 */
@Test
public void testGenerateExpression() {
    boolean valueOnly = true;
    FieldConfigSymbolType field = new FieldConfigSymbolType(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    field.populateExpression(null);
    field.setTestValue(FieldIdEnum.UNKNOWN, (String) null);
    assertNull(field.getEnumValue());
    assertNull(field.getSelectedValueObj());
    assertNull(field.getSelectedValue());
    field.createUI();
    String expectedValue1 = "circle";
    field.populateExpression(expectedValue1);
    String actualValue1 = field.getStringValue();
    assertNull(actualValue1);
    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", String.class));
    dataList.add(new ValueComboBoxData("key 2", "Value 2", Integer.class));
    dataList.add(new ValueComboBoxData("key 3", "Value 3", Boolean.class));
    List<ValueComboBoxDataGroup> combinedSymbolList = new ArrayList<ValueComboBoxDataGroup>();
    combinedSymbolList.add(new ValueComboBoxDataGroup(dataList));
    field.createUI();
    field.addField(marker);
    field.populate(null, combinedSymbolList);
    field.populateExpression(expectedValue1);
    actualValue1 = field.getStringValue();
    assertNull(actualValue1);
    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.setTestValue(null, 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);
    String expectedValue5 = "key 2";
    field.setSelectedItem(expectedValue5);
    String actualValue5 = field.getStringValue();
    assertTrue(expectedValue5.compareTo(actualValue5) == 0);
    ValueComboBoxData actualValueObj5 = field.getSelectedValueObj();
    assertNotNull(actualValueObj5.getKey());
    assertTrue(actualValueObj5.getKey().compareTo(expectedValue5) == 0);
    Class<?> actualValue6 = field.getSelectedValue();
    assertEquals(Integer.class, actualValue6);
}
Also used : ValueComboBoxDataGroup(com.sldeditor.ui.widgets.ValueComboBoxDataGroup) ArrayList(java.util.ArrayList) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) FieldConfigMarker(com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigSymbolType(com.sldeditor.ui.detail.config.FieldConfigSymbolType) Test(org.junit.Test)

Example 2 with ValueComboBoxDataGroup

use of com.sldeditor.ui.widgets.ValueComboBoxDataGroup in project sldeditor by robward-scisys.

the class VendorOptionMenuUtils method createMenu.

/**
 * Creates the menu.
 *
 * @param versionDataList the list version data
 * @return the list
 */
public static List<ValueComboBoxDataGroup> createMenu(List<VersionData> versionDataList) {
    if (dataSelectionList.isEmpty()) {
        Map<String, List<ValueComboBoxData>> map = new HashMap<String, List<ValueComboBoxData>>();
        List<String> keyOrderList = new ArrayList<String>();
        if (versionDataList != null) {
            for (VersionData versionData : versionDataList) {
                String key = getKey(versionData);
                List<ValueComboBoxData> dataList = map.get(key);
                if (dataList == null) {
                    dataList = new ArrayList<ValueComboBoxData>();
                    map.put(key, dataList);
                    keyOrderList.add(key);
                }
                VendorOptionVersion vendorOptionVersion = new VendorOptionVersion(versionData.getVendorOptionType(), versionData);
                ValueComboBoxData value = new ValueComboBoxData(versionData.getVersionString(), versionData.getVersionString(), vendorOptionVersion, String.class);
                dataList.add(value);
                valueMap.put(versionData.getVersionString(), value);
            }
            // Add groups to menu combo
            for (String key : keyOrderList) {
                List<ValueComboBoxData> dataList = map.get(key);
                ValueComboBoxDataGroup group = new ValueComboBoxDataGroup(key + ".x", dataList, (dataList.size() > 1));
                dataSelectionList.add(group);
            }
        }
    }
    return dataSelectionList;
}
Also used : ValueComboBoxDataGroup(com.sldeditor.ui.widgets.ValueComboBoxDataGroup) HashMap(java.util.HashMap) VersionData(com.sldeditor.common.vendoroption.VersionData) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 3 with ValueComboBoxDataGroup

use of com.sldeditor.ui.widgets.ValueComboBoxDataGroup in project sldeditor by robward-scisys.

the class SymbolTypeFactory method internal_populate.

/**
 * Internal populate.
 *
 * @param basePanel the base panel
 * @param multiOptionSelected the multi option selected
 * @param updateSymbol the update symbol
 * @param selectionField the selection field
 * @param fieldConfigManager the field config manager
 */
private void internal_populate(BasePanel basePanel, MultiOptionSelectedInterface multiOptionSelected, UpdateSymbolInterface updateSymbol, FieldIdEnum selectionField, GraphicPanelFieldManager fieldConfigManager) {
    List<ValueComboBoxDataGroup> combinedSymbolList = new ArrayList<ValueComboBoxDataGroup>();
    /**
     * Populate symbol type list. Given a panel details class iterate over all the field panels
     * asking them to populate the symbol type list.
     */
    for (FieldState panel : symbolTypeFieldList) {
        panel.populateSymbolList(basePanel.getClass(), combinedSymbolList);
    }
    FieldConfigBase field = fieldConfigManager.get(selectionField);
    this.symbolTypeField = (FieldConfigSymbolType) field;
    symbolTypeField.populate(multiOptionSelected, combinedSymbolList);
    for (FieldState panel : symbolTypeFieldList) {
        panel.setUpdateSymbolListener(updateSymbol);
        classMap.put(panel.getClass(), panel);
        this.symbolTypeField.addField(panel);
        basePanel.updateFieldConfig(panel.getBasePanel());
        // Transfer all the fields in the child panels into this panel
        Map<FieldIdEnum, FieldConfigBase> map = panel.getFieldList(fieldConfigManager);
        if (map != null) {
            for (FieldIdEnum panelField : map.keySet()) {
                fieldConfigManager.add(panelField, map.get(panelField));
            }
        }
    }
}
Also used : ValueComboBoxDataGroup(com.sldeditor.ui.widgets.ValueComboBoxDataGroup) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) ArrayList(java.util.ArrayList) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum)

Example 4 with ValueComboBoxDataGroup

use of com.sldeditor.ui.widgets.ValueComboBoxDataGroup in project sldeditor by robward-scisys.

the class MenuComboBox method createMenu.

/**
 * Creates the menu.
 *
 * @param listAll the list all
 * @return the combo menu
 */
private ComboMenu createMenu(List<ValueComboBoxDataGroup> listAll) {
    ComboMenu menu = new ComboMenu("");
    if (listAll != null) {
        for (ValueComboBoxDataGroup group : listAll) {
            if (group.isSubMenu()) {
                JMenu subMenu = new JMenu(group.getGroupName());
                for (ValueComboBoxData data : group.getDataList()) {
                    if (VendorOptionManager.getInstance().isAllowed(vendorOptionVersionsList, data.getVendorOption())) {
                        ComboMenuItem menuItem = new ComboMenuItem(data);
                        subMenu.add(menuItem);
                        dataMap.put(data.getKey(), data);
                        if (firstValue == null) {
                            firstValue = data;
                        }
                    }
                }
                if (subMenu.getMenuComponentCount() > 1) {
                    menu.add(subMenu);
                }
            } else {
                for (ValueComboBoxData data : group.getDataList()) {
                    if (VendorOptionManager.getInstance().isAllowed(vendorOptionVersionsList, data.getVendorOption())) {
                        ComboMenuItem menuItem = new ComboMenuItem(data);
                        menu.add(menuItem);
                        dataMap.put(data.getKey(), data);
                        if (firstValue == null) {
                            firstValue = data;
                        }
                    }
                }
            }
        }
    }
    return menu;
}
Also used : ValueComboBoxDataGroup(com.sldeditor.ui.widgets.ValueComboBoxDataGroup) JMenu(javax.swing.JMenu) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 5 with ValueComboBoxDataGroup

use of com.sldeditor.ui.widgets.ValueComboBoxDataGroup in project sldeditor by robward-scisys.

the class MenuComboBox method main.

/**
 * The main method.
 *
 * @param args the arguments
 */
public static void main(String[] args) {
    try {
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception evt) {
    // Do nothing
    }
    List<ValueComboBoxData> list1 = new ArrayList<ValueComboBoxData>();
    list1.add(new ValueComboBoxData("circle", "Circle", MenuComboBox.class));
    ValueComboBoxData square = new ValueComboBoxData("square", "Square", MenuComboBox.class);
    list1.add(square);
    list1.add(new ValueComboBoxData("triangle", "Triangle", MenuComboBox.class));
    List<ValueComboBoxData> list2 = new ArrayList<ValueComboBoxData>();
    list2.add(new ValueComboBoxData("shp://lArrow", "shp://lArrow", MenuComboBox.class));
    list2.add(new ValueComboBoxData("shp://star", "shp://star", MenuComboBox.class));
    list2.add(new ValueComboBoxData("shp://dot", "shp://dot", MenuComboBox.class));
    List<ValueComboBoxDataGroup> listAll = new ArrayList<ValueComboBoxDataGroup>();
    listAll.add(new ValueComboBoxDataGroup("", list1, false));
    listAll.add(new ValueComboBoxDataGroup("Shapes", list2, true));
    MenuComboBox comboMenu = new MenuComboBox(null);
    comboMenu.initialiseMenu(listAll);
    comboMenu.setSelectedData(square);
    JFrame frame = new JFrame();
    JPanel panel = new JPanel();
    panel.add(comboMenu);
    frame.getContentPane().setLayout(new FlowLayout());
    frame.getContentPane().add(panel);
    frame.addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    frame.setSize(370, 100);
    frame.setVisible(true);
}
Also used : ValueComboBoxDataGroup(com.sldeditor.ui.widgets.ValueComboBoxDataGroup) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) ArrayList(java.util.ArrayList) WindowAdapter(java.awt.event.WindowAdapter) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

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