From fb8e792478c9bb32d1bb22894a8e8e2d2dfa5549 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Tue, 9 May 2017 14:33:05 +0100 Subject: [PATCH] Bug 515296: Collapse empty space when buttons are not visible With the new "Preferences" button in CSourceNotFoundEditor always visible, under some conditions (e.g. when no debug info available) there would be a large gap due to invisible buttons. This change does a relayout / exclude when the visibility of the buttons change. Change-Id: I68ae8665c286eb41f37fa823b3d3168175140ba3 --- .../sourcelookup/CSourceNotFoundEditor.java | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java index d5c1ccac57f..5097a20b563 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java @@ -84,8 +84,11 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor { private Button disassemblyButton; private Button locateFileButton; + private GridData locateFileButtonGridData; private Button editLookupButton; + private GridData editLookupButtonGridData; + private boolean isDebugElement; private boolean isTranslationUnit; private Text fText; @@ -93,6 +96,8 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor { private Text preferenceText; private Button preferenceButton; + private Composite buttonParentComposite; + public CSourceNotFoundEditor() { super(); } @@ -163,11 +168,17 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor { } private void syncButtons() { + boolean visible = missingFile.length() > 0; if (locateFileButton != null) { - locateFileButton.setVisible(missingFile.length() > 0); + locateFileButton.setVisible(visible); + locateFileButtonGridData.exclude = !visible; } if (editLookupButton != null) { - editLookupButton.setVisible(missingFile.length() > 0); + editLookupButton.setVisible(visible); + editLookupButtonGridData.exclude = !visible; + } + if (buttonParentComposite != null) { + buttonParentComposite.layout(true, true); } } @@ -199,6 +210,7 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor { @Override protected void createButtons(Composite parent) { + this.buttonParentComposite = parent; if (isDebugElement) { GridData data; disassemblyButton = new Button(parent, SWT.PUSH); @@ -217,12 +229,11 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor { } { - GridData data; locateFileButton = new Button(parent, SWT.PUSH); - data = new GridData(); - data.grabExcessHorizontalSpace = false; - data.grabExcessVerticalSpace = false; - locateFileButton.setLayoutData(data); + locateFileButtonGridData = new GridData(); + locateFileButtonGridData.grabExcessHorizontalSpace = false; + locateFileButtonGridData.grabExcessVerticalSpace = false; + locateFileButton.setLayoutData(locateFileButtonGridData); locateFileButton.setText(SourceLookupUIMessages.CSourceNotFoundEditor_1); locateFileButton.addSelectionListener(new SelectionAdapter() { @Override @@ -234,12 +245,11 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor { } if (isDebugElement) { - GridData data; editLookupButton = new Button(parent, SWT.PUSH); - data = new GridData(); - data.grabExcessHorizontalSpace = false; - data.grabExcessVerticalSpace = false; - editLookupButton.setLayoutData(data); + editLookupButtonGridData = new GridData(); + editLookupButtonGridData.grabExcessHorizontalSpace = false; + editLookupButtonGridData.grabExcessVerticalSpace = false; + editLookupButton.setLayoutData(editLookupButtonGridData); editLookupButton.setText(SourceLookupUIMessages.CSourceNotFoundEditor_5); editLookupButton.addSelectionListener(new SelectionAdapter() { @Override