Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ve-dev] Read/Write of complex LayoutManager values


Hi,

First question can be answered by looking at org.eclipse.ve.internal.swt.GridLayoutPolicyHelper.getLayoutContainerDimensions(). What we've done is we've put over on the remote vm a class that does all of the complicated work to find the information and then we call it to figure out the info. The info is put into fields in the remote vm helper class and then the calls:

                IFieldProxy getColumnWidthsFieldProxy = gridLayoutHelperType.getDeclaredFieldProxy("widths"); //$NON-NLS-1$
                IFieldProxy getRowHeightsFieldProxy = gridLayoutHelperType.getDeclaredFieldProxy("heights"); //$NON-NLS-1$
                try {
                        // Get the column widths and row heights from the target VM helper
                        IArrayBeanProxy arrayProxyColumnWidths =
                                (IArrayBeanProxy) getColumnWidthsFieldProxy.get(gridLayoutHelperProxy);
are used to get the fields values (which arrays) back.


Note that we do something called JavaStandardSWTBeanConstants.invokeSyncExec(...). This is only needed in SWT because all of these functions need to run in the SWT display thread on the the remote vm. That probably isn't necessary for your stuff since it is not SWT.

Second question is no. At this time you can't generate code that calls a non-setter/getter method. That is because the codegen and the model work off of properties, and that is not a property. Since it is not a property it would not be recognized on reparsing from code.

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.

Thanks,
Rich


Gerald Rosenberg <gerald@xxxxxxxxxx>
Sent by: ve-dev-bounces@xxxxxxxxxxx

06/03/2006 03:54 PM

Please respond to
Discussions people developing code for the Visual Editor project <ve-dev@xxxxxxxxxxx>

To
ve-dev@xxxxxxxxxxx
cc
Subject
[ve-dev] Read/Write of complex LayoutManager values





Thanks for the excellent help... FormLayoutSwitcher is essentially done.

Now working on a simple FormLayoutPolicyEdit -- I see how to read/write simple bean properties to the layoutmanager using INumberBeanProxy and IStringBeanProxy.  However, I need to be able to access a property with a more complex type:

public int[][] getColumnGroups()
and
public ColumnSpec getColumnSpec(int columnIndex)
So the first question is: is there an IObjectBeanProxy or some equivalent?  If not, how do I extract existing layoutmanager constructor arguments (which is what defines the form of the layout format)?

FormLayout layout = new FormLayout(

"right:pref, 6dlu, 50dlu, 4dlu",  // 4 columns
"pref, 3dlu, pref, 3dlu, pref");  // 5 rows
---------------

Second question is: is there a way to invoke a non-bean (is/get/set) based method on the layoutmanager?  Not essential, but it would be helpful to be able to use layoutmanager methods of the form:

public void insertColumn(int columnIndex, ColumnSpec columnSpec)
and
public void removeColumn(int columnIndex)
----------------

The final question involves working with existing constraint objects -- I will need to enumerate the components in the container and then inspect the fields of the corresponding constraint object to extract the current constraint values.  Something like:

...
List cclist = ...  // accumulator for constraint values

while
(childs.hasNext()) { // where childs is an interator over the List of container components
EObject constraintComponent = InverseMaintenanceAdapter.getIntermediateReference((EObject)
getContainerBean(), sfComponents, sfConstraintComponent, (EObject) childs.next());

// this is the unknown part vvvvvv
CellConstraints constraint = ????(constraintComponent);
cclist.add(constraint.gridX);
cclist.add(constraint.gridY);
cclist.add(constraint.gridWidth);
cclist.add(constraint.gridHeight);
}

Explanations and/or pointers to exemplary source in the project would be appreciated.

Gerald
_______________________________________________
ve-dev mailing list
ve-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ve-dev


Back to the top