提交 1c36016f 编写于 作者: J jurgen

RSV properties

上级 af313968
......@@ -30,6 +30,8 @@ public interface DBDDataFormatter {
void init(Locale locale, Map<Object, Object> properties);
String getPattern();
String formatValue(Object value);
Object parseValue(String value) throws ParseException;
......
......@@ -31,16 +31,24 @@ public class DateTimeDataFormatter implements DBDDataFormatter {
public static final String PROP_PATTERN = "pattern";
private String pattern;
private DateFormat dateFormat;
@Override
public void init(Locale locale, Map<Object, Object> properties)
{
pattern = CommonUtils.toString(properties.get(PROP_PATTERN));
dateFormat = new ExtendedDateFormat(
CommonUtils.toString(properties.get(PROP_PATTERN)),
pattern,
locale);
}
@Override
public String getPattern()
{
return pattern;
}
@Override
public String formatValue(Object value)
{
......
......@@ -38,6 +38,12 @@ public class DefaultDataFormatter implements DBDDataFormatter {
{
}
@Override
public String getPattern()
{
return null;
}
@Override
public String formatValue(Object value)
{
......
......@@ -65,6 +65,12 @@ public class NumberDataFormatter implements DBDDataFormatter {
}
}
@Override
public String getPattern()
{
return null;
}
@Override
public String formatValue(Object value)
{
......
......@@ -57,6 +57,8 @@ public abstract class JDBCAbstractValueHandler implements DBDValueHandler {
static final Log log = LogFactory.getLog(JDBCAbstractValueHandler.class);
private static final String CELL_VALUE_INLINE_EDITOR = "org.jkiss.dbeaver.CellValueInlineEditor";
public static final String PROP_CATEGORY_STANDARD = "Standard";
@Override
public final Object fetchValueObject(DBCExecutionContext context, DBCResultSet resultSet, DBSTypedObject type, int index)
throws DBCException
......@@ -114,6 +116,12 @@ public abstract class JDBCAbstractValueHandler implements DBDValueHandler {
public void fillProperties(PropertySourceAbstract propertySource, DBDValueController controller)
{
propertySource.addProperty(
PROP_CATEGORY_STANDARD,
"column_type", //$NON-NLS-1$
"Data Type",
controller.getAttributeMetaData().getTypeName());
propertySource.addProperty(
PROP_CATEGORY_STANDARD,
"column_size", //$NON-NLS-1$
CoreMessages.model_jdbc_column_size,
controller.getAttributeMetaData().getMaxLength());
......
......@@ -84,10 +84,12 @@ public abstract class JDBCComplexValueHandler extends JDBCAbstractValueHandler {
@Override
public void fillProperties(PropertySourceAbstract propertySource, DBDValueController controller)
{
super.fillProperties(propertySource, controller);
try {
Object value = controller.getValue();
if (value instanceof DBDComplexType) {
propertySource.addProperty(
PROP_CATEGORY_STANDARD,
"object_type", //$NON-NLS-1$
CoreMessages.model_jdbc_type_name,
((DBDComplexType) value).getObjectDataType().getName());
......
......@@ -232,16 +232,19 @@ public class JDBCContentValueHandler extends JDBCAbstractValueHandler {
@Override
public void fillProperties(PropertySourceAbstract propertySource, DBDValueController controller)
{
super.fillProperties(propertySource, controller);
try {
Object value = controller.getValue();
if (value instanceof DBDContent) {
propertySource.addProperty(
PROP_CATEGORY_STANDARD,
"content_type", //$NON-NLS-1$
CoreMessages.model_jdbc_content_type,
((DBDContent)value).getContentType());
final long contentLength = ((DBDContent) value).getContentLength();
if (contentLength >= 0) {
propertySource.addProperty(
PROP_CATEGORY_STANDARD,
"content_length", //$NON-NLS-1$
CoreMessages.model_jdbc_content_length,
contentLength);
......@@ -252,7 +255,7 @@ public class JDBCContentValueHandler extends JDBCAbstractValueHandler {
log.warn("Could not extract LOB value information", e); //$NON-NLS-1$
}
propertySource.addProperty(
"max_length", //$NON-NLS-1$
null, "max_length", //$NON-NLS-1$
CoreMessages.model_jdbc_max_length,
controller.getAttributeMetaData().getMaxLength());
}
......
......@@ -37,6 +37,7 @@ import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSTypedObject;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.dialogs.data.DateTimeViewDialog;
import org.jkiss.dbeaver.ui.properties.PropertySourceAbstract;
import java.sql.SQLException;
import java.sql.Time;
......@@ -216,14 +217,7 @@ public class JDBCDateTimeValueHandler extends JDBCAbstractValueHandler {
"','YYYY-MM-DD HH24:MI:SS')";
}
} else {
switch (column.getTypeID()) {
case java.sql.Types.TIME:
return getFormatter(TYPE_NAME_TIME).formatValue(value);
case java.sql.Types.DATE:
return getFormatter(TYPE_NAME_DATE).formatValue(value);
default:
return getFormatter(TYPE_NAME_TIMESTAMP).formatValue(value);
}
return getFormatter(column).formatValue(value);
}
}
......@@ -249,14 +243,7 @@ public class JDBCDateTimeValueHandler extends JDBCAbstractValueHandler {
} else if (object instanceof String) {
String strValue = (String)object;
try {
switch (type.getTypeID()) {
case java.sql.Types.TIME:
return getFormatter(TYPE_NAME_TIME).parseValue(strValue);
case java.sql.Types.DATE:
return getFormatter(TYPE_NAME_DATE).parseValue(strValue);
default:
return getFormatter(TYPE_NAME_TIMESTAMP).parseValue(strValue);
}
return getFormatter(type).parseValue(strValue);
} catch (ParseException e) {
log.warn("Can't parse string value [" + strValue + "] to date/time value", e);
return null;
......@@ -280,6 +267,17 @@ public class JDBCDateTimeValueHandler extends JDBCAbstractValueHandler {
});
}
@Override
public void fillProperties(PropertySourceAbstract propertySource, DBDValueController controller)
{
super.fillProperties(propertySource, controller);
propertySource.addProperty(
PROP_CATEGORY_STANDARD,
"format", //$NON-NLS-1$
"Pattern",
getFormatter(controller.getAttributeMetaData()).getPattern());
}
public static Date getDate(DateTime dateEditor, DateTime timeEditor)
{
Calendar cl = Calendar.getInstance();
......@@ -352,4 +350,16 @@ public class JDBCDateTimeValueHandler extends JDBCAbstractValueHandler {
}
}
protected DBDDataFormatter getFormatter(DBSTypedObject column)
{
switch (column.getTypeID()) {
case java.sql.Types.TIME:
return getFormatter(TYPE_NAME_TIME);
case java.sql.Types.DATE:
return getFormatter(TYPE_NAME_DATE);
default:
return getFormatter(TYPE_NAME_TIMESTAMP);
}
}
}
\ No newline at end of file
......@@ -309,11 +309,14 @@ public class JDBCNumberValueHandler extends JDBCAbstractValueHandler {
@Override
public void fillProperties(PropertySourceAbstract propertySource, DBDValueController controller)
{
super.fillProperties(propertySource, controller);
propertySource.addProperty(
PROP_CATEGORY_STANDARD,
"precision", //$NON-NLS-1$
CoreMessages.model_jdbc_precision,
controller.getAttributeMetaData().getPrecision());
propertySource.addProperty(
PROP_CATEGORY_STANDARD,
"scale", //$NON-NLS-1$
CoreMessages.model_jdbc_scale,
controller.getAttributeMetaData().getScale());
......
......@@ -136,13 +136,4 @@ public class JDBCStringValueHandler extends JDBCAbstractValueHandler {
}
}
@Override
public void fillProperties(PropertySourceAbstract propertySource, DBDValueController controller)
{
propertySource.addProperty(
"max_length", //$NON-NLS-1$
CoreMessages.model_jdbc_max_length,
controller.getAttributeMetaData().getMaxLength());
}
}
\ No newline at end of file
......@@ -121,8 +121,8 @@ public class DBNAdapterFactory implements IAdapterFactory
if (props.isEmpty() && adaptableObject instanceof DBSObject) {
// Add default properties
DBSObject meta = (DBSObject)adaptableObject;
props.addProperty("name", CoreMessages.model_navigator_Name, meta.getName()); //$NON-NLS-1$
props.addProperty("desc", CoreMessages.model_navigator_Description, meta.getDescription()); //$NON-NLS-1$
props.addProperty(null, "name", CoreMessages.model_navigator_Name, meta.getName()); //$NON-NLS-1$
props.addProperty(null, "desc", CoreMessages.model_navigator_Description, meta.getDescription()); //$NON-NLS-1$
}
return props;
}
......
......@@ -52,12 +52,12 @@ public class ColumnInfoPanel extends Composite {
protected void createPanel(DBDAttributeController valueController)
{
PropertyCollector infoItem = new PropertyCollector(valueController.getAttributeMetaData(), false);
infoItem.addProperty("Table_Name", CoreMessages.controls_column_info_panel_property_table_name, valueController.getAttributeMetaData().getEntityName()); //$NON-NLS-1$
infoItem.addProperty("Column_Name", CoreMessages.controls_column_info_panel_property_column_name, valueController.getAttributeMetaData().getName() ); //$NON-NLS-1$
infoItem.addProperty("Column_Type", CoreMessages.controls_column_info_panel_property_column_type, valueController.getAttributeMetaData().getTypeName() ); //$NON-NLS-1$
infoItem.addProperty(null, "Table_Name", CoreMessages.controls_column_info_panel_property_table_name, valueController.getAttributeMetaData().getEntityName()); //$NON-NLS-1$
infoItem.addProperty(null, "Column_Name", CoreMessages.controls_column_info_panel_property_column_name, valueController.getAttributeMetaData().getName() ); //$NON-NLS-1$
infoItem.addProperty(null, "Column_Type", CoreMessages.controls_column_info_panel_property_column_type, valueController.getAttributeMetaData().getTypeName() ); //$NON-NLS-1$
valueController.getValueHandler().fillProperties(infoItem, valueController);
if (valueController.getValueLocator() != null) {
infoItem.addProperty("Key", CoreMessages.controls_column_info_panel_property_key, new CellKeyInfo(valueController) ); //$NON-NLS-1$
infoItem.addProperty(null, "Key", CoreMessages.controls_column_info_panel_property_key, new CellKeyInfo(valueController) ); //$NON-NLS-1$
}
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
......
......@@ -78,9 +78,9 @@ public abstract class PropertySourceAbstract implements IPropertySourceMulti
return this;
}
public PropertySourceAbstract addProperty(Object id, String name, Object value)
public PropertySourceAbstract addProperty(String category, Object id, String name, Object value)
{
props.add(new PropertyDescriptorEx(null, id, name, null, value == null ? null : value.getClass(), false, null, null, false));
props.add(new PropertyDescriptorEx(category, id, name, null, value == null ? null : value.getClass(), false, null, null, false));
propValues.put(id, value);
return this;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册