Java 类org.eclipse.swt.custom.ExtendedModifyListener 实例源码

项目:Black    文件:undoManager.java   
public undoManager(StyledText text,int level){
        if(text != null) {
            this.text = text;
            text.addExtendedModifyListener(new ExtendedModifyListener() {

                @Override
                public void modifyText(ExtendedModifyEvent event) {
                    // TODO Auto-generated method stub
//                  if(event.st)
                }
            });
        }
        this.level = level;
    }
项目:Black    文件:blackTextArea.java   
public void addModifyListener(final StyledText st) {
    st.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            // TODO Auto-generated method stub
            black.ba.setFileChanged();
        }
    });

    // Ϊ��������ַ�������ʽ
    st.addExtendedModifyListener(new ExtendedModifyListener() {

        public void modifyText(ExtendedModifyEvent event) {

            if (!st.isDisposed()) {
                if (event.start > 0 && event.start <= st.getCharCount()) {
                    int alignment = st.getLineAlignment(st.getLineAtOffset(event.start - 1));
                    st.setLineAlignment(st.getLineAtOffset(event.start), 1, alignment);

                    StyleRange s = st.getStyleRangeAtOffset(event.start - 1);
                    if (s != null && s.start + s.length < st.getCharCount()) {
                        s.start = event.start;
                        s.length = 1;

                        st.setStyleRange(s);
                    }
                }
                if (event.start + event.length == st.getCharCount() && defaultStyle != null) {
                    StyleRange sr = new StyleRange(defaultStyle);
                    sr.start = event.start;
                    sr.length = event.length;
                    st.setStyleRange(sr);
                    defaultStyle = null;
                }
            }
        }
    });
}
项目:Pydev    文件:ScriptConsoleViewer.java   
/**
 * Constructor.
 *
 * @param parent parent for the styled text
 * @param style style to be used
 */
public ScriptConsoleStyledText(Composite parent, int style) {
    super(parent, style);

    /**
     * The StyledText will change the caretOffset that we've updated during the modifications,
     * so, the verify and the extended modify listener will keep track if it actually does
     * that and will reset the caret to the position we actually added it.
     *
     * Feels like a hack but I couldn't find a better way to do it.
     */
    addVerifyListener(new VerifyListener() {

        @Override
        public void verifyText(VerifyEvent e) {
            internalCaretSet = -1;
        }
    });

    /**
     * Set it to the location we've set it to be.
     */
    addExtendedModifyListener(new ExtendedModifyListener() {

        @Override
        public void modifyText(ExtendedModifyEvent event) {
            if (internalCaretSet != -1) {
                if (internalCaretSet != getCaretOffset()) {
                    setCaretOffset(internalCaretSet);
                }
                internalCaretSet = -1;
            }
        }
    });

    initDragDrop();

    handleDeletePreviousWord = new HandleDeletePreviousWord();
    handleLineStartAction = new HandleLineStartAction();
}
项目:TranskribusSwtGui    文件:StyledTextGradientBackground.java   
public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    final StyledText styledText = new StyledText(shell, SWT.WRAP | SWT.BORDER |SWT.MULTI );
    styledText.setText(text);
    FontData data = display.getSystemFont().getFontData()[0];
    Font font = new Font(display, data.getName(), 16, SWT.BOLD);
    styledText.setFont(font);
    styledText.setForeground(display.getSystemColor(SWT.COLOR_BLUE));


//    styledText.setOrientation(SWT.RIGHT_TO_LEFT);
//  text.setTextDirection(SWT.RIGHT_TO_LEFT);

    styledText.setAlignment(SWT.RIGHT);

    styledText.addExtendedModifyListener(new ExtendedModifyListener() {
        @Override public void modifyText(ExtendedModifyEvent event) {
            styledText.setCaretOffset(event.start);
        }
    });    

//    styledText.addListener(SWT.Resize, new Listener() {
//      public void handleEvent(Event event) {
//        Rectangle rect = styledText.getClientArea();
//        Image newImage = new Image(display, 1, Math.max(1, rect.height));
//        GC gc = new GC(newImage);
//        gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
//        gc.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
//        gc.fillGradientRectangle(rect.x, rect.y, 1, rect.height, true);
//        gc.dispose();
//        styledText.setBackgroundImage(newImage);
//        if (oldImage != null)
//          oldImage.dispose();
//        oldImage = newImage;
//      }
//    });
    shell.setSize(700, 400);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    if (oldImage != null)
      oldImage.dispose();
    font.dispose();
    display.dispose();
  }
项目:TranskribusSwtGui    文件:ATranscriptionWidget.java   
public void addUserExtendedModifyListener(ExtendedModifyListener l) {
    extendedModifyListener.add(l);
    text.addExtendedModifyListener(l);
}