예제 #1
0
        public virtual void OpenFile(File file)
        {
            string encoding = (classifier == null) ? "utf-8" : classifier.flags.inputEncoding;
            string text     = IOUtils.SlurpFileNoExceptions(file.GetPath(), encoding);

            System.Console.Out.WriteLine(text);
            editorPane.SetContentType("text/plain");
            editorPane.SetText(text);
            System.Console.Out.WriteLine(editorPane.GetText());
            loadedFile = file;
            Redraw();
            saveUntagged.SetEnabled(true);
        }
예제 #2
0
        private void OpenURL(string url)
        {
            try
            {
                editorPane.SetPage(url);
            }
            catch (Exception e)
            {
                log.Info("Error loading |" + url + '|');
                log.Warn(e);
                DisplayError("Error Loading URL " + url, "Message: " + e);
                return;
            }
            loadedFile = null;
            string text = editorPane.GetText();

            taggedContents = null;
            if (!editorPane.GetContentType().Equals("text/html"))
            {
                editorPane.SetContentType("text/rtf");
                IDocument doc = editorPane.GetDocument();
                try
                {
                    doc.InsertString(0, text, defaultAttrSet);
                }
                catch (Exception e)
                {
                    throw new Exception(e);
                }
                editorPane.Revalidate();
                editorPane.Repaint();
                editorPane.SetEditable(true);
                htmlContents = null;
            }
            else
            {
                editorPane.SetEditable(false);
                htmlContents = editorPane.GetText();
            }
            saveUntagged.SetEnabled(false);
            saveTaggedAs.SetEnabled(false);
        }
예제 #3
0
        //  private String initText = "In";
        private void BuildContentPanel()
        {
            editorPane = new JEditorPane();
            editorPane.SetContentType("text/rtf");
            editorPane.AddKeyListener(new NERGUI.InputListener(this));
            //    defaultAttrSet = ((StyledEditorKit)editorPane.getEditorKit()).getInputAttributes();
            StyleConstants.SetFontFamily(defaultAttrSet, "Lucinda Sans");
            IDocument doc = new DefaultStyledDocument();

            editorPane.SetDocument(doc);
            try
            {
                doc.InsertString(0, initText, defaultAttrSet);
            }
            catch (Exception ex)
            {
                throw new Exception(ex);
            }
            JScrollPane scrollPane = new JScrollPane(editorPane);

            frame.GetContentPane().Add(scrollPane, BorderLayout.Center);
            editorPane.SetEditable(true);
        }