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

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

源代码1 项目: nebula   文件: Snippet8.java
public Shell createShell() {
	printJob = new PrintJob("Snippet8.java", createPrint())
			.setMargins(108); // 1.5"

	shell = new Shell(display);
	shell.setText("Snippet8.java");
	shell.setBounds(100, 100, 800, 600);
	shell.setLayout(new GridLayout(1, false));

	createButtonPanel(shell).setLayoutData(
			new GridData(SWT.FILL, SWT.FILL, true, false));
	createScrollingPreview(shell).setLayoutData(
			new GridData(SWT.FILL, SWT.FILL, true, true));

	preview.setLazyPageLayout(true);
	preview.setPrintJob(printJob);
	updatePreviewSize();
	updatePageNumber();
	preview.startBackgroundLayout(() -> {
		updatePageNumber();
	});

	shell.setVisible(true);

	return shell;
}
 
源代码2 项目: nebula   文件: Snippet7.java
public Shell createShell() {
	printJob = new PrintJob("Snippet7.java", createPrint())
			.setMargins(108); // 1.5"

	shell = new Shell(display);
	shell.setText("Snippet7.java");
	shell.setBounds(100, 100, 800, 600);
	shell.setLayout(new GridLayout(1, false));

	createButtonPanel(shell).setLayoutData(
			new GridData(SWT.FILL, SWT.FILL, true, false));
	createScrollingPreview(shell).setLayoutData(
			new GridData(SWT.FILL, SWT.FILL, true, true));

	preview.setPrintJob(printJob);
	updatePreviewSize();
	updatePageNumber();

	shell.setVisible(true);

	return shell;
}
 
源代码3 项目: eclipse-cs   文件: SWTUtil.java
/**
 * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
 */
@Override
public void mouseDown(MouseEvent e) {
  Control theControl = (Control) e.widget;

  Display display = theControl.getDisplay();
  Shell tip = new Shell(theControl.getShell(), SWT.ON_TOP | SWT.TOOL);
  tip.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
  FillLayout layout = new FillLayout();
  layout.marginHeight = 1;
  layout.marginWidth = 2;
  tip.setLayout(layout);
  Label label = new Label(tip, SWT.NONE);
  label.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
  label.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));

  label.setText(theControl.getToolTipText());
  label.addMouseTrackListener(this);
  Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
  Rectangle rect = theControl.getBounds();
  Point pt = theControl.getParent().toDisplay(rect.x, rect.y);
  tip.setBounds(pt.x, pt.y, size.x, size.y);
  tip.setVisible(true);
}
 
源代码4 项目: nebula   文件: Snippet6.java
/**
 * Executes the snippet.
 *
 * @param args
 *            command-line args.
 */
public static void main(String[] args) {
	Display display = Display.getDefault();
	final Shell shell = new Shell(display);
	shell.setText("Snippet6.java");
	shell.setBounds(100, 100, 640, 480);
	shell.setLayout(new GridLayout());

	Button button = new Button(shell, SWT.PUSH);
	button.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
	button.setText("Print");

	PrintViewer viewer = new PrintViewer(shell, SWT.BORDER);
	viewer.getControl()
			.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	final Print print = createPrint();
	viewer.setPrint(print);

	button.addListener(SWT.Selection, event -> {
		PrintDialog dialog = new PrintDialog(shell, SWT.NONE);
		PrinterData printerData = dialog.open();
		if (printerData != null)
			PaperClips.print(
					new PrintJob("Snippet6.java", print).setMargins(72),
					printerData);
	});

	shell.setVisible(true);

	while (!shell.isDisposed())
		if (!display.readAndDispatch())
			display.sleep();

	display.dispose();
}
 
源代码5 项目: nebula   文件: Snippet2.java
/**
 * Executes the snippet.
 *
 * @param args
 *            command-line args.
 */
public static void main(String[] args) {
	Display display = Display.getDefault();
	final Shell shell = new Shell(display);
	shell.setText("Snippet2.java");
	shell.setBounds(100, 100, 640, 480);
	shell.setLayout(new GridLayout());

	Button button = new Button(shell, SWT.PUSH);
	button.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
	button.setText("Print");

	PrintViewer viewer = new PrintViewer(shell, SWT.BORDER);
	viewer.getControl()
			.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	final Print print = createPrint();
	viewer.setPrint(print);

	button.addListener(SWT.Selection, event -> {
		PrintDialog dialog = new PrintDialog(shell, SWT.NONE);
		PrinterData printerData = dialog.open();
		if (printerData != null)
			PaperClips.print(
					new PrintJob("Snippet2.java", print).setMargins(72),
					printerData);
	});

	shell.setVisible(true);

	while (!shell.isDisposed())
		if (!display.readAndDispatch())
			display.sleep();

	display.dispose();
}
 
源代码6 项目: nebula   文件: Snippet5.java
/**
 * Executes the snippet.
 *
 * @param args
 *            command-line args.
 */
public static void main(String[] args) {
	Display display = Display.getDefault();
	final Shell shell = new Shell(display);
	shell.setText("Snippet5.java");
	shell.setBounds(100, 100, 640, 480);
	shell.setLayout(new GridLayout());

	Button button = new Button(shell, SWT.PUSH);
	button.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
	button.setText("Print");

	PrintViewer viewer = new PrintViewer(shell, SWT.BORDER);
	viewer.getControl()
			.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	final Print print = createPrint();
	viewer.setPrint(print);

	button.addListener(SWT.Selection, event -> {
		PrintDialog dialog = new PrintDialog(shell, SWT.NONE);
		PrinterData printerData = dialog.open();
		if (printerData != null)
			PaperClips.print(
					new PrintJob("Snippet5.java", print).setMargins(72),
					printerData);
	});

	shell.setVisible(true);

	while (!shell.isDisposed())
		if (!display.readAndDispatch())
			display.sleep();

	display.dispose();
}
 
源代码7 项目: SWET   文件: PopupDialog.java
/**
 * Opens this window, creating it first if it has not yet been created.
 * <p>
 * This method is reimplemented for special configuration of PopupDialogs.
 * It never blocks on open, immediately returning <code>OK</code> if the
 * open is successful, or <code>CANCEL</code> if it is not. It provides
 * framework hooks that allow subclasses to set the focus and tab order, and
 * avoids the use of <code>shell.open()</code> in cases where the focus
 * should not be given to the shell initially.
 * 
 * @return the return code
 * 
 * @see org.eclipse.jface.window.Window#open()
 */
public int open() {

	Shell shell = getShell();
	if (shell == null || shell.isDisposed()) {
		shell = null;
		// create the window
		create();
		shell = getShell();
	}

	// provide a hook for adjusting the bounds. This is only
	// necessary when there is content driven sizing that must be
	// adjusted each time the dialog is opened.
	adjustBounds();

	// limit the shell size to the display size
	constrainShellSize();

	// set up the tab order for the dialog
	setTabOrder((Composite) getContents());

	// initialize flags for listening to deactivate
	listenToDeactivate = false;
	listenToParentDeactivate = false;

	// open the window
	if (takeFocusOnOpen) {
		shell.open();
		getFocusControl().setFocus();
	} else {
		shell.setVisible(true);
	}

	return OK;

}
 
源代码8 项目: BiglyBT   文件: ShellFactory.java
@Override
public void open() {
	UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
	if (uiFunctions != null) {
		Boolean bringToFront = (Boolean)getData( "bringToFront" );
		if ( bringToFront == null || bringToFront ){
			Shell mainShell = uiFunctions.getMainShell();
			if (mainShell != null && mainShell.getMinimized()) {
				uiFunctions.bringToFront();
			}
		}
	}

	Shell firstShellWithStyle = Utils.findFirstShellWithStyle(SWT.APPLICATION_MODAL);
	if (firstShellWithStyle != null && firstShellWithStyle != this) {
		// ok, there's a window with application_modal set, which on OSX will mean
		// that if we open our window, it will be on top, but users won't be able
		// to interact with it.  So, wait until the modal window goes away..
		firstShellWithStyle.addDisposeListener(new DisposeListener() {
			@Override
			public void widgetDisposed(DisposeEvent e) {
				// wait for dispose to complete, then run open again to check for
				// any new application modal shells to wait for
				Utils.execSWTThreadLater(0, new AERunnable() {
					@Override
					public void runSupport() {
						AEShell.this.open();
					}
				});
			}
		});
		firstShellWithStyle.setVisible(true);
		firstShellWithStyle.forceActive();
	} else {
		if (!isDisposed()) {
			super.open();
		}
	}
}
 
源代码9 项目: e4macs   文件: MetaXDialog.java
void showTip(String txt, ItemPkg tp, Table table)  {
	tip = new Shell((Shell) null, SWT.ON_TOP | SWT.TOOL);
	tip.setLayout(new FillLayout());
	tip.setBackground(table.getBackground());
	createCommandTip(tip, (Command) getSelectables().get(txt));
	Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
	Rectangle rect = tp.getBounds();
	Point pt = table.toDisplay(rect.x + getSizeAdjustment(), rect.y
			- size.y);
	tip.setBounds(pt.x, pt.y, size.x, size.y);
	tip.setVisible(true);
}
 
源代码10 项目: e4macs   文件: BufferDialog.java
void showTip(String txt, ItemPkg tp, Table table)  {
	tip = new Shell((Shell) null, SWT.ON_TOP | SWT.TOOL);
	tip.setLayout(new FillLayout());
	tip.setBackground(table.getBackground());
	createBufferTip(tip, (IEditorReference)getSelectables().get(txt));
	Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
	Rectangle rect = tp.getBounds();
	Point pt = table.toDisplay(rect.x + getSizeAdjustment(), rect.y
			- size.y);
	tip.setBounds(pt.x, pt.y, size.x, size.y);
	tip.setVisible(true);
}
 
源代码11 项目: nebula   文件: Snippet1.java
/**
 * Executes the snippet.
 *
 * @param args
 *            command-line args.
 */
public static void main(String[] args) {
	Display display = Display.getDefault();
	final Shell shell = new Shell(display);
	shell.setText("Snippet1.java");
	shell.setBounds(100, 100, 640, 480);
	shell.setLayout(new GridLayout());

	Button button = new Button(shell, SWT.PUSH);
	button.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
	button.setText("Print the table");

	final Table table = new Table(shell, SWT.BORDER);
	table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

	// Set up Table widget with dummy data.
	for (int i = 0; i < 5; i++)
		new TableColumn(table, SWT.LEFT).setText("Column " + i);

	for (int row = 0; row < 100; row++) {
		TableItem item = new TableItem(table, SWT.NONE);
		for (int col = 0; col < 5; col++)
			item.setText(col, "Cell [" + col + ", " + row + "]");
	}

	table.setHeaderVisible(true);
	TableColumn[] columns = table.getColumns();
	for (int i = 0; i < columns.length; i++)
		columns[i].pack();

	button.addListener(SWT.Selection, event -> {
		PrintDialog dialog = new PrintDialog(shell, SWT.NONE);
		PrinterData printerData = dialog.open();
		if (printerData != null) {
			Print print = createPrint(table);
			PaperClips.print(
					new PrintJob("Snippet1.java", print).setMargins(72),
					printerData);
		}
	});

	shell.setVisible(true);

	while (!shell.isDisposed())
		if (!display.readAndDispatch())
			display.sleep();

	display.dispose();
}
 
源代码12 项目: APICloud-Studio   文件: MinimizableWizardDialog.java
/**
 * The Hide button has been pressed.
 */
public void hidePressed()
{
	if (hideOnFinish)
	{
		final Shell activeShell = getShell();
		toast = new GenericInfoPopupDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
				infoTitle, infoMessage, new Runnable()
				{
					public void run()
					{
						activeShell.setVisible(true);
					}
				});
		toast.open();
		activeShell.setVisible(false);

		activeShell.addListener(SWT.Show, new Listener()
		{
			public void handleEvent(Event event)
			{
				if (toast != null)
				{
					// Incase if the shell is opened through other source, close the toast
					toast.close();
				}
			}
		});

		activeShell.addShellListener(new ShellAdapter()
		{
			@Override
			public void shellClosed(ShellEvent e)
			{
				if (toast != null)
				{
					// In case the shell gets closed programatically, close the toast.
					toast.close();
				}
			}
		});
	}

}