Package pivot.wtk

Examples of pivot.wtk.TextArea$TextAreaListenerList


        ListItem methodListItem = (ListItem)methodListButton.getSelectedItem();

        // Construct the HTTP request
        Request httpRequest = new Request(methodListItem.getText(), protocol.toString(), host, port, path);

        TextArea textArea = (TextArea)serializer.getObjectByID("request.body");
        String body = textArea.getText();
        httpRequest.setBody(body.getBytes());

        if (lenientHostnameVerification) {
            // Use a lenient hostname verifier to ensure that the request goes through
            httpRequest.setHostnameVerifier(lenientHostnameVerifier);
View Full Code Here


            document = plainTextSerializer.readObject(inputStream);
        } catch(Exception exception) {
            System.out.println(exception);
        }

        TextArea textArea = (TextArea)wtkxSerializer.getObjectByName("text.textArea");
        textArea.setDocument(document);

        final WatermarkDecorator watermarkDecorator = new WatermarkDecorator("Preview");
        watermarkDecorator.setOpacity(0.1f);
        watermarkDecorator.setFont(watermarkDecorator.getFont().deriveFont(Font.BOLD, 24));

        textArea.getDecorators().add(watermarkDecorator);

        textArea.getComponentStateListeners().add(new ComponentStateListener() {
            public void enabledChanged(Component component) {
                // No-op
            }

            public void focusedChanged(Component component, boolean temporary) {
View Full Code Here

        }

        @Override
        public void validate() {
            if (!isValid()) {
                TextArea textArea = (TextArea)getComponent();
                Container parent = textArea.getParent();

                int breakWidth = getBreakWidth();

                int width = 0;
                int y = 0;

                int top = -textArea.getY();
                int bottom = top + parent.getHeight();

                int i = 0;
                int j = 0;
                int n = getLength();
View Full Code Here

    }

    public void install(Component component) {
        super.install(component);

        TextArea textArea = (TextArea)component;
        textArea.getTextAreaListeners().add(this);
        textArea.getTextAreaSelectionListeners().add(this);

        textArea.setCursor(Cursor.TEXT);

        Document document = textArea.getDocument();
        if (document != null) {
            documentView = new DocumentView(document);
            documentView.attach();
        }
View Full Code Here

        selectionChanged(textArea, 0, 0);
    }

    public void uninstall() {
        TextArea textArea = (TextArea)getComponent();
        textArea.getTextAreaListeners().remove(this);
        textArea.getTextAreaSelectionListeners().remove(this);

        textArea.setCursor(Cursor.DEFAULT);

        if (documentView != null) {
            documentView.detach();
            documentView = null;
        }
View Full Code Here

        super.uninstall();
    }

    @Override
    public boolean isFocusable() {
        TextArea textArea = (TextArea)getComponent();
        return textArea.isEditable();
    }
View Full Code Here

        }
    }

    public void paint(Graphics2D graphics) {
        if (documentView != null) {
            TextArea textArea = (TextArea)getComponent();

            graphics.translate(margin.left, margin.top);
            documentView.paint(graphics);

            if (textArea.getSelectionLength() == 0
                && textArea.isFocused()
                && caretOn) {
                graphics.setPaint(Color.BLACK);
                graphics.fill(caret);
            }
        }
View Full Code Here

        }
    }

    @Override
    public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
        TextArea textArea = (TextArea)component;

        if (button == Mouse.Button.LEFT) {
            // Move the caret to the insertion point
            int offset = getCharacterAt(x, y);
            if (offset != -1) {
                textArea.setSelection(offset, 0);
            }

            caretX = x;

            // TODO Register mouse listener to begin selecting text; also handle
            // auto-scrolling when the mouse moves outside the component

            // Set focus to the text input
            if (textArea.isEditable()) {
                textArea.requestFocus();
            }
        }

        return super.mouseDown(component, button, x, y);
    }
View Full Code Here

    @Override
    public boolean keyTyped(Component component, char character) {
        boolean consumed = super.keyTyped(component, character);

        TextArea textArea = (TextArea)getComponent();

        if (textArea.isEditable()) {
            Document document = textArea.getDocument();

            if (document != null) {
                // Ignore characters in the control range and the ASCII delete
                // character
                if (character > 0x1F
                    && character != 0x7F) {
                    textArea.insertText(character);
                }
            }
        }

        return consumed;
View Full Code Here

    @Override
    public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
        boolean consumed = false;

        TextArea textArea = (TextArea)getComponent();

        if (textArea.isEditable()) {
            Document document = textArea.getDocument();

            if (document != null) {
                if (keyCode == Keyboard.KeyCode.ENTER) {
                    textArea.insertParagraph();
                    caretX = 0;
                } else if (keyCode == Keyboard.KeyCode.DELETE) {
                    textArea.delete(Direction.FORWARD);
                } else if (keyCode == Keyboard.KeyCode.BACKSPACE) {
                    textArea.delete(Direction.BACKWARD);
                } else if (keyCode == Keyboard.KeyCode.LEFT) {
                    int selectionStart = textArea.getSelectionStart();
                    int selectionLength = textArea.getSelectionLength();

                    if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)) {
                        // Add the previous character to the selection
                        if (selectionStart > 0) {
                            selectionStart--;
                            selectionLength++;
                        }
                    } else {
                        // Clear the selection and move the caret back by one
                        // character
                        if (selectionLength == 0
                            && selectionStart > 0) {
                            selectionStart--;
                        }

                        selectionLength = 0;
                    }

                    textArea.setSelection(selectionStart, selectionLength);

                    caretX = caret.x;

                    consumed = true;
                } else if (keyCode == Keyboard.KeyCode.RIGHT) {
                    int selectionStart = textArea.getSelectionStart();
                    int selectionLength = textArea.getSelectionLength();

                    if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)) {
                        // Add the next character to the selection
                        if (selectionStart + selectionLength < document.getCharacterCount()) {
                            selectionLength++;
                        }
                    } else {
                        // Clear the selection and move the caret forward by one
                        // character
                        selectionStart += selectionLength;

                        if (selectionLength == 0
                            && selectionStart < document.getCharacterCount()) {
                            selectionStart++;
                        }

                        selectionLength = 0;
                    }

                    textArea.setSelection(selectionStart, selectionLength);

                    caretX = caret.x;

                    consumed = true;
                } else if (keyCode == Keyboard.KeyCode.UP) {
                    // TODO We shouldn't need a "magic" number like 2 here
                    int offset = documentView.getCharacterAt(caretX, caret.y - 2);

                    // TODO Modify selection based on SHIFT key
                    textArea.setSelection(offset, 0);

                    // TODO Make sure we scroll the next view to visible

                    consumed = true;
                } else if (keyCode == Keyboard.KeyCode.DOWN) {
                    int offset = documentView.getCharacterAt(caretX, caret.y + caret.height + 1);

                    // TODO Modify selection based on SHIFT key
                    textArea.setSelection(offset, 0);

                    // TODO Make sure we scroll the next view to visible

                    consumed = true;
                } else if (Keyboard.isPressed(Keyboard.Modifier.CTRL)) {
                    if (keyCode == Keyboard.KeyCode.A) {
                        textArea.setSelection(0, document.getCharacterCount());
                    } else if (keyCode == Keyboard.KeyCode.X) {
                        textArea.cut();
                    } else if (keyCode == Keyboard.KeyCode.C) {
                        textArea.copy();
                    } else if (keyCode == Keyboard.KeyCode.V) {
                        textArea.paste();
                    } else if (keyCode == Keyboard.KeyCode.Z) {
                        if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)) {
                            textArea.undo();
                        } else {
                            textArea.redo();
                        }
                    }
                } else {
                    consumed = super.keyPressed(component, keyCode, keyLocation);
                }
View Full Code Here

TOP

Related Classes of pivot.wtk.TextArea$TextAreaListenerList

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.