use of com.sldeditor.datasource.DataSourceInterface in project sldeditor by robward-scisys.
the class FieldConfigDSPropertiesTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
boolean valueOnly = true;
TestDataSource testDataSource = new TestDataSource();
@SuppressWarnings("unused") DataSourceInterface dataSource = DataSourceFactory.createDataSource(testDataSource);
FieldConfigDSProperties field = new FieldConfigDSProperties(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
field.dataSourceLoaded(GeometryTypeEnum.POLYGON, false);
assertNull(field.getStringValue());
// Now create the ui
field.createUI();
String expectedValue1 = "Date_2";
field.populateField(expectedValue1);
String expectedValue2 = "String_3";
field.populateField(expectedValue2);
UndoManager.getInstance().undo();
String actualValueString = field.getStringValue();
assertTrue(expectedValue1.compareTo(actualValueString) == 0);
UndoManager.getInstance().redo();
actualValueString = field.getStringValue();
assertTrue(expectedValue2.compareTo(actualValueString) == 0);
// Increase the code coverage
field.undoAction(null);
field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(23)));
field.redoAction(null);
field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(54)));
DataSourceFactory.reset();
}
use of com.sldeditor.datasource.DataSourceInterface in project sldeditor by robward-scisys.
the class DefaultSymbols method createArrow.
/**
* Creates the arrow.
*
* @param angleFunction the angle function
* @param locationFunction the location function
* @param markerSymbol the marker symbol
* @param isSourceArrow the is source arrow
* @return the point symbolizer
*/
private static PointSymbolizer createArrow(FunctionName angleFunction, FunctionName locationFunction, String markerSymbol, boolean isSourceArrow) {
String name = isSourceArrow ? Localisation.getString(SLDTreeTools.class, "TreeItem.sourceArrow") : Localisation.getString(SLDTreeTools.class, "TreeItem.destArrow");
PointSymbolizer pointSymbolizer = createDefaultPointSymbolizer();
pointSymbolizer.setName(name);
Graphic graphic = pointSymbolizer.getGraphic();
graphic.setSize(ff.literal(DEFAULT_ARROW_SIZE));
List<GraphicalSymbol> graphicalSymbolList = graphic.graphicalSymbols();
MarkImpl mark = (MarkImpl) graphicalSymbolList.get(0);
Expression wellKnownName = ff.literal(markerSymbol);
mark.setWellKnownName(wellKnownName);
mark.getFill().setColor(ff.literal(DEFAULT_COLOUR));
// Arrow rotation
List<Expression> rotationArgumentList = new ArrayList<Expression>();
String geometryFieldName = "geom";
DataSourceInterface dsInfo = DataSourceFactory.getDataSource();
if (dsInfo != null) {
geometryFieldName = dsInfo.getGeometryFieldName();
}
rotationArgumentList.add(ff.property(geometryFieldName));
Expression rotation = FunctionManager.getInstance().createExpression(angleFunction, rotationArgumentList);
if (isSourceArrow) {
graphic.setRotation(ff.add(ff.literal(DEGREES_180), rotation));
} else {
graphic.setRotation(rotation);
}
AnchorPoint anchorPoint = styleFactory.anchorPoint(ff.literal(0.5), ff.literal(0.5));
graphic.setAnchorPoint(anchorPoint);
// Set location of the arrow head
List<Expression> endPointArgumentList = new ArrayList<Expression>();
endPointArgumentList.add(ff.property(geometryFieldName));
Expression geometry = FunctionManager.getInstance().createExpression(locationFunction, endPointArgumentList);
pointSymbolizer.setGeometry(geometry);
return pointSymbolizer;
}
use of com.sldeditor.datasource.DataSourceInterface in project sldeditor by robward-scisys.
the class FilterPanelv2 method dataSourceLoaded.
/**
* Data source loaded.
*
* @param geometryType the geometry type
* @param isConnectedToDataSourceFlag the is connected to data source flag
*/
@Override
public void dataSourceLoaded(GeometryTypeEnum geometryType, boolean isConnectedToDataSourceFlag) {
DataSourceInterface dataSource = DataSourceFactory.getDataSource();
propertyPanel.dataSourceLoaded(dataSource);
expressionPanel.dataSourceLoaded(dataSource);
}
use of com.sldeditor.datasource.DataSourceInterface in project sldeditor by robward-scisys.
the class FilterPanelv2 method closeDialog.
/**
* Close dialog.
*
* @param okButton the ok button
*/
private void closeDialog(boolean okButton) {
okButtonPressed = okButton;
DataSourceInterface dataSource = DataSourceFactory.getDataSource();
if (dataSource != null) {
dataSource.removeListener(this);
}
setVisible(false);
}
use of com.sldeditor.datasource.DataSourceInterface in project sldeditor by robward-scisys.
the class VectorTool method setDataSource.
/**
* Sets the data source.
*
* @param featureClassNode the new data source
*/
protected void setDataSource(DatabaseFeatureClassNode featureClassNode) {
DatabaseClientInterface dbClient = DatabaseConnectionManager.getInstance().getConnectionMap().get(featureClassNode.getConnectionData());
if (dbClient != null) {
ConsoleManager.getInstance().information(this, String.format("%s : %s", Localisation.getString(VectorTool.class, "VectorTool.setDataSource"), featureClassNode.toString()));
// Vector file
DataSourcePropertiesInterface dsProperties = SLDEditorFile.getInstance().getDataSource();
DataSourceConnectorInterface dsc = DataSourceConnectorFactory.getDataSource(dbClient.getClass());
dsProperties = dsc.getDataSourceProperties(dbClient.getDBConnectionParams());
dsProperties.setFilename(featureClassNode.toString());
SLDEditorFile.getInstance().setDataSource(dsProperties);
DataSourceInterface dataSource = DataSourceFactory.createDataSource(null);
if (dataSource != null) {
dataSource.connect(featureClassNode.toString(), SLDEditorFile.getInstance(), CheckAttributeFactory.getCheckList());
}
}
}
Aggregations