Bug 161902 [JFace] Enhancements to GridLayoutFactory.margins
This enhancement requests the following: 1. Rename the new GridLayoutFactory.margins(int,int,int,int) to GridLayoutFactory.extendedMargins(int,int,int,int) 2. Add a GridLayoutFactory.extendedMargins(Rectangle) method that accepts a difference rectangle. 3. Add static methods to Geometry in order to easily construct difference rectangles. Why? 1. We should not use overloaded methods in GridLayoutFactory unless they really do set the same thing. Since the four-argument margins(...) method and the two-argument margins(...) method set independent values, we should give them different names or clients will expect a call to margins(int, int, int, int) to overwrite a previous call to margins(int, int). 2. All methods on GridLayoutFactory and GridDataFactory should have vector initializers, so that clients can store and reuse standard margin settings in a single variable. 3. Vector initializers are only a convenience if there is a convenient way to construct the vector.
bundles/org.eclipse.jface/src/org/eclipse/jface/layout/GridLayoutFactory.java
result.horizontalSpacing = l.horizontalSpacing;
        result.marginBottom = l.marginBottom;
        result.marginHeight = l.marginHeight;
        result.marginLeft = l.marginLeft;
        result.marginRight = l.marginRight;
        result.marginTop = l.marginTop;
        result.marginWidth = l.marginWidth;
        result.verticalSpacing = l.verticalSpacing;
        return result;
    }
    /**
     * Applies this layout to the given composite, and attaches default GridData
     * to all immediate children that don't have one. The layout is generated using 
     * heuristics based on the widget types. In most cases, it will create exactly the same
     * layout that would have been hardcoded by the programmer. In any situation
     * where it does not produce the desired layout, the GridData for any child can be 
     * overridden by attaching the layout data before calling this method. In these cases,
     * the special-case layout data can be hardcoded and the algorithm can supply defaults
     * to the rest.
     * 
     * <p>
     * This must be called <b>AFTER</b> all of the child controls have been created and their
     * layouts attached. This method will attach a layout to the given composite. If any new 
     * children are created after calling this method, their GridData must be created manually. 
     * The algorithm does not recurse into child composites. To generate all the layouts in
     * a widget hierarchy, the method must be called bottom-up for each Composite.   
     * </p>
     * 
     * <p>
     * All controls are made to span a single cell. The algorithm tries to classify controls into one