use of com.sldeditor.ui.widgets.ValueComboBoxData 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;
}
use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.
the class MultiOptionGroup method optionSelected.
/**
* Option selected.
*
* @param box the box
* @param fieldConfigManager the field config manager
* @param panel the panel
* @param parentObj the parent obj
*/
private void optionSelected(Box box, GraphicPanelFieldManager fieldConfigManager, FieldPanel panel, UndoActionInterface parentObj) {
if ((comboBox != null) && (comboBox.getSelectedItem() != null)) {
ValueComboBoxData value = comboBox.getSelectedValue();
if (value != null) {
// Remove the fields from the previous selection
removeOptionFields(box, fieldConfigManager);
optionPanel = new JPanel();
optionPanel.setLayout(new BorderLayout());
Box optionBox = Box.createVerticalBox();
optionPanel.add(optionBox, BorderLayout.CENTER);
int index = findOptionPanel(box, panel);
OptionGroup optionGroup = optionMap.get(value.getKey());
populateOptionGroup(fieldConfigManager, optionBox, optionGroup.getGroupList());
box.add(optionPanel, index + 1);
Object newValueObj = value.getKey();
if ((oldValueObj == null) && (comboBox.getItemCount() > 0)) {
oldValueObj = comboBox.getFirstItem().getKey();
}
UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, "Multi option : " + getId(), oldValueObj, newValueObj));
oldValueObj = newValueObj;
box.revalidate();
}
}
}
use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.
the class MultiOptionGroup method createUI.
/**
* Creates the ui.
*
* @param fieldConfigManager the field config manager
* @param box the box
* @param parent the parent
* @param panelId the panel id
*/
public void createUI(GraphicPanelFieldManager fieldConfigManager, Box box, UpdateSymbolInterface parent, Class<?> panelId) {
final UndoActionInterface parentObj = this;
this.fieldConfigManager = fieldConfigManager;
this.parentBox = box;
this.parent = parent;
this.panelId = panelId;
int x = 2;
box.add(GroupConfig.createSeparator());
fieldPanel = new FieldPanel(0, "", BasePanel.WIDGET_HEIGHT * 2, false, null);
// Set up title
if (isOptional()) {
groupTitleCheckbox = new JCheckBox(getLabel());
groupTitleCheckbox.setBounds(x, 0, BasePanel.WIDGET_EXTENDED_WIDTH, BasePanel.WIDGET_HEIGHT);
groupTitleCheckbox.setOpaque(true);
fieldPanel.add(groupTitleCheckbox);
multiOptionGroupEnabled = false;
groupTitleCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
enable(groupTitleCheckbox.isSelected());
if (parent != null) {
if (!Controller.getInstance().isPopulating()) {
parent.dataChanged(FieldIdEnum.UNKNOWN);
}
}
}
});
} else {
JLabel groupTitle = new JLabel(getLabel());
groupTitle.setBounds(x, 0, BasePanel.WIDGET_EXTENDED_WIDTH, BasePanel.WIDGET_HEIGHT);
groupTitle.setOpaque(true);
fieldPanel.add(groupTitle);
}
// Set up options in the drop down
List<ValueComboBoxData> valueComboDataMap = new ArrayList<ValueComboBoxData>();
for (OptionGroup optionGroup : optionList) {
valueComboDataMap.add(new ValueComboBoxData(optionGroup.getId().toString(), optionGroup.getLabel(), panelId));
}
comboBox = new ValueComboBox();
comboBox.initialiseSingle(valueComboDataMap);
comboBox.setBounds(BasePanel.WIDGET_X_START, BasePanel.WIDGET_HEIGHT, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
fieldPanel.add(comboBox);
comboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
optionSelected(parentBox, fieldConfigManager, fieldPanel, parentObj);
if (parent != null) {
if (!Controller.getInstance().isPopulating()) {
parent.dataChanged(FieldIdEnum.UNKNOWN);
}
}
}
});
box.add(fieldPanel);
}
use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.
the class FieldConfigBoundingBox method createCRSList.
/**
* Creates the crs list.
*
* @param label the label
* @param xPos the x pos
* @param fieldPanel the field panel
* @param row the row
* @return the value combo box
*/
private ValueComboBox createCRSList(String label, int xPos, FieldPanel fieldPanel, int row) {
JLabel lbl = new JLabel(label);
lbl.setHorizontalAlignment(SwingConstants.TRAILING);
lbl.setBounds(xPos, getRowY(row), BasePanel.LABEL_WIDTH, BasePanel.WIDGET_HEIGHT);
fieldPanel.add(lbl);
// Populate data list
List<ValueComboBoxData> crsDataList = CoordManager.getInstance().getCRSList();
crsComboBox = new ValueComboBox();
crsComboBox.initialiseSingle(crsDataList);
crsComboBox.setBounds(xPos + BasePanel.WIDGET_X_START, getRowY(row), this.isValueOnly() ? BasePanel.WIDGET_EXTENDED_WIDTH : BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
fieldPanel.add(crsComboBox);
crsComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
valueUpdated();
}
});
return crsComboBox;
}
use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.
the class FieldConfigBoundingBox method getBBox.
/**
* Generates the bounding box from the ui.
*
* @return the b box
*/
private ReferencedEnvelope getBBox() {
if (xMinTextField == null) {
return null;
}
double minX = xMinTextField.getText().isEmpty() ? 0.0 : Double.valueOf(xMinTextField.getText());
double maxX = xMaxTextField.getText().isEmpty() ? 0.0 : Double.valueOf(xMaxTextField.getText());
double minY = yMinTextField.getText().isEmpty() ? 0.0 : Double.valueOf(yMinTextField.getText());
double maxY = yMaxTextField.getText().isEmpty() ? 0.0 : Double.valueOf(yMaxTextField.getText());
ValueComboBoxData crsDataValue = crsComboBox.getSelectedValue();
CoordinateReferenceSystem crs = null;
try {
if (crsDataValue != null) {
crs = CRS.decode(crsDataValue.getKey());
}
} catch (NoSuchAuthorityCodeException e) {
ConsoleManager.getInstance().exception(this, e);
} catch (FactoryException e) {
ConsoleManager.getInstance().exception(this, e);
}
ReferencedEnvelope envelope = new ReferencedEnvelope(minX, maxX, minY, maxY, crs);
return envelope;
}
Aggregations