diff options
author | Tor Norbye <tnorbye@google.com> | 2011-03-07 14:16:48 -0800 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2011-03-11 16:06:48 -0800 |
commit | 9e6db060854d0e890190919a27a1846f50f69d1a (patch) | |
tree | 6e5e73e1cbb7549bdaf87d95d535dcf280d382a7 /eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/VisualRefactoringAction.java | |
parent | 826ed229db5562dfcb661bda2e9a2a9a844db3ce (diff) | |
download | sdk-9e6db060854d0e890190919a27a1846f50f69d1a.tar.gz |
Extract as Include support for configuration variations
First, add support for the "Extract as Include" refactoring to update
all identical code fragments in configuration variations of the same
file. For example, if you have a particular subtree of XML elements
in a file that you have then duplicated into say a landscape mode,
then applying the Extract as Include refactoring will locate the same
code fragment in both files, and replace *both* code fragments with an
include (and this is optional with a checkbox in the wizard
dialog). This only happens when the extracted code fragment is
"identical" in both files. The code fragments can vary in terms of XML
formatting and attribute order (and namespace prefix choice), but the
element hierarchy order, names, attributes defined and attribute
values must be identical.
Second, make fixes to the Change Layout and Change Widget Type
refactorings such that when the id of the converted element is
changed, then references to that id are updated as well.
Third, ensure that the refactorings are enabled even when there is no
text selection; in that case the refactoring will apply to the element
containing the caret.
Some test infrastructure improvements.
Change-Id: Idb4ba40f4217dba2b13881b3d06e269c80ba4b97
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/VisualRefactoringAction.java')
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/VisualRefactoringAction.java | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/VisualRefactoringAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/VisualRefactoringAction.java index 627f1b128..48181328f 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/VisualRefactoringAction.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/VisualRefactoringAction.java @@ -15,8 +15,8 @@ */ package com.android.ide.eclipse.adt.internal.editors.layout.refactoring; -import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AdtConstants; +import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor; import com.android.ide.eclipse.adt.internal.editors.layout.gle2.CanvasViewInfo; @@ -56,7 +56,7 @@ abstract class VisualRefactoringAction implements IWorkbenchWindowActionDelegate /** * Examine the selection to determine if the action should be enabled or not. * <p/> - * Keep a link to the relevant selection structure (i.e. a part of the Java AST). + * Keep a link to the relevant selection structure */ public void selectionChanged(IAction action, ISelection selection) { // Look for selections in XML and in the layout UI editor @@ -76,10 +76,8 @@ abstract class VisualRefactoringAction implements IWorkbenchWindowActionDelegate if (selection instanceof ITextSelection) { mTextSelection = (ITextSelection) selection; - if (mTextSelection.getLength() > 0) { - editor = getActiveEditor(); - mFile = getSelectedFile(editor); - } + editor = getActiveEditor(); + mFile = getSelectedFile(editor); } else if (selection instanceof ITreeSelection) { Object firstElement = ((ITreeSelection)selection).getFirstElement(); if (firstElement instanceof CanvasViewInfo) { |