Examples of MConstText


Examples of com.ibm.richtext.styledtext.MConstText

        try {
            ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_NAME);

            Object document = bundle.getObject(docName+".sample");
            MConstText text;
           
            if (document instanceof String) {
                text = new StyledText((String)document,
                                      AttributeMap.EMPTY_ATTRIBUTE_MAP);
            }
View Full Code Here

Examples of com.ibm.richtext.styledtext.MConstText

    public static boolean testMTextToString(String mtextFile, String stringFile) {

        boolean success = false;

        File mtext = new File(mtextFile);
        MConstText text = FileUtils.loadMText(mtext);
        if (text != null) {
            String str = StringToMText.loadString(new File(stringFile));
            if (str != null) {
                success = compareMTextToString(text, str);
            }
View Full Code Here

Examples of com.ibm.richtext.styledtext.MConstText

        String fileStr = dialog.getFile();
        String dirStr = dialog.getDirectory();

        if (fileStr != null) {
            File rval = new File(dirStr, fileStr);
            MConstText src = loadMText(rval);
            if (src != null) {
                dest.replaceAll(src);
                return rval;
            }
        }
View Full Code Here

Examples of com.ibm.richtext.styledtext.MConstText

        try {
            FileInputStream inStream = new FileInputStream(file);
            ObjectInputStream objStream = new ObjectInputStream(inStream);

            MConstText text = (MConstText) objStream.readObject();
            inStream.close();
            return text;
        }
        catch(IOException e) {
            error = e;
View Full Code Here

Examples of com.ibm.richtext.styledtext.MConstText

    }

    public static void writeMTextAsString(String inFile, String outFile) {

        File file = new File(inFile);
        MConstText text = FileUtils.loadMText(file);

        if (text != null) {
            char[] ch = new char[text.length()];
            text.extractChars(0, ch.length, ch, 0);
            String str = new String(ch);
            writeString(str, outFile);
        }
        else {
            System.out.println("Can't read inFile.");
View Full Code Here

Examples of com.ibm.richtext.styledtext.MConstText

        else {
            String str = loadString(new File(args[0]));
            if (str == null) {
                throw new Error("Couldn't load String from file " + args[0]);
            }
            MConstText text = new StyledText(str, AttributeMap.EMPTY_ATTRIBUTE_MAP);
            FileUtils.saveMText(new File(args[1]), text);
        }
    }
View Full Code Here

Examples of com.ibm.richtext.styledtext.MConstText

    public void test() {

        AttributeMap bold = new AttributeMap(TextAttribute.WEIGHT,
                                             TextAttribute.WEIGHT_BOLD);
        MConstText text1 = new StyledText("Test contents. 1234\nHow about it?",
                                              AttributeMap.EMPTY_ATTRIBUTE_MAP);
        MConstText text2 = new StyledText("Another test string.", bold);

        _testWithText(text1);
        _testWithText(text2);
        _testWithText(new StyledText());
View Full Code Here

Examples of com.ibm.richtext.styledtext.MConstText

     * Text must be editable to pass this test.
     */
    public void _testModifications(MConstText insertionText,
                                   boolean restoreOldText) {

        MConstText oldText = new StyledText(fTextPanel.getText());
        final int insLength = insertionText.length();

        fListener.allowAll();
        fListener.expectEvent(TextPanelEvent.TEXT_CHANGED);
        fListener.expectEvent(TextPanelEvent.SELECTION_RANGE_CHANGED);
        fTextPanel.append(insertionText);
        fListener.assertNotExpectingEvents();
       
        if (fTextPanel.getSelectionStart() != oldText.length() + insLength) {
            reportError("Append didn't result in correct selection");
        }

        fListener.expectEvent(TextPanelEvent.TEXT_CHANGED);
        fListener.expectEvent(TextPanelEvent.SELECTION_RANGE_CHANGED);
        fTextPanel.insert(insertionText, 0);
        fListener.assertNotExpectingEvents();
        fListener.allowAll();
       
        if (fTextPanel.getSelectionStart() != insLength) {
            reportError("Insert didn't result in correct selection");
        }

        fTextPanel.replaceRange(insertionText, insLength, insLength+oldText.length());
        if (fTextPanel.getSelectionStart() != insLength*2) {
            reportError("Replace didn't result in correct selection");
        }
        if (fTextPanel.getSelectionEnd() != insLength*2) {
            reportError("Replace didn't result in correct selection");
        }
        if (fTextPanel.getTextLength() != insLength*3) {
            reportError("textLength is incorrect");
        }

        if (restoreOldText) {
            fTextPanel.setText(oldText);
            if (fTextPanel.getSelectionStart() != oldText.length()) {
                reportError("setText didn't result in correct selection");
            }
            if (fTextPanel.getTextLength() != oldText.length()) {
                reportError("length incorrect after setText");
            }
        }
       
        fListener.allowAll();
View Full Code Here

Examples of com.ibm.richtext.styledtext.MConstText

        //catch(Error e) {
        //    logMessage("iterationCount="+iterationCount+";  expexting="+exp);
        //    throw e;
        //}

        MConstText insText = new StyledText("7",
                                AttributeMap.EMPTY_ATTRIBUTE_MAP);

        final int origLength = fTextPanel.getTextLength();
        int start = origLength / 3;
       
        fListener.allowEvent(TextPanelEvent.SELECTION_RANGE_CHANGED);
        fListener.allowEvent(TextPanelEvent.SELECTION_STYLES_CHANGED);

        for (int i=start; i < BIG_COMMAND_LOG_SIZE+start; i++) {
            fListener.expectEvent(TextPanelEvent.UNDO_STATE_CHANGED);
            fListener.expectEvent(TextPanelEvent.TEXT_CHANGED);
            if (fTextPanel.getSelectionStart() != fTextPanel.getSelectionEnd()) {
                fListener.expectEvent(TextPanelEvent.SELECTION_EMPTY_CHANGED);
            }
            fTextPanel.insert(insText, i);
            fListener.assertNotExpectingEvents();
        }

        fListener.allowEvent(TextPanelEvent.SELECTION_EMPTY_CHANGED);
       
        for (int i=0; i < BIG_COMMAND_LOG_SIZE-1; i++) {
            fListener.expectEvent(TextPanelEvent.UNDO_STATE_CHANGED);
            fListener.expectEvent(TextPanelEvent.TEXT_CHANGED);
            fTextPanel.undo();
            fListener.assertNotExpectingEvents();
        }
        if (!fTextPanel.canUndo()) {
            reportError("Command log is too small");
        }
       
        fListener.allowAll();
        fTextPanel.undo();
        if (fTextPanel.canUndo()) {
            reportError("Command log is too large");
        }

        if (fTextPanel.getTextLength() != origLength * insText.length()) {
            reportError("Text length was not restored");
        }

        for (int i=0; i < BIG_COMMAND_LOG_SIZE; i++) {
            fTextPanel.redo();
View Full Code Here

Examples of com.ibm.richtext.styledtext.MConstText

    public static void main(String[] args) {

        // not used OutputStream outStream = null;
        PrintWriter writer = new PrintWriter(System.out);

        MConstText text = Declaration.fgDeclaration;
        char[] insText = "The quick brown fox jumps over the lazy dog. The end. ".toCharArray();
       
        int index = 0;
        while (index < args.length) {
            if (args[index].equals("-insertionText")) {
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.