History log of /sdk/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java
Revision Date Author Comments
12d4581faa6438941e65a9dc83213be34c6ca970 13-Sep-2012 Tor Norbye <tnorbye@google.com> Constants refactoring.

This changeset moves most constants into the SdkConstants
class, and gets rid of AndroidConstants and LintConstants.
It also migrates all non-ADT specific constants from
AdtConstants into SdkConstants. It furthermore moves various
other constants (such as those in XmlUtils and ValuesDescriptors)
into the constants class. It also fixes the modifier order
to be the canonical modifier order (JLS 8.x).

Finally, it removes redundancy and combines various constant
aliases such that we don't have both NAME_ATTR and ATTR_NAME
pointing to "name", etc.

Change-Id: Ifd1755016f62ce2dd80e5c76130d6de4b0e32161
81cefe2a26dd6db8a878e30874d12cdcbff0e83b 11-Aug-2012 Xavier Ducrohet <xav@android.com> More refactoring.

Move stuff out of sdklib into common and ide_common.
Remove androidprefs and move the one class into common.

Change-Id: I71d126a13cf2ba413692e29616f4968a37d7b33a
85e4a1a9dd133abb879ec211ce8dd385004edf22 08-Aug-2012 Xavier Ducrohet <xav@android.com> Refactor common.jar

Move resources and com.android.util.Pair into layoutlib_api
where they belong since layoutlib depends on them and we need
to control the API.

Made a copy of Pair to stay in common.jar but moved it to
com.android.utils.Pair (the one in com.android.util.Pair is
marked as deprecated to prevent usage where applicable).

Also moved XmlUtil and PositionXmlParser to com.android.utils
to match Pair.

Change-Id: I21d7057d3f2ce604f86a3bb1fa3c130948c93b89
7e4b8e9d595e45baa9d87cdb8282f02759e73abc 30-May-2012 Tor Norbye <tnorbye@google.com> Fix nullness annotations

Eclipse 4.2 includes analysis support for @Nullable and @NonNull
annotations. However, it requires these annotations to be *repeated*
on every single method implementing or overriding a superclass or
interface method (!).

This changeset basically applies the quickfixes to inline these
annotations. It also changes the retention of our nullness
annotations from source to class, since without this Eclipse believes
that a @NonNull annotation downstream is a redefinition of a @Nullable
annotation.

Finally, the null analysis revealed a dozen or so places where the
nullness annotation was either wrong, or some null checking on
parameters or return values needed to be done.

Change-Id: I43b4e56e2d025a8a4c92a8873f55c13cdbc4c1cb
a881b0b34678ad76c9f5eba62fac7a00a22ac606 20-May-2012 Tor Norbye <tnorbye@google.com> Move XML code to the common library

The ManifestMerger library needs to look up the prefix to use for the
Android namespace, and the Document.lookupPrefix method is not
implemented by the Eclipse DOM implementation (which throws an
exception). However, we have an implementation of this in the ADT
plugin.

This changeset creates a new XmlUtils class in the common/ library
(which is accessible by both ADT and the manifest merger, and the
anttasks where the manifest merger is used), and moves the namespace
prefix lookup code in there. It also moves the XML escape methods
into that class. It also adds a new method to the ManifestMerger for
merging directly from documents (rather than files), and makes sure
that all the merging code goes via the prefix utility method rather
than calling the document.lookupPrefix method.

Finally, it moves the various string constants associated with XML
namespaces into the single XmlUtils class, since these were spread
across several different classes before (and many of them are needed
in the XmlUtils class).

The vast majority of the diffs in this changeset are related to simple
import statement changes to reflect the new locations of these
constants.

Change-Id: Ib8f3d0e5c89e47e61ea509a23925af7b6580abee
61684adfd7345f1a0df24bcf9176e6f528295bbb 22-Mar-2012 Tor Norbye <tnorbye@google.com> Change AttributeInfo.getFormats() to returning an EnumSet<Format>

This changeset changes the signature of AttributeInfo.getFormats()
from returning a Format[] to returning an EnumSet<Format>.
Furthermore, it defines a number of constants for the various common
format sets such that they can be reused.

Nearly all uses of the getFormats() method was really just trying to
see "is format X among the formats", so using enumsets is more natural
since it has a contains method. This also lets us replace some
attribute init code which was building up a set from the array for
this exact same purpose just reuse the format set directly.

In the attribute parser, rather than computing the uppercase version
of each format string ("dimension"=>"DIMENSION") and then doing a
Format.valueOf("DIMENSION"), we now compute a map for all the format
constants as lowercase to the corresponding format instance, and use
that map when parsing the attrs.xml file.

Note that there is a small semantic change from having an array of
formats to using an enumset: The format specified an
ordering. However, it does not look like any code depended on this,
and it's also not clear that the ordering in attrs.xml is
intentional. For example, it contains both "color|reference" and
"reference|color", and in both cases the intent is that the attribute
can specify an actual color or a reference to a color. Now with an
enum set, the order used when traversing the formats will always be in
their natural order, and for this purpose the REFERENCE type is moved
to the end since it's the least specific.

Change-Id: I1170cff48086f5cc13e4b70a35deea1f9979c883
3e75d4f79a8328ed18505830c786402369082efa 06-Mar-2012 Tor Norbye <tnorbye@google.com> Make GridLayout support work with the support library

Also fix the paste operation to target the parent if
the paste target does not accept children.

Change-Id: Id084db376e5ff9b4a374e6d2145bc890a925a078
ab36f4e7488358dea4ab6b54ee2b7bef3da0232b 21-Dec-2011 Tor Norbye <tnorbye@google.com> Update SDK codebase to JDK 6

This changeset makes the SDK codebase compile with source=1.6 (which
means it also requires JDK 6). This means that methods implementing an
interface requires @Override's. It also means we can start using APIs
like the ArrayDeque class and methods like String#isEmpty().

This changeset looks big but the change is trivial: it's basically
adding @Override in all the places that need it, along with some other
automatic Eclipse cleanup in certain files (such as reordering imports
where they were incorrectly ordered (because older versions of Eclipse
didn't always handle inner classes right)), as well as cleaning up
trailing whitespace and removing some $NON-NLS-1$ markers on lines
where there aren't any string literals anymore.

This changeset also sets the source and target JDK level to 6 in the
Eclipse compiler .settings file, and synchronizes this file to all the
other Eclipse SDK projects.

Change-Id: I6a9585aa44c3dee9a5c00739ab22fbdbcb9f8275
bf9db3ba5053c8f22a07ee748b2cb41d374d8642 24-Aug-2011 Tor Norbye <tnorbye@google.com> Use GridLayout state to determine exact row and column boundaries

This changeset updates the GridLayout support to consider the state of
a rendered GridLayout when deciding where the rows and columns
are. This information is already available in the GridLayout object,
so if one is provided use that data rather than inferring it from the
bounds of the views in each row and column.

This required changing the view rules API a bit to pass the view
objects in to the key entry points (drawing selection, drag & drop and
resize).

Change-Id: If8484f7f7181c65d0a2fdf629ffd515edd05448b
e287bc8580e19d72a911615475b353790cf000eb 16-Aug-2011 Tor Norbye <tnorbye@google.com> Layout editor property menu improvements

This changeset adds two forms of view attribute metadata:
* First, it records the most commonly used attributes for each
view. This was determined by gathering statistics on as many layout
files as I could find and then picking those that are used 10% or
more.

* Second, it records in the attribute metadata which View defines a
given attribute.

The context menu uses the above information to present the available
attributes in several ways:

* In the top level menu, where we had "Edit ID", and if applicable
"Edit Text", it now lists the top attributes instead. For example,
for a RatingBar the first handful of menu options are "Edit ID...",
"Edit NumStars...", "Edit StepSize...", "Edit Style..." and
"IsIndicator" (a boolean pull-right menu).

Incidentally this automatically handles some cases which were
manually handled before, so the code in LinearLayoutRule to add an
"Orientation" menu is no longer needed; it's just one of the two
common attributes handled by the new attribute list.

* The "Properties" menu is now called "Other Properties", and instead
of showing all properties, it has a new level of menus:

* "Recent". This is initially empty, but as you edit other attributes,
it gets populated (in most recently used order, kept up to date)
with recently edited properties.

* One submenu for each defining View super class listing exactly
the attributes defined by that view. This is useful for browsing
and editing related attributes. If you are looking at a textual
view like a Button for example, you can look at the "TextView"
menu to find all the text related options (TextColor, TextSize,
etc). These menus are listed from the nearest to the further
superclass, so for example if you right click on a CalendarView
you'll see these menus:

Recent >
----------------------------
Defined by CalendarView >
Inherited from FrameLayout >
Inherited from ViewGroup >
Inherited from View >
----------------------------
Layout Parameters >
----------------------------
All By Name >

* As you can see from the above, there are two more menus below the
inherited menu items. "Layout Parameters" lists all the layout
parameters available for the selected nodes (which is defined not
by the view itself but the view that it is contained within). And
finally there is "All By Name", which is a complete menu
containing all available attributes for the view (and this is what
the Properties menu used to contain).

* The code which computes a display name from an attribute was also
tweaked to capitalize not just the first letter but any first word
letter, so for example when you look at the possible values for
Gravity you now see "Clip Vertical" instead of "Clip vertical".

* The edit property dialog for the properties menus now uses @string
or @style resource choosers for the text, hint and style attributes
(used to just be a plain text box.)

Change-Id: I3b30d48b85fd13f0190c760756bf383a47b3f4a5
a0bccbddc52575255c5ce19c9d2c96d9639d26ca 16-Aug-2011 Tor Norbye <tnorbye@google.com> Pull View Rules API into a separate library

This changeset pulls out the API classes from the plugin sources and
into a separate standalone .jar library. The library depends on the
common.jar library.

With the separate view API it should be possible to build designtime
helpers (view rules) for custom views to improve editing behavior in
the layout editor.

Change-Id: I20bb511668de2fe52910e5fe0bbd3ec2a18b5a08
94986e745141118cace0391da1b4dc8533408751 10-Aug-2011 Tor Norbye <tnorbye@google.com> Action API improvements

This changeset changes the Actions mechanism for view rules to add
support for the following:

* Delayed computation of submenu contents. Before this, a view rule
would have to produce the full tree of actions to be shown in menus
and submenus - for example including all the properties, and in turn
all the enumerated values for those properties and so on. Now
there's a Provider interface which can be used to compute these menu
items only when the menu is actually opened. The properties menu now
takes advantage of this.

This was also necessary to implement the following new feature:

* The layout editor context menu now also lists not just the
properties for the currently selected views, but also the
properties for the parents. For example, if you open the context
menu, you'll see the properties for the button you just right
clicked on, but there will also be a "frameLayout1" submenu
containing the actions for the <FrameLayout> parent of the button,
and a "linearLayout1" submenu for the parent linear layout. This
is useful when a parent layout doesn't have blank space on its own
so it is difficult to target.

A future CL will use the lazy initialization to add more options to
the properties menu.

* Support for arbitrary nesting. Submenus can contain submenus can
contain other submenus etc.

* Custom ordering. This changeset moves the "sort priority" concept
(which was already used for layout actions) up to all actions, which
makes it easier for rules to cooperate on ordering because instead
of appending or prepending to the superclass' context menu result,
actions can now just be initialized with a sorting priority value
which makes it trivial to interleave actions regardless of who adds
them. This also makes it a lot easier to use custom ordering in
choice menus where the ordering used to be alphabetically sorting on
keys.

* Improved support for multiselection. The callback interface now
takes a list of nodes to apply the callback to, and actions can
indicate whether they support multiple nodes. This makes it possible
for actions to more directly support the case where you apply an
action to multiple nodes. As before, the available actions in the
context menu is limited such that it only shows the actions common
to all. But now those actions can do something specific. For
example, if you select "Edit Text..." on many nodes, you will get
the input-string dialog once, and then the value is applied to
all. Similarly, if you select "Edit Id..." it will ask for a
separate id for each value (and you can cancel out of this loop).

There are various API changes too. Since the Choices action (which had
a map-based set of values) was removed, the OrderedChoices is now
renamed Choices. The Actions subclass of MenuAction which all actions
also extended has simply been moved up to the top level MenuAction.
And MenuAction has been renamed to RuleActions since they are used
not just for menus but for toolbars etc and the key thing about this
interface is that they are intended for use by rules.
Change-Id: If49f75213f2041ebfef7e84254d70d219bb766ab
4eacdfbcc84ad11f599020b12ad76aebed70537f 07-Jul-2011 Tor Norbye <tnorbye@google.com> Grid Layout Support.

This changeset adds basic support for grid layouts:

- Freeform mode where you can drag & drop anywhere in the layout, and
guidelines are offered to align with other left boundaries, right
boundaries, baseline vertical alignment and center layout horizontal
alingment. In addition, it also offers "preferred spacing"
positioning, using the recommended distance between widgets.

Also, during a drag a regular 16x16 grid is also (faintly) shown and
(when there are no alignment matches as explained above) the
position snaps to this grid.

We also show the grid-structure (rows and columns, not the regular
snapping grid) during drags to make it more obvious that behind the
scenes there is a grid (because some other operations might shift
rows and columns so it's important to present the right user model.)

The freeform grid layout editor will automatically create rows and
columns and size them using spacers which are hidden from the user,
and on deletion these are automatically cleaned up as well.

- Grid mode where you can drag to any given cell, or between any two
rows or columns.

- Some layout actions for manipulating the grid (add/remove row and
column, adjust the gravity, toggle modes.)

This CL also contains various diagnostics code for the grid mode, and
does not yet correctly support dragging multiple views simultaneously.

Change-Id: Ie9ec54805039645e3db78d19095da86b04e44ca0
8f6e2fc89af2a75e05608d9ee1c648171ea47d83 11-Jul-2011 Tor Norbye <tnorbye@google.com> Add resize feedback tooltip

This changeset adds a "tooltip" during resize operations close to the
mouse cursor which displays feedback about the current resize
dimensions.

The feedback window is similar in appearance to a tooltip, but unlike
SWT tooltips it moves with the cursor and updates the text
dynamically, and appears immediately rather than being tied to mouse
motion timeouts. It is also partially translucent and uses a slightly
smaller font.

Change-Id: I6b663510f078f325d2f7b168c887aeff14de31b8
628f0f8dcdfaad793a97690a1479ba0f22d8b0ee 06-Jun-2011 Tor Norbye <tnorbye@google.com> Guidelines for match_parent, and linear layout weight fixes

First, add guidelines to allow snapping to "match_parent" (or
fill_parent, depending on the API level).

Second, fix the linear layout resizing scheme to handle corner cases a
bit better (corner cases such as resizing to a smaller size than the
wrap_content bounds, or resizing inside a layout that is "full"). Also
split up the resizing code into a compute-method and an apply-method
such that we can display feedback for the current weight during the
resizing operation.

Change-Id: Idd2917230870d26f94473dabc1a2a6becc3ba738
80d9301c2e874b29889c41adb0623666cf534fa0 10-Apr-2011 Tor Norbye <tnorbye@google.com> Resize & Guideline Support

RelativeLayout now has both drop/move and resize guidelines, and
existing constraints are visualized for the selection.

LinearLayout resizing now uses weights to change the size of nodes
rather than setting width/height.

All resize operations offer guidelines to snap to their "wrap_content"
size.

Various bug fixes in related areas as well.

Change-Id: I817e34c6e67ce61cfb137eb067076d91f69f99e9
523c97de99580f005611d982df0459324267cf1b 08-Feb-2011 Tor Norbye <tnorbye@google.com> Layout Actions bar fixes

This changeset fixes a couple of layout actions bar issues:

(1) Refresh the actions bar after running one of the layout
actions. This for example fixes the issue that if you click to
toggle the layout orientation then the baseline button will appear
for horizontal layouts.

(2) Fix an issue with the lazy-initialization of dropdown menus; they
weren't actually initialized lazily because the code to determine
whether a choice list should be a dropdown or a radio group would
cause initialization.

(3) Fix layout gravity on RelativeLayouts; it was reading/writing the
attribute "layout_gravity" instead of "gravity".

Change-Id: Ic41158257b3938a2e6daa8714dcd15d6bf21fa2f
a7da09b74d5f41667823ddf36c0cd7f145f54a2d 01-Feb-2011 Tor Norbye <tnorbye@google.com> Add Layout Actions toolbar

Add a new toolbar above the layout canvas (and to the right of the
palette). This toolbar shows various layout-related actions on its
left, and the canvas zoom controls on the right. The zoom controls
have been moved from the configuration panel, which has also been
reorganized a little with three of the dropdowns moved up to make more
horizontal width and take the place of the old zoom controls.

The toolbar items vary based on which layout is "active". The active
layout is the parent layout of the selection, or the root layout in
the canvas if there is no selection.

Some examples:

- In a LinearLayout, there are radio-button icons for switching
between horizontal and vertical orientation, and for toggling
baseline alignment

- There are toggle buttons for toggling between wrap_content and
match_parent (or fill_parent) for the layout_width and layout_height
properties

- There is a dropdown menu in LinearLayout and RelativeLayout which
lets you set the layout_gravity to one of the dozen gravity settings

- There is an action button which brings up a margin chooser dialog
where you can configure the margin settings for the currently
selected elements for layouts that support margins

There will be additional actions here in the future.

This changeset also adds a few new MenuAction subclasses and factories
to make it possible to do ordered lists of choices. It also adds
sorting keys to make it easier for parents and children to interleave
their actions with simple sorting keys rather than having to append,
prepend or merge their respective result lists. In a follow-up
changeset I will replace the context menu code to use these, as well
as attempt to make all actions stateless such that they can be cached
and reapplied for different targets.

Some misc cleanup.

Change-Id: I6a87144fcfd1d359e5561829bd5d63c852f16970
1f72cb7cb032538b79e79d6fc7ff3905e9766ce1 29-Jan-2011 Xavier Ducrohet <xav@android.com> Move Pair and annoatations into resources.jar now renamed as common.jar

Move all the resource query methods that returned an array of 2 Strings
to return a pair of ResourceType and String.

Change-Id: I6b8447aa27005de786e2defef81ad88a72363523
1fea27a759c2fbae154bbae0cd5ca02096f52d9a 31-Dec-2010 Raphael Moll <ralf@android.com> Move Pair<,> from ADT to SdkLib.utils

Change-Id: I5c37e4b4dd83bc239ed242709ede70982f14705f
a5d2bf173d15b74a6bcf57220c4e73b971bd09ab 17-Dec-2010 Tor Norbye <tnorbye@google.com> Rewrite Outline drag & drop handler

Rewrite the drag source and drop target listeners for the Outline. The
drop target listener now uses the SWT Tree support for drag & drop
(such that you for example get drop position feedback lines between
siblings). You can now drag items within the outline to do precise
reordering, as well as target particular positions during drops,
either within the outline or from the canvas or the palette.

This changeset also fixes a number of other issues I ran into at the same time:

- Fix keyboard shortcuts such that they map to the same context as the
canvas (e.g. when you activate the outline it shows the same undo
context as if you click in the associated canvas)

- Fix a bug with context menu code when none of the options are
selected in the XML

- Fix selection dispatch. If you had two side by side canvases,
selecting items in the Outline would show highlights in both
canvases; it now only causes selection syncing with the associated
canvas.

Change-Id: I00c3c38fabf3711c826a3bc527356cbc77ad4a7e
dc040487da0fed1b5f366c5435bdff3638bc37b6 30-Nov-2010 Tor Norbye <tnorbye@google.com> Rename some layout editor classes

This changeset contains only renaming of some classes (and a couple
of >100 column adjustments), no semantic changes.

The name changes are:

BaseView => BaseViewRule
BaseLayout => BaseLayoutRule
ScaleInfo => CanvasTransform
CanvasSelection => SelectionItem
PropertySheetPage2 => PropertySheetPage
OutlinePage2 => OutlinePage

Change-Id: I14d8c711b12154f4fcb2169129fd553e31fdab84