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

项目:bts    文件: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;
}
项目: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;
}
项目: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;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件: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;
}
项目: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;
}
项目: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();
}
项目: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();
}
项目:StringEditEclipse    文件:StringHandler.java   
public static Point getPoint(Caret c) {
    Point p = new Point(c.getBounds().x + 46, c.getBounds().y
            + c.getBounds().height + 51);

    Control control = c.getParent();

    while (control.getParent() != null) {
        control = control.getParent();
        p.x += control.getBounds().x;
        p.y += control.getBounds().y;
    }

    return p;
}
项目:Black    文件:windowLocation.java   
/**
 * ��ֹ���ڳ�����Ļ
 * �˷����������ձ��ԣ�����black�����ijЩShell�������
 * @param location ����λ�õ�
 * @param shell ��ҪУ׼��Shell����
 * @param addvalue �ڻ���λ�õ�location֮�ϵ����긽��ֵ������Ϊnull
 * 
 */
public static Point windowAlwaysInScreen(Point location,Shell parent, Shell shell,Caret caret){
    int newX = 0,newY = 0;
    int width = 0, height = 0;
    int lineheightatcaretoffset = (int)caret.getData();
    int caretsizeX = 0,caretsizeY =0;
    if(caret != null){
        caretsizeX = caret.getSize().x;
        caretsizeY = caret.getSize().y;
    }
    if(parent != null){
        width = returnScreenWidth();
        //width = parent.getSize().x;
        height = parent.getSize().y;
    }else{
        width = returnScreenWidth();
        height = returnScreenHeight();
    }
    int locationX = location.x;
    int locationY = location.y;
    int sizeX = shell.getSize().x;
    int sizeY = shell.getSize().y;

    if(locationX <= 0){
        newX = 0;
    }
    if(locationX+sizeX+caretsizeX >= width){
        newX = width-sizeX;
    }
    if(locationY <= 0){
        newY = 0;
    }
    if(locationY+sizeY+caretsizeY >= height){
        if(caret.getStyle() == SWT.VERTICAL)
            newY = locationY-sizeY;
        else newY = locationY-sizeY-lineheightatcaretoffset;
    }
    if(newX == 0) newX = locationX;
    if(newY == 0) {
        if(caret.getStyle() == SWT.VERTICAL)
            newY = locationY+caretsizeY;
        else newY = locationY+caret.getSize().y;
    }
    shell.setLocation(newX, newY);
    return new Point(newX,newY);
}
项目: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);
}