use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class PrefManager method setPrefData.
/**
* Sets the pref data.
*
* @param newPrefData the new pref data
*/
public void setPrefData(PrefData newPrefData) {
oldValueObj = prefData.clone();
setUseAntiAlias(newPrefData.isUseAntiAlias());
setVendorOptionList(newPrefData.getVendorOptionVersionList(), true);
setUiLayoutClass(newPrefData.getUiLayoutClass());
setBackgroundColour(newPrefData.getBackgroundColour());
setLastFolderViewed(newPrefData.isSaveLastFolderView(), newPrefData.getLastViewedKey(), newPrefData.getLastFolderViewed());
setCheckAppVersionOnStartUp(newPrefData.isCheckAppVersionOnStartUp());
UndoManager.getInstance().addUndoEvent(new UndoEvent(this, "Preferences", oldValueObj, newPrefData));
}
use of com.sldeditor.common.undo.UndoEvent 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.UndoEvent 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.UndoEvent 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.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigBoolean method populateField.
/**
* Populate field.
*
* @param value the value
*/
@Override
public void populateField(Boolean value) {
if ((value != null) && (this.checkBox != null)) {
checkBox.setSelected(value);
UndoManager.getInstance().addUndoEvent(new UndoEvent(this, getFieldId(), oldValueObj, value));
oldValueObj = value;
}
}
Aggregations