Omaha #5444 Fix hard coded GUI element sizes in WeatherElementBrowserDialog
Change-Id: Iebf30e7cec18b30b4254a9e9038a86ab5427a0a5 Former-commit-id: 775fe500cda918b9db62115e14503c9e0e5caa2a
This commit is contained in:
parent
bbd0a34445
commit
48cbcacc08
1 changed files with 92 additions and 88 deletions
|
@ -34,6 +34,7 @@ import org.eclipse.jface.window.Window;
|
|||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
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.Composite;
|
||||
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.MenuItem;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
@ -70,11 +71,12 @@ import com.raytheon.viz.ui.widgets.ToggleSelectList;
|
|||
* 04/30/2009 2282 rjpeter Refactored.
|
||||
* 08/19/2009 2547 rjpeter Fix Test/Prac database display.
|
||||
* 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
|
||||
* not EDEX.
|
||||
* 10/30/2012 1298 rferrel Code clean up non-blocking dialog.
|
||||
* Changes for non-blocking WeatherElementGroupDialog.
|
||||
* 03/07/2016 5444 randerso Fix hard coded sizes of GUI elements
|
||||
* </pre>
|
||||
*
|
||||
* @author ebabin
|
||||
|
@ -82,6 +84,12 @@ import com.raytheon.viz.ui.widgets.ToggleSelectList;
|
|||
*/
|
||||
|
||||
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 Menu sourceMenu, fieldsMenu, presMenu, miscMenu;
|
||||
|
@ -103,7 +111,7 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
|
|||
|
||||
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,
|
||||
miscToolItem;
|
||||
|
@ -112,30 +120,22 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
|
|||
|
||||
private ParmID[] currentDisplayedParms;
|
||||
|
||||
private final Point size = new Point(603, 778);
|
||||
|
||||
private final String IFP = "IFP";
|
||||
|
||||
private int charWidth;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param parent
|
||||
* @param dataManager
|
||||
*/
|
||||
public WeatherElementBrowserDialog(Shell parent, DataManager dataManager) {
|
||||
super(parent);
|
||||
setShellStyle(SWT.TITLE | SWT.MODELESS | SWT.CLOSE);
|
||||
setShellStyle(SWT.TITLE | SWT.MODELESS | SWT.CLOSE | SWT.RESIZE);
|
||||
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
|
||||
protected Control createDialogArea(Composite parent) {
|
||||
Composite top = (Composite) super.createDialogArea(parent);
|
||||
|
@ -185,9 +185,12 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
|
|||
*/
|
||||
private void initializeComponents(Composite parent) {
|
||||
getDatabases();
|
||||
|
||||
loadTypesAndSites();
|
||||
|
||||
GC gc = new GC(parent);
|
||||
charWidth = gc.getFontMetrics().getAverageCharWidth();
|
||||
gc.dispose();
|
||||
|
||||
createTypesComp(parent);
|
||||
createSourceComp(parent);
|
||||
createFieldsComp(parent);
|
||||
|
@ -265,8 +268,8 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
|
|||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof Integer) {
|
||||
int returnCode = (Integer) returnValue;
|
||||
if (returnCode == Window.OK
|
||||
&& dialog.getSelectedItem() != null) {
|
||||
if ((returnCode == Window.OK)
|
||||
&& (dialog.getSelectedItem() != null)) {
|
||||
String groupName = dialog.getSelectedItem();
|
||||
// we may have just overridden a site or base level
|
||||
// group, need to verify menu item can be deleted
|
||||
|
@ -404,18 +407,16 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
|
|||
*/
|
||||
private void createTypesComp(Composite parent) {
|
||||
|
||||
GridData data = new GridData(100, 200);
|
||||
Composite comp = new Composite(parent, SWT.BORDER);
|
||||
comp.setLayoutData(data);
|
||||
comp.setLayout(new GridLayout());
|
||||
Label lab = new Label(comp, SWT.NONE);
|
||||
lab.setText("Types");
|
||||
data = new GridData();
|
||||
data.horizontalAlignment = SWT.CENTER;
|
||||
lab.setLayoutData(data);
|
||||
Group group = new Group(parent, SWT.BORDER);
|
||||
GridData layoutData = new GridData(SWT.DEFAULT, SWT.FILL, false, true);
|
||||
group.setLayoutData(layoutData);
|
||||
group.setLayout(new GridLayout());
|
||||
group.setText("Types");
|
||||
|
||||
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.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
|
@ -828,20 +829,16 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
|
|||
* Creates the source composite.
|
||||
*/
|
||||
private void createSourceComp(Composite parent) {
|
||||
Composite comp = new Composite(parent, SWT.BORDER);
|
||||
comp.setLayout(new GridLayout(1, true));
|
||||
GridData data = new GridData(140, 200);
|
||||
comp.setLayoutData(data);
|
||||
|
||||
Label lab1 = new Label(comp, SWT.NONE);
|
||||
lab1.setText("Sources");
|
||||
data = new GridData();
|
||||
data.horizontalAlignment = SWT.LEFT;
|
||||
lab1.setLayoutData(data);
|
||||
Group group = new Group(parent, SWT.BORDER);
|
||||
group.setLayout(new GridLayout(1, true));
|
||||
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
group.setLayoutData(layoutData);
|
||||
group.setText("Sources");
|
||||
|
||||
sourceMenu = new Menu(getParentShell(), SWT.POP_UP);
|
||||
sourceToolBar = new ToolBar(comp, SWT.NONE);
|
||||
sourceToolBar.setLayoutData(new GridData(90, SWT.DEFAULT));
|
||||
sourceToolBar = new ToolBar(group, SWT.NONE);
|
||||
sourceToolBar.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true,
|
||||
false));
|
||||
|
||||
sourceToolItem = new ToolItem(sourceToolBar, SWT.DROP_DOWN);
|
||||
sourceToolItem.setText("Source");
|
||||
|
@ -856,16 +853,20 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
|
|||
sourceMenu.setVisible(true);
|
||||
}
|
||||
});
|
||||
sourceList = new ToggleSelectList(comp, SWT.V_SCROLL | SWT.MULTI);
|
||||
data = new GridData(130, SWT.DEFAULT);
|
||||
sourceList = new ToggleSelectList(group, SWT.V_SCROLL | SWT.H_SCROLL
|
||||
| SWT.MULTI);
|
||||
sourceList.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent arg0) {
|
||||
processSourceSelection();
|
||||
}
|
||||
});
|
||||
data = new GridData(GridData.FILL_BOTH);
|
||||
sourceList.setLayoutData(data);
|
||||
layoutData = new GridData(GridData.FILL_BOTH);
|
||||
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) {
|
||||
|
@ -880,19 +881,16 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
|
|||
* Creates the field composite.
|
||||
*/
|
||||
private void createFieldsComp(Composite parent) {
|
||||
GridData data = new GridData(140, 200);
|
||||
Composite comp = new Composite(parent, SWT.BORDER);
|
||||
comp.setLayout(new GridLayout());
|
||||
comp.setLayoutData(data);
|
||||
|
||||
Label lab = new Label(comp, SWT.NONE);
|
||||
lab.setText("Fields");
|
||||
data = new GridData();
|
||||
data.horizontalAlignment = SWT.CENTER;
|
||||
lab.setLayoutData(data);
|
||||
Group group = new Group(parent, SWT.BORDER);
|
||||
group.setLayout(new GridLayout());
|
||||
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
group.setLayoutData(layoutData);
|
||||
group.setText("Fields");
|
||||
|
||||
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.setText("Field");
|
||||
fieldsToolItem.addSelectionListener(new SelectionAdapter() {
|
||||
|
@ -905,42 +903,41 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
|
|||
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() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent arg0) {
|
||||
processFieldSelection();
|
||||
}
|
||||
});
|
||||
data = new GridData(GridData.FILL_BOTH);
|
||||
fieldsList.setLayoutData(data);
|
||||
layoutData = new GridData(GridData.FILL_BOTH);
|
||||
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.
|
||||
*/
|
||||
private void createPlanesComp(Composite parent) {
|
||||
GridData data = new GridData(180, 200);
|
||||
Composite comp = new Composite(parent, SWT.BORDER);
|
||||
comp.setLayout(new GridLayout(2, false));
|
||||
comp.setLayoutData(data);
|
||||
Label lab = new Label(comp, SWT.NONE);
|
||||
lab.setText("Planes");
|
||||
data = new GridData();
|
||||
data.horizontalAlignment = SWT.CENTER;
|
||||
data.horizontalSpan = 2;
|
||||
|
||||
lab.setLayoutData(data);
|
||||
Group group = new Group(parent, SWT.BORDER);
|
||||
group.setLayout(new GridLayout(2, false));
|
||||
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
group.setLayoutData(layoutData);
|
||||
group.setText("Planes");
|
||||
|
||||
presMenu = new Menu(getParentShell(), SWT.POP_UP);
|
||||
miscMenu = new Menu(getParentShell(), SWT.POP_UP);
|
||||
|
||||
presToolBar = new ToolBar(comp, SWT.NONE);
|
||||
miscToolBar = new ToolBar(comp, SWT.NONE);
|
||||
|
||||
presToolItem = new ToolItem(presToolBar, SWT.DROP_DOWN);
|
||||
planesToolBar = new ToolBar(group, SWT.NONE);
|
||||
planesToolBar.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true,
|
||||
false));
|
||||
presToolItem = new ToolItem(planesToolBar, SWT.DROP_DOWN);
|
||||
presToolItem.setText("Pres");
|
||||
miscToolItem = new ToolItem(miscToolBar, SWT.DROP_DOWN);
|
||||
miscToolItem = new ToolItem(planesToolBar, SWT.DROP_DOWN);
|
||||
miscToolItem.setText("Misc");
|
||||
|
||||
presToolItem.addSelectionListener(new SelectionAdapter() {
|
||||
|
@ -948,7 +945,7 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
|
|||
public void widgetSelected(SelectionEvent event) {
|
||||
Rectangle rect = presToolItem.getBounds();
|
||||
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.setVisible(true);
|
||||
}
|
||||
|
@ -958,14 +955,15 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
|
|||
public void widgetSelected(SelectionEvent event) {
|
||||
Rectangle rect = miscToolItem.getBounds();
|
||||
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.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() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent arg0) {
|
||||
|
@ -973,9 +971,13 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
|
|||
}
|
||||
});
|
||||
|
||||
data = new GridData(GridData.FILL_BOTH);
|
||||
data.horizontalSpan = 2;
|
||||
planesList.setLayoutData(data);
|
||||
layoutData = new GridData(GridData.FILL_BOTH);
|
||||
Rectangle trim = sourceList.computeTrim(0, 0, charWidth * NUM_CHARS,
|
||||
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) {
|
||||
|
@ -1028,12 +1030,14 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
|
|||
* Creates the product selection composite.
|
||||
*/
|
||||
private void createProductSelctionComp(Composite parent) {
|
||||
GridData data = new GridData(GridData.FILL_BOTH);
|
||||
data.horizontalSpan = 4;
|
||||
|
||||
productSelectionList = new ToggleSelectList(parent, SWT.V_SCROLL
|
||||
| SWT.MULTI);
|
||||
productSelectionList.setLayoutData(data);
|
||||
| SWT.H_SCROLL | SWT.MULTI);
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue