Thread: [Jsxe-cvs] SF.net SVN: jsxe: [935] trunk/sourceview
Status: Inactive
Brought to you by:
ian_lewis
From: <ian...@us...> - 2006-06-09 01:11:12
|
Revision: 935 Author: ian_lewis Date: 2006-06-08 18:11:05 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=935&view=rev Log Message: ----------- updated version and dependency info Modified Paths: -------------- trunk/sourceview/build.xml trunk/sourceview/dependency.props Modified: trunk/sourceview/build.xml =================================================================== --- trunk/sourceview/build.xml 2006-06-09 01:10:53 UTC (rev 934) +++ trunk/sourceview/build.xml 2006-06-09 01:11:05 UTC (rev 935) @@ -34,8 +34,8 @@ <property name="javadoc.link" value="http://java.sun.com/j2se/1.3/docs/api/"/> <property name="main.class" value="sourceview.SourceViewPlugin"/> <property name="major.version" value="0"/> - <property name="minor.version" value="4"/> - <property name="build.version" value="3"/> + <property name="minor.version" value="5"/> + <property name="build.version" value="1"/> <property name="app.version" value="${major.version}.${minor.version}.${build.version}"/> <property name="app_version" value="${major.version}_${minor.version}_${build.version}"/> <property name="implementation.version" value="${major.version}.${minor.version}.${build.version}"/> Modified: trunk/sourceview/dependency.props =================================================================== --- trunk/sourceview/dependency.props 2006-06-09 01:10:53 UTC (rev 934) +++ trunk/sourceview/dependency.props 2006-06-09 01:11:05 UTC (rev 935) @@ -1 +1 @@ -dependency.0=jsxe 00.04.03.00 +dependency.0=jsxe 00.05.01.00 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-06-20 19:31:08
|
Revision: 968 Author: ian_lewis Date: 2006-06-20 12:30:55 -0700 (Tue, 20 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=968&view=rev Log Message: ----------- updated the sourceview's actions to extend the new LocalizedAction class Modified Paths: -------------- trunk/sourceview/Changelog trunk/sourceview/src/sourceview/SourceView.java trunk/sourceview/src/sourceview/SourceViewPlugin.java trunk/sourceview/src/sourceview/action/EditCopyAction.java trunk/sourceview/src/sourceview/action/EditCutAction.java trunk/sourceview/src/sourceview/action/EditFindAction.java trunk/sourceview/src/sourceview/action/EditPasteAction.java Modified: trunk/sourceview/Changelog =================================================================== --- trunk/sourceview/Changelog 2006-06-20 19:30:24 UTC (rev 967) +++ trunk/sourceview/Changelog 2006-06-20 19:30:55 UTC (rev 968) @@ -1,3 +1,7 @@ +06/20/2006 Ian Lewis <Ian...@me...> + + * Updated the sourceview's actions to extend the new LocalizedAction class. + 06/13/2006 Ian Lewis <Ian...@me...> * Updated the source view options panel to extend AbstractOptionPane Modified: trunk/sourceview/src/sourceview/SourceView.java =================================================================== --- trunk/sourceview/src/sourceview/SourceView.java 2006-06-20 19:30:24 UTC (rev 967) +++ trunk/sourceview/src/sourceview/SourceView.java 2006-06-20 19:30:55 UTC (rev 968) @@ -138,14 +138,14 @@ //{{{ create popup menu JPopupMenu popup = new JPopupMenu(); - JMenuItem menuItem = new JMenuItem(jsXe.getAction("sourceview.cut")); + JMenuItem menuItem = new JMenuItem(ActionManager.getAction("sourceview.cut")); popup.add(menuItem); - menuItem = new JMenuItem(jsXe.getAction("sourceview.copy")); + menuItem = new JMenuItem(ActionManager.getAction("sourceview.copy")); popup.add(menuItem); - menuItem = new JMenuItem(jsXe.getAction("sourceview.paste")); + menuItem = new JMenuItem(ActionManager.getAction("sourceview.paste")); popup.add(menuItem); popup.addSeparator(); - menuItem = new JMenuItem(jsXe.getAction("sourceview.find")); + menuItem = new JMenuItem(ActionManager.getAction("sourceview.find")); popup.add(menuItem); m_textarea.setRightClickPopup(popup); @@ -165,14 +165,14 @@ // menuItem.addActionListener( new EditRedoAction() ); // menu.add(menuItem); // menu.addSeparator(); - menuItem = new JMenuItem(jsXe.getAction("sourceview.cut")); + menuItem = new JMenuItem(ActionManager.getAction("sourceview.cut")); m_editMenu.add(menuItem); - menuItem = new JMenuItem(jsXe.getAction("sourceview.copy")); + menuItem = new JMenuItem(ActionManager.getAction("sourceview.copy")); m_editMenu.add(menuItem); - menuItem = new JMenuItem(jsXe.getAction("sourceview.paste")); + menuItem = new JMenuItem(ActionManager.getAction("sourceview.paste")); m_editMenu.add(menuItem); m_editMenu.addSeparator(); - menuItem = new JMenuItem(jsXe.getAction("sourceview.find")); + menuItem = new JMenuItem(ActionManager.getAction("sourceview.find")); m_editMenu.add(menuItem); // menuItem = new JMenuItem(new EditFindNextAction()); // menu.add(menuItem); Modified: trunk/sourceview/src/sourceview/SourceViewPlugin.java =================================================================== --- trunk/sourceview/src/sourceview/SourceViewPlugin.java 2006-06-20 19:30:24 UTC (rev 967) +++ trunk/sourceview/src/sourceview/SourceViewPlugin.java 2006-06-20 19:30:55 UTC (rev 968) @@ -58,10 +58,10 @@ //{{{ SourceViewPlugin public SourceViewPlugin() { - addAction("sourceview.cut", new EditCutAction()); - addAction("sourceview.copy", new EditCopyAction()); - addAction("sourceview.paste", new EditPasteAction()); - addAction("sourceview.find", new EditFindAction()); + addAction(new EditCutAction()); + addAction(new EditCopyAction()); + addAction(new EditPasteAction()); + addAction(new EditFindAction()); }//}}} //{{{ newDocumentView() Modified: trunk/sourceview/src/sourceview/action/EditCopyAction.java =================================================================== --- trunk/sourceview/src/sourceview/action/EditCopyAction.java 2006-06-20 19:30:24 UTC (rev 967) +++ trunk/sourceview/src/sourceview/action/EditCopyAction.java 2006-06-20 19:30:55 UTC (rev 968) @@ -30,6 +30,8 @@ //{{{ jsXe classes import net.sourceforge.jsxe.jsXe; +import net.sourceforge.jsxe.LocalizedAction; +import net.sourceforge.jsxe.gui.TabbedView; import net.sourceforge.jsxe.gui.Messages; import net.sourceforge.jsxe.gui.DocumentView; import net.sourceforge.jsxe.util.Log; @@ -39,37 +41,33 @@ import java.awt.event.ActionEvent; //}}} -//{{{ Swing classes -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.KeyStroke; //}}} -//}}} - /** * This action that "copies" selected text from the text area to the system * clipboard. * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ */ -public class EditCopyAction extends AbstractAction { +public class EditCopyAction extends LocalizedAction { //{{{ EditCopyAction constructor - public EditCopyAction() { //putValue(Action.NAME, "Copy"); - putValue(Action.NAME, Messages.getMessage("common.copy")); - putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl C")); - putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("O").getKeyCode())); + super("sourceview.copy"); + // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl C")); }//}}} - //{{{ actionPerformed() + //{{{ getLabel() + public String getLabel() { + return Messages.getMessage("common.copy"); + }//}}} - public void actionPerformed(ActionEvent e) { - DocumentView view = jsXe.getActiveView().getDocumentView(); - if (view instanceof SourceView) { - SourceView sourceView = (SourceView)view; + //{{{ import() + public void invoke(TabbedView view, ActionEvent evt) { + DocumentView docView = view.getDocumentView(); + if (docView instanceof SourceView) { + SourceView sourceView = (SourceView)docView; sourceView.getTextArea().copy(); } }//}}} Modified: trunk/sourceview/src/sourceview/action/EditCutAction.java =================================================================== --- trunk/sourceview/src/sourceview/action/EditCutAction.java 2006-06-20 19:30:24 UTC (rev 967) +++ trunk/sourceview/src/sourceview/action/EditCutAction.java 2006-06-20 19:30:55 UTC (rev 968) @@ -30,6 +30,8 @@ //{{{ jsXe classes import net.sourceforge.jsxe.jsXe; +import net.sourceforge.jsxe.LocalizedAction; +import net.sourceforge.jsxe.gui.TabbedView; import net.sourceforge.jsxe.gui.Messages; import net.sourceforge.jsxe.gui.DocumentView; import net.sourceforge.jsxe.util.Log; @@ -39,37 +41,32 @@ import java.awt.event.ActionEvent; //}}} -//{{{ Swing classes -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.KeyStroke; //}}} -//}}} - /** * This action that "cuts" selected text from the text area to the system * clipboard. * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ */ -public class EditCutAction extends AbstractAction { +public class EditCutAction extends LocalizedAction { //{{{ EditCutAction constructor - public EditCutAction() { - //putValue(Action.NAME, "Cut"); - putValue(Action.NAME, Messages.getMessage("common.cut")); - putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl X")); - putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("C").getKeyCode())); + super("sourceview.cut"); + // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl X")); }//}}} - - //{{{ actionPerformed() - public void actionPerformed(ActionEvent e) { - DocumentView view = jsXe.getActiveView().getDocumentView(); - if (view instanceof SourceView) { - SourceView sourceView = (SourceView)view; + //{{{ getLabel() + public String getLabel() { + return Messages.getMessage("common.cut"); + }//}}} + + //{{{ invoke() + public void invoke(TabbedView view, ActionEvent evt) { + DocumentView docView = view.getDocumentView(); + if (docView instanceof SourceView) { + SourceView sourceView = (SourceView)docView; sourceView.getTextArea().cut(); } }//}}} Modified: trunk/sourceview/src/sourceview/action/EditFindAction.java =================================================================== --- trunk/sourceview/src/sourceview/action/EditFindAction.java 2006-06-20 19:30:24 UTC (rev 967) +++ trunk/sourceview/src/sourceview/action/EditFindAction.java 2006-06-20 19:30:55 UTC (rev 968) @@ -29,48 +29,43 @@ import sourceview.*; //{{{ jsXe classes - import net.sourceforge.jsxe.jsXe; +import net.sourceforge.jsxe.LocalizedAction; +import net.sourceforge.jsxe.gui.TabbedView; import net.sourceforge.jsxe.gui.Messages; import net.sourceforge.jsxe.gui.DocumentView; - //}}} //{{{ AWT classes import java.awt.event.ActionEvent; //}}} -//{{{ Swing classes -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.KeyStroke; //}}} -//}}} - /** * This action that opens the find dialog. * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ */ -public class EditFindAction extends AbstractAction { +public class EditFindAction extends LocalizedAction { //{{{ EditFindAction constructor - public EditFindAction() { - //putValue(Action.NAME, "Find..."); - putValue(Action.NAME, Messages.getMessage("common.find")); - putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl F")); - putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("F").getKeyCode())); + super("sourceview.find"); + // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl F")); }//}}} - //{{{ actionPerformed() + //{{{ getLabel() + public String getLabel() { + return Messages.getMessage("common.find"); + }//}}} - public void actionPerformed(ActionEvent e) { - DocumentView view = jsXe.getActiveView().getDocumentView(); - if (view instanceof SourceView) { - SourceView sourceView = (SourceView)view; + //{{{ invoke() + public void invoke(TabbedView view, ActionEvent evt) { + DocumentView docView = view.getDocumentView(); + if (docView instanceof SourceView) { + SourceView sourceView = (SourceView)docView; SourceViewSearchDialog.showSearchDialog(sourceView); } Modified: trunk/sourceview/src/sourceview/action/EditPasteAction.java =================================================================== --- trunk/sourceview/src/sourceview/action/EditPasteAction.java 2006-06-20 19:30:24 UTC (rev 967) +++ trunk/sourceview/src/sourceview/action/EditPasteAction.java 2006-06-20 19:30:55 UTC (rev 968) @@ -30,6 +30,8 @@ //{{{ jsXe classes import net.sourceforge.jsxe.jsXe; +import net.sourceforge.jsxe.LocalizedAction; +import net.sourceforge.jsxe.gui.TabbedView; import net.sourceforge.jsxe.gui.Messages; import net.sourceforge.jsxe.gui.DocumentView; import net.sourceforge.jsxe.util.Log; @@ -39,36 +41,32 @@ import java.awt.event.ActionEvent; //}}} -//{{{ Swing classes -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.KeyStroke; //}}} -//}}} - /** * This action that "pastes" selected text from the text area to the system * clipboard. * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ */ -public class EditPasteAction extends AbstractAction { +public class EditPasteAction extends LocalizedAction { //{{{ EditPasteAction constructor - public EditPasteAction() { - putValue(Action.NAME, Messages.getMessage("common.paste")); - putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl V")); - putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("P").getKeyCode())); + super("sourceview.paste"); + // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl V")); }//}}} - //{{{ actionPerformed() + //{{{ getLabel() + public String getLabel() { + return Messages.getMessage("common.paste"); + }//}}} - public void actionPerformed(ActionEvent e) { - DocumentView view = jsXe.getActiveView().getDocumentView(); - if (view instanceof SourceView) { - SourceView sourceView = (SourceView)view; + //{{{ invoke() + public void invoke(TabbedView view, ActionEvent evt) { + DocumentView docView = view.getDocumentView(); + if (docView instanceof SourceView) { + SourceView sourceView = (SourceView)docView; sourceView.getTextArea().paste(); } }//}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-06-23 19:44:48
|
Revision: 978 Author: ian_lewis Date: 2006-06-23 12:44:35 -0700 (Fri, 23 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=978&view=rev Log Message: ----------- Added back key bindings Modified Paths: -------------- trunk/sourceview/Changelog trunk/sourceview/src/org/syntax/jedit/JEditTextArea.java trunk/sourceview/src/sourceview/action/EditCopyAction.java trunk/sourceview/src/sourceview/action/EditCutAction.java trunk/sourceview/src/sourceview/action/EditFindAction.java trunk/sourceview/src/sourceview/sourceview.props Modified: trunk/sourceview/Changelog =================================================================== --- trunk/sourceview/Changelog 2006-06-23 19:39:58 UTC (rev 977) +++ trunk/sourceview/Changelog 2006-06-23 19:44:35 UTC (rev 978) @@ -1,3 +1,9 @@ +06/23/2006 Ian Lewis <Ian...@me...> + + * Added back rudimentary key bindings using Swing Actions so they get + dispached by Swing and are displayed in menus. But infrastructure is + in place to allow jsXe to catch key bindings itself. + 06/20/2006 Ian Lewis <Ian...@me...> * Updated the sourceview's actions to extend the new LocalizedAction class. Modified: trunk/sourceview/src/org/syntax/jedit/JEditTextArea.java =================================================================== --- trunk/sourceview/src/org/syntax/jedit/JEditTextArea.java 2006-06-23 19:39:58 UTC (rev 977) +++ trunk/sourceview/src/org/syntax/jedit/JEditTextArea.java 2006-06-23 19:44:35 UTC (rev 978) @@ -6,7 +6,6 @@ Copyright (C) 1999 Slava Pestov Copyright (C) 2002 Ian Lewis (Ian...@me...) - You may use and modify this package for any purpose. Redistribution is permitted, in both source and binary form, provided that this notice remains intact in all source distributions of this package. Modified: trunk/sourceview/src/sourceview/action/EditCopyAction.java =================================================================== --- trunk/sourceview/src/sourceview/action/EditCopyAction.java 2006-06-23 19:39:58 UTC (rev 977) +++ trunk/sourceview/src/sourceview/action/EditCopyAction.java 2006-06-23 19:44:35 UTC (rev 978) @@ -53,9 +53,7 @@ //{{{ EditCopyAction constructor public EditCopyAction() { - //putValue(Action.NAME, "Copy"); super("sourceview.copy"); - // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl C")); }//}}} //{{{ getLabel() Modified: trunk/sourceview/src/sourceview/action/EditCutAction.java =================================================================== --- trunk/sourceview/src/sourceview/action/EditCutAction.java 2006-06-23 19:39:58 UTC (rev 977) +++ trunk/sourceview/src/sourceview/action/EditCutAction.java 2006-06-23 19:44:35 UTC (rev 978) @@ -54,7 +54,6 @@ //{{{ EditCutAction constructor public EditCutAction() { super("sourceview.cut"); - // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl X")); }//}}} //{{{ getLabel() Modified: trunk/sourceview/src/sourceview/action/EditFindAction.java =================================================================== --- trunk/sourceview/src/sourceview/action/EditFindAction.java 2006-06-23 19:39:58 UTC (rev 977) +++ trunk/sourceview/src/sourceview/action/EditFindAction.java 2006-06-23 19:44:35 UTC (rev 978) @@ -53,7 +53,6 @@ //{{{ EditFindAction constructor public EditFindAction() { super("sourceview.find"); - // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl F")); }//}}} //{{{ getLabel() Modified: trunk/sourceview/src/sourceview/sourceview.props =================================================================== --- trunk/sourceview/src/sourceview/sourceview.props 2006-06-23 19:39:58 UTC (rev 977) +++ trunk/sourceview/src/sourceview/sourceview.props 2006-06-23 19:44:35 UTC (rev 978) @@ -23,3 +23,10 @@ #end of line markers source.end-of-line-markers=true + +#{{{ Default key bindings +sourceview.copy.shortcut=ctrl C +sourceview.cut.shortcut=ctrl X +sourceview.paste.shortcut=ctrl V +sourceview.find.shortcut=ctrl F +#}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-06-15 21:52:33
|
Revision: 965 Author: ian_lewis Date: 2006-06-15 14:52:24 -0700 (Thu, 15 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=965&view=rev Log Message: ----------- Updated the source view options panel to extend AbstractOptionPane Modified Paths: -------------- trunk/sourceview/Changelog trunk/sourceview/messages/messages.en trunk/sourceview/src/sourceview/SourceView.java trunk/sourceview/src/sourceview/SourceViewDocument.java trunk/sourceview/src/sourceview/SourceViewPlugin.java Added Paths: ----------- trunk/sourceview/src/sourceview/SourceViewOptionPane.java Removed Paths: ------------- trunk/sourceview/src/sourceview/SourceViewOptionsPanel.java Modified: trunk/sourceview/Changelog =================================================================== --- trunk/sourceview/Changelog 2006-06-15 21:49:54 UTC (rev 964) +++ trunk/sourceview/Changelog 2006-06-15 21:52:24 UTC (rev 965) @@ -1,3 +1,7 @@ +06/13/2006 Ian Lewis <Ian...@me...> + + * Updated the source view options panel to extend AbstractOptionPane + 06/09/2006 Ian Lewis <Ian...@me...> * Updated version and dependency info Modified: trunk/sourceview/messages/messages.en =================================================================== --- trunk/sourceview/messages/messages.en 2006-06-15 21:49:54 UTC (rev 964) +++ trunk/sourceview/messages/messages.en 2006-06-15 21:52:24 UTC (rev 965) @@ -7,7 +7,7 @@ #{{{ Source View #{{{ Source View Options -SourceView.Options.Title=Source View Options +SourceView.Options.Title=Source View SourceView.Options.EndOfLineMarker=End of line markers SourceView.Syntax.Object=Node Type SourceView.Syntax.Style=Text Style Modified: trunk/sourceview/src/sourceview/SourceView.java =================================================================== --- trunk/sourceview/src/sourceview/SourceView.java 2006-06-15 21:49:54 UTC (rev 964) +++ trunk/sourceview/src/sourceview/SourceView.java 2006-06-15 21:52:24 UTC (rev 965) @@ -34,11 +34,11 @@ //{{{ jsXe classes import net.sourceforge.jsxe.*; import net.sourceforge.jsxe.gui.Messages; -import net.sourceforge.jsxe.gui.OptionsPanel; import net.sourceforge.jsxe.gui.DocumentView; import net.sourceforge.jsxe.dom.AdapterNode; import net.sourceforge.jsxe.dom.XMLDocument; import net.sourceforge.jsxe.dom.XMLDocumentListener; +import net.sourceforge.jsxe.msg.PropertyChanged; import net.sourceforge.jsxe.util.Log; import net.sourceforge.jsxe.util.MiscUtilities; //}}} @@ -81,11 +81,8 @@ * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ */ -public class SourceView extends JPanel implements DocumentView { +public class SourceView extends JPanel implements DocumentView, EBListener { - // Temporary Hack - protected static ArrayList m_sourceviews = new ArrayList(); - //{{{ Private static members private static final String _VIEWNAME = "source"; //}}} @@ -117,19 +114,19 @@ TextAreaPainter painter = m_textarea.getPainter(); painter.setEOLMarkersPainted(jsXe.getBooleanProperty(SourceView.END_OF_LINE_MARKS, true)); painter.setStyles( - new SyntaxStyle[] { SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.text.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.comment.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.doctype.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.attribute.value.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.attribute.value.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.cdata.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.entity.reference.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.element.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.attribute.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.processing.instruction.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.namespace.prefix.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.markup.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.invalid.color")), + new SyntaxStyle[] { SourceViewOptionPane.parseStyle(jsXe.getProperty("source.text.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.comment.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.doctype.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.attribute.value.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.attribute.value.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.cdata.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.entity.reference.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.element.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.attribute.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.processing.instruction.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.namespace.prefix.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.markup.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.invalid.color")), }); // textarea.setFont(new Font("Monospaced", 0, 12)); m_textarea.setCaretPosition(0); @@ -181,8 +178,6 @@ // menu.add(menuItem); //}}} - m_sourceviews.add(this); - setDocumentBuffer(document); //focus on the text area the first time the view is shown @@ -201,8 +196,39 @@ });//}}} + EditBus.addToBus(this); }//}}} + //{{{ handleMessage() + public void handleMessage(EBMessage message) { + if (message instanceof PropertyChanged) { + String key = ((PropertyChanged)message).getKey(); + TextAreaPainter painter = getTextArea().getPainter(); + if (key.equals("source.end-of-line-markers")) { + painter.setEOLMarkersPainted(jsXe.getBooleanProperty("source.end-of-line-markers", false)); + } + + if (key.startsWith("source.") && key.endsWith(".color")) { + painter.setStyles( + new SyntaxStyle[] { + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.text.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.comment.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.doctype.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.attribute.value.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.attribute.value.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.cdata.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.entity.reference.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.element.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.attribute.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.processing.instruction.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.namespace.prefix.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.markup.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.invalid.color")), + }); + } + } + }//}}} + //{{{ getTextArea() public JEditTextArea getTextArea() { @@ -225,7 +251,6 @@ dialog.dispose(); } m_document.removeXMLDocumentListener(docListener); - m_sourceviews.remove(this); return true; }//}}} Modified: trunk/sourceview/src/sourceview/SourceViewDocument.java =================================================================== --- trunk/sourceview/src/sourceview/SourceViewDocument.java 2006-06-15 21:49:54 UTC (rev 964) +++ trunk/sourceview/src/sourceview/SourceViewDocument.java 2006-06-15 21:52:24 UTC (rev 965) @@ -138,29 +138,6 @@ //}}} - // private class SourceViewDocumentXMLDocumentListener implements XMLDocumentListener {//{{{ - // - // public void propertiesChanged(XMLDocument source, String propertyKey) { - // if (propertyKey.equals("encoding")) { - // try { - // String text = getText(0, getLength()); - // SourceViewDocument.super.remove(0, getLength()); - // SourceViewDocument.super.insertString(0, document.getSource(), new SimpleAttributeSet()); - // } catch (BadLocationException ble) { - // //This should never happen. If it does however jsXe will - // //act abnormally so... crash. - // jsXe.exiterror(view, ble.toString(), 1); - // } catch (IOException ioe) { - // //This might happen. If it does jsXe will - // //act abnormally so... crash. - // jsXe.exiterror(view, ioe.toString(), 1); - // } - // } - // } - // - // public void fileChanged(XMLDocument source) {} - // }//}}} - //{{{ Private members private XMLDocument m_document; //}}} Copied: trunk/sourceview/src/sourceview/SourceViewOptionPane.java (from rev 959, trunk/sourceview/src/sourceview/SourceViewOptionsPanel.java) =================================================================== --- trunk/sourceview/src/sourceview/SourceViewOptionPane.java (rev 0) +++ trunk/sourceview/src/sourceview/SourceViewOptionPane.java 2006-06-15 21:52:24 UTC (rev 965) @@ -0,0 +1,696 @@ +/* +SourceViewOptionPane.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2002, 2006 Ian Lewis (Ian...@me...) +Portions Copyright (C) 1999, 2000, 2001, 2002 Slava Pestov + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package sourceview; + +//{{{ Imports + +import org.syntax.jedit.*; + +//{{{ jsXe classes +import net.sourceforge.jsxe.*; +import net.sourceforge.jsxe.gui.*; +import net.sourceforge.jsxe.options.*; +import net.sourceforge.jsxe.msg.PropertyChanged; +import net.sourceforge.jsxe.util.MiscUtilities; +//}}} + +//{{{ Java Classes +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.table.*; +import javax.swing.border.EmptyBorder; +import java.util.Vector; +import java.util.StringTokenizer; +import java.util.Iterator; +//}}} + +//}}} + +public class SourceViewOptionPane extends AbstractOptionPane { + + //{{{ SourceViewOptionPane constructor + public SourceViewOptionPane(DocumentBuffer buffer) { + super("sourceview"); + }//}}} + + //{{{ _init() + protected void _init() { + setLayout(new BorderLayout(6,6)); + + // {{{ styles + + add(BorderLayout.CENTER,createStyleTableScroller()); + + //}}} + + //{{{ end of line markers + m_endOfLineMarkCheckBox = new JCheckBox(Messages.getMessage("SourceView.Options.EndOfLineMarker"),jsXe.getBooleanProperty("source.end-of-line-markers",true)); + m_endOfLineMarkCheckBox.setToolTipText(Messages.getMessage("SourceView.Options.EndOfLineMarker.Tooltip")); + add(BorderLayout.SOUTH, m_endOfLineMarkCheckBox); + + //}}} + + }//}}} + + //{{{ _save() + protected void _save() { + styleModel.save(); + jsXe.setBooleanProperty("source.end-of-line-markers",m_endOfLineMarkCheckBox.isSelected()); + }//}}} + + //{{{ getTitle() + + public String getTitle() { + return Messages.getMessage("SourceView.Options.Title"); + }//}}} + + //{{{ parseStyle() method + /** + * Converts a style string to a style object. + * @param str The style string + * @param family Style strings only specify font style, not font family + * @param size Style strings only specify font style, not font family + * @param color If false, the styles will be monochrome + * @exception IllegalArgumentException if the style is invalid + */ + public static SyntaxStyle parseStyle(String str) throws IllegalArgumentException { + Color fgColor = Color.black; + Color bgColor = null; + boolean italic = false; + boolean bold = false; + StringTokenizer st = new StringTokenizer(str); + while(st.hasMoreTokens()) { + String s = st.nextToken(); + if (s.startsWith("color:")) { + fgColor = parseColor(s.substring(6), Color.black); + } + else if (s.startsWith("style:")) { + for (int i = 6; i < s.length(); i++) { + if (s.charAt(i) == 'i') + italic = true; + else if(s.charAt(i) == 'b') + bold = true; + else + throw new IllegalArgumentException("Invalid style: " + s); + } + } + else + throw new IllegalArgumentException("Invalid directive: " + s); + } + return new SyntaxStyle(fgColor, italic, bold); + } //}}} + + //{{{ parseColor() method + public static Color parseColor(String name, Color defaultColor) { + if (name == null) + return defaultColor; + else if(name.startsWith("#")) { + try + { + return Color.decode(name); + } + catch(NumberFormatException nf) + { + return defaultColor; + } + } + else if("red".equals(name)) + return Color.red; + else if("green".equals(name)) + return Color.green; + else if("blue".equals(name)) + return Color.blue; + else if("yellow".equals(name)) + return Color.yellow; + else if("orange".equals(name)) + return Color.orange; + else if("white".equals(name)) + return Color.white; + else if("lightGray".equals(name)) + return Color.lightGray; + else if("gray".equals(name)) + return Color.gray; + else if("darkGray".equals(name)) + return Color.darkGray; + else if("black".equals(name)) + return Color.black; + else if("cyan".equals(name)) + return Color.cyan; + else if("magenta".equals(name)) + return Color.magenta; + else if("pink".equals(name)) + return Color.pink; + else + return defaultColor; + } //}}} + + //{{{ Private Members + + //{{{ getParentDialog() method + /** + * Traverses the given component's parent tree looking for an + * instance of JDialog, and return it. If not found, return null. + * @param c The component + */ + private static JDialog getParentDialog(Component c) { + Component p = c.getParent(); + while (p != null && !(p instanceof JDialog)) { + p = p.getParent(); + } + + return (p instanceof JDialog) ? (JDialog) p : null; + } //}}} + + //{{{ getStyleString() method + /** + * Converts a style into it's string representation. + * @param style The style + */ + private static String getStyleString(SyntaxStyle style) { + StringBuffer buf = new StringBuffer(); + + if (style.getColor() != null) { + buf.append("color:" + getColorHexString(style.getColor())); + } + + if (!style.isPlain()) { + buf.append(" style:" + (style.isItalic() ? "i" : "") + + (style.isBold() ? "b" : "")); + } + + return buf.toString(); + }//}}} + + //{{{ createStyleTableScroller() method + + private JScrollPane createStyleTableScroller() { + styleModel = createStyleTableModel(); + styleTable = new JTable(styleModel); + styleTable.setRowSelectionAllowed(false); + styleTable.setColumnSelectionAllowed(false); + styleTable.setCellSelectionEnabled(false); + styleTable.getTableHeader().setReorderingAllowed(false); + styleTable.addMouseListener(new MouseHandler()); + TableColumnModel tcm = styleTable.getColumnModel(); + TableColumn styleColumn = tcm.getColumn(1); + styleColumn.setCellRenderer(new StyleTableModel.StyleRenderer()); + Dimension d = styleTable.getPreferredSize(); + d.height = Math.min(d.height,100); + JScrollPane scroller = new JScrollPane(styleTable); + scroller.setPreferredSize(d); + return scroller; + } //}}} + + //{{{ createStyleTableModel() method + + private StyleTableModel createStyleTableModel() { + return new StyleTableModel(); + } //}}} + + //{{{ getColorHexString() method + /** + * Converts a color object to its hex value. The hex value + * prefixed is with `#', for example `#ff0088'. + * @param c The color object + */ + private static String getColorHexString(Color c) { + String colString = Integer.toHexString(c.getRGB() & 0xffffff); + return "#000000".substring(0,7 - colString.length()).concat(colString); + } //}}} + + //{{{ MouseHandler class + + private class MouseHandler extends MouseAdapter { + public void mouseClicked(MouseEvent evt) { + int row = styleTable.rowAtPoint(evt.getPoint()); + if(row == -1) + return; + + SyntaxStyle style = new StyleEditor( + SourceViewOptionPane.this, + (SyntaxStyle)styleModel.getValueAt( + row,1)).getStyle(); + if(style != null) + styleModel.setValueAt(style,row,1); + } + } //}}} + + //{{{ StyleEditor class + private static class StyleEditor extends EnhancedDialog implements ActionListener { + //{{{ StyleEditor constructor + public StyleEditor(Component comp, SyntaxStyle style) { + super(getParentDialog(comp), + Messages.getMessage("SourceView.StyleEditor.Title"),true); + + JPanel content = new JPanel(new BorderLayout(12,12)); + content.setBorder(new EmptyBorder(12,12,12,12)); + setContentPane(content); + + GridBagLayout layout = new GridBagLayout(); + JPanel panel = new JPanel(layout); + + GridBagConstraints cons = new GridBagConstraints(); + cons.gridx = cons.gridy = 0; + cons.gridwidth = 2; + cons.gridheight = 1; + cons.fill = GridBagConstraints.BOTH; + cons.weightx = 0.0f; + + italics = new JCheckBox(Messages.getMessage("SourceView.StyleEditor.Italics")); + italics.setSelected(style.isItalic()); + italics.setToolTipText(Messages.getMessage("SourceView.StyleEditor.Italics.ToolTip")); + layout.setConstraints(italics,cons); + panel.add(italics); + + cons.gridy++; + bold = new JCheckBox(Messages.getMessage("SourceView.StyleEditor.Bold")); + bold.setSelected(style.isBold()); + bold.setToolTipText(Messages.getMessage("SourceView.StyleEditor.Bold.ToolTip")); + layout.setConstraints(bold,cons); + panel.add(bold); + + cons.gridy++; + cons.gridwidth = 1; + Color fg = style.getColor(); + + fgColorCheckBox = new JCheckBox(Messages.getMessage("SourceView.StyleEditor.Color")); + fgColorCheckBox.setSelected(fg != null); + fgColorCheckBox.addActionListener(this); + fgColorCheckBox.setBorder(new EmptyBorder(0,0,0,12)); + fgColorCheckBox.setToolTipText(Messages.getMessage("SourceView.StyleEditor.Color.ToolTip")); + layout.setConstraints(fgColorCheckBox,cons); + panel.add(fgColorCheckBox); + + cons.gridx++; + fgColor = new ColorWellButton(fg); + fgColor.setEnabled(fg != null); + layout.setConstraints(fgColor,cons); + panel.add(fgColor); + + content.add(BorderLayout.CENTER,panel); + + Box box = new Box(BoxLayout.X_AXIS); + box.add(Box.createGlue()); + box.add(ok = new JButton(Messages.getMessage("common.ok"))); + getRootPane().setDefaultButton(ok); + ok.addActionListener(this); + box.add(Box.createHorizontalStrut(6)); + box.add(cancel = new JButton(Messages.getMessage("common.cancel"))); + cancel.addActionListener(this); + box.add(Box.createGlue()); + + content.add(BorderLayout.SOUTH,box); + + pack(); + setLocationRelativeTo(getParentDialog(comp)); + + setResizable(false); + show(); + } //}}} + + //{{{ actionPerformed() method + public void actionPerformed(ActionEvent evt) { + Object source = evt.getSource(); + if(source == ok) + ok(); + else if(source == cancel) + cancel(); + else if(source == fgColorCheckBox) + fgColor.setEnabled(fgColorCheckBox.isSelected()); + } //}}} + + //{{{ ok() method + public void ok() { + okClicked = true; + dispose(); + } //}}} + + //{{{ cancel() method + public void cancel() { + dispose(); + } //}}} + + //{{{ getStyle() method + public SyntaxStyle getStyle() { + if(!okClicked) + return null; + + Color foreground = (fgColorCheckBox.isSelected() + ? fgColor.getSelectedColor() + : null); + + return new SyntaxStyle(foreground, italics.isSelected(), bold.isSelected()); + } //}}} + + //{{{ Private members + private JCheckBox italics; + private JCheckBox bold; + private JCheckBox fgColorCheckBox; + private ColorWellButton fgColor; + private JButton ok; + private JButton cancel; + private boolean okClicked; + //}}} + } //}}} + + //{{{ StyleTableModel class + private static class StyleTableModel extends AbstractTableModel { + private Vector styleChoices; + + //{{{ StyleTableModel constructor + public StyleTableModel() { + styleChoices = new Vector(9); + addStyleChoice("SourceView.Markup", "source.markup.color"); + addStyleChoice("xml.namespace.prefix", "source.namespace.prefix.color"); + addStyleChoice("xml.text","source.text.color"); + addStyleChoice("xml.element","source.element.color"); + addStyleChoice("xml.attribute","source.attribute.color"); + addStyleChoice("xml.attribute.value", "source.attribute.value.color"); + addStyleChoice("xml.cdata","source.cdata.color"); + addStyleChoice("xml.processing.instruction","source.processing.instruction.color"); + addStyleChoice("xml.entity.reference","source.entity.reference.color"); + addStyleChoice("xml.comment","source.comment.color"); + addStyleChoice("xml.doctype","source.doctype.color"); + addStyleChoice("SourceView.Invalid", "source.invalid.color"); + MiscUtilities.quicksort(styleChoices, new MiscUtilities.StringCompare()); + } //}}} + + //{{{ getColumnCount() method + public int getColumnCount() + { + return 2; + } //}}} + + //{{{ getRowCount() method + public int getRowCount() + { + return styleChoices.size(); + } //}}} + + //{{{ getValueAt() method + public Object getValueAt(int row, int col) + { + StyleChoice ch = (StyleChoice)styleChoices.elementAt(row); + switch(col) + { + case 0: + return ch.label; + case 1: + return ch.style; + default: + return null; + } + } //}}} + + //{{{ setValueAt() method + public void setValueAt(Object value, int row, int col) + { + StyleChoice ch = (StyleChoice)styleChoices.elementAt(row); + if(col == 1) + ch.style = (SyntaxStyle)value; + fireTableRowsUpdated(row,row); + } //}}} + + //{{{ getColumnName() method + public String getColumnName(int index) + { + switch(index) + { + case 0: + return Messages.getMessage("SourceView.Syntax.Object"); + case 1: + return Messages.getMessage("SourceView.Syntax.Style"); + default: + return null; + } + } //}}} + + //{{{ save() method + public void save() { + for (int i = 0; i < styleChoices.size(); i++) { + StyleChoice ch = (StyleChoice)styleChoices.elementAt(i); + jsXe.setProperty(ch.property, getStyleString(ch.style)); + } + } //}}} + + //{{{ addStyleChoice() method + private void addStyleChoice(String label, String property) { + styleChoices.addElement(new StyleChoice(Messages.getMessage(label), property, parseStyle(jsXe.getProperty(property, "color:#000000")))); + } //}}} + + //{{{ StyleChoice class + private class StyleChoice { + String label; + String property; + SyntaxStyle style; + + StyleChoice(String label, String property, SyntaxStyle style) { + this.label = label; + this.property = property; + this.style = style; + } + + // for sorting + public String toString() { + return label; + } + } //}}} + + //{{{ StyleRenderer class + static class StyleRenderer extends JLabel implements TableCellRenderer { + //{{{ StyleRenderer constructor + public StyleRenderer() { + setOpaque(true); + // setBorder(); + setText("Hello World"); + setToolTipText(Messages.getMessage("SourceView.Syntax.ToolTip")); + } //}}} + + //{{{ getTableCellRendererComponent() method + public Component getTableCellRendererComponent( + JTable table, + Object value, + boolean isSelected, + boolean cellHasFocus, + int row, + int col) + { + if (value != null) { + SyntaxStyle style = (SyntaxStyle)value; + setForeground(style.getColor()); + setBackground(Color.WHITE); + setFont(new Font("Monospaced", (style.isItalic() ? Font.ITALIC : 0) | (style.isBold() ? Font.BOLD : 0), 12)); + } + + //Set a border if focused? + // setBorder(); + return this; + } //}}} + } //}}} + } //}}} + + //{{{ ColorWellButton class + + /** + * A button that, when clicked, shows a color chooser. + * + * You can get and set the currently selected color using + * {@link #getSelectedColor()} and {@link #setSelectedColor(Color)}. + * @author Slava Pestov + * @version $Id$ + */ + public static class ColorWellButton extends JButton { + + //{{{ ColorWellButton constructor + public ColorWellButton(Color color) + { + setIcon(new ColorWell(color)); + setMargin(new Insets(2,2,2,2)); + addActionListener(new ActionHandler()); + + // according to krisk this looks better on OS X... + if(OperatingSystem.isMacOSLF()) + putClientProperty("JButton.buttonType","toolbar"); + } //}}} + + //{{{ getSelectedColor() method + public Color getSelectedColor() + { + return ((ColorWell)getIcon()).color; + } //}}} + + //{{{ setSelectedColor() method + public void setSelectedColor(Color color) + { + ((ColorWell)getIcon()).color = color; + repaint(); + } //}}} + + //{{{ ColorWell class + private class ColorWell implements Icon { + + Color color; + + ColorWell(Color color) + { + this.color = color; + } + + public int getIconWidth() + { + return 35; + } + + public int getIconHeight() + { + return 10; + } + + public void paintIcon(Component c, Graphics g, int x, int y) + { + if(color == null) + return; + + g.setColor(color); + g.fillRect(x,y,getIconWidth(),getIconHeight()); + g.setColor(color.darker()); + g.drawRect(x,y,getIconWidth()-1,getIconHeight()-1); + } + } //}}} + + //{{{ ActionHandler class + class ActionHandler implements ActionListener + { + public void actionPerformed(ActionEvent evt) + { + JDialog parent = getParentDialog(ColorWellButton.this); + JDialog dialog; + if (parent != null) + { + dialog = new ColorPickerDialog(parent, + Messages.getMessage("SourceView.ColorChooser.Title"), + true); + } + else + { + dialog = new ColorPickerDialog( + JOptionPane.getFrameForComponent( + ColorWellButton.this), + Messages.getMessage("SourceView.ColorChooser.Title"), + true); + } + dialog.pack(); + dialog.show(); + } + } //}}} + + //{{{ ColorPickerDialog class + /** + * Replacement for the color picker dialog provided with Swing. This version + * supports dialog as well as frame parents. + */ + private class ColorPickerDialog extends EnhancedDialog implements ActionListener + { + public ColorPickerDialog(Frame parent, String title, boolean modal) + { + super(parent,title,modal); + + init(); + } + + public ColorPickerDialog(Dialog parent, String title, boolean modal) + { + super(parent,title,modal); + + getContentPane().setLayout(new BorderLayout()); + + init(); + } + + public void ok() + { + Color c = chooser.getColor(); + if (c != null) + setSelectedColor(c); + setVisible(false); + } + + public void cancel() + { + setVisible(false); + } + + public void actionPerformed(ActionEvent evt) + { + if (evt.getSource() == ok) + ok(); + else + cancel(); + } + + //{{{ Private members + private JColorChooser chooser; + private JButton ok; + private JButton cancel; + + private void init() + { + Color c = getSelectedColor(); + if(c == null) + chooser = new JColorChooser(); + else + chooser = new JColorChooser(c); + + getContentPane().add(BorderLayout.CENTER, chooser); + + Box buttons = new Box(BoxLayout.X_AXIS); + buttons.add(Box.createGlue()); + + ok = new JButton(Messages.getMessage("common.ok")); + ok.addActionListener(this); + buttons.add(ok); + buttons.add(Box.createHorizontalStrut(6)); + getRootPane().setDefaultButton(ok); + cancel = new JButton(Messages.getMessage("common.cancel")); + cancel.addActionListener(this); + buttons.add(cancel); + buttons.add(Box.createGlue()); + + getContentPane().add(BorderLayout.SOUTH, buttons); + pack(); + setLocationRelativeTo(getParent()); + } //}}} + } //}}} + }//}}} + + private StyleTableModel styleModel; + private JTable styleTable; + private JCheckBox m_endOfLineMarkCheckBox; + //}}} + +}//}}} + Deleted: trunk/sourceview/src/sourceview/SourceViewOptionsPanel.java =================================================================== --- trunk/sourceview/src/sourceview/SourceViewOptionsPanel.java 2006-06-15 21:49:54 UTC (rev 964) +++ trunk/sourceview/src/sourceview/SourceViewOptionsPanel.java 2006-06-15 21:52:24 UTC (rev 965) @@ -1,736 +0,0 @@ -/* -SourceViewOptionsPanel.java -:tabSize=4:indentSize=4:noTabs=true: -:folding=explicit:collapseFolds=1: - -Copyright (C) 2002 Ian Lewis (Ian...@me...) -Portions Copyright (C) 1999, 2000, 2001, 2002 Slava Pestov - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -Optionally, you may find a copy of the GNU General Public License -from http://www.fsf.org/copyleft/gpl.txt -*/ - -package sourceview; - -//{{{ Imports - -import org.syntax.jedit.*; - -//{{{ jsXe classes -import net.sourceforge.jsxe.*; -import net.sourceforge.jsxe.gui.*; -import net.sourceforge.jsxe.util.MiscUtilities; -//}}} - -//{{{ Java Classes -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.table.*; -import javax.swing.border.EmptyBorder; -import java.util.Vector; -import java.util.StringTokenizer; -import java.util.Iterator; -//}}} - -//}}} - -public class SourceViewOptionsPanel extends OptionsPanel { - - //{{{ SourceViewOptionsPanel constructor - - public SourceViewOptionsPanel(DocumentBuffer buffer) { - - m_document = buffer; - - setLayout(new BorderLayout(6,6)); - - add(BorderLayout.CENTER,createStyleTableScroller()); - - JPanel panel = new JPanel(); - - GridBagLayout layout = new GridBagLayout(); - GridBagConstraints constraints = new GridBagConstraints(); - panel.setLayout(layout); - - int gridY = 0; - - m_endOfLineMarkCheckBox = new JCheckBox(Messages.getMessage("SourceView.Options.EndOfLineMarker"),jsXe.getBooleanProperty("source.end-of-line-markers",true)); - - constraints.gridy = gridY++; - constraints.gridx = 1; - constraints.gridheight = 1; - constraints.gridwidth = 2; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(m_endOfLineMarkCheckBox, constraints); - panel.add(m_endOfLineMarkCheckBox); - - add(BorderLayout.SOUTH, panel); - - }//}}} - - //{{{ getName() - - public String getName() { - return "sourceview"; - }//}}} - - //{{{ save() - - public void save() { - styleModel.save(); - jsXe.setBooleanProperty("source.end-of-line-markers",m_endOfLineMarkCheckBox.isSelected()); - - Iterator itr = SourceView.m_sourceviews.iterator(); - while (itr.hasNext()) { - TextAreaPainter painter = ((SourceView)itr.next()).getTextArea().getPainter(); - painter.setEOLMarkersPainted(m_endOfLineMarkCheckBox.isSelected()); - painter.setStyles( - new SyntaxStyle[] { parseStyle(jsXe.getProperty("source.text.color")), - parseStyle(jsXe.getProperty("source.comment.color")), - parseStyle(jsXe.getProperty("source.doctype.color")), - parseStyle(jsXe.getProperty("source.attribute.value.color")), - parseStyle(jsXe.getProperty("source.attribute.value.color")), - parseStyle(jsXe.getProperty("source.cdata.color")), - parseStyle(jsXe.getProperty("source.entity.reference.color")), - parseStyle(jsXe.getProperty("source.element.color")), - parseStyle(jsXe.getProperty("source.attribute.color")), - parseStyle(jsXe.getProperty("source.processing.instruction.color")), - parseStyle(jsXe.getProperty("source.namespace.prefix.color")), - parseStyle(jsXe.getProperty("source.markup.color")), - parseStyle(jsXe.getProperty("source.invalid.color")), - }); - } - - - }//}}} - - //{{{ getTitle() - - public String getTitle() { - return Messages.getMessage("SourceView.Options.Title"); - }//}}} - - //{{{ parseStyle() method - /** - * Converts a style string to a style object. - * @param str The style string - * @param family Style strings only specify font style, not font family - * @param size Style strings only specify font style, not font family - * @param color If false, the styles will be monochrome - * @exception IllegalArgumentException if the style is invalid - */ - public static SyntaxStyle parseStyle(String str) throws IllegalArgumentException { - Color fgColor = Color.black; - Color bgColor = null; - boolean italic = false; - boolean bold = false; - StringTokenizer st = new StringTokenizer(str); - while(st.hasMoreTokens()) { - String s = st.nextToken(); - if (s.startsWith("color:")) { - fgColor = parseColor(s.substring(6), Color.black); - } - else if (s.startsWith("style:")) { - for (int i = 6; i < s.length(); i++) { - if (s.charAt(i) == 'i') - italic = true; - else if(s.charAt(i) == 'b') - bold = true; - else - throw new IllegalArgumentException("Invalid style: " + s); - } - } - else - throw new IllegalArgumentException("Invalid directive: " + s); - } - return new SyntaxStyle(fgColor, italic, bold); - } //}}} - - //{{{ parseColor() method - public static Color parseColor(String name, Color defaultColor) { - if (name == null) - return defaultColor; - else if(name.startsWith("#")) { - try - { - return Color.decode(name); - } - catch(NumberFormatException nf) - { - return defaultColor; - } - } - else if("red".equals(name)) - return Color.red; - else if("green".equals(name)) - return Color.green; - else if("blue".equals(name)) - return Color.blue; - else if("yellow".equals(name)) - return Color.yellow; - else if("orange".equals(name)) - return Color.orange; - else if("white".equals(name)) - return Color.white; - else if("lightGray".equals(name)) - return Color.lightGray; - else if("gray".equals(name)) - return Color.gray; - else if("darkGray".equals(name)) - return Color.darkGray; - else if("black".equals(name)) - return Color.black; - else if("cyan".equals(name)) - return Color.cyan; - else if("magenta".equals(name)) - return Color.magenta; - else if("pink".equals(name)) - return Color.pink; - else - return defaultColor; - } //}}} - - //{{{ Private Members - - //{{{ getParentDialog() method - /** - * Traverses the given component's parent tree looking for an - * instance of JDialog, and return it. If not found, return null. - * @param c The component - */ - private static JDialog getParentDialog(Component c) { - Component p = c.getParent(); - while (p != null && !(p instanceof JDialog)) { - p = p.getParent(); - } - - return (p instanceof JDialog) ? (JDialog) p : null; - } //}}} - - //{{{ getStyleString() method - /** - * Converts a style into it's string representation. - * @param style The style - */ - private static String getStyleString(SyntaxStyle style) { - StringBuffer buf = new StringBuffer(); - - if (style.getColor() != null) { - buf.append("color:" + getColorHexString(style.getColor())); - } - - if (!style.isPlain()) { - buf.append(" style:" + (style.isItalic() ? "i" : "") - + (style.isBold() ? "b" : "")); - } - - return buf.toString(); - }//}}} - - //{{{ createStyleTableScroller() method - - private JScrollPane createStyleTableScroller() { - styleModel = createStyleTableModel(); - styleTable = new JTable(styleModel); - styleTable.setRowSelectionAllowed(false); - styleTable.setColumnSelectionAllowed(false); - styleTable.setCellSelectionEnabled(false); - styleTable.getTableHeader().setReorderingAllowed(false); - styleTable.addMouseListener(new MouseHandler()); - TableColumnModel tcm = styleTable.getColumnModel(); - TableColumn styleColumn = tcm.getColumn(1); - styleColumn.setCellRenderer(new StyleTableModel.StyleRenderer()); - Dimension d = styleTable.getPreferredSize(); - d.height = Math.min(d.height,100); - JScrollPane scroller = new JScrollPane(styleTable); - scroller.setPreferredSize(d); - return scroller; - } //}}} - - //{{{ createStyleTableModel() method - - private StyleTableModel createStyleTableModel() { - return new StyleTableModel(); - } //}}} - - //{{{ getColorHexString() method - /** - * Converts a color object to its hex value. The hex value - * prefixed is with `#', for example `#ff0088'. - * @param c The color object - */ - private static String getColorHexString(Color c) { - String colString = Integer.toHexString(c.getRGB() & 0xffffff); - return "#000000".substring(0,7 - colString.length()).concat(colString); - } //}}} - - //{{{ MouseHandler class - - private class MouseHandler extends MouseAdapter { - public void mouseClicked(MouseEvent evt) { - int row = styleTable.rowAtPoint(evt.getPoint()); - if(row == -1) - return; - - SyntaxStyle style = new StyleEditor( - SourceViewOptionsPanel.this, - (SyntaxStyle)styleModel.getValueAt( - row,1)).getStyle(); - if(style != null) - styleModel.setValueAt(style,row,1); - } - } //}}} - - //{{{ StyleEditor class - private static class StyleEditor extends EnhancedDialog implements ActionListener { - //{{{ StyleEditor constructor - public StyleEditor(Component comp, SyntaxStyle style) { - super(getParentDialog(comp), - Messages.getMessage("SourceView.StyleEditor.Title"),true); - - JPanel content = new JPanel(new BorderLayout(12,12)); - content.setBorder(new EmptyBorder(12,12,12,12)); - setContentPane(content); - - GridBagLayout layout = new GridBagLayout(); - JPanel panel = new JPanel(layout); - - GridBagConstraints cons = new GridBagConstraints(); - cons.gridx = cons.gridy = 0; - cons.gridwidth = 2; - cons.gridheight = 1; - cons.fill = GridBagConstraints.BOTH; - cons.weightx = 0.0f; - - italics = new JCheckBox(Messages.getMessage("SourceView.StyleEditor.Italics")); - italics.setSelected(style.isItalic()); - italics.setToolTipText(Messages.getMessage("SourceView.StyleEditor.Italics.ToolTip")); - layout.setConstraints(italics,cons); - panel.add(italics); - - cons.gridy++; - bold = new JCheckBox(Messages.getMessage("SourceView.StyleEditor.Bold")); - bold.setSelected(style.isBold()); - bold.setToolTipText(Messages.getMessage("SourceView.StyleEditor.Bold.ToolTip")); - layout.setConstraints(bold,cons); - panel.add(bold); - - cons.gridy++; - cons.gridwidth = 1; - Color fg = style.getColor(); - - fgColorCheckBox = new JCheckBox(Messages.getMessage("SourceView.StyleEditor.Color")); - fgColorCheckBox.setSelected(fg != null); - fgColorCheckBox.addActionListener(this); - fgColorCheckBox.setBorder(new EmptyBorder(0,0,0,12)); - fgColorCheckBox.setToolTipText(Messages.getMessage("SourceView.StyleEditor.Color.ToolTip")); - layout.setConstraints(fgColorCheckBox,cons); - panel.add(fgColorCheckBox); - - cons.gridx++; - fgColor = new ColorWellButton(fg); - fgColor.setEnabled(fg != null); - layout.setConstraints(fgColor,cons); - panel.add(fgColor); - - content.add(BorderLayout.CENTER,panel); - - Box box = new Box(BoxLayout.X_AXIS); - box.add(Box.createGlue()); - box.add(ok = new JButton(Messages.getMessage("common.ok"))); - getRootPane().setDefaultButton(ok); - ok.addActionListener(this); - box.add(Box.createHorizontalStrut(6)); - box.add(cancel = new JButton(Messages.getMessage("common.cancel"))); - cancel.addActionListener(this); - box.add(Box.createGlue()); - - content.add(BorderLayout.SOUTH,box); - - pack(); - setLocationRelativeTo(getParentDialog(comp)); - - setResizable(false); - show(); - } //}}} - - //{{{ actionPerformed() method - public void actionPerformed(ActionEvent evt) { - Object source = evt.getSource(); - if(source == ok) - ok(); - else if(source == cancel) - cancel(); - else if(source == fgColorCheckBox) - fgColor.setEnabled(fgColorCheckBox.isSelected()); - } //}}} - - //{{{ ok() method - public void ok() { - okClicked = true; - dispose(); - } //}}} - - //{{{ cancel() method - public void cancel() { - dispose(); - } //}}} - - //{{{ getStyle() method - public SyntaxStyle getStyle() { - if(!okClicked) - return null; - - Color foreground = (fgColorCheckBox.isSelected() - ? fgColor.getSelectedColor() - : null); - - return new SyntaxStyle(foreground, italics.isSelected(), bold.isSelected()); - } //}}} - - //{{{ Private members - private JCheckBox italics; - private JCheckBox bold; - private JCheckBox fgColorCheckBox; - private ColorWellButton fgColor; - private JButton ok; - private JButton cancel; - private boolean okClicked; - //}}} - } //}}} - - //{{{ StyleTableModel class - private static class StyleTableModel extends AbstractTableModel { - private Vector styleChoices; - - //{{{ StyleTableModel constructor - public StyleTableModel() { - styleChoices = new Vector(9); - addStyleChoice("SourceView.Markup", "source.markup.color"); - addStyleChoice("xml.namespace.prefix", "source.namespace.prefix.color"); - addStyleChoice("xml.text","source.text.color"); - addStyleChoice("xml.element","source.element.color"); - addStyleChoice("xml.attribute","source.attribute.color"); - addStyleChoice("xml.attribute.value", "source.attribute.value.color"); - addStyleChoice("xml.cdata","source.cdata.color"); - addStyleChoice("xml.processing.instruction","source.processing.instruction.color"); - addStyleChoice("xml.entity.reference","source.entity.reference.color"); - addStyleChoice("xml.comment","source.comment.color"); - addStyleChoice("xml.doctype","source.doctype.color"); - addStyleChoice("SourceView.Invalid", "source.invalid.color"); - MiscUtilities.quicksort(styleChoices, new MiscUtilities.StringCompare()); - } //}}} - - //{{{ getColumnCount() method - public int getColumnCount() - { - return 2; - } //}}} - - //{{{ getRowCount() method - public int getRowCount() - { - return styleChoices.size(); - } //}}} - - //{{{ getValueAt() method - public Object getValueAt(int row, int col) - { - StyleChoice ch = (StyleChoice)styleChoices.elementAt(row); - switch(col) - { - case 0: - return ch.label; - case 1: - return ch.style; - default: - return null; - } - } //}}} - - //{{{ setValueAt() method - public void setValueAt(Object value, int row, int col) - { - StyleChoice ch = (StyleChoice)styleChoices.elementAt(row); - if(col == 1) - ch.style = (SyntaxStyle)value; - fireTableRowsUpdated(row,row); - } //}}} - - //{{{ getColumnName() method - public String getColumnName(int index) - { - switch(index) - { - case 0: - return Messages.getMessage("SourceView.Syntax.Object"); - case 1: - return Messages.getMessage("SourceView.Syntax.Style"); - default: - return null; - } - } //}}} - - //{{{ save() method - public void save() { - for (int i = 0; i < styleChoices.size(); i++) { - StyleChoice ch = (StyleChoice)styleChoices.elementAt(i); - jsXe.setProperty(ch.property, getStyleString(ch.style)); - } - } //}}} - - //{{{ addStyleChoice() method - private void addStyleChoice(String label, String property) { - styleChoices.addElement(new StyleChoice(Messages.getMessage(label), property, parseStyle(jsXe.getProperty(property, "color:#000000")))); - } //}}} - - //{{{ StyleChoice class - private class StyleChoice { - String label; - String property; - SyntaxStyle style; - - StyleChoice(String label, String property, SyntaxStyle style) { - this.label = label; - this.property = property; - this.style = style; - } - - // for sorting - public String toString() { - return label; - } - } //}}} - - //{{{ StyleRenderer class - static class StyleRenderer extends JLabel implements TableCellRenderer { - //{{{ StyleRenderer constructor - public StyleRenderer() { - setOpaque(true); - // setBorder(); - setText("Hello World"); - setToolTipText(Messages.getMessage("SourceView.Syntax.ToolTip")); - } //}}} - - //{{{ getTableCellRendererComponent() method - public Component getTableCellRendererComponent( - JTable table, - Object value, - boolean isSelected, - boolean cellHasFocus, - int row, - int col) - { - if (value != null) { - SyntaxStyle style = (SyntaxStyle)value; - setForeground(style.getColor()); - setBackground(Color.WHITE); - setFont(new Font("Monospaced", (style.isItalic() ? Font.ITALIC : 0) | (style.isBold() ? Font.BOLD : 0), 12)); - } - - //Set a border if focused? - // setBorder(); - return this; - } //}}} - } //}}} - } //}}} - - //{{{ ColorWellButton class - - /** - * A button that, when clicked, shows a color chooser. - * - * You can get and set the currently selected color using - * {@link #getSelectedColor()} and {@link #setSelectedColor(Color)}. - * @author Slava Pestov - * @version $Id$ - */ - public static class ColorWellButton extends JButton { - - //{{{ ColorWellButton constructor - public ColorWellButton(Color color) - { - setIcon(new ColorWell(color)); - setMargin(new Insets(2,2,2,2)); - addActionListener(new ActionHandler()); - - // according to krisk this looks better on OS X... - if(OperatingSystem.isMacOSLF()) - putClientProperty("JButton.buttonType","toolbar"); - } //}}} - - //{{{ getSelectedColor() method - public Color getSelectedColor() - { - return ((ColorWell)getIcon()).color; - } //}}} - - //{{{ setSelectedColor() method - public void setSelectedColor(Color color) - { - ((ColorWell)getIcon()).color = color; - repaint(); - } //}}} - - //{{{ ColorWell class - private class ColorWell implements Icon { - - Color color; - - ColorWell(Color color) - { - this.color = color; - } - - public int getIconWidth() - { - return 35; - } - - public int getIconHeight() - { - return 10; - } - - public void paintIcon(Component c, Graphics g, int x, int y) - { - if(color == null) - return; - - g.setColor(color); - g.fillRect(x,y,getIconWidth(),getIconHeight()); - g.setColor(color.darker()); - g.drawRect(x,y,getIconWidth()-1,getIconHeight()-1); - } - } //}}} - - //{{{ ActionHandler class - class ActionHandler implements ActionListener - { - public void actionPerformed(ActionEvent evt) - { - JDialog parent = getParentDialog(ColorWellButton.this); - JDialog dialog; - if (parent != null) - { - dialog = new ColorPickerDialog(parent, - Messages.getMessage("SourceView.ColorChooser.Title"), - true); - } - else - { - dialog = new ColorPickerDialog( - JOptionPane.getFrameForComponent( - ColorWellButton.this), - Messages.getMessage("SourceView.ColorChooser.Title"), - true); - } - dialog.pack(); - dialog.show(); - } - } //}}} - - //{{{ ColorPickerDialog class - /** - * Replacement for the color picker dialog provided with Swing. This version - * supports dialog as well as frame parents. - */ - private class ColorPickerDialog extends EnhancedDialog implements ActionListener - { - public ColorPickerDialog(Frame parent, String title, boolean modal) - { - super(parent,title,modal); - - init(); - } - - public ColorPickerDialog(Dialog parent, String title, boolean modal) - { - super(parent,title,modal); - - getContentPane().setLayout(new BorderLayout()); - - init(); - } - - public void ok() - { - Color c = chooser.getColor(); - if (c != null) - setSelectedColor(c); - setVisible(false); - } - - public void cancel() - { - setVisible(false); - } - - public void actionPerformed(ActionEvent evt) - { - if (evt.getSource() == ok) - ok(); - else - cancel(); - } - - //{{{ Private members - private JColorChooser chooser; - private JButton ok; - private JButton cancel; - - ... [truncated message content] |
From: <ian...@us...> - 2006-07-26 17:07:43
|
Revision: 1070 Author: ian_lewis Date: 2006-07-26 10:07:26 -0700 (Wed, 26 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1070&view=rev Log Message: ----------- Version bump Modified Paths: -------------- trunk/sourceview/build.xml trunk/sourceview/dependency.props Modified: trunk/sourceview/build.xml =================================================================== --- trunk/sourceview/build.xml 2006-07-26 17:07:14 UTC (rev 1069) +++ trunk/sourceview/build.xml 2006-07-26 17:07:26 UTC (rev 1070) @@ -38,7 +38,7 @@ <property name="main.class" value="sourceview.SourceViewPlugin"/> <property name="major.version" value="0"/> <property name="minor.version" value="5"/> - <property name="build.version" value="1"/> + <property name="build.version" value="3"/> <property name="app.version" value="${major.version}.${minor.version}.${build.version}"/> <property name="app_version" value="${major.version}_${minor.version}_${build.version}"/> <property name="implementation.version" value="${major.version}.${minor.version}.${build.version}"/> Modified: trunk/sourceview/dependency.props =================================================================== --- trunk/sourceview/dependency.props 2006-07-26 17:07:14 UTC (rev 1069) +++ trunk/sourceview/dependency.props 2006-07-26 17:07:26 UTC (rev 1070) @@ -1 +1 @@ -dependency.0=jsxe 00.05.01.00 +dependency.0=jsxe 00.05.03.00 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-27 21:12:47
|
Revision: 1068 Author: ian_lewis Date: 2006-07-26 09:57:45 -0700 (Wed, 26 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1068&view=rev Log Message: ----------- Added support for the findnext action Modified Paths: -------------- trunk/sourceview/Changelog trunk/sourceview/messages/messages trunk/sourceview/src/sourceview/SourceView.java trunk/sourceview/src/sourceview/SourceViewPlugin.java trunk/sourceview/src/sourceview/SourceViewSearchDialog.java Modified: trunk/sourceview/Changelog =================================================================== --- trunk/sourceview/Changelog 2006-07-26 16:56:28 UTC (rev 1067) +++ trunk/sourceview/Changelog 2006-07-26 16:57:45 UTC (rev 1068) @@ -1,3 +1,7 @@ +07/26/2006 Ian Lewis <Ian...@me...> + + * Addded support for the findnext action + 07/21/2006 Ian Lewis <Ian...@me...> * Added better horizontal scrolling support. It isn't perfect because Modified: trunk/sourceview/messages/messages =================================================================== --- trunk/sourceview/messages/messages 2006-07-26 16:56:28 UTC (rev 1067) +++ trunk/sourceview/messages/messages 2006-07-26 16:57:45 UTC (rev 1068) @@ -20,3 +20,14 @@ SourceView.StyleEditor.Bold=Bold SourceView.StyleEditor.Italics=Italics #}}} + +#{{{ Find Dialog +SourceView.Find.title and Replace +SourceView.Ignore.Case=Ignore Case +SourceView.Search.For=Search for: +SourceView.Replace.With=Replace With: +SourceView.Replace.And.Find=Replace&Find +SourceView.No.More.Matches.title=No More Matches +SourceView.No.More.Matches.message="No more matches were found. Continue search from the beginning?" +SourceView.Search.Error.title=Search Error +#}}} \ No newline at end of file Modified: trunk/sourceview/src/sourceview/SourceView.java =================================================================== --- trunk/sourceview/src/sourceview/SourceView.java 2006-07-26 16:56:28 UTC (rev 1067) +++ trunk/sourceview/src/sourceview/SourceView.java 2006-07-26 16:57:45 UTC (rev 1068) @@ -85,7 +85,6 @@ //{{{ Public static members public static final String SOFT_TABS = SourceViewPlugin.PLUGIN_NAME+".soft.tabs"; - public static final String LAST_FIND_STRING = SourceViewPlugin.PLUGIN_NAME+".last.find.string"; public static final String END_OF_LINE_MARKS = SourceViewPlugin.PLUGIN_NAME+".end-of-line-markers"; //}}} Modified: trunk/sourceview/src/sourceview/SourceViewPlugin.java =================================================================== --- trunk/sourceview/src/sourceview/SourceViewPlugin.java 2006-07-26 16:56:28 UTC (rev 1067) +++ trunk/sourceview/src/sourceview/SourceViewPlugin.java 2006-07-26 16:57:45 UTC (rev 1068) @@ -64,6 +64,7 @@ addAction(new EditCopyAction()); addAction(new EditPasteAction()); addAction(new EditFindAction()); + addAction(new EditFindNextAction()); }//}}} //{{{ newDocumentView() Modified: trunk/sourceview/src/sourceview/SourceViewSearchDialog.java =================================================================== --- trunk/sourceview/src/sourceview/SourceViewSearchDialog.java 2006-07-26 16:56:28 UTC (rev 1067) +++ trunk/sourceview/src/sourceview/SourceViewSearchDialog.java 2006-07-26 16:57:45 UTC (rev 1068) @@ -70,13 +70,19 @@ //}}} +/** + * The Find dialog for the source view. This allows users to search + * for strings in the document and possibly replace the strings with + * another. + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id$ + */ public class SourceViewSearchDialog extends EnhancedDialog { //{{{ Private static members private static int m_dialogHeight = 200; private static int m_dialogWidth = 350; private static SourceViewSearchDialog m_dialog = null; - private static final String IGNORE_CASE = "source.ignore.case"; //}}} //{{{ Public static members @@ -108,15 +114,15 @@ //{{{ SourceViewSearchDialog constructor public SourceViewSearchDialog(Frame parentFrame, SourceView view) { - super(parentFrame, "Search and Replace", false); + super(parentFrame, Messages.getMessage("SourceView.Search.And.Replace"), false); m_view = view; JPanel frame = new JPanel(); getContentPane().add(frame,BorderLayout.CENTER); - JButton findButton = new JButton("Find"); - JButton replaceButton = new JButton("Replace&Find"); + JButton findButton = new JButton(Messages.getMessage("common.find")); + JButton replaceButton = new JButton(Messages.getMessage("SourceView.Replace.And.Find")); // JButton replaceAllButton = new JButton("Replace All"); JButton cancelButton = new JButton(Messages.getMessage("common.cancel")); @@ -140,7 +146,9 @@ m_findComboBox.setName("FindComboBox"); m_findComboBox.setEditable(true); - String last = jsXe.getProperty("SourceView.Search.Last"); + DocumentBuffer buffer = m_view.getDocumentBuffer(); + + String last = buffer.getProperty(SourceViewSearch.LAST_FIND_STRING); if (last != null) { m_findComboBox.setSelectedItem(last); m_findComboBox.getEditor().selectAll(); @@ -150,9 +158,8 @@ m_replaceComboBox.setName("ReplaceComboBox"); m_replaceComboBox.setEditable(true); - DocumentBuffer buffer = m_view.getDocumentBuffer(); - boolean ignoreCase = Boolean.valueOf(jsXe.getProperty(IGNORE_CASE)).booleanValue(); - m_ignoreCaseCheckBox = new JCheckBox("Ignore Case", ignoreCase); + boolean ignoreCase = Boolean.valueOf(jsXe.getProperty(SourceViewSearch.IGNORE_CASE)).booleanValue(); + m_ignoreCaseCheckBox = new JCheckBox(Messages.getMessage("SourceView.Ignore.Case"), ignoreCase); constraints.gridy = 0; constraints.gridx = 0; @@ -164,7 +171,7 @@ constraints.fill = GridBagConstraints.BOTH; constraints.insets = new Insets(1,0,1,0); - JLabel searchLabel = new JLabel("Search for:"); + JLabel searchLabel = new JLabel(Messages.getMessage("SourceView.Search.For")); layout.setConstraints(searchLabel, constraints); frame.add(searchLabel); @@ -191,7 +198,7 @@ constraints.fill = GridBagConstraints.BOTH; constraints.insets = new Insets(1,0,1,0); - JLabel replaceLabel = new JLabel("Replace With:"); + JLabel replaceLabel = new JLabel(Messages.getMessage("SourceView.Replace.With")); layout.setConstraints(replaceLabel, constraints); frame.add(replaceLabel); @@ -247,7 +254,6 @@ //{{{ cancel() public void cancel() { - jsXe.setProperty(IGNORE_CASE, String.valueOf(m_ignoreCaseCheckBox.isSelected())); dispose(); }//}}} @@ -292,68 +298,28 @@ //{{{ find() private void find(boolean doReplace) { - find(doReplace, m_view.getTextArea().getCaretPosition()); - }//}}} - - //{{{ find() - - private void find(boolean doReplace, int startIndex) { - try { - Object searchItem = m_findComboBox.getSelectedItem(); - Object replaceItem = m_replaceComboBox.getSelectedItem(); - boolean ignoreCase = m_ignoreCaseCheckBox.isSelected(); - - String search = ""; - if (searchItem != null) { - search = searchItem.toString(); - } - - String replace = ""; - if (replaceItem != null) { - replace = replaceItem.toString(); - } - - RESearchMatcher matcher = new RESearchMatcher(search, replace, ignoreCase); - - JEditTextArea textArea = m_view.getTextArea(); - - //replace previous text - if (doReplace) { - String selText = textArea.getSelectedText(); - if (selText != null && !selText.equals("")) { - String replaceString = matcher.substitute(selText); - textArea.setSelectedText(replaceString); - } - } - - DocumentBuffer buffer = m_view.getDocumentBuffer(); - Segment seg = buffer.getSegment(0, buffer.getLength()); - int caretPosition = startIndex; - CharIndexedSegment charSeg = new CharIndexedSegment(seg, caretPosition); - - int[] match = matcher.nextMatch(charSeg, false, true, true, false); - - buffer.setProperty(SourceView.LAST_FIND_STRING, search); - - if (match != null) { - Log.log(Log.DEBUG, this, match[0] + " "+ match[1]); - int start = match[0]+caretPosition; - int end = match[1]+caretPosition; - // textArea.requestFocus(); - textArea.select(start, end); - } else { - int again = JOptionPane.showConfirmDialog(m_view, "No more matches were found. Continue search from the beginning?", "No More Matches Found", JOptionPane.YES_NO_OPTION); - if (again == 0) { - find(doReplace, 0); - } - } - - requestFocus(); - jsXe.setProperty("SourceView.Search.Last", search); - } catch (Exception ex) { - ex.printStackTrace(); - JOptionPane.showMessageDialog(m_view, ex, "Search Error", JOptionPane.WARNING_MESSAGE); + Object searchItem = m_findComboBox.getSelectedItem(); + Object replaceItem = m_replaceComboBox.getSelectedItem(); + boolean ignoreCase = m_ignoreCaseCheckBox.isSelected(); + + String search = ""; + if (searchItem != null) { + search = searchItem.toString(); } + + String replace = ""; + if (replaceItem != null) { + replace = replaceItem.toString(); + } + + SourceViewSearch searcher = new SourceViewSearch(m_view); + if (doReplace) { + searcher.replaceAndFind(search, replace, ignoreCase); + } else { + searcher.find(search, ignoreCase); + } + + requestFocus(); }//}}} private SourceView m_view; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-08-05 21:41:22
|
Revision: 1106 Author: ian_lewis Date: 2006-08-05 14:41:13 -0700 (Sat, 05 Aug 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1106&view=rev Log Message: ----------- Added Undo to the source view Modified Paths: -------------- trunk/sourceview/Changelog trunk/sourceview/src/sourceview/SourceView.java trunk/sourceview/src/sourceview/SourceViewDocument.java trunk/sourceview/src/sourceview/SourceViewPlugin.java Added Paths: ----------- trunk/sourceview/src/sourceview/action/RedoAction.java trunk/sourceview/src/sourceview/action/UndoAction.java Modified: trunk/sourceview/Changelog =================================================================== --- trunk/sourceview/Changelog 2006-08-05 20:24:09 UTC (rev 1105) +++ trunk/sourceview/Changelog 2006-08-05 21:41:13 UTC (rev 1106) @@ -1,3 +1,7 @@ +08/05/2006 Ian Lewis <Ian...@me...> + + * Added undo to the source view + 07/26/2006 Ian Lewis <Ian...@me...> * Addded support for the findnext action Modified: trunk/sourceview/src/sourceview/SourceView.java =================================================================== --- trunk/sourceview/src/sourceview/SourceView.java 2006-08-05 20:24:09 UTC (rev 1105) +++ trunk/sourceview/src/sourceview/SourceView.java 2006-08-05 21:41:13 UTC (rev 1106) @@ -155,13 +155,11 @@ m_editMenu = new JMenu(Messages.getMessage("Edit.Menu")); m_editMenu.setMnemonic('E'); // These don't do anything yet. - // JMenuItem menuItem = new JMenuItem("Undo"); - // menuItem.addActionListener( new EditUndoAction() ); - // menu.add( menuItem ); - // menuItem = new JMenuItem("Redo"); - // menuItem.addActionListener( new EditRedoAction() ); - // menu.add(menuItem); - // menu.addSeparator(); + menuItem = new JMenuItem(ActionManager.getAction("undo")); + m_editMenu.add( menuItem ); + menuItem = new JMenuItem(ActionManager.getAction("redo")); + m_editMenu.add(menuItem); + m_editMenu.addSeparator(); menuItem = new JMenuItem(ActionManager.getAction("cut")); m_editMenu.add(menuItem); menuItem = new JMenuItem(ActionManager.getAction("copy")); Modified: trunk/sourceview/src/sourceview/SourceViewDocument.java =================================================================== --- trunk/sourceview/src/sourceview/SourceViewDocument.java 2006-08-05 20:24:09 UTC (rev 1105) +++ trunk/sourceview/src/sourceview/SourceViewDocument.java 2006-08-05 21:41:13 UTC (rev 1106) @@ -55,6 +55,10 @@ import javax.swing.text.GapContent; import javax.swing.text.SimpleAttributeSet; import javax.swing.text.StyleContext; +import javax.swing.event.DocumentEvent; +import javax.swing.event.UndoableEditListener; +import javax.swing.event.UndoableEditEvent; +import javax.swing.undo.*; //}}} //{{{ DOM classes @@ -96,50 +100,103 @@ //buffer is actually loaded in the text area at any //given time(?) super.insertString(0, document.getText(0,document.getLength()), null); + m_initialized = true; } catch (BadLocationException ble) { Log.log(Log.ERROR, this, ble); } } + + addUndoableEditListener(new UndoableEditListener() { + public void undoableEditHappened(UndoableEditEvent e) { + m_undoManager.addEdit(e.getEdit()); + } + }); }//}}} //{{{ DefaultStyledDocument methods - //{{{ insertString() + // //{{{ insertString() - public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { + // public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { + // Log.log(Log.DEBUG, this, "insert: "+str); + // try { + // super.insertString(offs, str, a); + // m_document.insertText(offs, str); + // } catch (DOMException dome) { + // Log.log(Log.ERROR, this, dome); + // Toolkit.getDefaultToolkit().beep(); + // } catch (IOException ioe) { + // Log.log(Log.ERROR, this, ioe); + // } + + // }//}}} + + // //{{{ remove() + + // public void remove(int offs, int len) throws BadLocationException { + // Log.log(Log.DEBUG, this, "remove"); + // try { + // super.remove(offs, len); + // m_document.removeText(offs, len); + // } catch (DOMException dome) { + // Log.log(Log.ERROR, this, dome); + // Toolkit.getDefaultToolkit().beep(); + // } catch (IOException ioe) { + // Log.log(Log.ERROR, this, ioe); + // } + // }//}}} + + protected void fireInsertUpdate(DocumentEvent e) { try { - super.insertString(offs, str, a); - m_document.insertText(offs, str); - } catch (DOMException dome) { - Log.log(Log.ERROR, this, dome); - Toolkit.getDefaultToolkit().beep(); + Log.log(Log.DEBUG, this, "insert: "+getText(e.getOffset(), e.getLength())); + if (m_initialized) { + m_document.insertText(e.getOffset(), getText(e.getOffset(), e.getLength())); + } + super.fireInsertUpdate(e); } catch (IOException ioe) { Log.log(Log.ERROR, this, ioe); + } catch (BadLocationException ble) { + Log.log(Log.ERROR, this, ble); } - - }//}}} - - //{{{ remove() + } - public void remove(int offs, int len) throws BadLocationException { - + protected void fireRemoveUpdate(DocumentEvent e) { try { - super.remove(offs, len); - m_document.removeText(offs, len); - } catch (DOMException dome) { - Log.log(Log.ERROR, this, dome); - Toolkit.getDefaultToolkit().beep(); + Log.log(Log.DEBUG, this, "remove: "+e.getOffset()+":"+e.getLength()); + if (m_initialized) { + m_document.removeText(e.getOffset(), e.getLength()); + } + super.fireRemoveUpdate(e); } catch (IOException ioe) { Log.log(Log.ERROR, this, ioe); } - - }//}}} - + } + //}}} + //{{{ undo() + public void undo() { + try { + m_undoManager.undo(); + } catch (CannotUndoException e) { + Log.log(Log.WARNING, this, "Cannot undo"); + } + }//}}} + + //{{{ redo() + public void redo() throws CannotUndoException { + try { + m_undoManager.redo(); + } catch (CannotUndoException e) { + Log.log(Log.WARNING, this, "Cannot redo"); + } + }//}}} + //{{{ Private members + private boolean m_initialized = false; private XMLDocument m_document; + private UndoManager m_undoManager = new UndoManager(); //}}} } Modified: trunk/sourceview/src/sourceview/SourceViewPlugin.java =================================================================== --- trunk/sourceview/src/sourceview/SourceViewPlugin.java 2006-08-05 20:24:09 UTC (rev 1105) +++ trunk/sourceview/src/sourceview/SourceViewPlugin.java 2006-08-05 21:41:13 UTC (rev 1106) @@ -65,6 +65,8 @@ addAction(new EditPasteAction()); addAction(new EditFindAction()); addAction(new EditFindNextAction()); + addAction(new UndoAction()); + addAction(new RedoAction()); }//}}} //{{{ newDocumentView() Added: trunk/sourceview/src/sourceview/action/RedoAction.java =================================================================== --- trunk/sourceview/src/sourceview/action/RedoAction.java (rev 0) +++ trunk/sourceview/src/sourceview/action/RedoAction.java 2006-08-05 21:41:13 UTC (rev 1106) @@ -0,0 +1,74 @@ +/* +RedoAction.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2006 Ian Lewis (Ian...@me...) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package sourceview.action; + +//{{{ imports + +import sourceview.*; + +//{{{ jsXe classes +import net.sourceforge.jsxe.jsXe; +import net.sourceforge.jsxe.ActionManager; +import net.sourceforge.jsxe.LocalizedAction; +import net.sourceforge.jsxe.gui.TabbedView; +import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.gui.DocumentView; +import net.sourceforge.jsxe.util.Log; +//}}} + +//{{{ AWT classes +import java.awt.event.ActionEvent; +//}}} + +//}}} + +/** + * This action that redoes the last action made in the source view. + * + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id$ + */ +public class RedoAction extends LocalizedAction { + + //{{{ RedoAction constructor + public RedoAction() { + super(SourceViewPlugin.PLUGIN_NAME+ActionManager.REDO_SUFFIX); + }//}}} + + //{{{ getLabel() + public String getLabel() { + return Messages.getMessage("common.redo"); + }//}}} + + //{{{ invoke() + public void invoke(TabbedView view, ActionEvent evt) { + DocumentView docView = view.getDocumentView(); + if (docView instanceof SourceView) { + SourceView sourceView = (SourceView)docView; + ((SourceViewDocument)sourceView.getTextArea().getDocument()).redo(); + } + }//}}} + +} Property changes on: trunk/sourceview/src/sourceview/action/RedoAction.java ___________________________________________________________________ Name: svn:executable + * Added: trunk/sourceview/src/sourceview/action/UndoAction.java =================================================================== --- trunk/sourceview/src/sourceview/action/UndoAction.java (rev 0) +++ trunk/sourceview/src/sourceview/action/UndoAction.java 2006-08-05 21:41:13 UTC (rev 1106) @@ -0,0 +1,74 @@ +/* +UndoAction.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2006 Ian Lewis (Ian...@me...) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package sourceview.action; + +//{{{ imports + +import sourceview.*; + +//{{{ jsXe classes +import net.sourceforge.jsxe.jsXe; +import net.sourceforge.jsxe.ActionManager; +import net.sourceforge.jsxe.LocalizedAction; +import net.sourceforge.jsxe.gui.TabbedView; +import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.gui.DocumentView; +import net.sourceforge.jsxe.util.Log; +//}}} + +//{{{ AWT classes +import java.awt.event.ActionEvent; +//}}} + +//}}} + +/** + * This action that undoes the last action made in the source view. + * + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id$ + */ +public class UndoAction extends LocalizedAction { + + //{{{ UndoAction constructor + public UndoAction() { + super(SourceViewPlugin.PLUGIN_NAME+ActionManager.UNDO_SUFFIX); + }//}}} + + //{{{ getLabel() + public String getLabel() { + return Messages.getMessage("common.undo"); + }//}}} + + //{{{ invoke() + public void invoke(TabbedView view, ActionEvent evt) { + DocumentView docView = view.getDocumentView(); + if (docView instanceof SourceView) { + SourceView sourceView = (SourceView)docView; + ((SourceViewDocument)sourceView.getTextArea().getDocument()).undo(); + } + }//}}} + +} Property changes on: trunk/sourceview/src/sourceview/action/UndoAction.java ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-08-08 00:08:26
|
Revision: 1111 Author: ian_lewis Date: 2006-08-07 17:08:19 -0700 (Mon, 07 Aug 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1111&view=rev Log Message: ----------- Moved the edit menu to jsXe core and added a hack so that undo will work Modified Paths: -------------- trunk/sourceview/Changelog trunk/sourceview/src/sourceview/SourceView.java trunk/sourceview/src/sourceview/SourceViewDocument.java Modified: trunk/sourceview/Changelog =================================================================== --- trunk/sourceview/Changelog 2006-08-08 00:07:37 UTC (rev 1110) +++ trunk/sourceview/Changelog 2006-08-08 00:08:19 UTC (rev 1111) @@ -1,3 +1,7 @@ +08/07/2006 Ian Lewis <Ian...@me...> + + * Moved the edit menu to jsXe core and added a hack so that undo will work. + 07/26/2006 Ian Lewis <Ian...@me...> * Addded support for the findnext action Modified: trunk/sourceview/src/sourceview/SourceView.java =================================================================== --- trunk/sourceview/src/sourceview/SourceView.java 2006-08-08 00:07:37 UTC (rev 1110) +++ trunk/sourceview/src/sourceview/SourceView.java 2006-08-08 00:08:19 UTC (rev 1111) @@ -39,6 +39,8 @@ import net.sourceforge.jsxe.dom.XMLDocument; import net.sourceforge.jsxe.dom.XMLDocumentListener; import net.sourceforge.jsxe.msg.PropertyChanged; +import net.sourceforge.jsxe.msg.UndoEvent; +import net.sourceforge.jsxe.msg.RedoEvent; import net.sourceforge.jsxe.util.Log; import net.sourceforge.jsxe.util.MiscUtilities; //}}} @@ -151,30 +153,6 @@ setLayout(new BorderLayout()); add(m_textarea, BorderLayout.CENTER); - //{{{ Construct Edit Menu - m_editMenu = new JMenu(Messages.getMessage("Edit.Menu")); - m_editMenu.setMnemonic('E'); - // These don't do anything yet. - // JMenuItem menuItem = new JMenuItem("Undo"); - // menuItem.addActionListener( new EditUndoAction() ); - // menu.add( menuItem ); - // menuItem = new JMenuItem("Redo"); - // menuItem.addActionListener( new EditRedoAction() ); - // menu.add(menuItem); - // menu.addSeparator(); - menuItem = new JMenuItem(ActionManager.getAction("cut")); - m_editMenu.add(menuItem); - menuItem = new JMenuItem(ActionManager.getAction("copy")); - m_editMenu.add(menuItem); - menuItem = new JMenuItem(ActionManager.getAction("paste")); - m_editMenu.add(menuItem); - m_editMenu.addSeparator(); - menuItem = new JMenuItem(ActionManager.getAction("find")); - m_editMenu.add(menuItem); - menuItem = new JMenuItem(ActionManager.getAction("findnext")); - m_editMenu.add(menuItem); - //}}} - setDocumentBuffer(document); //focus on the text area the first time the view is shown @@ -223,6 +201,18 @@ SourceViewOptionPane.parseStyle(jsXe.getProperty("source.invalid.color")), }); } + } else { + if ((message instanceof UndoEvent) || (message instanceof RedoEvent)) { + //hack to get undo to work properly + try { + int caret = m_textarea.getCaretPosition(); + m_textarea.setDocument(new SourceViewDocument(m_document)); + m_textarea.setTokenMarker(new XMLTokenMarker()); + m_textarea.setCaretPosition(caret); + } catch (IOException ioe) { + Log.log(Log.ERROR, this, ioe); + } + } } }//}}} @@ -260,7 +250,7 @@ //{{{ getMenus() public JMenu[] getMenus() { - return new JMenu[] { m_editMenu }; + return null; }//}}} //{{{ getDocumentBuffer() @@ -420,8 +410,6 @@ private String m_replaceString; private SourceViewPlugin m_plugin; - private JMenu m_editMenu; - //}}} } Modified: trunk/sourceview/src/sourceview/SourceViewDocument.java =================================================================== --- trunk/sourceview/src/sourceview/SourceViewDocument.java 2006-08-08 00:07:37 UTC (rev 1110) +++ trunk/sourceview/src/sourceview/SourceViewDocument.java 2006-08-08 00:08:19 UTC (rev 1111) @@ -55,6 +55,7 @@ import javax.swing.text.GapContent; import javax.swing.text.SimpleAttributeSet; import javax.swing.text.StyleContext; +import javax.swing.undo.UndoableEdit; //}}} //{{{ DOM classes @@ -73,6 +74,7 @@ /** * The Document model used by the SourceView for displaying the text of * an XML document. + * * @author <a href="mailto:IanLewis at member dot fsf dot org">Ian Lewis</a> * @version $Id$ * @see SourceView @@ -138,7 +140,27 @@ //}}} + //{{{ beginCompoundEdit() + + public void beginCompoundEdit() { + m_document.beginCompoundEdit(); + }//}}} + + //{{{ endCompoundEdit() + + public void endCompoundEdit() { + m_document.endCompoundEdit(); + }//}}} + + //{{{ addUndoableEdit() + + public void addUndoableEdit(UndoableEdit edit) { + // Log.log(Log.DEBUG, this, "adding edit"); + // m_document.addUndoableEdit(edit); + }//}}} + //{{{ Private members + private XMLDocument m_document; //}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-08-31 20:43:04
|
Revision: 1216 http://svn.sourceforge.net/jsxe/?rev=1216&view=rev Author: ian_lewis Date: 2006-08-31 13:42:55 -0700 (Thu, 31 Aug 2006) Log Message: ----------- merge from 05pre3 branch rev. 1213 Modified Paths: -------------- trunk/sourceview/Changelog trunk/sourceview/src/sourceview/SourceView.java trunk/sourceview/src/sourceview/SourceViewPlugin.java trunk/sourceview/src/sourceview/action/EditCopyAction.java trunk/sourceview/src/sourceview/action/EditCutAction.java trunk/sourceview/src/sourceview/action/EditFindAction.java trunk/sourceview/src/sourceview/action/EditFindNextAction.java trunk/sourceview/src/sourceview/action/EditPasteAction.java Modified: trunk/sourceview/Changelog =================================================================== --- trunk/sourceview/Changelog 2006-08-31 20:41:42 UTC (rev 1215) +++ trunk/sourceview/Changelog 2006-08-31 20:42:55 UTC (rev 1216) @@ -1,3 +1,8 @@ +08/31/2006 Ian Lewis <Ian...@me...> + + * Updated the sourceview actions to use the new ContextSpecificActions in + jsXe. + 08/22/2006 Ian Lewis <Ian...@me...> * Changing the encoding now updates the SourceViewDocument so that it Modified: trunk/sourceview/src/sourceview/SourceView.java =================================================================== --- trunk/sourceview/src/sourceview/SourceView.java 2006-08-31 20:41:42 UTC (rev 1215) +++ trunk/sourceview/src/sourceview/SourceView.java 2006-08-31 20:42:55 UTC (rev 1216) @@ -25,12 +25,9 @@ package sourceview; //{{{ imports -/* -All classes are listed explicitly so -it is easy to see which package it -belongs to. -*/ +import sourceview.action.*; + //{{{ jsXe classes import net.sourceforge.jsxe.*; import net.sourceforge.jsxe.gui.Messages; @@ -132,6 +129,12 @@ m_textarea.putClientProperty(InputHandler.SMART_HOME_END_PROPERTY, Boolean.TRUE); + ActionManager.addActionImplementation("cut", m_textarea, new EditCutAction()); + ActionManager.addActionImplementation("copy", m_textarea, new EditCopyAction()); + ActionManager.addActionImplementation("paste", m_textarea, new EditPasteAction()); + ActionManager.addActionImplementation("find", m_textarea, new EditFindAction()); + ActionManager.addActionImplementation("findnext", m_textarea, new EditFindNextAction()); + //{{{ create popup menu JPopupMenu popup = new JPopupMenu(); @@ -238,6 +241,13 @@ dialog.dispose(); } m_document.removeXMLDocumentListener(docListener); + + ActionManager.removeActionImplementation("cut", m_textarea); + ActionManager.removeActionImplementation("copy", m_textarea); + ActionManager.removeActionImplementation("paste", m_textarea); + ActionManager.removeActionImplementation("find", m_textarea); + ActionManager.removeActionImplementation("findNext", m_textarea); + return true; }//}}} Modified: trunk/sourceview/src/sourceview/SourceViewPlugin.java =================================================================== --- trunk/sourceview/src/sourceview/SourceViewPlugin.java 2006-08-31 20:41:42 UTC (rev 1215) +++ trunk/sourceview/src/sourceview/SourceViewPlugin.java 2006-08-31 20:42:55 UTC (rev 1216) @@ -60,11 +60,6 @@ //{{{ SourceViewPlugin public SourceViewPlugin() { - addAction(new EditCutAction()); - addAction(new EditCopyAction()); - addAction(new EditPasteAction()); - addAction(new EditFindAction()); - addAction(new EditFindNextAction()); }//}}} //{{{ newDocumentView() Modified: trunk/sourceview/src/sourceview/action/EditCopyAction.java =================================================================== --- trunk/sourceview/src/sourceview/action/EditCopyAction.java 2006-08-31 20:41:42 UTC (rev 1215) +++ trunk/sourceview/src/sourceview/action/EditCopyAction.java 2006-08-31 20:42:55 UTC (rev 1216) @@ -30,14 +30,14 @@ //{{{ jsXe classes import net.sourceforge.jsxe.jsXe; -import net.sourceforge.jsxe.LocalizedAction; import net.sourceforge.jsxe.gui.TabbedView; -import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.action.ContextSpecificAction; import net.sourceforge.jsxe.gui.DocumentView; import net.sourceforge.jsxe.util.Log; //}}} //{{{ AWT classes +import java.awt.Component; import java.awt.event.ActionEvent; //}}} @@ -49,20 +49,10 @@ * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ */ -public class EditCopyAction extends LocalizedAction { +public class EditCopyAction implements ContextSpecificAction.ActionImplementation { - //{{{ EditCopyAction constructor - public EditCopyAction() { - super(SourceViewPlugin.PLUGIN_NAME+".copy"); - }//}}} - - //{{{ getLabel() - public String getLabel() { - return Messages.getMessage("common.copy"); - }//}}} - //{{{ invoke() - public void invoke(TabbedView view, ActionEvent evt) { + public void invoke(TabbedView view, Component comp, ActionEvent evt) { DocumentView docView = view.getDocumentView(); if (docView instanceof SourceView) { SourceView sourceView = (SourceView)docView; Modified: trunk/sourceview/src/sourceview/action/EditCutAction.java =================================================================== --- trunk/sourceview/src/sourceview/action/EditCutAction.java 2006-08-31 20:41:42 UTC (rev 1215) +++ trunk/sourceview/src/sourceview/action/EditCutAction.java 2006-08-31 20:42:55 UTC (rev 1216) @@ -30,14 +30,14 @@ //{{{ jsXe classes import net.sourceforge.jsxe.jsXe; -import net.sourceforge.jsxe.LocalizedAction; +import net.sourceforge.jsxe.action.ContextSpecificAction; import net.sourceforge.jsxe.gui.TabbedView; -import net.sourceforge.jsxe.gui.Messages; import net.sourceforge.jsxe.gui.DocumentView; import net.sourceforge.jsxe.util.Log; //}}} //{{{ AWT classes +import java.awt.Component; import java.awt.event.ActionEvent; //}}} @@ -49,20 +49,10 @@ * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ */ -public class EditCutAction extends LocalizedAction { +public class EditCutAction implements ContextSpecificAction.ActionImplementation { - //{{{ EditCutAction constructor - public EditCutAction() { - super(SourceViewPlugin.PLUGIN_NAME+".cut"); - }//}}} - - //{{{ getLabel() - public String getLabel() { - return Messages.getMessage("common.cut"); - }//}}} - //{{{ invoke() - public void invoke(TabbedView view, ActionEvent evt) { + public void invoke(TabbedView view, Component comp, ActionEvent evt) { DocumentView docView = view.getDocumentView(); if (docView instanceof SourceView) { SourceView sourceView = (SourceView)docView; Modified: trunk/sourceview/src/sourceview/action/EditFindAction.java =================================================================== --- trunk/sourceview/src/sourceview/action/EditFindAction.java 2006-08-31 20:41:42 UTC (rev 1215) +++ trunk/sourceview/src/sourceview/action/EditFindAction.java 2006-08-31 20:42:55 UTC (rev 1216) @@ -30,13 +30,13 @@ //{{{ jsXe classes import net.sourceforge.jsxe.jsXe; -import net.sourceforge.jsxe.LocalizedAction; +import net.sourceforge.jsxe.action.ContextSpecificAction; import net.sourceforge.jsxe.gui.TabbedView; -import net.sourceforge.jsxe.gui.Messages; import net.sourceforge.jsxe.gui.DocumentView; //}}} //{{{ AWT classes +import java.awt.Component; import java.awt.event.ActionEvent; //}}} @@ -48,20 +48,10 @@ * @version $Id$ */ -public class EditFindAction extends LocalizedAction { +public class EditFindAction implements ContextSpecificAction.ActionImplementation { - //{{{ EditFindAction constructor - public EditFindAction() { - super(SourceViewPlugin.PLUGIN_NAME+".find"); - }//}}} - - //{{{ getLabel() - public String getLabel() { - return Messages.getMessage("common.find"); - }//}}} - //{{{ invoke() - public void invoke(TabbedView view, ActionEvent evt) { + public void invoke(TabbedView view, Component comp, ActionEvent evt) { DocumentView docView = view.getDocumentView(); if (docView instanceof SourceView) { SourceView sourceView = (SourceView)docView; Modified: trunk/sourceview/src/sourceview/action/EditFindNextAction.java =================================================================== --- trunk/sourceview/src/sourceview/action/EditFindNextAction.java 2006-08-31 20:41:42 UTC (rev 1215) +++ trunk/sourceview/src/sourceview/action/EditFindNextAction.java 2006-08-31 20:42:55 UTC (rev 1216) @@ -30,13 +30,13 @@ //{{{ jsXe classes import net.sourceforge.jsxe.jsXe; -import net.sourceforge.jsxe.LocalizedAction; +import net.sourceforge.jsxe.action.ContextSpecificAction; import net.sourceforge.jsxe.gui.TabbedView; -import net.sourceforge.jsxe.gui.Messages; import net.sourceforge.jsxe.gui.DocumentView; //}}} //{{{ AWT classes +import java.awt.Component; import java.awt.event.ActionEvent; //}}} @@ -49,20 +49,10 @@ * @version $Id$ */ -public class EditFindNextAction extends LocalizedAction { +public class EditFindNextAction implements ContextSpecificAction.ActionImplementation { - //{{{ EditFindNextAction constructor - public EditFindNextAction() { - super(SourceViewPlugin.PLUGIN_NAME+".findnext"); - }//}}} - - //{{{ getLabel() - public String getLabel() { - return Messages.getMessage("common.findnext"); - }//}}} - //{{{ invoke() - public void invoke(TabbedView view, ActionEvent evt) { + public void invoke(TabbedView view, Component comp, ActionEvent evt) { DocumentView docView = view.getDocumentView(); if (docView instanceof SourceView) { SourceView sourceView = (SourceView)docView; Modified: trunk/sourceview/src/sourceview/action/EditPasteAction.java =================================================================== --- trunk/sourceview/src/sourceview/action/EditPasteAction.java 2006-08-31 20:41:42 UTC (rev 1215) +++ trunk/sourceview/src/sourceview/action/EditPasteAction.java 2006-08-31 20:42:55 UTC (rev 1216) @@ -30,14 +30,14 @@ //{{{ jsXe classes import net.sourceforge.jsxe.jsXe; -import net.sourceforge.jsxe.LocalizedAction; import net.sourceforge.jsxe.gui.TabbedView; -import net.sourceforge.jsxe.gui.Messages; -import net.sourceforge.jsxe.gui.DocumentView; +import net.sourceforge.jsxe.action.ContextSpecificAction; import net.sourceforge.jsxe.util.Log; +import net.sourceforge.jsxe.gui.DocumentView; //}}} //{{{ AWT classes +import java.awt.Component; import java.awt.event.ActionEvent; //}}} @@ -49,20 +49,10 @@ * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ */ -public class EditPasteAction extends LocalizedAction { +public class EditPasteAction implements ContextSpecificAction.ActionImplementation { - //{{{ EditPasteAction constructor - public EditPasteAction() { - super(SourceViewPlugin.PLUGIN_NAME+".paste"); - }//}}} - - //{{{ getLabel() - public String getLabel() { - return Messages.getMessage("common.paste"); - }//}}} - //{{{ invoke() - public void invoke(TabbedView view, ActionEvent evt) { + public void invoke(TabbedView view, Component comp, ActionEvent evt) { DocumentView docView = view.getDocumentView(); if (docView instanceof SourceView) { SourceView sourceView = (SourceView)docView; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-07 03:46:59
|
Revision: 996 Author: ian_lewis Date: 2006-07-06 20:46:52 -0700 (Thu, 06 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=996&view=rev Log Message: ----------- Added support for countries and language variants Modified Paths: -------------- trunk/sourceview/Changelog trunk/sourceview/build.xml Added Paths: ----------- trunk/sourceview/messages/messages Removed Paths: ------------- trunk/sourceview/messages/messages.en Modified: trunk/sourceview/Changelog =================================================================== --- trunk/sourceview/Changelog 2006-07-07 03:46:37 UTC (rev 995) +++ trunk/sourceview/Changelog 2006-07-07 03:46:52 UTC (rev 996) @@ -1,3 +1,7 @@ +07/06/2006 Ian Lewis <Ian...@me...> + + * Updated to support the new Messages format. + 06/23/2006 Ian Lewis <Ian...@me...> * Added back rudimentary key bindings using Swing Actions so they get Modified: trunk/sourceview/build.xml =================================================================== --- trunk/sourceview/build.xml 2006-07-07 03:46:37 UTC (rev 995) +++ trunk/sourceview/build.xml 2006-07-07 03:46:52 UTC (rev 996) @@ -69,7 +69,7 @@ <mkdir dir="${build.messages}"/> <copy todir="${build.messages}"> <fileset dir="${messages.dir}"> - <include name="**/messages.*"/> + <include name="**/messages*"/> </fileset> </copy> </target> @@ -133,7 +133,7 @@ <jar jarfile="${root.dir}/../${app.name}.jar" manifest="${app.name}.manifest"> <fileset dir="${build.dir}"> - <include name="messages/messages.*"/> + <include name="messages/messages*"/> </fileset> <fileset dir="${build.dest}"> <include name="**/*.class"/> Copied: trunk/sourceview/messages/messages (from rev 989, trunk/sourceview/messages/messages.en) =================================================================== --- trunk/sourceview/messages/messages (rev 0) +++ trunk/sourceview/messages/messages 2006-07-07 03:46:52 UTC (rev 996) @@ -0,0 +1,27 @@ +# JSXE source view English properties file +# $Id$ +#:mode=properties: +#:tabSize=4:indentSize=4:noTabs=true: +#:folding=explicit:collapseFolds=1 + +#{{{ Source View + +#{{{ Source View Options +SourceView.Options.Title=Source View +SourceView.Options.EndOfLineMarker=End of line markers +SourceView.Syntax.Object=Node Type +SourceView.Syntax.Style=Text Style +SourceView.ColorChooser.Title=Color Chooser +SourceView.Markup=Markup +SourceView.Invalid=Invalid +#}}} + +#{{{ Style Editor +SourceView.StyleEditor.Title=Style Editor +SourceView.StyleEditor.Color=Text Color +SourceView.StyleEditor.Bold=Bold +SourceView.StyleEditor.Italics=Italics +#}}} + +#}}} + Deleted: trunk/sourceview/messages/messages.en =================================================================== --- trunk/sourceview/messages/messages.en 2006-07-07 03:46:37 UTC (rev 995) +++ trunk/sourceview/messages/messages.en 2006-07-07 03:46:52 UTC (rev 996) @@ -1,27 +0,0 @@ -# JSXE source view English properties file -# $Id$ -#:mode=properties: -#:tabSize=4:indentSize=4:noTabs=true: -#:folding=explicit:collapseFolds=1 - -#{{{ Source View - -#{{{ Source View Options -SourceView.Options.Title=Source View -SourceView.Options.EndOfLineMarker=End of line markers -SourceView.Syntax.Object=Node Type -SourceView.Syntax.Style=Text Style -SourceView.ColorChooser.Title=Color Chooser -SourceView.Markup=Markup -SourceView.Invalid=Invalid -#}}} - -#{{{ Style Editor -SourceView.StyleEditor.Title=Style Editor -SourceView.StyleEditor.Color=Text Color -SourceView.StyleEditor.Bold=Bold -SourceView.StyleEditor.Italics=Italics -#}}} - -#}}} - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-20 23:46:33
|
Revision: 1048 Author: ian_lewis Date: 2006-07-20 16:46:29 -0700 (Thu, 20 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1048&view=rev Log Message: ----------- Fixed default syntax highlighting colors Modified Paths: -------------- trunk/sourceview/Changelog trunk/sourceview/src/sourceview/SourceViewOptionPane.java Modified: trunk/sourceview/Changelog =================================================================== --- trunk/sourceview/Changelog 2006-07-20 23:44:21 UTC (rev 1047) +++ trunk/sourceview/Changelog 2006-07-20 23:46:29 UTC (rev 1048) @@ -1,6 +1,7 @@ 07/20/2006 Ian Lewis <Ian...@me...> * Added Japanese translation + * Fixed syntax highlighting colors when you first load jsXe 07/06/2006 Ian Lewis <Ian...@me...> Modified: trunk/sourceview/src/sourceview/SourceViewOptionPane.java =================================================================== --- trunk/sourceview/src/sourceview/SourceViewOptionPane.java 2006-07-20 23:44:21 UTC (rev 1047) +++ trunk/sourceview/src/sourceview/SourceViewOptionPane.java 2006-07-20 23:46:29 UTC (rev 1048) @@ -384,18 +384,18 @@ //{{{ StyleTableModel constructor public StyleTableModel() { styleChoices = new Vector(9); - addStyleChoice("SourceView.Markup", "source.markup.color"); - addStyleChoice("xml.namespace.prefix", "source.namespace.prefix.color"); - addStyleChoice("xml.text","source.text.color"); - addStyleChoice("xml.element","source.element.color"); - addStyleChoice("xml.attribute","source.attribute.color"); - addStyleChoice("xml.attribute.value", "source.attribute.value.color"); - addStyleChoice("xml.cdata","source.cdata.color"); - addStyleChoice("xml.processing.instruction","source.processing.instruction.color"); - addStyleChoice("xml.entity.reference","source.entity.reference.color"); - addStyleChoice("xml.comment","source.comment.color"); - addStyleChoice("xml.doctype","source.doctype.color"); - addStyleChoice("SourceView.Invalid", "source.invalid.color"); + addStyleChoice("SourceView.Markup", "sourceview.markup.color"); + addStyleChoice("xml.namespace.prefix", "sourceview.namespace.prefix.color"); + addStyleChoice("xml.text", "sourceview.text.color"); + addStyleChoice("xml.element", "sourceview.element.color"); + addStyleChoice("xml.attribute", "sourceview.attribute.color"); + addStyleChoice("xml.attribute.value", "sourceview.attribute.value.color"); + addStyleChoice("xml.cdata", "sourceview.cdata.color"); + addStyleChoice("xml.processing.instruction", "sourceview.processing.instruction.color"); + addStyleChoice("xml.entity.reference", "sourceview.entity.reference.color"); + addStyleChoice("xml.comment", "sourceview.comment.color"); + addStyleChoice("xml.doctype", "sourceview.doctype.color"); + addStyleChoice("SourceView.Invalid", "sourceview.invalid.color"); MiscUtilities.quicksort(styleChoices, new MiscUtilities.StringCompare()); } //}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-21 20:01:40
|
Revision: 1050 Author: ian_lewis Date: 2006-07-21 11:39:45 -0700 (Fri, 21 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1050&view=rev Log Message: ----------- Added better horizontal scrolling support Modified Paths: -------------- trunk/sourceview/Changelog trunk/sourceview/src/org/syntax/jedit/JEditTextArea.java trunk/sourceview/src/org/syntax/jedit/TextAreaPainter.java Modified: trunk/sourceview/Changelog =================================================================== --- trunk/sourceview/Changelog 2006-07-21 16:19:06 UTC (rev 1049) +++ trunk/sourceview/Changelog 2006-07-21 18:39:45 UTC (rev 1050) @@ -1,3 +1,9 @@ +07/21/2006 Ian Lewis <Ian...@me...> + + * Added better horizontal scrolling support. It isn't perfect because + it's hard to know the true width of the line because parts of it + can have bold text while other parts don't. + 07/20/2006 Ian Lewis <Ian...@me...> * Added Japanese translation Modified: trunk/sourceview/src/org/syntax/jedit/JEditTextArea.java =================================================================== --- trunk/sourceview/src/org/syntax/jedit/JEditTextArea.java 2006-07-21 16:19:06 UTC (rev 1049) +++ trunk/sourceview/src/org/syntax/jedit/JEditTextArea.java 2006-07-21 18:39:45 UTC (rev 1050) @@ -251,19 +251,17 @@ * if the number of lines in the document changes, or when the * size of the text are changes. */ - public void updateScrollBars() - { - if(vertical != null && visibleLines != 0) - { + public void updateScrollBars() { + if (vertical != null && visibleLines != 0) { vertical.setValues(firstLine,visibleLines,0,getLineCount()); vertical.setUnitIncrement(2); vertical.setBlockIncrement(visibleLines); } - int width = painter.getWidth(); - if(horizontal != null && width != 0) - { - horizontal.setValues(-horizontalOffset,width,0,width * 5); + if (horizontal != null && width != 0) { + // Log.log(Log.DEBUG, this, "value: "+ (-horizontalOffset)); + + horizontal.setValue(-horizontalOffset); horizontal.setUnitIncrement(painter.getFontMetrics().charWidth('w')); horizontal.setBlockIncrement(width / 2); } @@ -328,13 +326,14 @@ * implement horizontal scrolling. * @param horizontalOffset offset The new horizontal offset */ - public void setHorizontalOffset(int horizontalOffset) - { - if(horizontalOffset == this.horizontalOffset) + public void setHorizontalOffset(int horizontalOffset) { + if (horizontalOffset == this.horizontalOffset) { return; + } this.horizontalOffset = horizontalOffset; - if(horizontalOffset != horizontal.getValue()) + if (horizontalOffset != horizontal.getValue()) { updateScrollBars(); + } painter.repaint(); } @@ -1602,6 +1601,8 @@ protected int magicCaret; protected boolean overwrite; protected boolean rectSelect; + + private int maxHorizontalScrollWidth; protected void fireCaretEvent() { @@ -2130,6 +2131,51 @@ return false; } } + + //{{{ updateMaxHorizontalScrollWidth() method + void updateMaxHorizontalScrollWidth() { + + int max = 0; + + for (int i = firstLine; i < firstLine + visibleLines; i++) { + /* + TODO: This is broken since some parts of the line can be bold and + thus be wider than other parts of the line. Need to implement + a chunk cache like jEdit has. + */ + int width = (int)Math.round( + painter.getFont().getStringBounds(getLineText(i), + new java.awt.font.FontRenderContext(null,false,false)).getWidth()); + if (width > max) { + max = width; + } + } + + int _tabSize = ((Integer)getDocument().getProperty(PlainDocument.tabSizeAttribute)).intValue(); + char[] foo = new char[] { ' ' }; + + int charWidth = (int)Math.round( + painter.getFont().getStringBounds(foo,0,1, + new java.awt.font.FontRenderContext(null,false,false)).getWidth()); + + // Log.log(Log.DEBUG, this, "value: "+ Math.max(0, + // Math.min(maxHorizontalScrollWidth /*+ charWidth*/ + // - painter.getWidth(), + // -horizontalOffset)) + // +" extent: "+painter.getWidth() + // +" min: "+0 + // +" max: "+max); + if (max != maxHorizontalScrollWidth) { + maxHorizontalScrollWidth = max; + horizontal.setValues(Math.max(0, + Math.min(maxHorizontalScrollWidth /*+ charWidth*/ + - painter.getWidth(), + -horizontalOffset)), + painter.getWidth(), + 0,maxHorizontalScrollWidth + /*+ charWidth*/); + } + } //}}} //{{{ WheelScrollListener class static class MouseWheelHandler implements MouseWheelListener { Modified: trunk/sourceview/src/org/syntax/jedit/TextAreaPainter.java =================================================================== --- trunk/sourceview/src/org/syntax/jedit/TextAreaPainter.java 2006-07-21 16:19:06 UTC (rev 1049) +++ trunk/sourceview/src/org/syntax/jedit/TextAreaPainter.java 2006-07-21 18:39:45 UTC (rev 1050) @@ -1,14 +1,32 @@ /* - * TextAreaPainter.java - Paints the text area - * Copyright (C) 1999 Slava Pestov - * - * 08/05/2002 Cursor (caret) rendering fixed for JDK 1.4 (Anonymous) - * - * You may use and modify this package for any purpose. Redistribution is - * permitted, in both source and binary form, provided that this notice - * remains intact in all source distributions of this package. - */ +TextAreaPainter.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: +Copyright (C) 1999 Slava Pestov +Copyright (C) 2002 Ian Lewis (Ian...@me...) + +You may use and modify this package for any purpose. Redistribution is +permitted, in both source and binary form, provided that this notice +remains intact in all source distributions of this package. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + package org.syntax.jedit; import org.syntax.jedit.tokenmarker.*; @@ -25,6 +43,8 @@ * The text area repaint manager. It performs double buffering and paints * lines of text. * @author Slava Pestov + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * * @version $Id$ */ public class TextAreaPainter extends JComponent implements TabExpander @@ -47,7 +67,7 @@ currentLineIndex = -1; setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); - + setFont(new Font("Monospaced",Font.PLAIN,14)); setForeground(Color.black); setBackground(Color.white); @@ -66,7 +86,28 @@ eolMarkerColor = defaults.eolMarkerColor; eolMarkers = defaults.eolMarkers; } + + //{{{ setBounds() method + /** + * It is a bad idea to override this, but we need to get the component + * event before the first repaint. + */ + public void setBounds(int x, int y, int width, int height) { + if (x == getX() && y == getY() && width == getWidth() && height == getHeight()) { + return; + } + super.setBounds(x,y,width,height); + + textArea.recalculateVisibleLines(); + // if (textArea.getBuffer().isLoaded()) { + // textArea.recalculateLastPhysicalLine(); + // } + // textArea.propertiesChanged(); + textArea.updateMaxHorizontalScrollWidth(); + textArea.scrollBarsInitialized = true; + } //}}} + /** * Returns if this component can be traversed by pressing the * Tab key. This returns false. @@ -352,8 +393,7 @@ * cached font metrics and to recalculate which lines are visible. * @param font The font */ - public void setFont(Font font) - { + public void setFont(Font font) { super.setFont(font); //TODO: this is deprecated, figure out how to do it the right way. fm = Toolkit.getDefaultToolkit().getFontMetrics(font); @@ -364,10 +404,8 @@ * Repaints the text. * @param g The graphics context */ - public void paint(Graphics gfx) - { - tabSize = fm.charWidth(' ') * ((Integer)textArea - .getDocument().getProperty( + public void paint(Graphics gfx) { + tabSize = fm.charWidth(' ') * ((Integer)textArea.getDocument().getProperty( PlainDocument.tabSizeAttribute)).intValue(); Rectangle clipRect = gfx.getClipBounds(); @@ -385,25 +423,22 @@ // too many lines will always be painted. int lastInvalid = firstLine + (clipRect.y + clipRect.height - 1) / height; - try - { - TokenMarker tokenMarker = textArea.getDocument() - .getTokenMarker(); + try { + TokenMarker tokenMarker = textArea.getDocument().getTokenMarker(); int x = textArea.getHorizontalOffset(); - for(int line = firstInvalid; line <= lastInvalid; line++) - { + for(int line = firstInvalid; line <= lastInvalid; line++) { paintLine(gfx,tokenMarker,line,x); } - if(tokenMarker != null && tokenMarker.isNextLineRequested()) - { + if (tokenMarker != null && tokenMarker.isNextLineRequested()) { int h = clipRect.y + clipRect.height; repaint(0,h,getWidth(),getHeight() - h); } - } - catch(Exception e) - { + + textArea.updateMaxHorizontalScrollWidth(); + + } catch(Exception e) { System.err.println("Error repainting line" + " range {" + firstInvalid + "," + lastInvalid + "}:"); @@ -502,7 +537,7 @@ protected FontMetrics fm; protected Highlight highlights; - + protected void paintLine(Graphics gfx, TokenMarker tokenMarker, int line, int x) { @@ -696,7 +731,7 @@ fm.getHeight() - 1); } -protected void paintCaret(Graphics gfx, int line, int y) + protected void paintCaret(Graphics gfx, int line, int y) { if(textArea.isCaretVisible()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-08-07 21:54:12
|
Revision: 1108 Author: ian_lewis Date: 2006-08-07 14:53:57 -0700 (Mon, 07 Aug 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1108&view=rev Log Message: ----------- Backed out changes for undo in the source view Modified Paths: -------------- trunk/sourceview/Changelog trunk/sourceview/src/sourceview/SourceView.java trunk/sourceview/src/sourceview/SourceViewDocument.java trunk/sourceview/src/sourceview/SourceViewPlugin.java Removed Paths: ------------- trunk/sourceview/src/sourceview/action/RedoAction.java trunk/sourceview/src/sourceview/action/UndoAction.java Modified: trunk/sourceview/Changelog =================================================================== --- trunk/sourceview/Changelog 2006-08-07 19:50:51 UTC (rev 1107) +++ trunk/sourceview/Changelog 2006-08-07 21:53:57 UTC (rev 1108) @@ -1,7 +1,3 @@ -08/05/2006 Ian Lewis <Ian...@me...> - - * Added undo to the source view - 07/26/2006 Ian Lewis <Ian...@me...> * Addded support for the findnext action Modified: trunk/sourceview/src/sourceview/SourceView.java =================================================================== --- trunk/sourceview/src/sourceview/SourceView.java 2006-08-07 19:50:51 UTC (rev 1107) +++ trunk/sourceview/src/sourceview/SourceView.java 2006-08-07 21:53:57 UTC (rev 1108) @@ -155,11 +155,13 @@ m_editMenu = new JMenu(Messages.getMessage("Edit.Menu")); m_editMenu.setMnemonic('E'); // These don't do anything yet. - menuItem = new JMenuItem(ActionManager.getAction("undo")); - m_editMenu.add( menuItem ); - menuItem = new JMenuItem(ActionManager.getAction("redo")); - m_editMenu.add(menuItem); - m_editMenu.addSeparator(); + // JMenuItem menuItem = new JMenuItem("Undo"); + // menuItem.addActionListener( new EditUndoAction() ); + // menu.add( menuItem ); + // menuItem = new JMenuItem("Redo"); + // menuItem.addActionListener( new EditRedoAction() ); + // menu.add(menuItem); + // menu.addSeparator(); menuItem = new JMenuItem(ActionManager.getAction("cut")); m_editMenu.add(menuItem); menuItem = new JMenuItem(ActionManager.getAction("copy")); Modified: trunk/sourceview/src/sourceview/SourceViewDocument.java =================================================================== --- trunk/sourceview/src/sourceview/SourceViewDocument.java 2006-08-07 19:50:51 UTC (rev 1107) +++ trunk/sourceview/src/sourceview/SourceViewDocument.java 2006-08-07 21:53:57 UTC (rev 1108) @@ -55,10 +55,6 @@ import javax.swing.text.GapContent; import javax.swing.text.SimpleAttributeSet; import javax.swing.text.StyleContext; -import javax.swing.event.DocumentEvent; -import javax.swing.event.UndoableEditListener; -import javax.swing.event.UndoableEditEvent; -import javax.swing.undo.*; //}}} //{{{ DOM classes @@ -100,103 +96,50 @@ //buffer is actually loaded in the text area at any //given time(?) super.insertString(0, document.getText(0,document.getLength()), null); - m_initialized = true; } catch (BadLocationException ble) { Log.log(Log.ERROR, this, ble); } } - - addUndoableEditListener(new UndoableEditListener() { - public void undoableEditHappened(UndoableEditEvent e) { - m_undoManager.addEdit(e.getEdit()); - } - }); }//}}} //{{{ DefaultStyledDocument methods - // //{{{ insertString() + //{{{ insertString() - // public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { - // Log.log(Log.DEBUG, this, "insert: "+str); - // try { - // super.insertString(offs, str, a); - // m_document.insertText(offs, str); - // } catch (DOMException dome) { - // Log.log(Log.ERROR, this, dome); - // Toolkit.getDefaultToolkit().beep(); - // } catch (IOException ioe) { - // Log.log(Log.ERROR, this, ioe); - // } - - // }//}}} - - // //{{{ remove() - - // public void remove(int offs, int len) throws BadLocationException { - // Log.log(Log.DEBUG, this, "remove"); - // try { - // super.remove(offs, len); - // m_document.removeText(offs, len); - // } catch (DOMException dome) { - // Log.log(Log.ERROR, this, dome); - // Toolkit.getDefaultToolkit().beep(); - // } catch (IOException ioe) { - // Log.log(Log.ERROR, this, ioe); - // } + public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { - // }//}}} - - protected void fireInsertUpdate(DocumentEvent e) { try { - Log.log(Log.DEBUG, this, "insert: "+getText(e.getOffset(), e.getLength())); - if (m_initialized) { - m_document.insertText(e.getOffset(), getText(e.getOffset(), e.getLength())); - } - super.fireInsertUpdate(e); + super.insertString(offs, str, a); + m_document.insertText(offs, str); + } catch (DOMException dome) { + Log.log(Log.ERROR, this, dome); + Toolkit.getDefaultToolkit().beep(); } catch (IOException ioe) { Log.log(Log.ERROR, this, ioe); - } catch (BadLocationException ble) { - Log.log(Log.ERROR, this, ble); } - } + + }//}}} + + //{{{ remove() - protected void fireRemoveUpdate(DocumentEvent e) { + public void remove(int offs, int len) throws BadLocationException { + try { - Log.log(Log.DEBUG, this, "remove: "+e.getOffset()+":"+e.getLength()); - if (m_initialized) { - m_document.removeText(e.getOffset(), e.getLength()); - } - super.fireRemoveUpdate(e); + super.remove(offs, len); + m_document.removeText(offs, len); + } catch (DOMException dome) { + Log.log(Log.ERROR, this, dome); + Toolkit.getDefaultToolkit().beep(); } catch (IOException ioe) { Log.log(Log.ERROR, this, ioe); } - } - + + }//}}} + //}}} - //{{{ undo() - public void undo() { - try { - m_undoManager.undo(); - } catch (CannotUndoException e) { - Log.log(Log.WARNING, this, "Cannot undo"); - } - }//}}} - - //{{{ redo() - public void redo() throws CannotUndoException { - try { - m_undoManager.redo(); - } catch (CannotUndoException e) { - Log.log(Log.WARNING, this, "Cannot redo"); - } - }//}}} - //{{{ Private members - private boolean m_initialized = false; private XMLDocument m_document; - private UndoManager m_undoManager = new UndoManager(); //}}} } Modified: trunk/sourceview/src/sourceview/SourceViewPlugin.java =================================================================== --- trunk/sourceview/src/sourceview/SourceViewPlugin.java 2006-08-07 19:50:51 UTC (rev 1107) +++ trunk/sourceview/src/sourceview/SourceViewPlugin.java 2006-08-07 21:53:57 UTC (rev 1108) @@ -65,8 +65,6 @@ addAction(new EditPasteAction()); addAction(new EditFindAction()); addAction(new EditFindNextAction()); - addAction(new UndoAction()); - addAction(new RedoAction()); }//}}} //{{{ newDocumentView() Deleted: trunk/sourceview/src/sourceview/action/RedoAction.java =================================================================== --- trunk/sourceview/src/sourceview/action/RedoAction.java 2006-08-07 19:50:51 UTC (rev 1107) +++ trunk/sourceview/src/sourceview/action/RedoAction.java 2006-08-07 21:53:57 UTC (rev 1108) @@ -1,74 +0,0 @@ -/* -RedoAction.java -:tabSize=4:indentSize=4:noTabs=true: -:folding=explicit:collapseFolds=1: - -Copyright (C) 2006 Ian Lewis (Ian...@me...) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -Optionally, you may find a copy of the GNU General Public License -from http://www.fsf.org/copyleft/gpl.txt -*/ - -package sourceview.action; - -//{{{ imports - -import sourceview.*; - -//{{{ jsXe classes -import net.sourceforge.jsxe.jsXe; -import net.sourceforge.jsxe.ActionManager; -import net.sourceforge.jsxe.LocalizedAction; -import net.sourceforge.jsxe.gui.TabbedView; -import net.sourceforge.jsxe.gui.Messages; -import net.sourceforge.jsxe.gui.DocumentView; -import net.sourceforge.jsxe.util.Log; -//}}} - -//{{{ AWT classes -import java.awt.event.ActionEvent; -//}}} - -//}}} - -/** - * This action that redoes the last action made in the source view. - * - * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) - * @version $Id$ - */ -public class RedoAction extends LocalizedAction { - - //{{{ RedoAction constructor - public RedoAction() { - super(SourceViewPlugin.PLUGIN_NAME+ActionManager.REDO_SUFFIX); - }//}}} - - //{{{ getLabel() - public String getLabel() { - return Messages.getMessage("common.redo"); - }//}}} - - //{{{ invoke() - public void invoke(TabbedView view, ActionEvent evt) { - DocumentView docView = view.getDocumentView(); - if (docView instanceof SourceView) { - SourceView sourceView = (SourceView)docView; - ((SourceViewDocument)sourceView.getTextArea().getDocument()).redo(); - } - }//}}} - -} Deleted: trunk/sourceview/src/sourceview/action/UndoAction.java =================================================================== --- trunk/sourceview/src/sourceview/action/UndoAction.java 2006-08-07 19:50:51 UTC (rev 1107) +++ trunk/sourceview/src/sourceview/action/UndoAction.java 2006-08-07 21:53:57 UTC (rev 1108) @@ -1,74 +0,0 @@ -/* -UndoAction.java -:tabSize=4:indentSize=4:noTabs=true: -:folding=explicit:collapseFolds=1: - -Copyright (C) 2006 Ian Lewis (Ian...@me...) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -Optionally, you may find a copy of the GNU General Public License -from http://www.fsf.org/copyleft/gpl.txt -*/ - -package sourceview.action; - -//{{{ imports - -import sourceview.*; - -//{{{ jsXe classes -import net.sourceforge.jsxe.jsXe; -import net.sourceforge.jsxe.ActionManager; -import net.sourceforge.jsxe.LocalizedAction; -import net.sourceforge.jsxe.gui.TabbedView; -import net.sourceforge.jsxe.gui.Messages; -import net.sourceforge.jsxe.gui.DocumentView; -import net.sourceforge.jsxe.util.Log; -//}}} - -//{{{ AWT classes -import java.awt.event.ActionEvent; -//}}} - -//}}} - -/** - * This action that undoes the last action made in the source view. - * - * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) - * @version $Id$ - */ -public class UndoAction extends LocalizedAction { - - //{{{ UndoAction constructor - public UndoAction() { - super(SourceViewPlugin.PLUGIN_NAME+ActionManager.UNDO_SUFFIX); - }//}}} - - //{{{ getLabel() - public String getLabel() { - return Messages.getMessage("common.undo"); - }//}}} - - //{{{ invoke() - public void invoke(TabbedView view, ActionEvent evt) { - DocumentView docView = view.getDocumentView(); - if (docView instanceof SourceView) { - SourceView sourceView = (SourceView)docView; - ((SourceViewDocument)sourceView.getTextArea().getDocument()).undo(); - } - }//}}} - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-08-27 13:42:30
|
Revision: 1166 Author: ian_lewis Date: 2006-08-27 06:37:28 -0700 (Sun, 27 Aug 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1166&view=rev Log Message: ----------- merge from the 0.5pre3 branch Modified Paths: -------------- trunk/sourceview/Changelog trunk/sourceview/messages/messages.ru trunk/sourceview/src/sourceview/SourceView.java trunk/sourceview/src/sourceview/SourceViewDocument.java Modified: trunk/sourceview/Changelog =================================================================== --- trunk/sourceview/Changelog 2006-08-27 13:30:41 UTC (rev 1165) +++ trunk/sourceview/Changelog 2006-08-27 13:37:28 UTC (rev 1166) @@ -1,3 +1,13 @@ +08/22/2006 Ian Lewis <Ian...@me...> + + * Changing the encoding now updates the SourceViewDocument so that it + doesn't cause the SourceViewDocument to get out of sync with the + XMLDocument. + +08/21/2006 Ian Lewis <Ian...@me...> + + * Updated russian translation. + 08/07/2006 Ian Lewis <Ian...@me...> * Moved the edit menu to jsXe core and added a hack so that undo will work. Modified: trunk/sourceview/messages/messages.ru =================================================================== --- trunk/sourceview/messages/messages.ru 2006-08-27 13:30:41 UTC (rev 1165) +++ trunk/sourceview/messages/messages.ru 2006-08-27 13:37:28 UTC (rev 1166) @@ -1,10 +1,10 @@ -# JSXE source view English properties file +# JSXE source view English properties file # $Id: messages 1068 2006-07-26 16:57:45Z ian_lewis $ -# Maintained by Alexandr Gridnev (ale...@ya...) -#:mode=properties: -#:tabSize=4:indentSize=4:noTabs=true: -#:folding=explicit:collapseFolds=1 - +# Maintained by Alexandr Gridnev (ale...@ya...) +#:mode=properties: +#:tabSize=4:indentSize=4:noTabs=true: +#:folding=explicit:collapseFolds=1 + #{{{ Source View Options SourceView.Options.Title=Отображение исходником SourceView.Options.EndOfLineMarker=Отображать символы конца строки @@ -29,6 +29,6 @@ SourceView.Replace.With=Заменить на: SourceView.Replace.And.Find=Найти и заменить SourceView.No.More.Matches.title=Дальше не найдено :( -SourceView.No.More.Matches.message="Ничего не найдено. Искать с начала документа?" -SourceView.Search.Error.title=Ошибка поиска 0_0 +SourceView.No.More.Matches.message="Ничего не найдено. Искать с начала документа?" +SourceView.Search.Error.title=Ошибка поиска :( #}}} Modified: trunk/sourceview/src/sourceview/SourceView.java =================================================================== --- trunk/sourceview/src/sourceview/SourceView.java 2006-08-27 13:30:41 UTC (rev 1165) +++ trunk/sourceview/src/sourceview/SourceView.java 2006-08-27 13:37:28 UTC (rev 1166) @@ -311,6 +311,15 @@ Log.log(Log.WARNING, this, e.getMessage()); } } + if (key.equals(XMLDocument.ENCODING)) { + try { + //reload the document + m_textarea.setDocument(new SourceViewDocument(m_document)); + m_textarea.setTokenMarker(new XMLTokenMarker()); + } catch (IOException e) { + Log.log(Log.ERROR, this, e); + } + } }//}}} //{{{ structureChanged Modified: trunk/sourceview/src/sourceview/SourceViewDocument.java =================================================================== --- trunk/sourceview/src/sourceview/SourceViewDocument.java 2006-08-27 13:30:41 UTC (rev 1165) +++ trunk/sourceview/src/sourceview/SourceViewDocument.java 2006-08-27 13:37:28 UTC (rev 1166) @@ -87,8 +87,6 @@ super(); m_document = document; - // document.addXMLDocumentListener(new SourceViewDocumentXMLDocumentListener()); - if (document != null) { try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |