Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.Span


    public void paint(Graphics2D graphics) {
        TextArea textArea = (TextArea)textAreaSkin.getComponent();

        int selectionStart = textArea.getSelectionStart();
        int selectionLength = textArea.getSelectionLength();
        Span selectionRange = new Span(selectionStart, selectionStart + selectionLength - 1);

        int paragraphOffset = paragraph.getOffset();
        Span characterRange = new Span(paragraphOffset, paragraphOffset
            + paragraph.getCharacters().length() - 1);

        if (selectionLength > 0
            && characterRange.intersects(selectionRange)) {
            boolean focused = textArea.isFocused();
            boolean editable = textArea.isEditable();

            // Determine the selected and unselected areas
            Area selection = textAreaSkin.getSelection();
View Full Code Here


                        // if there is nothing currently selected, selected the indicated row
                        if (startIndex == -1) {
                            tableView.addSelectedIndex(rowIndex);
                        } else {
                            // otherwise select the range of rows
                            Span selectedRange = (rowIndex > startIndex) ?
                                new Span(startIndex, rowIndex) : new Span(rowIndex, endIndex);

                            ArrayList<Span> selectedRanges = new ArrayList<Span>();
                            selectedRanges.add(selectedRange);

                            tableView.setSelectedRanges(selectedRanges);
View Full Code Here

                            // Select the range
                            ArrayList<Span> selectedRanges = new ArrayList<Span>();
                            int startIndex = listView.getFirstSelectedIndex();
                            int endIndex = listView.getLastSelectedIndex();

                            Span selectedRange = (itemIndex > startIndex) ?
                                new Span(startIndex, itemIndex) : new Span(itemIndex, endIndex);
                            selectedRanges.add(selectedRange);

                            listView.setSelectedRanges(selectedRanges);
                        }
                    } else if (Keyboard.isPressed(commandModifier)
View Full Code Here

        return boxPane;
    }

    private static Component addSpanControl(final Dictionary<String, Object> dictionary,
        final String key, Form.Section section) {
        Span span = (Span)dictionary.get(key);

        BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
        section.add(boxPane);
        Form.setLabel(boxPane, key);

        FlowPane flowPane = new FlowPane();
        flowPane.getStyles().put("alignToBaseline", true);
        flowPane.getStyles().put("horizontalSpacing", 5);
        boxPane.add(flowPane);

        TextInput textInput = new TextInput();
        textInput.setTextSize(10);
        textInput.setMaximumLength(10);
        textInput.setValidator(new IntValidator());
        textInput.setText(span == null ? "" : String.valueOf(span.start));
        flowPane.add(textInput);

        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
            @Override
            public void focusedChanged(Component component, Component obverseComponent) {
                if (!component.isFocused()) {
                    TextInput textInputLocal = (TextInput)component;
                    Span spanLocal = (Span)dictionary.get(key);

                    try {
                        int start = Integer.parseInt(textInputLocal.getText());
                        dictionary.put(key, new Span(start, spanLocal == null ? start : spanLocal.end));
                    } catch (Exception exception) {
                        displayErrorMessage(exception, component.getWindow());
                        textInputLocal.setText(spanLocal == null ? "" : String.valueOf(spanLocal.start));
                    }
                }
            }
        });

        Label label = new Label("start");
        label.getStyles().put("font", "{italic:true}");
        flowPane.add(label);

        flowPane = new FlowPane();
        flowPane.getStyles().put("alignToBaseline", true);
        flowPane.getStyles().put("horizontalSpacing", 5);
        boxPane.add(flowPane);

        textInput = new TextInput();
        textInput.setTextSize(10);
        textInput.setMaximumLength(10);
        textInput.setValidator(new IntValidator());
        textInput.setText(span == null ? "" : String.valueOf(span.end));
        flowPane.add(textInput);

        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
            @Override
            public void focusedChanged(Component component, Component obverseComponent) {
                if (!component.isFocused()) {
                    TextInput textInputLocal = (TextInput)component;
                    Span spanLocal = (Span)dictionary.get(key);

                    try {
                        int end = Integer.parseInt(textInputLocal.getText());
                        dictionary.put(key, new Span(spanLocal == null ? end : spanLocal.start, end));
                    } catch (Exception exception) {
                        displayErrorMessage(exception, component.getWindow());
                        textInputLocal.setText(spanLocal == null ? "" : String.valueOf(spanLocal.end));
                    }
                }
View Full Code Here

    private void updateSpanControl(Dictionary<String, Object> dictionary, String key) {
        BoxPane boxPane = (BoxPane)controls.get(key);

        if (boxPane != null) {
            Span span = (Span)dictionary.get(key);

            TextInput startTextInput = (TextInput)((FlowPane)boxPane.get(0)).get(0);
            TextInput endTextInput = (TextInput)((FlowPane)boxPane.get(1)).get(0);

            startTextInput.setText(span == null ? "" : String.valueOf(span.start));
View Full Code Here

        return boxPane;
    }

    private static Component addSpanControl(final Dictionary<String, Object> dictionary,
        final String key, Form.Section section) {
        Span span = (Span)dictionary.get(key);

        BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
        section.add(boxPane);
        Form.setLabel(boxPane, key);

        FlowPane flowPane = new FlowPane();
        flowPane.getStyles().put("alignToBaseline", true);
        flowPane.getStyles().put("horizontalSpacing", 5);
        boxPane.add(flowPane);

        TextInput textInput = new TextInput();
        textInput.setTextSize(10);
        textInput.setMaximumLength(10);
        textInput.setValidator(new IntValidator());
        textInput.setText(span == null ? "" : String.valueOf(span.start));
        flowPane.add(textInput);

        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
            @Override
            public void focusedChanged(Component component, Component obverseComponent) {
                if (!component.isFocused()) {
                    TextInput textInputLocal = (TextInput)component;
                    Span spanLocal = (Span)dictionary.get(key);

                    try {
                        int start = Integer.parseInt(textInputLocal.getText());
                        dictionary.put(key, new Span(start, spanLocal == null ? start : spanLocal.end));
                    } catch (Exception exception) {
                        displayErrorMessage(exception, component.getWindow());
                        textInputLocal.setText(spanLocal == null ? "" : String.valueOf(spanLocal.start));
                    }
                }
            }
        });

        Label label = new Label("start");
        label.getStyles().put("font", "{italic:true}");
        flowPane.add(label);

        flowPane = new FlowPane();
        flowPane.getStyles().put("alignToBaseline", true);
        flowPane.getStyles().put("horizontalSpacing", 5);
        boxPane.add(flowPane);

        textInput = new TextInput();
        textInput.setTextSize(10);
        textInput.setMaximumLength(10);
        textInput.setValidator(new IntValidator());
        textInput.setText(span == null ? "" : String.valueOf(span.end));
        flowPane.add(textInput);

        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
            @Override
            public void focusedChanged(Component component, Component obverseComponent) {
                if (!component.isFocused()) {
                    TextInput textInputLocal = (TextInput)component;
                    Span spanLocal = (Span)dictionary.get(key);

                    try {
                        int end = Integer.parseInt(textInputLocal.getText());
                        dictionary.put(key, new Span(spanLocal == null ? end : spanLocal.start, end));
                    } catch (Exception exception) {
                        displayErrorMessage(exception, component.getWindow());
                        textInputLocal.setText(spanLocal == null ? "" : String.valueOf(spanLocal.end));
                    }
                }
View Full Code Here

    private void updateSpanControl(Dictionary<String, Object> dictionary, String key) {
        BoxPane boxPane = (BoxPane)controls.get(key);

        if (boxPane != null) {
            Span span = (Span)dictionary.get(key);

            TextInput startTextInput = (TextInput)((FlowPane)boxPane.get(0)).get(0);
            TextInput endTextInput = (TextInput)((FlowPane)boxPane.get(1)).get(0);

            startTextInput.setText(span == null ? "" : String.valueOf(span.start));
View Full Code Here

    }

    @Override
    public void startup(Display display, Map<String, String> properties) {
        ArrayList<Span> selectedRanges = new ArrayList<Span>();
        selectedRanges.add(new Span(0, 0));

        listView.setSelectedRanges(selectedRanges);
        dumpSelection();

        listView.addSelectedRange(new Span(4, 4));
        dumpSelection();

        listView.addSelectedRange(new Span(2, 2));
        dumpSelection();

        listView.addSelectedRange(new Span(0, 4));
        dumpSelection();

        selectedRanges.clear();
        selectedRanges.add(new Span(1, 1));
        selectedRanges.add(new Span(3, 3));

        listView.setSelectedRanges(selectedRanges);
        dumpSelection();

        listView.addSelectedRange(new Span(0, 4));
        dumpSelection();

        listView.removeSelectedRange(new Span(2, 2));
        dumpSelection();

        listView.removeSelectedRange(new Span(4, 4));
        dumpSelection();

        listView.removeSelectedRange(new Span(0, 0));
        dumpSelection();

        listView.removeSelectedRange(new Span(1, 3));
        dumpSelection();

        selectedRanges.clear();
        selectedRanges.add(new Span(4, 6));
        listView.setSelectedRanges(selectedRanges);
        dumpSelection();

        listView.addSelectedRange(new Span(2, 5));
        dumpSelection();

        listView.addSelectedRange(new Span(4, 8));
        dumpSelection();

        verifySelection(0);
        verifySelection(4);
        verifySelection(6);
        verifySelection(8);

        listView.removeSelectedRange(new Span(8, 12));
        dumpSelection();
        verifySelection(8);

        listView.removeSelectedRange(new Span(0, 4));
        dumpSelection();
        verifySelection(4);

        listView.getListViewSelectionListeners().add(new ListViewSelectionListener.Adapter() {
            @Override
View Full Code Here

                if (keyCode == Keyboard.KeyCode.DELETE) {
                    List<Object> listData = (List<Object>)listView.getListData();

                    Sequence<Span> selectedRanges = listView.getSelectedRanges();
                    for (int i = selectedRanges.getLength() - 1; i >= 0; i--) {
                        Span selectedRange = selectedRanges.get(i);
                        listData.remove(selectedRange.start, selectedRange.end - selectedRange.start + 1);
                    }
                }

                return false;
View Full Code Here

                // TODO: in future use StringBuffer instead ...
                String selectionText = "";

                Sequence<Span> selectedRanges = listViewArgument.getSelectedRanges();
                for (int i = 0, n = selectedRanges.getLength(); i < n; i++) {
                    Span selectedRange = selectedRanges.get(i);

                    for (int j = selectedRange.start;
                        j <= selectedRange.end;
                        j++) {
                        if (selectionText.length() > 0) {
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.Span

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.