use of org.eclipse.swt.widgets.Monitor in project pentaho-kettle by pentaho.
the class BaseStepDialog method setSize.
/**
* Sets the size of this dialog with respect to the given parameters.
*
* @param shell the shell
* @param minWidth the minimum width
* @param minHeight the minimum height
* @param packIt true to pack the dialog components, false otherwise
*/
public static void setSize(Shell shell, int minWidth, int minHeight, boolean packIt) {
PropsUI props = PropsUI.getInstance();
WindowProperty winprop = props.getScreen(shell.getText());
if (winprop != null) {
winprop.setShell(shell, minWidth, minHeight);
} else {
if (packIt) {
shell.pack();
} else {
shell.layout();
}
// OK, sometimes this produces dialogs that are waay too big.
// Try to limit this a bit, m'kay?
// Use the same algorithm by cheating :-)
//
winprop = new WindowProperty(shell);
winprop.setShell(shell, minWidth, minHeight);
// Now, as this is the first time it gets opened, try to put it in the middle of the screen...
Rectangle shellBounds = shell.getBounds();
Monitor monitor = shell.getDisplay().getPrimaryMonitor();
if (shell.getParent() != null) {
monitor = shell.getParent().getMonitor();
}
Rectangle monitorClientArea = monitor.getClientArea();
int middleX = monitorClientArea.x + (monitorClientArea.width - shellBounds.width) / 2;
int middleY = monitorClientArea.y + (monitorClientArea.height - shellBounds.height) / 2;
shell.setLocation(middleX, middleY);
}
}
use of org.eclipse.swt.widgets.Monitor in project pentaho-kettle by pentaho.
the class BaseStepXulDialog method setSize.
public static void setSize(Shell shell, int minWidth, int minHeight, boolean packIt) {
PropsUI props = PropsUI.getInstance();
WindowProperty winprop = props.getScreen(shell.getText());
if (winprop != null) {
winprop.setShell(shell, minWidth, minHeight);
} else {
if (packIt) {
shell.pack();
} else {
shell.layout();
}
// OK, sometimes this produces dialogs that are waay too big.
// Try to limit this a bit, m'kay?
// Use the same algorithm by cheating :-)
//
winprop = new WindowProperty(shell);
winprop.setShell(shell, minWidth, minHeight);
// Now, as this is the first time it gets opened, try to put it in the middle of the screen...
Rectangle shellBounds = shell.getBounds();
Monitor monitor = shell.getDisplay().getPrimaryMonitor();
if (shell.getParent() != null) {
monitor = shell.getParent().getMonitor();
}
Rectangle monitorClientArea = monitor.getClientArea();
int middleX = monitorClientArea.x + (monitorClientArea.width - shellBounds.width) / 2;
int middleY = monitorClientArea.y + (monitorClientArea.height - shellBounds.height) / 2;
shell.setLocation(middleX, middleY);
}
}
use of org.eclipse.swt.widgets.Monitor in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_Control method test_getMonitor.
@Test
public void test_getMonitor() {
Monitor monitor = control.getMonitor();
assertNotNull(monitor);
Display display = control.getDisplay();
Monitor[] monitors = display.getMonitors();
int i;
/* monitor must be listed in Display.getMonitors */
for (i = 0; i < monitors.length; i++) {
if (monitor.equals(monitors[i]))
break;
}
if (i == monitors.length) {
fail("Control.getMonitor does not return a monitor listed in Display.getMonitors");
}
}
use of org.eclipse.swt.widgets.Monitor in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_Display method test_getPrimaryMonitor.
/**
* Note, this is hard to test via unit tests as you might not have multiple monitors.
* When altering this function, it is recommended to perform
* the following tests manually:
* - Dual monitors with:
* - Primary being on the left
* - Primary being on the right
* - Stacked displays, primary on top
* - Stack displays, primary on bottom
* - Single display
*/
@Test
public void test_getPrimaryMonitor() {
Display display = new Display();
Monitor monitor = display.getPrimaryMonitor();
assertNotNull(monitor);
display.dispose();
}
use of org.eclipse.swt.widgets.Monitor in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_Display method test_getMonitors.
@Test
public void test_getMonitors() {
Display display = new Display();
Monitor[] monitors = display.getMonitors();
assertNotNull(monitors);
assertTrue("at least one monitor should be returned", monitors.length >= 1);
for (int i = 0; i < monitors.length; i++) assertNotNull("monitor at index " + i + " should not be null", monitors[i]);
display.dispose();
}
Aggregations