use of com.sldeditor.ui.widgets.ValueComboBox in project sldeditor by robward-scisys.
the class FieldConfigEnum method createUI.
/**
* Creates the ui.
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
*/
@Override
public void createUI() {
if (comboBox == null) {
final UndoActionInterface parentObj = this;
List<ValueComboBoxData> dataList = new ArrayList<ValueComboBoxData>();
for (String key : keyList) {
dataList.add(new ValueComboBoxData(key, valueMap.get(key), getPanelId()));
}
if (!dataList.isEmpty()) {
defaultValue = dataList.get(0).getKey();
}
int xPos = getXPos();
comboBox = new ValueComboBox();
comboBox.initialiseSingle(dataList);
comboBox.setBounds(xPos + BasePanel.WIDGET_X_START, 0, isValueOnly() ? BasePanel.WIDGET_EXTENDED_WIDTH : BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
FieldPanel fieldPanel = createFieldPanel(xPos, getLabel());
fieldPanel.add(comboBox);
if (!isValueOnly()) {
setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(String.class, this, isRasterSymbol()));
}
if (dataList != null) {
for (ValueComboBoxData data : dataList) {
this.comboDataMap.put(data.getKey(), data);
}
}
comboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ValueComboBox comboBox = (ValueComboBox) e.getSource();
if (comboBox.getSelectedItem() != null) {
Object newValueObj = comboBox.getSelectedValue().getKey();
if ((oldValueObj == null) && comboBox.getItemCount() > 0) {
oldValueObj = comboBox.getFirstItem().getKey();
}
UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
oldValueObj = newValueObj;
valueUpdated();
}
}
});
}
}
use of com.sldeditor.ui.widgets.ValueComboBox in project sldeditor by robward-scisys.
the class SLDTextArea method makeTextAreaPanel.
/**
* Make text area panel.
*
* @return the j component
*/
private JPanel makeTextAreaPanel() {
JPanel sldSourcePanel = new JPanel(false);
sldSourcePanel.setLayout(new BorderLayout());
List<ValueComboBoxData> dataList = new ArrayList<ValueComboBoxData>();
dataList.add(new ValueComboBoxData(SLDOutputFormatEnum.SLD.name(), "SLD", VendorOptionManager.getInstance().getDefaultVendorOptionVersion()));
dataList.add(new ValueComboBoxData(SLDOutputFormatEnum.YSLD.name(), "YSLD", VendorOptionManager.getInstance().getDefaultVendorOptionVersion()));
/*
* Code to be uncommented to used when gt-mbstyles becomes a supported module.
*
* dataList.add(new ValueComboBoxData(SLDOutputFormatEnum.MAPBOX.name(), "MapBox",
* VendorOptionManager.getInstance().getDefaultVendorOptionVersion()));
*/
// Options panel
JPanel optionsPanel = new JPanel();
JLabel label = new JLabel(Localisation.getField(SLDTextArea.class, "SLDTextArea.format"));
optionsPanel.add(label);
comboBox = new ValueComboBox();
comboBox.setPreferredSize(new Dimension(BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT));
comboBox.initialiseSingle(dataList);
comboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ValueComboBox comboBox = (ValueComboBox) e.getSource();
if (comboBox.getSelectedItem() != null) {
String name = comboBox.getSelectedValue().getKey();
outputFormat = SLDOutputFormatEnum.valueOf(SLDOutputFormatEnum.class, name);
outputText();
}
}
});
optionsPanel.add(comboBox);
sldSourcePanel.add(optionsPanel, BorderLayout.NORTH);
// Scroll pane
JScrollPane scrollPane = new JScrollPane();
sldSourcePanel.add(scrollPane);
sldSourceTextArea = new JTextArea();
scrollPane.setViewportView(sldSourceTextArea);
sldSourceTextArea.setEditable(false);
sldSourceTextArea.setWrapStyleWord(true);
sldSourceTextArea.setLineWrap(true);
sldSourcePanel.add(scrollPane, BorderLayout.CENTER);
return sldSourcePanel;
}
use of com.sldeditor.ui.widgets.ValueComboBox in project sldeditor by robward-scisys.
the class ColourRampPanel method createTopPanel.
/**
* Creates the top panel.
*/
private void createTopPanel() {
final UndoActionInterface undoObj = this;
JPanel topPanel = new JPanel();
topPanel.setPreferredSize(new Dimension(BasePanel.FIELD_PANEL_WIDTH, BasePanel.WIDGET_HEIGHT));
topPanel.setLayout(null);
panel.add(topPanel, BorderLayout.NORTH);
List<ValueComboBoxData> dataList = populateColourRamps(false);
rampComboBox = new ValueComboBox();
rampComboBox.initialiseSingle(dataList);
rampComboBox.setBounds(BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_EXTENDED_WIDTH, BasePanel.WIDGET_HEIGHT);
topPanel.add(rampComboBox);
rampComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!isPopulating()) {
Integer newValueObj = rampComboBox.getSelectedIndex();
UndoManager.getInstance().addUndoEvent(new UndoEvent(undoObj, FieldIdEnum.COLOUR_RAMP_COLOUR, oldColourRampIndex, newValueObj));
oldColourRampIndex = newValueObj;
}
}
});
reverseCheckbox = new JCheckBox(Localisation.getString(ColourRampConfigPanel.class, "ColourRampPanel.reverse"));
reverseCheckbox.setBounds(rampComboBox.getX() + rampComboBox.getWidth() + 20, 0, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
reverseCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean isSelected = reverseCheckbox.isSelected();
Boolean oldValueObj = Boolean.valueOf(!isSelected);
Boolean newValueObj = Boolean.valueOf(isSelected);
UndoManager.getInstance().addUndoEvent(new UndoEvent(undoObj, FieldIdEnum.COLOUR_RAMP_REVERSE, oldValueObj, newValueObj));
reverseColourRamp(isSelected);
}
});
topPanel.add(reverseCheckbox);
}
Aggregations