本文整理匯總了Java中org.eclipse.swt.widgets.Shell.getDisplay方法的典型用法代碼示例。如果您正苦於以下問題:Java Shell.getDisplay方法的具體用法?Java Shell.getDisplay怎麽用?Java Shell.getDisplay使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.widgets.Shell
的用法示例。
在下文中一共展示了Shell.getDisplay方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: runEventLoop
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
private void runEventLoop(Shell loopShell) {
Display display;
if (getShell() == null) {
display = Display.getCurrent();
} else {
display = loopShell.getDisplay();
}
while (loopShell != null && !loopShell.isDisposed()) {
try {
if (!display.readAndDispatch()) {
display.sleep();
}
} catch (Throwable e) {
EclipseUtil.logError("UI problems on dispatch",e);
}
}
if (!display.isDisposed()) {
display.update();
}
}
示例2: DialogFuture
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
public DialogFuture ( final Shell parentShell, final Callback[] callbacks, final List<CallbackWidgetFactory> factories )
{
this.parentShell = parentShell;
this.display = parentShell.getDisplay ();
this.callbacks = callbacks;
this.factories = factories;
}
示例3: DisplayCallbackHandler
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
public DisplayCallbackHandler ( final Shell parentShell, final String dialogTitle, final String dialogMessage )
{
this.parentShell = parentShell;
this.display = parentShell.getDisplay ();
this.dialogTitle = dialogTitle;
this.dialogMessage = dialogMessage;
}
示例4: configureShell
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
@Override
public void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText("Limit chars logs");
newShell.setSize(nWidth, nHeight);
int nLeft = 0;
int nTop = 0;
Display display = newShell.getDisplay();
Point pt = display.getCursorLocation();
Monitor[] monitors = display.getMonitors();
for (int i = 0; i < monitors.length; i++) {
if (monitors[i].getBounds().contains(pt)) {
Rectangle rect = monitors[i].getClientArea();
if (rect.x < 0)
nLeft = ((rect.width - nWidth) / 2) + rect.x;
else
nLeft = (rect.width - nWidth) / 2;
if (rect.y < 0)
nTop = ((rect.height - nHeight) / 2) + rect.y;
else
nTop = (rect.height - nHeight) / 2;
break;
}
}
newShell.setBounds(nLeft, nTop, nWidth, nHeight);
}
示例5: configureShell
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
@Override
public void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText("Parameters availables");
newShell.setSize(nWidth, nHeight);
int nLeft = 0;
int nTop = 0;
Display display = newShell.getDisplay();
Point pt = display.getCursorLocation();
Monitor[] monitors = display.getMonitors();
for (int i = 0; i < monitors.length; i++) {
if (monitors[i].getBounds().contains(pt)) {
Rectangle rect = monitors[i].getClientArea();
if (rect.x < 0)
nLeft = ((rect.width - nWidth) / 2) + rect.x;
else
nLeft = (rect.width - nWidth) / 2;
if (rect.y < 0)
nTop = ((rect.height - nHeight) / 2) + rect.y;
else
nTop = (rect.height - nHeight) / 2;
break;
}
}
newShell.setBounds(nLeft, nTop, nWidth, nHeight);
}
示例6: configureShell
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
@Override
public void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText(dialogTitle);
int nLeft = 0;
int nTop = 0;
Display display = newShell.getDisplay();
// // mods jmc 22/10/2013
// nWidth = newShell.getSize().x;
// nHeight = newShell.getSize().y;
Point pt = display.getCursorLocation();
Monitor [] monitors = display.getMonitors();
for (int i= 0; i<monitors.length; i++) {
if (monitors[i].getBounds().contains(pt)) {
Rectangle rect = monitors[i].getClientArea();
if (rect.x < 0)
nLeft = ((rect.width - nWidth) / 2) + rect.x;
else
nLeft = (rect.width - nWidth) / 2;
if (rect.y < 0)
nTop = ((rect.height - nHeight) / 2) + rect.y;
else
nTop = (rect.height - nHeight) / 2;
break;
}
}
newShell.setBounds(nLeft, nTop, nWidth, nHeight);
}
示例7: configureShell
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
@Override
public void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText("Engine Log settings");
newShell.setSize(nWidth, nHeight);
int nLeft = 0;
int nTop = 0;
Display display = newShell.getDisplay();
Point pt = display.getCursorLocation();
Monitor[] monitors = display.getMonitors();
for (int i = 0; i < monitors.length; i++) {
if (monitors[i].getBounds().contains(pt)) {
Rectangle rect = monitors[i].getClientArea();
if (rect.x < 0)
nLeft = ((rect.width - nWidth) / 2) + rect.x;
else
nLeft = (rect.width - nWidth) / 2;
if (rect.y < 0)
nTop = ((rect.height - nHeight) / 2) + rect.y;
else
nTop = (rect.height - nHeight) / 2;
break;
}
}
newShell.setBounds(nLeft, nTop, nWidth, nHeight);
}
示例8: main
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
// create the widget's shell
Shell shell = new Shell();
shell.setLayout(new FillLayout());
shell.setSize(500, 500);
Display display = shell.getDisplay();
Composite parent = new Composite(shell, SWT.NONE);
parent.setLayout(new GridLayout());
StyledText styledText = new StyledText(parent, SWT.BORDER | SWT.V_SCROLL);
styledText.setLayoutData(new GridData(GridData.FILL_BOTH));
styledText.setText("a\nb\nc\nd");
StyledTextPatcher.setLineSpacingProvider(styledText, new ILineSpacingProvider() {
@Override
public Integer getLineSpacing(int lineIndex) {
if (lineIndex == 0) {
return 10;
} else if (lineIndex == 1) {
return 30;
}
return null;
}
});
shell.open();
while (!shell.isDisposed())
if (!display.readAndDispatch())
display.sleep();
}
示例9: main
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
public static void main(String[] args) {
Shell shell = new Shell(new Display());
shell.setSize(365, 280);
shell.setLayout(new GridLayout());
Figure root = new Figure();
root.setFont(shell.getFont());
XYLayout layout = new XYLayout();
root.setLayoutManager(layout);
Canvas canvas = new Canvas(shell, SWT.DOUBLE_BUFFERED);
canvas.setBackground(ColorConstants.white);
canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
VarParser parser = new VarParser("src/pt/iscte/pandionj/tests/Test.java");
parser.run();
System.out.println(parser.toText());
createDiagram(root, parser);
LightweightSystem lws = new LightweightSystem(canvas);
lws.setContents(root);
Display display = shell.getDisplay();
shell.open();
while (!shell.isDisposed()) {
while (!display.readAndDispatch()) {
display.sleep();
}
}
}
示例10: main
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
// create the widget's shell
Shell shell = new Shell();
shell.setLayout(new FillLayout());
shell.setSize(500, 500);
Display display = shell.getDisplay();
Composite parent = new Composite(shell, SWT.NONE);
parent.setLayout(new GridLayout(2, false));
ITextViewer textViewer = new TextViewer(parent, SWT.V_SCROLL | SWT.BORDER);
String delim = textViewer.getTextWidget().getLineDelimiter();
textViewer.setDocument(new Document(delim + " class A" + delim + "new A" + delim + "new A" + delim + "class B"
+ delim + "new B" + delim + "interface I" + delim + "class C implements I"));
StyledText styledText = textViewer.getTextWidget();
styledText.setLayoutData(new GridData(GridData.FILL_BOTH));
CodeLensProviderRegistry registry = CodeLensProviderRegistry.getInstance();
registry.register(CONTENT_TYPE_ID, new ClassReferencesCodeLensProvider());
registry.register(CONTENT_TYPE_ID, new ClassImplementationsCodeLensProvider());
CodeLensStrategy codelens = new CodeLensStrategy(new DefaultCodeLensContext(textViewer), false);
codelens.addTarget(CONTENT_TYPE_ID).reconcile(null);
styledText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent event) {
codelens.reconcile(null);
}
});
shell.open();
while (!shell.isDisposed())
if (!display.readAndDispatch())
display.sleep();
}
示例11: IconAndMessageDialogEx
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
public IconAndMessageDialogEx(Shell parent) {
super(parent);
// Create the image
try {
image = new Image(parent.getDisplay(),
new FileInputStream("facepalm.png"));
} catch (FileNotFoundException e) {
}
// Set the default message
message = "Are you sure you want to do something that dumb?";
}
示例12: getSWTImage
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
private Image getSWTImage() {
Shell shell = getShell();
final Display display;
if (shell == null || shell.isDisposed()) {
shell = getParentShell();
}
if (shell == null || shell.isDisposed()) {
display = Display.getCurrent();
// The dialog should be always instantiated in UI thread.
// However it was possible to instantiate it in other threads
// (the code worked in most cases) so the assertion covers
// only the failing scenario. See bug 107082 for details.
Assert.isNotNull(display,
"The dialog should be created in UI thread"); //$NON-NLS-1$
} else {
display = shell.getDisplay();
}
final Image[] image = new Image[1];
display.syncExec(new Runnable() {
public void run() {
image[0] = display.getSystemImage(SWT.ICON_QUESTION);
}
});
return image[0];
}
示例13: StringListChooser
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
public StringListChooser(final Shell parentShell) {
result = null;
display = parentShell.getDisplay();
if(display == null || display.isDisposed()) return;
display.syncExec(new Runnable() {
@Override
public void run() {
createShell(parentShell);
}
});
}
示例14: main
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
public static void main(String[] args) {
Shell shell = new Shell(new Display());
shell.setSize(1200, 500);
shell.setLayout(new GridLayout());
shell.setLocation(100, 150);
Figure root = new Figure();
root.setFont(shell.getFont());
// XYLayout layout = new XYLayout();
// root.setLayoutManager(layout);
org.eclipse.draw2d.GridLayout layout = new org.eclipse.draw2d.GridLayout(2,false);
layout.horizontalSpacing = 100;
root.setLayoutManager(layout);
Canvas canvas = new Canvas(shell, SWT.DOUBLE_BUFFERED);
canvas.setBackground(ColorConstants.white);
canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
createDiagram(root);
LightweightSystem lws = new LightweightSystem(canvas);
lws.setContents(root);
Display display = shell.getDisplay();
shell.open();
while (!shell.isDisposed()) {
while (!display.readAndDispatch()) {
display.sleep();
}
}
}
示例15: main
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
public static void main(String[] args) {
Shell shell = new Shell(new Display());
shell.setSize(1200, 500);
shell.setLayout(new GridLayout());
shell.setLocation(100, 150);
Figure root = new Figure();
root.setFont(shell.getFont());
// XYLayout layout = new XYLayout();
// root.setLayoutManager(layout);
org.eclipse.draw2d.GridLayout layout = new org.eclipse.draw2d.GridLayout(2,false);
layout.horizontalSpacing = 100;
root.setLayoutManager(layout);
Canvas canvas = new Canvas(shell, SWT.DOUBLE_BUFFERED);
canvas.setBackground(ColorConstants.white);
canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
MatrixWidget widget = new MatrixWidget();
MockArray array = new MockArray("int[]", new int[]{1,2,3}, new int[]{4,5,6}, new int[]{7,8,9}, new int[]{10,11,12});
root.add(widget.createFigure(array));
LightweightSystem lws = new LightweightSystem(canvas);
lws.setContents(root);
Display display = shell.getDisplay();
shell.open();
while (!shell.isDisposed()) {
while (!display.readAndDispatch()) {
display.sleep();
}
}
}