use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigTransformation method createUI.
/**
* Creates the ui.
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
*/
@Override
public void createUI() {
if (textField == null) {
final UndoActionInterface parentObj = this;
int xPos = getXPos();
int width = BasePanel.FIELD_PANEL_WIDTH - xPos - 20;
int height = BasePanel.WIDGET_HEIGHT * (NO_OF_ROWS - 1);
textField = new JTextArea();
textField.setBounds(xPos, BasePanel.WIDGET_HEIGHT, width, height);
textField.setEditable(false);
JScrollPane scroll = new JScrollPane(textField);
scroll.setBounds(xPos, BasePanel.WIDGET_HEIGHT, width, height);
scroll.setAutoscrolls(true);
FieldPanel fieldPanel = createFieldPanel(xPos, BasePanel.WIDGET_HEIGHT * NO_OF_ROWS, getLabel());
fieldPanel.add(scroll);
//
// Edit button
//
final JButton buttonEdit = new JButton(editButtonText);
buttonEdit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ProcessFunction expression = showTransformationDialog(processFunction);
if (expression != null) {
ProcessFunction newValueObj = processFunction;
processFunction = expression;
textField.setText(ParameterFunctionUtils.getString(processFunction));
UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
valueUpdated();
}
}
});
buttonEdit.setBounds(xPos + BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
fieldPanel.add(buttonEdit);
//
// Clear button
//
final JButton buttonClear = new JButton(clearButtonText);
buttonClear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
processFunction = null;
textField.setText("");
UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, null));
valueUpdated();
}
});
buttonClear.setBounds((int) buttonEdit.getBounds().getMaxX() + 5, 0, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
fieldPanel.add(buttonClear);
}
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class SLDTreeTools method removeItem.
/**
* Removes the item.
*/
public void removeItem() {
if (symbolTree == null) {
return;
}
TreePath path = symbolTree.getSelectionPath();
if (path == null) {
return;
}
DefaultMutableTreeNode lastNode = (DefaultMutableTreeNode) path.getLastPathComponent();
Object obj = lastNode.getUserObject();
// CHECKSTYLE:OFF
Object oldValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
if (obj instanceof NamedLayer) {
SelectedSymbol.getInstance().removeUserNamedLayer((NamedLayer) obj);
removeTreeNode(lastNode);
} else if (obj instanceof UserLayer) {
SelectedSymbol.getInstance().removeUserNamedLayer((UserLayer) obj);
removeTreeNode(lastNode);
} else if (obj instanceof Style) {
SelectedSymbol.getInstance().removeStyle((Style) obj);
removeTreeNode(lastNode);
} else if (obj instanceof FeatureTypeStyle) {
SelectedSymbol.getInstance().removeFeatureTypeStyle((FeatureTypeStyle) obj);
removeTreeNode(lastNode);
} else if (obj instanceof Rule) {
SelectedSymbol.getInstance().removeRule((Rule) obj);
removeTreeNode(lastNode);
} else if (obj instanceof Symbolizer) {
DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) lastNode.getParent();
if (parentNode != null) {
if (parentNode.getUserObject() instanceof RasterSymbolizer) {
SelectedSymbol.getInstance().removeRasterImageOutline((RasterSymbolizer) parentNode.getUserObject());
} else {
SelectedSymbol.getInstance().removeSymbolizer((Symbolizer) obj);
}
removeTreeNode(lastNode);
}
} else {
return;
}
SLDTreeManager.getInstance().rebuildTree((SLDTree) sldTree);
// Re-render the symbol
if (renderList != null) {
for (RenderSymbolInterface render : renderList) {
render.renderSymbol();
}
}
Object newValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
UndoManager.getInstance().addUndoEvent(new UndoEvent(sldTree.getUndoObject(), getClass().getName(), oldValueObj, newValueObj));
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class SLDTreeTools method addNewText.
/**
* Adds the new text symbolizer.
*/
public void addNewText() {
if (symbolTree == null) {
return;
}
// Store current state of the SLD before the add
Object oldValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
TextSymbolizer newTextSymbolizer = DefaultSymbols.createDefaultTextSymbolizer();
DefaultMutableTreeNode ruleNode = getRuleTreeNode();
SelectedSymbol.getInstance().addSymbolizerToRule(newTextSymbolizer);
DefaultMutableTreeNode newNode = sldTree.addObject(ruleNode, newTextSymbolizer, true);
// Select the item just added
if (newNode != null) {
SLDTreeManager.getInstance().rebuildTree((SLDTree) sldTree);
TreePath newPath = getPath(newNode);
symbolTree.setSelectionPath(newPath);
// Store current state of the SLD after the add
Object newValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
UndoManager.getInstance().addUndoEvent(new UndoEvent(sldTree.getUndoObject(), getClass().getName(), oldValueObj, newValueObj));
}
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class SLDTreeTools method addNewImageOutlineLine.
/**
* Adds the new image outline line symbolizer.
*/
public void addNewImageOutlineLine() {
if (symbolTree == null) {
return;
}
// Store current state of the SLD before the add
Object oldValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
LineSymbolizer newLineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
DefaultMutableTreeNode ruleNode = getRasterTreeNode();
SelectedSymbol.getInstance().addImageOutlineSymbolizerToRaster(newLineSymbolizer);
DefaultMutableTreeNode newNode = sldTree.addObject(ruleNode, newLineSymbolizer, true);
if (newNode != null) {
sldTree.addObject(newNode, SLDTreeLeafFactory.getInstance().getStroke(newLineSymbolizer), true);
SLDTreeManager.getInstance().rebuildTree((SLDTree) sldTree);
// Select the item just added
TreePath newPath = getPath(newNode);
symbolTree.setSelectionPath(newPath);
// Store current state of the SLD after the add
Object newValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
UndoManager.getInstance().addUndoEvent(new UndoEvent(sldTree.getUndoObject(), getClass().getName(), oldValueObj, newValueObj));
}
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class SLDTreeTools method addNewMarker.
/**
* Adds the new marker symbolizer.
*/
public void addNewMarker() {
if (symbolTree == null) {
return;
}
// Store current state of the SLD before the add
Object oldValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
PointSymbolizer newPointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer();
DefaultMutableTreeNode ruleNode = getRuleTreeNode();
SelectedSymbol.getInstance().addSymbolizerToRule(newPointSymbolizer);
DefaultMutableTreeNode newNode = sldTree.addObject(ruleNode, newPointSymbolizer, true);
// Select the item just added
if (newNode != null) {
sldTree.addObject(newNode, SLDTreeLeafFactory.getInstance().getFill(newPointSymbolizer), true);
SLDTreeManager.getInstance().rebuildTree((SLDTree) sldTree);
TreePath newPath = getPath(newNode);
symbolTree.setSelectionPath(newPath);
// Store current state of the SLD after the add
Object newValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
UndoManager.getInstance().addUndoEvent(new UndoEvent(sldTree.getUndoObject(), getClass().getName(), oldValueObj, newValueObj));
}
}
Aggregations