当前位置: 首页>>代码示例>>Java>>正文


Java Display.getCurrent方法代码示例

本文整理汇总了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]));
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:24,代码来源:KspOutlinePage.java

示例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);
  }
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:23,代码来源:SWTX.java

示例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();
}
 
开发者ID:Thizzer,项目名称:JTouchBar,代码行数:24,代码来源:JTouchBarSWTTest.java

示例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();
	}
}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:22,代码来源:AbstractQuickDialog.java

示例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];

}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:29,代码来源:SaveJobFileBeforeRunDialog.java

示例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;
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:31,代码来源:EngineLogViewLabelProvider.java

示例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;
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:8,代码来源:UnitView.java

示例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)");
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:16,代码来源:DisplaySafeSyncer.java

示例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);
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:32,代码来源:JUnitGW4ETestUIPage.java

示例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();
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:20,代码来源:SWTResourceManager.java

示例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);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:29,代码来源:CFEdge.java

示例12: checkDisplay

import org.eclipse.swt.widgets.Display; //导入方法依赖的package包/类
private void checkDisplay ()
{
    if ( Display.getCurrent () != this.display )
    {
        SWT.error ( SWT.ERROR_THREAD_INVALID_ACCESS );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:8,代码来源:KeyInstanceManager.java

示例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 );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:11,代码来源:FigureRenderer.java

示例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);
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:8,代码来源:SWTX.java

示例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(); 
}
 
开发者ID:nextopcn,项目名称:xcalendar,代码行数:8,代码来源:SwtUtils.java


注:本文中的org.eclipse.swt.widgets.Display.getCurrent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。