Omaha #5444 Fix hard coded GUI element sizes in WeatherElementBrowserDialog

Change-Id: Iebf30e7cec18b30b4254a9e9038a86ab5427a0a5

Former-commit-id: 775fe500cda918b9db62115e14503c9e0e5caa2a
This commit is contained in:
Ron Anderson 2016-03-07 14:04:26 -06:00
parent bbd0a34445
commit 48cbcacc08

View file

@ -34,6 +34,7 @@ import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
@ -41,7 +42,7 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
@ -70,11 +71,12 @@ import com.raytheon.viz.ui.widgets.ToggleSelectList;
* 04/30/2009 2282 rjpeter Refactored. * 04/30/2009 2282 rjpeter Refactored.
* 08/19/2009 2547 rjpeter Fix Test/Prac database display. * 08/19/2009 2547 rjpeter Fix Test/Prac database display.
* 02/22/2012 14351 mli update with incoming new grids. * 02/22/2012 14351 mli update with incoming new grids.
* 09/12/2012 #1117 dgilling Revert previous changes, retrieve * 09/12/2012 1117 dgilling Revert previous changes, retrieve
* database list from ParmManager * database list from ParmManager
* not EDEX. * not EDEX.
* 10/30/2012 1298 rferrel Code clean up non-blocking dialog. * 10/30/2012 1298 rferrel Code clean up non-blocking dialog.
* Changes for non-blocking WeatherElementGroupDialog. * Changes for non-blocking WeatherElementGroupDialog.
* 03/07/2016 5444 randerso Fix hard coded sizes of GUI elements
* </pre> * </pre>
* *
* @author ebabin * @author ebabin
@ -82,6 +84,12 @@ import com.raytheon.viz.ui.widgets.ToggleSelectList;
*/ */
public class WeatherElementBrowserDialog extends CaveJFACEDialog { public class WeatherElementBrowserDialog extends CaveJFACEDialog {
private static final int NUM_LIST_ITEMS = 10;
private static final int NUM_SEL_ITEMS = 20;
private static final int NUM_CHARS = 20;
private DataManager dataManager; private DataManager dataManager;
private Menu sourceMenu, fieldsMenu, presMenu, miscMenu; private Menu sourceMenu, fieldsMenu, presMenu, miscMenu;
@ -103,7 +111,7 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
private HashMap<String, ParmID> productIDs = new HashMap<String, ParmID>(); private HashMap<String, ParmID> productIDs = new HashMap<String, ParmID>();
private ToolBar sourceToolBar, fieldsToolBar, presToolBar, miscToolBar; private ToolBar sourceToolBar, fieldsToolBar, planesToolBar;
private ToolItem sourceToolItem, fieldsToolItem, presToolItem, private ToolItem sourceToolItem, fieldsToolItem, presToolItem,
miscToolItem; miscToolItem;
@ -112,30 +120,22 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
private ParmID[] currentDisplayedParms; private ParmID[] currentDisplayedParms;
private final Point size = new Point(603, 778);
private final String IFP = "IFP"; private final String IFP = "IFP";
private int charWidth;
/** /**
* Constructor * Constructor
*
* @param parent
* @param dataManager
*/ */
public WeatherElementBrowserDialog(Shell parent, DataManager dataManager) { public WeatherElementBrowserDialog(Shell parent, DataManager dataManager) {
super(parent); super(parent);
setShellStyle(SWT.TITLE | SWT.MODELESS | SWT.CLOSE); setShellStyle(SWT.TITLE | SWT.MODELESS | SWT.CLOSE | SWT.RESIZE);
this.dataManager = dataManager; this.dataManager = dataManager;
} }
@Override
protected Control createContents(Composite parent) {
Control contents = super.createContents(parent);
// Point size = getInitialSize();
getShell().setSize(size);
getShell().setLocation(getInitialLocation(size));
return contents;
}
@Override @Override
protected Control createDialogArea(Composite parent) { protected Control createDialogArea(Composite parent) {
Composite top = (Composite) super.createDialogArea(parent); Composite top = (Composite) super.createDialogArea(parent);
@ -185,9 +185,12 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
*/ */
private void initializeComponents(Composite parent) { private void initializeComponents(Composite parent) {
getDatabases(); getDatabases();
loadTypesAndSites(); loadTypesAndSites();
GC gc = new GC(parent);
charWidth = gc.getFontMetrics().getAverageCharWidth();
gc.dispose();
createTypesComp(parent); createTypesComp(parent);
createSourceComp(parent); createSourceComp(parent);
createFieldsComp(parent); createFieldsComp(parent);
@ -265,8 +268,8 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
public void dialogClosed(Object returnValue) { public void dialogClosed(Object returnValue) {
if (returnValue instanceof Integer) { if (returnValue instanceof Integer) {
int returnCode = (Integer) returnValue; int returnCode = (Integer) returnValue;
if (returnCode == Window.OK if ((returnCode == Window.OK)
&& dialog.getSelectedItem() != null) { && (dialog.getSelectedItem() != null)) {
String groupName = dialog.getSelectedItem(); String groupName = dialog.getSelectedItem();
// we may have just overridden a site or base level // we may have just overridden a site or base level
// group, need to verify menu item can be deleted // group, need to verify menu item can be deleted
@ -404,18 +407,16 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
*/ */
private void createTypesComp(Composite parent) { private void createTypesComp(Composite parent) {
GridData data = new GridData(100, 200); Group group = new Group(parent, SWT.BORDER);
Composite comp = new Composite(parent, SWT.BORDER); GridData layoutData = new GridData(SWT.DEFAULT, SWT.FILL, false, true);
comp.setLayoutData(data); group.setLayoutData(layoutData);
comp.setLayout(new GridLayout()); group.setLayout(new GridLayout());
Label lab = new Label(comp, SWT.NONE); group.setText("Types");
lab.setText("Types");
data = new GridData();
data.horizontalAlignment = SWT.CENTER;
lab.setLayoutData(data);
for (final WEBrowserTypeRecord entry : typeEntries) { for (final WEBrowserTypeRecord entry : typeEntries) {
final Button b = new Button(comp, SWT.RADIO | SWT.BORDER); final Button b = new Button(group, SWT.RADIO | SWT.BORDER);
layoutData = new GridData(SWT.DEFAULT, SWT.DEFAULT);
b.setLayoutData(layoutData);
b.setText(entry.getType()); b.setText(entry.getType());
b.addSelectionListener(new SelectionAdapter() { b.addSelectionListener(new SelectionAdapter() {
@Override @Override
@ -828,20 +829,16 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
* Creates the source composite. * Creates the source composite.
*/ */
private void createSourceComp(Composite parent) { private void createSourceComp(Composite parent) {
Composite comp = new Composite(parent, SWT.BORDER); Group group = new Group(parent, SWT.BORDER);
comp.setLayout(new GridLayout(1, true)); group.setLayout(new GridLayout(1, true));
GridData data = new GridData(140, 200); GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
comp.setLayoutData(data); group.setLayoutData(layoutData);
group.setText("Sources");
Label lab1 = new Label(comp, SWT.NONE);
lab1.setText("Sources");
data = new GridData();
data.horizontalAlignment = SWT.LEFT;
lab1.setLayoutData(data);
sourceMenu = new Menu(getParentShell(), SWT.POP_UP); sourceMenu = new Menu(getParentShell(), SWT.POP_UP);
sourceToolBar = new ToolBar(comp, SWT.NONE); sourceToolBar = new ToolBar(group, SWT.NONE);
sourceToolBar.setLayoutData(new GridData(90, SWT.DEFAULT)); sourceToolBar.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true,
false));
sourceToolItem = new ToolItem(sourceToolBar, SWT.DROP_DOWN); sourceToolItem = new ToolItem(sourceToolBar, SWT.DROP_DOWN);
sourceToolItem.setText("Source"); sourceToolItem.setText("Source");
@ -856,16 +853,20 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
sourceMenu.setVisible(true); sourceMenu.setVisible(true);
} }
}); });
sourceList = new ToggleSelectList(comp, SWT.V_SCROLL | SWT.MULTI); sourceList = new ToggleSelectList(group, SWT.V_SCROLL | SWT.H_SCROLL
data = new GridData(130, SWT.DEFAULT); | SWT.MULTI);
sourceList.addSelectionListener(new SelectionAdapter() { sourceList.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent arg0) { public void widgetSelected(SelectionEvent arg0) {
processSourceSelection(); processSourceSelection();
} }
}); });
data = new GridData(GridData.FILL_BOTH); layoutData = new GridData(GridData.FILL_BOTH);
sourceList.setLayoutData(data); Rectangle trim = sourceList.computeTrim(0, 0, charWidth * NUM_CHARS,
sourceList.getItemHeight() * NUM_LIST_ITEMS);
layoutData.widthHint = trim.width;
layoutData.heightHint = trim.height;
sourceList.setLayoutData(layoutData);
} }
private static void resetMenu(Menu menu) { private static void resetMenu(Menu menu) {
@ -880,19 +881,16 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
* Creates the field composite. * Creates the field composite.
*/ */
private void createFieldsComp(Composite parent) { private void createFieldsComp(Composite parent) {
GridData data = new GridData(140, 200); Group group = new Group(parent, SWT.BORDER);
Composite comp = new Composite(parent, SWT.BORDER); group.setLayout(new GridLayout());
comp.setLayout(new GridLayout()); GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
comp.setLayoutData(data); group.setLayoutData(layoutData);
group.setText("Fields");
Label lab = new Label(comp, SWT.NONE);
lab.setText("Fields");
data = new GridData();
data.horizontalAlignment = SWT.CENTER;
lab.setLayoutData(data);
fieldsMenu = new Menu(getParentShell(), SWT.POP_UP); fieldsMenu = new Menu(getParentShell(), SWT.POP_UP);
fieldsToolBar = new ToolBar(comp, SWT.NONE); fieldsToolBar = new ToolBar(group, SWT.NONE);
fieldsToolBar.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true,
false));
fieldsToolItem = new ToolItem(fieldsToolBar, SWT.DROP_DOWN); fieldsToolItem = new ToolItem(fieldsToolBar, SWT.DROP_DOWN);
fieldsToolItem.setText("Field"); fieldsToolItem.setText("Field");
fieldsToolItem.addSelectionListener(new SelectionAdapter() { fieldsToolItem.addSelectionListener(new SelectionAdapter() {
@ -905,42 +903,41 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
fieldsMenu.setVisible(true); fieldsMenu.setVisible(true);
} }
}); });
fieldsList = new ToggleSelectList(comp, SWT.V_SCROLL | SWT.MULTI); fieldsList = new ToggleSelectList(group, SWT.V_SCROLL | SWT.H_SCROLL
| SWT.MULTI);
fieldsList.addSelectionListener(new SelectionAdapter() { fieldsList.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent arg0) { public void widgetSelected(SelectionEvent arg0) {
processFieldSelection(); processFieldSelection();
} }
}); });
data = new GridData(GridData.FILL_BOTH); layoutData = new GridData(GridData.FILL_BOTH);
fieldsList.setLayoutData(data); Rectangle trim = sourceList.computeTrim(0, 0, charWidth * NUM_CHARS,
sourceList.getItemHeight() * NUM_LIST_ITEMS);
layoutData.widthHint = trim.width;
layoutData.heightHint = trim.height;
fieldsList.setLayoutData(layoutData);
} }
/** /**
* Creates the plans composite. * Creates the plans composite.
*/ */
private void createPlanesComp(Composite parent) { private void createPlanesComp(Composite parent) {
GridData data = new GridData(180, 200); Group group = new Group(parent, SWT.BORDER);
Composite comp = new Composite(parent, SWT.BORDER); group.setLayout(new GridLayout(2, false));
comp.setLayout(new GridLayout(2, false)); GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
comp.setLayoutData(data); group.setLayoutData(layoutData);
Label lab = new Label(comp, SWT.NONE); group.setText("Planes");
lab.setText("Planes");
data = new GridData();
data.horizontalAlignment = SWT.CENTER;
data.horizontalSpan = 2;
lab.setLayoutData(data);
presMenu = new Menu(getParentShell(), SWT.POP_UP); presMenu = new Menu(getParentShell(), SWT.POP_UP);
miscMenu = new Menu(getParentShell(), SWT.POP_UP); miscMenu = new Menu(getParentShell(), SWT.POP_UP);
presToolBar = new ToolBar(comp, SWT.NONE); planesToolBar = new ToolBar(group, SWT.NONE);
miscToolBar = new ToolBar(comp, SWT.NONE); planesToolBar.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true,
false));
presToolItem = new ToolItem(presToolBar, SWT.DROP_DOWN); presToolItem = new ToolItem(planesToolBar, SWT.DROP_DOWN);
presToolItem.setText("Pres"); presToolItem.setText("Pres");
miscToolItem = new ToolItem(miscToolBar, SWT.DROP_DOWN); miscToolItem = new ToolItem(planesToolBar, SWT.DROP_DOWN);
miscToolItem.setText("Misc"); miscToolItem.setText("Misc");
presToolItem.addSelectionListener(new SelectionAdapter() { presToolItem.addSelectionListener(new SelectionAdapter() {
@ -948,7 +945,7 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
Rectangle rect = presToolItem.getBounds(); Rectangle rect = presToolItem.getBounds();
Point pt = new Point(rect.x, rect.y + rect.height); Point pt = new Point(rect.x, rect.y + rect.height);
pt = presToolBar.toDisplay(pt); pt = planesToolBar.toDisplay(pt);
presMenu.setLocation(pt.x, pt.y); presMenu.setLocation(pt.x, pt.y);
presMenu.setVisible(true); presMenu.setVisible(true);
} }
@ -958,14 +955,15 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
Rectangle rect = miscToolItem.getBounds(); Rectangle rect = miscToolItem.getBounds();
Point pt = new Point(rect.x, rect.y + rect.height); Point pt = new Point(rect.x, rect.y + rect.height);
pt = miscToolBar.toDisplay(pt); pt = planesToolBar.toDisplay(pt);
miscMenu.setLocation(pt.x, pt.y); miscMenu.setLocation(pt.x, pt.y);
miscMenu.setVisible(true); miscMenu.setVisible(true);
} }
}); });
planesList = new ToggleSelectList(comp, SWT.V_SCROLL | SWT.MULTI); planesList = new ToggleSelectList(group, SWT.V_SCROLL | SWT.H_SCROLL
| SWT.MULTI);
planesList.addSelectionListener(new SelectionAdapter() { planesList.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent arg0) { public void widgetSelected(SelectionEvent arg0) {
@ -973,9 +971,13 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
} }
}); });
data = new GridData(GridData.FILL_BOTH); layoutData = new GridData(GridData.FILL_BOTH);
data.horizontalSpan = 2; Rectangle trim = sourceList.computeTrim(0, 0, charWidth * NUM_CHARS,
planesList.setLayoutData(data); sourceList.getItemHeight() * NUM_LIST_ITEMS);
layoutData.widthHint = trim.width;
layoutData.heightHint = trim.height;
layoutData.horizontalSpan = 2;
planesList.setLayoutData(layoutData);
} }
private Set<String> getMenuStringSet(Menu menu) { private Set<String> getMenuStringSet(Menu menu) {
@ -1028,12 +1030,14 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
* Creates the product selection composite. * Creates the product selection composite.
*/ */
private void createProductSelctionComp(Composite parent) { private void createProductSelctionComp(Composite parent) {
GridData data = new GridData(GridData.FILL_BOTH);
data.horizontalSpan = 4;
productSelectionList = new ToggleSelectList(parent, SWT.V_SCROLL productSelectionList = new ToggleSelectList(parent, SWT.V_SCROLL
| SWT.MULTI); | SWT.H_SCROLL | SWT.MULTI);
productSelectionList.setLayoutData(data); GridData layoutData = new GridData(GridData.FILL_BOTH);
layoutData.horizontalSpan = 4;
Rectangle trim = sourceList.computeTrim(0, 0, SWT.DEFAULT,
sourceList.getItemHeight() * NUM_SEL_ITEMS);
layoutData.heightHint = trim.height;
productSelectionList.setLayoutData(layoutData);
} }
/** /**