Examples of PlainTextSerializer


Examples of org.apache.pivot.wtk.text.PlainTextSerializer

            // Copy selection to clipboard
            Document selection = (Document)removeDocumentRange(selectionStart, selectionLength);

            String selectedText = null;
            try {
                PlainTextSerializer serializer = new PlainTextSerializer();
                StringWriter writer = new StringWriter();
                serializer.writeObject(selection, writer);
                selectedText = writer.toString();
            } catch(IOException exception) {
                throw new RuntimeException(exception);
            }
View Full Code Here

Examples of org.apache.pivot.wtk.text.PlainTextSerializer

                // Insert the clipboard contents
                Document documentLocal;
                int n;
                try {
                    PlainTextSerializer serializer = new PlainTextSerializer();
                    StringReader reader = new StringReader(text);
                    documentLocal = serializer.readObject(reader);
                    n = documentLocal.getCharacterCount();

                    bulkOperation = true;
                    int start = selectionStart;
                    this.document.insertRange(documentLocal, start);
View Full Code Here

Examples of org.apache.pivot.wtk.text.PlainTextSerializer

        if (selectionLength > 0) {
            Document selection = (Document)document.getRange(selectionStart, selectionLength);

            try {
                PlainTextSerializer serializer = new PlainTextSerializer();
                StringWriter writer = new StringWriter();
                serializer.writeObject(selection, writer);
                selectedText = writer.toString();
            } catch(IOException exception) {
                throw new RuntimeException(exception);
            }
        }
View Full Code Here

Examples of org.apache.pivot.wtk.text.PlainTextSerializer

        String text = null;
        Document document = getDocument();

        if (document != null) {
            try {
                PlainTextSerializer serializer = new PlainTextSerializer();
                StringWriter writer = new StringWriter();
                serializer.writeObject(document, writer);
                text = writer.toString();
            } catch(SerializationException exception) {
                throw new RuntimeException(exception);
            } catch(IOException exception) {
                throw new RuntimeException(exception);
View Full Code Here

Examples of org.apache.pivot.wtk.text.PlainTextSerializer

        Document document = null;

        if (text != null
            && text.length() > 0) {
            try {
                PlainTextSerializer serializer = new PlainTextSerializer();
                StringReader reader = new StringReader(text);
                document = serializer.readObject(reader);
            } catch(IOException exception) {
                throw new RuntimeException(exception);
            }
        } else {
            document = new Document();
View Full Code Here

Examples of org.apache.pivot.wtk.text.PlainTextSerializer

        setDocument(document);
    }

    public void setText(URL text) {
        PlainTextSerializer plainTextSerializer = new PlainTextSerializer("UTF-8");

        Document document = null;
        InputStream inputStream = null;

        try {
            try {
                inputStream = text.openStream();
                document = plainTextSerializer.readObject(inputStream);
            } finally {
                if (inputStream != null) {
                    inputStream.close();
                }
            }
View Full Code Here

Examples of org.apache.pivot.wtk.text.PlainTextSerializer

            // Copy selection to clipboard
            Document selection = (Document)document.removeRange(selectionStart, selectionLength);

            String selectedText = null;
            try {
                PlainTextSerializer serializer = new PlainTextSerializer();
                StringWriter writer = new StringWriter();
                serializer.writeObject(selection, writer);
                selectedText = writer.toString();
            } catch(SerializationException exception) {
                throw new RuntimeException(exception);
            } catch(IOException exception) {
                throw new RuntimeException(exception);
View Full Code Here

Examples of org.apache.pivot.wtk.text.PlainTextSerializer

                // Insert the clipboard contents
                Document document;
                int n;
                try {
                    PlainTextSerializer serializer = new PlainTextSerializer();
                    StringReader reader = new StringReader(text);
                    document = serializer.readObject(reader);
                    n = document.getCharacterCount();

                    this.document.insertRange(document, selectionStart);
                } catch(IOException exception) {
                    throw new RuntimeException(exception);
View Full Code Here

Examples of org.apache.pivot.wtk.text.PlainTextSerializer

        if (selectionLength > 0) {
            Document selection = (Document)document.getRange(selectionStart, selectionLength);

            try {
                PlainTextSerializer serializer = new PlainTextSerializer();
                StringWriter writer = new StringWriter();
                serializer.writeObject(selection, writer);
                selectedText = writer.toString();
            } catch(SerializationException exception) {
                throw new RuntimeException(exception);
            } catch(IOException exception) {
                throw new RuntimeException(exception);
View Full Code Here

Examples of org.apache.pivot.wtk.text.PlainTextSerializer

                        if (sheet.getResult()) {
                            loadedFile = fileBrowserSheet.getSelectedFile();

                            try {
                                BufferedReader reader = new BufferedReader(new FileReader(loadedFile));
                                PlainTextSerializer serializer = new PlainTextSerializer();
                                textPane.setDocument(serializer.readObject(reader));
                                reader.close();
                                window.setTitle(loadedFile.getCanonicalPath());
                            } catch (IOException ex) {
                                ex.printStackTrace();
                                Alert.alert(ex.getMessage(), window);
                            }
                        }
                    }
                });
            }
        });

        saveFileButton.getButtonPressListeners().add(new ButtonPressListener() {
            @Override
            public void buttonPressed(Button button) {
                final FileBrowserSheet fileBrowserSheet = new FileBrowserSheet();

                if (loadedFile != null) {
                    fileBrowserSheet.setSelectedFile(loadedFile);
                }

                fileBrowserSheet.setMode(FileBrowserSheet.Mode.SAVE_AS);
                fileBrowserSheet.open(window, new SheetCloseListener() {
                    @Override
                    public void sheetClosed(Sheet sheet) {
                        if (sheet.getResult()) {
                            File selectedFile = fileBrowserSheet.getSelectedFile();

                            try {
                                FileWriter writer = new FileWriter(selectedFile);
                                PlainTextSerializer serializer = new PlainTextSerializer();
                                serializer.writeObject(textPane.getDocument(), writer);
                                writer.close();
                                loadedFile = selectedFile;
                                window.setTitle(loadedFile.getCanonicalPath());
                            } catch (IOException ex) {
                                ex.printStackTrace();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.