Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Instrument Control
NomadCommandSystem
Commits
3b79fbe1
Commit
3b79fbe1
authored
Feb 27, 2015
by
yannick legoc
Browse files
separated property object creation from configuration before adding automatically the properties
parent
efb99575
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/fr/ill/ics/core/property/PropertyFactory.java
View file @
3b79fbe1
...
...
@@ -63,12 +63,10 @@ public class PropertyFactory {
return
instance
;
}
public
Property
createProperty
(
int
containerId
,
int
id
,
XMLPropertyDescriptor
propertyDescriptor
,
boolean
isCommandBox
)
{
public
Property
createProperty
(
int
containerId
,
int
id
,
String
type
,
boolean
isCommandBox
)
{
// Create basic property
Property
property
=
null
;
String
type
=
propertyDescriptor
.
getPropertyType
().
toLowerCase
();
//
String type = propertyDescriptor.getPropertyType().toLowerCase();
if
(
type
.
equals
(
"unknown"
))
{
// Get property type directly from the controller
...
...
@@ -95,11 +93,9 @@ public class PropertyFactory {
}
else
if
(
type
.
equals
(
"float32"
))
{
property
=
new
Float32Property
(
containerId
,
id
,
isCommandBox
);
property
.
setPropertyFormat
(
new
DecimalFormat
(
propertyDescriptor
,
id
,
false
));
}
else
if
(
type
.
equals
(
"float64"
)
||
type
.
equals
(
"double"
))
{
property
=
new
Float64Property
(
containerId
,
id
,
isCommandBox
);
property
.
setPropertyFormat
(
new
DecimalFormat
(
propertyDescriptor
,
id
,
false
));
}
else
if
(
type
.
equals
(
"boolean"
)
||
type
.
equals
(
"Boolean"
))
{
property
=
new
BooleanProperty
(
containerId
,
id
,
isCommandBox
);
...
...
@@ -129,8 +125,25 @@ public class PropertyFactory {
property
=
new
StringProperty
(
containerId
,
id
,
isCommandBox
);
LOGGER
.
log
(
Level
.
WARNING
,
"Unable to manage type "
+
type
+
" for property "
+
id
);
}
return
property
;
}
// add format
public
Property
configureProperty
(
Property
property
,
XMLPropertyDescriptor
propertyDescriptor
)
{
// Create basic property
String
type
=
propertyDescriptor
.
getPropertyType
().
toLowerCase
();
int
id
=
property
.
getPropertyID
();
if
(
type
.
equals
(
"float32"
))
{
property
.
setPropertyFormat
(
new
DecimalFormat
(
propertyDescriptor
,
id
,
false
));
}
else
if
(
type
.
equals
(
"float64"
)
||
type
.
equals
(
"double"
))
{
property
.
setPropertyFormat
(
new
DecimalFormat
(
propertyDescriptor
,
id
,
false
));
}
// add format
if
(
propertyDescriptor
.
getFormat
().
equals
(
PropertyParser
.
TAG_DECIMAL_FORMAT
))
{
property
.
setPropertyFormat
(
new
DecimalFormat
(
propertyDescriptor
,
id
,
false
));
...
...
@@ -182,6 +195,15 @@ public class PropertyFactory {
return
property
;
}
public
Property
createProperty
(
int
containerId
,
int
id
,
XMLPropertyDescriptor
propertyDescriptor
,
boolean
isCommandBox
)
{
// Create basic property
String
type
=
propertyDescriptor
.
getPropertyType
().
toLowerCase
();
Property
property
=
createProperty
(
containerId
,
id
,
type
,
isCommandBox
);
configureProperty
(
property
,
propertyDescriptor
);
return
property
;
}
/**
*
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment