use of com.sldeditor.common.undo.UndoActionInterface in project sldeditor by robward-scisys.
the class DataSourceConfigPanel method createTable.
/**
* Creates the table.
*
* @return the component
*/
private Component createTable() {
final UndoActionInterface parentObj = this;
dataModel = new DataSourceAttributeModel();
dataModel.addTableModelListener(new TableModelListener() {
/**
* Table changed.
*
* @param arg0 the arg0
*/
@Override
public void tableChanged(TableModelEvent arg0) {
if (!isPopulatingTable()) {
dataChanged = true;
updateButtonState();
}
}
});
table = new JTable();
table.setModel(dataModel);
table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent arg0) {
updateButtonState();
}
});
TableColumn tmpColum = table.getColumnModel().getColumn(1);
JComboBox<String> comboBox = new JComboBox<String>(dataModel.getTypeData());
DefaultCellEditor defaultCellEditor = new DefaultCellEditor(comboBox);
tmpColum.setCellEditor(defaultCellEditor);
tmpColum.setCellRenderer(new ComboBoxCellRenderer(comboBox));
JPanel buttonPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) buttonPanel.getLayout();
flowLayout.setHgap(1);
flowLayout.setAlignment(FlowLayout.TRAILING);
add(buttonPanel, BorderLayout.SOUTH);
btnDisconnect = new JButton(Localisation.getString(DataSourceConfigPanel.class, "DataSourceConfigPanel.disconnect"));
btnDisconnect.setEnabled(false);
btnDisconnect.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
SLDEditorFile.getInstance().getSLDData().setDataSourceProperties(DataSourceConnectorFactory.getNoDataSource());
applyData(parentObj);
}
});
buttonPanel.add(btnDisconnect);
btnAddField = new JButton(Localisation.getString(DataSourceConfigPanel.class, "DataSourceConfigPanel.add"));
btnAddField.setEnabled(false);
btnAddField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
addNewField();
}
});
buttonPanel.add(btnAddField);
btnRemoveField = new JButton(Localisation.getString(DataSourceConfigPanel.class, "DataSourceConfigPanel.remove"));
btnRemoveField.setEnabled(false);
btnRemoveField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
removeField();
}
});
buttonPanel.add(btnRemoveField);
btnApply = new JButton(Localisation.getString(DataSourceConfigPanel.class, "common.apply"));
btnApply.setEnabled(false);
btnApply.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
applyData(parentObj);
}
});
buttonPanel.add(btnApply);
btnCancel = new JButton(Localisation.getString(DataSourceConfigPanel.class, "common.cancel"));
btnCancel.setEnabled(false);
btnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
cancelData();
}
});
buttonPanel.add(btnCancel);
JScrollPane scrollPane = new JScrollPane(table);
return scrollPane;
}
use of com.sldeditor.common.undo.UndoActionInterface in project sldeditor by robward-scisys.
the class AttributeSelection method createUI.
/**
* Creates the ui.
*
* @param expectedDataType the expected data type
*/
@SuppressWarnings({ "unchecked" })
private void createUI(Class<?> expectedDataType) {
final UndoActionInterface thisObj = this;
outerPanel = new JPanel();
add(outerPanel, BorderLayout.CENTER);
outerPanel.setLayout(new CardLayout(5, 0));
valuePanel = createValuePanel(false);
expressionPanel = createExpressionPanel(expectedDataType);
dataSourceAttributePanel = createDataSourceAttributePanel(expectedDataType);
attributeChooserComboBox = new JComboBox<String>();
attributeChooserComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JComboBox<String> cb = (JComboBox<String>) e.getSource();
String selected = (String) cb.getSelectedItem();
showPanel(selected);
if ((oldValueObj == null) && cb.getItemCount() > 0) {
oldValueObj = cb.getItemAt(0);
}
UndoManager.getInstance().addUndoEvent(new UndoEvent(thisObj, "DataSourceAttribute", oldValueObj, selected));
updateSymbol();
}
});
add(attributeChooserComboBox, BorderLayout.WEST);
}
use of com.sldeditor.common.undo.UndoActionInterface in project sldeditor by robward-scisys.
the class GroupConfig method createTitle.
/**
* Creates the title components.
*
* @param box the box to add the components to
* @param parent the parent object to be called when fields are changed
*/
@Override
public void createTitle(Box box, UpdateSymbolInterface parent) {
this.parentBox = box;
if (isShowLabel()) {
Component separator = createSeparator();
componentList.add(createSeparator());
box.add(separator);
Component component;
if (isOptional()) {
final UndoActionInterface parentObj = this;
groupCheckbox = new JCheckBox(getLabel());
component = groupCheckbox;
groupCheckbox.setBounds(0, 0, FULL_WIDTH, BasePanel.WIDGET_HEIGHT);
groupCheckbox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
enableSubGroups(groupCheckbox.isSelected());
boolean isSelected = groupCheckbox.isSelected();
Boolean oldValueObj = Boolean.valueOf(!isSelected);
Boolean newValueObj = Boolean.valueOf(isSelected);
UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, "Group : " + getId(), oldValueObj, newValueObj));
if (parent != null) {
parent.dataChanged(FieldIdEnum.UNKNOWN);
}
}
});
} else {
groupTitle = new JLabel(getLabel());
groupTitle.setBounds(0, 0, FULL_WIDTH, BasePanel.WIDGET_HEIGHT);
groupTitle.setOpaque(true);
component = groupTitle;
}
// Make sure label/check box appears left aligned within the group
JPanel panel = new JPanel();
panel.setLayout(null);
Dimension size = new Dimension(FULL_WIDTH, BasePanel.WIDGET_HEIGHT);
panel.setPreferredSize(size);
panel.setMaximumSize(size);
panel.setSize(size);
panel.add(component);
box.add(panel);
componentList.add(panel);
}
}
use of com.sldeditor.common.undo.UndoActionInterface 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.common.undo.UndoActionInterface in project sldeditor by robward-scisys.
the class FieldConfigBoolean method createUI.
/**
* Creates the ui.
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
*/
@Override
public void createUI() {
if (checkBox == null) {
final UndoActionInterface parentObj = this;
int xPos = getXPos();
FieldPanel fieldPanel = createFieldPanel(xPos, getLabel());
checkBox = new JCheckBox("");
checkBox.setBounds(xPos + BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
fieldPanel.add(checkBox);
checkBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
boolean isSelected = checkBox.isSelected();
Boolean oldValueObj = Boolean.valueOf(!isSelected);
Boolean newValueObj = Boolean.valueOf(isSelected);
UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
valueUpdated();
}
});
if (!isValueOnly()) {
setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(Boolean.class, this, isRasterSymbol()));
}
}
}
Aggregations