use of com.revolsys.datatype.DataType in project com.revolsys.open by revolsys.
the class LayerRecordForm method addDoubleField.
protected void addDoubleField(final String fieldName, final int length, final int scale, final Double minimumValie, final Double maximumValue) {
final DataType dataType = DataTypes.DOUBLE;
final NumberTextField field = new NumberTextField(fieldName, dataType, length, scale, minimumValie, maximumValue);
addField(fieldName, field);
}
use of com.revolsys.datatype.DataType in project com.revolsys.open by revolsys.
the class LayerRecordForm method addToolBar.
protected ToolBar addToolBar(final AbstractRecordLayer layer) {
this.toolBar = new ToolBar();
add(this.toolBar, BorderLayout.NORTH);
final RecordDefinition recordDefinition = getRecordDefinition();
final FieldDefinition geometryField = recordDefinition.getGeometryField();
final boolean hasGeometry = geometryField != null;
final EnableCheck editable = new ObjectPropertyEnableCheck(this, "editable");
if (layer != null) {
final MenuFactory menuFactory = MenuFactory.findMenu(layer);
if (menuFactory != null) {
this.toolBar.addButtonTitleIcon("menu", "Layer Menu", "menu", () -> menuFactory.showMenu(layer, this, 10, 10));
}
}
final EnableCheck deletableEnableCheck = editable.and(new ObjectPropertyEnableCheck(this, "deletable"));
this.toolBar.addButton("record", "Delete Record", "table_row_delete", deletableEnableCheck, this::deleteRecord);
// Cut, Copy Paste
this.toolBar.addButton("dnd", "Copy Record", "page_copy", (EnableCheck) null, this::dataTransferCopy);
if (hasGeometry) {
this.toolBar.addButton("dnd", "Copy Geometry", "geometry_copy", (EnableCheck) null, this::copyGeometry);
}
this.toolBar.addButton("dnd", "Paste Record", "paste_plain", editable, this::dataTransferPaste);
if (hasGeometry) {
this.toolBar.addButton("dnd", "Paste Geometry", "geometry_paste", editable, this::pasteGeometry);
}
final EnableCheck canUndo = new ObjectPropertyEnableCheck(this.undoManager, "canUndo");
final EnableCheck canRedo = new ObjectPropertyEnableCheck(this.undoManager, "canRedo");
final EnableCheck modifiedOrDeleted = new ObjectPropertyEnableCheck(this, "modifiedOrDeleted");
this.toolBar.addButton("changes", "Revert Record", "arrow_revert", modifiedOrDeleted, this::revertChanges);
this.toolBar.addButton("changes", "Revert Empty Fields", "field_empty_revert", new ObjectPropertyEnableCheck(this, "hasModifiedEmptyFields"), this::revertEmptyFields);
this.toolBar.addButton("changes", "Undo", "arrow_undo", canUndo, this.undoManager::undo);
this.toolBar.addButton("changes", "Redo", "arrow_redo", canRedo, this.undoManager::redo);
if (hasGeometry) {
this.toolBar.addButtonTitleIcon("zoom", "Zoom to Record", "magnifier_zoom_selected", () -> {
final LayerRecord record = getRecord();
layer.zoomToRecord(record);
});
this.toolBar.addButtonTitleIcon("zoom", "Pan to Record", "pan_selected", () -> {
final LayerRecord record = getRecord();
final MapPanel mapPanel = layer.getMapPanel();
if (mapPanel != null) {
mapPanel.panToRecord(record);
}
});
}
// Geometry manipulation
if (hasGeometry) {
final DataType geometryDataType = geometryField.getDataType();
if (geometryDataType == DataTypes.LINE_STRING || geometryDataType == DataTypes.MULTI_LINE_STRING) {
if (DirectionalFields.getProperty(recordDefinition).hasDirectionalFields()) {
this.toolBar.addButton("geometry", FLIP_RECORD_NAME, FLIP_RECORD_ICON, editable, this::flipRecordOrientation);
this.toolBar.addButton("geometry", FLIP_LINE_ORIENTATION_NAME, FLIP_LINE_ORIENTATION_ICON, editable, this::flipLineOrientation);
this.toolBar.addButton("geometry", FLIP_FIELDS_NAME, FLIP_FIELDS_ICON, editable, this::flipFields);
} else {
this.toolBar.addButton("geometry", "Flip Line Orientation", "flip_line", editable, this::flipLineOrientation);
}
}
}
return this.toolBar;
}
use of com.revolsys.datatype.DataType in project com.revolsys.open by revolsys.
the class GeometryStyleRenderer method newIcon.
@Override
public Icon newIcon() {
final AbstractRecordLayer layer = getLayer();
if (layer == null) {
return ICON;
} else {
final GeometryStyle geometryStyle = getStyle();
Shape shape = null;
final DataType geometryDataType = layer.getGeometryType();
if (DataTypes.POINT.equals(geometryDataType) || DataTypes.MULTI_POINT.equals(geometryDataType)) {
return this.style.getMarker().newIcon(geometryStyle);
} else if (DataTypes.LINE_STRING.equals(geometryDataType) || DataTypes.MULTI_LINE_STRING.equals(geometryDataType)) {
shape = GeometryStylePreview.getLineShape(16);
} else if (DataTypes.POLYGON.equals(geometryDataType) || DataTypes.MULTI_POLYGON.equals(geometryDataType)) {
shape = getPolygonShape();
} else {
return ICON;
}
final BufferedImage image = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
final Graphics2D graphics = image.createGraphics();
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
if (DataTypes.POLYGON.equals(geometryDataType) || DataTypes.MULTI_POLYGON.equals(geometryDataType)) {
graphics.setPaint(geometryStyle.getPolygonFill());
graphics.fill(shape);
}
final Color color = geometryStyle.getLineColor();
graphics.setColor(color);
graphics.draw(shape);
graphics.dispose();
return new ImageIcon(image);
}
}
use of com.revolsys.datatype.DataType in project com.revolsys.open by revolsys.
the class WebMethodHandler method requestParameter.
public static WebParameterHandler requestParameter(final WebAnnotationMethodHandlerAdapter adapter, final Parameter parameter, final Annotation annotation) {
final RequestParam requestParam = (RequestParam) annotation;
final String name = getName(parameter, requestParam.value());
final boolean required = requestParam.required();
final String defaultValueString = requestParam.defaultValue();
final Class<?> parameterClass = parameter.getType();
final DataType dataType = DataTypes.getDataType(parameterClass);
BiFunction<HttpServletRequest, HttpServletResponse, Object> function;
Object defaultValue = null;
if (List.class.equals(parameterClass)) {
if (ValueConstants.DEFAULT_NONE.equals(defaultValueString)) {
final ParameterizedType parameterizedType = (ParameterizedType) parameter.getParameterizedType();
final Type[] typeParameters = parameterizedType.getActualTypeArguments();
final Type elementType = typeParameters[0];
if (MultipartFile.class.equals(elementType)) {
function = (request, response) -> {
if (request instanceof MultipartRequest) {
final MultipartRequest multipartRequest = (MultipartRequest) request;
return multipartRequest.getFiles(name);
} else {
return Collections.emptyList();
}
};
} else {
final DataType elementDataType = DataTypes.getDataType(elementType);
function = (request, response) -> {
final List<Object> list = new ArrayList<>();
final String[] parameterValues = request.getParameterValues(name);
if (parameterValues != null) {
for (final String stringValue : parameterValues) {
final Object value = elementDataType.toObject(stringValue);
list.add(value);
}
}
return list;
};
}
} else {
throw new IllegalArgumentException("RequestParam.defaultValue not allowed for " + name);
}
} else if (parameterClass.isArray()) {
if (ValueConstants.DEFAULT_NONE.equals(defaultValueString)) {
final Class<?> elementClass = parameterClass.getComponentType();
if (MultipartFile.class.equals(elementClass)) {
function = (request, response) -> {
if (request instanceof MultipartRequest) {
final MultipartRequest multipartRequest = (MultipartRequest) request;
final List<MultipartFile> files = multipartRequest.getFiles(name);
return files.toArray();
} else {
return new MultipartFile[0];
}
};
} else {
final DataType elementDataType = DataTypes.getDataType(elementClass);
function = (request, response) -> {
final String[] parameterValues = request.getParameterValues(name);
int length;
if (parameterValues == null) {
length = 0;
} else {
length = parameterValues.length;
}
final Object array = Array.newInstance(elementClass, length);
for (int i = 0; i < length; i++) {
final String stringValue = parameterValues[i];
final Object value = elementDataType.toObject(stringValue);
Array.set(array, i, value);
}
return array;
};
}
} else {
throw new IllegalArgumentException("RequestParam.defaultValue not allowed for " + name);
}
} else {
defaultValue = parseDefaultValueAttribute(dataType, defaultValueString);
if (MultipartFile.class.equals(parameterClass)) {
function = (request, response) -> {
if (request instanceof MultipartRequest) {
final MultipartRequest multipartRequest = (MultipartRequest) request;
return multipartRequest.getFile(name);
} else {
return null;
}
};
} else {
function = (request, response) -> {
return request.getParameter(name);
};
}
}
return //
WebParameterHandler.function(//
name, //
function, //
dataType, //
required, //
defaultValue);
}
use of com.revolsys.datatype.DataType in project com.revolsys.open by revolsys.
the class WebMethodHandler method requestHeader.
public static WebParameterHandler requestHeader(final WebAnnotationMethodHandlerAdapter adapter, final Parameter parameter, final Annotation annotation) {
final Class<?> parameterClass = parameter.getType();
final DataType dataType = DataTypes.getDataType(parameterClass);
final RequestHeader requestHeader = (RequestHeader) annotation;
final String name = getName(parameter, requestHeader.value());
final boolean required = requestHeader.required();
final Object defaultValue = parseDefaultValueAttribute(dataType, requestHeader.defaultValue());
return //
WebParameterHandler.function(//
name, (request, response) -> {
return request.getHeader(name);
}, //
dataType, //
required, //
defaultValue);
}
Aggregations