本文整理汇总了Java中org.eclipse.swt.widgets.Display.getCurrent方法的典型用法代码示例。如果您正苦于以下问题:Java Display.getCurrent方法的具体用法?Java Display.getCurrent怎么用?Java Display.getCurrent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.widgets.Display
的用法示例。
在下文中一共展示了Display.getCurrent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setStyledText
import org.eclipse.swt.widgets.Display; //导入方法依赖的package包/类
private void setStyledText(ViewerCell cell, TreeObject obj) {
/* Calcul du texte. */
String mainText = obj.getMainText();
if (mainText == null) {
return;
}
String subText = obj.getSubText();
String subTextFinal = subText == null ? "" : (" : " + subText);
String fullText = mainText + subTextFinal;
cell.setText(fullText);
/* Calcul du style. */
List<StyleRange> styles = new ArrayList<>();
StyleRange styleMainText = new StyleRange(0, mainText.length(), null, null);
styles.add(styleMainText);
if (!subTextFinal.isEmpty()) {
Display display = Display.getCurrent();
Color blue = display.getSystemColor(SWT.COLOR_DARK_YELLOW);
StyleRange styleSubText = new StyleRange(mainText.length(), subTextFinal.length(), blue, null);
styles.add(styleSubText);
}
cell.setStyleRanges(styles.toArray(new StyleRange[0]));
}
示例2: drawButtonDeepDown
import org.eclipse.swt.widgets.Display; //导入方法依赖的package包/类
public static void drawButtonDeepDown(GC gc, String text, int textAlign,
Image image, int imageAlign, int x, int y, int w, int h) {
Display display = Display.getCurrent();
gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
gc.drawLine(x, y, x + w - 2, y);
gc.drawLine(x, y, x, y + h - 2);
gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
gc.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
gc.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
gc.drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2);
gc.drawLine(x + w - 2, y + h - 2, x + w - 2, y + 1);
//
gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
gc.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
gc.fillRectangle(x + 2, y + 2, w - 4, 1);
gc.fillRectangle(x + 1, y + 2, 2, h - 4);
//
gc.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
drawTextImage(gc, text, textAlign, image, imageAlign, x + 2 + 1,
y + 2 + 1, w - 4, h - 3 - 1);
}
示例3: test
import org.eclipse.swt.widgets.Display; //导入方法依赖的package包/类
@Test
public void test() {
JTouchBar jTouchBar = JTouchBarTestUtils.constructTouchBar();
assertNotNull(jTouchBar);
Display display = Display.getCurrent();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
shell.open();
jTouchBar.show( shell );
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
break;
}
}
display.dispose();
}
示例4: runEventLoop
import org.eclipse.swt.widgets.Display; //导入方法依赖的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();
}
}
示例5: getSWTImage
import org.eclipse.swt.widgets.Display; //导入方法依赖的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];
}
示例6: getBackground
import org.eclipse.swt.widgets.Display; //导入方法依赖的package包/类
public Color getBackground(Object element, int columnIndex) {
LogLine line = (LogLine) element;
String level = line.getLevel();
if (level.equals(Level.ERROR.toString())) {
if (line.getCounter() % 2 == 0) {
return new Color(Display.getCurrent(), 255, 158, 147);
} else {
return new Color(Display.getCurrent(), 255, 186, 178);
}
} else if (level.equals(Level.INFO.toString())) {
if (line.getCounter() % 2 == 0) {
return new Color(Display.getCurrent(), 225, 242, 228);
} else {
return new Color(Display.getCurrent(), 237, 255, 241);
}
} else if (level.equals(Level.DEBUG.toString())) {
if (line.getCounter() % 2 == 0) {
return new Color(Display.getCurrent(), 249, 249, 177);
} else {
return new Color(Display.getCurrent(), 255, 255, 196);
}
} else if (level.equals(Level.WARN.toString())) {
if (line.getCounter() % 2 == 0) {
return new Color(Display.getCurrent(), 242, 196, 208);
} else {
return new Color(Display.getCurrent(), 255, 204, 217);
}
}
return null;
}
示例7: getDisplay
import org.eclipse.swt.widgets.Display; //导入方法依赖的package包/类
public static Display getDisplay() {
Display display = Display.getCurrent();
if (display == null) {
display = Display.getDefault();
}
return display;
}
示例8: awaitSignal
import org.eclipse.swt.widgets.Display; //导入方法依赖的package包/类
public void awaitSignal(long timeout) throws TimeoutException, InterruptedException {
if (latch == null)
throw new IllegalStateException("Syncher must be initialized");
long waitTime = 0;
while (waitTime < timeout) {
if (latch.await(10, TimeUnit.MILLISECONDS)) {
latch = null;
return;
}
waitTime += 10;
if (Display.getCurrent() != null)
Display.getCurrent().readAndDispatch();
}
throw new TimeoutException("Timeout in Syncer (timeout " + timeout + " ms)");
}
示例9: loadVertices
import org.eclipse.swt.widgets.Display; //导入方法依赖的package包/类
/**
*
*/
private void loadVertices() {
Display display = Display.getCurrent();
Runnable longJob = new Runnable() {
public void run() {
display.syncExec(new Runnable() {
public void run() {
IFile ifile = ResourceManager.toIFile(selection);
String modelFileName = null;
try {
modelFileName = ResourceManager.getAbsolutePath(ifile);
context = GraphWalkerFacade.getContext(modelFileName);
updateUI();
} catch (Exception e) {
ResourceManager.logException(e);
JUnitGW4ETestUIPage.this.setErrorMessage(
"Unable to load the graph model. See error logs in the Error View.");
return;
}
comboReachedVertexViewer.setInput(_loadVertices(context));
}
});
display.wake();
}
};
BusyIndicator.showWhile(display, longJob);
}
示例10: getImage
import org.eclipse.swt.widgets.Display; //导入方法依赖的package包/类
/**
* Returns an {@link Image} encoded by the specified {@link InputStream}.
*
* @param stream
* the {@link InputStream} encoding the image data
* @return the {@link Image} encoded by the specified input stream
*/
protected static Image getImage(InputStream stream) throws IOException {
try {
Display display = Display.getCurrent();
ImageData data = new ImageData(stream);
if (data.transparentPixel > 0) {
return new Image(display, data, data.getTransparencyMask());
}
return new Image(display, data);
} finally {
stream.close();
}
}
示例11: setColor
import org.eclipse.swt.widgets.Display; //导入方法依赖的package包/类
/** Sets the color of the {@link GC} depending on the edge type. */
void setColor(GC gc) {
Display displ = Display.getCurrent();
Color color = GraphUtils.getColor(50, 50, 50);
if (isDead || cfTypes.contains(ControlFlowType.DeadCode)) {
color = displ.getSystemColor(SWT.COLOR_GRAY);
} else {
for (ControlFlowType cfType : cfTypes) {
switch (cfType) {
case LoopEnter:
case LoopReenter:
case LoopInfinite:
case Break:
case Continue:
case Return:
color = displ.getSystemColor(SWT.COLOR_BLUE);
break;
case Throw:
color = displ.getSystemColor(SWT.COLOR_RED);
break;
default:
break;
}
}
}
gc.setForeground(color);
}
示例12: checkDisplay
import org.eclipse.swt.widgets.Display; //导入方法依赖的package包/类
private void checkDisplay ()
{
if ( Display.getCurrent () != this.display )
{
SWT.error ( SWT.ERROR_THREAD_INVALID_ACCESS );
}
}
示例13: FigureRenderer
import org.eclipse.swt.widgets.Display; //导入方法依赖的package包/类
public FigureRenderer ( final ChartFigure chartFigure, final ResourceManager resourceManager )
{
super ( resourceManager );
this.realm = new DisplayRealm ( Display.getCurrent () );
this.chartFigure = chartFigure;
this.figureListener = new FigureListenerImpl ();
this.chartFigure.addFigureListener ( this.figureListener );
}
示例14: drawButtonDown
import org.eclipse.swt.widgets.Display; //导入方法依赖的package包/类
public static void drawButtonDown(GC gc, String text, int textAlign,
Image image, int imageAlign, int x, int y, int w, int h, Color face) {
Display display = Display.getCurrent();
drawButtonDown(gc, text, textAlign, image, imageAlign, x, y, w, h,
face, display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW),
2, 2);
}
示例15: dispatch
import org.eclipse.swt.widgets.Display; //导入方法依赖的package包/类
/**
* Dispatch
*/
public static void dispatch(final Supplier<Boolean> condition) {
final Display display = Display.getCurrent();
while (!condition.get()) if(!display.readAndDispatch()) display.sleep();
}