org.eclipse.swt.widgets.Caret Java Examples

The following examples show how to use org.eclipse.swt.widgets.Caret. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BidiLayout.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
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();
	}
}
 
Example #2
Source File: SWTUtil.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #3
Source File: SWTUtil.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #4
Source File: SWTUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #5
Source File: SWTUtil.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #6
Source File: GridCopyEnable.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @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();
}
 
Example #7
Source File: GridCopyEnable.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @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();
}
 
Example #8
Source File: CheckForUpdates.java    From Rel with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
}