diff options
author | Raphael Moll <ralf@android.com> | 2010-11-18 14:55:17 -0800 |
---|---|---|
committer | Raphael Moll <ralf@android.com> | 2010-11-18 14:56:02 -0800 |
commit | 06ad677dd9875e20549f82bc2abf3e2b4cd4b321 (patch) | |
tree | 5a0c71ce7cd15c81a3707ca6be6911add651084b /eclipse/plugins/com.android.ide.eclipse.adt/src/com | |
parent | 797aebac4aa55532cc42125e8f09e46e2b52879d (diff) | |
download | sdk-06ad677dd9875e20549f82bc2abf3e2b4cd4b321.zip sdk-06ad677dd9875e20549f82bc2abf3e2b4cd4b321.tar.gz sdk-06ad677dd9875e20549f82bc2abf3e2b4cd4b321.tar.bz2 |
Cleanup and comment the refresh code in GLE2.
Change-Id: I95a922c463992600edfc8c25edfc688dc38f79bd
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt/src/com')
-rwxr-xr-x | eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java index 4335754..73711aa 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java @@ -184,7 +184,6 @@ public class GraphicalEditorPart extends EditorPart private ProjectCallback mProjectCallback; private ILayoutLog mLogger; - private boolean mNeedsXmlReload = false; private boolean mNeedsRecompute = false; private TargetListener mTargetListener; @@ -874,7 +873,7 @@ public class GraphicalEditorPart extends EditorPart * Responds to a page change that made the Graphical editor page the activated page. */ public void activated() { - if (mNeedsRecompute || mNeedsXmlReload) { + if (mNeedsRecompute) { recomputeLayout(); } } @@ -965,41 +964,28 @@ public class GraphicalEditorPart extends EditorPart * Callback for XML model changed. Only update/recompute the layout if the editor is visible */ public void onXmlModelChanged() { + // To optimize the rendering when the user is editing in the XML pane, we don't + // refresh the editor if it's not the active part. + // + // This behavior is acceptable when the editor is the single "full screen" part + // (as in this case active means visible.) + // Unfortunately this breaks in 2 cases: + // - when performing a drag'n'drop from one editor to another, the target is not + // properly refreshed before it becomes active. + // - when duplicating the editor window and placing both editors side by side (xml in one + // and canvas in the other one), the canvas may not be refreshed when the XML is edited. + // + // TODO find a way to really query whether the pane is visible, not just active. + if (mLayoutEditor.isGraphicalEditorActive()) { - doXmlReload(true /* force */); recomputeLayout(); } else { - mNeedsXmlReload = true; - } - } - - /** - * Actually performs the XML reload - * @see #onXmlModelChanged() - */ - private void doXmlReload(boolean force) { - if (force || mNeedsXmlReload) { - - // TODO : update the mLayoutCanvas, preserving the current selection if possible. - -// GraphicalViewer viewer = getGraphicalViewer(); -// -// // try to preserve the selection before changing the content -// SelectionManager selMan = viewer.getSelectionManager(); -// ISelection selection = selMan.getSelection(); -// -// try { -// viewer.setContents(getModel()); -// } finally { -// selMan.setSelection(selection); -// } - - mNeedsXmlReload = false; + // Remember we want to recompute as soon as the editor becomes active. + mNeedsRecompute = true; } } public void recomputeLayout() { - doXmlReload(false /* force */); try { if (!ensureFileValid()) { return; |