org.eclipse.swt.widgets.Shell#layout ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Shell#layout ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hop   文件: BaseTransformDialog.java
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, 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 );
  }
}
 
源代码2 项目: nebula   文件: DropTestSnippet.java
public void open() {
	Shell parent = getParent();
	final Shell shell = new Shell(parent, getStyle());
	shell.setText("Testing");
	shell.setLayout(new GridLayout());

	final CDateTime cdc2 = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
	cdc2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

	Display display = parent.getDisplay();
	shell.layout(true, true);
	shell.pack();
	int x = shell.getSize().x;
	int y = shell.getSize().y;
	shell.setLocation(
			(display.getBounds().width-x)/2,
			(display.getBounds().height-y)/2
	);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) display.sleep();
	}
}
 
源代码3 项目: nebula   文件: DropTestSnippet.java
public void open() {
	Shell parent = getParent();
	final Shell shell = new Shell(parent, getStyle());
	shell.setText("Testing");
	shell.setLayout(new GridLayout());

	final BaseCombo cdc2 = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
	cdc2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

	Display display = parent.getDisplay();
	shell.layout(true, true);
	shell.pack();
	int x = shell.getSize().x;
	int y = shell.getSize().y;
	shell.setLocation(
			(display.getBounds().width-x)/2,
			(display.getBounds().height-y)/2
	);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) display.sleep();
	}
}
 
源代码4 项目: tuxguitar   文件: SWTDialogUtils.java
public static final void openDialog(final Shell dialog, final Shell parent, int style){
	if((style & OPEN_STYLE_PACK) != 0){
		dialog.pack();
	}
	if((style & OPEN_STYLE_LAYOUT) != 0){
		dialog.layout();
	}
	if((style & OPEN_STYLE_MAXIMIZED) != 0){
		dialog.setMaximized(true);
	}
	else if((style & OPEN_STYLE_CENTER) != 0){
		int x = Math.max(0,parent.getBounds().x + (parent.getBounds().width - dialog.getSize().x) / 2);
		int y = Math.max(0,parent.getBounds().y + (parent.getBounds().height - dialog.getSize().y) / 2);
		dialog.setLocation(x,y);
	}
	dialog.open();
}
 
源代码5 项目: AndroidRobot   文件: LogAnalysis.java
/**
 * Open the window.
 */
public void open() {
    display = Display.getDefault();
    shell = new Shell();
    shell.setLayout(new FormLayout());
    shell.open();
    shell.setSize(800, 600);
    shell.setText("日志分析系统");
    shell.setImage(new Image(display, ClassLoader.getSystemResourceAsStream("icons/log.png")));

    createToolBar();
    createSashForm();
    createStatusBar();
    loadLogs();

    shell.layout();
    while (shell != null & !shell.isDisposed()) {
        if (display != null && !display.readAndDispatch()) {
            display.sleep();
        }
    }

}
 
源代码6 项目: APICloud-Studio   文件: APICloudSplashHandler.java
public void init(final Shell splash) {
	super.init(splash);
	if (AuthenticActivator.getFile().exists()
			&&AuthenticActivator.getProperties().getProperty("username") != null) {
		isLogin = false;
		Properties p =AuthenticActivator.getProperties();
		fAuthenticated = login(
				p.getProperty("username"),
				RC4Util.HloveyRC4(p.getProperty("password"),RC4Util.getKey()), p.getProperty("ip"), (!testConnection(p.getProperty("ip"))), "1"); 
		if (!fAuthenticated) {
			isLogin = true;
		}
	}
	configureUISplash();
	createUI();
	splash.layout(true);
	doEventLoop();	
}
 
源代码7 项目: birt   文件: PatternImageEditorDialog.java
public void toggleDropDown( )
{
	if ( dropDown == null || dropDown.isDisposed( ) )
	{
		Point pt = UIHelper.getScreenLocation( host );
		int x = pt.x;
		int y = pt.y + host.getSize( ).y;

		Shell shell = new Shell( host.getShell( ), SWT.NONE );
		shell.setLayout( new GridLayout( ) );
		shell.setLocation( x, y );
		dropDown = createDropDown( shell );
		shell.layout( );
		shell.pack( );
		shell.open( );
	}
	else
	{
		dropDown.getShell( ).close( );
	}
}
 
源代码8 项目: swt-bling   文件: PopOverShellIntegTest.java
private static void initialize() {
  if (needsInitialization()) {
    display = Display.getDefault();
    shell = new Shell(display);
    shell.setLayout(new FillLayout());
    Composite composite = new Composite(shell, SWT.NONE);
    composite.setLayout(new GridLayout());

    button = new Button(composite, SWT.PUSH);
    button.setText("Testing Button");

    popOverShell = Bubble.createBubble(button, BUBBLE_TEXT);
    button.setLayoutData(new GridData(SWT.LEFT, SWT.LEFT, true, true));
    shell.pack();
    shell.layout();

    initialized = true;
  }
}
 
源代码9 项目: hop   文件: BaseTransformDialog.java
/**
 * 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 );
  }
}
 
源代码10 项目: nebula   文件: SnippetGalleryViewerTester.java
public SnippetGalleryViewerTester() {
	// Initialize the containing Shell
	Display display = new Display();
	shell = new Shell(display);
	shell.setSize(WIDTH, HEIGHT);
	shell.setBackground(display.getSystemColor(SWT.COLOR_RED));
	GridLayoutFactory.fillDefaults().applyTo(shell);

	GalleryTreeViewer viewer = new GalleryTreeViewer(shell);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getGallery());
	viewer.setContentProvider(new GalleryTestContentProvider());
	viewer.setLabelProvider(new GalleryTestLabelProvider());
	viewer.setComparator(new ViewerComparator());
	// viewer.addFilter(new OddNumbersFilter());
	viewer.setInput(new Object());

	// Show the Shell
	shell.open();
	shell.layout();

	// Run the event loop
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
 
源代码11 项目: AndroidRobot   文件: Find_Replace.java
/**
 * Open the window.
 */
public void open() {
    if (isOpen == true)
        return;
    isOpen = true;
    display = Display.getDefault();
    shell = new Shell(parent);//
    shell.setLayout(new GridLayout());
    shell.open();
    shell.setSize(273, 400);
    shell.setText("查找/替换");

    createForm();

    shell.addListener(SWT.Close, new Listener() {
        public void handleEvent(Event event) {
            switch (event.type) {
                case SWT.Close:
                    isOpen = false;
                    break;
            }
        }
    });

    shell.layout();
    while (shell != null && !shell.isDisposed()) {
        if (display != null && !display.readAndDispatch()) {
            display.sleep();
        }
    }

}
 
源代码12 项目: gama   文件: DisplayOverlay.java
public DisplayOverlay(final LayeredDisplayView view, final Composite c,
		final IOverlayProvider<OverlayInfo> provider) {
	this.createExtraInfo = provider != null;
	this.view = view;
	final IPartService ps = ((IWorkbenchPart) view).getSite().getService(IPartService.class);
	ps.addPartListener(pl2);
	referenceComposite = c;
	// parentShell = c.getShell();
	popup = new Shell(c.getShell(), SWT.NO_TRIM | SWT.NO_FOCUS);
	popup.setAlpha(140);
	final FillLayout layout = new FillLayout();
	layout.type = SWT.VERTICAL;
	layout.spacing = 10;
	popup.setLayout(layout);
	popup.setBackground(IGamaColors.BLACK.color());
	createPopupControl();
	popup.setAlpha(140);
	popup.layout();
	c.getShell().addShellListener(listener);
	// parentShell.addControlListener(listener);
	c.addControlListener(listener);
	if (provider != null) {
		provider.setTarget(new ThreadedOverlayUpdater(this), view.getDisplaySurface());
	}
	// if (GamaPreferences.Displays.CORE_SHOW_FPS.getValue()) {
	timer.schedule(new FPSTask(), 0, 1000);
	// }
}
 
源代码13 项目: gama   文件: DisplayOverlay.java
protected void createPopupControl() {
	// overall panel
	final Shell top = getPopup();
	final GridLayout layout = new GridLayout(3, true);
	layout.horizontalSpacing = 0;
	layout.verticalSpacing = 0;
	layout.marginWidth = 5;
	layout.marginHeight = 5;
	top.setLayout(layout);
	top.setBackground(IGamaColors.BLACK.color());
	if (createExtraInfo) {
		// left overlay info
		left = label(top, SWT.LEFT);
		// center overlay info
		center = label(top, SWT.CENTER);
		// right overlay info
		right = label(top, SWT.RIGHT);
	}
	// coordinates overlay info
	coord = label(top, SWT.LEFT);
	// zoom overlay info
	zoom = label(top, SWT.CENTER);
	// scalebar overlay info
	scalebar = new Canvas(top, SWT.None);
	scalebar.setVisible(true);
	final GridData scaleData = new GridData(SWT.RIGHT, SWT.CENTER, true, false);
	scaleData.minimumWidth = 140;
	scaleData.widthHint = 140;
	scaleData.minimumHeight = 24;
	scaleData.heightHint = 24;
	scalebar.setLayoutData(scaleData);
	scalebar.setBackground(IGamaColors.BLACK.color());
	scalebar.addPaintListener(e -> paintScale(e.gc));
	top.addMouseListener(toggleListener);
	scalebar.addMouseListener(toggleListener);
	top.layout();
}
 
源代码14 项目: gama   文件: Popup2.java
protected void adjustSize() {
	final Shell shell = getShell();
	shell.layout();
	shell.pack();
	shell.setLocation(getDefaultLocation(null));
	shell.setSize(getDefaultSize());
}
 
源代码15 项目: birt   文件: MarkerEditorComposite.java
private void createDropDownComponent( )
{
	Point pLoc = UIHelper.getScreenLocation( btnDropDown.getParent( ) );
	int iXLoc = pLoc.x;
	int iYLoc = pLoc.y + btnDropDown.getParent( ).getSize( ).y;
	int iShellWidth = MARKER_BLOCK_HEIGHT * MARKER_ROW_MAX_NUMBER + 15;

	if ( ( getStyle( ) & SWT.RIGHT_TO_LEFT ) != 0 )
	{
		iXLoc -= iShellWidth;
	}

	// Avoid the right boundary out of screen
	if ( iXLoc + iShellWidth > this.getDisplay( ).getClientArea( ).width )
	{
		iXLoc = this.getDisplay( ).getClientArea( ).width - iShellWidth;
	}

	Shell shell = new Shell( this.getShell( ), SWT.NONE );
	shell.setLayout( new FillLayout( ) );
	// shell.setSize( iShellWidth, iShellHeight );
	shell.setLocation( iXLoc, iYLoc );

	cmpDropDown = new MarkerDropDownEditorComposite( shell, SWT.NONE );

	shell.layout( );
	shell.pack( );
	shell.setFocus( ); // Set focus to this shell to receive key event.
	shell.open( );
	cmpDropDown.setFocus( );
}
 
源代码16 项目: birt   文件: AggregateEditorComposite.java
private void createDropDownComponent( )
{
	Point pLoc = UIHelper.getScreenLocation( fBtnDropDown.getParent( ) );
	int iXLoc = pLoc.x;
	int iYLoc = pLoc.y + fBtnDropDown.getParent( ).getSize( ).y;
	int iShellWidth = BLOCK_WIDTH;
	int iShellHeight = BLOCK_HEIGHT;

	if ( ( getStyle( ) & SWT.RIGHT_TO_LEFT ) != 0 )
	{
		iXLoc -= iShellWidth;
	}

	// Avoid the right boundary out of screen
	if ( iXLoc + iShellWidth > this.getDisplay( ).getClientArea( ).width )
	{
		iXLoc = this.getDisplay( ).getClientArea( ).width - iShellWidth;
	}

	Shell shell = new Shell( this.getShell( ), SWT.NONE );
	shell.setLayout( new FillLayout( ) );
	shell.setSize( iShellWidth, iShellHeight );
	shell.setLocation( iXLoc, iYLoc );

	if ( query != null )
	{
		setAggregation( query, fSeriesDefi );
	}
	else
	{
		setSeriesDefinition( fSeriesDefi );
	}
	fAggregateEditor = new AggregateDropDownEditorComposite( shell, SWT.NONE, null );
	
	shell.layout( );
	shell.open( );
}
 
源代码17 项目: bonita-studio   文件: OperatorSelectionDialog.java
private void relayout() {
    final Shell shell = section.getShell();
    final Point defaultSize = shell.getSize();
    final Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    shell.setSize(defaultSize.x, size.y);
    shell.layout(true, true);
}
 
源代码18 项目: Universal-FE-Randomizer   文件: ProgressModal.java
public ProgressModal(Shell parent, String title) {
	display = Display.getDefault();
	yuneImage = new Image(display, Main.class.getClassLoader().getResourceAsStream("YuneIcon_100x100.png"));
	
	dialogShell = new Shell(parent, SWT.PRIMARY_MODAL | SWT.DIALOG_TRIM);
	dialogShell.setText(title);
	dialogShell.setImage(yuneImage);
	
	progressBar = new ProgressBar(dialogShell, SWT.SMOOTH);
	
	FormLayout mainLayout = new FormLayout();
	mainLayout.marginWidth = 5;
	mainLayout.marginHeight = 5;
	dialogShell.setLayout(mainLayout);
	
	imageLabel = new Label(dialogShell, SWT.NONE);
	imageLabel.setImage(yuneImage);
	
	FormData imageData = new FormData(100, 100);
	imageData.left = new FormAttachment(0, 10);
	imageData.top = new FormAttachment(0, 10);
	imageData.bottom = new FormAttachment(100, -10);
	imageLabel.setLayoutData(imageData);
	
	FormData progressData = new FormData(300, 20);
	progressData.left = new FormAttachment(imageLabel, 10);
	progressData.bottom = new FormAttachment(imageLabel, -50, SWT.CENTER);
	progressData.right = new FormAttachment(100, -10);
	progressBar.setLayoutData(progressData);
	
	statusLabel = new Label(dialogShell, SWT.NONE);
	
	FormData statusData = new FormData();
	statusData.left = new FormAttachment(progressBar, 0, SWT.LEFT);
	statusData.top = new FormAttachment(progressBar, 5);
	statusData.right = new FormAttachment(100, -10);
	statusLabel.setLayoutData(statusData);
	
	dialogShell.layout();
	final Point newSize = dialogShell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
	dialogShell.setSize(newSize);
	
	Rectangle parentBounds = parent.getBounds();
	Rectangle dialogBounds = dialogShell.getBounds();
	
	dialogShell.setLocation(parentBounds.x + (parentBounds.width - dialogBounds.width) / 2, parentBounds.y + (parentBounds.height - dialogBounds.height) / 2);
}
 
源代码19 项目: nebula   文件: FontAwesomeSnippet3.java
public static void main(final String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setText("FontAwesome Snippet");
	shell.setSize(1000, 600);
	shell.setLayout(new GridLayout(2, false));

	fScrolledComposite = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
	fScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
	fScrolledComposite.setAlwaysShowScrollBars(false);
	fScrolledComposite.setExpandHorizontal(true);
	fScrolledComposite.setExpandVertical(true);

	Composite composite = new Composite(fScrolledComposite, SWT.NONE);
	fScrolledComposite.setContent(composite);

	RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
	rowLayout.marginTop = 5;
	rowLayout.marginRight = 5;
	rowLayout.marginLeft = 5;
	rowLayout.marginBottom = 5;
	rowLayout.pack = false;
	composite.setLayout(rowLayout);
	buildComposite(composite);
	calcMinsize(composite);
	shell.layout(true, true);

	fFontLabel = new Label(shell, SWT.NONE);
	fFontLabel.setText("Font size (22)");


	fSlider = new Slider(shell, SWT.NONE);
	fSlider.addListener(SWT.MouseUp, e -> {
		shell.setRedraw(false);
		Arrays.asList(composite.getChildren()).forEach(c -> c.dispose());
		fFontSize = fSlider.getSelection();
		buildComposite(composite);
		fFontLabel.setText("Font size (" + fFontSize + ")");
		shell.setRedraw(true);

		shell.layout(true, true);
		calcMinsize(composite);
	});
	fSlider.setPageIncrement(1);
	fSlider.setMaximum(150);
	fSlider.setMinimum(4);
	fSlider.setSelection(22);
	fSlider.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	display.dispose();

}
 
源代码20 项目: birt   文件: CustomChooserComposite.java
private void createDropDownComponent( int iXLoc, int iYLoc )
{
	if ( !bEnabled )
	{
		return;
	}

	int shellWidth = this.getSize( ).x;
	Shell shell = new Shell( this.getShell( ), SWT.NONE );
	shell.setLayout( new FillLayout( SWT.FILL ) );
	if ( ( getStyle( ) & SWT.RIGHT_TO_LEFT ) != 0 )
	{
		iXLoc -= shellWidth;
	}
	shell.setLocation( iXLoc, iYLoc );

	container = new ScrolledComposite( shell, SWT.V_SCROLL );
	container.setAlwaysShowScrollBars( false );
	container.setExpandHorizontal( true );

	cmpDropDown = new Composite( container, SWT.NONE );
	GridLayout gl = new GridLayout( );
	gl.horizontalSpacing = 0;
	gl.verticalSpacing = 0;
	gl.marginHeight = 0;
	gl.marginWidth = 0;
	cmpDropDown.setLayout( gl );

	Listener listenerCmpDropDown = new Listener( ) {

		public void handleEvent( Event event )
		{
			handleEventCmpDropDown( event );
		}
	};

	cmpDropDown.addListener( SWT.KeyDown, listenerCmpDropDown );
	cmpDropDown.addListener( SWT.FocusOut, listenerCmpDropDown );

	popupCanvases = new ICustomChoice[this.items.length];

	for ( int iC = 0; iC < items.length; iC++ )
	{
		ICustomChoice cnv = createChoice( cmpDropDown, items[iC] );
		GridData gd = new GridData( GridData.FILL_HORIZONTAL );
		cnv.setLayoutData( gd );
		cnv.addListener( SWT.MouseDown, canvasListener );
		cnv.addListener( SWT.MouseEnter, canvasListener );
		cnv.addListener( SWT.KeyDown, canvasListener );

		popupCanvases[iC] = cnv;
		if ( cnvSelection.getValue( ).equals( cnv.getValue( ) ) )
		{
			cnv.notifyListeners( SWT.FocusIn, new Event( ) );
			popupSelection = cnv;
		}
	}

	int width = 0;
	int height = 0;

	int maxWidth = 0;
	Control[] children = container.getChildren( );
	for ( int i = 0; i < children.length; i++ )
	{
		Point point = children[i].computeSize( SWT.DEFAULT, SWT.DEFAULT );
		maxWidth = point.x > maxWidth ? point.x : maxWidth;
		height += point.y;
	}
	
	width = getSize( ).x > maxWidth ? getSize( ).x : maxWidth;
	height = 18 > height ? 18 : height;

	cmpDropDown.setBounds( 0, 0, width, height );

	container.setContent( cmpDropDown );

	if ( height >= 298 )
	{
		int containerWidth = maxWidth
				+ container.getVerticalBar( ).getSize( ).x;
		width = width > containerWidth ? getSize( ).x : containerWidth;
	}

	shell.setSize( width, height < 298 ? height + 2 : 300 );

	shell.layout( );
	shell.open( );
}