From 5dfd87456cf988ffc45aeb686bd34125ce1912a4 Mon Sep 17 00:00:00 2001 From: angryziber Date: Mon, 17 Mar 2008 22:38:21 +0000 Subject: [PATCH] a better workaround for SWT bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=223015 git-svn-id: https://ipscan.svn.sourceforge.net/svnroot/ipscan/trunk@292 375186e5-ef17-0410-b0b6-91563547dcda --- .../azib/ipscan/config/ComponentRegistry.java | 3 +- src/net/azib/ipscan/gui/MainWindow.java | 32 ++++++++----------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/net/azib/ipscan/config/ComponentRegistry.java b/src/net/azib/ipscan/config/ComponentRegistry.java index e8561b5a..9e517524 100755 --- a/src/net/azib/ipscan/config/ComponentRegistry.java +++ b/src/net/azib/ipscan/config/ComponentRegistry.java @@ -129,7 +129,8 @@ public class ComponentRegistry { new ComponentParameter("controlsArea"), new ConstantParameter(new Integer(SWT.NONE))}); container.registerComponentImplementation("feederSelectionCombo", FeederSelectionCombo.class, new Parameter[] { - new ComponentParameter("controlsArea")}); + new ComponentParameter("controlsArea"), + anyComponentParameter}); // GUI Feeders container.registerComponentImplementation(FeederGUIRegistry.class); diff --git a/src/net/azib/ipscan/gui/MainWindow.java b/src/net/azib/ipscan/gui/MainWindow.java index d7847e13..c8629511 100755 --- a/src/net/azib/ipscan/gui/MainWindow.java +++ b/src/net/azib/ipscan/gui/MainWindow.java @@ -170,18 +170,12 @@ public class MainWindow { // steal the height from the second child of the FeederGUI - this must be the first edit box. // this results in better visual alignment with FeederGUIs Control secondControl = feederRegistry.current().getChildren()[1]; - int controlHeight = secondControl.getSize().y + 1; - - //System.out.println(((Text)secondControl).getT); + // initialize global standard button height + guiConfig.standardButtonHeight = secondControl.getSize().y + 1; - // start/stop button - shell.setDefaultButton(startStopButton); - startStopButton.setLayoutData(new RowData(SWT.DEFAULT, controlHeight)); - startStopButton.addSelectionListener(startStopScanningAction); - // feeder selection combobox this.feederSelectionCombo = feederSelectionCombo; - feederSelectionCombo.setLayoutData(new RowData(SWT.DEFAULT, controlHeight)); + feederSelectionCombo.setLayoutData(new RowData(SWT.DEFAULT, guiConfig.standardButtonHeight)); for (AbstractFeederGUI feederGUI : feederRegistry) { feederSelectionCombo.add(feederGUI.getFeederName()); } @@ -192,15 +186,14 @@ public class MainWindow { feederSelectionCombo.setToolTipText(Labels.getLabel("combobox.feeder.tooltip")); feederSelectionListener.widgetSelected(null); - //((RowData)startStopButton.getLayoutData()).height = feederSelectionCombo.getBounds().height; - ((RowData)startStopButton.getLayoutData()).width = feederSelectionCombo.getBounds().width; - + // start/stop button + shell.setDefaultButton(startStopButton); + startStopButton.setLayoutData(new RowData(feederSelectionCombo.getBounds().width, guiConfig.standardButtonHeight)); + startStopButton.addSelectionListener(startStopScanningAction); + // traverse the button before the combo (and don't traverse other buttons at all) controlsArea.setTabList(new Control[] {startStopButton, feederSelectionCombo}); - - // initialize global standard button height - guiConfig.standardButtonHeight = feederSelectionCombo.getBounds().height; - + int toolbarHeight = guiConfig.standardButtonHeight; int toolbarWidth = guiConfig.standardButtonHeight + (Platform.MAC_OS ? 20 : 0); @@ -273,14 +266,17 @@ public class MainWindow { } public static class FeederSelectionCombo extends Combo { - public FeederSelectionCombo(Composite parent) { + private final GUIConfig guiConfig; + + public FeederSelectionCombo(Composite parent, GUIConfig guiConfig) { super(parent, SWT.READ_ONLY); + this.guiConfig = guiConfig; } @Override public int getTextHeight() { // fixes the problem described here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=223015 - return super.getTextHeight() + ((getStyle() & SWT.READ_ONLY) > 0 ? 5 : 0); + return guiConfig.standardButtonHeight; } @Override