OSDN Git Service

Layout editor property menu improvements
authorTor Norbye <tnorbye@google.com>
Mon, 15 Aug 2011 23:38:30 +0000 (16:38 -0700)
committerTor Norbye <tnorbye@google.com>
Fri, 19 Aug 2011 23:43:08 +0000 (16:43 -0700)
commite287bc8580e19d72a911615475b353790cf000eb
treeb9fa61fcb0b68f29fdd56359b84bb37aa815c4ab
parent39f953c53d4388044afdac63629e260b0a1ddce5
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
31 files changed:
attribute_stats/.classpath [new file with mode: 0644]
attribute_stats/.gitignore [new file with mode: 0644]
attribute_stats/.project [new file with mode: 0644]
attribute_stats/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
attribute_stats/README.txt [new file with mode: 0644]
attribute_stats/src/Analyzer.java [new file with mode: 0644]
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseViewRule.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/EditTextRule.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LayoutConstants.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LinearLayoutRule.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/resources/platform/AttributeInfo.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/resources/platform/AttrsXmlParser.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/resources/platform/DeclareStyleableInfo.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/ElementDescriptor.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/LayoutDescriptors.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/ViewElementDescriptor.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/DynamicContextMenu.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ClientRulesEngine.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/NodeProxy.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ViewMetadataRepository.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/extra-view-metadata.xml
eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/BaseViewRuleTest.java
eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LayoutTestBase.java
eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LinearLayoutRuleTest.java
eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestAttributeInfo.java
eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestNode.java
eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gre/ViewMetadataRepositoryTest.java
rule_api/src/com/android/ide/common/api/IAttributeInfo.java
rule_api/src/com/android/ide/common/api/INode.java
rule_api/src/com/android/ide/common/api/IViewMetadata.java