[jsword-svn]
bibledesktop/java/main/org/crosswire/bibledesktop/desktop s
jswordcvs at crosswire.org
jswordcvs at crosswire.org
Sat Mar 12 14:16:01 MST 2005
Update of /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/desktop
In directory www.crosswire.org:/tmp/cvs-serv1387/java/main/org/crosswire/bibledesktop/desktop
Modified Files:
ViewSourcePane.java DesktopActions.java
Log Message:
Jira BD-28. Tidy and syntax highlighting of View Source.
Index: DesktopActions.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/desktop/DesktopActions.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** DesktopActions.java 6 Mar 2005 20:21:36 -0000 1.20
--- DesktopActions.java 12 Mar 2005 21:15:59 -0000 1.21
***************
*** 19,32 ****
import org.crosswire.common.swing.desktop.ViewVisitor;
import org.crosswire.common.util.Reporter;
- import org.crosswire.common.xml.Converter;
- import org.crosswire.common.xml.SAXEventProvider;
- import org.crosswire.common.xml.SerializingContentHandler;
- import org.crosswire.common.xml.TransformingSAXEventProvider;
- import org.crosswire.common.xml.XMLUtil;
import org.crosswire.jsword.book.Book;
- import org.crosswire.jsword.book.BookData;
- import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.passage.Key;
- import org.crosswire.jsword.util.ConverterFactory;
import org.crosswire.jsword.util.Project;
--- 19,24 ----
***************
*** 58,62 ****
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
! * @author DM Smith [dmsmith555 at yahoo dot com]
* @version $Id$
*/
--- 50,54 ----
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
! * @author DM Smith [dmsmith555 at gmail dot com]
* @version $Id$
*/
***************
*** 70,74 ****
{
this.desktop = desktop;
- converter = ConverterFactory.getConverter();
actions = new ActionFactory(Desktop.class, this);
}
--- 62,65 ----
***************
*** 297,316 ****
Book book = da.getBook();
! String orig = book.getRawData(key);
!
! BookData bdata = book.getData(key);
!
! BookMetaData bmd = book.getBookMetaData();
! boolean direction = bmd.isLeftToRight();
!
! SAXEventProvider osissep = bdata.getSAXEventProvider();
! TransformingSAXEventProvider htmlsep = (TransformingSAXEventProvider) converter.convert(osissep);
! htmlsep.setParameter("direction", direction ? "ltr" : "rtl"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
! String html = XMLUtil.writeToString(htmlsep);
!
! SerializingContentHandler osis = new SerializingContentHandler(true);
! osissep.provideSAXEvents(osis);
! ViewSourcePane viewer = new ViewSourcePane(orig, osis.toString(), html);
viewer.showInFrame(getDesktop());
}
--- 288,310 ----
Book book = da.getBook();
! // String orig = book.getRawData(key);
! //
! // BookData bdata = book.getData(key);
! //
! // BookMetaData bmd = book.getBookMetaData();
! // boolean direction = bmd.isLeftToRight();
! //
! // SAXEventProvider osissep = bdata.getSAXEventProvider();
! //
! // ContentHandler osis = new HTMLSerializingContentHandler(FormatType.CLASSIC_INDENT);
! // osissep.provideSAXEvents(osis);
! //
! // TransformingSAXEventProvider htmlsep = (TransformingSAXEventProvider) converter.convert(osissep);
! // htmlsep.setParameter("direction", direction ? "ltr" : "rtl"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
! //
! // ContentHandler html = new HTMLSerializingContentHandler(FormatType.CLASSIC_INDENT);
! // htmlsep.provideSAXEvents(html);
! ViewSourcePane viewer = new ViewSourcePane(book, key);
viewer.showInFrame(getDesktop());
}
***************
*** 434,442 ****
/**
- * To convert OSIS to HTML
- */
- private Converter converter;
-
- /**
* The About window
*/
--- 428,431 ----
Index: ViewSourcePane.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/desktop/ViewSourcePane.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** ViewSourcePane.java 24 Jan 2005 23:25:18 -0000 1.9
--- ViewSourcePane.java 12 Mar 2005 21:15:59 -0000 1.10
***************
*** 15,23 ****
--- 15,39 ----
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
+ import javax.swing.JTextPane;
import javax.swing.WindowConstants;
+ import javax.swing.text.JTextComponent;
+ import javax.swing.text.html.HTMLEditorKit;
import org.crosswire.bibledesktop.util.ConfigurableSwingConverter;
import org.crosswire.common.swing.ActionFactory;
+ import org.crosswire.common.swing.AntiAliasedTextPane;
import org.crosswire.common.swing.GuiUtil;
+ import org.crosswire.common.util.Reporter;
+ import org.crosswire.common.xml.Converter;
+ import org.crosswire.common.xml.FormatType;
+ import org.crosswire.common.xml.HTMLSerializingContentHandler;
+ import org.crosswire.common.xml.SAXEventProvider;
+ import org.crosswire.common.xml.TransformingSAXEventProvider;
+ import org.crosswire.jsword.book.Book;
+ import org.crosswire.jsword.book.BookData;
+ import org.crosswire.jsword.book.BookMetaData;
+ import org.crosswire.jsword.passage.Key;
+ import org.crosswire.jsword.util.ConverterFactory;
+ import org.xml.sax.ContentHandler;
/**
***************
*** 44,51 ****
--- 60,104 ----
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
+ * @author DM Smith [dmsmith555 at gmail dot com]
* @version $Id$
*/
public class ViewSourcePane extends JPanel
{
+ public ViewSourcePane(Book book, Key key)
+ {
+ try
+ {
+ String orig = book.getRawData(key);
+
+ BookData bdata = book.getData(key);
+
+ BookMetaData bmd = book.getBookMetaData();
+ boolean direction = bmd.isLeftToRight();
+
+ SAXEventProvider osissep = bdata.getSAXEventProvider();
+
+ ContentHandler osis = new HTMLSerializingContentHandler(FormatType.CLASSIC_INDENT);
+ osissep.provideSAXEvents(osis);
+
+ TransformingSAXEventProvider htmlsep = (TransformingSAXEventProvider) converter.convert(osissep);
+ htmlsep.setParameter(XSLTProperty.STRONGS_NUMBERS.getName(), Boolean.toString(XSLTProperty.STRONGS_NUMBERS.getState()));
+ htmlsep.setParameter(XSLTProperty.START_VERSE_ON_NEWLINE.getName(), Boolean.toString(XSLTProperty.START_VERSE_ON_NEWLINE.getState()));
+ htmlsep.setParameter(XSLTProperty.VERSE_NUMBERS.getName(), Boolean.toString(XSLTProperty.VERSE_NUMBERS.getState()));
+ htmlsep.setParameter(XSLTProperty.TINY_VERSE_NUMBERS.getName(), Boolean.toString(XSLTProperty.TINY_VERSE_NUMBERS.getState()));
+ htmlsep.setParameter(XSLTProperty.NOTES.getName(), Boolean.toString(XSLTProperty.NOTES.getState()));
+ htmlsep.setParameter(XSLTProperty.XREF.getName(), Boolean.toString(XSLTProperty.XREF.getState()));
+ htmlsep.setParameter("direction", direction ? "ltr" : "rtl"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ ContentHandler html = new HTMLSerializingContentHandler(FormatType.CLASSIC_INDENT);
+ htmlsep.provideSAXEvents(html);
+
+ init(orig, osis.toString(), html.toString());
+ }
+ catch (Exception ex)
+ {
+ Reporter.informUser(null, ex);
+ }
+ }
+
/**
* Construct a ViewSourcePane with some string contents
***************
*** 70,95 ****
JTextArea txtOrig = new JTextArea(orig, 24, 80);
txtOrig.setFont(userRequestedFont);
- txtOrig.setEditable(false);
txtOrig.setLineWrap(true);
txtOrig.setWrapStyleWord(true);
JPanel pnlOrig = new JPanel(new BorderLayout());
pnlOrig.add(new JScrollPane(txtOrig), BorderLayout.CENTER);
pnlOrig.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
! JTextArea txtOsis = new JTextArea(osis, 24, 80);
txtOsis.setFont(userRequestedFont);
txtOsis.setEditable(false);
JPanel pnlOsis = new JPanel(new BorderLayout());
pnlOsis.add(new JScrollPane(txtOsis), BorderLayout.CENTER);
pnlOsis.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
! JTextArea txtHtml = new JTextArea(html, 24, 80);
txtHtml.setFont(userRequestedFont);
txtHtml.setEditable(false);
JPanel pnlHtml = new JPanel(new BorderLayout());
pnlHtml.add(new JScrollPane(txtHtml), BorderLayout.CENTER);
pnlHtml.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
! textAreas = new JTextArea[] { txtOrig, txtOsis, txtHtml };
pnlButtons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
--- 123,155 ----
JTextArea txtOrig = new JTextArea(orig, 24, 80);
txtOrig.setFont(userRequestedFont);
txtOrig.setLineWrap(true);
txtOrig.setWrapStyleWord(true);
+ txtOrig.setTabSize(2);
+ txtOrig.setEditable(false);
JPanel pnlOrig = new JPanel(new BorderLayout());
pnlOrig.add(new JScrollPane(txtOrig), BorderLayout.CENTER);
pnlOrig.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
! JTextPane txtOsis = new AntiAliasedTextPane();
txtOsis.setFont(userRequestedFont);
txtOsis.setEditable(false);
+ txtOsis.setEditorKit(new HTMLEditorKit());
+ txtOsis.setText(osis);
+ txtOsis.setCaretPosition(0);
JPanel pnlOsis = new JPanel(new BorderLayout());
pnlOsis.add(new JScrollPane(txtOsis), BorderLayout.CENTER);
pnlOsis.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
! JTextPane txtHtml = new AntiAliasedTextPane();
txtHtml.setFont(userRequestedFont);
txtHtml.setEditable(false);
+ txtHtml.setEditorKit(new HTMLEditorKit());
+ txtHtml.setText(html);
+ txtHtml.setCaretPosition(0);
JPanel pnlHtml = new JPanel(new BorderLayout());
pnlHtml.add(new JScrollPane(txtHtml), BorderLayout.CENTER);
pnlHtml.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
! textAreas = new JTextComponent[] { txtOrig, txtOsis, txtHtml };
pnlButtons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
***************
*** 132,137 ****
{
int i = tabMain.getSelectedIndex();
! JTextArea ta = textAreas[i];
! StringSelection ss = new StringSelection(ta.getText());
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
}
--- 192,197 ----
{
int i = tabMain.getSelectedIndex();
! JTextComponent tc = textAreas[i];
! StringSelection ss = new StringSelection(tc.getText());
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
}
***************
*** 150,158 ****
*/
private JTabbedPane tabMain;
! private JTextArea [] textAreas;
private JPanel pnlButtons;
private JDialog frame;
private ActionFactory actions;
/**
* Serialization ID
--- 210,220 ----
*/
private JTabbedPane tabMain;
! private JTextComponent [] textAreas;
private JPanel pnlButtons;
private JDialog frame;
private ActionFactory actions;
+ private static Converter converter = ConverterFactory.getConverter();
+
/**
* Serialization ID
More information about the jsword-svn
mailing list