History log of /sdk/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonXmlEditor.java
Revision Date Author Comments
630d28af94d1d7f5f791e49d8504a16b7f4559a4 19-Sep-2012 Tor Norbye <tnorbye@google.com> Improve last editor mode handling

We recently added the ability for the IDE to remember whether you last
edited an XML file in text mode or in graphical mode (see issue
31340). However, this was tracked with a single boolean flag, which
meant that it was an "all or nothing" flag.

However, you may want to always edit string resource files with the
XML editor, but you want to always use the graphical editor for the
manifest file.

In this changeset, the state is kept in a bitmask instead, which
allows us to track the broad editor types separately. With this, new
editors are opened according to the last mode you used for that type
of editor. (Note that it tracks "categories" of editors, not
individual resource types, so for example the editor for color
resources and the editor for state list drawables share the same last
mode as the string resource editor. This is because these editors
share roughly the same graphical editing capabilities.)

(The CL also contains some minor code cleanup.)

Change-Id: I4624dffa2349230684c0558a33081adda8d799b2
fe51dba2aa25e559786e5da315d4db714ffe7559 12-Sep-2012 Tor Norbye <tnorbye@google.com> Support separate layout editors for a single layout resource

This changeset changes the "reuse" behavior of the layout editor to no
longer reuse the same layout editor when you are switching between
alternate layout files for the same layout resource, such as
layout/foo.xml and layout-land/foo.xml. This lets you more quickly
switch back and forth and inspect differences between the layouts,
etc. There is also an option in the Android > Editors panel to turn on
single editor sharing again.

The biggest part of the changeset, by far, is a cleanup of the
ConfigurationComposite class and associated code. This was necessary
not just to support the above feature (where we need to "back out" UI
changes when you've made a configuration edit which results in a
different file getting opened), but it's also an important preparation
for multi configuration editing, where we need to be able to switch
configuration settings in and out of a single configuration editor,
etc.

The configuration data itself is now in a separate Configuration
class; the UI is in ConfigurationChooser, and the configuration
matching code is in ConfigurationMatcher. There's also a new Locale
class to track language/region pairs instead of using 2-element
ResourceQualifier arrays. The various menu listeners are also in
separate UI classes now. While there are new classes, most of the
configuration matching algorithm is unchanged, just moved to a new
class and the UI syncing and configuration data lookup replaced.

Bitmasks are used to handle configuration changes, such that updating
multiple related attributes (e.g. a rendering target change also
causes a theme change if say Holo isn't available) can now be processed
just once with a single change call.

(Various other cleanup too.)

Change-Id: I04ac969f46824321be3db0c487ef077c03cc6012
8c83dcc3ec2cb72e44ddac7372980732f439d70d 18-Jul-2012 Tor Norbye <tnorbye@google.com> Fix keybindings in various XML editors for Eclipse 4.x.

This changeset attempts to fix the issue with cut/copy/paste (and
other keybindings) not working properly in the non-layout XML
files. The symptom is that the action appears not to work, but is
actually applied to a different editor.

I haven't figured out why this happens in e4; after you switch focus
the editor action map should switch, but the fix here is to listen for
part changes, and manually reset the action bindings whenever this
happens.

This fixes issue 34630 (as well as several duplicates filed recently).

Change-Id: Ia1134c16ac3323a8a03f2c61182d810b7f7d2589
9e758709bf4cc90059cc135d55cfc6d446b439f0 05-Jun-2012 Tor Norbye <tnorbye@google.com> Fix Cut & Paste in value files for Eclipse 4.x

This changeset works around the following bug in Eclipse 4.2:

* Open some arbitrary file, like main.xml.
* Open strings.xml for the first time. (If it has already been opened,
switch to the graphical tab, close it, and start again).
* Place the caret in strings.xml and paste something from the
clipboard. In Eclipse 4.x, strings.xml will not change, but the
*other* file is edited to include the new paste!

This appears to be related to some sort of change in the defaults for
action bar registrations in Eclipse 4. The workaround is to explicitly
set these actions on each opened editor, which seems to fix the
problem in 4.2 (and things still work in 3.7).

Change-Id: I86035d7921102ff684adf319c3bf5f94ce416cb7
253bfc9e4a7b3a0ffd42c7a364763e16db66edb2 20-Mar-2012 Tor Norbye <tnorbye@google.com> Add plain XML editor for typeless XML files

This changeset adds a new editor delegate, "PlainXmlEditorDelegate",
which is used for XML files that have no associated resource
type. This is used instead of the OtherXmlEditorDelegate, which is
intended for resource files.

This changeset means that if you open the lint.xml file in the root of
the project, you no longer get a form (which wasn't helpful since we
don't have descriptors for that filetype).

Change-Id: I776f7dbe2b9fc994993b26524cc2965d014496aa
b9317238c40c76f9a31647021f232adba6da0979 15-Mar-2012 Tor Norbye <tnorbye@google.com> Use XML outline in the layout editor when editing text

This changeset adds an XML outline in the layout XML editor when
editing text, and the graphical outline when the graphical layout
editor tab is shown. This is complicated because it's not really
supported in Eclipse:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=1917

See the long comment in LayoutEditorDelegate.delegateGetAdapter for an
explanation of the two tricks involved:
- Using a multiplexing outline implementation to switch outlines,
triggered by editor page switch notifications
- Using a selection listener to anticipate when the XML outline is
attempting to react to editor selection events and return the
non-multiplexing outline from getAdapter in that specific scenario

While I was at it I also made the outline customized to handle our
icons, similar to how the quick outline already handles it, and fixed
the quick outline to work with the new delegated editors.

Change-Id: I0b7ea8c8d8c09d2ecc1500689f9dda4b5db2b492
8894233bc9e334d4fcaa129e65170d0ef7d919da 08-Mar-2012 Raphael <raphael@google.com> ADT: Use file path to find which editor to use.

In case we don't have any ResourceFolder information
when opening a file using the CommonXmlEditor, we can
fallback on the foldername to find which delegate to use.

Change-Id: Id83f0c70ddfdc81de867cd8489135eaec45aa2c3
f14914e59366377316c70f068347d3e34a1dea3c 29-Feb-2012 Tor Norbye <tnorbye@google.com> Make XML editors work with non-workspace files

This changeset makes the AndroidXmlEditor handle other editor inputs
than just FileEditorInput. In particular, it now handles
IURIEditorInput as well. This makes the "Go To Declaration" facility
for @android resources work properly again, and unlike before, you can
now use our editors in those files as well, so you can use Go To
Declaration to jump to other @android resources within the same
platform.

This changeset adds checks after all the getInputFile() calls on the
editor, which ensures that features which assume a file exists (such
as the quickfix and visual refactoring operations) do not do anything
in these files.

The layout editor has a lot of file requirements, so that editor is
deliberately skipped and you get a plain editor instead if you try to
open layout files outside of the workspace.

See
http://code.google.com/p/android/issues/detail?id=26164

Change-Id: I7457494ec0bfc2eb4e6eba2e059025142c21d3ce
ecd69dd768fc25aeb12791a477c44e04f007d5f4 21-Feb-2012 Raphael <raphael@google.com> ADT fix save on layout configuration change.

When a layout is opened and its configuration is changed,
the new delegate layout wasn't properly saving the layout
before changing files.

This is due to another instance of the delegate code calling
a method on the delegate whereas it should have called a method
with the same exact name on the editor.
To reduce this confusion, this CL adds a 'delegate' prefix to
methods which are common in the CommonXmlEditor and the delegates.
At the expense of being a bit more verbose it makes it clearer
which method is being invoked.

Change-Id: I34e620a9d25272fe75dab54279161b04a961a598
c068e0e4646318364119eb17bff596866faa3a36 21-Feb-2012 Raphael <raphael@google.com> ADT fix GLE configuration change.

SDK Bug: 6036506

Change-Id: I92f86940bf158ca8da8597a7f387d1f2595c0131
fdd7eb0ab3b26a8751bb4451893d26827c391d23 06-Feb-2012 Raphael <raphael@google.com> SDK: verbose log for CommonXmlEditor.

This just adds a simple printf of the resFolder + type
when the CommonXmlEditor can't find a matching delegate.

Also a 1-character typo fix in a lint message
and ignore bin/gen folders for the sdk controller app.

Change-Id: If43877e6c4d4158c475507671993fe29716a7c5e
15863d56ac9a7bd2079fd1c2d68a14a9ecbcafc8 23-Jan-2012 Raphael <raphael@google.com> ADT: fix missing supportsFormatOnGuiEdit delegate method.

Also makes the base xmlModelChanged(doc) abstract since
there is no useful base implementation.

Change-Id: I2fbe4c9c8f261c983c76c6ff1b60fb11c9e10b97
155c33b963bc135697f65b93fdfb63ffe531153b 21-Jan-2012 Raphael <raphael@google.com> ADT: SourceViewerConfig for CommonXmlEditor.

Change-Id: I918cba752bf55445197cb7be208af4891f3d3bca
734d947687f3f3a761f404dbb0bf3dfe8f3f5843 21-Jan-2012 Raphael <raphael@google.com> ADT: Refactor CommonXmlEditor in its own package.

Change-Id: I0ee61ade9ea15335268fa313b74d9a949ecb189f