类org.eclipse.swt.widgets.Caret源码实例Demo

下面列出了怎么用org.eclipse.swt.widgets.Caret的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: nebula   文件: BidiLayout.java
protected void startPushMode() {
	final Image image = new Image (styledText.getDisplay(), 20, 20);
	GC gc = new GC (image);
	gc.setBackground (styledText.getDisplay().getSystemColor(SWT.COLOR_BLACK));
	gc.fillRectangle (0, 0, 20, 20);
	gc.setForeground (styledText.getDisplay().getSystemColor(SWT.COLOR_WHITE));
	gc.setLineAttributes(new LineAttributes(2));
	gc.drawLine (0, 13, gc.getFontMetrics().getAverageCharWidth(), 13);
	gc.dispose ();
	defaultCaret = styledText.getCaret();
	Caret cc = new Caret(styledText, 0);
	cc.setImage(image);
	styledText.setCaret(cc);
	int carOffset = styledText.getCaretOffset();


	String str = reverseStr(styledText.getText());
	styledText.setText(str);
	indxPushSegmentStart = carOffset;
	styledText.setCaretOffset(getUpdatedCaret(carOffset));
	if (!isWidgetReversed) {
		setBidiKeyboardLanguage();
	} else {
		setNonBidiKeyboardLanguage();
	}
}
 
源代码2 项目: xtext-eclipse   文件: SWTUtil.java
/**
 * Returns the shell for the given widget. If the widget doesn't represent a SWT object that manage a shell,
 * <code>null</code> is returned.
 * 
 * @param widget
 *            the widget
 * 
 * @return the shell for the given widget
 */
public static Shell getShell(Widget widget) {
	if (widget instanceof Control)
		return ((Control) widget).getShell();
	if (widget instanceof Caret)
		return ((Caret) widget).getParent().getShell();
	if (widget instanceof DragSource)
		return ((DragSource) widget).getControl().getShell();
	if (widget instanceof DropTarget)
		return ((DropTarget) widget).getControl().getShell();
	if (widget instanceof Menu)
		return ((Menu) widget).getParent().getShell();
	if (widget instanceof ScrollBar)
		return ((ScrollBar) widget).getParent().getShell();

	return null;
}
 
源代码3 项目: APICloud-Studio   文件: SWTUtil.java
/**
 * Returns the shell for the given widget. If the widget doesn't represent a SWT object that manage a shell,
 * <code>null</code> is returned.
 * 
 * @return the shell for the given widget
 */
public static Shell getShell(Widget widget)
{
	if (widget instanceof Control)
		return ((Control) widget).getShell();
	if (widget instanceof Caret)
		return ((Caret) widget).getParent().getShell();
	if (widget instanceof DragSource)
		return ((DragSource) widget).getControl().getShell();
	if (widget instanceof DropTarget)
		return ((DropTarget) widget).getControl().getShell();
	if (widget instanceof Menu)
		return ((Menu) widget).getParent().getShell();
	if (widget instanceof ScrollBar)
		return ((ScrollBar) widget).getParent().getShell();

	return null;
}
 
源代码4 项目: Eclipse-Postfix-Code-Completion   文件: SWTUtil.java
/**
 * Returns the shell for the given widget. If the widget doesn't represent
 * a SWT object that manage a shell, <code>null</code> is returned.
 * @param widget the widget
 *
 * @return the shell for the given widget
 */
public static Shell getShell(Widget widget) {
	if (widget instanceof Control)
		return ((Control)widget).getShell();
	if (widget instanceof Caret)
		return ((Caret)widget).getParent().getShell();
	if (widget instanceof DragSource)
		return ((DragSource)widget).getControl().getShell();
	if (widget instanceof DropTarget)
		return ((DropTarget)widget).getControl().getShell();
	if (widget instanceof Menu)
		return ((Menu)widget).getParent().getShell();
	if (widget instanceof ScrollBar)
		return ((ScrollBar)widget).getParent().getShell();

	return null;
}
 
源代码5 项目: Pydev   文件: SWTUtil.java
/**
 * Returns the shell for the given widget. If the widget doesn't represent
 * a SWT object that manage a shell, <code>null</code> is returned.
 * @param widget the widget
 *
 * @return the shell for the given widget
 */
public static Shell getShell(Widget widget) {
    if (widget instanceof Control) {
        return ((Control) widget).getShell();
    }
    if (widget instanceof Caret) {
        return ((Caret) widget).getParent().getShell();
    }
    if (widget instanceof DragSource) {
        return ((DragSource) widget).getControl().getShell();
    }
    if (widget instanceof DropTarget) {
        return ((DropTarget) widget).getControl().getShell();
    }
    if (widget instanceof Menu) {
        return ((Menu) widget).getParent().getShell();
    }
    if (widget instanceof ScrollBar) {
        return ((ScrollBar) widget).getParent().getShell();
    }

    return null;
}
 
源代码6 项目: translationstudio8   文件: GridCopyEnable.java
/**
 * @param gridTable
 */
public GridCopyEnable(Grid gridTable) {
	Assert.isNotNull(gridTable);
	this.gridTable = gridTable;
	defaultCaret = new Caret(gridTable, SWT.NONE);
	clipboard = new Clipboard(gridTable.getDisplay());
	this.gridTable.setCaret(defaultCaret);
	this.gridTable.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_IBEAM));
	initListener();
}
 
源代码7 项目: tmxeditor8   文件: GridCopyEnable.java
/**
 * @param gridTable
 */
public GridCopyEnable(Grid gridTable) {
	Assert.isNotNull(gridTable);
	this.gridTable = gridTable;
	defaultCaret = new Caret(gridTable, SWT.NONE);
	clipboard = new Clipboard(gridTable.getDisplay());
	this.gridTable.setCaret(defaultCaret);
	this.gridTable.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_IBEAM));
	initListener();
}
 
源代码8 项目: Rel   文件: CheckForUpdates.java
/**
 * Create the composite.
 * 
 * @param parent
 * @param style
 */
public CheckForUpdates(Composite parent, int style) {
	super(parent, style);
	GridLayout gridLayout = new GridLayout(1, false);
	gridLayout.marginHeight = 0;
	gridLayout.marginWidth = 0;
	gridLayout.verticalSpacing = 0;
	gridLayout.horizontalSpacing = 0;
	setLayout(gridLayout);
	setVisible(false);

	txtStatus = new StyledText(this, SWT.WRAP);
	txtStatus.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	txtStatus.setEditable(false);
	txtStatus.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
	txtStatus.setBackground(getBackground());
	txtStatus.setFont(FontSize.getThisFontInNewSize(txtStatus.getFont(), 10, SWT.NORMAL));
	txtStatus.addMouseListener(mouseHandler);
	txtStatus.setCaret(new Caret(txtStatus, SWT.NONE));
	setText("Rel updates?");

	updateChecker = new UpdatesCheck(parent.getDisplay()) {
		@Override
		public void completed(SendStatus sendStatus) {
			CheckForUpdates.this.completed(sendStatus);
		}
	};

	TimerTask checkForUpdates = new TimerTask() {
		@Override
		public void run() {
			if (CheckForUpdates.this.isDisposed())
				return;
			getDisplay().asyncExec(() -> {
				if (CheckForUpdates.this.isDisposed())
					return;
				setVisible(true);
				setText("Rel updates?");
				System.out.println("CheckForUpdates: check for updates.");
				updateChecker.doCancel();
				updateChecker.doSend();
			});
		}
	};

	// Check for updates after 10 seconds, then every 12 hours
	Timer checkTimer = new Timer();
	checkTimer.schedule(checkForUpdates, 1000 * 5, 1000 * 60 * 60 * 12);
}
 
 类所在包
 类方法
 同包方法