本文整理了Java中org.eclipse.swt.widgets.Shell.getParent()
方法的一些代码示例,展示了Shell.getParent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Shell.getParent()
方法的具体详情如下:
包路径:org.eclipse.swt.widgets.Shell
类名称:Shell
方法名:getParent
暂无
代码示例来源:origin: caoxinyu/RedisClient
protected void setMiddle() {
Rectangle screenSize = shell.getParent().getBounds();
Rectangle shellSize = shell.getBounds();
shell.setLocation(screenSize.x + screenSize.width / 2 - shellSize.width / 2,
screenSize.y + screenSize.height / 2 - shellSize.height / 2);
}
代码示例来源:origin: pentaho/pentaho-kettle
if ( shell.getParent() != null ) {
monitor = shell.getParent().getMonitor();
代码示例来源:origin: pentaho/pentaho-kettle
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 );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static void setSize( Shell shell, int prefWidth, int prefHeight ) {
PropsUI props = PropsUI.getInstance();
WindowProperty winprop = props.getScreen( shell.getText() );
if ( winprop != null ) {
winprop.setShell( shell, prefWidth, prefHeight );
} else {
shell.layout();
winprop = new WindowProperty( shell.getText(), false, new Rectangle( 0, 0, prefWidth, prefHeight ) );
winprop.setShell( shell );
// 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 );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
if ( shell.getParent() != null ) {
monitor = shell.getParent().getMonitor();
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text
@Override
public void widgetDisposed(DisposeEvent e) {
Composite parent= null;
if (e.widget instanceof Shell)
parent= ((Shell)e.widget).getParent();
if (parent instanceof Shell)
fInformationControls.remove(parent);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text
@Override
public void widgetDisposed(DisposeEvent e) {
Composite parent= null;
if (e.widget instanceof Shell)
parent= ((Shell)e.widget).getParent();
if (parent instanceof Shell)
fInformationControls.remove(parent);
}
代码示例来源:origin: org.codehaus.openxma/xmartclient
private Shell getParentShell ( Shell child ) {
if (child != null) {
if (child.getParent() != null) {
return child.getParent().getShell();
}
}
return null;
}
}
代码示例来源:origin: org.codehaus.openxma/xmartserver
private Shell getParentShell ( Shell child ) {
if (child != null) {
if (child.getParent() != null) {
return child.getParent().getShell();
}
}
return null;
}
}
代码示例来源:origin: org.eclipse/org.eclipse.help.ui
public static boolean isDisplayModal(Shell activeShell) {
while (activeShell != null) {
if ((activeShell.getStyle() & (SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL | SWT.SYSTEM_MODAL)) > 0)
return true;
activeShell = (Shell) activeShell.getParent();
}
return false;
}
代码示例来源:origin: org.xworker/xworker_swt
public SwtDialog(Shell shell, ActionContext actionContext){
super((Shell) shell.getParent());
this.actionContext = actionContext;
this.myShell = shell;
setRWTShell();
}
代码示例来源:origin: org.eclipse.e4.ui.css/swt
public boolean isPseudoInstanceOf(String s) {
if ("active".equals(s)) {
return this.isActive;
}
if ("swt-parented".equals(s)) {
return getShell().getParent() != null;
}
if ("swt-unparented".equals(s)) {
return getShell().getParent() == null;
}
return super.isPseudoInstanceOf(s);
}
代码示例来源:origin: org.microemu/microemu-javase-swt
protected Point getInitialLocation(Point initialSize)
{
Composite parentShell = shell.getParent();
Rectangle containerBounds = (parentShell != null) ? parentShell.getBounds() : shell.getDisplay().getClientArea();
int x = Math.max(0, containerBounds.x + (containerBounds.width - initialSize.x) / 2);
int y = Math.max(0, containerBounds.y + (containerBounds.height - initialSize.y) / 3);
return new Point(x, y);
}
代码示例来源:origin: infinitest/infinitest
private void moveToParentDialogCenter(Shell dialog) {
if (dialog.getParent() == null) {
// No parent shell no positioning
return;
}
Point dialogSize = dialog.getSize();
Rectangle parentDialogBounds = dialog.getParent().getBounds();
Point newLocation = computeCenteredLocation(dialogSize, parentDialogBounds);
dialog.setLocation(newLocation);
}
代码示例来源:origin: org.eclipse.e4.ui.workbench.addons/swt
public DragHost(Shell shell) {
dragWindow = (MWindow) shell.getData(AbstractPartRenderer.OWNING_ME);
baseWindow = (MWindow) shell.getParent().getData(
AbstractPartRenderer.OWNING_ME);
dragElement = dragWindow.getChildren().get(0);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.e4.ui.workbench.addons.swt
public DragHost(Shell shell) {
dragWindow = (MWindow) shell.getData(AbstractPartRenderer.OWNING_ME);
baseWindow = (MWindow) shell.getParent().getData(
AbstractPartRenderer.OWNING_ME);
dragElement = dragWindow.getChildren().get(0);
}
代码示例来源:origin: stefanhaustein/flowgrid
public static void center(Shell dialog) {
Shell parent = (Shell) dialog.getParent();
Rectangle parentBounds = parent.getBounds();
Rectangle childBounds = dialog.getBounds();
dialog.setLocation(parentBounds.x + (parentBounds.width - childBounds.width) / 2,
parentBounds.y + (parentBounds.height - childBounds.height) / 2);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
/**
* Opens the key binding preference page, closes this dialog
*/
private int openPreferencePage() {
// Create a preference dialog on the keys preference page.
Shell shell = getShell();
if (shell.getParent() != null) {
shell = shell.getParent().getShell();
}
PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell,
keysPageId, null, getSelectedBinding());
close();
return dialog.open();
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
@Override
protected Point getInitialLocation(Point initialSize) {
if (getShell().getParent() == null) {
return super.getInitialLocation(initialSize);
}
Rectangle bounds = getShell().getParent().getMonitor().getBounds();
GC gc = new GC(getShell().getDisplay());
int textExtendX = gc.textExtent(message).x;
gc.dispose();
return new Point(bounds.x + bounds.width / 2 - textExtendX / 2, bounds.y + bounds.height / 5);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
/**
* Opens the dialog.
*/
public void open() {
shell.pack();
final Shell parentShell = (Shell) shell.getParent();
Rectangle rect = parentShell.getBounds();
Rectangle bounds = shell.getBounds();
bounds.x = rect.x + (rect.width - bounds.width) / 2;
bounds.y = rect.y + (rect.height - bounds.height) / 2;
shell.setBounds(bounds);
shell.open();
}
/**
内容来源于网络,如有侵权,请联系作者删除!