[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [ve-dev] Read/Write of complex LayoutManager values
|
Hi Gerald,
The most annoying thing anyone can do
to someone asking a specific question is ask a question back rather than
give an answer. I'll do both however.
First - why do you want the constructor
args ? A different approach might be to ask the live object (the
CellConstraints) to return the int pairs, presumabely through a public
getter or public field. If these are available the way to do this
is to get the IProxyValue for the actual CellConstraints, get the IMethodProxy
and then query the live values. The advantage of this over parsing
constructor args is that they're live and will work if a different constructor
was used for example, or the object had default values or maybe had capped
max and mins or whatever. i.e., if you want to find out stuff from
an object better to ask it than look at how is was constructed and assume
that this represents it only state.
Second - if you really really really
want to read the constructor args it can be done. You're going to
need to get the allocation, case it to a ParseTreeAllocation and walk it.
In the debugger just look at the allocation and you should be able
to figure out the structur. However - I really think you shouldn't
do this this. The only reason I can think to want to do this, instead
of the first technique which is to ping the live object, is because a)
the live object doesn't give up its values or b) you want to do something
clever in code gen. If the answer is a) then don't worry - you can
use the IMethodProxy technique and set the accessible to true to get round
VM exceptions about fields not being visible and rip it open to find the
live values, and if the answer is b) then you should be doing stuff with
the BeanDeclarationModel instead.
Does this make sense ? If so and
you want to do the first route then let us know if you need help with the
code to yank field values or invoke getter on the actual live CellConstrants
object,
Best regards,
Joe Winchester
Please respond to Discussions
people developing code for the Visual Editor project <ve-dev@xxxxxxxxxxx>
Sent by:
ve-dev-bounces@xxxxxxxxxxx
To:
Discussions people
developing code for the Visual Editor project <ve-dev@xxxxxxxxxxx>
cc:
Subject:
Re: [ve-dev]
Read/Write of complex LayoutManager values
Rich -
Not sure my question was clear. The form of enumeration is not really
the point of my problem, but rather, once I do get a IJavaInstance (or
something) representing a constraint object, how do I then get the constraint
constructor parameter values. Swing BoxLayout does retrieve
the individual constraint objects, but merely types them. I do not
see an example of actually extracting constructor parameter values.
That is, given only the (prior generated) source:
jPanel.add(jLabel,
new
CellConstraints(2, 2));
jPanel.add(getJButton(), new
CellConstraints(4, 2));
how do I subsquently read back just the int pair values 2, 2 and 4, 2?
Hopefully, the following routine will give a better picture of what
I am trying to do -- just need to understand how to fill in the "???????".
Thanks,
Gerald
/**
* Retrieves
a map
of constraint
values for
some set
of components
present in
a
* container
managed by
a FormLayout.
Required to
determine the
existing constraint
* values
as a precondition to
computing revised
constraints.
* <p>
* The
set of
components may
be a
subset of
all components
in the
container.
* <p>
* The
returned map
must contain
sufficient information
to allow
component/constraint
* tuples
to be
subsequently identified
and revised
with new
constraint values.
* Example:
*
* <pre>
* Map
workMap =
getConstraintMap(children);
* workMap
= shiftRightByOne(workMap);
* updateConstraintsFromMap(children,
workMap);
* </pre>
*
* @param
children
*
a
List of
components in
a container.
*
* @return
a Map
containing component
keys and
corresponding cell
addresses.
*
*/
public Map getConstraintsMap(List children) {
ResourceSet rset = JavaEditDomainHelper.getResourceSet(policy.getEditDomain());
EReference sfConstraintConstraint = JavaInstantiation.getReference(rset,
JFCConstants.SF_CONSTRAINT_CONSTRAINT);
EReference sfConstraintComponent = JavaInstantiation.getReference(rset,
JFCConstants.SF_CONSTRAINT_COMPONENT);
EReference sfComponents = JavaInstantiation.getReference(rset,
JFCConstants.SF_CONTAINER_COMPONENTS);
// formlayout is defined by a column/row
grid
Point p = null;
// for each grid cell, p.x is the column
and p.y is the row
LinkedHashMap<IJavaInstance, Point> map = new
LinkedHashMap<IJavaInstance, Point>();
Iterator childs = children.iterator();
while (childs.hasNext())
{
EObject constraintComponent = InverseMaintenanceAdapter.getIntermediateReference((EObject)
getContainerBean(), sfComponents, sfConstraintComponent,(EObject) childs.next());
if (constraintComponent.eIsSet(sfConstraintComponent)
&& constraintComponent.eIsSet(sfConstraintConstraint)) {
// get the component
IJavaInstance constraintComponentAttributeValue = (IJavaInstance)
constraintComponent.eGet(sfConstraintComponent);
// then get the constraint
IJavaInstance constraintConstraintAttributeValue = (IJavaInstance)
constraintComponent.eGet(sfConstraintConstraint);
// given that constraintAttributeValue represents
a constraint object in source of the form:
// new CellConstraints(int
col, int row)
// pull out the constructor parameter values
int col = ?????????(constraintConstraintAttributeValue,
0); // <<<< unknown part; get first parameter
int row = ?????????(constraintConstraintAttributeValue,
1); // <<<< unknown part; get second parameter
p = new
Point(col, row);
map.put(constraintComponentAttributeValue, p);
}
}
return map;
}
At 10:47 AM 6/5/2006, you wrote:
Third question is you don't need to use the inverse maintenance
adapter to get the constraints. The Panel's (the parent container) "components"
feature points to an intermidiate object that contains both the constraint
and the child. Take a look at ContainerProxyAdapter.addComponentWithConstraint()
method and where it was called from. It is called with the intermediate
object (called a ConstraintComponent). The constraint components are the
true value of the "components" setting on the parent. From the
constraint component there are two other settings, one is the constraint
and the other is the child control.
The call in addComponentWithConstraint:
if
(constraintComponent.eIsSet(sfConstraintConstraint))
{
constraintAttributeValue = (IJavaInstance)
constraintComponent.eGet(sfConstraintConstraint);
constraintIsSet = true;
}
is how you retrieve the constraint out of the constraint component. Do
a search on where sfConstraintConstraint is is set to see how to get it.
PS: sfContainerComponents
is the feature for getting the cooresponding child out of the constraint
component. _______________________________________________
ve-dev mailing list
ve-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ve-dev