Package org.sodbeans.controller.impl.processors

Examples of org.sodbeans.controller.impl.processors.NullProcessor


    private JSlider slider;

    @Override
    protected SpeechProcessor getKeyEventProcessor() {
       if (slider == null || (getUberEvent().key.getKeyCode() != KeyEvent.VK_LEFT && getUberEvent().key.getKeyCode() != KeyEvent.VK_RIGHT))
            return new NullProcessor();

        SliderProcessor proc = new SliderProcessor();
        proc.setKeyEvent(true);

        //When a checkbox is selected using the space bar read "selected" followed by the name of the checkbox followed by "Check Box"
View Full Code Here


    private JMenuItem menuItem = null;
   
    @Override
    protected SpeechProcessor getMenuEventProcessor() {
        if (menuItem == null)
            return new NullProcessor();

        MenuItemProcessor proc = new MenuItemProcessor();
        proc.setText(menuItem.getText());
        proc.setEnabled(menuItem.isEnabled());
        proc.setAccelerator(menuItem.getAccelerator());
View Full Code Here

    protected SpeechProcessor getKeyEventProcessor() {
        // If this is the tutorial text area, don't speak anything! It
        // gets in the way.
        String accessibleName = text.getAccessibleContext().getAccessibleName();
        if (accessibleName != null && accessibleName.equals(TUTORIAL_TEXT_AREA_NAME)) {
            NullProcessor proc = new NullProcessor();
            return proc;
        }
       
        //if the screen magnification is on, tell it what's going on
        if(magnifier.isStarted()) {
            try {
                Rectangle x = text.modelToView(text.getCaretPosition());
               
                // Focus at the point in the editor.
                magnifier.setFocusCenter(x.x + text.getLocationOnScreen().x, x.y +
                        text.getLocationOnScreen().y);
               
                // Move the magnifier as well (if windowed).
                if (!magnifier.isFullScreen()) {
                    magnifier.setLocation(x.x + text.getLocationOnScreen().x - (magnifier.getWidth()/2), x.y +
                        text.getLocationOnScreen().y - (magnifier.getHeight()/2));
                }
            } catch (BadLocationException ex) { //ignore the call or log it?
                Logger.getLogger(EditorReader.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
       
        // Master processor used for the editor.
        // Allows us to do things like append brace matcher text.
        EditorProcessor proc = new EditorProcessor();
        proc.setCodeEditor(true); // assume it is a code editor for now
        proc.setPasswordField(text instanceof JPasswordField);
       
        String message = null;
        boolean addAnnotation = false;
        boolean addMatcherText = false;

        char code = getUberEvent().key.getKeyChar();
        int keyCode = getUberEvent().key.getKeyCode();

        //save whether the shift key is held
        boolean isShiftDown = getUberEvent().key.isShiftDown();
        //save whether the alt key is held
        boolean isAltDown = getUberEvent().key.isAltDown();
        //save whether the meta/altGr key is held
        boolean isMetaDown = getUberEvent().key.isMetaDown();
        //save whether the control key is held
        boolean isControlDown = getUberEvent().key.isControlDown();

        //get operating system
        String os = System.getProperty("os.name");

        //get type of textbox
        String editorType = text.getClass().getName();


        boolean process = false;
        //variable for whether the line information should be spoken
        boolean lineInfo = false;

        // Determine whether or not editing is allowed.
        proc.setEditable(text.isEditable());
        proc.setMultiLine(text instanceof JEditorPane);

        switch (keyCode) {
            //right key is pressed
            case KeyEvent.VK_RIGHT:
                //While the alt key is held on Mac OS - jumps over next word
                if (isAltDown && !getUberEvent().preprocess && os.startsWith("Mac")) {
                    //after event, read previous word
                    proc.setText(getPreviousWord());
                    process = true;
                }
                //while the control key is held on Windows - jumps over next word
                else if (isControlDown && !getUberEvent().preprocess && os.startsWith("Win")){
                    //after event, read previous word
                    proc.setText(getPreviousWord());
                    process = true;
                }
                //while the meta key is held on Mac OS - jumps to end of line
                else if (isMetaDown && !getUberEvent().preprocess && os.startsWith("Mac")) {
                    //after event, read previous word - last word on line
                    proc.setText(getPreviousWord());
                    process = true;
                }
                //otherwise read character that was stepped over
                else {
                    // Don't read newlines here.
                    String c = getCurrentCharacterAsString();
                    if (!c.equals("\n") && !c.equals("\r")) {
                        proc.setText(getCurrentCharacterAsString());
                        proc.setRequestType(RequestType.CHARACTER);
                        process = true;
                    }
 
                    //if you are not using any special keys and you are in the editor, also do auditory brace matching
                    /*if (!isControlDown && !isShiftDown && !isAltDown && !isMetaDown && editorType.equals("org.openide.text.QuietEditorPane")) {
                        addMatcherText = true;
                    }*/
                    process = true;
                }
                break;

            //delete key is pressed
            case KeyEvent.VK_DELETE:
                if (getUberEvent().preprocess) {
                    String word;
                    word = Character.toString(getNextCharacter());
                    //followed by "deleted"
                    proc.setText(word);
                    proc.setRequestType(RequestType.CHARACTER);
                    proc.setDeletedChar(true);
                    process = true;
                }
                break;

            //backspace key is pressed
            case KeyEvent.VK_BACK_SPACE:
                if (getUberEvent().preprocess) {
                    String word;
                    // say character was deleted.
                    proc.setText(Character.toString(getPreviousCharacter()));
                    proc.setRequestType(RequestType.CHARACTER);
                    proc.setDeletedChar(true);
                    process = true;
                }
                break;

            //left key is pressed
            case KeyEvent.VK_LEFT:
                //While the alt key is held on Mac OS - jumps over previous word
                if (isAltDown && !getUberEvent().preprocess && os.startsWith("Mac")) {
                    //after event, read next word
                    proc.setText(getNextWord());
                    process = true;
                }
                //while the control key is held on Windows - jumps over pevious word
                else if (isControlDown && !getUberEvent().preprocess && os.startsWith("Win")){
                    //after event, read next word
                    proc.setText(getNextWord());
                    process = true;
                }
                //while the meta key is held on Mac OS - jumps to beginning of line
                else if (isMetaDown && !getUberEvent().preprocess && os.startsWith("Mac")) {
                    //after event, read next word - first word on line
                    proc.setText(getNextWord());
                    process = true;
                }
                //otherwise read character that was stepped over
                else {
                    // Don't read newlines here.
                    String c = getCurrentCharacterAsString();
                    if (!c.equals("\n") && !c.equals("\r")) {
                        proc.setText(getCurrentCharacterAsString());
                        proc.setRequestType(RequestType.CHARACTER);
                        process = true;
                    }

                    //if you are not using any special keys and you are in the editor, also do auditory brace matching
                    /*if (!isControlDown && !isShiftDown && !isAltDown && !isMetaDown && editorType.equals("org.openide.text.QuietEditorPane")) {
                        // TODO: Modify handling of matcher text
                        addMatcherText = true;
                    }*/
                    process = true;
                }

                break;

            //up or down arrow key is pressed
            case KeyEvent.VK_UP:
            case KeyEvent.VK_DOWN:
                //read current line
                proc.setText(getCurrentLineOfText());
                process = true;
                lineInfo = true;
                //if you are not using any special keys and you are in the editor, also do auditory brace matching and add annotations
                if (!isControlDown && !isShiftDown && !isAltDown && !isMetaDown && editorType.equals("org.openide.text.QuietEditorPane")) {
                    addMatcherText = true;
                    addAnnotation = true;
                }
                break;

            //end button is pressed
            case KeyEvent.VK_END:
                //read previous word - last word on line
                proc.setText(getPreviousWord());
                process = true;
                break;

            //home button is pressed
            case KeyEvent.VK_HOME:
                //read next word - first word on line
                proc.setText(getNextWord());
                process = true;
                break;

            //0 is pressed
            case KeyEvent.VK_0:
                // If control is down, don't speak "0".
                if (isControlDown || isMetaDown)
                {
                    // Fix to focus bug on Windows
                    proc.setText("");
                    process = false;
                }
                else
                {
                    if (Character.isDefined(code) && keyCode != 0) {
                        proc.setText(Character.toString(code));
                        process = true;
                    }
                    //}
                    proc.setRequestType(RequestType.CHARACTER)
                    }
                break;
               
            //1 is pressed
            case KeyEvent.VK_1:
                //if shift is pressed - exclamation mark is written - read "exclamation"
                /*if (isShiftDown && !getUberEvent().preprocess) {
                    //read "exclamation"
                    proc.setText("!");
                    process = true;
                }
                //otherwise read normal character
                else {*/
                if (Character.isDefined(code) && keyCode != 0) {
                    proc.setText(Character.toString(code));
                    process = true;
                }
                //}
                proc.setRequestType(RequestType.CHARACTER);
                break;

            //C is pressed
            case KeyEvent.VK_C:
                //if control is pressed on Windows, read "copy"
                if (os.startsWith("Win") && isControlDown && !getUberEvent().preprocess) {
                    //read line number
                    proc.setText("copy");
                    process = true;
                }
                //if command (meta-key) is pressed on Mac, read "copy"
                if (os.startsWith("Mac") && isMetaDown && !getUberEvent().preprocess) {
                    //read line number
                    proc.setText("copy");
                    process = true;
                }
                //otherwise read normal character
                else {
                    if (Character.isDefined(code) && keyCode != 0) {
                        proc.setText(Character.toString(code));
                        proc.setRequestType(RequestType.CHARACTER);
                        process = true;
                    }
                }
                break;

            //L is pressed
            case KeyEvent.VK_L:
                //if control is pressed
                if (isControlDown && !getUberEvent().preprocess) {
                    //read line number
                    int line = getCurrentLineNumber();
                    proc.setLineNumber(line);
                    process = true;
                }
                //otherwise read normal character
                else {
                    if (Character.isDefined(code) && keyCode != 0) {
                        proc.setText(Character.toString(code));
                        proc.setRequestType(RequestType.CHARACTER);
                        process = true;
                    }
                }
                break;

            //V is pressed
            case KeyEvent.VK_V:
                //if control is pressed on Windows, read "copy"
                if (os.startsWith("Win") && isControlDown && !getUberEvent().preprocess) {
                    //read line number
                    proc.setText("paste");
                    process = true;
                }
                //if command (meta-key) is pressed on Mac, read "copy"
                if (os.startsWith("Mac") && isMetaDown && !getUberEvent().preprocess) {
                    //read line number
                    proc.setText("paste");
                    process = true;
                }
                //otherwise read normal character
                else {
                    if (Character.isDefined(code) && keyCode != 0) {
                        proc.setText(Character.toString(code));
                        proc.setRequestType(RequestType.CHARACTER);
                        process = true;
                    }
                }
                break;

            //X is pressed
            case KeyEvent.VK_X:
                //if control is pressed on Windows, read "copy"
                if (os.startsWith("Win") && isControlDown && !getUberEvent().preprocess) {
                    //read line number
                    proc.setText("cut");
                    process = true;
                }
                //if command (meta-key) is pressed on Mac, read "copy"
                if (os.startsWith("Mac") && isMetaDown && !getUberEvent().preprocess) {
                    //read line number
                    proc.setText("cut");
                    process = true;
                }
                //otherwise read normal character
                else {
                    if (Character.isDefined(code) && keyCode != 0) {
                        proc.setText(Character.toString(code));
                        proc.setRequestType(RequestType.CHARACTER);
                        process = true;
                    }
                }
                break;

            //Y is pressed
            case KeyEvent.VK_Y:
                //if control is pressed on Windows, read "copy"
                if (os.startsWith("Win") && isControlDown && !getUberEvent().preprocess) {
                    //read line number
                    proc.setText("redo");
                    process = true;
                }
                //if command (meta-key) is pressed on Mac, read "copy"
                if (os.startsWith("Mac") && isMetaDown && !getUberEvent().preprocess) {
                    //read line number
                    proc.setText("redo");
                    process = true;
                }
                //otherwise read normal character
                else {
                    if (Character.isDefined(code) && keyCode != 0) {
                        proc.setText(Character.toString(code));
                        proc.setRequestType(RequestType.CHARACTER);
                        process = true;
                    }
                }
                break;

            //Z is pressed
            case KeyEvent.VK_Z:
                //if control is pressed on Windows, read "copy"
                if (os.startsWith("Win") && isControlDown && !getUberEvent().preprocess) {
                    //read line number
                    proc.setText("undo");
                    process = true;
                }
                //if command (meta-key) is pressed on Mac, read "copy"
                if (os.startsWith("Mac") && isMetaDown && !getUberEvent().preprocess) {
                    //read line number
                    proc.setText("undo");
                    process = true;
                }
                //otherwise read normal character
                else {
                    if (Character.isDefined(code) && keyCode != 0) {
                        proc.setText(Character.toString(code));
                        proc.setRequestType(RequestType.CHARACTER);
                        process = true;
                    }
                }
                break;

            default:
                if (Character.isDefined(code) && keyCode != 0) {
                    proc.setText(Character.toString(code));
                    proc.setRequestType(RequestType.CHARACTER);
                    process = true;
                }
        }

        if (process) {
            String processed = textProcessor.process("");
            if (lineInfo && proc.isMultiLine()) {
                proc.setLineNumber(getCurrentLineNumber());
                if (getCurrentLineNumber() == 1)
                    proc.setStartOfDocument(true);
                else if(getLastLineNumber() == getCurrentLineNumber())
                    proc.setEndOfDocument(true);
            }
           
            //add the end matcher text to the end of the processed line message
            if (addMatcherText) {
                proc.setBraceMatcherText(getMatchingMessage());
            }
            //ad the line annotation descriptions to the end of the processed line message
            if (addAnnotation) {
                proc.setAnnotations(getAnnotation());
            }
        }

        return proc;
    }
View Full Code Here

    @Override
    @SuppressWarnings("empty-statement")
    protected SpeechProcessor getKeyEventProcessor() {
        if (box == null)
            return new NullProcessor();

        ComboBoxProcessor proc = new ComboBoxProcessor();
        Object o = box.getSelectedItem();
        String sayString = null;
        Accessible acc = null;
View Full Code Here

    }

    @Override
    protected SpeechProcessor getFocusEventProcessor() {
        if (box == null)
            return new NullProcessor();

        ComboBoxProcessor proc = new ComboBoxProcessor();
        proc.setKeyEvent(false);
        String accessibleDesc = null;
        String name = null;
View Full Code Here

TOP

Related Classes of org.sodbeans.controller.impl.processors.NullProcessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.