當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。